@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
|
@@ -214,6 +214,11 @@ function normalizeAutoUpdate(raw) {
|
|
|
214
214
|
const userAU = raw.autoUpdate ?? {};
|
|
215
215
|
raw.autoUpdate = { ...defaultAU, ...userAU };
|
|
216
216
|
}
|
|
217
|
+
function normalizeOrchestration(raw) {
|
|
218
|
+
const defaultOrg = DEFAULT_CONFIG.orchestration;
|
|
219
|
+
const userOrg = raw.orchestration ?? {};
|
|
220
|
+
raw.orchestration = { ...defaultOrg, ...userOrg };
|
|
221
|
+
}
|
|
217
222
|
async function loadConfig() {
|
|
218
223
|
const dir = process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? EXE_AI_DIR;
|
|
219
224
|
await ensurePrivateDir(dir);
|
|
@@ -238,10 +243,15 @@ async function loadConfig() {
|
|
|
238
243
|
normalizeScalingRoadmap(migratedCfg);
|
|
239
244
|
normalizeSessionLifecycle(migratedCfg);
|
|
240
245
|
normalizeAutoUpdate(migratedCfg);
|
|
246
|
+
normalizeOrchestration(migratedCfg);
|
|
241
247
|
const config = { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db"), ...migratedCfg };
|
|
242
248
|
if (config.dbPath.startsWith("~")) {
|
|
243
249
|
config.dbPath = config.dbPath.replace(/^~/, os.homedir());
|
|
244
250
|
}
|
|
251
|
+
const envDbPath = path.join(dir, "memories.db");
|
|
252
|
+
if (process.env.EXE_OS_DIR && config.dbPath !== envDbPath && !existsSync2(config.dbPath) && existsSync2(envDbPath)) {
|
|
253
|
+
config.dbPath = envDbPath;
|
|
254
|
+
}
|
|
245
255
|
return config;
|
|
246
256
|
} catch {
|
|
247
257
|
return { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db") };
|
|
@@ -261,7 +271,16 @@ function loadConfigSync() {
|
|
|
261
271
|
normalizeScalingRoadmap(migratedCfg);
|
|
262
272
|
normalizeSessionLifecycle(migratedCfg);
|
|
263
273
|
normalizeAutoUpdate(migratedCfg);
|
|
264
|
-
|
|
274
|
+
normalizeOrchestration(migratedCfg);
|
|
275
|
+
const config = { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db"), ...migratedCfg };
|
|
276
|
+
if (config.dbPath.startsWith("~")) {
|
|
277
|
+
config.dbPath = config.dbPath.replace(/^~/, os.homedir());
|
|
278
|
+
}
|
|
279
|
+
const envDbPath = path.join(dir, "memories.db");
|
|
280
|
+
if (process.env.EXE_OS_DIR && config.dbPath !== envDbPath && !existsSync2(config.dbPath) && existsSync2(envDbPath)) {
|
|
281
|
+
config.dbPath = envDbPath;
|
|
282
|
+
}
|
|
283
|
+
return config;
|
|
265
284
|
} catch {
|
|
266
285
|
return { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db") };
|
|
267
286
|
}
|
|
@@ -282,6 +301,7 @@ async function loadConfigFrom(configPath) {
|
|
|
282
301
|
normalizeScalingRoadmap(migratedCfg);
|
|
283
302
|
normalizeSessionLifecycle(migratedCfg);
|
|
284
303
|
normalizeAutoUpdate(migratedCfg);
|
|
304
|
+
normalizeOrchestration(migratedCfg);
|
|
285
305
|
return { ...DEFAULT_CONFIG, ...migratedCfg };
|
|
286
306
|
} catch {
|
|
287
307
|
return { ...DEFAULT_CONFIG };
|
|
@@ -353,6 +373,10 @@ var init_config = __esm({
|
|
|
353
373
|
checkOnBoot: true,
|
|
354
374
|
autoInstall: false,
|
|
355
375
|
checkIntervalMs: 24 * 60 * 60 * 1e3
|
|
376
|
+
},
|
|
377
|
+
orchestration: {
|
|
378
|
+
phase: "phase_1_coo",
|
|
379
|
+
phaseSetBy: "default"
|
|
356
380
|
}
|
|
357
381
|
};
|
|
358
382
|
CONFIG_MIGRATIONS = [
|
|
@@ -1767,6 +1791,9 @@ function getClient() {
|
|
|
1767
1791
|
if (_daemonClient && _daemonClient._isDaemonActive()) {
|
|
1768
1792
|
return _daemonClient;
|
|
1769
1793
|
}
|
|
1794
|
+
if (!_resilientClient) {
|
|
1795
|
+
return _adapterClient;
|
|
1796
|
+
}
|
|
1770
1797
|
return _resilientClient;
|
|
1771
1798
|
}
|
|
1772
1799
|
async function initDaemonClient() {
|
|
@@ -2799,6 +2826,127 @@ async function ensureSchema() {
|
|
|
2799
2826
|
VALUES (new.rowid, new.content, new.subject, new.predicate, new.object);
|
|
2800
2827
|
END;
|
|
2801
2828
|
`);
|
|
2829
|
+
await client.executeMultiple(`
|
|
2830
|
+
CREATE TABLE IF NOT EXISTS agent_sessions (
|
|
2831
|
+
id TEXT PRIMARY KEY,
|
|
2832
|
+
agent_id TEXT NOT NULL,
|
|
2833
|
+
project_name TEXT,
|
|
2834
|
+
started_at TEXT NOT NULL,
|
|
2835
|
+
last_event_at TEXT NOT NULL,
|
|
2836
|
+
event_count INTEGER NOT NULL DEFAULT 0,
|
|
2837
|
+
properties TEXT DEFAULT '{}'
|
|
2838
|
+
);
|
|
2839
|
+
|
|
2840
|
+
CREATE INDEX IF NOT EXISTS idx_agent_sessions_agent_time
|
|
2841
|
+
ON agent_sessions(agent_id, started_at);
|
|
2842
|
+
|
|
2843
|
+
CREATE TABLE IF NOT EXISTS agent_goals (
|
|
2844
|
+
id TEXT PRIMARY KEY,
|
|
2845
|
+
statement TEXT NOT NULL,
|
|
2846
|
+
owner_agent_id TEXT,
|
|
2847
|
+
project_name TEXT,
|
|
2848
|
+
status TEXT NOT NULL DEFAULT 'open',
|
|
2849
|
+
priority INTEGER NOT NULL DEFAULT 5,
|
|
2850
|
+
success_criteria TEXT,
|
|
2851
|
+
parent_goal_id TEXT,
|
|
2852
|
+
due_at TEXT,
|
|
2853
|
+
achieved_at TEXT,
|
|
2854
|
+
supersedes_id TEXT,
|
|
2855
|
+
created_at TEXT NOT NULL,
|
|
2856
|
+
updated_at TEXT NOT NULL,
|
|
2857
|
+
source_memory_id TEXT
|
|
2858
|
+
);
|
|
2859
|
+
|
|
2860
|
+
CREATE INDEX IF NOT EXISTS idx_agent_goals_project_status
|
|
2861
|
+
ON agent_goals(project_name, status, priority);
|
|
2862
|
+
|
|
2863
|
+
CREATE TABLE IF NOT EXISTS agent_events (
|
|
2864
|
+
id TEXT PRIMARY KEY,
|
|
2865
|
+
event_type TEXT NOT NULL,
|
|
2866
|
+
occurred_at TEXT NOT NULL,
|
|
2867
|
+
sequence_index INTEGER NOT NULL,
|
|
2868
|
+
actor_agent_id TEXT,
|
|
2869
|
+
agent_role TEXT,
|
|
2870
|
+
project_name TEXT,
|
|
2871
|
+
session_id TEXT,
|
|
2872
|
+
task_id TEXT,
|
|
2873
|
+
goal_id TEXT,
|
|
2874
|
+
parent_event_id TEXT,
|
|
2875
|
+
intention TEXT,
|
|
2876
|
+
outcome TEXT,
|
|
2877
|
+
evidence_memory_id TEXT,
|
|
2878
|
+
impact TEXT,
|
|
2879
|
+
payload TEXT DEFAULT '{}',
|
|
2880
|
+
created_at TEXT NOT NULL
|
|
2881
|
+
);
|
|
2882
|
+
|
|
2883
|
+
CREATE INDEX IF NOT EXISTS idx_agent_events_time
|
|
2884
|
+
ON agent_events(occurred_at, sequence_index);
|
|
2885
|
+
|
|
2886
|
+
CREATE INDEX IF NOT EXISTS idx_agent_events_session_seq
|
|
2887
|
+
ON agent_events(session_id, sequence_index);
|
|
2888
|
+
|
|
2889
|
+
CREATE INDEX IF NOT EXISTS idx_agent_events_goal_time
|
|
2890
|
+
ON agent_events(goal_id, occurred_at);
|
|
2891
|
+
|
|
2892
|
+
CREATE INDEX IF NOT EXISTS idx_agent_events_memory
|
|
2893
|
+
ON agent_events(evidence_memory_id);
|
|
2894
|
+
|
|
2895
|
+
CREATE TABLE IF NOT EXISTS agent_goal_links (
|
|
2896
|
+
id TEXT PRIMARY KEY,
|
|
2897
|
+
goal_id TEXT NOT NULL,
|
|
2898
|
+
link_type TEXT NOT NULL,
|
|
2899
|
+
target_id TEXT NOT NULL,
|
|
2900
|
+
target_type TEXT NOT NULL,
|
|
2901
|
+
created_at TEXT NOT NULL
|
|
2902
|
+
);
|
|
2903
|
+
|
|
2904
|
+
CREATE INDEX IF NOT EXISTS idx_agent_goal_links_goal
|
|
2905
|
+
ON agent_goal_links(goal_id, target_type);
|
|
2906
|
+
|
|
2907
|
+
CREATE TABLE IF NOT EXISTS agent_semantic_labels (
|
|
2908
|
+
id TEXT PRIMARY KEY,
|
|
2909
|
+
source_memory_id TEXT NOT NULL,
|
|
2910
|
+
event_id TEXT,
|
|
2911
|
+
labeler TEXT NOT NULL,
|
|
2912
|
+
schema_version INTEGER NOT NULL DEFAULT 1,
|
|
2913
|
+
confidence REAL NOT NULL DEFAULT 0,
|
|
2914
|
+
labels TEXT NOT NULL,
|
|
2915
|
+
created_at TEXT NOT NULL,
|
|
2916
|
+
updated_at TEXT NOT NULL
|
|
2917
|
+
);
|
|
2918
|
+
|
|
2919
|
+
CREATE INDEX IF NOT EXISTS idx_agent_semantic_labels_memory
|
|
2920
|
+
ON agent_semantic_labels(source_memory_id, labeler);
|
|
2921
|
+
|
|
2922
|
+
CREATE INDEX IF NOT EXISTS idx_agent_semantic_labels_event
|
|
2923
|
+
ON agent_semantic_labels(event_id);
|
|
2924
|
+
|
|
2925
|
+
CREATE TABLE IF NOT EXISTS agent_reflection_checkpoints (
|
|
2926
|
+
id TEXT PRIMARY KEY,
|
|
2927
|
+
project_name TEXT,
|
|
2928
|
+
session_id TEXT,
|
|
2929
|
+
window_start_at TEXT NOT NULL,
|
|
2930
|
+
window_end_at TEXT NOT NULL,
|
|
2931
|
+
event_count INTEGER NOT NULL DEFAULT 0,
|
|
2932
|
+
goal_count INTEGER NOT NULL DEFAULT 0,
|
|
2933
|
+
success_count INTEGER NOT NULL DEFAULT 0,
|
|
2934
|
+
failure_count INTEGER NOT NULL DEFAULT 0,
|
|
2935
|
+
risk_count INTEGER NOT NULL DEFAULT 0,
|
|
2936
|
+
summary TEXT NOT NULL,
|
|
2937
|
+
learnings TEXT NOT NULL DEFAULT '[]',
|
|
2938
|
+
next_actions TEXT NOT NULL DEFAULT '[]',
|
|
2939
|
+
evidence_event_ids TEXT NOT NULL DEFAULT '[]',
|
|
2940
|
+
confidence REAL NOT NULL DEFAULT 0,
|
|
2941
|
+
created_at TEXT NOT NULL
|
|
2942
|
+
);
|
|
2943
|
+
|
|
2944
|
+
CREATE INDEX IF NOT EXISTS idx_agent_reflection_project_time
|
|
2945
|
+
ON agent_reflection_checkpoints(project_name, window_end_at);
|
|
2946
|
+
|
|
2947
|
+
CREATE INDEX IF NOT EXISTS idx_agent_reflection_session_time
|
|
2948
|
+
ON agent_reflection_checkpoints(session_id, window_end_at);
|
|
2949
|
+
`);
|
|
2802
2950
|
try {
|
|
2803
2951
|
await client.execute({
|
|
2804
2952
|
sql: `ALTER TABLE memories ADD COLUMN tier INTEGER DEFAULT 3`,
|
|
@@ -2948,7 +3096,7 @@ var init_database = __esm({
|
|
|
2948
3096
|
|
|
2949
3097
|
// src/lib/keychain.ts
|
|
2950
3098
|
import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2 } from "fs/promises";
|
|
2951
|
-
import { existsSync as existsSync6 } from "fs";
|
|
3099
|
+
import { existsSync as existsSync6, statSync as statSync2 } from "fs";
|
|
2952
3100
|
import { execSync as execSync2 } from "child_process";
|
|
2953
3101
|
import path6 from "path";
|
|
2954
3102
|
import os5 from "os";
|
|
@@ -2958,29 +3106,78 @@ function getKeyDir() {
|
|
|
2958
3106
|
function getKeyPath() {
|
|
2959
3107
|
return path6.join(getKeyDir(), "master.key");
|
|
2960
3108
|
}
|
|
2961
|
-
function
|
|
3109
|
+
function nativeKeychainAllowed() {
|
|
3110
|
+
return process.env.EXE_OS_DISABLE_NATIVE_KEYCHAIN !== "1";
|
|
3111
|
+
}
|
|
3112
|
+
function linuxSecretAvailable() {
|
|
3113
|
+
if (!nativeKeychainAllowed()) return false;
|
|
3114
|
+
if (process.platform !== "linux") return false;
|
|
3115
|
+
if (linuxSecretAvailability !== null) return linuxSecretAvailability;
|
|
3116
|
+
try {
|
|
3117
|
+
execSync2("command -v secret-tool >/dev/null 2>&1", { timeout: 1e3 });
|
|
3118
|
+
} catch {
|
|
3119
|
+
linuxSecretAvailability = false;
|
|
3120
|
+
return false;
|
|
3121
|
+
}
|
|
3122
|
+
try {
|
|
3123
|
+
execSync2("secret-tool search --all exe-os probe >/dev/null 2>&1", { timeout: 1e3 });
|
|
3124
|
+
linuxSecretAvailability = true;
|
|
3125
|
+
} catch {
|
|
3126
|
+
linuxSecretAvailability = false;
|
|
3127
|
+
}
|
|
3128
|
+
return linuxSecretAvailability;
|
|
3129
|
+
}
|
|
3130
|
+
function isRootOnlyTrustedServerKeyFile(keyPath) {
|
|
3131
|
+
if (process.platform !== "linux") return false;
|
|
3132
|
+
try {
|
|
3133
|
+
const uid = typeof os5.userInfo().uid === "number" ? os5.userInfo().uid : -1;
|
|
3134
|
+
const st = statSync2(keyPath);
|
|
3135
|
+
if (!st.isFile() || (st.mode & 63) !== 0) return false;
|
|
3136
|
+
if (uid === 0) return true;
|
|
3137
|
+
const exeOsDir = process.env.EXE_OS_DIR;
|
|
3138
|
+
return Boolean(exeOsDir && path6.resolve(keyPath).startsWith(path6.resolve(exeOsDir) + path6.sep));
|
|
3139
|
+
} catch {
|
|
3140
|
+
return false;
|
|
3141
|
+
}
|
|
3142
|
+
}
|
|
3143
|
+
function macKeychainGet(service = SERVICE) {
|
|
3144
|
+
if (!nativeKeychainAllowed()) return null;
|
|
2962
3145
|
if (process.platform !== "darwin") return null;
|
|
2963
3146
|
try {
|
|
2964
3147
|
return execSync2(
|
|
2965
|
-
`security find-generic-password -s "${
|
|
3148
|
+
`security find-generic-password -s "${service}" -a "${ACCOUNT}" -w 2>/dev/null`,
|
|
2966
3149
|
{ encoding: "utf-8", timeout: 5e3 }
|
|
2967
3150
|
).trim();
|
|
2968
3151
|
} catch {
|
|
2969
3152
|
return null;
|
|
2970
3153
|
}
|
|
2971
3154
|
}
|
|
2972
|
-
function macKeychainSet(value) {
|
|
3155
|
+
function macKeychainSet(value, service = SERVICE) {
|
|
3156
|
+
if (!nativeKeychainAllowed()) return false;
|
|
2973
3157
|
if (process.platform !== "darwin") return false;
|
|
2974
3158
|
try {
|
|
2975
3159
|
try {
|
|
2976
3160
|
execSync2(
|
|
2977
|
-
`security delete-generic-password -s "${
|
|
3161
|
+
`security delete-generic-password -s "${service}" -a "${ACCOUNT}" 2>/dev/null`,
|
|
2978
3162
|
{ timeout: 5e3 }
|
|
2979
3163
|
);
|
|
2980
3164
|
} catch {
|
|
2981
3165
|
}
|
|
2982
3166
|
execSync2(
|
|
2983
|
-
`security add-generic-password -s "${
|
|
3167
|
+
`security add-generic-password -s "${service}" -a "${ACCOUNT}" -w "${value}"`,
|
|
3168
|
+
{ timeout: 5e3 }
|
|
3169
|
+
);
|
|
3170
|
+
return true;
|
|
3171
|
+
} catch {
|
|
3172
|
+
return false;
|
|
3173
|
+
}
|
|
3174
|
+
}
|
|
3175
|
+
function macKeychainDelete(service = SERVICE) {
|
|
3176
|
+
if (!nativeKeychainAllowed()) return false;
|
|
3177
|
+
if (process.platform !== "darwin") return false;
|
|
3178
|
+
try {
|
|
3179
|
+
execSync2(
|
|
3180
|
+
`security delete-generic-password -s "${service}" -a "${ACCOUNT}" 2>/dev/null`,
|
|
2984
3181
|
{ timeout: 5e3 }
|
|
2985
3182
|
);
|
|
2986
3183
|
return true;
|
|
@@ -2988,22 +3185,35 @@ function macKeychainSet(value) {
|
|
|
2988
3185
|
return false;
|
|
2989
3186
|
}
|
|
2990
3187
|
}
|
|
2991
|
-
function linuxSecretGet() {
|
|
2992
|
-
if (
|
|
3188
|
+
function linuxSecretGet(service = SERVICE) {
|
|
3189
|
+
if (!linuxSecretAvailable()) return null;
|
|
2993
3190
|
try {
|
|
2994
3191
|
return execSync2(
|
|
2995
|
-
`secret-tool lookup service "${
|
|
3192
|
+
`secret-tool lookup service "${service}" account "${ACCOUNT}" 2>/dev/null`,
|
|
2996
3193
|
{ encoding: "utf-8", timeout: 5e3 }
|
|
2997
3194
|
).trim();
|
|
2998
3195
|
} catch {
|
|
2999
3196
|
return null;
|
|
3000
3197
|
}
|
|
3001
3198
|
}
|
|
3002
|
-
function linuxSecretSet(value) {
|
|
3199
|
+
function linuxSecretSet(value, service = SERVICE) {
|
|
3200
|
+
if (!linuxSecretAvailable()) return false;
|
|
3201
|
+
try {
|
|
3202
|
+
execSync2(
|
|
3203
|
+
`echo -n "${value}" | secret-tool store --label="exe-os master key" service "${service}" account "${ACCOUNT}" 2>/dev/null`,
|
|
3204
|
+
{ timeout: 5e3 }
|
|
3205
|
+
);
|
|
3206
|
+
return true;
|
|
3207
|
+
} catch {
|
|
3208
|
+
return false;
|
|
3209
|
+
}
|
|
3210
|
+
}
|
|
3211
|
+
function linuxSecretDelete(service = SERVICE) {
|
|
3212
|
+
if (!nativeKeychainAllowed()) return false;
|
|
3003
3213
|
if (process.platform !== "linux") return false;
|
|
3004
3214
|
try {
|
|
3005
3215
|
execSync2(
|
|
3006
|
-
`
|
|
3216
|
+
`secret-tool clear service "${service}" account "${ACCOUNT}" 2>/dev/null`,
|
|
3007
3217
|
{ timeout: 5e3 }
|
|
3008
3218
|
);
|
|
3009
3219
|
return true;
|
|
@@ -3012,6 +3222,7 @@ function linuxSecretSet(value) {
|
|
|
3012
3222
|
}
|
|
3013
3223
|
}
|
|
3014
3224
|
async function tryKeytar() {
|
|
3225
|
+
if (!nativeKeychainAllowed()) return null;
|
|
3015
3226
|
try {
|
|
3016
3227
|
return await import("keytar");
|
|
3017
3228
|
} catch {
|
|
@@ -3085,7 +3296,19 @@ async function writeMachineBoundFileFallback(b64) {
|
|
|
3085
3296
|
return "plaintext";
|
|
3086
3297
|
}
|
|
3087
3298
|
async function getMasterKey() {
|
|
3088
|
-
|
|
3299
|
+
let nativeValue = macKeychainGet() ?? linuxSecretGet();
|
|
3300
|
+
if (!nativeValue) {
|
|
3301
|
+
const legacyValue = macKeychainGet(LEGACY_SERVICE) ?? linuxSecretGet(LEGACY_SERVICE);
|
|
3302
|
+
if (legacyValue) {
|
|
3303
|
+
const migrated = macKeychainSet(legacyValue) || linuxSecretSet(legacyValue);
|
|
3304
|
+
if (migrated) {
|
|
3305
|
+
macKeychainDelete(LEGACY_SERVICE);
|
|
3306
|
+
linuxSecretDelete(LEGACY_SERVICE);
|
|
3307
|
+
process.stderr.write("[keychain] Migrated keychain service from exe-mem to exe-os.\n");
|
|
3308
|
+
}
|
|
3309
|
+
nativeValue = legacyValue;
|
|
3310
|
+
}
|
|
3311
|
+
}
|
|
3089
3312
|
if (nativeValue) {
|
|
3090
3313
|
return Buffer.from(nativeValue, "base64");
|
|
3091
3314
|
}
|
|
@@ -3093,12 +3316,17 @@ async function getMasterKey() {
|
|
|
3093
3316
|
if (keytar) {
|
|
3094
3317
|
try {
|
|
3095
3318
|
const keytarValue = await keytar.getPassword(SERVICE, ACCOUNT);
|
|
3096
|
-
|
|
3097
|
-
|
|
3319
|
+
const legacyKeytarValue = keytarValue ?? await keytar.getPassword(LEGACY_SERVICE, ACCOUNT);
|
|
3320
|
+
if (legacyKeytarValue) {
|
|
3321
|
+
const migrated = macKeychainSet(legacyKeytarValue) || linuxSecretSet(legacyKeytarValue);
|
|
3098
3322
|
if (migrated) {
|
|
3099
3323
|
process.stderr.write("[keychain] Migrated key from keytar to native keychain.\n");
|
|
3324
|
+
try {
|
|
3325
|
+
await keytar.deletePassword(LEGACY_SERVICE, ACCOUNT);
|
|
3326
|
+
} catch {
|
|
3327
|
+
}
|
|
3100
3328
|
}
|
|
3101
|
-
return Buffer.from(
|
|
3329
|
+
return Buffer.from(legacyKeytarValue, "base64");
|
|
3102
3330
|
}
|
|
3103
3331
|
} catch {
|
|
3104
3332
|
}
|
|
@@ -3123,7 +3351,7 @@ async function getMasterKey() {
|
|
|
3123
3351
|
const decrypted = decryptWithMachineKey(content, machineKey);
|
|
3124
3352
|
if (!decrypted) {
|
|
3125
3353
|
process.stderr.write(
|
|
3126
|
-
"[keychain] Key decryption failed \u2014 machine may have changed.\n Use your 24-word recovery phrase: exe-os
|
|
3354
|
+
"[keychain] Key decryption failed \u2014 machine may have changed.\n Use your 24-word recovery phrase during setup: exe-os setup\n"
|
|
3127
3355
|
);
|
|
3128
3356
|
return null;
|
|
3129
3357
|
}
|
|
@@ -3132,6 +3360,9 @@ async function getMasterKey() {
|
|
|
3132
3360
|
b64Value = content;
|
|
3133
3361
|
}
|
|
3134
3362
|
const key = Buffer.from(b64Value, "base64");
|
|
3363
|
+
if (!content.startsWith(ENCRYPTED_PREFIX) && isRootOnlyTrustedServerKeyFile(keyPath)) {
|
|
3364
|
+
return key;
|
|
3365
|
+
}
|
|
3135
3366
|
const migrated = macKeychainSet(b64Value) || linuxSecretSet(b64Value);
|
|
3136
3367
|
if (migrated) {
|
|
3137
3368
|
process.stderr.write("[keychain] Migrated key from file to native keychain.\n");
|
|
@@ -3159,12 +3390,14 @@ async function getMasterKey() {
|
|
|
3159
3390
|
return null;
|
|
3160
3391
|
}
|
|
3161
3392
|
}
|
|
3162
|
-
var SERVICE, ACCOUNT, ENCRYPTED_PREFIX;
|
|
3393
|
+
var SERVICE, LEGACY_SERVICE, ACCOUNT, linuxSecretAvailability, ENCRYPTED_PREFIX;
|
|
3163
3394
|
var init_keychain = __esm({
|
|
3164
3395
|
"src/lib/keychain.ts"() {
|
|
3165
3396
|
"use strict";
|
|
3166
|
-
SERVICE = "exe-
|
|
3397
|
+
SERVICE = "exe-os";
|
|
3398
|
+
LEGACY_SERVICE = "exe-mem";
|
|
3167
3399
|
ACCOUNT = "master-key";
|
|
3400
|
+
linuxSecretAvailability = null;
|
|
3168
3401
|
ENCRYPTED_PREFIX = "enc:";
|
|
3169
3402
|
}
|
|
3170
3403
|
});
|
|
@@ -3434,7 +3667,7 @@ __export(shard_manager_exports, {
|
|
|
3434
3667
|
shardExists: () => shardExists
|
|
3435
3668
|
});
|
|
3436
3669
|
import path7 from "path";
|
|
3437
|
-
import { existsSync as existsSync7, mkdirSync as mkdirSync2, readdirSync, renameSync as renameSync3, statSync as
|
|
3670
|
+
import { existsSync as existsSync7, mkdirSync as mkdirSync2, readdirSync, renameSync as renameSync3, statSync as statSync3 } from "fs";
|
|
3438
3671
|
import { createClient as createClient2 } from "@libsql/client";
|
|
3439
3672
|
function initShardManager(encryptionKey) {
|
|
3440
3673
|
_encryptionKey = encryptionKey;
|
|
@@ -3498,7 +3731,7 @@ async function auditShardHealth(options = {}) {
|
|
|
3498
3731
|
const shards = [];
|
|
3499
3732
|
for (const name of names) {
|
|
3500
3733
|
const dbPath = path7.join(SHARDS_DIR, `${name}.db`);
|
|
3501
|
-
const stat =
|
|
3734
|
+
const stat = statSync3(dbPath);
|
|
3502
3735
|
const item = {
|
|
3503
3736
|
name,
|
|
3504
3737
|
path: dbPath,
|
|
@@ -3751,7 +3984,7 @@ async function getReadyShardClient(projectName) {
|
|
|
3751
3984
|
_shardLastAccess.delete(safeName);
|
|
3752
3985
|
const dbPath = path7.join(SHARDS_DIR, `${safeName}.db`);
|
|
3753
3986
|
if (existsSync7(dbPath)) {
|
|
3754
|
-
const stat =
|
|
3987
|
+
const stat = statSync3(dbPath);
|
|
3755
3988
|
const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
3756
3989
|
const archivedPath = path7.join(SHARDS_DIR, `${safeName}.db.broken-${stamp}`);
|
|
3757
3990
|
renameSync3(dbPath, archivedPath);
|
|
@@ -3871,6 +4104,12 @@ var init_platform_procedures = __esm({
|
|
|
3871
4104
|
priority: "p0",
|
|
3872
4105
|
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."
|
|
3873
4106
|
},
|
|
4107
|
+
{
|
|
4108
|
+
title: "Customer orchestration maturity \u2014 recommend, never trap",
|
|
4109
|
+
domain: "workflow",
|
|
4110
|
+
priority: "p1",
|
|
4111
|
+
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."
|
|
4112
|
+
},
|
|
3874
4113
|
{
|
|
3875
4114
|
title: "Single dispatch path \u2014 create_task only",
|
|
3876
4115
|
domain: "workflow",
|
|
@@ -3929,6 +4168,12 @@ var init_platform_procedures = __esm({
|
|
|
3929
4168
|
priority: "p0",
|
|
3930
4169
|
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."
|
|
3931
4170
|
},
|
|
4171
|
+
{
|
|
4172
|
+
title: "Commit discipline \u2014 never leave verified work floating",
|
|
4173
|
+
domain: "workflow",
|
|
4174
|
+
priority: "p1",
|
|
4175
|
+
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."
|
|
4176
|
+
},
|
|
3932
4177
|
{
|
|
3933
4178
|
title: "Desktop and TUI are the same product",
|
|
3934
4179
|
domain: "architecture",
|
|
@@ -4246,6 +4491,274 @@ var init_memory_cards = __esm({
|
|
|
4246
4491
|
}
|
|
4247
4492
|
});
|
|
4248
4493
|
|
|
4494
|
+
// src/lib/agentic-ontology.ts
|
|
4495
|
+
var agentic_ontology_exports = {};
|
|
4496
|
+
__export(agentic_ontology_exports, {
|
|
4497
|
+
clean: () => clean,
|
|
4498
|
+
extractGoalCandidates: () => extractGoalCandidates,
|
|
4499
|
+
inferIntention: () => inferIntention,
|
|
4500
|
+
inferOntologyEventType: () => inferOntologyEventType,
|
|
4501
|
+
inferOutcome: () => inferOutcome,
|
|
4502
|
+
inferSemanticLabel: () => inferSemanticLabel,
|
|
4503
|
+
insertOntologyForBatch: () => insertOntologyForBatch,
|
|
4504
|
+
insertOntologyForMemory: () => insertOntologyForMemory,
|
|
4505
|
+
ontologyPayload: () => ontologyPayload,
|
|
4506
|
+
stableId: () => stableId2
|
|
4507
|
+
});
|
|
4508
|
+
import { createHash as createHash3 } from "crypto";
|
|
4509
|
+
function stableId2(...parts) {
|
|
4510
|
+
return createHash3("sha256").update(parts.map((p) => String(p ?? "")).join("::")).digest("hex").slice(0, 32);
|
|
4511
|
+
}
|
|
4512
|
+
function clean(text, max = 240) {
|
|
4513
|
+
return text.replace(/\u0000/g, "").replace(/```[\s\S]*?```/g, " ").replace(/\s+/g, " ").trim().slice(0, max);
|
|
4514
|
+
}
|
|
4515
|
+
function inferOntologyEventType(row) {
|
|
4516
|
+
const lower = row.raw_text.toLowerCase();
|
|
4517
|
+
if (row.has_error) return "error";
|
|
4518
|
+
if (/\b(done|complete|completed|fixed|resolved|shipped|deployed|pushed|published)\b/.test(lower)) return "milestone";
|
|
4519
|
+
if (/\b(blocked|failed|error|bug|regression|broken)\b/.test(lower)) return "problem";
|
|
4520
|
+
if (/\b(decided|decision|adr|we chose|approved|rejected)\b/.test(lower)) return "decision";
|
|
4521
|
+
if (/\b(goal|need to|we need|want to|trying to|objective)\b/.test(lower)) return "goal_signal";
|
|
4522
|
+
if (["Bash", "Read", "Edit", "Write", "Grep", "Glob"].includes(row.tool_name)) return "tool_action";
|
|
4523
|
+
if (row.tool_name.startsWith("memory_card")) return "memory_card";
|
|
4524
|
+
return "memory_observation";
|
|
4525
|
+
}
|
|
4526
|
+
function inferIntention(row) {
|
|
4527
|
+
if (row.intent) return clean(row.intent, 220);
|
|
4528
|
+
const text = clean(row.raw_text, 1e3);
|
|
4529
|
+
const patterns = [
|
|
4530
|
+
/(?: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,
|
|
4531
|
+
/(?:so that|in order to)\s+([^.!?\n]{8,220})/i,
|
|
4532
|
+
/(?:task|plan):\s*([^.!?\n]{8,220})/i
|
|
4533
|
+
];
|
|
4534
|
+
for (const p of patterns) {
|
|
4535
|
+
const m = text.match(p);
|
|
4536
|
+
if (m?.[1]) return clean(m[1], 220);
|
|
4537
|
+
}
|
|
4538
|
+
if (["Bash", "Read", "Edit", "Write", "Grep", "Glob"].includes(row.tool_name)) {
|
|
4539
|
+
return `${row.tool_name} during ${row.project_name}`;
|
|
4540
|
+
}
|
|
4541
|
+
return null;
|
|
4542
|
+
}
|
|
4543
|
+
function inferOutcome(row) {
|
|
4544
|
+
if (row.outcome) return clean(row.outcome, 220);
|
|
4545
|
+
if (row.has_error) return "error";
|
|
4546
|
+
const lower = row.raw_text.toLowerCase();
|
|
4547
|
+
if (/\b(done|complete|completed|fixed|resolved|shipped|deployed|pushed|published|passed)\b/.test(lower)) return "success_signal";
|
|
4548
|
+
if (/\b(blocked|failed|error|regression|broken|not working|could not)\b/.test(lower)) return "failure_signal";
|
|
4549
|
+
if (/\b(warning|risk|concern|caveat)\b/.test(lower)) return "risk_signal";
|
|
4550
|
+
return null;
|
|
4551
|
+
}
|
|
4552
|
+
function extractGoalCandidates(row) {
|
|
4553
|
+
const text = clean(row.raw_text, 1600);
|
|
4554
|
+
const patterns = [
|
|
4555
|
+
/(?: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,
|
|
4556
|
+
/(?:success means|success criteria|so that)\s+([^.!?\n]{12,220})/gi
|
|
4557
|
+
];
|
|
4558
|
+
const out = [];
|
|
4559
|
+
for (const pattern of patterns) {
|
|
4560
|
+
for (const m of text.matchAll(pattern)) {
|
|
4561
|
+
const candidate = clean(m[1] ?? "", 220);
|
|
4562
|
+
if (candidate.length >= 12 && !out.some((x) => x.toLowerCase() === candidate.toLowerCase())) out.push(candidate);
|
|
4563
|
+
if (out.length >= 3) return out;
|
|
4564
|
+
}
|
|
4565
|
+
}
|
|
4566
|
+
return out;
|
|
4567
|
+
}
|
|
4568
|
+
function uniq(values, max = 6) {
|
|
4569
|
+
const out = [];
|
|
4570
|
+
for (const value of values.map((v) => clean(v, 220)).filter(Boolean)) {
|
|
4571
|
+
if (!out.some((x) => x.toLowerCase() === value.toLowerCase())) out.push(value);
|
|
4572
|
+
if (out.length >= max) break;
|
|
4573
|
+
}
|
|
4574
|
+
return out;
|
|
4575
|
+
}
|
|
4576
|
+
function extractMatches(text, patterns, max = 5) {
|
|
4577
|
+
const out = [];
|
|
4578
|
+
for (const pattern of patterns) {
|
|
4579
|
+
for (const match of text.matchAll(pattern)) {
|
|
4580
|
+
const value = match[1] ?? match[0];
|
|
4581
|
+
if (value) out.push(value);
|
|
4582
|
+
if (out.length >= max) return uniq(out, max);
|
|
4583
|
+
}
|
|
4584
|
+
}
|
|
4585
|
+
return uniq(out, max);
|
|
4586
|
+
}
|
|
4587
|
+
function inferSemanticLabel(row) {
|
|
4588
|
+
const text = clean(row.raw_text, 2400);
|
|
4589
|
+
const eventType = inferOntologyEventType(row);
|
|
4590
|
+
const intention = inferIntention(row);
|
|
4591
|
+
const outcome = inferOutcome(row);
|
|
4592
|
+
const goals = extractGoalCandidates(row);
|
|
4593
|
+
const milestones = extractMatches(text, [
|
|
4594
|
+
/\b(?:completed|finished|fixed|resolved|shipped|deployed|published|pushed|passed)\b([^.!?\n]{0,180})/gi,
|
|
4595
|
+
/(?:milestone|done):\s*([^.!?\n]{8,220})/gi
|
|
4596
|
+
]);
|
|
4597
|
+
const problems = extractMatches(text, [
|
|
4598
|
+
/\b(?:blocked by|failed because|bug|regression|broken|not working|error)\b([^.!?\n]{0,180})/gi,
|
|
4599
|
+
/(?:problem|issue|risk):\s*([^.!?\n]{8,220})/gi
|
|
4600
|
+
]);
|
|
4601
|
+
const decisions = extractMatches(text, [
|
|
4602
|
+
/(?:decided|decision|adr|we chose|approved|rejected)\s+([^.!?\n]{8,220})/gi
|
|
4603
|
+
]);
|
|
4604
|
+
const temporalAnchors = extractMatches(text, [
|
|
4605
|
+
/\b(\d{4}-\d{2}-\d{2}(?:[T ][0-9:.+-Z]+)?)\b/g,
|
|
4606
|
+
/\b(today|yesterday|tomorrow|this week|next week|last week|morning|afternoon|tonight)\b/gi
|
|
4607
|
+
], 8);
|
|
4608
|
+
const nextActions = extractMatches(text, [
|
|
4609
|
+
/(?:next|todo|follow[- ]?up|remaining|need to)\s*:?\s*([^.!?\n]{8,220})/gi
|
|
4610
|
+
]);
|
|
4611
|
+
const actors = uniq([
|
|
4612
|
+
row.agent_id,
|
|
4613
|
+
...extractMatches(text, [/\b(?:agent|employee|owner|assignee)[:= ]+([a-zA-Z][a-zA-Z0-9_-]{1,40})/gi], 5)
|
|
4614
|
+
], 6);
|
|
4615
|
+
const successSignals = milestones.length ? milestones : outcome === "success_signal" ? [clean(text, 180)] : [];
|
|
4616
|
+
const failureSignals = problems.length ? problems : outcome === "failure_signal" || row.has_error ? [clean(text, 180)] : [];
|
|
4617
|
+
const impact = successSignals.length && failureSignals.length ? "mixed" : failureSignals.length ? "negative" : successSignals.length ? "positive" : "neutral";
|
|
4618
|
+
const signalCount = goals.length + milestones.length + problems.length + decisions.length + nextActions.length;
|
|
4619
|
+
return {
|
|
4620
|
+
labeler: "deterministic",
|
|
4621
|
+
schemaVersion: 1,
|
|
4622
|
+
eventType,
|
|
4623
|
+
intention,
|
|
4624
|
+
outcome,
|
|
4625
|
+
impact,
|
|
4626
|
+
confidence: Math.min(0.95, 0.45 + signalCount * 0.08 + (intention ? 0.1 : 0) + (outcome ? 0.1 : 0)),
|
|
4627
|
+
goals,
|
|
4628
|
+
milestones,
|
|
4629
|
+
problems,
|
|
4630
|
+
decisions,
|
|
4631
|
+
actors,
|
|
4632
|
+
temporalAnchors,
|
|
4633
|
+
successSignals,
|
|
4634
|
+
failureSignals,
|
|
4635
|
+
nextActions,
|
|
4636
|
+
summary: clean(text, 280)
|
|
4637
|
+
};
|
|
4638
|
+
}
|
|
4639
|
+
function ontologyPayload(row) {
|
|
4640
|
+
const semantic = inferSemanticLabel(row);
|
|
4641
|
+
return {
|
|
4642
|
+
tool_name: row.tool_name,
|
|
4643
|
+
memory_version: row.version ?? null,
|
|
4644
|
+
domain: row.domain ?? null,
|
|
4645
|
+
trajectory: row.trajectory ? safeJson(row.trajectory) : null,
|
|
4646
|
+
semantic
|
|
4647
|
+
};
|
|
4648
|
+
}
|
|
4649
|
+
function safeJson(value) {
|
|
4650
|
+
try {
|
|
4651
|
+
return JSON.parse(value);
|
|
4652
|
+
} catch {
|
|
4653
|
+
return value.slice(0, 1e3);
|
|
4654
|
+
}
|
|
4655
|
+
}
|
|
4656
|
+
async function resolveClient(client) {
|
|
4657
|
+
if (client) return client;
|
|
4658
|
+
const { getClient: getClient2 } = await Promise.resolve().then(() => (init_database(), database_exports));
|
|
4659
|
+
return getClient2();
|
|
4660
|
+
}
|
|
4661
|
+
async function insertOntologyForMemory(row, client) {
|
|
4662
|
+
const db = await resolveClient(client);
|
|
4663
|
+
const occurredAt = row.timestamp;
|
|
4664
|
+
const sequence = Number(row.version ?? 0) || Math.floor(new Date(occurredAt).getTime() / 1e3);
|
|
4665
|
+
const eventType = inferOntologyEventType(row);
|
|
4666
|
+
const intention = inferIntention(row);
|
|
4667
|
+
const outcome = inferOutcome(row);
|
|
4668
|
+
const eventId = stableId2("event", row.id);
|
|
4669
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
4670
|
+
await db.execute({
|
|
4671
|
+
sql: `INSERT INTO agent_sessions (id, agent_id, project_name, started_at, last_event_at, event_count, properties)
|
|
4672
|
+
VALUES (?, ?, ?, ?, ?, 1, ?)
|
|
4673
|
+
ON CONFLICT(id) DO UPDATE SET last_event_at = MAX(last_event_at, excluded.last_event_at),
|
|
4674
|
+
event_count = event_count + 1`,
|
|
4675
|
+
args: [row.session_id, row.agent_id, row.project_name, occurredAt, occurredAt, JSON.stringify({ agent_role: row.agent_role })]
|
|
4676
|
+
});
|
|
4677
|
+
await db.execute({
|
|
4678
|
+
sql: `INSERT OR IGNORE INTO agent_events
|
|
4679
|
+
(id, event_type, occurred_at, sequence_index, actor_agent_id, agent_role, project_name,
|
|
4680
|
+
session_id, task_id, goal_id, parent_event_id, intention, outcome, evidence_memory_id,
|
|
4681
|
+
impact, payload, created_at)
|
|
4682
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NULL, NULL, ?, ?, ?, ?, ?, ?)`,
|
|
4683
|
+
args: [
|
|
4684
|
+
eventId,
|
|
4685
|
+
eventType,
|
|
4686
|
+
occurredAt,
|
|
4687
|
+
sequence,
|
|
4688
|
+
row.agent_id,
|
|
4689
|
+
row.agent_role,
|
|
4690
|
+
row.project_name,
|
|
4691
|
+
row.session_id,
|
|
4692
|
+
row.task_id ?? null,
|
|
4693
|
+
intention,
|
|
4694
|
+
outcome,
|
|
4695
|
+
row.id,
|
|
4696
|
+
row.has_error ? "negative" : outcome === "success_signal" ? "positive" : "neutral",
|
|
4697
|
+
JSON.stringify(ontologyPayload(row)),
|
|
4698
|
+
now
|
|
4699
|
+
]
|
|
4700
|
+
});
|
|
4701
|
+
const semantic = inferSemanticLabel(row);
|
|
4702
|
+
await db.execute({
|
|
4703
|
+
sql: `INSERT INTO agent_semantic_labels
|
|
4704
|
+
(id, source_memory_id, event_id, labeler, schema_version, confidence, labels, created_at, updated_at)
|
|
4705
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
4706
|
+
ON CONFLICT(id) DO UPDATE SET confidence = excluded.confidence,
|
|
4707
|
+
labels = excluded.labels, updated_at = excluded.updated_at`,
|
|
4708
|
+
args: [
|
|
4709
|
+
stableId2("semantic", row.id, semantic.labeler, semantic.schemaVersion),
|
|
4710
|
+
row.id,
|
|
4711
|
+
eventId,
|
|
4712
|
+
semantic.labeler,
|
|
4713
|
+
semantic.schemaVersion,
|
|
4714
|
+
semantic.confidence,
|
|
4715
|
+
JSON.stringify(semantic),
|
|
4716
|
+
now,
|
|
4717
|
+
now
|
|
4718
|
+
]
|
|
4719
|
+
});
|
|
4720
|
+
for (const statement of extractGoalCandidates(row)) {
|
|
4721
|
+
const goalId = stableId2("goal", row.project_name, statement.toLowerCase());
|
|
4722
|
+
await db.execute({
|
|
4723
|
+
sql: `INSERT INTO agent_goals
|
|
4724
|
+
(id, statement, owner_agent_id, project_name, status, priority, success_criteria,
|
|
4725
|
+
parent_goal_id, due_at, achieved_at, supersedes_id, created_at, updated_at, source_memory_id)
|
|
4726
|
+
VALUES (?, ?, ?, ?, 'open', 5, NULL, NULL, NULL, NULL, NULL, ?, ?, ?)
|
|
4727
|
+
ON CONFLICT(id) DO UPDATE SET updated_at = excluded.updated_at`,
|
|
4728
|
+
args: [goalId, statement, row.agent_id, row.project_name, now, now, row.id]
|
|
4729
|
+
});
|
|
4730
|
+
await db.execute({
|
|
4731
|
+
sql: `INSERT OR IGNORE INTO agent_goal_links
|
|
4732
|
+
(id, goal_id, link_type, target_id, target_type, created_at)
|
|
4733
|
+
VALUES (?, ?, 'evidence', ?, 'memory', ?)`,
|
|
4734
|
+
args: [stableId2("goal_link", goalId, row.id, "memory"), goalId, row.id, now]
|
|
4735
|
+
});
|
|
4736
|
+
await db.execute({
|
|
4737
|
+
sql: `INSERT OR IGNORE INTO agent_goal_links
|
|
4738
|
+
(id, goal_id, link_type, target_id, target_type, created_at)
|
|
4739
|
+
VALUES (?, ?, 'event', ?, 'event', ?)`,
|
|
4740
|
+
args: [stableId2("goal_link", goalId, eventId, "event"), goalId, eventId, now]
|
|
4741
|
+
});
|
|
4742
|
+
}
|
|
4743
|
+
}
|
|
4744
|
+
async function insertOntologyForBatch(rows, client) {
|
|
4745
|
+
const db = await resolveClient(client);
|
|
4746
|
+
let count = 0;
|
|
4747
|
+
for (const row of rows) {
|
|
4748
|
+
try {
|
|
4749
|
+
await insertOntologyForMemory(row, db);
|
|
4750
|
+
count++;
|
|
4751
|
+
} catch {
|
|
4752
|
+
}
|
|
4753
|
+
}
|
|
4754
|
+
return count;
|
|
4755
|
+
}
|
|
4756
|
+
var init_agentic_ontology = __esm({
|
|
4757
|
+
"src/lib/agentic-ontology.ts"() {
|
|
4758
|
+
"use strict";
|
|
4759
|
+
}
|
|
4760
|
+
});
|
|
4761
|
+
|
|
4249
4762
|
// src/lib/store.ts
|
|
4250
4763
|
var store_exports = {};
|
|
4251
4764
|
__export(store_exports, {
|
|
@@ -4589,6 +5102,11 @@ async function flushBatch() {
|
|
|
4589
5102
|
await insertMemoryCardsForBatch2(batch);
|
|
4590
5103
|
} catch {
|
|
4591
5104
|
}
|
|
5105
|
+
try {
|
|
5106
|
+
const { insertOntologyForBatch: insertOntologyForBatch2 } = await Promise.resolve().then(() => (init_agentic_ontology(), agentic_ontology_exports));
|
|
5107
|
+
await insertOntologyForBatch2(batch);
|
|
5108
|
+
} catch {
|
|
5109
|
+
}
|
|
4592
5110
|
schedulePostWriteMemoryHygiene(batch.map((row) => row.id));
|
|
4593
5111
|
_pendingRecords.splice(0, batch.length);
|
|
4594
5112
|
try {
|