@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
|
@@ -134,6 +134,11 @@ function normalizeAutoUpdate(raw) {
|
|
|
134
134
|
const userAU = raw.autoUpdate ?? {};
|
|
135
135
|
raw.autoUpdate = { ...defaultAU, ...userAU };
|
|
136
136
|
}
|
|
137
|
+
function normalizeOrchestration(raw) {
|
|
138
|
+
const defaultOrg = DEFAULT_CONFIG.orchestration;
|
|
139
|
+
const userOrg = raw.orchestration ?? {};
|
|
140
|
+
raw.orchestration = { ...defaultOrg, ...userOrg };
|
|
141
|
+
}
|
|
137
142
|
async function loadConfig() {
|
|
138
143
|
const dir = process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? EXE_AI_DIR;
|
|
139
144
|
await ensurePrivateDir(dir);
|
|
@@ -158,10 +163,15 @@ async function loadConfig() {
|
|
|
158
163
|
normalizeScalingRoadmap(migratedCfg);
|
|
159
164
|
normalizeSessionLifecycle(migratedCfg);
|
|
160
165
|
normalizeAutoUpdate(migratedCfg);
|
|
166
|
+
normalizeOrchestration(migratedCfg);
|
|
161
167
|
const config = { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db"), ...migratedCfg };
|
|
162
168
|
if (config.dbPath.startsWith("~")) {
|
|
163
169
|
config.dbPath = config.dbPath.replace(/^~/, os.homedir());
|
|
164
170
|
}
|
|
171
|
+
const envDbPath = path.join(dir, "memories.db");
|
|
172
|
+
if (process.env.EXE_OS_DIR && config.dbPath !== envDbPath && !existsSync2(config.dbPath) && existsSync2(envDbPath)) {
|
|
173
|
+
config.dbPath = envDbPath;
|
|
174
|
+
}
|
|
165
175
|
return config;
|
|
166
176
|
} catch {
|
|
167
177
|
return { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db") };
|
|
@@ -233,6 +243,10 @@ var init_config = __esm({
|
|
|
233
243
|
checkOnBoot: true,
|
|
234
244
|
autoInstall: false,
|
|
235
245
|
checkIntervalMs: 24 * 60 * 60 * 1e3
|
|
246
|
+
},
|
|
247
|
+
orchestration: {
|
|
248
|
+
phase: "phase_1_coo",
|
|
249
|
+
phaseSetBy: "default"
|
|
236
250
|
}
|
|
237
251
|
};
|
|
238
252
|
CONFIG_MIGRATIONS = [
|
|
@@ -2038,6 +2052,9 @@ function getClient() {
|
|
|
2038
2052
|
if (_daemonClient && _daemonClient._isDaemonActive()) {
|
|
2039
2053
|
return _daemonClient;
|
|
2040
2054
|
}
|
|
2055
|
+
if (!_resilientClient) {
|
|
2056
|
+
return _adapterClient;
|
|
2057
|
+
}
|
|
2041
2058
|
return _resilientClient;
|
|
2042
2059
|
}
|
|
2043
2060
|
async function initDaemonClient() {
|
|
@@ -3070,6 +3087,127 @@ async function ensureSchema() {
|
|
|
3070
3087
|
VALUES (new.rowid, new.content, new.subject, new.predicate, new.object);
|
|
3071
3088
|
END;
|
|
3072
3089
|
`);
|
|
3090
|
+
await client.executeMultiple(`
|
|
3091
|
+
CREATE TABLE IF NOT EXISTS agent_sessions (
|
|
3092
|
+
id TEXT PRIMARY KEY,
|
|
3093
|
+
agent_id TEXT NOT NULL,
|
|
3094
|
+
project_name TEXT,
|
|
3095
|
+
started_at TEXT NOT NULL,
|
|
3096
|
+
last_event_at TEXT NOT NULL,
|
|
3097
|
+
event_count INTEGER NOT NULL DEFAULT 0,
|
|
3098
|
+
properties TEXT DEFAULT '{}'
|
|
3099
|
+
);
|
|
3100
|
+
|
|
3101
|
+
CREATE INDEX IF NOT EXISTS idx_agent_sessions_agent_time
|
|
3102
|
+
ON agent_sessions(agent_id, started_at);
|
|
3103
|
+
|
|
3104
|
+
CREATE TABLE IF NOT EXISTS agent_goals (
|
|
3105
|
+
id TEXT PRIMARY KEY,
|
|
3106
|
+
statement TEXT NOT NULL,
|
|
3107
|
+
owner_agent_id TEXT,
|
|
3108
|
+
project_name TEXT,
|
|
3109
|
+
status TEXT NOT NULL DEFAULT 'open',
|
|
3110
|
+
priority INTEGER NOT NULL DEFAULT 5,
|
|
3111
|
+
success_criteria TEXT,
|
|
3112
|
+
parent_goal_id TEXT,
|
|
3113
|
+
due_at TEXT,
|
|
3114
|
+
achieved_at TEXT,
|
|
3115
|
+
supersedes_id TEXT,
|
|
3116
|
+
created_at TEXT NOT NULL,
|
|
3117
|
+
updated_at TEXT NOT NULL,
|
|
3118
|
+
source_memory_id TEXT
|
|
3119
|
+
);
|
|
3120
|
+
|
|
3121
|
+
CREATE INDEX IF NOT EXISTS idx_agent_goals_project_status
|
|
3122
|
+
ON agent_goals(project_name, status, priority);
|
|
3123
|
+
|
|
3124
|
+
CREATE TABLE IF NOT EXISTS agent_events (
|
|
3125
|
+
id TEXT PRIMARY KEY,
|
|
3126
|
+
event_type TEXT NOT NULL,
|
|
3127
|
+
occurred_at TEXT NOT NULL,
|
|
3128
|
+
sequence_index INTEGER NOT NULL,
|
|
3129
|
+
actor_agent_id TEXT,
|
|
3130
|
+
agent_role TEXT,
|
|
3131
|
+
project_name TEXT,
|
|
3132
|
+
session_id TEXT,
|
|
3133
|
+
task_id TEXT,
|
|
3134
|
+
goal_id TEXT,
|
|
3135
|
+
parent_event_id TEXT,
|
|
3136
|
+
intention TEXT,
|
|
3137
|
+
outcome TEXT,
|
|
3138
|
+
evidence_memory_id TEXT,
|
|
3139
|
+
impact TEXT,
|
|
3140
|
+
payload TEXT DEFAULT '{}',
|
|
3141
|
+
created_at TEXT NOT NULL
|
|
3142
|
+
);
|
|
3143
|
+
|
|
3144
|
+
CREATE INDEX IF NOT EXISTS idx_agent_events_time
|
|
3145
|
+
ON agent_events(occurred_at, sequence_index);
|
|
3146
|
+
|
|
3147
|
+
CREATE INDEX IF NOT EXISTS idx_agent_events_session_seq
|
|
3148
|
+
ON agent_events(session_id, sequence_index);
|
|
3149
|
+
|
|
3150
|
+
CREATE INDEX IF NOT EXISTS idx_agent_events_goal_time
|
|
3151
|
+
ON agent_events(goal_id, occurred_at);
|
|
3152
|
+
|
|
3153
|
+
CREATE INDEX IF NOT EXISTS idx_agent_events_memory
|
|
3154
|
+
ON agent_events(evidence_memory_id);
|
|
3155
|
+
|
|
3156
|
+
CREATE TABLE IF NOT EXISTS agent_goal_links (
|
|
3157
|
+
id TEXT PRIMARY KEY,
|
|
3158
|
+
goal_id TEXT NOT NULL,
|
|
3159
|
+
link_type TEXT NOT NULL,
|
|
3160
|
+
target_id TEXT NOT NULL,
|
|
3161
|
+
target_type TEXT NOT NULL,
|
|
3162
|
+
created_at TEXT NOT NULL
|
|
3163
|
+
);
|
|
3164
|
+
|
|
3165
|
+
CREATE INDEX IF NOT EXISTS idx_agent_goal_links_goal
|
|
3166
|
+
ON agent_goal_links(goal_id, target_type);
|
|
3167
|
+
|
|
3168
|
+
CREATE TABLE IF NOT EXISTS agent_semantic_labels (
|
|
3169
|
+
id TEXT PRIMARY KEY,
|
|
3170
|
+
source_memory_id TEXT NOT NULL,
|
|
3171
|
+
event_id TEXT,
|
|
3172
|
+
labeler TEXT NOT NULL,
|
|
3173
|
+
schema_version INTEGER NOT NULL DEFAULT 1,
|
|
3174
|
+
confidence REAL NOT NULL DEFAULT 0,
|
|
3175
|
+
labels TEXT NOT NULL,
|
|
3176
|
+
created_at TEXT NOT NULL,
|
|
3177
|
+
updated_at TEXT NOT NULL
|
|
3178
|
+
);
|
|
3179
|
+
|
|
3180
|
+
CREATE INDEX IF NOT EXISTS idx_agent_semantic_labels_memory
|
|
3181
|
+
ON agent_semantic_labels(source_memory_id, labeler);
|
|
3182
|
+
|
|
3183
|
+
CREATE INDEX IF NOT EXISTS idx_agent_semantic_labels_event
|
|
3184
|
+
ON agent_semantic_labels(event_id);
|
|
3185
|
+
|
|
3186
|
+
CREATE TABLE IF NOT EXISTS agent_reflection_checkpoints (
|
|
3187
|
+
id TEXT PRIMARY KEY,
|
|
3188
|
+
project_name TEXT,
|
|
3189
|
+
session_id TEXT,
|
|
3190
|
+
window_start_at TEXT NOT NULL,
|
|
3191
|
+
window_end_at TEXT NOT NULL,
|
|
3192
|
+
event_count INTEGER NOT NULL DEFAULT 0,
|
|
3193
|
+
goal_count INTEGER NOT NULL DEFAULT 0,
|
|
3194
|
+
success_count INTEGER NOT NULL DEFAULT 0,
|
|
3195
|
+
failure_count INTEGER NOT NULL DEFAULT 0,
|
|
3196
|
+
risk_count INTEGER NOT NULL DEFAULT 0,
|
|
3197
|
+
summary TEXT NOT NULL,
|
|
3198
|
+
learnings TEXT NOT NULL DEFAULT '[]',
|
|
3199
|
+
next_actions TEXT NOT NULL DEFAULT '[]',
|
|
3200
|
+
evidence_event_ids TEXT NOT NULL DEFAULT '[]',
|
|
3201
|
+
confidence REAL NOT NULL DEFAULT 0,
|
|
3202
|
+
created_at TEXT NOT NULL
|
|
3203
|
+
);
|
|
3204
|
+
|
|
3205
|
+
CREATE INDEX IF NOT EXISTS idx_agent_reflection_project_time
|
|
3206
|
+
ON agent_reflection_checkpoints(project_name, window_end_at);
|
|
3207
|
+
|
|
3208
|
+
CREATE INDEX IF NOT EXISTS idx_agent_reflection_session_time
|
|
3209
|
+
ON agent_reflection_checkpoints(session_id, window_end_at);
|
|
3210
|
+
`);
|
|
3073
3211
|
try {
|
|
3074
3212
|
await client.execute({
|
|
3075
3213
|
sql: `ALTER TABLE memories ADD COLUMN tier INTEGER DEFAULT 3`,
|
|
@@ -3362,7 +3500,7 @@ var init_task_scope = __esm({
|
|
|
3362
3500
|
|
|
3363
3501
|
// src/lib/keychain.ts
|
|
3364
3502
|
import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2 } from "fs/promises";
|
|
3365
|
-
import { existsSync as existsSync12 } from "fs";
|
|
3503
|
+
import { existsSync as existsSync12, statSync as statSync2 } from "fs";
|
|
3366
3504
|
import { execSync as execSync5 } from "child_process";
|
|
3367
3505
|
import path14 from "path";
|
|
3368
3506
|
import os10 from "os";
|
|
@@ -3372,29 +3510,78 @@ function getKeyDir() {
|
|
|
3372
3510
|
function getKeyPath() {
|
|
3373
3511
|
return path14.join(getKeyDir(), "master.key");
|
|
3374
3512
|
}
|
|
3375
|
-
function
|
|
3513
|
+
function nativeKeychainAllowed() {
|
|
3514
|
+
return process.env.EXE_OS_DISABLE_NATIVE_KEYCHAIN !== "1";
|
|
3515
|
+
}
|
|
3516
|
+
function linuxSecretAvailable() {
|
|
3517
|
+
if (!nativeKeychainAllowed()) return false;
|
|
3518
|
+
if (process.platform !== "linux") return false;
|
|
3519
|
+
if (linuxSecretAvailability !== null) return linuxSecretAvailability;
|
|
3520
|
+
try {
|
|
3521
|
+
execSync5("command -v secret-tool >/dev/null 2>&1", { timeout: 1e3 });
|
|
3522
|
+
} catch {
|
|
3523
|
+
linuxSecretAvailability = false;
|
|
3524
|
+
return false;
|
|
3525
|
+
}
|
|
3526
|
+
try {
|
|
3527
|
+
execSync5("secret-tool search --all exe-os probe >/dev/null 2>&1", { timeout: 1e3 });
|
|
3528
|
+
linuxSecretAvailability = true;
|
|
3529
|
+
} catch {
|
|
3530
|
+
linuxSecretAvailability = false;
|
|
3531
|
+
}
|
|
3532
|
+
return linuxSecretAvailability;
|
|
3533
|
+
}
|
|
3534
|
+
function isRootOnlyTrustedServerKeyFile(keyPath) {
|
|
3535
|
+
if (process.platform !== "linux") return false;
|
|
3536
|
+
try {
|
|
3537
|
+
const uid = typeof os10.userInfo().uid === "number" ? os10.userInfo().uid : -1;
|
|
3538
|
+
const st = statSync2(keyPath);
|
|
3539
|
+
if (!st.isFile() || (st.mode & 63) !== 0) return false;
|
|
3540
|
+
if (uid === 0) return true;
|
|
3541
|
+
const exeOsDir = process.env.EXE_OS_DIR;
|
|
3542
|
+
return Boolean(exeOsDir && path14.resolve(keyPath).startsWith(path14.resolve(exeOsDir) + path14.sep));
|
|
3543
|
+
} catch {
|
|
3544
|
+
return false;
|
|
3545
|
+
}
|
|
3546
|
+
}
|
|
3547
|
+
function macKeychainGet(service = SERVICE) {
|
|
3548
|
+
if (!nativeKeychainAllowed()) return null;
|
|
3376
3549
|
if (process.platform !== "darwin") return null;
|
|
3377
3550
|
try {
|
|
3378
3551
|
return execSync5(
|
|
3379
|
-
`security find-generic-password -s "${
|
|
3552
|
+
`security find-generic-password -s "${service}" -a "${ACCOUNT}" -w 2>/dev/null`,
|
|
3380
3553
|
{ encoding: "utf-8", timeout: 5e3 }
|
|
3381
3554
|
).trim();
|
|
3382
3555
|
} catch {
|
|
3383
3556
|
return null;
|
|
3384
3557
|
}
|
|
3385
3558
|
}
|
|
3386
|
-
function macKeychainSet(value) {
|
|
3559
|
+
function macKeychainSet(value, service = SERVICE) {
|
|
3560
|
+
if (!nativeKeychainAllowed()) return false;
|
|
3387
3561
|
if (process.platform !== "darwin") return false;
|
|
3388
3562
|
try {
|
|
3389
3563
|
try {
|
|
3390
3564
|
execSync5(
|
|
3391
|
-
`security delete-generic-password -s "${
|
|
3565
|
+
`security delete-generic-password -s "${service}" -a "${ACCOUNT}" 2>/dev/null`,
|
|
3392
3566
|
{ timeout: 5e3 }
|
|
3393
3567
|
);
|
|
3394
3568
|
} catch {
|
|
3395
3569
|
}
|
|
3396
3570
|
execSync5(
|
|
3397
|
-
`security add-generic-password -s "${
|
|
3571
|
+
`security add-generic-password -s "${service}" -a "${ACCOUNT}" -w "${value}"`,
|
|
3572
|
+
{ timeout: 5e3 }
|
|
3573
|
+
);
|
|
3574
|
+
return true;
|
|
3575
|
+
} catch {
|
|
3576
|
+
return false;
|
|
3577
|
+
}
|
|
3578
|
+
}
|
|
3579
|
+
function macKeychainDelete(service = SERVICE) {
|
|
3580
|
+
if (!nativeKeychainAllowed()) return false;
|
|
3581
|
+
if (process.platform !== "darwin") return false;
|
|
3582
|
+
try {
|
|
3583
|
+
execSync5(
|
|
3584
|
+
`security delete-generic-password -s "${service}" -a "${ACCOUNT}" 2>/dev/null`,
|
|
3398
3585
|
{ timeout: 5e3 }
|
|
3399
3586
|
);
|
|
3400
3587
|
return true;
|
|
@@ -3402,22 +3589,35 @@ function macKeychainSet(value) {
|
|
|
3402
3589
|
return false;
|
|
3403
3590
|
}
|
|
3404
3591
|
}
|
|
3405
|
-
function linuxSecretGet() {
|
|
3406
|
-
if (
|
|
3592
|
+
function linuxSecretGet(service = SERVICE) {
|
|
3593
|
+
if (!linuxSecretAvailable()) return null;
|
|
3407
3594
|
try {
|
|
3408
3595
|
return execSync5(
|
|
3409
|
-
`secret-tool lookup service "${
|
|
3596
|
+
`secret-tool lookup service "${service}" account "${ACCOUNT}" 2>/dev/null`,
|
|
3410
3597
|
{ encoding: "utf-8", timeout: 5e3 }
|
|
3411
3598
|
).trim();
|
|
3412
3599
|
} catch {
|
|
3413
3600
|
return null;
|
|
3414
3601
|
}
|
|
3415
3602
|
}
|
|
3416
|
-
function linuxSecretSet(value) {
|
|
3603
|
+
function linuxSecretSet(value, service = SERVICE) {
|
|
3604
|
+
if (!linuxSecretAvailable()) return false;
|
|
3605
|
+
try {
|
|
3606
|
+
execSync5(
|
|
3607
|
+
`echo -n "${value}" | secret-tool store --label="exe-os master key" service "${service}" account "${ACCOUNT}" 2>/dev/null`,
|
|
3608
|
+
{ timeout: 5e3 }
|
|
3609
|
+
);
|
|
3610
|
+
return true;
|
|
3611
|
+
} catch {
|
|
3612
|
+
return false;
|
|
3613
|
+
}
|
|
3614
|
+
}
|
|
3615
|
+
function linuxSecretDelete(service = SERVICE) {
|
|
3616
|
+
if (!nativeKeychainAllowed()) return false;
|
|
3417
3617
|
if (process.platform !== "linux") return false;
|
|
3418
3618
|
try {
|
|
3419
3619
|
execSync5(
|
|
3420
|
-
`
|
|
3620
|
+
`secret-tool clear service "${service}" account "${ACCOUNT}" 2>/dev/null`,
|
|
3421
3621
|
{ timeout: 5e3 }
|
|
3422
3622
|
);
|
|
3423
3623
|
return true;
|
|
@@ -3426,6 +3626,7 @@ function linuxSecretSet(value) {
|
|
|
3426
3626
|
}
|
|
3427
3627
|
}
|
|
3428
3628
|
async function tryKeytar() {
|
|
3629
|
+
if (!nativeKeychainAllowed()) return null;
|
|
3429
3630
|
try {
|
|
3430
3631
|
return await import("keytar");
|
|
3431
3632
|
} catch {
|
|
@@ -3499,7 +3700,19 @@ async function writeMachineBoundFileFallback(b64) {
|
|
|
3499
3700
|
return "plaintext";
|
|
3500
3701
|
}
|
|
3501
3702
|
async function getMasterKey() {
|
|
3502
|
-
|
|
3703
|
+
let nativeValue = macKeychainGet() ?? linuxSecretGet();
|
|
3704
|
+
if (!nativeValue) {
|
|
3705
|
+
const legacyValue = macKeychainGet(LEGACY_SERVICE) ?? linuxSecretGet(LEGACY_SERVICE);
|
|
3706
|
+
if (legacyValue) {
|
|
3707
|
+
const migrated = macKeychainSet(legacyValue) || linuxSecretSet(legacyValue);
|
|
3708
|
+
if (migrated) {
|
|
3709
|
+
macKeychainDelete(LEGACY_SERVICE);
|
|
3710
|
+
linuxSecretDelete(LEGACY_SERVICE);
|
|
3711
|
+
process.stderr.write("[keychain] Migrated keychain service from exe-mem to exe-os.\n");
|
|
3712
|
+
}
|
|
3713
|
+
nativeValue = legacyValue;
|
|
3714
|
+
}
|
|
3715
|
+
}
|
|
3503
3716
|
if (nativeValue) {
|
|
3504
3717
|
return Buffer.from(nativeValue, "base64");
|
|
3505
3718
|
}
|
|
@@ -3507,12 +3720,17 @@ async function getMasterKey() {
|
|
|
3507
3720
|
if (keytar) {
|
|
3508
3721
|
try {
|
|
3509
3722
|
const keytarValue = await keytar.getPassword(SERVICE, ACCOUNT);
|
|
3510
|
-
|
|
3511
|
-
|
|
3723
|
+
const legacyKeytarValue = keytarValue ?? await keytar.getPassword(LEGACY_SERVICE, ACCOUNT);
|
|
3724
|
+
if (legacyKeytarValue) {
|
|
3725
|
+
const migrated = macKeychainSet(legacyKeytarValue) || linuxSecretSet(legacyKeytarValue);
|
|
3512
3726
|
if (migrated) {
|
|
3513
3727
|
process.stderr.write("[keychain] Migrated key from keytar to native keychain.\n");
|
|
3728
|
+
try {
|
|
3729
|
+
await keytar.deletePassword(LEGACY_SERVICE, ACCOUNT);
|
|
3730
|
+
} catch {
|
|
3731
|
+
}
|
|
3514
3732
|
}
|
|
3515
|
-
return Buffer.from(
|
|
3733
|
+
return Buffer.from(legacyKeytarValue, "base64");
|
|
3516
3734
|
}
|
|
3517
3735
|
} catch {
|
|
3518
3736
|
}
|
|
@@ -3537,7 +3755,7 @@ async function getMasterKey() {
|
|
|
3537
3755
|
const decrypted = decryptWithMachineKey(content, machineKey);
|
|
3538
3756
|
if (!decrypted) {
|
|
3539
3757
|
process.stderr.write(
|
|
3540
|
-
"[keychain] Key decryption failed \u2014 machine may have changed.\n Use your 24-word recovery phrase: exe-os
|
|
3758
|
+
"[keychain] Key decryption failed \u2014 machine may have changed.\n Use your 24-word recovery phrase during setup: exe-os setup\n"
|
|
3541
3759
|
);
|
|
3542
3760
|
return null;
|
|
3543
3761
|
}
|
|
@@ -3546,6 +3764,9 @@ async function getMasterKey() {
|
|
|
3546
3764
|
b64Value = content;
|
|
3547
3765
|
}
|
|
3548
3766
|
const key = Buffer.from(b64Value, "base64");
|
|
3767
|
+
if (!content.startsWith(ENCRYPTED_PREFIX) && isRootOnlyTrustedServerKeyFile(keyPath)) {
|
|
3768
|
+
return key;
|
|
3769
|
+
}
|
|
3549
3770
|
const migrated = macKeychainSet(b64Value) || linuxSecretSet(b64Value);
|
|
3550
3771
|
if (migrated) {
|
|
3551
3772
|
process.stderr.write("[keychain] Migrated key from file to native keychain.\n");
|
|
@@ -3573,12 +3794,14 @@ async function getMasterKey() {
|
|
|
3573
3794
|
return null;
|
|
3574
3795
|
}
|
|
3575
3796
|
}
|
|
3576
|
-
var SERVICE, ACCOUNT, ENCRYPTED_PREFIX;
|
|
3797
|
+
var SERVICE, LEGACY_SERVICE, ACCOUNT, linuxSecretAvailability, ENCRYPTED_PREFIX;
|
|
3577
3798
|
var init_keychain = __esm({
|
|
3578
3799
|
"src/lib/keychain.ts"() {
|
|
3579
3800
|
"use strict";
|
|
3580
|
-
SERVICE = "exe-
|
|
3801
|
+
SERVICE = "exe-os";
|
|
3802
|
+
LEGACY_SERVICE = "exe-mem";
|
|
3581
3803
|
ACCOUNT = "master-key";
|
|
3804
|
+
linuxSecretAvailability = null;
|
|
3582
3805
|
ENCRYPTED_PREFIX = "enc:";
|
|
3583
3806
|
}
|
|
3584
3807
|
});
|
|
@@ -3848,7 +4071,7 @@ __export(shard_manager_exports, {
|
|
|
3848
4071
|
shardExists: () => shardExists
|
|
3849
4072
|
});
|
|
3850
4073
|
import path15 from "path";
|
|
3851
|
-
import { existsSync as existsSync13, mkdirSync as mkdirSync7, readdirSync as readdirSync3, renameSync as renameSync4, statSync as
|
|
4074
|
+
import { existsSync as existsSync13, mkdirSync as mkdirSync7, readdirSync as readdirSync3, renameSync as renameSync4, statSync as statSync3 } from "fs";
|
|
3852
4075
|
import { createClient as createClient2 } from "@libsql/client";
|
|
3853
4076
|
function initShardManager(encryptionKey) {
|
|
3854
4077
|
_encryptionKey = encryptionKey;
|
|
@@ -3912,7 +4135,7 @@ async function auditShardHealth(options = {}) {
|
|
|
3912
4135
|
const shards = [];
|
|
3913
4136
|
for (const name of names) {
|
|
3914
4137
|
const dbPath = path15.join(SHARDS_DIR, `${name}.db`);
|
|
3915
|
-
const stat =
|
|
4138
|
+
const stat = statSync3(dbPath);
|
|
3916
4139
|
const item = {
|
|
3917
4140
|
name,
|
|
3918
4141
|
path: dbPath,
|
|
@@ -4165,7 +4388,7 @@ async function getReadyShardClient(projectName) {
|
|
|
4165
4388
|
_shardLastAccess.delete(safeName);
|
|
4166
4389
|
const dbPath = path15.join(SHARDS_DIR, `${safeName}.db`);
|
|
4167
4390
|
if (existsSync13(dbPath)) {
|
|
4168
|
-
const stat =
|
|
4391
|
+
const stat = statSync3(dbPath);
|
|
4169
4392
|
const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
4170
4393
|
const archivedPath = path15.join(SHARDS_DIR, `${safeName}.db.broken-${stamp}`);
|
|
4171
4394
|
renameSync4(dbPath, archivedPath);
|
|
@@ -4285,6 +4508,12 @@ var init_platform_procedures = __esm({
|
|
|
4285
4508
|
priority: "p0",
|
|
4286
4509
|
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."
|
|
4287
4510
|
},
|
|
4511
|
+
{
|
|
4512
|
+
title: "Customer orchestration maturity \u2014 recommend, never trap",
|
|
4513
|
+
domain: "workflow",
|
|
4514
|
+
priority: "p1",
|
|
4515
|
+
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."
|
|
4516
|
+
},
|
|
4288
4517
|
{
|
|
4289
4518
|
title: "Single dispatch path \u2014 create_task only",
|
|
4290
4519
|
domain: "workflow",
|
|
@@ -4343,6 +4572,12 @@ var init_platform_procedures = __esm({
|
|
|
4343
4572
|
priority: "p0",
|
|
4344
4573
|
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."
|
|
4345
4574
|
},
|
|
4575
|
+
{
|
|
4576
|
+
title: "Commit discipline \u2014 never leave verified work floating",
|
|
4577
|
+
domain: "workflow",
|
|
4578
|
+
priority: "p1",
|
|
4579
|
+
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."
|
|
4580
|
+
},
|
|
4346
4581
|
{
|
|
4347
4582
|
title: "Desktop and TUI are the same product",
|
|
4348
4583
|
domain: "architecture",
|
|
@@ -4660,6 +4895,274 @@ var init_memory_cards = __esm({
|
|
|
4660
4895
|
}
|
|
4661
4896
|
});
|
|
4662
4897
|
|
|
4898
|
+
// src/lib/agentic-ontology.ts
|
|
4899
|
+
var agentic_ontology_exports = {};
|
|
4900
|
+
__export(agentic_ontology_exports, {
|
|
4901
|
+
clean: () => clean,
|
|
4902
|
+
extractGoalCandidates: () => extractGoalCandidates,
|
|
4903
|
+
inferIntention: () => inferIntention,
|
|
4904
|
+
inferOntologyEventType: () => inferOntologyEventType,
|
|
4905
|
+
inferOutcome: () => inferOutcome,
|
|
4906
|
+
inferSemanticLabel: () => inferSemanticLabel,
|
|
4907
|
+
insertOntologyForBatch: () => insertOntologyForBatch,
|
|
4908
|
+
insertOntologyForMemory: () => insertOntologyForMemory,
|
|
4909
|
+
ontologyPayload: () => ontologyPayload,
|
|
4910
|
+
stableId: () => stableId2
|
|
4911
|
+
});
|
|
4912
|
+
import { createHash as createHash3 } from "crypto";
|
|
4913
|
+
function stableId2(...parts) {
|
|
4914
|
+
return createHash3("sha256").update(parts.map((p) => String(p ?? "")).join("::")).digest("hex").slice(0, 32);
|
|
4915
|
+
}
|
|
4916
|
+
function clean(text, max = 240) {
|
|
4917
|
+
return text.replace(/\u0000/g, "").replace(/```[\s\S]*?```/g, " ").replace(/\s+/g, " ").trim().slice(0, max);
|
|
4918
|
+
}
|
|
4919
|
+
function inferOntologyEventType(row) {
|
|
4920
|
+
const lower = row.raw_text.toLowerCase();
|
|
4921
|
+
if (row.has_error) return "error";
|
|
4922
|
+
if (/\b(done|complete|completed|fixed|resolved|shipped|deployed|pushed|published)\b/.test(lower)) return "milestone";
|
|
4923
|
+
if (/\b(blocked|failed|error|bug|regression|broken)\b/.test(lower)) return "problem";
|
|
4924
|
+
if (/\b(decided|decision|adr|we chose|approved|rejected)\b/.test(lower)) return "decision";
|
|
4925
|
+
if (/\b(goal|need to|we need|want to|trying to|objective)\b/.test(lower)) return "goal_signal";
|
|
4926
|
+
if (["Bash", "Read", "Edit", "Write", "Grep", "Glob"].includes(row.tool_name)) return "tool_action";
|
|
4927
|
+
if (row.tool_name.startsWith("memory_card")) return "memory_card";
|
|
4928
|
+
return "memory_observation";
|
|
4929
|
+
}
|
|
4930
|
+
function inferIntention(row) {
|
|
4931
|
+
if (row.intent) return clean(row.intent, 220);
|
|
4932
|
+
const text = clean(row.raw_text, 1e3);
|
|
4933
|
+
const patterns = [
|
|
4934
|
+
/(?: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,
|
|
4935
|
+
/(?:so that|in order to)\s+([^.!?\n]{8,220})/i,
|
|
4936
|
+
/(?:task|plan):\s*([^.!?\n]{8,220})/i
|
|
4937
|
+
];
|
|
4938
|
+
for (const p of patterns) {
|
|
4939
|
+
const m = text.match(p);
|
|
4940
|
+
if (m?.[1]) return clean(m[1], 220);
|
|
4941
|
+
}
|
|
4942
|
+
if (["Bash", "Read", "Edit", "Write", "Grep", "Glob"].includes(row.tool_name)) {
|
|
4943
|
+
return `${row.tool_name} during ${row.project_name}`;
|
|
4944
|
+
}
|
|
4945
|
+
return null;
|
|
4946
|
+
}
|
|
4947
|
+
function inferOutcome(row) {
|
|
4948
|
+
if (row.outcome) return clean(row.outcome, 220);
|
|
4949
|
+
if (row.has_error) return "error";
|
|
4950
|
+
const lower = row.raw_text.toLowerCase();
|
|
4951
|
+
if (/\b(done|complete|completed|fixed|resolved|shipped|deployed|pushed|published|passed)\b/.test(lower)) return "success_signal";
|
|
4952
|
+
if (/\b(blocked|failed|error|regression|broken|not working|could not)\b/.test(lower)) return "failure_signal";
|
|
4953
|
+
if (/\b(warning|risk|concern|caveat)\b/.test(lower)) return "risk_signal";
|
|
4954
|
+
return null;
|
|
4955
|
+
}
|
|
4956
|
+
function extractGoalCandidates(row) {
|
|
4957
|
+
const text = clean(row.raw_text, 1600);
|
|
4958
|
+
const patterns = [
|
|
4959
|
+
/(?: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,
|
|
4960
|
+
/(?:success means|success criteria|so that)\s+([^.!?\n]{12,220})/gi
|
|
4961
|
+
];
|
|
4962
|
+
const out = [];
|
|
4963
|
+
for (const pattern of patterns) {
|
|
4964
|
+
for (const m of text.matchAll(pattern)) {
|
|
4965
|
+
const candidate = clean(m[1] ?? "", 220);
|
|
4966
|
+
if (candidate.length >= 12 && !out.some((x) => x.toLowerCase() === candidate.toLowerCase())) out.push(candidate);
|
|
4967
|
+
if (out.length >= 3) return out;
|
|
4968
|
+
}
|
|
4969
|
+
}
|
|
4970
|
+
return out;
|
|
4971
|
+
}
|
|
4972
|
+
function uniq(values, max = 6) {
|
|
4973
|
+
const out = [];
|
|
4974
|
+
for (const value of values.map((v) => clean(v, 220)).filter(Boolean)) {
|
|
4975
|
+
if (!out.some((x) => x.toLowerCase() === value.toLowerCase())) out.push(value);
|
|
4976
|
+
if (out.length >= max) break;
|
|
4977
|
+
}
|
|
4978
|
+
return out;
|
|
4979
|
+
}
|
|
4980
|
+
function extractMatches(text, patterns, max = 5) {
|
|
4981
|
+
const out = [];
|
|
4982
|
+
for (const pattern of patterns) {
|
|
4983
|
+
for (const match of text.matchAll(pattern)) {
|
|
4984
|
+
const value = match[1] ?? match[0];
|
|
4985
|
+
if (value) out.push(value);
|
|
4986
|
+
if (out.length >= max) return uniq(out, max);
|
|
4987
|
+
}
|
|
4988
|
+
}
|
|
4989
|
+
return uniq(out, max);
|
|
4990
|
+
}
|
|
4991
|
+
function inferSemanticLabel(row) {
|
|
4992
|
+
const text = clean(row.raw_text, 2400);
|
|
4993
|
+
const eventType = inferOntologyEventType(row);
|
|
4994
|
+
const intention = inferIntention(row);
|
|
4995
|
+
const outcome = inferOutcome(row);
|
|
4996
|
+
const goals = extractGoalCandidates(row);
|
|
4997
|
+
const milestones = extractMatches(text, [
|
|
4998
|
+
/\b(?:completed|finished|fixed|resolved|shipped|deployed|published|pushed|passed)\b([^.!?\n]{0,180})/gi,
|
|
4999
|
+
/(?:milestone|done):\s*([^.!?\n]{8,220})/gi
|
|
5000
|
+
]);
|
|
5001
|
+
const problems = extractMatches(text, [
|
|
5002
|
+
/\b(?:blocked by|failed because|bug|regression|broken|not working|error)\b([^.!?\n]{0,180})/gi,
|
|
5003
|
+
/(?:problem|issue|risk):\s*([^.!?\n]{8,220})/gi
|
|
5004
|
+
]);
|
|
5005
|
+
const decisions = extractMatches(text, [
|
|
5006
|
+
/(?:decided|decision|adr|we chose|approved|rejected)\s+([^.!?\n]{8,220})/gi
|
|
5007
|
+
]);
|
|
5008
|
+
const temporalAnchors = extractMatches(text, [
|
|
5009
|
+
/\b(\d{4}-\d{2}-\d{2}(?:[T ][0-9:.+-Z]+)?)\b/g,
|
|
5010
|
+
/\b(today|yesterday|tomorrow|this week|next week|last week|morning|afternoon|tonight)\b/gi
|
|
5011
|
+
], 8);
|
|
5012
|
+
const nextActions = extractMatches(text, [
|
|
5013
|
+
/(?:next|todo|follow[- ]?up|remaining|need to)\s*:?\s*([^.!?\n]{8,220})/gi
|
|
5014
|
+
]);
|
|
5015
|
+
const actors = uniq([
|
|
5016
|
+
row.agent_id,
|
|
5017
|
+
...extractMatches(text, [/\b(?:agent|employee|owner|assignee)[:= ]+([a-zA-Z][a-zA-Z0-9_-]{1,40})/gi], 5)
|
|
5018
|
+
], 6);
|
|
5019
|
+
const successSignals = milestones.length ? milestones : outcome === "success_signal" ? [clean(text, 180)] : [];
|
|
5020
|
+
const failureSignals = problems.length ? problems : outcome === "failure_signal" || row.has_error ? [clean(text, 180)] : [];
|
|
5021
|
+
const impact = successSignals.length && failureSignals.length ? "mixed" : failureSignals.length ? "negative" : successSignals.length ? "positive" : "neutral";
|
|
5022
|
+
const signalCount = goals.length + milestones.length + problems.length + decisions.length + nextActions.length;
|
|
5023
|
+
return {
|
|
5024
|
+
labeler: "deterministic",
|
|
5025
|
+
schemaVersion: 1,
|
|
5026
|
+
eventType,
|
|
5027
|
+
intention,
|
|
5028
|
+
outcome,
|
|
5029
|
+
impact,
|
|
5030
|
+
confidence: Math.min(0.95, 0.45 + signalCount * 0.08 + (intention ? 0.1 : 0) + (outcome ? 0.1 : 0)),
|
|
5031
|
+
goals,
|
|
5032
|
+
milestones,
|
|
5033
|
+
problems,
|
|
5034
|
+
decisions,
|
|
5035
|
+
actors,
|
|
5036
|
+
temporalAnchors,
|
|
5037
|
+
successSignals,
|
|
5038
|
+
failureSignals,
|
|
5039
|
+
nextActions,
|
|
5040
|
+
summary: clean(text, 280)
|
|
5041
|
+
};
|
|
5042
|
+
}
|
|
5043
|
+
function ontologyPayload(row) {
|
|
5044
|
+
const semantic = inferSemanticLabel(row);
|
|
5045
|
+
return {
|
|
5046
|
+
tool_name: row.tool_name,
|
|
5047
|
+
memory_version: row.version ?? null,
|
|
5048
|
+
domain: row.domain ?? null,
|
|
5049
|
+
trajectory: row.trajectory ? safeJson(row.trajectory) : null,
|
|
5050
|
+
semantic
|
|
5051
|
+
};
|
|
5052
|
+
}
|
|
5053
|
+
function safeJson(value) {
|
|
5054
|
+
try {
|
|
5055
|
+
return JSON.parse(value);
|
|
5056
|
+
} catch {
|
|
5057
|
+
return value.slice(0, 1e3);
|
|
5058
|
+
}
|
|
5059
|
+
}
|
|
5060
|
+
async function resolveClient(client) {
|
|
5061
|
+
if (client) return client;
|
|
5062
|
+
const { getClient: getClient2 } = await Promise.resolve().then(() => (init_database(), database_exports));
|
|
5063
|
+
return getClient2();
|
|
5064
|
+
}
|
|
5065
|
+
async function insertOntologyForMemory(row, client) {
|
|
5066
|
+
const db = await resolveClient(client);
|
|
5067
|
+
const occurredAt = row.timestamp;
|
|
5068
|
+
const sequence = Number(row.version ?? 0) || Math.floor(new Date(occurredAt).getTime() / 1e3);
|
|
5069
|
+
const eventType = inferOntologyEventType(row);
|
|
5070
|
+
const intention = inferIntention(row);
|
|
5071
|
+
const outcome = inferOutcome(row);
|
|
5072
|
+
const eventId = stableId2("event", row.id);
|
|
5073
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
5074
|
+
await db.execute({
|
|
5075
|
+
sql: `INSERT INTO agent_sessions (id, agent_id, project_name, started_at, last_event_at, event_count, properties)
|
|
5076
|
+
VALUES (?, ?, ?, ?, ?, 1, ?)
|
|
5077
|
+
ON CONFLICT(id) DO UPDATE SET last_event_at = MAX(last_event_at, excluded.last_event_at),
|
|
5078
|
+
event_count = event_count + 1`,
|
|
5079
|
+
args: [row.session_id, row.agent_id, row.project_name, occurredAt, occurredAt, JSON.stringify({ agent_role: row.agent_role })]
|
|
5080
|
+
});
|
|
5081
|
+
await db.execute({
|
|
5082
|
+
sql: `INSERT OR IGNORE INTO agent_events
|
|
5083
|
+
(id, event_type, occurred_at, sequence_index, actor_agent_id, agent_role, project_name,
|
|
5084
|
+
session_id, task_id, goal_id, parent_event_id, intention, outcome, evidence_memory_id,
|
|
5085
|
+
impact, payload, created_at)
|
|
5086
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NULL, NULL, ?, ?, ?, ?, ?, ?)`,
|
|
5087
|
+
args: [
|
|
5088
|
+
eventId,
|
|
5089
|
+
eventType,
|
|
5090
|
+
occurredAt,
|
|
5091
|
+
sequence,
|
|
5092
|
+
row.agent_id,
|
|
5093
|
+
row.agent_role,
|
|
5094
|
+
row.project_name,
|
|
5095
|
+
row.session_id,
|
|
5096
|
+
row.task_id ?? null,
|
|
5097
|
+
intention,
|
|
5098
|
+
outcome,
|
|
5099
|
+
row.id,
|
|
5100
|
+
row.has_error ? "negative" : outcome === "success_signal" ? "positive" : "neutral",
|
|
5101
|
+
JSON.stringify(ontologyPayload(row)),
|
|
5102
|
+
now
|
|
5103
|
+
]
|
|
5104
|
+
});
|
|
5105
|
+
const semantic = inferSemanticLabel(row);
|
|
5106
|
+
await db.execute({
|
|
5107
|
+
sql: `INSERT INTO agent_semantic_labels
|
|
5108
|
+
(id, source_memory_id, event_id, labeler, schema_version, confidence, labels, created_at, updated_at)
|
|
5109
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
5110
|
+
ON CONFLICT(id) DO UPDATE SET confidence = excluded.confidence,
|
|
5111
|
+
labels = excluded.labels, updated_at = excluded.updated_at`,
|
|
5112
|
+
args: [
|
|
5113
|
+
stableId2("semantic", row.id, semantic.labeler, semantic.schemaVersion),
|
|
5114
|
+
row.id,
|
|
5115
|
+
eventId,
|
|
5116
|
+
semantic.labeler,
|
|
5117
|
+
semantic.schemaVersion,
|
|
5118
|
+
semantic.confidence,
|
|
5119
|
+
JSON.stringify(semantic),
|
|
5120
|
+
now,
|
|
5121
|
+
now
|
|
5122
|
+
]
|
|
5123
|
+
});
|
|
5124
|
+
for (const statement of extractGoalCandidates(row)) {
|
|
5125
|
+
const goalId = stableId2("goal", row.project_name, statement.toLowerCase());
|
|
5126
|
+
await db.execute({
|
|
5127
|
+
sql: `INSERT INTO agent_goals
|
|
5128
|
+
(id, statement, owner_agent_id, project_name, status, priority, success_criteria,
|
|
5129
|
+
parent_goal_id, due_at, achieved_at, supersedes_id, created_at, updated_at, source_memory_id)
|
|
5130
|
+
VALUES (?, ?, ?, ?, 'open', 5, NULL, NULL, NULL, NULL, NULL, ?, ?, ?)
|
|
5131
|
+
ON CONFLICT(id) DO UPDATE SET updated_at = excluded.updated_at`,
|
|
5132
|
+
args: [goalId, statement, row.agent_id, row.project_name, now, now, row.id]
|
|
5133
|
+
});
|
|
5134
|
+
await db.execute({
|
|
5135
|
+
sql: `INSERT OR IGNORE INTO agent_goal_links
|
|
5136
|
+
(id, goal_id, link_type, target_id, target_type, created_at)
|
|
5137
|
+
VALUES (?, ?, 'evidence', ?, 'memory', ?)`,
|
|
5138
|
+
args: [stableId2("goal_link", goalId, row.id, "memory"), goalId, row.id, now]
|
|
5139
|
+
});
|
|
5140
|
+
await db.execute({
|
|
5141
|
+
sql: `INSERT OR IGNORE INTO agent_goal_links
|
|
5142
|
+
(id, goal_id, link_type, target_id, target_type, created_at)
|
|
5143
|
+
VALUES (?, ?, 'event', ?, 'event', ?)`,
|
|
5144
|
+
args: [stableId2("goal_link", goalId, eventId, "event"), goalId, eventId, now]
|
|
5145
|
+
});
|
|
5146
|
+
}
|
|
5147
|
+
}
|
|
5148
|
+
async function insertOntologyForBatch(rows, client) {
|
|
5149
|
+
const db = await resolveClient(client);
|
|
5150
|
+
let count = 0;
|
|
5151
|
+
for (const row of rows) {
|
|
5152
|
+
try {
|
|
5153
|
+
await insertOntologyForMemory(row, db);
|
|
5154
|
+
count++;
|
|
5155
|
+
} catch {
|
|
5156
|
+
}
|
|
5157
|
+
}
|
|
5158
|
+
return count;
|
|
5159
|
+
}
|
|
5160
|
+
var init_agentic_ontology = __esm({
|
|
5161
|
+
"src/lib/agentic-ontology.ts"() {
|
|
5162
|
+
"use strict";
|
|
5163
|
+
}
|
|
5164
|
+
});
|
|
5165
|
+
|
|
4663
5166
|
// src/lib/store.ts
|
|
4664
5167
|
var store_exports = {};
|
|
4665
5168
|
__export(store_exports, {
|
|
@@ -5003,6 +5506,11 @@ async function flushBatch() {
|
|
|
5003
5506
|
await insertMemoryCardsForBatch2(batch);
|
|
5004
5507
|
} catch {
|
|
5005
5508
|
}
|
|
5509
|
+
try {
|
|
5510
|
+
const { insertOntologyForBatch: insertOntologyForBatch2 } = await Promise.resolve().then(() => (init_agentic_ontology(), agentic_ontology_exports));
|
|
5511
|
+
await insertOntologyForBatch2(batch);
|
|
5512
|
+
} catch {
|
|
5513
|
+
}
|
|
5006
5514
|
schedulePostWriteMemoryHygiene(batch.map((row) => row.id));
|
|
5007
5515
|
_pendingRecords.splice(0, batch.length);
|
|
5008
5516
|
try {
|