@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/hooks/stop.js
CHANGED
|
@@ -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") };
|
|
@@ -181,7 +191,16 @@ function loadConfigSync() {
|
|
|
181
191
|
normalizeScalingRoadmap(migratedCfg);
|
|
182
192
|
normalizeSessionLifecycle(migratedCfg);
|
|
183
193
|
normalizeAutoUpdate(migratedCfg);
|
|
184
|
-
|
|
194
|
+
normalizeOrchestration(migratedCfg);
|
|
195
|
+
const config = { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db"), ...migratedCfg };
|
|
196
|
+
if (config.dbPath.startsWith("~")) {
|
|
197
|
+
config.dbPath = config.dbPath.replace(/^~/, os.homedir());
|
|
198
|
+
}
|
|
199
|
+
const envDbPath = path.join(dir, "memories.db");
|
|
200
|
+
if (process.env.EXE_OS_DIR && config.dbPath !== envDbPath && !existsSync2(config.dbPath) && existsSync2(envDbPath)) {
|
|
201
|
+
config.dbPath = envDbPath;
|
|
202
|
+
}
|
|
203
|
+
return config;
|
|
185
204
|
} catch {
|
|
186
205
|
return { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db") };
|
|
187
206
|
}
|
|
@@ -252,6 +271,10 @@ var init_config = __esm({
|
|
|
252
271
|
checkOnBoot: true,
|
|
253
272
|
autoInstall: false,
|
|
254
273
|
checkIntervalMs: 24 * 60 * 60 * 1e3
|
|
274
|
+
},
|
|
275
|
+
orchestration: {
|
|
276
|
+
phase: "phase_1_coo",
|
|
277
|
+
phaseSetBy: "default"
|
|
255
278
|
}
|
|
256
279
|
};
|
|
257
280
|
CONFIG_MIGRATIONS = [
|
|
@@ -2057,6 +2080,9 @@ function getClient() {
|
|
|
2057
2080
|
if (_daemonClient && _daemonClient._isDaemonActive()) {
|
|
2058
2081
|
return _daemonClient;
|
|
2059
2082
|
}
|
|
2083
|
+
if (!_resilientClient) {
|
|
2084
|
+
return _adapterClient;
|
|
2085
|
+
}
|
|
2060
2086
|
return _resilientClient;
|
|
2061
2087
|
}
|
|
2062
2088
|
async function initDaemonClient() {
|
|
@@ -3089,6 +3115,127 @@ async function ensureSchema() {
|
|
|
3089
3115
|
VALUES (new.rowid, new.content, new.subject, new.predicate, new.object);
|
|
3090
3116
|
END;
|
|
3091
3117
|
`);
|
|
3118
|
+
await client.executeMultiple(`
|
|
3119
|
+
CREATE TABLE IF NOT EXISTS agent_sessions (
|
|
3120
|
+
id TEXT PRIMARY KEY,
|
|
3121
|
+
agent_id TEXT NOT NULL,
|
|
3122
|
+
project_name TEXT,
|
|
3123
|
+
started_at TEXT NOT NULL,
|
|
3124
|
+
last_event_at TEXT NOT NULL,
|
|
3125
|
+
event_count INTEGER NOT NULL DEFAULT 0,
|
|
3126
|
+
properties TEXT DEFAULT '{}'
|
|
3127
|
+
);
|
|
3128
|
+
|
|
3129
|
+
CREATE INDEX IF NOT EXISTS idx_agent_sessions_agent_time
|
|
3130
|
+
ON agent_sessions(agent_id, started_at);
|
|
3131
|
+
|
|
3132
|
+
CREATE TABLE IF NOT EXISTS agent_goals (
|
|
3133
|
+
id TEXT PRIMARY KEY,
|
|
3134
|
+
statement TEXT NOT NULL,
|
|
3135
|
+
owner_agent_id TEXT,
|
|
3136
|
+
project_name TEXT,
|
|
3137
|
+
status TEXT NOT NULL DEFAULT 'open',
|
|
3138
|
+
priority INTEGER NOT NULL DEFAULT 5,
|
|
3139
|
+
success_criteria TEXT,
|
|
3140
|
+
parent_goal_id TEXT,
|
|
3141
|
+
due_at TEXT,
|
|
3142
|
+
achieved_at TEXT,
|
|
3143
|
+
supersedes_id TEXT,
|
|
3144
|
+
created_at TEXT NOT NULL,
|
|
3145
|
+
updated_at TEXT NOT NULL,
|
|
3146
|
+
source_memory_id TEXT
|
|
3147
|
+
);
|
|
3148
|
+
|
|
3149
|
+
CREATE INDEX IF NOT EXISTS idx_agent_goals_project_status
|
|
3150
|
+
ON agent_goals(project_name, status, priority);
|
|
3151
|
+
|
|
3152
|
+
CREATE TABLE IF NOT EXISTS agent_events (
|
|
3153
|
+
id TEXT PRIMARY KEY,
|
|
3154
|
+
event_type TEXT NOT NULL,
|
|
3155
|
+
occurred_at TEXT NOT NULL,
|
|
3156
|
+
sequence_index INTEGER NOT NULL,
|
|
3157
|
+
actor_agent_id TEXT,
|
|
3158
|
+
agent_role TEXT,
|
|
3159
|
+
project_name TEXT,
|
|
3160
|
+
session_id TEXT,
|
|
3161
|
+
task_id TEXT,
|
|
3162
|
+
goal_id TEXT,
|
|
3163
|
+
parent_event_id TEXT,
|
|
3164
|
+
intention TEXT,
|
|
3165
|
+
outcome TEXT,
|
|
3166
|
+
evidence_memory_id TEXT,
|
|
3167
|
+
impact TEXT,
|
|
3168
|
+
payload TEXT DEFAULT '{}',
|
|
3169
|
+
created_at TEXT NOT NULL
|
|
3170
|
+
);
|
|
3171
|
+
|
|
3172
|
+
CREATE INDEX IF NOT EXISTS idx_agent_events_time
|
|
3173
|
+
ON agent_events(occurred_at, sequence_index);
|
|
3174
|
+
|
|
3175
|
+
CREATE INDEX IF NOT EXISTS idx_agent_events_session_seq
|
|
3176
|
+
ON agent_events(session_id, sequence_index);
|
|
3177
|
+
|
|
3178
|
+
CREATE INDEX IF NOT EXISTS idx_agent_events_goal_time
|
|
3179
|
+
ON agent_events(goal_id, occurred_at);
|
|
3180
|
+
|
|
3181
|
+
CREATE INDEX IF NOT EXISTS idx_agent_events_memory
|
|
3182
|
+
ON agent_events(evidence_memory_id);
|
|
3183
|
+
|
|
3184
|
+
CREATE TABLE IF NOT EXISTS agent_goal_links (
|
|
3185
|
+
id TEXT PRIMARY KEY,
|
|
3186
|
+
goal_id TEXT NOT NULL,
|
|
3187
|
+
link_type TEXT NOT NULL,
|
|
3188
|
+
target_id TEXT NOT NULL,
|
|
3189
|
+
target_type TEXT NOT NULL,
|
|
3190
|
+
created_at TEXT NOT NULL
|
|
3191
|
+
);
|
|
3192
|
+
|
|
3193
|
+
CREATE INDEX IF NOT EXISTS idx_agent_goal_links_goal
|
|
3194
|
+
ON agent_goal_links(goal_id, target_type);
|
|
3195
|
+
|
|
3196
|
+
CREATE TABLE IF NOT EXISTS agent_semantic_labels (
|
|
3197
|
+
id TEXT PRIMARY KEY,
|
|
3198
|
+
source_memory_id TEXT NOT NULL,
|
|
3199
|
+
event_id TEXT,
|
|
3200
|
+
labeler TEXT NOT NULL,
|
|
3201
|
+
schema_version INTEGER NOT NULL DEFAULT 1,
|
|
3202
|
+
confidence REAL NOT NULL DEFAULT 0,
|
|
3203
|
+
labels TEXT NOT NULL,
|
|
3204
|
+
created_at TEXT NOT NULL,
|
|
3205
|
+
updated_at TEXT NOT NULL
|
|
3206
|
+
);
|
|
3207
|
+
|
|
3208
|
+
CREATE INDEX IF NOT EXISTS idx_agent_semantic_labels_memory
|
|
3209
|
+
ON agent_semantic_labels(source_memory_id, labeler);
|
|
3210
|
+
|
|
3211
|
+
CREATE INDEX IF NOT EXISTS idx_agent_semantic_labels_event
|
|
3212
|
+
ON agent_semantic_labels(event_id);
|
|
3213
|
+
|
|
3214
|
+
CREATE TABLE IF NOT EXISTS agent_reflection_checkpoints (
|
|
3215
|
+
id TEXT PRIMARY KEY,
|
|
3216
|
+
project_name TEXT,
|
|
3217
|
+
session_id TEXT,
|
|
3218
|
+
window_start_at TEXT NOT NULL,
|
|
3219
|
+
window_end_at TEXT NOT NULL,
|
|
3220
|
+
event_count INTEGER NOT NULL DEFAULT 0,
|
|
3221
|
+
goal_count INTEGER NOT NULL DEFAULT 0,
|
|
3222
|
+
success_count INTEGER NOT NULL DEFAULT 0,
|
|
3223
|
+
failure_count INTEGER NOT NULL DEFAULT 0,
|
|
3224
|
+
risk_count INTEGER NOT NULL DEFAULT 0,
|
|
3225
|
+
summary TEXT NOT NULL,
|
|
3226
|
+
learnings TEXT NOT NULL DEFAULT '[]',
|
|
3227
|
+
next_actions TEXT NOT NULL DEFAULT '[]',
|
|
3228
|
+
evidence_event_ids TEXT NOT NULL DEFAULT '[]',
|
|
3229
|
+
confidence REAL NOT NULL DEFAULT 0,
|
|
3230
|
+
created_at TEXT NOT NULL
|
|
3231
|
+
);
|
|
3232
|
+
|
|
3233
|
+
CREATE INDEX IF NOT EXISTS idx_agent_reflection_project_time
|
|
3234
|
+
ON agent_reflection_checkpoints(project_name, window_end_at);
|
|
3235
|
+
|
|
3236
|
+
CREATE INDEX IF NOT EXISTS idx_agent_reflection_session_time
|
|
3237
|
+
ON agent_reflection_checkpoints(session_id, window_end_at);
|
|
3238
|
+
`);
|
|
3092
3239
|
try {
|
|
3093
3240
|
await client.execute({
|
|
3094
3241
|
sql: `ALTER TABLE memories ADD COLUMN tier INTEGER DEFAULT 3`,
|
|
@@ -3381,7 +3528,7 @@ var init_task_scope = __esm({
|
|
|
3381
3528
|
|
|
3382
3529
|
// src/lib/keychain.ts
|
|
3383
3530
|
import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2 } from "fs/promises";
|
|
3384
|
-
import { existsSync as existsSync12 } from "fs";
|
|
3531
|
+
import { existsSync as existsSync12, statSync as statSync2 } from "fs";
|
|
3385
3532
|
import { execSync as execSync5 } from "child_process";
|
|
3386
3533
|
import path14 from "path";
|
|
3387
3534
|
import os10 from "os";
|
|
@@ -3391,29 +3538,65 @@ function getKeyDir() {
|
|
|
3391
3538
|
function getKeyPath() {
|
|
3392
3539
|
return path14.join(getKeyDir(), "master.key");
|
|
3393
3540
|
}
|
|
3394
|
-
function
|
|
3541
|
+
function nativeKeychainAllowed() {
|
|
3542
|
+
return process.env.EXE_OS_DISABLE_NATIVE_KEYCHAIN !== "1";
|
|
3543
|
+
}
|
|
3544
|
+
function linuxSecretAvailable() {
|
|
3545
|
+
if (!nativeKeychainAllowed()) return false;
|
|
3546
|
+
if (process.platform !== "linux") return false;
|
|
3547
|
+
if (linuxSecretAvailability !== null) return linuxSecretAvailability;
|
|
3548
|
+
try {
|
|
3549
|
+
execSync5("command -v secret-tool >/dev/null 2>&1", { timeout: 1e3 });
|
|
3550
|
+
} catch {
|
|
3551
|
+
linuxSecretAvailability = false;
|
|
3552
|
+
return false;
|
|
3553
|
+
}
|
|
3554
|
+
try {
|
|
3555
|
+
execSync5("secret-tool search --all exe-os probe >/dev/null 2>&1", { timeout: 1e3 });
|
|
3556
|
+
linuxSecretAvailability = true;
|
|
3557
|
+
} catch {
|
|
3558
|
+
linuxSecretAvailability = false;
|
|
3559
|
+
}
|
|
3560
|
+
return linuxSecretAvailability;
|
|
3561
|
+
}
|
|
3562
|
+
function isRootOnlyTrustedServerKeyFile(keyPath) {
|
|
3563
|
+
if (process.platform !== "linux") return false;
|
|
3564
|
+
try {
|
|
3565
|
+
const uid = typeof os10.userInfo().uid === "number" ? os10.userInfo().uid : -1;
|
|
3566
|
+
const st = statSync2(keyPath);
|
|
3567
|
+
if (!st.isFile() || (st.mode & 63) !== 0) return false;
|
|
3568
|
+
if (uid === 0) return true;
|
|
3569
|
+
const exeOsDir = process.env.EXE_OS_DIR;
|
|
3570
|
+
return Boolean(exeOsDir && path14.resolve(keyPath).startsWith(path14.resolve(exeOsDir) + path14.sep));
|
|
3571
|
+
} catch {
|
|
3572
|
+
return false;
|
|
3573
|
+
}
|
|
3574
|
+
}
|
|
3575
|
+
function macKeychainGet(service = SERVICE) {
|
|
3576
|
+
if (!nativeKeychainAllowed()) return null;
|
|
3395
3577
|
if (process.platform !== "darwin") return null;
|
|
3396
3578
|
try {
|
|
3397
3579
|
return execSync5(
|
|
3398
|
-
`security find-generic-password -s "${
|
|
3580
|
+
`security find-generic-password -s "${service}" -a "${ACCOUNT}" -w 2>/dev/null`,
|
|
3399
3581
|
{ encoding: "utf-8", timeout: 5e3 }
|
|
3400
3582
|
).trim();
|
|
3401
3583
|
} catch {
|
|
3402
3584
|
return null;
|
|
3403
3585
|
}
|
|
3404
3586
|
}
|
|
3405
|
-
function macKeychainSet(value) {
|
|
3587
|
+
function macKeychainSet(value, service = SERVICE) {
|
|
3588
|
+
if (!nativeKeychainAllowed()) return false;
|
|
3406
3589
|
if (process.platform !== "darwin") return false;
|
|
3407
3590
|
try {
|
|
3408
3591
|
try {
|
|
3409
3592
|
execSync5(
|
|
3410
|
-
`security delete-generic-password -s "${
|
|
3593
|
+
`security delete-generic-password -s "${service}" -a "${ACCOUNT}" 2>/dev/null`,
|
|
3411
3594
|
{ timeout: 5e3 }
|
|
3412
3595
|
);
|
|
3413
3596
|
} catch {
|
|
3414
3597
|
}
|
|
3415
3598
|
execSync5(
|
|
3416
|
-
`security add-generic-password -s "${
|
|
3599
|
+
`security add-generic-password -s "${service}" -a "${ACCOUNT}" -w "${value}"`,
|
|
3417
3600
|
{ timeout: 5e3 }
|
|
3418
3601
|
);
|
|
3419
3602
|
return true;
|
|
@@ -3421,22 +3604,48 @@ function macKeychainSet(value) {
|
|
|
3421
3604
|
return false;
|
|
3422
3605
|
}
|
|
3423
3606
|
}
|
|
3424
|
-
function
|
|
3425
|
-
if (
|
|
3607
|
+
function macKeychainDelete(service = SERVICE) {
|
|
3608
|
+
if (!nativeKeychainAllowed()) return false;
|
|
3609
|
+
if (process.platform !== "darwin") return false;
|
|
3610
|
+
try {
|
|
3611
|
+
execSync5(
|
|
3612
|
+
`security delete-generic-password -s "${service}" -a "${ACCOUNT}" 2>/dev/null`,
|
|
3613
|
+
{ timeout: 5e3 }
|
|
3614
|
+
);
|
|
3615
|
+
return true;
|
|
3616
|
+
} catch {
|
|
3617
|
+
return false;
|
|
3618
|
+
}
|
|
3619
|
+
}
|
|
3620
|
+
function linuxSecretGet(service = SERVICE) {
|
|
3621
|
+
if (!linuxSecretAvailable()) return null;
|
|
3426
3622
|
try {
|
|
3427
3623
|
return execSync5(
|
|
3428
|
-
`secret-tool lookup service "${
|
|
3624
|
+
`secret-tool lookup service "${service}" account "${ACCOUNT}" 2>/dev/null`,
|
|
3429
3625
|
{ encoding: "utf-8", timeout: 5e3 }
|
|
3430
3626
|
).trim();
|
|
3431
3627
|
} catch {
|
|
3432
3628
|
return null;
|
|
3433
3629
|
}
|
|
3434
3630
|
}
|
|
3435
|
-
function linuxSecretSet(value) {
|
|
3631
|
+
function linuxSecretSet(value, service = SERVICE) {
|
|
3632
|
+
if (!linuxSecretAvailable()) return false;
|
|
3633
|
+
try {
|
|
3634
|
+
execSync5(
|
|
3635
|
+
`echo -n "${value}" | secret-tool store --label="exe-os master key" service "${service}" account "${ACCOUNT}" 2>/dev/null`,
|
|
3636
|
+
{ timeout: 5e3 }
|
|
3637
|
+
);
|
|
3638
|
+
return true;
|
|
3639
|
+
} catch {
|
|
3640
|
+
return false;
|
|
3641
|
+
}
|
|
3642
|
+
}
|
|
3643
|
+
function linuxSecretDelete(service = SERVICE) {
|
|
3644
|
+
if (!nativeKeychainAllowed()) return false;
|
|
3436
3645
|
if (process.platform !== "linux") return false;
|
|
3437
3646
|
try {
|
|
3438
3647
|
execSync5(
|
|
3439
|
-
`
|
|
3648
|
+
`secret-tool clear service "${service}" account "${ACCOUNT}" 2>/dev/null`,
|
|
3440
3649
|
{ timeout: 5e3 }
|
|
3441
3650
|
);
|
|
3442
3651
|
return true;
|
|
@@ -3445,6 +3654,7 @@ function linuxSecretSet(value) {
|
|
|
3445
3654
|
}
|
|
3446
3655
|
}
|
|
3447
3656
|
async function tryKeytar() {
|
|
3657
|
+
if (!nativeKeychainAllowed()) return null;
|
|
3448
3658
|
try {
|
|
3449
3659
|
return await import("keytar");
|
|
3450
3660
|
} catch {
|
|
@@ -3518,7 +3728,19 @@ async function writeMachineBoundFileFallback(b64) {
|
|
|
3518
3728
|
return "plaintext";
|
|
3519
3729
|
}
|
|
3520
3730
|
async function getMasterKey() {
|
|
3521
|
-
|
|
3731
|
+
let nativeValue = macKeychainGet() ?? linuxSecretGet();
|
|
3732
|
+
if (!nativeValue) {
|
|
3733
|
+
const legacyValue = macKeychainGet(LEGACY_SERVICE) ?? linuxSecretGet(LEGACY_SERVICE);
|
|
3734
|
+
if (legacyValue) {
|
|
3735
|
+
const migrated = macKeychainSet(legacyValue) || linuxSecretSet(legacyValue);
|
|
3736
|
+
if (migrated) {
|
|
3737
|
+
macKeychainDelete(LEGACY_SERVICE);
|
|
3738
|
+
linuxSecretDelete(LEGACY_SERVICE);
|
|
3739
|
+
process.stderr.write("[keychain] Migrated keychain service from exe-mem to exe-os.\n");
|
|
3740
|
+
}
|
|
3741
|
+
nativeValue = legacyValue;
|
|
3742
|
+
}
|
|
3743
|
+
}
|
|
3522
3744
|
if (nativeValue) {
|
|
3523
3745
|
return Buffer.from(nativeValue, "base64");
|
|
3524
3746
|
}
|
|
@@ -3526,12 +3748,17 @@ async function getMasterKey() {
|
|
|
3526
3748
|
if (keytar) {
|
|
3527
3749
|
try {
|
|
3528
3750
|
const keytarValue = await keytar.getPassword(SERVICE, ACCOUNT);
|
|
3529
|
-
|
|
3530
|
-
|
|
3751
|
+
const legacyKeytarValue = keytarValue ?? await keytar.getPassword(LEGACY_SERVICE, ACCOUNT);
|
|
3752
|
+
if (legacyKeytarValue) {
|
|
3753
|
+
const migrated = macKeychainSet(legacyKeytarValue) || linuxSecretSet(legacyKeytarValue);
|
|
3531
3754
|
if (migrated) {
|
|
3532
3755
|
process.stderr.write("[keychain] Migrated key from keytar to native keychain.\n");
|
|
3756
|
+
try {
|
|
3757
|
+
await keytar.deletePassword(LEGACY_SERVICE, ACCOUNT);
|
|
3758
|
+
} catch {
|
|
3759
|
+
}
|
|
3533
3760
|
}
|
|
3534
|
-
return Buffer.from(
|
|
3761
|
+
return Buffer.from(legacyKeytarValue, "base64");
|
|
3535
3762
|
}
|
|
3536
3763
|
} catch {
|
|
3537
3764
|
}
|
|
@@ -3556,7 +3783,7 @@ async function getMasterKey() {
|
|
|
3556
3783
|
const decrypted = decryptWithMachineKey(content, machineKey);
|
|
3557
3784
|
if (!decrypted) {
|
|
3558
3785
|
process.stderr.write(
|
|
3559
|
-
"[keychain] Key decryption failed \u2014 machine may have changed.\n Use your 24-word recovery phrase: exe-os
|
|
3786
|
+
"[keychain] Key decryption failed \u2014 machine may have changed.\n Use your 24-word recovery phrase during setup: exe-os setup\n"
|
|
3560
3787
|
);
|
|
3561
3788
|
return null;
|
|
3562
3789
|
}
|
|
@@ -3565,6 +3792,9 @@ async function getMasterKey() {
|
|
|
3565
3792
|
b64Value = content;
|
|
3566
3793
|
}
|
|
3567
3794
|
const key = Buffer.from(b64Value, "base64");
|
|
3795
|
+
if (!content.startsWith(ENCRYPTED_PREFIX) && isRootOnlyTrustedServerKeyFile(keyPath)) {
|
|
3796
|
+
return key;
|
|
3797
|
+
}
|
|
3568
3798
|
const migrated = macKeychainSet(b64Value) || linuxSecretSet(b64Value);
|
|
3569
3799
|
if (migrated) {
|
|
3570
3800
|
process.stderr.write("[keychain] Migrated key from file to native keychain.\n");
|
|
@@ -3592,12 +3822,14 @@ async function getMasterKey() {
|
|
|
3592
3822
|
return null;
|
|
3593
3823
|
}
|
|
3594
3824
|
}
|
|
3595
|
-
var SERVICE, ACCOUNT, ENCRYPTED_PREFIX;
|
|
3825
|
+
var SERVICE, LEGACY_SERVICE, ACCOUNT, linuxSecretAvailability, ENCRYPTED_PREFIX;
|
|
3596
3826
|
var init_keychain = __esm({
|
|
3597
3827
|
"src/lib/keychain.ts"() {
|
|
3598
3828
|
"use strict";
|
|
3599
|
-
SERVICE = "exe-
|
|
3829
|
+
SERVICE = "exe-os";
|
|
3830
|
+
LEGACY_SERVICE = "exe-mem";
|
|
3600
3831
|
ACCOUNT = "master-key";
|
|
3832
|
+
linuxSecretAvailability = null;
|
|
3601
3833
|
ENCRYPTED_PREFIX = "enc:";
|
|
3602
3834
|
}
|
|
3603
3835
|
});
|
|
@@ -3867,7 +4099,7 @@ __export(shard_manager_exports, {
|
|
|
3867
4099
|
shardExists: () => shardExists
|
|
3868
4100
|
});
|
|
3869
4101
|
import path15 from "path";
|
|
3870
|
-
import { existsSync as existsSync13, mkdirSync as mkdirSync7, readdirSync as readdirSync3, renameSync as renameSync4, statSync as
|
|
4102
|
+
import { existsSync as existsSync13, mkdirSync as mkdirSync7, readdirSync as readdirSync3, renameSync as renameSync4, statSync as statSync3 } from "fs";
|
|
3871
4103
|
import { createClient as createClient2 } from "@libsql/client";
|
|
3872
4104
|
function initShardManager(encryptionKey) {
|
|
3873
4105
|
_encryptionKey = encryptionKey;
|
|
@@ -3931,7 +4163,7 @@ async function auditShardHealth(options = {}) {
|
|
|
3931
4163
|
const shards = [];
|
|
3932
4164
|
for (const name of names) {
|
|
3933
4165
|
const dbPath = path15.join(SHARDS_DIR, `${name}.db`);
|
|
3934
|
-
const stat =
|
|
4166
|
+
const stat = statSync3(dbPath);
|
|
3935
4167
|
const item = {
|
|
3936
4168
|
name,
|
|
3937
4169
|
path: dbPath,
|
|
@@ -4184,7 +4416,7 @@ async function getReadyShardClient(projectName) {
|
|
|
4184
4416
|
_shardLastAccess.delete(safeName);
|
|
4185
4417
|
const dbPath = path15.join(SHARDS_DIR, `${safeName}.db`);
|
|
4186
4418
|
if (existsSync13(dbPath)) {
|
|
4187
|
-
const stat =
|
|
4419
|
+
const stat = statSync3(dbPath);
|
|
4188
4420
|
const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
4189
4421
|
const archivedPath = path15.join(SHARDS_DIR, `${safeName}.db.broken-${stamp}`);
|
|
4190
4422
|
renameSync4(dbPath, archivedPath);
|
|
@@ -4304,6 +4536,12 @@ var init_platform_procedures = __esm({
|
|
|
4304
4536
|
priority: "p0",
|
|
4305
4537
|
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."
|
|
4306
4538
|
},
|
|
4539
|
+
{
|
|
4540
|
+
title: "Customer orchestration maturity \u2014 recommend, never trap",
|
|
4541
|
+
domain: "workflow",
|
|
4542
|
+
priority: "p1",
|
|
4543
|
+
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."
|
|
4544
|
+
},
|
|
4307
4545
|
{
|
|
4308
4546
|
title: "Single dispatch path \u2014 create_task only",
|
|
4309
4547
|
domain: "workflow",
|
|
@@ -4362,6 +4600,12 @@ var init_platform_procedures = __esm({
|
|
|
4362
4600
|
priority: "p0",
|
|
4363
4601
|
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."
|
|
4364
4602
|
},
|
|
4603
|
+
{
|
|
4604
|
+
title: "Commit discipline \u2014 never leave verified work floating",
|
|
4605
|
+
domain: "workflow",
|
|
4606
|
+
priority: "p1",
|
|
4607
|
+
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."
|
|
4608
|
+
},
|
|
4365
4609
|
{
|
|
4366
4610
|
title: "Desktop and TUI are the same product",
|
|
4367
4611
|
domain: "architecture",
|
|
@@ -4679,6 +4923,274 @@ var init_memory_cards = __esm({
|
|
|
4679
4923
|
}
|
|
4680
4924
|
});
|
|
4681
4925
|
|
|
4926
|
+
// src/lib/agentic-ontology.ts
|
|
4927
|
+
var agentic_ontology_exports = {};
|
|
4928
|
+
__export(agentic_ontology_exports, {
|
|
4929
|
+
clean: () => clean,
|
|
4930
|
+
extractGoalCandidates: () => extractGoalCandidates,
|
|
4931
|
+
inferIntention: () => inferIntention,
|
|
4932
|
+
inferOntologyEventType: () => inferOntologyEventType,
|
|
4933
|
+
inferOutcome: () => inferOutcome,
|
|
4934
|
+
inferSemanticLabel: () => inferSemanticLabel,
|
|
4935
|
+
insertOntologyForBatch: () => insertOntologyForBatch,
|
|
4936
|
+
insertOntologyForMemory: () => insertOntologyForMemory,
|
|
4937
|
+
ontologyPayload: () => ontologyPayload,
|
|
4938
|
+
stableId: () => stableId2
|
|
4939
|
+
});
|
|
4940
|
+
import { createHash as createHash3 } from "crypto";
|
|
4941
|
+
function stableId2(...parts) {
|
|
4942
|
+
return createHash3("sha256").update(parts.map((p) => String(p ?? "")).join("::")).digest("hex").slice(0, 32);
|
|
4943
|
+
}
|
|
4944
|
+
function clean(text, max = 240) {
|
|
4945
|
+
return text.replace(/\u0000/g, "").replace(/```[\s\S]*?```/g, " ").replace(/\s+/g, " ").trim().slice(0, max);
|
|
4946
|
+
}
|
|
4947
|
+
function inferOntologyEventType(row) {
|
|
4948
|
+
const lower = row.raw_text.toLowerCase();
|
|
4949
|
+
if (row.has_error) return "error";
|
|
4950
|
+
if (/\b(done|complete|completed|fixed|resolved|shipped|deployed|pushed|published)\b/.test(lower)) return "milestone";
|
|
4951
|
+
if (/\b(blocked|failed|error|bug|regression|broken)\b/.test(lower)) return "problem";
|
|
4952
|
+
if (/\b(decided|decision|adr|we chose|approved|rejected)\b/.test(lower)) return "decision";
|
|
4953
|
+
if (/\b(goal|need to|we need|want to|trying to|objective)\b/.test(lower)) return "goal_signal";
|
|
4954
|
+
if (["Bash", "Read", "Edit", "Write", "Grep", "Glob"].includes(row.tool_name)) return "tool_action";
|
|
4955
|
+
if (row.tool_name.startsWith("memory_card")) return "memory_card";
|
|
4956
|
+
return "memory_observation";
|
|
4957
|
+
}
|
|
4958
|
+
function inferIntention(row) {
|
|
4959
|
+
if (row.intent) return clean(row.intent, 220);
|
|
4960
|
+
const text = clean(row.raw_text, 1e3);
|
|
4961
|
+
const patterns = [
|
|
4962
|
+
/(?: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,
|
|
4963
|
+
/(?:so that|in order to)\s+([^.!?\n]{8,220})/i,
|
|
4964
|
+
/(?:task|plan):\s*([^.!?\n]{8,220})/i
|
|
4965
|
+
];
|
|
4966
|
+
for (const p of patterns) {
|
|
4967
|
+
const m = text.match(p);
|
|
4968
|
+
if (m?.[1]) return clean(m[1], 220);
|
|
4969
|
+
}
|
|
4970
|
+
if (["Bash", "Read", "Edit", "Write", "Grep", "Glob"].includes(row.tool_name)) {
|
|
4971
|
+
return `${row.tool_name} during ${row.project_name}`;
|
|
4972
|
+
}
|
|
4973
|
+
return null;
|
|
4974
|
+
}
|
|
4975
|
+
function inferOutcome(row) {
|
|
4976
|
+
if (row.outcome) return clean(row.outcome, 220);
|
|
4977
|
+
if (row.has_error) return "error";
|
|
4978
|
+
const lower = row.raw_text.toLowerCase();
|
|
4979
|
+
if (/\b(done|complete|completed|fixed|resolved|shipped|deployed|pushed|published|passed)\b/.test(lower)) return "success_signal";
|
|
4980
|
+
if (/\b(blocked|failed|error|regression|broken|not working|could not)\b/.test(lower)) return "failure_signal";
|
|
4981
|
+
if (/\b(warning|risk|concern|caveat)\b/.test(lower)) return "risk_signal";
|
|
4982
|
+
return null;
|
|
4983
|
+
}
|
|
4984
|
+
function extractGoalCandidates(row) {
|
|
4985
|
+
const text = clean(row.raw_text, 1600);
|
|
4986
|
+
const patterns = [
|
|
4987
|
+
/(?: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,
|
|
4988
|
+
/(?:success means|success criteria|so that)\s+([^.!?\n]{12,220})/gi
|
|
4989
|
+
];
|
|
4990
|
+
const out = [];
|
|
4991
|
+
for (const pattern of patterns) {
|
|
4992
|
+
for (const m of text.matchAll(pattern)) {
|
|
4993
|
+
const candidate = clean(m[1] ?? "", 220);
|
|
4994
|
+
if (candidate.length >= 12 && !out.some((x) => x.toLowerCase() === candidate.toLowerCase())) out.push(candidate);
|
|
4995
|
+
if (out.length >= 3) return out;
|
|
4996
|
+
}
|
|
4997
|
+
}
|
|
4998
|
+
return out;
|
|
4999
|
+
}
|
|
5000
|
+
function uniq(values, max = 6) {
|
|
5001
|
+
const out = [];
|
|
5002
|
+
for (const value of values.map((v) => clean(v, 220)).filter(Boolean)) {
|
|
5003
|
+
if (!out.some((x) => x.toLowerCase() === value.toLowerCase())) out.push(value);
|
|
5004
|
+
if (out.length >= max) break;
|
|
5005
|
+
}
|
|
5006
|
+
return out;
|
|
5007
|
+
}
|
|
5008
|
+
function extractMatches(text, patterns, max = 5) {
|
|
5009
|
+
const out = [];
|
|
5010
|
+
for (const pattern of patterns) {
|
|
5011
|
+
for (const match of text.matchAll(pattern)) {
|
|
5012
|
+
const value = match[1] ?? match[0];
|
|
5013
|
+
if (value) out.push(value);
|
|
5014
|
+
if (out.length >= max) return uniq(out, max);
|
|
5015
|
+
}
|
|
5016
|
+
}
|
|
5017
|
+
return uniq(out, max);
|
|
5018
|
+
}
|
|
5019
|
+
function inferSemanticLabel(row) {
|
|
5020
|
+
const text = clean(row.raw_text, 2400);
|
|
5021
|
+
const eventType = inferOntologyEventType(row);
|
|
5022
|
+
const intention = inferIntention(row);
|
|
5023
|
+
const outcome = inferOutcome(row);
|
|
5024
|
+
const goals = extractGoalCandidates(row);
|
|
5025
|
+
const milestones = extractMatches(text, [
|
|
5026
|
+
/\b(?:completed|finished|fixed|resolved|shipped|deployed|published|pushed|passed)\b([^.!?\n]{0,180})/gi,
|
|
5027
|
+
/(?:milestone|done):\s*([^.!?\n]{8,220})/gi
|
|
5028
|
+
]);
|
|
5029
|
+
const problems = extractMatches(text, [
|
|
5030
|
+
/\b(?:blocked by|failed because|bug|regression|broken|not working|error)\b([^.!?\n]{0,180})/gi,
|
|
5031
|
+
/(?:problem|issue|risk):\s*([^.!?\n]{8,220})/gi
|
|
5032
|
+
]);
|
|
5033
|
+
const decisions = extractMatches(text, [
|
|
5034
|
+
/(?:decided|decision|adr|we chose|approved|rejected)\s+([^.!?\n]{8,220})/gi
|
|
5035
|
+
]);
|
|
5036
|
+
const temporalAnchors = extractMatches(text, [
|
|
5037
|
+
/\b(\d{4}-\d{2}-\d{2}(?:[T ][0-9:.+-Z]+)?)\b/g,
|
|
5038
|
+
/\b(today|yesterday|tomorrow|this week|next week|last week|morning|afternoon|tonight)\b/gi
|
|
5039
|
+
], 8);
|
|
5040
|
+
const nextActions = extractMatches(text, [
|
|
5041
|
+
/(?:next|todo|follow[- ]?up|remaining|need to)\s*:?\s*([^.!?\n]{8,220})/gi
|
|
5042
|
+
]);
|
|
5043
|
+
const actors = uniq([
|
|
5044
|
+
row.agent_id,
|
|
5045
|
+
...extractMatches(text, [/\b(?:agent|employee|owner|assignee)[:= ]+([a-zA-Z][a-zA-Z0-9_-]{1,40})/gi], 5)
|
|
5046
|
+
], 6);
|
|
5047
|
+
const successSignals = milestones.length ? milestones : outcome === "success_signal" ? [clean(text, 180)] : [];
|
|
5048
|
+
const failureSignals = problems.length ? problems : outcome === "failure_signal" || row.has_error ? [clean(text, 180)] : [];
|
|
5049
|
+
const impact = successSignals.length && failureSignals.length ? "mixed" : failureSignals.length ? "negative" : successSignals.length ? "positive" : "neutral";
|
|
5050
|
+
const signalCount = goals.length + milestones.length + problems.length + decisions.length + nextActions.length;
|
|
5051
|
+
return {
|
|
5052
|
+
labeler: "deterministic",
|
|
5053
|
+
schemaVersion: 1,
|
|
5054
|
+
eventType,
|
|
5055
|
+
intention,
|
|
5056
|
+
outcome,
|
|
5057
|
+
impact,
|
|
5058
|
+
confidence: Math.min(0.95, 0.45 + signalCount * 0.08 + (intention ? 0.1 : 0) + (outcome ? 0.1 : 0)),
|
|
5059
|
+
goals,
|
|
5060
|
+
milestones,
|
|
5061
|
+
problems,
|
|
5062
|
+
decisions,
|
|
5063
|
+
actors,
|
|
5064
|
+
temporalAnchors,
|
|
5065
|
+
successSignals,
|
|
5066
|
+
failureSignals,
|
|
5067
|
+
nextActions,
|
|
5068
|
+
summary: clean(text, 280)
|
|
5069
|
+
};
|
|
5070
|
+
}
|
|
5071
|
+
function ontologyPayload(row) {
|
|
5072
|
+
const semantic = inferSemanticLabel(row);
|
|
5073
|
+
return {
|
|
5074
|
+
tool_name: row.tool_name,
|
|
5075
|
+
memory_version: row.version ?? null,
|
|
5076
|
+
domain: row.domain ?? null,
|
|
5077
|
+
trajectory: row.trajectory ? safeJson(row.trajectory) : null,
|
|
5078
|
+
semantic
|
|
5079
|
+
};
|
|
5080
|
+
}
|
|
5081
|
+
function safeJson(value) {
|
|
5082
|
+
try {
|
|
5083
|
+
return JSON.parse(value);
|
|
5084
|
+
} catch {
|
|
5085
|
+
return value.slice(0, 1e3);
|
|
5086
|
+
}
|
|
5087
|
+
}
|
|
5088
|
+
async function resolveClient(client) {
|
|
5089
|
+
if (client) return client;
|
|
5090
|
+
const { getClient: getClient2 } = await Promise.resolve().then(() => (init_database(), database_exports));
|
|
5091
|
+
return getClient2();
|
|
5092
|
+
}
|
|
5093
|
+
async function insertOntologyForMemory(row, client) {
|
|
5094
|
+
const db = await resolveClient(client);
|
|
5095
|
+
const occurredAt = row.timestamp;
|
|
5096
|
+
const sequence = Number(row.version ?? 0) || Math.floor(new Date(occurredAt).getTime() / 1e3);
|
|
5097
|
+
const eventType = inferOntologyEventType(row);
|
|
5098
|
+
const intention = inferIntention(row);
|
|
5099
|
+
const outcome = inferOutcome(row);
|
|
5100
|
+
const eventId = stableId2("event", row.id);
|
|
5101
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
5102
|
+
await db.execute({
|
|
5103
|
+
sql: `INSERT INTO agent_sessions (id, agent_id, project_name, started_at, last_event_at, event_count, properties)
|
|
5104
|
+
VALUES (?, ?, ?, ?, ?, 1, ?)
|
|
5105
|
+
ON CONFLICT(id) DO UPDATE SET last_event_at = MAX(last_event_at, excluded.last_event_at),
|
|
5106
|
+
event_count = event_count + 1`,
|
|
5107
|
+
args: [row.session_id, row.agent_id, row.project_name, occurredAt, occurredAt, JSON.stringify({ agent_role: row.agent_role })]
|
|
5108
|
+
});
|
|
5109
|
+
await db.execute({
|
|
5110
|
+
sql: `INSERT OR IGNORE INTO agent_events
|
|
5111
|
+
(id, event_type, occurred_at, sequence_index, actor_agent_id, agent_role, project_name,
|
|
5112
|
+
session_id, task_id, goal_id, parent_event_id, intention, outcome, evidence_memory_id,
|
|
5113
|
+
impact, payload, created_at)
|
|
5114
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NULL, NULL, ?, ?, ?, ?, ?, ?)`,
|
|
5115
|
+
args: [
|
|
5116
|
+
eventId,
|
|
5117
|
+
eventType,
|
|
5118
|
+
occurredAt,
|
|
5119
|
+
sequence,
|
|
5120
|
+
row.agent_id,
|
|
5121
|
+
row.agent_role,
|
|
5122
|
+
row.project_name,
|
|
5123
|
+
row.session_id,
|
|
5124
|
+
row.task_id ?? null,
|
|
5125
|
+
intention,
|
|
5126
|
+
outcome,
|
|
5127
|
+
row.id,
|
|
5128
|
+
row.has_error ? "negative" : outcome === "success_signal" ? "positive" : "neutral",
|
|
5129
|
+
JSON.stringify(ontologyPayload(row)),
|
|
5130
|
+
now
|
|
5131
|
+
]
|
|
5132
|
+
});
|
|
5133
|
+
const semantic = inferSemanticLabel(row);
|
|
5134
|
+
await db.execute({
|
|
5135
|
+
sql: `INSERT INTO agent_semantic_labels
|
|
5136
|
+
(id, source_memory_id, event_id, labeler, schema_version, confidence, labels, created_at, updated_at)
|
|
5137
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
5138
|
+
ON CONFLICT(id) DO UPDATE SET confidence = excluded.confidence,
|
|
5139
|
+
labels = excluded.labels, updated_at = excluded.updated_at`,
|
|
5140
|
+
args: [
|
|
5141
|
+
stableId2("semantic", row.id, semantic.labeler, semantic.schemaVersion),
|
|
5142
|
+
row.id,
|
|
5143
|
+
eventId,
|
|
5144
|
+
semantic.labeler,
|
|
5145
|
+
semantic.schemaVersion,
|
|
5146
|
+
semantic.confidence,
|
|
5147
|
+
JSON.stringify(semantic),
|
|
5148
|
+
now,
|
|
5149
|
+
now
|
|
5150
|
+
]
|
|
5151
|
+
});
|
|
5152
|
+
for (const statement of extractGoalCandidates(row)) {
|
|
5153
|
+
const goalId = stableId2("goal", row.project_name, statement.toLowerCase());
|
|
5154
|
+
await db.execute({
|
|
5155
|
+
sql: `INSERT INTO agent_goals
|
|
5156
|
+
(id, statement, owner_agent_id, project_name, status, priority, success_criteria,
|
|
5157
|
+
parent_goal_id, due_at, achieved_at, supersedes_id, created_at, updated_at, source_memory_id)
|
|
5158
|
+
VALUES (?, ?, ?, ?, 'open', 5, NULL, NULL, NULL, NULL, NULL, ?, ?, ?)
|
|
5159
|
+
ON CONFLICT(id) DO UPDATE SET updated_at = excluded.updated_at`,
|
|
5160
|
+
args: [goalId, statement, row.agent_id, row.project_name, now, now, row.id]
|
|
5161
|
+
});
|
|
5162
|
+
await db.execute({
|
|
5163
|
+
sql: `INSERT OR IGNORE INTO agent_goal_links
|
|
5164
|
+
(id, goal_id, link_type, target_id, target_type, created_at)
|
|
5165
|
+
VALUES (?, ?, 'evidence', ?, 'memory', ?)`,
|
|
5166
|
+
args: [stableId2("goal_link", goalId, row.id, "memory"), goalId, row.id, now]
|
|
5167
|
+
});
|
|
5168
|
+
await db.execute({
|
|
5169
|
+
sql: `INSERT OR IGNORE INTO agent_goal_links
|
|
5170
|
+
(id, goal_id, link_type, target_id, target_type, created_at)
|
|
5171
|
+
VALUES (?, ?, 'event', ?, 'event', ?)`,
|
|
5172
|
+
args: [stableId2("goal_link", goalId, eventId, "event"), goalId, eventId, now]
|
|
5173
|
+
});
|
|
5174
|
+
}
|
|
5175
|
+
}
|
|
5176
|
+
async function insertOntologyForBatch(rows, client) {
|
|
5177
|
+
const db = await resolveClient(client);
|
|
5178
|
+
let count = 0;
|
|
5179
|
+
for (const row of rows) {
|
|
5180
|
+
try {
|
|
5181
|
+
await insertOntologyForMemory(row, db);
|
|
5182
|
+
count++;
|
|
5183
|
+
} catch {
|
|
5184
|
+
}
|
|
5185
|
+
}
|
|
5186
|
+
return count;
|
|
5187
|
+
}
|
|
5188
|
+
var init_agentic_ontology = __esm({
|
|
5189
|
+
"src/lib/agentic-ontology.ts"() {
|
|
5190
|
+
"use strict";
|
|
5191
|
+
}
|
|
5192
|
+
});
|
|
5193
|
+
|
|
4682
5194
|
// src/lib/store.ts
|
|
4683
5195
|
var store_exports = {};
|
|
4684
5196
|
__export(store_exports, {
|
|
@@ -5022,6 +5534,11 @@ async function flushBatch() {
|
|
|
5022
5534
|
await insertMemoryCardsForBatch2(batch);
|
|
5023
5535
|
} catch {
|
|
5024
5536
|
}
|
|
5537
|
+
try {
|
|
5538
|
+
const { insertOntologyForBatch: insertOntologyForBatch2 } = await Promise.resolve().then(() => (init_agentic_ontology(), agentic_ontology_exports));
|
|
5539
|
+
await insertOntologyForBatch2(batch);
|
|
5540
|
+
} catch {
|
|
5541
|
+
}
|
|
5025
5542
|
schedulePostWriteMemoryHygiene(batch.map((row) => row.id));
|
|
5026
5543
|
_pendingRecords.splice(0, batch.length);
|
|
5027
5544
|
try {
|
|
@@ -5370,7 +5887,7 @@ var init_fast_db_init = __esm({
|
|
|
5370
5887
|
});
|
|
5371
5888
|
|
|
5372
5889
|
// src/lib/memory-queue.ts
|
|
5373
|
-
import { appendFileSync as appendFileSync2, readFileSync as readFileSync11, renameSync as renameSync5, unlinkSync as unlinkSync4, existsSync as existsSync14, statSync as
|
|
5890
|
+
import { appendFileSync as appendFileSync2, readFileSync as readFileSync11, renameSync as renameSync5, unlinkSync as unlinkSync4, existsSync as existsSync14, statSync as statSync4 } from "fs";
|
|
5374
5891
|
import path16 from "path";
|
|
5375
5892
|
function enqueueMemory(entry) {
|
|
5376
5893
|
appendFileSync2(QUEUE_PATH2, JSON.stringify(entry) + "\n");
|