@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
|
@@ -138,6 +138,11 @@ function normalizeAutoUpdate(raw) {
|
|
|
138
138
|
const userAU = raw.autoUpdate ?? {};
|
|
139
139
|
raw.autoUpdate = { ...defaultAU, ...userAU };
|
|
140
140
|
}
|
|
141
|
+
function normalizeOrchestration(raw) {
|
|
142
|
+
const defaultOrg = DEFAULT_CONFIG.orchestration;
|
|
143
|
+
const userOrg = raw.orchestration ?? {};
|
|
144
|
+
raw.orchestration = { ...defaultOrg, ...userOrg };
|
|
145
|
+
}
|
|
141
146
|
async function loadConfig() {
|
|
142
147
|
const dir = process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? EXE_AI_DIR;
|
|
143
148
|
await ensurePrivateDir(dir);
|
|
@@ -162,10 +167,15 @@ async function loadConfig() {
|
|
|
162
167
|
normalizeScalingRoadmap(migratedCfg);
|
|
163
168
|
normalizeSessionLifecycle(migratedCfg);
|
|
164
169
|
normalizeAutoUpdate(migratedCfg);
|
|
170
|
+
normalizeOrchestration(migratedCfg);
|
|
165
171
|
const config = { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db"), ...migratedCfg };
|
|
166
172
|
if (config.dbPath.startsWith("~")) {
|
|
167
173
|
config.dbPath = config.dbPath.replace(/^~/, os.homedir());
|
|
168
174
|
}
|
|
175
|
+
const envDbPath = path.join(dir, "memories.db");
|
|
176
|
+
if (process.env.EXE_OS_DIR && config.dbPath !== envDbPath && !existsSync2(config.dbPath) && existsSync2(envDbPath)) {
|
|
177
|
+
config.dbPath = envDbPath;
|
|
178
|
+
}
|
|
169
179
|
return config;
|
|
170
180
|
} catch {
|
|
171
181
|
return { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db") };
|
|
@@ -185,7 +195,16 @@ function loadConfigSync() {
|
|
|
185
195
|
normalizeScalingRoadmap(migratedCfg);
|
|
186
196
|
normalizeSessionLifecycle(migratedCfg);
|
|
187
197
|
normalizeAutoUpdate(migratedCfg);
|
|
188
|
-
|
|
198
|
+
normalizeOrchestration(migratedCfg);
|
|
199
|
+
const config = { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db"), ...migratedCfg };
|
|
200
|
+
if (config.dbPath.startsWith("~")) {
|
|
201
|
+
config.dbPath = config.dbPath.replace(/^~/, os.homedir());
|
|
202
|
+
}
|
|
203
|
+
const envDbPath = path.join(dir, "memories.db");
|
|
204
|
+
if (process.env.EXE_OS_DIR && config.dbPath !== envDbPath && !existsSync2(config.dbPath) && existsSync2(envDbPath)) {
|
|
205
|
+
config.dbPath = envDbPath;
|
|
206
|
+
}
|
|
207
|
+
return config;
|
|
189
208
|
} catch {
|
|
190
209
|
return { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db") };
|
|
191
210
|
}
|
|
@@ -206,6 +225,7 @@ async function loadConfigFrom(configPath) {
|
|
|
206
225
|
normalizeScalingRoadmap(migratedCfg);
|
|
207
226
|
normalizeSessionLifecycle(migratedCfg);
|
|
208
227
|
normalizeAutoUpdate(migratedCfg);
|
|
228
|
+
normalizeOrchestration(migratedCfg);
|
|
209
229
|
return { ...DEFAULT_CONFIG, ...migratedCfg };
|
|
210
230
|
} catch {
|
|
211
231
|
return { ...DEFAULT_CONFIG };
|
|
@@ -277,6 +297,10 @@ var init_config = __esm({
|
|
|
277
297
|
checkOnBoot: true,
|
|
278
298
|
autoInstall: false,
|
|
279
299
|
checkIntervalMs: 24 * 60 * 60 * 1e3
|
|
300
|
+
},
|
|
301
|
+
orchestration: {
|
|
302
|
+
phase: "phase_1_coo",
|
|
303
|
+
phaseSetBy: "default"
|
|
280
304
|
}
|
|
281
305
|
};
|
|
282
306
|
CONFIG_MIGRATIONS = [
|
|
@@ -1900,6 +1924,9 @@ function getClient() {
|
|
|
1900
1924
|
if (_daemonClient && _daemonClient._isDaemonActive()) {
|
|
1901
1925
|
return _daemonClient;
|
|
1902
1926
|
}
|
|
1927
|
+
if (!_resilientClient) {
|
|
1928
|
+
return _adapterClient;
|
|
1929
|
+
}
|
|
1903
1930
|
return _resilientClient;
|
|
1904
1931
|
}
|
|
1905
1932
|
async function initDaemonClient() {
|
|
@@ -2932,6 +2959,127 @@ async function ensureSchema() {
|
|
|
2932
2959
|
VALUES (new.rowid, new.content, new.subject, new.predicate, new.object);
|
|
2933
2960
|
END;
|
|
2934
2961
|
`);
|
|
2962
|
+
await client.executeMultiple(`
|
|
2963
|
+
CREATE TABLE IF NOT EXISTS agent_sessions (
|
|
2964
|
+
id TEXT PRIMARY KEY,
|
|
2965
|
+
agent_id TEXT NOT NULL,
|
|
2966
|
+
project_name TEXT,
|
|
2967
|
+
started_at TEXT NOT NULL,
|
|
2968
|
+
last_event_at TEXT NOT NULL,
|
|
2969
|
+
event_count INTEGER NOT NULL DEFAULT 0,
|
|
2970
|
+
properties TEXT DEFAULT '{}'
|
|
2971
|
+
);
|
|
2972
|
+
|
|
2973
|
+
CREATE INDEX IF NOT EXISTS idx_agent_sessions_agent_time
|
|
2974
|
+
ON agent_sessions(agent_id, started_at);
|
|
2975
|
+
|
|
2976
|
+
CREATE TABLE IF NOT EXISTS agent_goals (
|
|
2977
|
+
id TEXT PRIMARY KEY,
|
|
2978
|
+
statement TEXT NOT NULL,
|
|
2979
|
+
owner_agent_id TEXT,
|
|
2980
|
+
project_name TEXT,
|
|
2981
|
+
status TEXT NOT NULL DEFAULT 'open',
|
|
2982
|
+
priority INTEGER NOT NULL DEFAULT 5,
|
|
2983
|
+
success_criteria TEXT,
|
|
2984
|
+
parent_goal_id TEXT,
|
|
2985
|
+
due_at TEXT,
|
|
2986
|
+
achieved_at TEXT,
|
|
2987
|
+
supersedes_id TEXT,
|
|
2988
|
+
created_at TEXT NOT NULL,
|
|
2989
|
+
updated_at TEXT NOT NULL,
|
|
2990
|
+
source_memory_id TEXT
|
|
2991
|
+
);
|
|
2992
|
+
|
|
2993
|
+
CREATE INDEX IF NOT EXISTS idx_agent_goals_project_status
|
|
2994
|
+
ON agent_goals(project_name, status, priority);
|
|
2995
|
+
|
|
2996
|
+
CREATE TABLE IF NOT EXISTS agent_events (
|
|
2997
|
+
id TEXT PRIMARY KEY,
|
|
2998
|
+
event_type TEXT NOT NULL,
|
|
2999
|
+
occurred_at TEXT NOT NULL,
|
|
3000
|
+
sequence_index INTEGER NOT NULL,
|
|
3001
|
+
actor_agent_id TEXT,
|
|
3002
|
+
agent_role TEXT,
|
|
3003
|
+
project_name TEXT,
|
|
3004
|
+
session_id TEXT,
|
|
3005
|
+
task_id TEXT,
|
|
3006
|
+
goal_id TEXT,
|
|
3007
|
+
parent_event_id TEXT,
|
|
3008
|
+
intention TEXT,
|
|
3009
|
+
outcome TEXT,
|
|
3010
|
+
evidence_memory_id TEXT,
|
|
3011
|
+
impact TEXT,
|
|
3012
|
+
payload TEXT DEFAULT '{}',
|
|
3013
|
+
created_at TEXT NOT NULL
|
|
3014
|
+
);
|
|
3015
|
+
|
|
3016
|
+
CREATE INDEX IF NOT EXISTS idx_agent_events_time
|
|
3017
|
+
ON agent_events(occurred_at, sequence_index);
|
|
3018
|
+
|
|
3019
|
+
CREATE INDEX IF NOT EXISTS idx_agent_events_session_seq
|
|
3020
|
+
ON agent_events(session_id, sequence_index);
|
|
3021
|
+
|
|
3022
|
+
CREATE INDEX IF NOT EXISTS idx_agent_events_goal_time
|
|
3023
|
+
ON agent_events(goal_id, occurred_at);
|
|
3024
|
+
|
|
3025
|
+
CREATE INDEX IF NOT EXISTS idx_agent_events_memory
|
|
3026
|
+
ON agent_events(evidence_memory_id);
|
|
3027
|
+
|
|
3028
|
+
CREATE TABLE IF NOT EXISTS agent_goal_links (
|
|
3029
|
+
id TEXT PRIMARY KEY,
|
|
3030
|
+
goal_id TEXT NOT NULL,
|
|
3031
|
+
link_type TEXT NOT NULL,
|
|
3032
|
+
target_id TEXT NOT NULL,
|
|
3033
|
+
target_type TEXT NOT NULL,
|
|
3034
|
+
created_at TEXT NOT NULL
|
|
3035
|
+
);
|
|
3036
|
+
|
|
3037
|
+
CREATE INDEX IF NOT EXISTS idx_agent_goal_links_goal
|
|
3038
|
+
ON agent_goal_links(goal_id, target_type);
|
|
3039
|
+
|
|
3040
|
+
CREATE TABLE IF NOT EXISTS agent_semantic_labels (
|
|
3041
|
+
id TEXT PRIMARY KEY,
|
|
3042
|
+
source_memory_id TEXT NOT NULL,
|
|
3043
|
+
event_id TEXT,
|
|
3044
|
+
labeler TEXT NOT NULL,
|
|
3045
|
+
schema_version INTEGER NOT NULL DEFAULT 1,
|
|
3046
|
+
confidence REAL NOT NULL DEFAULT 0,
|
|
3047
|
+
labels TEXT NOT NULL,
|
|
3048
|
+
created_at TEXT NOT NULL,
|
|
3049
|
+
updated_at TEXT NOT NULL
|
|
3050
|
+
);
|
|
3051
|
+
|
|
3052
|
+
CREATE INDEX IF NOT EXISTS idx_agent_semantic_labels_memory
|
|
3053
|
+
ON agent_semantic_labels(source_memory_id, labeler);
|
|
3054
|
+
|
|
3055
|
+
CREATE INDEX IF NOT EXISTS idx_agent_semantic_labels_event
|
|
3056
|
+
ON agent_semantic_labels(event_id);
|
|
3057
|
+
|
|
3058
|
+
CREATE TABLE IF NOT EXISTS agent_reflection_checkpoints (
|
|
3059
|
+
id TEXT PRIMARY KEY,
|
|
3060
|
+
project_name TEXT,
|
|
3061
|
+
session_id TEXT,
|
|
3062
|
+
window_start_at TEXT NOT NULL,
|
|
3063
|
+
window_end_at TEXT NOT NULL,
|
|
3064
|
+
event_count INTEGER NOT NULL DEFAULT 0,
|
|
3065
|
+
goal_count INTEGER NOT NULL DEFAULT 0,
|
|
3066
|
+
success_count INTEGER NOT NULL DEFAULT 0,
|
|
3067
|
+
failure_count INTEGER NOT NULL DEFAULT 0,
|
|
3068
|
+
risk_count INTEGER NOT NULL DEFAULT 0,
|
|
3069
|
+
summary TEXT NOT NULL,
|
|
3070
|
+
learnings TEXT NOT NULL DEFAULT '[]',
|
|
3071
|
+
next_actions TEXT NOT NULL DEFAULT '[]',
|
|
3072
|
+
evidence_event_ids TEXT NOT NULL DEFAULT '[]',
|
|
3073
|
+
confidence REAL NOT NULL DEFAULT 0,
|
|
3074
|
+
created_at TEXT NOT NULL
|
|
3075
|
+
);
|
|
3076
|
+
|
|
3077
|
+
CREATE INDEX IF NOT EXISTS idx_agent_reflection_project_time
|
|
3078
|
+
ON agent_reflection_checkpoints(project_name, window_end_at);
|
|
3079
|
+
|
|
3080
|
+
CREATE INDEX IF NOT EXISTS idx_agent_reflection_session_time
|
|
3081
|
+
ON agent_reflection_checkpoints(session_id, window_end_at);
|
|
3082
|
+
`);
|
|
2935
3083
|
try {
|
|
2936
3084
|
await client.execute({
|
|
2937
3085
|
sql: `ALTER TABLE memories ADD COLUMN tier INTEGER DEFAULT 3`,
|
|
@@ -3081,7 +3229,7 @@ var init_database = __esm({
|
|
|
3081
3229
|
|
|
3082
3230
|
// src/lib/keychain.ts
|
|
3083
3231
|
import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2 } from "fs/promises";
|
|
3084
|
-
import { existsSync as existsSync6 } from "fs";
|
|
3232
|
+
import { existsSync as existsSync6, statSync as statSync2 } from "fs";
|
|
3085
3233
|
import { execSync as execSync2 } from "child_process";
|
|
3086
3234
|
import path6 from "path";
|
|
3087
3235
|
import os5 from "os";
|
|
@@ -3091,29 +3239,65 @@ function getKeyDir() {
|
|
|
3091
3239
|
function getKeyPath() {
|
|
3092
3240
|
return path6.join(getKeyDir(), "master.key");
|
|
3093
3241
|
}
|
|
3094
|
-
function
|
|
3242
|
+
function nativeKeychainAllowed() {
|
|
3243
|
+
return process.env.EXE_OS_DISABLE_NATIVE_KEYCHAIN !== "1";
|
|
3244
|
+
}
|
|
3245
|
+
function linuxSecretAvailable() {
|
|
3246
|
+
if (!nativeKeychainAllowed()) return false;
|
|
3247
|
+
if (process.platform !== "linux") return false;
|
|
3248
|
+
if (linuxSecretAvailability !== null) return linuxSecretAvailability;
|
|
3249
|
+
try {
|
|
3250
|
+
execSync2("command -v secret-tool >/dev/null 2>&1", { timeout: 1e3 });
|
|
3251
|
+
} catch {
|
|
3252
|
+
linuxSecretAvailability = false;
|
|
3253
|
+
return false;
|
|
3254
|
+
}
|
|
3255
|
+
try {
|
|
3256
|
+
execSync2("secret-tool search --all exe-os probe >/dev/null 2>&1", { timeout: 1e3 });
|
|
3257
|
+
linuxSecretAvailability = true;
|
|
3258
|
+
} catch {
|
|
3259
|
+
linuxSecretAvailability = false;
|
|
3260
|
+
}
|
|
3261
|
+
return linuxSecretAvailability;
|
|
3262
|
+
}
|
|
3263
|
+
function isRootOnlyTrustedServerKeyFile(keyPath) {
|
|
3264
|
+
if (process.platform !== "linux") return false;
|
|
3265
|
+
try {
|
|
3266
|
+
const uid = typeof os5.userInfo().uid === "number" ? os5.userInfo().uid : -1;
|
|
3267
|
+
const st = statSync2(keyPath);
|
|
3268
|
+
if (!st.isFile() || (st.mode & 63) !== 0) return false;
|
|
3269
|
+
if (uid === 0) return true;
|
|
3270
|
+
const exeOsDir = process.env.EXE_OS_DIR;
|
|
3271
|
+
return Boolean(exeOsDir && path6.resolve(keyPath).startsWith(path6.resolve(exeOsDir) + path6.sep));
|
|
3272
|
+
} catch {
|
|
3273
|
+
return false;
|
|
3274
|
+
}
|
|
3275
|
+
}
|
|
3276
|
+
function macKeychainGet(service = SERVICE) {
|
|
3277
|
+
if (!nativeKeychainAllowed()) return null;
|
|
3095
3278
|
if (process.platform !== "darwin") return null;
|
|
3096
3279
|
try {
|
|
3097
3280
|
return execSync2(
|
|
3098
|
-
`security find-generic-password -s "${
|
|
3281
|
+
`security find-generic-password -s "${service}" -a "${ACCOUNT}" -w 2>/dev/null`,
|
|
3099
3282
|
{ encoding: "utf-8", timeout: 5e3 }
|
|
3100
3283
|
).trim();
|
|
3101
3284
|
} catch {
|
|
3102
3285
|
return null;
|
|
3103
3286
|
}
|
|
3104
3287
|
}
|
|
3105
|
-
function macKeychainSet(value) {
|
|
3288
|
+
function macKeychainSet(value, service = SERVICE) {
|
|
3289
|
+
if (!nativeKeychainAllowed()) return false;
|
|
3106
3290
|
if (process.platform !== "darwin") return false;
|
|
3107
3291
|
try {
|
|
3108
3292
|
try {
|
|
3109
3293
|
execSync2(
|
|
3110
|
-
`security delete-generic-password -s "${
|
|
3294
|
+
`security delete-generic-password -s "${service}" -a "${ACCOUNT}" 2>/dev/null`,
|
|
3111
3295
|
{ timeout: 5e3 }
|
|
3112
3296
|
);
|
|
3113
3297
|
} catch {
|
|
3114
3298
|
}
|
|
3115
3299
|
execSync2(
|
|
3116
|
-
`security add-generic-password -s "${
|
|
3300
|
+
`security add-generic-password -s "${service}" -a "${ACCOUNT}" -w "${value}"`,
|
|
3117
3301
|
{ timeout: 5e3 }
|
|
3118
3302
|
);
|
|
3119
3303
|
return true;
|
|
@@ -3121,22 +3305,48 @@ function macKeychainSet(value) {
|
|
|
3121
3305
|
return false;
|
|
3122
3306
|
}
|
|
3123
3307
|
}
|
|
3124
|
-
function
|
|
3125
|
-
if (
|
|
3308
|
+
function macKeychainDelete(service = SERVICE) {
|
|
3309
|
+
if (!nativeKeychainAllowed()) return false;
|
|
3310
|
+
if (process.platform !== "darwin") return false;
|
|
3311
|
+
try {
|
|
3312
|
+
execSync2(
|
|
3313
|
+
`security delete-generic-password -s "${service}" -a "${ACCOUNT}" 2>/dev/null`,
|
|
3314
|
+
{ timeout: 5e3 }
|
|
3315
|
+
);
|
|
3316
|
+
return true;
|
|
3317
|
+
} catch {
|
|
3318
|
+
return false;
|
|
3319
|
+
}
|
|
3320
|
+
}
|
|
3321
|
+
function linuxSecretGet(service = SERVICE) {
|
|
3322
|
+
if (!linuxSecretAvailable()) return null;
|
|
3126
3323
|
try {
|
|
3127
3324
|
return execSync2(
|
|
3128
|
-
`secret-tool lookup service "${
|
|
3325
|
+
`secret-tool lookup service "${service}" account "${ACCOUNT}" 2>/dev/null`,
|
|
3129
3326
|
{ encoding: "utf-8", timeout: 5e3 }
|
|
3130
3327
|
).trim();
|
|
3131
3328
|
} catch {
|
|
3132
3329
|
return null;
|
|
3133
3330
|
}
|
|
3134
3331
|
}
|
|
3135
|
-
function linuxSecretSet(value) {
|
|
3332
|
+
function linuxSecretSet(value, service = SERVICE) {
|
|
3333
|
+
if (!linuxSecretAvailable()) return false;
|
|
3334
|
+
try {
|
|
3335
|
+
execSync2(
|
|
3336
|
+
`echo -n "${value}" | secret-tool store --label="exe-os master key" service "${service}" account "${ACCOUNT}" 2>/dev/null`,
|
|
3337
|
+
{ timeout: 5e3 }
|
|
3338
|
+
);
|
|
3339
|
+
return true;
|
|
3340
|
+
} catch {
|
|
3341
|
+
return false;
|
|
3342
|
+
}
|
|
3343
|
+
}
|
|
3344
|
+
function linuxSecretDelete(service = SERVICE) {
|
|
3345
|
+
if (!nativeKeychainAllowed()) return false;
|
|
3136
3346
|
if (process.platform !== "linux") return false;
|
|
3137
3347
|
try {
|
|
3138
3348
|
execSync2(
|
|
3139
|
-
`
|
|
3349
|
+
`secret-tool clear service "${service}" account "${ACCOUNT}" 2>/dev/null`,
|
|
3140
3350
|
{ timeout: 5e3 }
|
|
3141
3351
|
);
|
|
3142
3352
|
return true;
|
|
@@ -3145,6 +3355,7 @@ function linuxSecretSet(value) {
|
|
|
3145
3355
|
}
|
|
3146
3356
|
}
|
|
3147
3357
|
async function tryKeytar() {
|
|
3358
|
+
if (!nativeKeychainAllowed()) return null;
|
|
3148
3359
|
try {
|
|
3149
3360
|
return await import("keytar");
|
|
3150
3361
|
} catch {
|
|
@@ -3218,7 +3429,19 @@ async function writeMachineBoundFileFallback(b64) {
|
|
|
3218
3429
|
return "plaintext";
|
|
3219
3430
|
}
|
|
3220
3431
|
async function getMasterKey() {
|
|
3221
|
-
|
|
3432
|
+
let nativeValue = macKeychainGet() ?? linuxSecretGet();
|
|
3433
|
+
if (!nativeValue) {
|
|
3434
|
+
const legacyValue = macKeychainGet(LEGACY_SERVICE) ?? linuxSecretGet(LEGACY_SERVICE);
|
|
3435
|
+
if (legacyValue) {
|
|
3436
|
+
const migrated = macKeychainSet(legacyValue) || linuxSecretSet(legacyValue);
|
|
3437
|
+
if (migrated) {
|
|
3438
|
+
macKeychainDelete(LEGACY_SERVICE);
|
|
3439
|
+
linuxSecretDelete(LEGACY_SERVICE);
|
|
3440
|
+
process.stderr.write("[keychain] Migrated keychain service from exe-mem to exe-os.\n");
|
|
3441
|
+
}
|
|
3442
|
+
nativeValue = legacyValue;
|
|
3443
|
+
}
|
|
3444
|
+
}
|
|
3222
3445
|
if (nativeValue) {
|
|
3223
3446
|
return Buffer.from(nativeValue, "base64");
|
|
3224
3447
|
}
|
|
@@ -3226,12 +3449,17 @@ async function getMasterKey() {
|
|
|
3226
3449
|
if (keytar) {
|
|
3227
3450
|
try {
|
|
3228
3451
|
const keytarValue = await keytar.getPassword(SERVICE, ACCOUNT);
|
|
3229
|
-
|
|
3230
|
-
|
|
3452
|
+
const legacyKeytarValue = keytarValue ?? await keytar.getPassword(LEGACY_SERVICE, ACCOUNT);
|
|
3453
|
+
if (legacyKeytarValue) {
|
|
3454
|
+
const migrated = macKeychainSet(legacyKeytarValue) || linuxSecretSet(legacyKeytarValue);
|
|
3231
3455
|
if (migrated) {
|
|
3232
3456
|
process.stderr.write("[keychain] Migrated key from keytar to native keychain.\n");
|
|
3457
|
+
try {
|
|
3458
|
+
await keytar.deletePassword(LEGACY_SERVICE, ACCOUNT);
|
|
3459
|
+
} catch {
|
|
3460
|
+
}
|
|
3233
3461
|
}
|
|
3234
|
-
return Buffer.from(
|
|
3462
|
+
return Buffer.from(legacyKeytarValue, "base64");
|
|
3235
3463
|
}
|
|
3236
3464
|
} catch {
|
|
3237
3465
|
}
|
|
@@ -3256,7 +3484,7 @@ async function getMasterKey() {
|
|
|
3256
3484
|
const decrypted = decryptWithMachineKey(content, machineKey);
|
|
3257
3485
|
if (!decrypted) {
|
|
3258
3486
|
process.stderr.write(
|
|
3259
|
-
"[keychain] Key decryption failed \u2014 machine may have changed.\n Use your 24-word recovery phrase: exe-os
|
|
3487
|
+
"[keychain] Key decryption failed \u2014 machine may have changed.\n Use your 24-word recovery phrase during setup: exe-os setup\n"
|
|
3260
3488
|
);
|
|
3261
3489
|
return null;
|
|
3262
3490
|
}
|
|
@@ -3265,6 +3493,9 @@ async function getMasterKey() {
|
|
|
3265
3493
|
b64Value = content;
|
|
3266
3494
|
}
|
|
3267
3495
|
const key = Buffer.from(b64Value, "base64");
|
|
3496
|
+
if (!content.startsWith(ENCRYPTED_PREFIX) && isRootOnlyTrustedServerKeyFile(keyPath)) {
|
|
3497
|
+
return key;
|
|
3498
|
+
}
|
|
3268
3499
|
const migrated = macKeychainSet(b64Value) || linuxSecretSet(b64Value);
|
|
3269
3500
|
if (migrated) {
|
|
3270
3501
|
process.stderr.write("[keychain] Migrated key from file to native keychain.\n");
|
|
@@ -3292,12 +3523,14 @@ async function getMasterKey() {
|
|
|
3292
3523
|
return null;
|
|
3293
3524
|
}
|
|
3294
3525
|
}
|
|
3295
|
-
var SERVICE, ACCOUNT, ENCRYPTED_PREFIX;
|
|
3526
|
+
var SERVICE, LEGACY_SERVICE, ACCOUNT, linuxSecretAvailability, ENCRYPTED_PREFIX;
|
|
3296
3527
|
var init_keychain = __esm({
|
|
3297
3528
|
"src/lib/keychain.ts"() {
|
|
3298
3529
|
"use strict";
|
|
3299
|
-
SERVICE = "exe-
|
|
3530
|
+
SERVICE = "exe-os";
|
|
3531
|
+
LEGACY_SERVICE = "exe-mem";
|
|
3300
3532
|
ACCOUNT = "master-key";
|
|
3533
|
+
linuxSecretAvailability = null;
|
|
3301
3534
|
ENCRYPTED_PREFIX = "enc:";
|
|
3302
3535
|
}
|
|
3303
3536
|
});
|
|
@@ -3567,7 +3800,7 @@ __export(shard_manager_exports, {
|
|
|
3567
3800
|
shardExists: () => shardExists
|
|
3568
3801
|
});
|
|
3569
3802
|
import path7 from "path";
|
|
3570
|
-
import { existsSync as existsSync7, mkdirSync as mkdirSync2, readdirSync, renameSync as renameSync3, statSync as
|
|
3803
|
+
import { existsSync as existsSync7, mkdirSync as mkdirSync2, readdirSync, renameSync as renameSync3, statSync as statSync3 } from "fs";
|
|
3571
3804
|
import { createClient as createClient2 } from "@libsql/client";
|
|
3572
3805
|
function initShardManager(encryptionKey) {
|
|
3573
3806
|
_encryptionKey = encryptionKey;
|
|
@@ -3631,7 +3864,7 @@ async function auditShardHealth(options = {}) {
|
|
|
3631
3864
|
const shards = [];
|
|
3632
3865
|
for (const name of names) {
|
|
3633
3866
|
const dbPath = path7.join(SHARDS_DIR, `${name}.db`);
|
|
3634
|
-
const stat =
|
|
3867
|
+
const stat = statSync3(dbPath);
|
|
3635
3868
|
const item = {
|
|
3636
3869
|
name,
|
|
3637
3870
|
path: dbPath,
|
|
@@ -3884,7 +4117,7 @@ async function getReadyShardClient(projectName) {
|
|
|
3884
4117
|
_shardLastAccess.delete(safeName);
|
|
3885
4118
|
const dbPath = path7.join(SHARDS_DIR, `${safeName}.db`);
|
|
3886
4119
|
if (existsSync7(dbPath)) {
|
|
3887
|
-
const stat =
|
|
4120
|
+
const stat = statSync3(dbPath);
|
|
3888
4121
|
const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
3889
4122
|
const archivedPath = path7.join(SHARDS_DIR, `${safeName}.db.broken-${stamp}`);
|
|
3890
4123
|
renameSync3(dbPath, archivedPath);
|
|
@@ -4004,6 +4237,12 @@ var init_platform_procedures = __esm({
|
|
|
4004
4237
|
priority: "p0",
|
|
4005
4238
|
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."
|
|
4006
4239
|
},
|
|
4240
|
+
{
|
|
4241
|
+
title: "Customer orchestration maturity \u2014 recommend, never trap",
|
|
4242
|
+
domain: "workflow",
|
|
4243
|
+
priority: "p1",
|
|
4244
|
+
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."
|
|
4245
|
+
},
|
|
4007
4246
|
{
|
|
4008
4247
|
title: "Single dispatch path \u2014 create_task only",
|
|
4009
4248
|
domain: "workflow",
|
|
@@ -4062,6 +4301,12 @@ var init_platform_procedures = __esm({
|
|
|
4062
4301
|
priority: "p0",
|
|
4063
4302
|
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."
|
|
4064
4303
|
},
|
|
4304
|
+
{
|
|
4305
|
+
title: "Commit discipline \u2014 never leave verified work floating",
|
|
4306
|
+
domain: "workflow",
|
|
4307
|
+
priority: "p1",
|
|
4308
|
+
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."
|
|
4309
|
+
},
|
|
4065
4310
|
{
|
|
4066
4311
|
title: "Desktop and TUI are the same product",
|
|
4067
4312
|
domain: "architecture",
|
|
@@ -4379,6 +4624,274 @@ var init_memory_cards = __esm({
|
|
|
4379
4624
|
}
|
|
4380
4625
|
});
|
|
4381
4626
|
|
|
4627
|
+
// src/lib/agentic-ontology.ts
|
|
4628
|
+
var agentic_ontology_exports = {};
|
|
4629
|
+
__export(agentic_ontology_exports, {
|
|
4630
|
+
clean: () => clean,
|
|
4631
|
+
extractGoalCandidates: () => extractGoalCandidates,
|
|
4632
|
+
inferIntention: () => inferIntention,
|
|
4633
|
+
inferOntologyEventType: () => inferOntologyEventType,
|
|
4634
|
+
inferOutcome: () => inferOutcome,
|
|
4635
|
+
inferSemanticLabel: () => inferSemanticLabel,
|
|
4636
|
+
insertOntologyForBatch: () => insertOntologyForBatch,
|
|
4637
|
+
insertOntologyForMemory: () => insertOntologyForMemory,
|
|
4638
|
+
ontologyPayload: () => ontologyPayload,
|
|
4639
|
+
stableId: () => stableId2
|
|
4640
|
+
});
|
|
4641
|
+
import { createHash as createHash3 } from "crypto";
|
|
4642
|
+
function stableId2(...parts) {
|
|
4643
|
+
return createHash3("sha256").update(parts.map((p) => String(p ?? "")).join("::")).digest("hex").slice(0, 32);
|
|
4644
|
+
}
|
|
4645
|
+
function clean(text, max = 240) {
|
|
4646
|
+
return text.replace(/\u0000/g, "").replace(/```[\s\S]*?```/g, " ").replace(/\s+/g, " ").trim().slice(0, max);
|
|
4647
|
+
}
|
|
4648
|
+
function inferOntologyEventType(row) {
|
|
4649
|
+
const lower = row.raw_text.toLowerCase();
|
|
4650
|
+
if (row.has_error) return "error";
|
|
4651
|
+
if (/\b(done|complete|completed|fixed|resolved|shipped|deployed|pushed|published)\b/.test(lower)) return "milestone";
|
|
4652
|
+
if (/\b(blocked|failed|error|bug|regression|broken)\b/.test(lower)) return "problem";
|
|
4653
|
+
if (/\b(decided|decision|adr|we chose|approved|rejected)\b/.test(lower)) return "decision";
|
|
4654
|
+
if (/\b(goal|need to|we need|want to|trying to|objective)\b/.test(lower)) return "goal_signal";
|
|
4655
|
+
if (["Bash", "Read", "Edit", "Write", "Grep", "Glob"].includes(row.tool_name)) return "tool_action";
|
|
4656
|
+
if (row.tool_name.startsWith("memory_card")) return "memory_card";
|
|
4657
|
+
return "memory_observation";
|
|
4658
|
+
}
|
|
4659
|
+
function inferIntention(row) {
|
|
4660
|
+
if (row.intent) return clean(row.intent, 220);
|
|
4661
|
+
const text = clean(row.raw_text, 1e3);
|
|
4662
|
+
const patterns = [
|
|
4663
|
+
/(?: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,
|
|
4664
|
+
/(?:so that|in order to)\s+([^.!?\n]{8,220})/i,
|
|
4665
|
+
/(?:task|plan):\s*([^.!?\n]{8,220})/i
|
|
4666
|
+
];
|
|
4667
|
+
for (const p of patterns) {
|
|
4668
|
+
const m = text.match(p);
|
|
4669
|
+
if (m?.[1]) return clean(m[1], 220);
|
|
4670
|
+
}
|
|
4671
|
+
if (["Bash", "Read", "Edit", "Write", "Grep", "Glob"].includes(row.tool_name)) {
|
|
4672
|
+
return `${row.tool_name} during ${row.project_name}`;
|
|
4673
|
+
}
|
|
4674
|
+
return null;
|
|
4675
|
+
}
|
|
4676
|
+
function inferOutcome(row) {
|
|
4677
|
+
if (row.outcome) return clean(row.outcome, 220);
|
|
4678
|
+
if (row.has_error) return "error";
|
|
4679
|
+
const lower = row.raw_text.toLowerCase();
|
|
4680
|
+
if (/\b(done|complete|completed|fixed|resolved|shipped|deployed|pushed|published|passed)\b/.test(lower)) return "success_signal";
|
|
4681
|
+
if (/\b(blocked|failed|error|regression|broken|not working|could not)\b/.test(lower)) return "failure_signal";
|
|
4682
|
+
if (/\b(warning|risk|concern|caveat)\b/.test(lower)) return "risk_signal";
|
|
4683
|
+
return null;
|
|
4684
|
+
}
|
|
4685
|
+
function extractGoalCandidates(row) {
|
|
4686
|
+
const text = clean(row.raw_text, 1600);
|
|
4687
|
+
const patterns = [
|
|
4688
|
+
/(?: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,
|
|
4689
|
+
/(?:success means|success criteria|so that)\s+([^.!?\n]{12,220})/gi
|
|
4690
|
+
];
|
|
4691
|
+
const out = [];
|
|
4692
|
+
for (const pattern of patterns) {
|
|
4693
|
+
for (const m of text.matchAll(pattern)) {
|
|
4694
|
+
const candidate = clean(m[1] ?? "", 220);
|
|
4695
|
+
if (candidate.length >= 12 && !out.some((x) => x.toLowerCase() === candidate.toLowerCase())) out.push(candidate);
|
|
4696
|
+
if (out.length >= 3) return out;
|
|
4697
|
+
}
|
|
4698
|
+
}
|
|
4699
|
+
return out;
|
|
4700
|
+
}
|
|
4701
|
+
function uniq(values, max = 6) {
|
|
4702
|
+
const out = [];
|
|
4703
|
+
for (const value of values.map((v) => clean(v, 220)).filter(Boolean)) {
|
|
4704
|
+
if (!out.some((x) => x.toLowerCase() === value.toLowerCase())) out.push(value);
|
|
4705
|
+
if (out.length >= max) break;
|
|
4706
|
+
}
|
|
4707
|
+
return out;
|
|
4708
|
+
}
|
|
4709
|
+
function extractMatches(text, patterns, max = 5) {
|
|
4710
|
+
const out = [];
|
|
4711
|
+
for (const pattern of patterns) {
|
|
4712
|
+
for (const match of text.matchAll(pattern)) {
|
|
4713
|
+
const value = match[1] ?? match[0];
|
|
4714
|
+
if (value) out.push(value);
|
|
4715
|
+
if (out.length >= max) return uniq(out, max);
|
|
4716
|
+
}
|
|
4717
|
+
}
|
|
4718
|
+
return uniq(out, max);
|
|
4719
|
+
}
|
|
4720
|
+
function inferSemanticLabel(row) {
|
|
4721
|
+
const text = clean(row.raw_text, 2400);
|
|
4722
|
+
const eventType = inferOntologyEventType(row);
|
|
4723
|
+
const intention = inferIntention(row);
|
|
4724
|
+
const outcome = inferOutcome(row);
|
|
4725
|
+
const goals = extractGoalCandidates(row);
|
|
4726
|
+
const milestones = extractMatches(text, [
|
|
4727
|
+
/\b(?:completed|finished|fixed|resolved|shipped|deployed|published|pushed|passed)\b([^.!?\n]{0,180})/gi,
|
|
4728
|
+
/(?:milestone|done):\s*([^.!?\n]{8,220})/gi
|
|
4729
|
+
]);
|
|
4730
|
+
const problems = extractMatches(text, [
|
|
4731
|
+
/\b(?:blocked by|failed because|bug|regression|broken|not working|error)\b([^.!?\n]{0,180})/gi,
|
|
4732
|
+
/(?:problem|issue|risk):\s*([^.!?\n]{8,220})/gi
|
|
4733
|
+
]);
|
|
4734
|
+
const decisions = extractMatches(text, [
|
|
4735
|
+
/(?:decided|decision|adr|we chose|approved|rejected)\s+([^.!?\n]{8,220})/gi
|
|
4736
|
+
]);
|
|
4737
|
+
const temporalAnchors = extractMatches(text, [
|
|
4738
|
+
/\b(\d{4}-\d{2}-\d{2}(?:[T ][0-9:.+-Z]+)?)\b/g,
|
|
4739
|
+
/\b(today|yesterday|tomorrow|this week|next week|last week|morning|afternoon|tonight)\b/gi
|
|
4740
|
+
], 8);
|
|
4741
|
+
const nextActions = extractMatches(text, [
|
|
4742
|
+
/(?:next|todo|follow[- ]?up|remaining|need to)\s*:?\s*([^.!?\n]{8,220})/gi
|
|
4743
|
+
]);
|
|
4744
|
+
const actors = uniq([
|
|
4745
|
+
row.agent_id,
|
|
4746
|
+
...extractMatches(text, [/\b(?:agent|employee|owner|assignee)[:= ]+([a-zA-Z][a-zA-Z0-9_-]{1,40})/gi], 5)
|
|
4747
|
+
], 6);
|
|
4748
|
+
const successSignals = milestones.length ? milestones : outcome === "success_signal" ? [clean(text, 180)] : [];
|
|
4749
|
+
const failureSignals = problems.length ? problems : outcome === "failure_signal" || row.has_error ? [clean(text, 180)] : [];
|
|
4750
|
+
const impact = successSignals.length && failureSignals.length ? "mixed" : failureSignals.length ? "negative" : successSignals.length ? "positive" : "neutral";
|
|
4751
|
+
const signalCount = goals.length + milestones.length + problems.length + decisions.length + nextActions.length;
|
|
4752
|
+
return {
|
|
4753
|
+
labeler: "deterministic",
|
|
4754
|
+
schemaVersion: 1,
|
|
4755
|
+
eventType,
|
|
4756
|
+
intention,
|
|
4757
|
+
outcome,
|
|
4758
|
+
impact,
|
|
4759
|
+
confidence: Math.min(0.95, 0.45 + signalCount * 0.08 + (intention ? 0.1 : 0) + (outcome ? 0.1 : 0)),
|
|
4760
|
+
goals,
|
|
4761
|
+
milestones,
|
|
4762
|
+
problems,
|
|
4763
|
+
decisions,
|
|
4764
|
+
actors,
|
|
4765
|
+
temporalAnchors,
|
|
4766
|
+
successSignals,
|
|
4767
|
+
failureSignals,
|
|
4768
|
+
nextActions,
|
|
4769
|
+
summary: clean(text, 280)
|
|
4770
|
+
};
|
|
4771
|
+
}
|
|
4772
|
+
function ontologyPayload(row) {
|
|
4773
|
+
const semantic = inferSemanticLabel(row);
|
|
4774
|
+
return {
|
|
4775
|
+
tool_name: row.tool_name,
|
|
4776
|
+
memory_version: row.version ?? null,
|
|
4777
|
+
domain: row.domain ?? null,
|
|
4778
|
+
trajectory: row.trajectory ? safeJson(row.trajectory) : null,
|
|
4779
|
+
semantic
|
|
4780
|
+
};
|
|
4781
|
+
}
|
|
4782
|
+
function safeJson(value) {
|
|
4783
|
+
try {
|
|
4784
|
+
return JSON.parse(value);
|
|
4785
|
+
} catch {
|
|
4786
|
+
return value.slice(0, 1e3);
|
|
4787
|
+
}
|
|
4788
|
+
}
|
|
4789
|
+
async function resolveClient(client) {
|
|
4790
|
+
if (client) return client;
|
|
4791
|
+
const { getClient: getClient2 } = await Promise.resolve().then(() => (init_database(), database_exports));
|
|
4792
|
+
return getClient2();
|
|
4793
|
+
}
|
|
4794
|
+
async function insertOntologyForMemory(row, client) {
|
|
4795
|
+
const db = await resolveClient(client);
|
|
4796
|
+
const occurredAt = row.timestamp;
|
|
4797
|
+
const sequence = Number(row.version ?? 0) || Math.floor(new Date(occurredAt).getTime() / 1e3);
|
|
4798
|
+
const eventType = inferOntologyEventType(row);
|
|
4799
|
+
const intention = inferIntention(row);
|
|
4800
|
+
const outcome = inferOutcome(row);
|
|
4801
|
+
const eventId = stableId2("event", row.id);
|
|
4802
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
4803
|
+
await db.execute({
|
|
4804
|
+
sql: `INSERT INTO agent_sessions (id, agent_id, project_name, started_at, last_event_at, event_count, properties)
|
|
4805
|
+
VALUES (?, ?, ?, ?, ?, 1, ?)
|
|
4806
|
+
ON CONFLICT(id) DO UPDATE SET last_event_at = MAX(last_event_at, excluded.last_event_at),
|
|
4807
|
+
event_count = event_count + 1`,
|
|
4808
|
+
args: [row.session_id, row.agent_id, row.project_name, occurredAt, occurredAt, JSON.stringify({ agent_role: row.agent_role })]
|
|
4809
|
+
});
|
|
4810
|
+
await db.execute({
|
|
4811
|
+
sql: `INSERT OR IGNORE INTO agent_events
|
|
4812
|
+
(id, event_type, occurred_at, sequence_index, actor_agent_id, agent_role, project_name,
|
|
4813
|
+
session_id, task_id, goal_id, parent_event_id, intention, outcome, evidence_memory_id,
|
|
4814
|
+
impact, payload, created_at)
|
|
4815
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NULL, NULL, ?, ?, ?, ?, ?, ?)`,
|
|
4816
|
+
args: [
|
|
4817
|
+
eventId,
|
|
4818
|
+
eventType,
|
|
4819
|
+
occurredAt,
|
|
4820
|
+
sequence,
|
|
4821
|
+
row.agent_id,
|
|
4822
|
+
row.agent_role,
|
|
4823
|
+
row.project_name,
|
|
4824
|
+
row.session_id,
|
|
4825
|
+
row.task_id ?? null,
|
|
4826
|
+
intention,
|
|
4827
|
+
outcome,
|
|
4828
|
+
row.id,
|
|
4829
|
+
row.has_error ? "negative" : outcome === "success_signal" ? "positive" : "neutral",
|
|
4830
|
+
JSON.stringify(ontologyPayload(row)),
|
|
4831
|
+
now
|
|
4832
|
+
]
|
|
4833
|
+
});
|
|
4834
|
+
const semantic = inferSemanticLabel(row);
|
|
4835
|
+
await db.execute({
|
|
4836
|
+
sql: `INSERT INTO agent_semantic_labels
|
|
4837
|
+
(id, source_memory_id, event_id, labeler, schema_version, confidence, labels, created_at, updated_at)
|
|
4838
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
4839
|
+
ON CONFLICT(id) DO UPDATE SET confidence = excluded.confidence,
|
|
4840
|
+
labels = excluded.labels, updated_at = excluded.updated_at`,
|
|
4841
|
+
args: [
|
|
4842
|
+
stableId2("semantic", row.id, semantic.labeler, semantic.schemaVersion),
|
|
4843
|
+
row.id,
|
|
4844
|
+
eventId,
|
|
4845
|
+
semantic.labeler,
|
|
4846
|
+
semantic.schemaVersion,
|
|
4847
|
+
semantic.confidence,
|
|
4848
|
+
JSON.stringify(semantic),
|
|
4849
|
+
now,
|
|
4850
|
+
now
|
|
4851
|
+
]
|
|
4852
|
+
});
|
|
4853
|
+
for (const statement of extractGoalCandidates(row)) {
|
|
4854
|
+
const goalId = stableId2("goal", row.project_name, statement.toLowerCase());
|
|
4855
|
+
await db.execute({
|
|
4856
|
+
sql: `INSERT INTO agent_goals
|
|
4857
|
+
(id, statement, owner_agent_id, project_name, status, priority, success_criteria,
|
|
4858
|
+
parent_goal_id, due_at, achieved_at, supersedes_id, created_at, updated_at, source_memory_id)
|
|
4859
|
+
VALUES (?, ?, ?, ?, 'open', 5, NULL, NULL, NULL, NULL, NULL, ?, ?, ?)
|
|
4860
|
+
ON CONFLICT(id) DO UPDATE SET updated_at = excluded.updated_at`,
|
|
4861
|
+
args: [goalId, statement, row.agent_id, row.project_name, now, now, row.id]
|
|
4862
|
+
});
|
|
4863
|
+
await db.execute({
|
|
4864
|
+
sql: `INSERT OR IGNORE INTO agent_goal_links
|
|
4865
|
+
(id, goal_id, link_type, target_id, target_type, created_at)
|
|
4866
|
+
VALUES (?, ?, 'evidence', ?, 'memory', ?)`,
|
|
4867
|
+
args: [stableId2("goal_link", goalId, row.id, "memory"), goalId, row.id, now]
|
|
4868
|
+
});
|
|
4869
|
+
await db.execute({
|
|
4870
|
+
sql: `INSERT OR IGNORE INTO agent_goal_links
|
|
4871
|
+
(id, goal_id, link_type, target_id, target_type, created_at)
|
|
4872
|
+
VALUES (?, ?, 'event', ?, 'event', ?)`,
|
|
4873
|
+
args: [stableId2("goal_link", goalId, eventId, "event"), goalId, eventId, now]
|
|
4874
|
+
});
|
|
4875
|
+
}
|
|
4876
|
+
}
|
|
4877
|
+
async function insertOntologyForBatch(rows, client) {
|
|
4878
|
+
const db = await resolveClient(client);
|
|
4879
|
+
let count = 0;
|
|
4880
|
+
for (const row of rows) {
|
|
4881
|
+
try {
|
|
4882
|
+
await insertOntologyForMemory(row, db);
|
|
4883
|
+
count++;
|
|
4884
|
+
} catch {
|
|
4885
|
+
}
|
|
4886
|
+
}
|
|
4887
|
+
return count;
|
|
4888
|
+
}
|
|
4889
|
+
var init_agentic_ontology = __esm({
|
|
4890
|
+
"src/lib/agentic-ontology.ts"() {
|
|
4891
|
+
"use strict";
|
|
4892
|
+
}
|
|
4893
|
+
});
|
|
4894
|
+
|
|
4382
4895
|
// src/lib/store.ts
|
|
4383
4896
|
var store_exports = {};
|
|
4384
4897
|
__export(store_exports, {
|
|
@@ -4722,6 +5235,11 @@ async function flushBatch() {
|
|
|
4722
5235
|
await insertMemoryCardsForBatch2(batch);
|
|
4723
5236
|
} catch {
|
|
4724
5237
|
}
|
|
5238
|
+
try {
|
|
5239
|
+
const { insertOntologyForBatch: insertOntologyForBatch2 } = await Promise.resolve().then(() => (init_agentic_ontology(), agentic_ontology_exports));
|
|
5240
|
+
await insertOntologyForBatch2(batch);
|
|
5241
|
+
} catch {
|
|
5242
|
+
}
|
|
4725
5243
|
schedulePostWriteMemoryHygiene(batch.map((row) => row.id));
|
|
4726
5244
|
_pendingRecords.splice(0, batch.length);
|
|
4727
5245
|
try {
|
|
@@ -5340,7 +5858,7 @@ __export(file_grep_exports, {
|
|
|
5340
5858
|
grepProjectFiles: () => grepProjectFiles
|
|
5341
5859
|
});
|
|
5342
5860
|
import { execSync as execSync4 } from "child_process";
|
|
5343
|
-
import { readFileSync as readFileSync5, readdirSync as readdirSync2, statSync as
|
|
5861
|
+
import { readFileSync as readFileSync5, readdirSync as readdirSync2, statSync as statSync4, existsSync as existsSync9 } from "fs";
|
|
5344
5862
|
import path10 from "path";
|
|
5345
5863
|
import crypto3 from "crypto";
|
|
5346
5864
|
function hasRipgrep() {
|
|
@@ -5457,7 +5975,7 @@ function grepWithNodeFs(pattern, projectRoot, patterns) {
|
|
|
5457
5975
|
for (const filePath of files.slice(0, MAX_FILES)) {
|
|
5458
5976
|
const absPath = path10.join(projectRoot, filePath);
|
|
5459
5977
|
try {
|
|
5460
|
-
const stat =
|
|
5978
|
+
const stat = statSync4(absPath);
|
|
5461
5979
|
if (stat.size > MAX_FILE_SIZE) continue;
|
|
5462
5980
|
const content = readFileSync5(absPath, "utf8");
|
|
5463
5981
|
const lines = content.split("\n");
|
|
@@ -6783,7 +7301,7 @@ var init_hybrid_search = __esm({
|
|
|
6783
7301
|
});
|
|
6784
7302
|
|
|
6785
7303
|
// src/lib/memory-queue.ts
|
|
6786
|
-
import { appendFileSync, readFileSync as readFileSync6, renameSync as renameSync4, unlinkSync as unlinkSync3, existsSync as existsSync10, statSync as
|
|
7304
|
+
import { appendFileSync, readFileSync as readFileSync6, renameSync as renameSync4, unlinkSync as unlinkSync3, existsSync as existsSync10, statSync as statSync5 } from "fs";
|
|
6787
7305
|
import path11 from "path";
|
|
6788
7306
|
function enqueueMemory(entry) {
|
|
6789
7307
|
appendFileSync(QUEUE_PATH, JSON.stringify(entry) + "\n");
|