@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
|
@@ -441,6 +441,11 @@ function normalizeAutoUpdate(raw) {
|
|
|
441
441
|
const userAU = raw.autoUpdate ?? {};
|
|
442
442
|
raw.autoUpdate = { ...defaultAU, ...userAU };
|
|
443
443
|
}
|
|
444
|
+
function normalizeOrchestration(raw) {
|
|
445
|
+
const defaultOrg = DEFAULT_CONFIG.orchestration;
|
|
446
|
+
const userOrg = raw.orchestration ?? {};
|
|
447
|
+
raw.orchestration = { ...defaultOrg, ...userOrg };
|
|
448
|
+
}
|
|
444
449
|
async function loadConfig() {
|
|
445
450
|
const dir = process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? EXE_AI_DIR;
|
|
446
451
|
await ensurePrivateDir(dir);
|
|
@@ -465,10 +470,15 @@ async function loadConfig() {
|
|
|
465
470
|
normalizeScalingRoadmap(migratedCfg);
|
|
466
471
|
normalizeSessionLifecycle(migratedCfg);
|
|
467
472
|
normalizeAutoUpdate(migratedCfg);
|
|
473
|
+
normalizeOrchestration(migratedCfg);
|
|
468
474
|
const config = { ...DEFAULT_CONFIG, dbPath: path2.join(dir, "memories.db"), ...migratedCfg };
|
|
469
475
|
if (config.dbPath.startsWith("~")) {
|
|
470
476
|
config.dbPath = config.dbPath.replace(/^~/, os2.homedir());
|
|
471
477
|
}
|
|
478
|
+
const envDbPath = path2.join(dir, "memories.db");
|
|
479
|
+
if (process.env.EXE_OS_DIR && config.dbPath !== envDbPath && !existsSync3(config.dbPath) && existsSync3(envDbPath)) {
|
|
480
|
+
config.dbPath = envDbPath;
|
|
481
|
+
}
|
|
472
482
|
return config;
|
|
473
483
|
} catch {
|
|
474
484
|
return { ...DEFAULT_CONFIG, dbPath: path2.join(dir, "memories.db") };
|
|
@@ -488,7 +498,16 @@ function loadConfigSync() {
|
|
|
488
498
|
normalizeScalingRoadmap(migratedCfg);
|
|
489
499
|
normalizeSessionLifecycle(migratedCfg);
|
|
490
500
|
normalizeAutoUpdate(migratedCfg);
|
|
491
|
-
|
|
501
|
+
normalizeOrchestration(migratedCfg);
|
|
502
|
+
const config = { ...DEFAULT_CONFIG, dbPath: path2.join(dir, "memories.db"), ...migratedCfg };
|
|
503
|
+
if (config.dbPath.startsWith("~")) {
|
|
504
|
+
config.dbPath = config.dbPath.replace(/^~/, os2.homedir());
|
|
505
|
+
}
|
|
506
|
+
const envDbPath = path2.join(dir, "memories.db");
|
|
507
|
+
if (process.env.EXE_OS_DIR && config.dbPath !== envDbPath && !existsSync3(config.dbPath) && existsSync3(envDbPath)) {
|
|
508
|
+
config.dbPath = envDbPath;
|
|
509
|
+
}
|
|
510
|
+
return config;
|
|
492
511
|
} catch {
|
|
493
512
|
return { ...DEFAULT_CONFIG, dbPath: path2.join(dir, "memories.db") };
|
|
494
513
|
}
|
|
@@ -509,6 +528,7 @@ async function loadConfigFrom(configPath) {
|
|
|
509
528
|
normalizeScalingRoadmap(migratedCfg);
|
|
510
529
|
normalizeSessionLifecycle(migratedCfg);
|
|
511
530
|
normalizeAutoUpdate(migratedCfg);
|
|
531
|
+
normalizeOrchestration(migratedCfg);
|
|
512
532
|
return { ...DEFAULT_CONFIG, ...migratedCfg };
|
|
513
533
|
} catch {
|
|
514
534
|
return { ...DEFAULT_CONFIG };
|
|
@@ -580,6 +600,10 @@ var init_config = __esm({
|
|
|
580
600
|
checkOnBoot: true,
|
|
581
601
|
autoInstall: false,
|
|
582
602
|
checkIntervalMs: 24 * 60 * 60 * 1e3
|
|
603
|
+
},
|
|
604
|
+
orchestration: {
|
|
605
|
+
phase: "phase_1_coo",
|
|
606
|
+
phaseSetBy: "default"
|
|
583
607
|
}
|
|
584
608
|
};
|
|
585
609
|
CONFIG_MIGRATIONS = [
|
|
@@ -2312,6 +2336,9 @@ function getClient() {
|
|
|
2312
2336
|
if (_daemonClient && _daemonClient._isDaemonActive()) {
|
|
2313
2337
|
return _daemonClient;
|
|
2314
2338
|
}
|
|
2339
|
+
if (!_resilientClient) {
|
|
2340
|
+
return _adapterClient;
|
|
2341
|
+
}
|
|
2315
2342
|
return _resilientClient;
|
|
2316
2343
|
}
|
|
2317
2344
|
async function initDaemonClient() {
|
|
@@ -3344,6 +3371,127 @@ async function ensureSchema() {
|
|
|
3344
3371
|
VALUES (new.rowid, new.content, new.subject, new.predicate, new.object);
|
|
3345
3372
|
END;
|
|
3346
3373
|
`);
|
|
3374
|
+
await client.executeMultiple(`
|
|
3375
|
+
CREATE TABLE IF NOT EXISTS agent_sessions (
|
|
3376
|
+
id TEXT PRIMARY KEY,
|
|
3377
|
+
agent_id TEXT NOT NULL,
|
|
3378
|
+
project_name TEXT,
|
|
3379
|
+
started_at TEXT NOT NULL,
|
|
3380
|
+
last_event_at TEXT NOT NULL,
|
|
3381
|
+
event_count INTEGER NOT NULL DEFAULT 0,
|
|
3382
|
+
properties TEXT DEFAULT '{}'
|
|
3383
|
+
);
|
|
3384
|
+
|
|
3385
|
+
CREATE INDEX IF NOT EXISTS idx_agent_sessions_agent_time
|
|
3386
|
+
ON agent_sessions(agent_id, started_at);
|
|
3387
|
+
|
|
3388
|
+
CREATE TABLE IF NOT EXISTS agent_goals (
|
|
3389
|
+
id TEXT PRIMARY KEY,
|
|
3390
|
+
statement TEXT NOT NULL,
|
|
3391
|
+
owner_agent_id TEXT,
|
|
3392
|
+
project_name TEXT,
|
|
3393
|
+
status TEXT NOT NULL DEFAULT 'open',
|
|
3394
|
+
priority INTEGER NOT NULL DEFAULT 5,
|
|
3395
|
+
success_criteria TEXT,
|
|
3396
|
+
parent_goal_id TEXT,
|
|
3397
|
+
due_at TEXT,
|
|
3398
|
+
achieved_at TEXT,
|
|
3399
|
+
supersedes_id TEXT,
|
|
3400
|
+
created_at TEXT NOT NULL,
|
|
3401
|
+
updated_at TEXT NOT NULL,
|
|
3402
|
+
source_memory_id TEXT
|
|
3403
|
+
);
|
|
3404
|
+
|
|
3405
|
+
CREATE INDEX IF NOT EXISTS idx_agent_goals_project_status
|
|
3406
|
+
ON agent_goals(project_name, status, priority);
|
|
3407
|
+
|
|
3408
|
+
CREATE TABLE IF NOT EXISTS agent_events (
|
|
3409
|
+
id TEXT PRIMARY KEY,
|
|
3410
|
+
event_type TEXT NOT NULL,
|
|
3411
|
+
occurred_at TEXT NOT NULL,
|
|
3412
|
+
sequence_index INTEGER NOT NULL,
|
|
3413
|
+
actor_agent_id TEXT,
|
|
3414
|
+
agent_role TEXT,
|
|
3415
|
+
project_name TEXT,
|
|
3416
|
+
session_id TEXT,
|
|
3417
|
+
task_id TEXT,
|
|
3418
|
+
goal_id TEXT,
|
|
3419
|
+
parent_event_id TEXT,
|
|
3420
|
+
intention TEXT,
|
|
3421
|
+
outcome TEXT,
|
|
3422
|
+
evidence_memory_id TEXT,
|
|
3423
|
+
impact TEXT,
|
|
3424
|
+
payload TEXT DEFAULT '{}',
|
|
3425
|
+
created_at TEXT NOT NULL
|
|
3426
|
+
);
|
|
3427
|
+
|
|
3428
|
+
CREATE INDEX IF NOT EXISTS idx_agent_events_time
|
|
3429
|
+
ON agent_events(occurred_at, sequence_index);
|
|
3430
|
+
|
|
3431
|
+
CREATE INDEX IF NOT EXISTS idx_agent_events_session_seq
|
|
3432
|
+
ON agent_events(session_id, sequence_index);
|
|
3433
|
+
|
|
3434
|
+
CREATE INDEX IF NOT EXISTS idx_agent_events_goal_time
|
|
3435
|
+
ON agent_events(goal_id, occurred_at);
|
|
3436
|
+
|
|
3437
|
+
CREATE INDEX IF NOT EXISTS idx_agent_events_memory
|
|
3438
|
+
ON agent_events(evidence_memory_id);
|
|
3439
|
+
|
|
3440
|
+
CREATE TABLE IF NOT EXISTS agent_goal_links (
|
|
3441
|
+
id TEXT PRIMARY KEY,
|
|
3442
|
+
goal_id TEXT NOT NULL,
|
|
3443
|
+
link_type TEXT NOT NULL,
|
|
3444
|
+
target_id TEXT NOT NULL,
|
|
3445
|
+
target_type TEXT NOT NULL,
|
|
3446
|
+
created_at TEXT NOT NULL
|
|
3447
|
+
);
|
|
3448
|
+
|
|
3449
|
+
CREATE INDEX IF NOT EXISTS idx_agent_goal_links_goal
|
|
3450
|
+
ON agent_goal_links(goal_id, target_type);
|
|
3451
|
+
|
|
3452
|
+
CREATE TABLE IF NOT EXISTS agent_semantic_labels (
|
|
3453
|
+
id TEXT PRIMARY KEY,
|
|
3454
|
+
source_memory_id TEXT NOT NULL,
|
|
3455
|
+
event_id TEXT,
|
|
3456
|
+
labeler TEXT NOT NULL,
|
|
3457
|
+
schema_version INTEGER NOT NULL DEFAULT 1,
|
|
3458
|
+
confidence REAL NOT NULL DEFAULT 0,
|
|
3459
|
+
labels TEXT NOT NULL,
|
|
3460
|
+
created_at TEXT NOT NULL,
|
|
3461
|
+
updated_at TEXT NOT NULL
|
|
3462
|
+
);
|
|
3463
|
+
|
|
3464
|
+
CREATE INDEX IF NOT EXISTS idx_agent_semantic_labels_memory
|
|
3465
|
+
ON agent_semantic_labels(source_memory_id, labeler);
|
|
3466
|
+
|
|
3467
|
+
CREATE INDEX IF NOT EXISTS idx_agent_semantic_labels_event
|
|
3468
|
+
ON agent_semantic_labels(event_id);
|
|
3469
|
+
|
|
3470
|
+
CREATE TABLE IF NOT EXISTS agent_reflection_checkpoints (
|
|
3471
|
+
id TEXT PRIMARY KEY,
|
|
3472
|
+
project_name TEXT,
|
|
3473
|
+
session_id TEXT,
|
|
3474
|
+
window_start_at TEXT NOT NULL,
|
|
3475
|
+
window_end_at TEXT NOT NULL,
|
|
3476
|
+
event_count INTEGER NOT NULL DEFAULT 0,
|
|
3477
|
+
goal_count INTEGER NOT NULL DEFAULT 0,
|
|
3478
|
+
success_count INTEGER NOT NULL DEFAULT 0,
|
|
3479
|
+
failure_count INTEGER NOT NULL DEFAULT 0,
|
|
3480
|
+
risk_count INTEGER NOT NULL DEFAULT 0,
|
|
3481
|
+
summary TEXT NOT NULL,
|
|
3482
|
+
learnings TEXT NOT NULL DEFAULT '[]',
|
|
3483
|
+
next_actions TEXT NOT NULL DEFAULT '[]',
|
|
3484
|
+
evidence_event_ids TEXT NOT NULL DEFAULT '[]',
|
|
3485
|
+
confidence REAL NOT NULL DEFAULT 0,
|
|
3486
|
+
created_at TEXT NOT NULL
|
|
3487
|
+
);
|
|
3488
|
+
|
|
3489
|
+
CREATE INDEX IF NOT EXISTS idx_agent_reflection_project_time
|
|
3490
|
+
ON agent_reflection_checkpoints(project_name, window_end_at);
|
|
3491
|
+
|
|
3492
|
+
CREATE INDEX IF NOT EXISTS idx_agent_reflection_session_time
|
|
3493
|
+
ON agent_reflection_checkpoints(session_id, window_end_at);
|
|
3494
|
+
`);
|
|
3347
3495
|
try {
|
|
3348
3496
|
await client.execute({
|
|
3349
3497
|
sql: `ALTER TABLE memories ADD COLUMN tier INTEGER DEFAULT 3`,
|
|
@@ -6741,7 +6889,7 @@ var init_task_scope = __esm({
|
|
|
6741
6889
|
|
|
6742
6890
|
// src/lib/keychain.ts
|
|
6743
6891
|
import { readFile as readFile4, writeFile as writeFile5, unlink, mkdir as mkdir4, chmod as chmod2 } from "fs/promises";
|
|
6744
|
-
import { existsSync as existsSync16 } from "fs";
|
|
6892
|
+
import { existsSync as existsSync16, statSync as statSync2 } from "fs";
|
|
6745
6893
|
import { execSync as execSync8 } from "child_process";
|
|
6746
6894
|
import path19 from "path";
|
|
6747
6895
|
import os12 from "os";
|
|
@@ -6751,29 +6899,78 @@ function getKeyDir() {
|
|
|
6751
6899
|
function getKeyPath() {
|
|
6752
6900
|
return path19.join(getKeyDir(), "master.key");
|
|
6753
6901
|
}
|
|
6754
|
-
function
|
|
6902
|
+
function nativeKeychainAllowed() {
|
|
6903
|
+
return process.env.EXE_OS_DISABLE_NATIVE_KEYCHAIN !== "1";
|
|
6904
|
+
}
|
|
6905
|
+
function linuxSecretAvailable() {
|
|
6906
|
+
if (!nativeKeychainAllowed()) return false;
|
|
6907
|
+
if (process.platform !== "linux") return false;
|
|
6908
|
+
if (linuxSecretAvailability !== null) return linuxSecretAvailability;
|
|
6909
|
+
try {
|
|
6910
|
+
execSync8("command -v secret-tool >/dev/null 2>&1", { timeout: 1e3 });
|
|
6911
|
+
} catch {
|
|
6912
|
+
linuxSecretAvailability = false;
|
|
6913
|
+
return false;
|
|
6914
|
+
}
|
|
6915
|
+
try {
|
|
6916
|
+
execSync8("secret-tool search --all exe-os probe >/dev/null 2>&1", { timeout: 1e3 });
|
|
6917
|
+
linuxSecretAvailability = true;
|
|
6918
|
+
} catch {
|
|
6919
|
+
linuxSecretAvailability = false;
|
|
6920
|
+
}
|
|
6921
|
+
return linuxSecretAvailability;
|
|
6922
|
+
}
|
|
6923
|
+
function isRootOnlyTrustedServerKeyFile(keyPath) {
|
|
6924
|
+
if (process.platform !== "linux") return false;
|
|
6925
|
+
try {
|
|
6926
|
+
const uid = typeof os12.userInfo().uid === "number" ? os12.userInfo().uid : -1;
|
|
6927
|
+
const st = statSync2(keyPath);
|
|
6928
|
+
if (!st.isFile() || (st.mode & 63) !== 0) return false;
|
|
6929
|
+
if (uid === 0) return true;
|
|
6930
|
+
const exeOsDir = process.env.EXE_OS_DIR;
|
|
6931
|
+
return Boolean(exeOsDir && path19.resolve(keyPath).startsWith(path19.resolve(exeOsDir) + path19.sep));
|
|
6932
|
+
} catch {
|
|
6933
|
+
return false;
|
|
6934
|
+
}
|
|
6935
|
+
}
|
|
6936
|
+
function macKeychainGet(service = SERVICE) {
|
|
6937
|
+
if (!nativeKeychainAllowed()) return null;
|
|
6755
6938
|
if (process.platform !== "darwin") return null;
|
|
6756
6939
|
try {
|
|
6757
6940
|
return execSync8(
|
|
6758
|
-
`security find-generic-password -s "${
|
|
6941
|
+
`security find-generic-password -s "${service}" -a "${ACCOUNT}" -w 2>/dev/null`,
|
|
6759
6942
|
{ encoding: "utf-8", timeout: 5e3 }
|
|
6760
6943
|
).trim();
|
|
6761
6944
|
} catch {
|
|
6762
6945
|
return null;
|
|
6763
6946
|
}
|
|
6764
6947
|
}
|
|
6765
|
-
function macKeychainSet(value) {
|
|
6948
|
+
function macKeychainSet(value, service = SERVICE) {
|
|
6949
|
+
if (!nativeKeychainAllowed()) return false;
|
|
6766
6950
|
if (process.platform !== "darwin") return false;
|
|
6767
6951
|
try {
|
|
6768
6952
|
try {
|
|
6769
6953
|
execSync8(
|
|
6770
|
-
`security delete-generic-password -s "${
|
|
6954
|
+
`security delete-generic-password -s "${service}" -a "${ACCOUNT}" 2>/dev/null`,
|
|
6771
6955
|
{ timeout: 5e3 }
|
|
6772
6956
|
);
|
|
6773
6957
|
} catch {
|
|
6774
6958
|
}
|
|
6775
6959
|
execSync8(
|
|
6776
|
-
`security add-generic-password -s "${
|
|
6960
|
+
`security add-generic-password -s "${service}" -a "${ACCOUNT}" -w "${value}"`,
|
|
6961
|
+
{ timeout: 5e3 }
|
|
6962
|
+
);
|
|
6963
|
+
return true;
|
|
6964
|
+
} catch {
|
|
6965
|
+
return false;
|
|
6966
|
+
}
|
|
6967
|
+
}
|
|
6968
|
+
function macKeychainDelete(service = SERVICE) {
|
|
6969
|
+
if (!nativeKeychainAllowed()) return false;
|
|
6970
|
+
if (process.platform !== "darwin") return false;
|
|
6971
|
+
try {
|
|
6972
|
+
execSync8(
|
|
6973
|
+
`security delete-generic-password -s "${service}" -a "${ACCOUNT}" 2>/dev/null`,
|
|
6777
6974
|
{ timeout: 5e3 }
|
|
6778
6975
|
);
|
|
6779
6976
|
return true;
|
|
@@ -6781,22 +6978,35 @@ function macKeychainSet(value) {
|
|
|
6781
6978
|
return false;
|
|
6782
6979
|
}
|
|
6783
6980
|
}
|
|
6784
|
-
function linuxSecretGet() {
|
|
6785
|
-
if (
|
|
6981
|
+
function linuxSecretGet(service = SERVICE) {
|
|
6982
|
+
if (!linuxSecretAvailable()) return null;
|
|
6786
6983
|
try {
|
|
6787
6984
|
return execSync8(
|
|
6788
|
-
`secret-tool lookup service "${
|
|
6985
|
+
`secret-tool lookup service "${service}" account "${ACCOUNT}" 2>/dev/null`,
|
|
6789
6986
|
{ encoding: "utf-8", timeout: 5e3 }
|
|
6790
6987
|
).trim();
|
|
6791
6988
|
} catch {
|
|
6792
6989
|
return null;
|
|
6793
6990
|
}
|
|
6794
6991
|
}
|
|
6795
|
-
function linuxSecretSet(value) {
|
|
6992
|
+
function linuxSecretSet(value, service = SERVICE) {
|
|
6993
|
+
if (!linuxSecretAvailable()) return false;
|
|
6994
|
+
try {
|
|
6995
|
+
execSync8(
|
|
6996
|
+
`echo -n "${value}" | secret-tool store --label="exe-os master key" service "${service}" account "${ACCOUNT}" 2>/dev/null`,
|
|
6997
|
+
{ timeout: 5e3 }
|
|
6998
|
+
);
|
|
6999
|
+
return true;
|
|
7000
|
+
} catch {
|
|
7001
|
+
return false;
|
|
7002
|
+
}
|
|
7003
|
+
}
|
|
7004
|
+
function linuxSecretDelete(service = SERVICE) {
|
|
7005
|
+
if (!nativeKeychainAllowed()) return false;
|
|
6796
7006
|
if (process.platform !== "linux") return false;
|
|
6797
7007
|
try {
|
|
6798
7008
|
execSync8(
|
|
6799
|
-
`
|
|
7009
|
+
`secret-tool clear service "${service}" account "${ACCOUNT}" 2>/dev/null`,
|
|
6800
7010
|
{ timeout: 5e3 }
|
|
6801
7011
|
);
|
|
6802
7012
|
return true;
|
|
@@ -6805,6 +7015,7 @@ function linuxSecretSet(value) {
|
|
|
6805
7015
|
}
|
|
6806
7016
|
}
|
|
6807
7017
|
async function tryKeytar() {
|
|
7018
|
+
if (!nativeKeychainAllowed()) return null;
|
|
6808
7019
|
try {
|
|
6809
7020
|
return await import("keytar");
|
|
6810
7021
|
} catch {
|
|
@@ -6878,7 +7089,19 @@ async function writeMachineBoundFileFallback(b64) {
|
|
|
6878
7089
|
return "plaintext";
|
|
6879
7090
|
}
|
|
6880
7091
|
async function getMasterKey() {
|
|
6881
|
-
|
|
7092
|
+
let nativeValue = macKeychainGet() ?? linuxSecretGet();
|
|
7093
|
+
if (!nativeValue) {
|
|
7094
|
+
const legacyValue = macKeychainGet(LEGACY_SERVICE) ?? linuxSecretGet(LEGACY_SERVICE);
|
|
7095
|
+
if (legacyValue) {
|
|
7096
|
+
const migrated = macKeychainSet(legacyValue) || linuxSecretSet(legacyValue);
|
|
7097
|
+
if (migrated) {
|
|
7098
|
+
macKeychainDelete(LEGACY_SERVICE);
|
|
7099
|
+
linuxSecretDelete(LEGACY_SERVICE);
|
|
7100
|
+
process.stderr.write("[keychain] Migrated keychain service from exe-mem to exe-os.\n");
|
|
7101
|
+
}
|
|
7102
|
+
nativeValue = legacyValue;
|
|
7103
|
+
}
|
|
7104
|
+
}
|
|
6882
7105
|
if (nativeValue) {
|
|
6883
7106
|
return Buffer.from(nativeValue, "base64");
|
|
6884
7107
|
}
|
|
@@ -6886,12 +7109,17 @@ async function getMasterKey() {
|
|
|
6886
7109
|
if (keytar) {
|
|
6887
7110
|
try {
|
|
6888
7111
|
const keytarValue = await keytar.getPassword(SERVICE, ACCOUNT);
|
|
6889
|
-
|
|
6890
|
-
|
|
7112
|
+
const legacyKeytarValue = keytarValue ?? await keytar.getPassword(LEGACY_SERVICE, ACCOUNT);
|
|
7113
|
+
if (legacyKeytarValue) {
|
|
7114
|
+
const migrated = macKeychainSet(legacyKeytarValue) || linuxSecretSet(legacyKeytarValue);
|
|
6891
7115
|
if (migrated) {
|
|
6892
7116
|
process.stderr.write("[keychain] Migrated key from keytar to native keychain.\n");
|
|
7117
|
+
try {
|
|
7118
|
+
await keytar.deletePassword(LEGACY_SERVICE, ACCOUNT);
|
|
7119
|
+
} catch {
|
|
7120
|
+
}
|
|
6893
7121
|
}
|
|
6894
|
-
return Buffer.from(
|
|
7122
|
+
return Buffer.from(legacyKeytarValue, "base64");
|
|
6895
7123
|
}
|
|
6896
7124
|
} catch {
|
|
6897
7125
|
}
|
|
@@ -6916,7 +7144,7 @@ async function getMasterKey() {
|
|
|
6916
7144
|
const decrypted = decryptWithMachineKey(content, machineKey);
|
|
6917
7145
|
if (!decrypted) {
|
|
6918
7146
|
process.stderr.write(
|
|
6919
|
-
"[keychain] Key decryption failed \u2014 machine may have changed.\n Use your 24-word recovery phrase: exe-os
|
|
7147
|
+
"[keychain] Key decryption failed \u2014 machine may have changed.\n Use your 24-word recovery phrase during setup: exe-os setup\n"
|
|
6920
7148
|
);
|
|
6921
7149
|
return null;
|
|
6922
7150
|
}
|
|
@@ -6925,6 +7153,9 @@ async function getMasterKey() {
|
|
|
6925
7153
|
b64Value = content;
|
|
6926
7154
|
}
|
|
6927
7155
|
const key = Buffer.from(b64Value, "base64");
|
|
7156
|
+
if (!content.startsWith(ENCRYPTED_PREFIX) && isRootOnlyTrustedServerKeyFile(keyPath)) {
|
|
7157
|
+
return key;
|
|
7158
|
+
}
|
|
6928
7159
|
const migrated = macKeychainSet(b64Value) || linuxSecretSet(b64Value);
|
|
6929
7160
|
if (migrated) {
|
|
6930
7161
|
process.stderr.write("[keychain] Migrated key from file to native keychain.\n");
|
|
@@ -6952,12 +7183,14 @@ async function getMasterKey() {
|
|
|
6952
7183
|
return null;
|
|
6953
7184
|
}
|
|
6954
7185
|
}
|
|
6955
|
-
var SERVICE, ACCOUNT, ENCRYPTED_PREFIX;
|
|
7186
|
+
var SERVICE, LEGACY_SERVICE, ACCOUNT, linuxSecretAvailability, ENCRYPTED_PREFIX;
|
|
6956
7187
|
var init_keychain = __esm({
|
|
6957
7188
|
"src/lib/keychain.ts"() {
|
|
6958
7189
|
"use strict";
|
|
6959
|
-
SERVICE = "exe-
|
|
7190
|
+
SERVICE = "exe-os";
|
|
7191
|
+
LEGACY_SERVICE = "exe-mem";
|
|
6960
7192
|
ACCOUNT = "master-key";
|
|
7193
|
+
linuxSecretAvailability = null;
|
|
6961
7194
|
ENCRYPTED_PREFIX = "enc:";
|
|
6962
7195
|
}
|
|
6963
7196
|
});
|
|
@@ -7172,7 +7405,7 @@ __export(shard_manager_exports, {
|
|
|
7172
7405
|
shardExists: () => shardExists
|
|
7173
7406
|
});
|
|
7174
7407
|
import path20 from "path";
|
|
7175
|
-
import { existsSync as existsSync17, mkdirSync as mkdirSync8, readdirSync as readdirSync4, renameSync as renameSync4, statSync as
|
|
7408
|
+
import { existsSync as existsSync17, mkdirSync as mkdirSync8, readdirSync as readdirSync4, renameSync as renameSync4, statSync as statSync3 } from "fs";
|
|
7176
7409
|
import { createClient as createClient2 } from "@libsql/client";
|
|
7177
7410
|
function initShardManager(encryptionKey) {
|
|
7178
7411
|
_encryptionKey = encryptionKey;
|
|
@@ -7236,7 +7469,7 @@ async function auditShardHealth(options = {}) {
|
|
|
7236
7469
|
const shards = [];
|
|
7237
7470
|
for (const name of names) {
|
|
7238
7471
|
const dbPath = path20.join(SHARDS_DIR, `${name}.db`);
|
|
7239
|
-
const stat =
|
|
7472
|
+
const stat = statSync3(dbPath);
|
|
7240
7473
|
const item = {
|
|
7241
7474
|
name,
|
|
7242
7475
|
path: dbPath,
|
|
@@ -7489,7 +7722,7 @@ async function getReadyShardClient(projectName) {
|
|
|
7489
7722
|
_shardLastAccess.delete(safeName);
|
|
7490
7723
|
const dbPath = path20.join(SHARDS_DIR, `${safeName}.db`);
|
|
7491
7724
|
if (existsSync17(dbPath)) {
|
|
7492
|
-
const stat =
|
|
7725
|
+
const stat = statSync3(dbPath);
|
|
7493
7726
|
const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
7494
7727
|
const archivedPath = path20.join(SHARDS_DIR, `${safeName}.db.broken-${stamp}`);
|
|
7495
7728
|
renameSync4(dbPath, archivedPath);
|
|
@@ -7609,6 +7842,12 @@ var init_platform_procedures = __esm({
|
|
|
7609
7842
|
priority: "p0",
|
|
7610
7843
|
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."
|
|
7611
7844
|
},
|
|
7845
|
+
{
|
|
7846
|
+
title: "Customer orchestration maturity \u2014 recommend, never trap",
|
|
7847
|
+
domain: "workflow",
|
|
7848
|
+
priority: "p1",
|
|
7849
|
+
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."
|
|
7850
|
+
},
|
|
7612
7851
|
{
|
|
7613
7852
|
title: "Single dispatch path \u2014 create_task only",
|
|
7614
7853
|
domain: "workflow",
|
|
@@ -7667,6 +7906,12 @@ var init_platform_procedures = __esm({
|
|
|
7667
7906
|
priority: "p0",
|
|
7668
7907
|
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."
|
|
7669
7908
|
},
|
|
7909
|
+
{
|
|
7910
|
+
title: "Commit discipline \u2014 never leave verified work floating",
|
|
7911
|
+
domain: "workflow",
|
|
7912
|
+
priority: "p1",
|
|
7913
|
+
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."
|
|
7914
|
+
},
|
|
7670
7915
|
{
|
|
7671
7916
|
title: "Desktop and TUI are the same product",
|
|
7672
7917
|
domain: "architecture",
|
|
@@ -7984,6 +8229,274 @@ var init_memory_cards = __esm({
|
|
|
7984
8229
|
}
|
|
7985
8230
|
});
|
|
7986
8231
|
|
|
8232
|
+
// src/lib/agentic-ontology.ts
|
|
8233
|
+
var agentic_ontology_exports = {};
|
|
8234
|
+
__export(agentic_ontology_exports, {
|
|
8235
|
+
clean: () => clean,
|
|
8236
|
+
extractGoalCandidates: () => extractGoalCandidates,
|
|
8237
|
+
inferIntention: () => inferIntention,
|
|
8238
|
+
inferOntologyEventType: () => inferOntologyEventType,
|
|
8239
|
+
inferOutcome: () => inferOutcome,
|
|
8240
|
+
inferSemanticLabel: () => inferSemanticLabel,
|
|
8241
|
+
insertOntologyForBatch: () => insertOntologyForBatch,
|
|
8242
|
+
insertOntologyForMemory: () => insertOntologyForMemory,
|
|
8243
|
+
ontologyPayload: () => ontologyPayload,
|
|
8244
|
+
stableId: () => stableId2
|
|
8245
|
+
});
|
|
8246
|
+
import { createHash as createHash3 } from "crypto";
|
|
8247
|
+
function stableId2(...parts) {
|
|
8248
|
+
return createHash3("sha256").update(parts.map((p) => String(p ?? "")).join("::")).digest("hex").slice(0, 32);
|
|
8249
|
+
}
|
|
8250
|
+
function clean(text, max = 240) {
|
|
8251
|
+
return text.replace(/\u0000/g, "").replace(/```[\s\S]*?```/g, " ").replace(/\s+/g, " ").trim().slice(0, max);
|
|
8252
|
+
}
|
|
8253
|
+
function inferOntologyEventType(row) {
|
|
8254
|
+
const lower = row.raw_text.toLowerCase();
|
|
8255
|
+
if (row.has_error) return "error";
|
|
8256
|
+
if (/\b(done|complete|completed|fixed|resolved|shipped|deployed|pushed|published)\b/.test(lower)) return "milestone";
|
|
8257
|
+
if (/\b(blocked|failed|error|bug|regression|broken)\b/.test(lower)) return "problem";
|
|
8258
|
+
if (/\b(decided|decision|adr|we chose|approved|rejected)\b/.test(lower)) return "decision";
|
|
8259
|
+
if (/\b(goal|need to|we need|want to|trying to|objective)\b/.test(lower)) return "goal_signal";
|
|
8260
|
+
if (["Bash", "Read", "Edit", "Write", "Grep", "Glob"].includes(row.tool_name)) return "tool_action";
|
|
8261
|
+
if (row.tool_name.startsWith("memory_card")) return "memory_card";
|
|
8262
|
+
return "memory_observation";
|
|
8263
|
+
}
|
|
8264
|
+
function inferIntention(row) {
|
|
8265
|
+
if (row.intent) return clean(row.intent, 220);
|
|
8266
|
+
const text = clean(row.raw_text, 1e3);
|
|
8267
|
+
const patterns = [
|
|
8268
|
+
/(?: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,
|
|
8269
|
+
/(?:so that|in order to)\s+([^.!?\n]{8,220})/i,
|
|
8270
|
+
/(?:task|plan):\s*([^.!?\n]{8,220})/i
|
|
8271
|
+
];
|
|
8272
|
+
for (const p of patterns) {
|
|
8273
|
+
const m = text.match(p);
|
|
8274
|
+
if (m?.[1]) return clean(m[1], 220);
|
|
8275
|
+
}
|
|
8276
|
+
if (["Bash", "Read", "Edit", "Write", "Grep", "Glob"].includes(row.tool_name)) {
|
|
8277
|
+
return `${row.tool_name} during ${row.project_name}`;
|
|
8278
|
+
}
|
|
8279
|
+
return null;
|
|
8280
|
+
}
|
|
8281
|
+
function inferOutcome(row) {
|
|
8282
|
+
if (row.outcome) return clean(row.outcome, 220);
|
|
8283
|
+
if (row.has_error) return "error";
|
|
8284
|
+
const lower = row.raw_text.toLowerCase();
|
|
8285
|
+
if (/\b(done|complete|completed|fixed|resolved|shipped|deployed|pushed|published|passed)\b/.test(lower)) return "success_signal";
|
|
8286
|
+
if (/\b(blocked|failed|error|regression|broken|not working|could not)\b/.test(lower)) return "failure_signal";
|
|
8287
|
+
if (/\b(warning|risk|concern|caveat)\b/.test(lower)) return "risk_signal";
|
|
8288
|
+
return null;
|
|
8289
|
+
}
|
|
8290
|
+
function extractGoalCandidates(row) {
|
|
8291
|
+
const text = clean(row.raw_text, 1600);
|
|
8292
|
+
const patterns = [
|
|
8293
|
+
/(?: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,
|
|
8294
|
+
/(?:success means|success criteria|so that)\s+([^.!?\n]{12,220})/gi
|
|
8295
|
+
];
|
|
8296
|
+
const out = [];
|
|
8297
|
+
for (const pattern of patterns) {
|
|
8298
|
+
for (const m of text.matchAll(pattern)) {
|
|
8299
|
+
const candidate = clean(m[1] ?? "", 220);
|
|
8300
|
+
if (candidate.length >= 12 && !out.some((x) => x.toLowerCase() === candidate.toLowerCase())) out.push(candidate);
|
|
8301
|
+
if (out.length >= 3) return out;
|
|
8302
|
+
}
|
|
8303
|
+
}
|
|
8304
|
+
return out;
|
|
8305
|
+
}
|
|
8306
|
+
function uniq(values, max = 6) {
|
|
8307
|
+
const out = [];
|
|
8308
|
+
for (const value of values.map((v) => clean(v, 220)).filter(Boolean)) {
|
|
8309
|
+
if (!out.some((x) => x.toLowerCase() === value.toLowerCase())) out.push(value);
|
|
8310
|
+
if (out.length >= max) break;
|
|
8311
|
+
}
|
|
8312
|
+
return out;
|
|
8313
|
+
}
|
|
8314
|
+
function extractMatches(text, patterns, max = 5) {
|
|
8315
|
+
const out = [];
|
|
8316
|
+
for (const pattern of patterns) {
|
|
8317
|
+
for (const match of text.matchAll(pattern)) {
|
|
8318
|
+
const value = match[1] ?? match[0];
|
|
8319
|
+
if (value) out.push(value);
|
|
8320
|
+
if (out.length >= max) return uniq(out, max);
|
|
8321
|
+
}
|
|
8322
|
+
}
|
|
8323
|
+
return uniq(out, max);
|
|
8324
|
+
}
|
|
8325
|
+
function inferSemanticLabel(row) {
|
|
8326
|
+
const text = clean(row.raw_text, 2400);
|
|
8327
|
+
const eventType = inferOntologyEventType(row);
|
|
8328
|
+
const intention = inferIntention(row);
|
|
8329
|
+
const outcome = inferOutcome(row);
|
|
8330
|
+
const goals = extractGoalCandidates(row);
|
|
8331
|
+
const milestones = extractMatches(text, [
|
|
8332
|
+
/\b(?:completed|finished|fixed|resolved|shipped|deployed|published|pushed|passed)\b([^.!?\n]{0,180})/gi,
|
|
8333
|
+
/(?:milestone|done):\s*([^.!?\n]{8,220})/gi
|
|
8334
|
+
]);
|
|
8335
|
+
const problems = extractMatches(text, [
|
|
8336
|
+
/\b(?:blocked by|failed because|bug|regression|broken|not working|error)\b([^.!?\n]{0,180})/gi,
|
|
8337
|
+
/(?:problem|issue|risk):\s*([^.!?\n]{8,220})/gi
|
|
8338
|
+
]);
|
|
8339
|
+
const decisions = extractMatches(text, [
|
|
8340
|
+
/(?:decided|decision|adr|we chose|approved|rejected)\s+([^.!?\n]{8,220})/gi
|
|
8341
|
+
]);
|
|
8342
|
+
const temporalAnchors = extractMatches(text, [
|
|
8343
|
+
/\b(\d{4}-\d{2}-\d{2}(?:[T ][0-9:.+-Z]+)?)\b/g,
|
|
8344
|
+
/\b(today|yesterday|tomorrow|this week|next week|last week|morning|afternoon|tonight)\b/gi
|
|
8345
|
+
], 8);
|
|
8346
|
+
const nextActions = extractMatches(text, [
|
|
8347
|
+
/(?:next|todo|follow[- ]?up|remaining|need to)\s*:?\s*([^.!?\n]{8,220})/gi
|
|
8348
|
+
]);
|
|
8349
|
+
const actors = uniq([
|
|
8350
|
+
row.agent_id,
|
|
8351
|
+
...extractMatches(text, [/\b(?:agent|employee|owner|assignee)[:= ]+([a-zA-Z][a-zA-Z0-9_-]{1,40})/gi], 5)
|
|
8352
|
+
], 6);
|
|
8353
|
+
const successSignals = milestones.length ? milestones : outcome === "success_signal" ? [clean(text, 180)] : [];
|
|
8354
|
+
const failureSignals = problems.length ? problems : outcome === "failure_signal" || row.has_error ? [clean(text, 180)] : [];
|
|
8355
|
+
const impact = successSignals.length && failureSignals.length ? "mixed" : failureSignals.length ? "negative" : successSignals.length ? "positive" : "neutral";
|
|
8356
|
+
const signalCount = goals.length + milestones.length + problems.length + decisions.length + nextActions.length;
|
|
8357
|
+
return {
|
|
8358
|
+
labeler: "deterministic",
|
|
8359
|
+
schemaVersion: 1,
|
|
8360
|
+
eventType,
|
|
8361
|
+
intention,
|
|
8362
|
+
outcome,
|
|
8363
|
+
impact,
|
|
8364
|
+
confidence: Math.min(0.95, 0.45 + signalCount * 0.08 + (intention ? 0.1 : 0) + (outcome ? 0.1 : 0)),
|
|
8365
|
+
goals,
|
|
8366
|
+
milestones,
|
|
8367
|
+
problems,
|
|
8368
|
+
decisions,
|
|
8369
|
+
actors,
|
|
8370
|
+
temporalAnchors,
|
|
8371
|
+
successSignals,
|
|
8372
|
+
failureSignals,
|
|
8373
|
+
nextActions,
|
|
8374
|
+
summary: clean(text, 280)
|
|
8375
|
+
};
|
|
8376
|
+
}
|
|
8377
|
+
function ontologyPayload(row) {
|
|
8378
|
+
const semantic = inferSemanticLabel(row);
|
|
8379
|
+
return {
|
|
8380
|
+
tool_name: row.tool_name,
|
|
8381
|
+
memory_version: row.version ?? null,
|
|
8382
|
+
domain: row.domain ?? null,
|
|
8383
|
+
trajectory: row.trajectory ? safeJson(row.trajectory) : null,
|
|
8384
|
+
semantic
|
|
8385
|
+
};
|
|
8386
|
+
}
|
|
8387
|
+
function safeJson(value) {
|
|
8388
|
+
try {
|
|
8389
|
+
return JSON.parse(value);
|
|
8390
|
+
} catch {
|
|
8391
|
+
return value.slice(0, 1e3);
|
|
8392
|
+
}
|
|
8393
|
+
}
|
|
8394
|
+
async function resolveClient(client) {
|
|
8395
|
+
if (client) return client;
|
|
8396
|
+
const { getClient: getClient2 } = await Promise.resolve().then(() => (init_database(), database_exports));
|
|
8397
|
+
return getClient2();
|
|
8398
|
+
}
|
|
8399
|
+
async function insertOntologyForMemory(row, client) {
|
|
8400
|
+
const db = await resolveClient(client);
|
|
8401
|
+
const occurredAt = row.timestamp;
|
|
8402
|
+
const sequence = Number(row.version ?? 0) || Math.floor(new Date(occurredAt).getTime() / 1e3);
|
|
8403
|
+
const eventType = inferOntologyEventType(row);
|
|
8404
|
+
const intention = inferIntention(row);
|
|
8405
|
+
const outcome = inferOutcome(row);
|
|
8406
|
+
const eventId = stableId2("event", row.id);
|
|
8407
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
8408
|
+
await db.execute({
|
|
8409
|
+
sql: `INSERT INTO agent_sessions (id, agent_id, project_name, started_at, last_event_at, event_count, properties)
|
|
8410
|
+
VALUES (?, ?, ?, ?, ?, 1, ?)
|
|
8411
|
+
ON CONFLICT(id) DO UPDATE SET last_event_at = MAX(last_event_at, excluded.last_event_at),
|
|
8412
|
+
event_count = event_count + 1`,
|
|
8413
|
+
args: [row.session_id, row.agent_id, row.project_name, occurredAt, occurredAt, JSON.stringify({ agent_role: row.agent_role })]
|
|
8414
|
+
});
|
|
8415
|
+
await db.execute({
|
|
8416
|
+
sql: `INSERT OR IGNORE INTO agent_events
|
|
8417
|
+
(id, event_type, occurred_at, sequence_index, actor_agent_id, agent_role, project_name,
|
|
8418
|
+
session_id, task_id, goal_id, parent_event_id, intention, outcome, evidence_memory_id,
|
|
8419
|
+
impact, payload, created_at)
|
|
8420
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NULL, NULL, ?, ?, ?, ?, ?, ?)`,
|
|
8421
|
+
args: [
|
|
8422
|
+
eventId,
|
|
8423
|
+
eventType,
|
|
8424
|
+
occurredAt,
|
|
8425
|
+
sequence,
|
|
8426
|
+
row.agent_id,
|
|
8427
|
+
row.agent_role,
|
|
8428
|
+
row.project_name,
|
|
8429
|
+
row.session_id,
|
|
8430
|
+
row.task_id ?? null,
|
|
8431
|
+
intention,
|
|
8432
|
+
outcome,
|
|
8433
|
+
row.id,
|
|
8434
|
+
row.has_error ? "negative" : outcome === "success_signal" ? "positive" : "neutral",
|
|
8435
|
+
JSON.stringify(ontologyPayload(row)),
|
|
8436
|
+
now
|
|
8437
|
+
]
|
|
8438
|
+
});
|
|
8439
|
+
const semantic = inferSemanticLabel(row);
|
|
8440
|
+
await db.execute({
|
|
8441
|
+
sql: `INSERT INTO agent_semantic_labels
|
|
8442
|
+
(id, source_memory_id, event_id, labeler, schema_version, confidence, labels, created_at, updated_at)
|
|
8443
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
8444
|
+
ON CONFLICT(id) DO UPDATE SET confidence = excluded.confidence,
|
|
8445
|
+
labels = excluded.labels, updated_at = excluded.updated_at`,
|
|
8446
|
+
args: [
|
|
8447
|
+
stableId2("semantic", row.id, semantic.labeler, semantic.schemaVersion),
|
|
8448
|
+
row.id,
|
|
8449
|
+
eventId,
|
|
8450
|
+
semantic.labeler,
|
|
8451
|
+
semantic.schemaVersion,
|
|
8452
|
+
semantic.confidence,
|
|
8453
|
+
JSON.stringify(semantic),
|
|
8454
|
+
now,
|
|
8455
|
+
now
|
|
8456
|
+
]
|
|
8457
|
+
});
|
|
8458
|
+
for (const statement of extractGoalCandidates(row)) {
|
|
8459
|
+
const goalId = stableId2("goal", row.project_name, statement.toLowerCase());
|
|
8460
|
+
await db.execute({
|
|
8461
|
+
sql: `INSERT INTO agent_goals
|
|
8462
|
+
(id, statement, owner_agent_id, project_name, status, priority, success_criteria,
|
|
8463
|
+
parent_goal_id, due_at, achieved_at, supersedes_id, created_at, updated_at, source_memory_id)
|
|
8464
|
+
VALUES (?, ?, ?, ?, 'open', 5, NULL, NULL, NULL, NULL, NULL, ?, ?, ?)
|
|
8465
|
+
ON CONFLICT(id) DO UPDATE SET updated_at = excluded.updated_at`,
|
|
8466
|
+
args: [goalId, statement, row.agent_id, row.project_name, now, now, row.id]
|
|
8467
|
+
});
|
|
8468
|
+
await db.execute({
|
|
8469
|
+
sql: `INSERT OR IGNORE INTO agent_goal_links
|
|
8470
|
+
(id, goal_id, link_type, target_id, target_type, created_at)
|
|
8471
|
+
VALUES (?, ?, 'evidence', ?, 'memory', ?)`,
|
|
8472
|
+
args: [stableId2("goal_link", goalId, row.id, "memory"), goalId, row.id, now]
|
|
8473
|
+
});
|
|
8474
|
+
await db.execute({
|
|
8475
|
+
sql: `INSERT OR IGNORE INTO agent_goal_links
|
|
8476
|
+
(id, goal_id, link_type, target_id, target_type, created_at)
|
|
8477
|
+
VALUES (?, ?, 'event', ?, 'event', ?)`,
|
|
8478
|
+
args: [stableId2("goal_link", goalId, eventId, "event"), goalId, eventId, now]
|
|
8479
|
+
});
|
|
8480
|
+
}
|
|
8481
|
+
}
|
|
8482
|
+
async function insertOntologyForBatch(rows, client) {
|
|
8483
|
+
const db = await resolveClient(client);
|
|
8484
|
+
let count = 0;
|
|
8485
|
+
for (const row of rows) {
|
|
8486
|
+
try {
|
|
8487
|
+
await insertOntologyForMemory(row, db);
|
|
8488
|
+
count++;
|
|
8489
|
+
} catch {
|
|
8490
|
+
}
|
|
8491
|
+
}
|
|
8492
|
+
return count;
|
|
8493
|
+
}
|
|
8494
|
+
var init_agentic_ontology = __esm({
|
|
8495
|
+
"src/lib/agentic-ontology.ts"() {
|
|
8496
|
+
"use strict";
|
|
8497
|
+
}
|
|
8498
|
+
});
|
|
8499
|
+
|
|
7987
8500
|
// src/lib/store.ts
|
|
7988
8501
|
var store_exports = {};
|
|
7989
8502
|
__export(store_exports, {
|
|
@@ -8327,6 +8840,11 @@ async function flushBatch() {
|
|
|
8327
8840
|
await insertMemoryCardsForBatch2(batch);
|
|
8328
8841
|
} catch {
|
|
8329
8842
|
}
|
|
8843
|
+
try {
|
|
8844
|
+
const { insertOntologyForBatch: insertOntologyForBatch2 } = await Promise.resolve().then(() => (init_agentic_ontology(), agentic_ontology_exports));
|
|
8845
|
+
await insertOntologyForBatch2(batch);
|
|
8846
|
+
} catch {
|
|
8847
|
+
}
|
|
8330
8848
|
schedulePostWriteMemoryHygiene(batch.map((row) => row.id));
|
|
8331
8849
|
_pendingRecords.splice(0, batch.length);
|
|
8332
8850
|
try {
|