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