@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 = [
|
|
@@ -2318,6 +2332,9 @@ function getClient() {
|
|
|
2318
2332
|
if (_daemonClient && _daemonClient._isDaemonActive()) {
|
|
2319
2333
|
return _daemonClient;
|
|
2320
2334
|
}
|
|
2335
|
+
if (!_resilientClient) {
|
|
2336
|
+
return _adapterClient;
|
|
2337
|
+
}
|
|
2321
2338
|
return _resilientClient;
|
|
2322
2339
|
}
|
|
2323
2340
|
async function initDaemonClient() {
|
|
@@ -3350,6 +3367,127 @@ async function ensureSchema() {
|
|
|
3350
3367
|
VALUES (new.rowid, new.content, new.subject, new.predicate, new.object);
|
|
3351
3368
|
END;
|
|
3352
3369
|
`);
|
|
3370
|
+
await client.executeMultiple(`
|
|
3371
|
+
CREATE TABLE IF NOT EXISTS agent_sessions (
|
|
3372
|
+
id TEXT PRIMARY KEY,
|
|
3373
|
+
agent_id TEXT NOT NULL,
|
|
3374
|
+
project_name TEXT,
|
|
3375
|
+
started_at TEXT NOT NULL,
|
|
3376
|
+
last_event_at TEXT NOT NULL,
|
|
3377
|
+
event_count INTEGER NOT NULL DEFAULT 0,
|
|
3378
|
+
properties TEXT DEFAULT '{}'
|
|
3379
|
+
);
|
|
3380
|
+
|
|
3381
|
+
CREATE INDEX IF NOT EXISTS idx_agent_sessions_agent_time
|
|
3382
|
+
ON agent_sessions(agent_id, started_at);
|
|
3383
|
+
|
|
3384
|
+
CREATE TABLE IF NOT EXISTS agent_goals (
|
|
3385
|
+
id TEXT PRIMARY KEY,
|
|
3386
|
+
statement TEXT NOT NULL,
|
|
3387
|
+
owner_agent_id TEXT,
|
|
3388
|
+
project_name TEXT,
|
|
3389
|
+
status TEXT NOT NULL DEFAULT 'open',
|
|
3390
|
+
priority INTEGER NOT NULL DEFAULT 5,
|
|
3391
|
+
success_criteria TEXT,
|
|
3392
|
+
parent_goal_id TEXT,
|
|
3393
|
+
due_at TEXT,
|
|
3394
|
+
achieved_at TEXT,
|
|
3395
|
+
supersedes_id TEXT,
|
|
3396
|
+
created_at TEXT NOT NULL,
|
|
3397
|
+
updated_at TEXT NOT NULL,
|
|
3398
|
+
source_memory_id TEXT
|
|
3399
|
+
);
|
|
3400
|
+
|
|
3401
|
+
CREATE INDEX IF NOT EXISTS idx_agent_goals_project_status
|
|
3402
|
+
ON agent_goals(project_name, status, priority);
|
|
3403
|
+
|
|
3404
|
+
CREATE TABLE IF NOT EXISTS agent_events (
|
|
3405
|
+
id TEXT PRIMARY KEY,
|
|
3406
|
+
event_type TEXT NOT NULL,
|
|
3407
|
+
occurred_at TEXT NOT NULL,
|
|
3408
|
+
sequence_index INTEGER NOT NULL,
|
|
3409
|
+
actor_agent_id TEXT,
|
|
3410
|
+
agent_role TEXT,
|
|
3411
|
+
project_name TEXT,
|
|
3412
|
+
session_id TEXT,
|
|
3413
|
+
task_id TEXT,
|
|
3414
|
+
goal_id TEXT,
|
|
3415
|
+
parent_event_id TEXT,
|
|
3416
|
+
intention TEXT,
|
|
3417
|
+
outcome TEXT,
|
|
3418
|
+
evidence_memory_id TEXT,
|
|
3419
|
+
impact TEXT,
|
|
3420
|
+
payload TEXT DEFAULT '{}',
|
|
3421
|
+
created_at TEXT NOT NULL
|
|
3422
|
+
);
|
|
3423
|
+
|
|
3424
|
+
CREATE INDEX IF NOT EXISTS idx_agent_events_time
|
|
3425
|
+
ON agent_events(occurred_at, sequence_index);
|
|
3426
|
+
|
|
3427
|
+
CREATE INDEX IF NOT EXISTS idx_agent_events_session_seq
|
|
3428
|
+
ON agent_events(session_id, sequence_index);
|
|
3429
|
+
|
|
3430
|
+
CREATE INDEX IF NOT EXISTS idx_agent_events_goal_time
|
|
3431
|
+
ON agent_events(goal_id, occurred_at);
|
|
3432
|
+
|
|
3433
|
+
CREATE INDEX IF NOT EXISTS idx_agent_events_memory
|
|
3434
|
+
ON agent_events(evidence_memory_id);
|
|
3435
|
+
|
|
3436
|
+
CREATE TABLE IF NOT EXISTS agent_goal_links (
|
|
3437
|
+
id TEXT PRIMARY KEY,
|
|
3438
|
+
goal_id TEXT NOT NULL,
|
|
3439
|
+
link_type TEXT NOT NULL,
|
|
3440
|
+
target_id TEXT NOT NULL,
|
|
3441
|
+
target_type TEXT NOT NULL,
|
|
3442
|
+
created_at TEXT NOT NULL
|
|
3443
|
+
);
|
|
3444
|
+
|
|
3445
|
+
CREATE INDEX IF NOT EXISTS idx_agent_goal_links_goal
|
|
3446
|
+
ON agent_goal_links(goal_id, target_type);
|
|
3447
|
+
|
|
3448
|
+
CREATE TABLE IF NOT EXISTS agent_semantic_labels (
|
|
3449
|
+
id TEXT PRIMARY KEY,
|
|
3450
|
+
source_memory_id TEXT NOT NULL,
|
|
3451
|
+
event_id TEXT,
|
|
3452
|
+
labeler TEXT NOT NULL,
|
|
3453
|
+
schema_version INTEGER NOT NULL DEFAULT 1,
|
|
3454
|
+
confidence REAL NOT NULL DEFAULT 0,
|
|
3455
|
+
labels TEXT NOT NULL,
|
|
3456
|
+
created_at TEXT NOT NULL,
|
|
3457
|
+
updated_at TEXT NOT NULL
|
|
3458
|
+
);
|
|
3459
|
+
|
|
3460
|
+
CREATE INDEX IF NOT EXISTS idx_agent_semantic_labels_memory
|
|
3461
|
+
ON agent_semantic_labels(source_memory_id, labeler);
|
|
3462
|
+
|
|
3463
|
+
CREATE INDEX IF NOT EXISTS idx_agent_semantic_labels_event
|
|
3464
|
+
ON agent_semantic_labels(event_id);
|
|
3465
|
+
|
|
3466
|
+
CREATE TABLE IF NOT EXISTS agent_reflection_checkpoints (
|
|
3467
|
+
id TEXT PRIMARY KEY,
|
|
3468
|
+
project_name TEXT,
|
|
3469
|
+
session_id TEXT,
|
|
3470
|
+
window_start_at TEXT NOT NULL,
|
|
3471
|
+
window_end_at TEXT NOT NULL,
|
|
3472
|
+
event_count INTEGER NOT NULL DEFAULT 0,
|
|
3473
|
+
goal_count INTEGER NOT NULL DEFAULT 0,
|
|
3474
|
+
success_count INTEGER NOT NULL DEFAULT 0,
|
|
3475
|
+
failure_count INTEGER NOT NULL DEFAULT 0,
|
|
3476
|
+
risk_count INTEGER NOT NULL DEFAULT 0,
|
|
3477
|
+
summary TEXT NOT NULL,
|
|
3478
|
+
learnings TEXT NOT NULL DEFAULT '[]',
|
|
3479
|
+
next_actions TEXT NOT NULL DEFAULT '[]',
|
|
3480
|
+
evidence_event_ids TEXT NOT NULL DEFAULT '[]',
|
|
3481
|
+
confidence REAL NOT NULL DEFAULT 0,
|
|
3482
|
+
created_at TEXT NOT NULL
|
|
3483
|
+
);
|
|
3484
|
+
|
|
3485
|
+
CREATE INDEX IF NOT EXISTS idx_agent_reflection_project_time
|
|
3486
|
+
ON agent_reflection_checkpoints(project_name, window_end_at);
|
|
3487
|
+
|
|
3488
|
+
CREATE INDEX IF NOT EXISTS idx_agent_reflection_session_time
|
|
3489
|
+
ON agent_reflection_checkpoints(session_id, window_end_at);
|
|
3490
|
+
`);
|
|
3353
3491
|
try {
|
|
3354
3492
|
await client.execute({
|
|
3355
3493
|
sql: `ALTER TABLE memories ADD COLUMN tier INTEGER DEFAULT 3`,
|
|
@@ -3826,7 +3964,7 @@ var init_cto_delegation_gate = __esm({
|
|
|
3826
3964
|
|
|
3827
3965
|
// src/lib/keychain.ts
|
|
3828
3966
|
import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2 } from "fs/promises";
|
|
3829
|
-
import { existsSync as existsSync13 } from "fs";
|
|
3967
|
+
import { existsSync as existsSync13, statSync as statSync3 } from "fs";
|
|
3830
3968
|
import { execSync as execSync5 } from "child_process";
|
|
3831
3969
|
import path15 from "path";
|
|
3832
3970
|
import os11 from "os";
|
|
@@ -3836,29 +3974,78 @@ function getKeyDir() {
|
|
|
3836
3974
|
function getKeyPath() {
|
|
3837
3975
|
return path15.join(getKeyDir(), "master.key");
|
|
3838
3976
|
}
|
|
3839
|
-
function
|
|
3977
|
+
function nativeKeychainAllowed() {
|
|
3978
|
+
return process.env.EXE_OS_DISABLE_NATIVE_KEYCHAIN !== "1";
|
|
3979
|
+
}
|
|
3980
|
+
function linuxSecretAvailable() {
|
|
3981
|
+
if (!nativeKeychainAllowed()) return false;
|
|
3982
|
+
if (process.platform !== "linux") return false;
|
|
3983
|
+
if (linuxSecretAvailability !== null) return linuxSecretAvailability;
|
|
3984
|
+
try {
|
|
3985
|
+
execSync5("command -v secret-tool >/dev/null 2>&1", { timeout: 1e3 });
|
|
3986
|
+
} catch {
|
|
3987
|
+
linuxSecretAvailability = false;
|
|
3988
|
+
return false;
|
|
3989
|
+
}
|
|
3990
|
+
try {
|
|
3991
|
+
execSync5("secret-tool search --all exe-os probe >/dev/null 2>&1", { timeout: 1e3 });
|
|
3992
|
+
linuxSecretAvailability = true;
|
|
3993
|
+
} catch {
|
|
3994
|
+
linuxSecretAvailability = false;
|
|
3995
|
+
}
|
|
3996
|
+
return linuxSecretAvailability;
|
|
3997
|
+
}
|
|
3998
|
+
function isRootOnlyTrustedServerKeyFile(keyPath) {
|
|
3999
|
+
if (process.platform !== "linux") return false;
|
|
4000
|
+
try {
|
|
4001
|
+
const uid = typeof os11.userInfo().uid === "number" ? os11.userInfo().uid : -1;
|
|
4002
|
+
const st = statSync3(keyPath);
|
|
4003
|
+
if (!st.isFile() || (st.mode & 63) !== 0) return false;
|
|
4004
|
+
if (uid === 0) return true;
|
|
4005
|
+
const exeOsDir = process.env.EXE_OS_DIR;
|
|
4006
|
+
return Boolean(exeOsDir && path15.resolve(keyPath).startsWith(path15.resolve(exeOsDir) + path15.sep));
|
|
4007
|
+
} catch {
|
|
4008
|
+
return false;
|
|
4009
|
+
}
|
|
4010
|
+
}
|
|
4011
|
+
function macKeychainGet(service = SERVICE) {
|
|
4012
|
+
if (!nativeKeychainAllowed()) return null;
|
|
3840
4013
|
if (process.platform !== "darwin") return null;
|
|
3841
4014
|
try {
|
|
3842
4015
|
return execSync5(
|
|
3843
|
-
`security find-generic-password -s "${
|
|
4016
|
+
`security find-generic-password -s "${service}" -a "${ACCOUNT}" -w 2>/dev/null`,
|
|
3844
4017
|
{ encoding: "utf-8", timeout: 5e3 }
|
|
3845
4018
|
).trim();
|
|
3846
4019
|
} catch {
|
|
3847
4020
|
return null;
|
|
3848
4021
|
}
|
|
3849
4022
|
}
|
|
3850
|
-
function macKeychainSet(value) {
|
|
4023
|
+
function macKeychainSet(value, service = SERVICE) {
|
|
4024
|
+
if (!nativeKeychainAllowed()) return false;
|
|
3851
4025
|
if (process.platform !== "darwin") return false;
|
|
3852
4026
|
try {
|
|
3853
4027
|
try {
|
|
3854
4028
|
execSync5(
|
|
3855
|
-
`security delete-generic-password -s "${
|
|
4029
|
+
`security delete-generic-password -s "${service}" -a "${ACCOUNT}" 2>/dev/null`,
|
|
3856
4030
|
{ timeout: 5e3 }
|
|
3857
4031
|
);
|
|
3858
4032
|
} catch {
|
|
3859
4033
|
}
|
|
3860
4034
|
execSync5(
|
|
3861
|
-
`security add-generic-password -s "${
|
|
4035
|
+
`security add-generic-password -s "${service}" -a "${ACCOUNT}" -w "${value}"`,
|
|
4036
|
+
{ timeout: 5e3 }
|
|
4037
|
+
);
|
|
4038
|
+
return true;
|
|
4039
|
+
} catch {
|
|
4040
|
+
return false;
|
|
4041
|
+
}
|
|
4042
|
+
}
|
|
4043
|
+
function macKeychainDelete(service = SERVICE) {
|
|
4044
|
+
if (!nativeKeychainAllowed()) return false;
|
|
4045
|
+
if (process.platform !== "darwin") return false;
|
|
4046
|
+
try {
|
|
4047
|
+
execSync5(
|
|
4048
|
+
`security delete-generic-password -s "${service}" -a "${ACCOUNT}" 2>/dev/null`,
|
|
3862
4049
|
{ timeout: 5e3 }
|
|
3863
4050
|
);
|
|
3864
4051
|
return true;
|
|
@@ -3866,22 +4053,35 @@ function macKeychainSet(value) {
|
|
|
3866
4053
|
return false;
|
|
3867
4054
|
}
|
|
3868
4055
|
}
|
|
3869
|
-
function linuxSecretGet() {
|
|
3870
|
-
if (
|
|
4056
|
+
function linuxSecretGet(service = SERVICE) {
|
|
4057
|
+
if (!linuxSecretAvailable()) return null;
|
|
3871
4058
|
try {
|
|
3872
4059
|
return execSync5(
|
|
3873
|
-
`secret-tool lookup service "${
|
|
4060
|
+
`secret-tool lookup service "${service}" account "${ACCOUNT}" 2>/dev/null`,
|
|
3874
4061
|
{ encoding: "utf-8", timeout: 5e3 }
|
|
3875
4062
|
).trim();
|
|
3876
4063
|
} catch {
|
|
3877
4064
|
return null;
|
|
3878
4065
|
}
|
|
3879
4066
|
}
|
|
3880
|
-
function linuxSecretSet(value) {
|
|
4067
|
+
function linuxSecretSet(value, service = SERVICE) {
|
|
4068
|
+
if (!linuxSecretAvailable()) return false;
|
|
4069
|
+
try {
|
|
4070
|
+
execSync5(
|
|
4071
|
+
`echo -n "${value}" | secret-tool store --label="exe-os master key" service "${service}" account "${ACCOUNT}" 2>/dev/null`,
|
|
4072
|
+
{ timeout: 5e3 }
|
|
4073
|
+
);
|
|
4074
|
+
return true;
|
|
4075
|
+
} catch {
|
|
4076
|
+
return false;
|
|
4077
|
+
}
|
|
4078
|
+
}
|
|
4079
|
+
function linuxSecretDelete(service = SERVICE) {
|
|
4080
|
+
if (!nativeKeychainAllowed()) return false;
|
|
3881
4081
|
if (process.platform !== "linux") return false;
|
|
3882
4082
|
try {
|
|
3883
4083
|
execSync5(
|
|
3884
|
-
`
|
|
4084
|
+
`secret-tool clear service "${service}" account "${ACCOUNT}" 2>/dev/null`,
|
|
3885
4085
|
{ timeout: 5e3 }
|
|
3886
4086
|
);
|
|
3887
4087
|
return true;
|
|
@@ -3890,6 +4090,7 @@ function linuxSecretSet(value) {
|
|
|
3890
4090
|
}
|
|
3891
4091
|
}
|
|
3892
4092
|
async function tryKeytar() {
|
|
4093
|
+
if (!nativeKeychainAllowed()) return null;
|
|
3893
4094
|
try {
|
|
3894
4095
|
return await import("keytar");
|
|
3895
4096
|
} catch {
|
|
@@ -3963,7 +4164,19 @@ async function writeMachineBoundFileFallback(b64) {
|
|
|
3963
4164
|
return "plaintext";
|
|
3964
4165
|
}
|
|
3965
4166
|
async function getMasterKey() {
|
|
3966
|
-
|
|
4167
|
+
let nativeValue = macKeychainGet() ?? linuxSecretGet();
|
|
4168
|
+
if (!nativeValue) {
|
|
4169
|
+
const legacyValue = macKeychainGet(LEGACY_SERVICE) ?? linuxSecretGet(LEGACY_SERVICE);
|
|
4170
|
+
if (legacyValue) {
|
|
4171
|
+
const migrated = macKeychainSet(legacyValue) || linuxSecretSet(legacyValue);
|
|
4172
|
+
if (migrated) {
|
|
4173
|
+
macKeychainDelete(LEGACY_SERVICE);
|
|
4174
|
+
linuxSecretDelete(LEGACY_SERVICE);
|
|
4175
|
+
process.stderr.write("[keychain] Migrated keychain service from exe-mem to exe-os.\n");
|
|
4176
|
+
}
|
|
4177
|
+
nativeValue = legacyValue;
|
|
4178
|
+
}
|
|
4179
|
+
}
|
|
3967
4180
|
if (nativeValue) {
|
|
3968
4181
|
return Buffer.from(nativeValue, "base64");
|
|
3969
4182
|
}
|
|
@@ -3971,12 +4184,17 @@ async function getMasterKey() {
|
|
|
3971
4184
|
if (keytar) {
|
|
3972
4185
|
try {
|
|
3973
4186
|
const keytarValue = await keytar.getPassword(SERVICE, ACCOUNT);
|
|
3974
|
-
|
|
3975
|
-
|
|
4187
|
+
const legacyKeytarValue = keytarValue ?? await keytar.getPassword(LEGACY_SERVICE, ACCOUNT);
|
|
4188
|
+
if (legacyKeytarValue) {
|
|
4189
|
+
const migrated = macKeychainSet(legacyKeytarValue) || linuxSecretSet(legacyKeytarValue);
|
|
3976
4190
|
if (migrated) {
|
|
3977
4191
|
process.stderr.write("[keychain] Migrated key from keytar to native keychain.\n");
|
|
4192
|
+
try {
|
|
4193
|
+
await keytar.deletePassword(LEGACY_SERVICE, ACCOUNT);
|
|
4194
|
+
} catch {
|
|
4195
|
+
}
|
|
3978
4196
|
}
|
|
3979
|
-
return Buffer.from(
|
|
4197
|
+
return Buffer.from(legacyKeytarValue, "base64");
|
|
3980
4198
|
}
|
|
3981
4199
|
} catch {
|
|
3982
4200
|
}
|
|
@@ -4001,7 +4219,7 @@ async function getMasterKey() {
|
|
|
4001
4219
|
const decrypted = decryptWithMachineKey(content, machineKey);
|
|
4002
4220
|
if (!decrypted) {
|
|
4003
4221
|
process.stderr.write(
|
|
4004
|
-
"[keychain] Key decryption failed \u2014 machine may have changed.\n Use your 24-word recovery phrase: exe-os
|
|
4222
|
+
"[keychain] Key decryption failed \u2014 machine may have changed.\n Use your 24-word recovery phrase during setup: exe-os setup\n"
|
|
4005
4223
|
);
|
|
4006
4224
|
return null;
|
|
4007
4225
|
}
|
|
@@ -4010,6 +4228,9 @@ async function getMasterKey() {
|
|
|
4010
4228
|
b64Value = content;
|
|
4011
4229
|
}
|
|
4012
4230
|
const key = Buffer.from(b64Value, "base64");
|
|
4231
|
+
if (!content.startsWith(ENCRYPTED_PREFIX) && isRootOnlyTrustedServerKeyFile(keyPath)) {
|
|
4232
|
+
return key;
|
|
4233
|
+
}
|
|
4013
4234
|
const migrated = macKeychainSet(b64Value) || linuxSecretSet(b64Value);
|
|
4014
4235
|
if (migrated) {
|
|
4015
4236
|
process.stderr.write("[keychain] Migrated key from file to native keychain.\n");
|
|
@@ -4037,12 +4258,14 @@ async function getMasterKey() {
|
|
|
4037
4258
|
return null;
|
|
4038
4259
|
}
|
|
4039
4260
|
}
|
|
4040
|
-
var SERVICE, ACCOUNT, ENCRYPTED_PREFIX;
|
|
4261
|
+
var SERVICE, LEGACY_SERVICE, ACCOUNT, linuxSecretAvailability, ENCRYPTED_PREFIX;
|
|
4041
4262
|
var init_keychain = __esm({
|
|
4042
4263
|
"src/lib/keychain.ts"() {
|
|
4043
4264
|
"use strict";
|
|
4044
|
-
SERVICE = "exe-
|
|
4265
|
+
SERVICE = "exe-os";
|
|
4266
|
+
LEGACY_SERVICE = "exe-mem";
|
|
4045
4267
|
ACCOUNT = "master-key";
|
|
4268
|
+
linuxSecretAvailability = null;
|
|
4046
4269
|
ENCRYPTED_PREFIX = "enc:";
|
|
4047
4270
|
}
|
|
4048
4271
|
});
|
|
@@ -4312,7 +4535,7 @@ __export(shard_manager_exports, {
|
|
|
4312
4535
|
shardExists: () => shardExists
|
|
4313
4536
|
});
|
|
4314
4537
|
import path16 from "path";
|
|
4315
|
-
import { existsSync as existsSync14, mkdirSync as mkdirSync7, readdirSync as readdirSync3, renameSync as renameSync4, statSync as
|
|
4538
|
+
import { existsSync as existsSync14, mkdirSync as mkdirSync7, readdirSync as readdirSync3, renameSync as renameSync4, statSync as statSync4 } from "fs";
|
|
4316
4539
|
import { createClient as createClient2 } from "@libsql/client";
|
|
4317
4540
|
function initShardManager(encryptionKey) {
|
|
4318
4541
|
_encryptionKey = encryptionKey;
|
|
@@ -4376,7 +4599,7 @@ async function auditShardHealth(options = {}) {
|
|
|
4376
4599
|
const shards = [];
|
|
4377
4600
|
for (const name of names) {
|
|
4378
4601
|
const dbPath = path16.join(SHARDS_DIR, `${name}.db`);
|
|
4379
|
-
const stat =
|
|
4602
|
+
const stat = statSync4(dbPath);
|
|
4380
4603
|
const item = {
|
|
4381
4604
|
name,
|
|
4382
4605
|
path: dbPath,
|
|
@@ -4629,7 +4852,7 @@ async function getReadyShardClient(projectName) {
|
|
|
4629
4852
|
_shardLastAccess.delete(safeName);
|
|
4630
4853
|
const dbPath = path16.join(SHARDS_DIR, `${safeName}.db`);
|
|
4631
4854
|
if (existsSync14(dbPath)) {
|
|
4632
|
-
const stat =
|
|
4855
|
+
const stat = statSync4(dbPath);
|
|
4633
4856
|
const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
4634
4857
|
const archivedPath = path16.join(SHARDS_DIR, `${safeName}.db.broken-${stamp}`);
|
|
4635
4858
|
renameSync4(dbPath, archivedPath);
|
|
@@ -4749,6 +4972,12 @@ var init_platform_procedures = __esm({
|
|
|
4749
4972
|
priority: "p0",
|
|
4750
4973
|
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."
|
|
4751
4974
|
},
|
|
4975
|
+
{
|
|
4976
|
+
title: "Customer orchestration maturity \u2014 recommend, never trap",
|
|
4977
|
+
domain: "workflow",
|
|
4978
|
+
priority: "p1",
|
|
4979
|
+
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."
|
|
4980
|
+
},
|
|
4752
4981
|
{
|
|
4753
4982
|
title: "Single dispatch path \u2014 create_task only",
|
|
4754
4983
|
domain: "workflow",
|
|
@@ -4807,6 +5036,12 @@ var init_platform_procedures = __esm({
|
|
|
4807
5036
|
priority: "p0",
|
|
4808
5037
|
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."
|
|
4809
5038
|
},
|
|
5039
|
+
{
|
|
5040
|
+
title: "Commit discipline \u2014 never leave verified work floating",
|
|
5041
|
+
domain: "workflow",
|
|
5042
|
+
priority: "p1",
|
|
5043
|
+
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."
|
|
5044
|
+
},
|
|
4810
5045
|
{
|
|
4811
5046
|
title: "Desktop and TUI are the same product",
|
|
4812
5047
|
domain: "architecture",
|
|
@@ -5124,6 +5359,274 @@ var init_memory_cards = __esm({
|
|
|
5124
5359
|
}
|
|
5125
5360
|
});
|
|
5126
5361
|
|
|
5362
|
+
// src/lib/agentic-ontology.ts
|
|
5363
|
+
var agentic_ontology_exports = {};
|
|
5364
|
+
__export(agentic_ontology_exports, {
|
|
5365
|
+
clean: () => clean,
|
|
5366
|
+
extractGoalCandidates: () => extractGoalCandidates,
|
|
5367
|
+
inferIntention: () => inferIntention,
|
|
5368
|
+
inferOntologyEventType: () => inferOntologyEventType,
|
|
5369
|
+
inferOutcome: () => inferOutcome,
|
|
5370
|
+
inferSemanticLabel: () => inferSemanticLabel,
|
|
5371
|
+
insertOntologyForBatch: () => insertOntologyForBatch,
|
|
5372
|
+
insertOntologyForMemory: () => insertOntologyForMemory,
|
|
5373
|
+
ontologyPayload: () => ontologyPayload,
|
|
5374
|
+
stableId: () => stableId2
|
|
5375
|
+
});
|
|
5376
|
+
import { createHash as createHash3 } from "crypto";
|
|
5377
|
+
function stableId2(...parts) {
|
|
5378
|
+
return createHash3("sha256").update(parts.map((p) => String(p ?? "")).join("::")).digest("hex").slice(0, 32);
|
|
5379
|
+
}
|
|
5380
|
+
function clean(text, max = 240) {
|
|
5381
|
+
return text.replace(/\u0000/g, "").replace(/```[\s\S]*?```/g, " ").replace(/\s+/g, " ").trim().slice(0, max);
|
|
5382
|
+
}
|
|
5383
|
+
function inferOntologyEventType(row) {
|
|
5384
|
+
const lower = row.raw_text.toLowerCase();
|
|
5385
|
+
if (row.has_error) return "error";
|
|
5386
|
+
if (/\b(done|complete|completed|fixed|resolved|shipped|deployed|pushed|published)\b/.test(lower)) return "milestone";
|
|
5387
|
+
if (/\b(blocked|failed|error|bug|regression|broken)\b/.test(lower)) return "problem";
|
|
5388
|
+
if (/\b(decided|decision|adr|we chose|approved|rejected)\b/.test(lower)) return "decision";
|
|
5389
|
+
if (/\b(goal|need to|we need|want to|trying to|objective)\b/.test(lower)) return "goal_signal";
|
|
5390
|
+
if (["Bash", "Read", "Edit", "Write", "Grep", "Glob"].includes(row.tool_name)) return "tool_action";
|
|
5391
|
+
if (row.tool_name.startsWith("memory_card")) return "memory_card";
|
|
5392
|
+
return "memory_observation";
|
|
5393
|
+
}
|
|
5394
|
+
function inferIntention(row) {
|
|
5395
|
+
if (row.intent) return clean(row.intent, 220);
|
|
5396
|
+
const text = clean(row.raw_text, 1e3);
|
|
5397
|
+
const patterns = [
|
|
5398
|
+
/(?: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,
|
|
5399
|
+
/(?:so that|in order to)\s+([^.!?\n]{8,220})/i,
|
|
5400
|
+
/(?:task|plan):\s*([^.!?\n]{8,220})/i
|
|
5401
|
+
];
|
|
5402
|
+
for (const p of patterns) {
|
|
5403
|
+
const m = text.match(p);
|
|
5404
|
+
if (m?.[1]) return clean(m[1], 220);
|
|
5405
|
+
}
|
|
5406
|
+
if (["Bash", "Read", "Edit", "Write", "Grep", "Glob"].includes(row.tool_name)) {
|
|
5407
|
+
return `${row.tool_name} during ${row.project_name}`;
|
|
5408
|
+
}
|
|
5409
|
+
return null;
|
|
5410
|
+
}
|
|
5411
|
+
function inferOutcome(row) {
|
|
5412
|
+
if (row.outcome) return clean(row.outcome, 220);
|
|
5413
|
+
if (row.has_error) return "error";
|
|
5414
|
+
const lower = row.raw_text.toLowerCase();
|
|
5415
|
+
if (/\b(done|complete|completed|fixed|resolved|shipped|deployed|pushed|published|passed)\b/.test(lower)) return "success_signal";
|
|
5416
|
+
if (/\b(blocked|failed|error|regression|broken|not working|could not)\b/.test(lower)) return "failure_signal";
|
|
5417
|
+
if (/\b(warning|risk|concern|caveat)\b/.test(lower)) return "risk_signal";
|
|
5418
|
+
return null;
|
|
5419
|
+
}
|
|
5420
|
+
function extractGoalCandidates(row) {
|
|
5421
|
+
const text = clean(row.raw_text, 1600);
|
|
5422
|
+
const patterns = [
|
|
5423
|
+
/(?: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,
|
|
5424
|
+
/(?:success means|success criteria|so that)\s+([^.!?\n]{12,220})/gi
|
|
5425
|
+
];
|
|
5426
|
+
const out = [];
|
|
5427
|
+
for (const pattern of patterns) {
|
|
5428
|
+
for (const m of text.matchAll(pattern)) {
|
|
5429
|
+
const candidate = clean(m[1] ?? "", 220);
|
|
5430
|
+
if (candidate.length >= 12 && !out.some((x) => x.toLowerCase() === candidate.toLowerCase())) out.push(candidate);
|
|
5431
|
+
if (out.length >= 3) return out;
|
|
5432
|
+
}
|
|
5433
|
+
}
|
|
5434
|
+
return out;
|
|
5435
|
+
}
|
|
5436
|
+
function uniq(values, max = 6) {
|
|
5437
|
+
const out = [];
|
|
5438
|
+
for (const value of values.map((v) => clean(v, 220)).filter(Boolean)) {
|
|
5439
|
+
if (!out.some((x) => x.toLowerCase() === value.toLowerCase())) out.push(value);
|
|
5440
|
+
if (out.length >= max) break;
|
|
5441
|
+
}
|
|
5442
|
+
return out;
|
|
5443
|
+
}
|
|
5444
|
+
function extractMatches(text, patterns, max = 5) {
|
|
5445
|
+
const out = [];
|
|
5446
|
+
for (const pattern of patterns) {
|
|
5447
|
+
for (const match of text.matchAll(pattern)) {
|
|
5448
|
+
const value = match[1] ?? match[0];
|
|
5449
|
+
if (value) out.push(value);
|
|
5450
|
+
if (out.length >= max) return uniq(out, max);
|
|
5451
|
+
}
|
|
5452
|
+
}
|
|
5453
|
+
return uniq(out, max);
|
|
5454
|
+
}
|
|
5455
|
+
function inferSemanticLabel(row) {
|
|
5456
|
+
const text = clean(row.raw_text, 2400);
|
|
5457
|
+
const eventType = inferOntologyEventType(row);
|
|
5458
|
+
const intention = inferIntention(row);
|
|
5459
|
+
const outcome = inferOutcome(row);
|
|
5460
|
+
const goals = extractGoalCandidates(row);
|
|
5461
|
+
const milestones = extractMatches(text, [
|
|
5462
|
+
/\b(?:completed|finished|fixed|resolved|shipped|deployed|published|pushed|passed)\b([^.!?\n]{0,180})/gi,
|
|
5463
|
+
/(?:milestone|done):\s*([^.!?\n]{8,220})/gi
|
|
5464
|
+
]);
|
|
5465
|
+
const problems = extractMatches(text, [
|
|
5466
|
+
/\b(?:blocked by|failed because|bug|regression|broken|not working|error)\b([^.!?\n]{0,180})/gi,
|
|
5467
|
+
/(?:problem|issue|risk):\s*([^.!?\n]{8,220})/gi
|
|
5468
|
+
]);
|
|
5469
|
+
const decisions = extractMatches(text, [
|
|
5470
|
+
/(?:decided|decision|adr|we chose|approved|rejected)\s+([^.!?\n]{8,220})/gi
|
|
5471
|
+
]);
|
|
5472
|
+
const temporalAnchors = extractMatches(text, [
|
|
5473
|
+
/\b(\d{4}-\d{2}-\d{2}(?:[T ][0-9:.+-Z]+)?)\b/g,
|
|
5474
|
+
/\b(today|yesterday|tomorrow|this week|next week|last week|morning|afternoon|tonight)\b/gi
|
|
5475
|
+
], 8);
|
|
5476
|
+
const nextActions = extractMatches(text, [
|
|
5477
|
+
/(?:next|todo|follow[- ]?up|remaining|need to)\s*:?\s*([^.!?\n]{8,220})/gi
|
|
5478
|
+
]);
|
|
5479
|
+
const actors = uniq([
|
|
5480
|
+
row.agent_id,
|
|
5481
|
+
...extractMatches(text, [/\b(?:agent|employee|owner|assignee)[:= ]+([a-zA-Z][a-zA-Z0-9_-]{1,40})/gi], 5)
|
|
5482
|
+
], 6);
|
|
5483
|
+
const successSignals = milestones.length ? milestones : outcome === "success_signal" ? [clean(text, 180)] : [];
|
|
5484
|
+
const failureSignals = problems.length ? problems : outcome === "failure_signal" || row.has_error ? [clean(text, 180)] : [];
|
|
5485
|
+
const impact = successSignals.length && failureSignals.length ? "mixed" : failureSignals.length ? "negative" : successSignals.length ? "positive" : "neutral";
|
|
5486
|
+
const signalCount = goals.length + milestones.length + problems.length + decisions.length + nextActions.length;
|
|
5487
|
+
return {
|
|
5488
|
+
labeler: "deterministic",
|
|
5489
|
+
schemaVersion: 1,
|
|
5490
|
+
eventType,
|
|
5491
|
+
intention,
|
|
5492
|
+
outcome,
|
|
5493
|
+
impact,
|
|
5494
|
+
confidence: Math.min(0.95, 0.45 + signalCount * 0.08 + (intention ? 0.1 : 0) + (outcome ? 0.1 : 0)),
|
|
5495
|
+
goals,
|
|
5496
|
+
milestones,
|
|
5497
|
+
problems,
|
|
5498
|
+
decisions,
|
|
5499
|
+
actors,
|
|
5500
|
+
temporalAnchors,
|
|
5501
|
+
successSignals,
|
|
5502
|
+
failureSignals,
|
|
5503
|
+
nextActions,
|
|
5504
|
+
summary: clean(text, 280)
|
|
5505
|
+
};
|
|
5506
|
+
}
|
|
5507
|
+
function ontologyPayload(row) {
|
|
5508
|
+
const semantic = inferSemanticLabel(row);
|
|
5509
|
+
return {
|
|
5510
|
+
tool_name: row.tool_name,
|
|
5511
|
+
memory_version: row.version ?? null,
|
|
5512
|
+
domain: row.domain ?? null,
|
|
5513
|
+
trajectory: row.trajectory ? safeJson(row.trajectory) : null,
|
|
5514
|
+
semantic
|
|
5515
|
+
};
|
|
5516
|
+
}
|
|
5517
|
+
function safeJson(value) {
|
|
5518
|
+
try {
|
|
5519
|
+
return JSON.parse(value);
|
|
5520
|
+
} catch {
|
|
5521
|
+
return value.slice(0, 1e3);
|
|
5522
|
+
}
|
|
5523
|
+
}
|
|
5524
|
+
async function resolveClient(client) {
|
|
5525
|
+
if (client) return client;
|
|
5526
|
+
const { getClient: getClient2 } = await Promise.resolve().then(() => (init_database(), database_exports));
|
|
5527
|
+
return getClient2();
|
|
5528
|
+
}
|
|
5529
|
+
async function insertOntologyForMemory(row, client) {
|
|
5530
|
+
const db = await resolveClient(client);
|
|
5531
|
+
const occurredAt = row.timestamp;
|
|
5532
|
+
const sequence = Number(row.version ?? 0) || Math.floor(new Date(occurredAt).getTime() / 1e3);
|
|
5533
|
+
const eventType = inferOntologyEventType(row);
|
|
5534
|
+
const intention = inferIntention(row);
|
|
5535
|
+
const outcome = inferOutcome(row);
|
|
5536
|
+
const eventId = stableId2("event", row.id);
|
|
5537
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
5538
|
+
await db.execute({
|
|
5539
|
+
sql: `INSERT INTO agent_sessions (id, agent_id, project_name, started_at, last_event_at, event_count, properties)
|
|
5540
|
+
VALUES (?, ?, ?, ?, ?, 1, ?)
|
|
5541
|
+
ON CONFLICT(id) DO UPDATE SET last_event_at = MAX(last_event_at, excluded.last_event_at),
|
|
5542
|
+
event_count = event_count + 1`,
|
|
5543
|
+
args: [row.session_id, row.agent_id, row.project_name, occurredAt, occurredAt, JSON.stringify({ agent_role: row.agent_role })]
|
|
5544
|
+
});
|
|
5545
|
+
await db.execute({
|
|
5546
|
+
sql: `INSERT OR IGNORE INTO agent_events
|
|
5547
|
+
(id, event_type, occurred_at, sequence_index, actor_agent_id, agent_role, project_name,
|
|
5548
|
+
session_id, task_id, goal_id, parent_event_id, intention, outcome, evidence_memory_id,
|
|
5549
|
+
impact, payload, created_at)
|
|
5550
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NULL, NULL, ?, ?, ?, ?, ?, ?)`,
|
|
5551
|
+
args: [
|
|
5552
|
+
eventId,
|
|
5553
|
+
eventType,
|
|
5554
|
+
occurredAt,
|
|
5555
|
+
sequence,
|
|
5556
|
+
row.agent_id,
|
|
5557
|
+
row.agent_role,
|
|
5558
|
+
row.project_name,
|
|
5559
|
+
row.session_id,
|
|
5560
|
+
row.task_id ?? null,
|
|
5561
|
+
intention,
|
|
5562
|
+
outcome,
|
|
5563
|
+
row.id,
|
|
5564
|
+
row.has_error ? "negative" : outcome === "success_signal" ? "positive" : "neutral",
|
|
5565
|
+
JSON.stringify(ontologyPayload(row)),
|
|
5566
|
+
now
|
|
5567
|
+
]
|
|
5568
|
+
});
|
|
5569
|
+
const semantic = inferSemanticLabel(row);
|
|
5570
|
+
await db.execute({
|
|
5571
|
+
sql: `INSERT INTO agent_semantic_labels
|
|
5572
|
+
(id, source_memory_id, event_id, labeler, schema_version, confidence, labels, created_at, updated_at)
|
|
5573
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
5574
|
+
ON CONFLICT(id) DO UPDATE SET confidence = excluded.confidence,
|
|
5575
|
+
labels = excluded.labels, updated_at = excluded.updated_at`,
|
|
5576
|
+
args: [
|
|
5577
|
+
stableId2("semantic", row.id, semantic.labeler, semantic.schemaVersion),
|
|
5578
|
+
row.id,
|
|
5579
|
+
eventId,
|
|
5580
|
+
semantic.labeler,
|
|
5581
|
+
semantic.schemaVersion,
|
|
5582
|
+
semantic.confidence,
|
|
5583
|
+
JSON.stringify(semantic),
|
|
5584
|
+
now,
|
|
5585
|
+
now
|
|
5586
|
+
]
|
|
5587
|
+
});
|
|
5588
|
+
for (const statement of extractGoalCandidates(row)) {
|
|
5589
|
+
const goalId = stableId2("goal", row.project_name, statement.toLowerCase());
|
|
5590
|
+
await db.execute({
|
|
5591
|
+
sql: `INSERT INTO agent_goals
|
|
5592
|
+
(id, statement, owner_agent_id, project_name, status, priority, success_criteria,
|
|
5593
|
+
parent_goal_id, due_at, achieved_at, supersedes_id, created_at, updated_at, source_memory_id)
|
|
5594
|
+
VALUES (?, ?, ?, ?, 'open', 5, NULL, NULL, NULL, NULL, NULL, ?, ?, ?)
|
|
5595
|
+
ON CONFLICT(id) DO UPDATE SET updated_at = excluded.updated_at`,
|
|
5596
|
+
args: [goalId, statement, row.agent_id, row.project_name, now, now, row.id]
|
|
5597
|
+
});
|
|
5598
|
+
await db.execute({
|
|
5599
|
+
sql: `INSERT OR IGNORE INTO agent_goal_links
|
|
5600
|
+
(id, goal_id, link_type, target_id, target_type, created_at)
|
|
5601
|
+
VALUES (?, ?, 'evidence', ?, 'memory', ?)`,
|
|
5602
|
+
args: [stableId2("goal_link", goalId, row.id, "memory"), goalId, row.id, now]
|
|
5603
|
+
});
|
|
5604
|
+
await db.execute({
|
|
5605
|
+
sql: `INSERT OR IGNORE INTO agent_goal_links
|
|
5606
|
+
(id, goal_id, link_type, target_id, target_type, created_at)
|
|
5607
|
+
VALUES (?, ?, 'event', ?, 'event', ?)`,
|
|
5608
|
+
args: [stableId2("goal_link", goalId, eventId, "event"), goalId, eventId, now]
|
|
5609
|
+
});
|
|
5610
|
+
}
|
|
5611
|
+
}
|
|
5612
|
+
async function insertOntologyForBatch(rows, client) {
|
|
5613
|
+
const db = await resolveClient(client);
|
|
5614
|
+
let count = 0;
|
|
5615
|
+
for (const row of rows) {
|
|
5616
|
+
try {
|
|
5617
|
+
await insertOntologyForMemory(row, db);
|
|
5618
|
+
count++;
|
|
5619
|
+
} catch {
|
|
5620
|
+
}
|
|
5621
|
+
}
|
|
5622
|
+
return count;
|
|
5623
|
+
}
|
|
5624
|
+
var init_agentic_ontology = __esm({
|
|
5625
|
+
"src/lib/agentic-ontology.ts"() {
|
|
5626
|
+
"use strict";
|
|
5627
|
+
}
|
|
5628
|
+
});
|
|
5629
|
+
|
|
5127
5630
|
// src/lib/store.ts
|
|
5128
5631
|
var store_exports = {};
|
|
5129
5632
|
__export(store_exports, {
|
|
@@ -5467,6 +5970,11 @@ async function flushBatch() {
|
|
|
5467
5970
|
await insertMemoryCardsForBatch2(batch);
|
|
5468
5971
|
} catch {
|
|
5469
5972
|
}
|
|
5973
|
+
try {
|
|
5974
|
+
const { insertOntologyForBatch: insertOntologyForBatch2 } = await Promise.resolve().then(() => (init_agentic_ontology(), agentic_ontology_exports));
|
|
5975
|
+
await insertOntologyForBatch2(batch);
|
|
5976
|
+
} catch {
|
|
5977
|
+
}
|
|
5470
5978
|
schedulePostWriteMemoryHygiene(batch.map((row) => row.id));
|
|
5471
5979
|
_pendingRecords.splice(0, batch.length);
|
|
5472
5980
|
try {
|