@askexenow/exe-os 0.9.65 → 0.9.67
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/deploy/stack-manifests/v0.9.json +54 -5
- package/dist/bin/age-ontology-load.js +61 -0
- package/dist/bin/agentic-ontology-backfill.js +4708 -0
- package/dist/bin/agentic-reflection-backfill.js +4144 -0
- package/dist/bin/{exe-link.js → agentic-semantic-label.js} +1532 -2173
- package/dist/bin/backfill-conversations.js +528 -20
- package/dist/bin/backfill-responses.js +528 -20
- package/dist/bin/backfill-vectors.js +255 -20
- package/dist/bin/bulk-sync-postgres.js +4876 -0
- package/dist/bin/cleanup-stale-review-tasks.js +529 -21
- package/dist/bin/cli.js +3471 -1491
- package/dist/bin/exe-agent-config.js +4 -0
- package/dist/bin/exe-agent.js +16 -0
- package/dist/bin/exe-assign.js +528 -20
- package/dist/bin/exe-boot.js +492 -54
- package/dist/bin/exe-call.js +16 -0
- package/dist/bin/exe-cloud.js +7415 -518
- package/dist/bin/exe-dispatch.js +540 -22
- package/dist/bin/exe-doctor.js +3404 -1225
- package/dist/bin/exe-export-behaviors.js +542 -24
- package/dist/bin/exe-forget.js +529 -21
- package/dist/bin/exe-gateway.js +595 -25
- package/dist/bin/exe-heartbeat.js +541 -24
- package/dist/bin/exe-kill.js +529 -21
- package/dist/bin/exe-launch-agent.js +2334 -1067
- package/dist/bin/exe-new-employee.js +324 -166
- package/dist/bin/exe-pending-messages.js +529 -21
- package/dist/bin/exe-pending-notifications.js +529 -21
- package/dist/bin/exe-pending-reviews.js +529 -21
- package/dist/bin/exe-rename.js +529 -21
- package/dist/bin/exe-review.js +529 -21
- package/dist/bin/exe-search.js +542 -24
- package/dist/bin/exe-session-cleanup.js +540 -22
- package/dist/bin/exe-settings.js +14 -0
- package/dist/bin/exe-start-codex.js +817 -144
- package/dist/bin/exe-start-opencode.js +776 -80
- package/dist/bin/exe-status.js +529 -21
- package/dist/bin/exe-team.js +529 -21
- package/dist/bin/git-sweep.js +540 -22
- package/dist/bin/graph-backfill.js +580 -21
- package/dist/bin/graph-export.js +529 -21
- package/dist/bin/graph-layer-benchmark.js +109 -0
- package/dist/bin/install.js +420 -289
- package/dist/bin/intercom-check.js +540 -22
- package/dist/bin/postgres-agentic-reflection-backfill.js +187 -0
- package/dist/bin/postgres-agentic-semantic-backfill.js +237 -0
- package/dist/bin/scan-tasks.js +540 -22
- package/dist/bin/setup.js +790 -206
- package/dist/bin/shard-migrate.js +528 -20
- package/dist/bin/update.js +4 -0
- package/dist/gateway/index.js +593 -23
- package/dist/hooks/bug-report-worker.js +651 -64
- package/dist/hooks/codex-stop-task-finalizer.js +540 -22
- package/dist/hooks/commit-complete.js +540 -22
- package/dist/hooks/error-recall.js +542 -24
- package/dist/hooks/exe-heartbeat-hook.js +4 -0
- package/dist/hooks/ingest-worker.js +4 -0
- package/dist/hooks/ingest.js +539 -22
- package/dist/hooks/instructions-loaded.js +529 -21
- package/dist/hooks/notification.js +529 -21
- package/dist/hooks/post-compact.js +529 -21
- package/dist/hooks/post-tool-combined.js +543 -25
- package/dist/hooks/pre-compact.js +772 -127
- package/dist/hooks/pre-tool-use.js +529 -21
- package/dist/hooks/prompt-submit.js +543 -25
- package/dist/hooks/session-end.js +673 -140
- package/dist/hooks/session-start.js +662 -26
- package/dist/hooks/stop.js +540 -23
- package/dist/hooks/subagent-stop.js +529 -21
- package/dist/hooks/summary-worker.js +571 -126
- package/dist/index.js +593 -23
- package/dist/lib/agent-config.js +4 -0
- package/dist/lib/cloud-sync.js +408 -47
- package/dist/lib/config.js +25 -1
- package/dist/lib/consolidation.js +5 -1
- package/dist/lib/database.js +128 -0
- package/dist/lib/db-daemon-client.js +4 -0
- package/dist/lib/db.js +128 -0
- package/dist/lib/device-registry.js +128 -0
- package/dist/lib/embedder.js +25 -1
- package/dist/lib/employee-templates.js +16 -0
- package/dist/lib/employees.js +4 -0
- package/dist/lib/exe-daemon-client.js +4 -0
- package/dist/lib/exe-daemon.js +3158 -930
- package/dist/lib/hybrid-search.js +542 -24
- package/dist/lib/identity.js +7 -0
- package/dist/lib/keychain.js +178 -22
- package/dist/lib/license.js +4 -0
- package/dist/lib/messaging.js +7 -0
- package/dist/lib/reminders.js +7 -0
- package/dist/lib/schedules.js +255 -20
- package/dist/lib/skill-learning.js +28 -1
- package/dist/lib/status-brief.js +39 -0
- package/dist/lib/store.js +528 -20
- package/dist/lib/task-router.js +4 -0
- package/dist/lib/tasks.js +28 -1
- package/dist/lib/tmux-routing.js +28 -1
- package/dist/lib/token-spend.js +7 -0
- package/dist/mcp/server.js +2739 -813
- package/dist/mcp/tools/complete-reminder.js +7 -0
- package/dist/mcp/tools/create-reminder.js +7 -0
- package/dist/mcp/tools/create-task.js +28 -1
- package/dist/mcp/tools/deactivate-behavior.js +7 -0
- package/dist/mcp/tools/list-reminders.js +7 -0
- package/dist/mcp/tools/list-tasks.js +7 -0
- package/dist/mcp/tools/send-message.js +7 -0
- package/dist/mcp/tools/update-task.js +28 -1
- package/dist/runtime/index.js +540 -22
- package/dist/tui/App.js +618 -29
- package/package.json +9 -5
- package/src/commands/exe/cloud.md +11 -8
- package/stack.release.json +3 -3
- package/src/commands/exe/link.md +0 -17
package/dist/bin/graph-export.js
CHANGED
|
@@ -188,6 +188,11 @@ function normalizeAutoUpdate(raw) {
|
|
|
188
188
|
const userAU = raw.autoUpdate ?? {};
|
|
189
189
|
raw.autoUpdate = { ...defaultAU, ...userAU };
|
|
190
190
|
}
|
|
191
|
+
function normalizeOrchestration(raw) {
|
|
192
|
+
const defaultOrg = DEFAULT_CONFIG.orchestration;
|
|
193
|
+
const userOrg = raw.orchestration ?? {};
|
|
194
|
+
raw.orchestration = { ...defaultOrg, ...userOrg };
|
|
195
|
+
}
|
|
191
196
|
async function loadConfig() {
|
|
192
197
|
const dir = process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? EXE_AI_DIR;
|
|
193
198
|
await ensurePrivateDir(dir);
|
|
@@ -212,10 +217,15 @@ async function loadConfig() {
|
|
|
212
217
|
normalizeScalingRoadmap(migratedCfg);
|
|
213
218
|
normalizeSessionLifecycle(migratedCfg);
|
|
214
219
|
normalizeAutoUpdate(migratedCfg);
|
|
220
|
+
normalizeOrchestration(migratedCfg);
|
|
215
221
|
const config = { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db"), ...migratedCfg };
|
|
216
222
|
if (config.dbPath.startsWith("~")) {
|
|
217
223
|
config.dbPath = config.dbPath.replace(/^~/, os.homedir());
|
|
218
224
|
}
|
|
225
|
+
const envDbPath = path.join(dir, "memories.db");
|
|
226
|
+
if (process.env.EXE_OS_DIR && config.dbPath !== envDbPath && !existsSync2(config.dbPath) && existsSync2(envDbPath)) {
|
|
227
|
+
config.dbPath = envDbPath;
|
|
228
|
+
}
|
|
219
229
|
return config;
|
|
220
230
|
} catch {
|
|
221
231
|
return { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db") };
|
|
@@ -287,6 +297,10 @@ var init_config = __esm({
|
|
|
287
297
|
checkOnBoot: true,
|
|
288
298
|
autoInstall: false,
|
|
289
299
|
checkIntervalMs: 24 * 60 * 60 * 1e3
|
|
300
|
+
},
|
|
301
|
+
orchestration: {
|
|
302
|
+
phase: "phase_1_coo",
|
|
303
|
+
phaseSetBy: "default"
|
|
290
304
|
}
|
|
291
305
|
};
|
|
292
306
|
CONFIG_MIGRATIONS = [
|
|
@@ -1734,6 +1748,9 @@ function getClient() {
|
|
|
1734
1748
|
if (_daemonClient && _daemonClient._isDaemonActive()) {
|
|
1735
1749
|
return _daemonClient;
|
|
1736
1750
|
}
|
|
1751
|
+
if (!_resilientClient) {
|
|
1752
|
+
return _adapterClient;
|
|
1753
|
+
}
|
|
1737
1754
|
return _resilientClient;
|
|
1738
1755
|
}
|
|
1739
1756
|
async function initDaemonClient() {
|
|
@@ -2766,6 +2783,127 @@ async function ensureSchema() {
|
|
|
2766
2783
|
VALUES (new.rowid, new.content, new.subject, new.predicate, new.object);
|
|
2767
2784
|
END;
|
|
2768
2785
|
`);
|
|
2786
|
+
await client.executeMultiple(`
|
|
2787
|
+
CREATE TABLE IF NOT EXISTS agent_sessions (
|
|
2788
|
+
id TEXT PRIMARY KEY,
|
|
2789
|
+
agent_id TEXT NOT NULL,
|
|
2790
|
+
project_name TEXT,
|
|
2791
|
+
started_at TEXT NOT NULL,
|
|
2792
|
+
last_event_at TEXT NOT NULL,
|
|
2793
|
+
event_count INTEGER NOT NULL DEFAULT 0,
|
|
2794
|
+
properties TEXT DEFAULT '{}'
|
|
2795
|
+
);
|
|
2796
|
+
|
|
2797
|
+
CREATE INDEX IF NOT EXISTS idx_agent_sessions_agent_time
|
|
2798
|
+
ON agent_sessions(agent_id, started_at);
|
|
2799
|
+
|
|
2800
|
+
CREATE TABLE IF NOT EXISTS agent_goals (
|
|
2801
|
+
id TEXT PRIMARY KEY,
|
|
2802
|
+
statement TEXT NOT NULL,
|
|
2803
|
+
owner_agent_id TEXT,
|
|
2804
|
+
project_name TEXT,
|
|
2805
|
+
status TEXT NOT NULL DEFAULT 'open',
|
|
2806
|
+
priority INTEGER NOT NULL DEFAULT 5,
|
|
2807
|
+
success_criteria TEXT,
|
|
2808
|
+
parent_goal_id TEXT,
|
|
2809
|
+
due_at TEXT,
|
|
2810
|
+
achieved_at TEXT,
|
|
2811
|
+
supersedes_id TEXT,
|
|
2812
|
+
created_at TEXT NOT NULL,
|
|
2813
|
+
updated_at TEXT NOT NULL,
|
|
2814
|
+
source_memory_id TEXT
|
|
2815
|
+
);
|
|
2816
|
+
|
|
2817
|
+
CREATE INDEX IF NOT EXISTS idx_agent_goals_project_status
|
|
2818
|
+
ON agent_goals(project_name, status, priority);
|
|
2819
|
+
|
|
2820
|
+
CREATE TABLE IF NOT EXISTS agent_events (
|
|
2821
|
+
id TEXT PRIMARY KEY,
|
|
2822
|
+
event_type TEXT NOT NULL,
|
|
2823
|
+
occurred_at TEXT NOT NULL,
|
|
2824
|
+
sequence_index INTEGER NOT NULL,
|
|
2825
|
+
actor_agent_id TEXT,
|
|
2826
|
+
agent_role TEXT,
|
|
2827
|
+
project_name TEXT,
|
|
2828
|
+
session_id TEXT,
|
|
2829
|
+
task_id TEXT,
|
|
2830
|
+
goal_id TEXT,
|
|
2831
|
+
parent_event_id TEXT,
|
|
2832
|
+
intention TEXT,
|
|
2833
|
+
outcome TEXT,
|
|
2834
|
+
evidence_memory_id TEXT,
|
|
2835
|
+
impact TEXT,
|
|
2836
|
+
payload TEXT DEFAULT '{}',
|
|
2837
|
+
created_at TEXT NOT NULL
|
|
2838
|
+
);
|
|
2839
|
+
|
|
2840
|
+
CREATE INDEX IF NOT EXISTS idx_agent_events_time
|
|
2841
|
+
ON agent_events(occurred_at, sequence_index);
|
|
2842
|
+
|
|
2843
|
+
CREATE INDEX IF NOT EXISTS idx_agent_events_session_seq
|
|
2844
|
+
ON agent_events(session_id, sequence_index);
|
|
2845
|
+
|
|
2846
|
+
CREATE INDEX IF NOT EXISTS idx_agent_events_goal_time
|
|
2847
|
+
ON agent_events(goal_id, occurred_at);
|
|
2848
|
+
|
|
2849
|
+
CREATE INDEX IF NOT EXISTS idx_agent_events_memory
|
|
2850
|
+
ON agent_events(evidence_memory_id);
|
|
2851
|
+
|
|
2852
|
+
CREATE TABLE IF NOT EXISTS agent_goal_links (
|
|
2853
|
+
id TEXT PRIMARY KEY,
|
|
2854
|
+
goal_id TEXT NOT NULL,
|
|
2855
|
+
link_type TEXT NOT NULL,
|
|
2856
|
+
target_id TEXT NOT NULL,
|
|
2857
|
+
target_type TEXT NOT NULL,
|
|
2858
|
+
created_at TEXT NOT NULL
|
|
2859
|
+
);
|
|
2860
|
+
|
|
2861
|
+
CREATE INDEX IF NOT EXISTS idx_agent_goal_links_goal
|
|
2862
|
+
ON agent_goal_links(goal_id, target_type);
|
|
2863
|
+
|
|
2864
|
+
CREATE TABLE IF NOT EXISTS agent_semantic_labels (
|
|
2865
|
+
id TEXT PRIMARY KEY,
|
|
2866
|
+
source_memory_id TEXT NOT NULL,
|
|
2867
|
+
event_id TEXT,
|
|
2868
|
+
labeler TEXT NOT NULL,
|
|
2869
|
+
schema_version INTEGER NOT NULL DEFAULT 1,
|
|
2870
|
+
confidence REAL NOT NULL DEFAULT 0,
|
|
2871
|
+
labels TEXT NOT NULL,
|
|
2872
|
+
created_at TEXT NOT NULL,
|
|
2873
|
+
updated_at TEXT NOT NULL
|
|
2874
|
+
);
|
|
2875
|
+
|
|
2876
|
+
CREATE INDEX IF NOT EXISTS idx_agent_semantic_labels_memory
|
|
2877
|
+
ON agent_semantic_labels(source_memory_id, labeler);
|
|
2878
|
+
|
|
2879
|
+
CREATE INDEX IF NOT EXISTS idx_agent_semantic_labels_event
|
|
2880
|
+
ON agent_semantic_labels(event_id);
|
|
2881
|
+
|
|
2882
|
+
CREATE TABLE IF NOT EXISTS agent_reflection_checkpoints (
|
|
2883
|
+
id TEXT PRIMARY KEY,
|
|
2884
|
+
project_name TEXT,
|
|
2885
|
+
session_id TEXT,
|
|
2886
|
+
window_start_at TEXT NOT NULL,
|
|
2887
|
+
window_end_at TEXT NOT NULL,
|
|
2888
|
+
event_count INTEGER NOT NULL DEFAULT 0,
|
|
2889
|
+
goal_count INTEGER NOT NULL DEFAULT 0,
|
|
2890
|
+
success_count INTEGER NOT NULL DEFAULT 0,
|
|
2891
|
+
failure_count INTEGER NOT NULL DEFAULT 0,
|
|
2892
|
+
risk_count INTEGER NOT NULL DEFAULT 0,
|
|
2893
|
+
summary TEXT NOT NULL,
|
|
2894
|
+
learnings TEXT NOT NULL DEFAULT '[]',
|
|
2895
|
+
next_actions TEXT NOT NULL DEFAULT '[]',
|
|
2896
|
+
evidence_event_ids TEXT NOT NULL DEFAULT '[]',
|
|
2897
|
+
confidence REAL NOT NULL DEFAULT 0,
|
|
2898
|
+
created_at TEXT NOT NULL
|
|
2899
|
+
);
|
|
2900
|
+
|
|
2901
|
+
CREATE INDEX IF NOT EXISTS idx_agent_reflection_project_time
|
|
2902
|
+
ON agent_reflection_checkpoints(project_name, window_end_at);
|
|
2903
|
+
|
|
2904
|
+
CREATE INDEX IF NOT EXISTS idx_agent_reflection_session_time
|
|
2905
|
+
ON agent_reflection_checkpoints(session_id, window_end_at);
|
|
2906
|
+
`);
|
|
2769
2907
|
try {
|
|
2770
2908
|
await client.execute({
|
|
2771
2909
|
sql: `ALTER TABLE memories ADD COLUMN tier INTEGER DEFAULT 3`,
|
|
@@ -2915,7 +3053,7 @@ var init_database = __esm({
|
|
|
2915
3053
|
|
|
2916
3054
|
// src/lib/keychain.ts
|
|
2917
3055
|
import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2 } from "fs/promises";
|
|
2918
|
-
import { existsSync as existsSync6 } from "fs";
|
|
3056
|
+
import { existsSync as existsSync6, statSync as statSync2 } from "fs";
|
|
2919
3057
|
import { execSync as execSync2 } from "child_process";
|
|
2920
3058
|
import path6 from "path";
|
|
2921
3059
|
import os5 from "os";
|
|
@@ -2925,29 +3063,78 @@ function getKeyDir() {
|
|
|
2925
3063
|
function getKeyPath() {
|
|
2926
3064
|
return path6.join(getKeyDir(), "master.key");
|
|
2927
3065
|
}
|
|
2928
|
-
function
|
|
3066
|
+
function nativeKeychainAllowed() {
|
|
3067
|
+
return process.env.EXE_OS_DISABLE_NATIVE_KEYCHAIN !== "1";
|
|
3068
|
+
}
|
|
3069
|
+
function linuxSecretAvailable() {
|
|
3070
|
+
if (!nativeKeychainAllowed()) return false;
|
|
3071
|
+
if (process.platform !== "linux") return false;
|
|
3072
|
+
if (linuxSecretAvailability !== null) return linuxSecretAvailability;
|
|
3073
|
+
try {
|
|
3074
|
+
execSync2("command -v secret-tool >/dev/null 2>&1", { timeout: 1e3 });
|
|
3075
|
+
} catch {
|
|
3076
|
+
linuxSecretAvailability = false;
|
|
3077
|
+
return false;
|
|
3078
|
+
}
|
|
3079
|
+
try {
|
|
3080
|
+
execSync2("secret-tool search --all exe-os probe >/dev/null 2>&1", { timeout: 1e3 });
|
|
3081
|
+
linuxSecretAvailability = true;
|
|
3082
|
+
} catch {
|
|
3083
|
+
linuxSecretAvailability = false;
|
|
3084
|
+
}
|
|
3085
|
+
return linuxSecretAvailability;
|
|
3086
|
+
}
|
|
3087
|
+
function isRootOnlyTrustedServerKeyFile(keyPath) {
|
|
3088
|
+
if (process.platform !== "linux") return false;
|
|
3089
|
+
try {
|
|
3090
|
+
const uid = typeof os5.userInfo().uid === "number" ? os5.userInfo().uid : -1;
|
|
3091
|
+
const st = statSync2(keyPath);
|
|
3092
|
+
if (!st.isFile() || (st.mode & 63) !== 0) return false;
|
|
3093
|
+
if (uid === 0) return true;
|
|
3094
|
+
const exeOsDir = process.env.EXE_OS_DIR;
|
|
3095
|
+
return Boolean(exeOsDir && path6.resolve(keyPath).startsWith(path6.resolve(exeOsDir) + path6.sep));
|
|
3096
|
+
} catch {
|
|
3097
|
+
return false;
|
|
3098
|
+
}
|
|
3099
|
+
}
|
|
3100
|
+
function macKeychainGet(service = SERVICE) {
|
|
3101
|
+
if (!nativeKeychainAllowed()) return null;
|
|
2929
3102
|
if (process.platform !== "darwin") return null;
|
|
2930
3103
|
try {
|
|
2931
3104
|
return execSync2(
|
|
2932
|
-
`security find-generic-password -s "${
|
|
3105
|
+
`security find-generic-password -s "${service}" -a "${ACCOUNT}" -w 2>/dev/null`,
|
|
2933
3106
|
{ encoding: "utf-8", timeout: 5e3 }
|
|
2934
3107
|
).trim();
|
|
2935
3108
|
} catch {
|
|
2936
3109
|
return null;
|
|
2937
3110
|
}
|
|
2938
3111
|
}
|
|
2939
|
-
function macKeychainSet(value) {
|
|
3112
|
+
function macKeychainSet(value, service = SERVICE) {
|
|
3113
|
+
if (!nativeKeychainAllowed()) return false;
|
|
2940
3114
|
if (process.platform !== "darwin") return false;
|
|
2941
3115
|
try {
|
|
2942
3116
|
try {
|
|
2943
3117
|
execSync2(
|
|
2944
|
-
`security delete-generic-password -s "${
|
|
3118
|
+
`security delete-generic-password -s "${service}" -a "${ACCOUNT}" 2>/dev/null`,
|
|
2945
3119
|
{ timeout: 5e3 }
|
|
2946
3120
|
);
|
|
2947
3121
|
} catch {
|
|
2948
3122
|
}
|
|
2949
3123
|
execSync2(
|
|
2950
|
-
`security add-generic-password -s "${
|
|
3124
|
+
`security add-generic-password -s "${service}" -a "${ACCOUNT}" -w "${value}"`,
|
|
3125
|
+
{ timeout: 5e3 }
|
|
3126
|
+
);
|
|
3127
|
+
return true;
|
|
3128
|
+
} catch {
|
|
3129
|
+
return false;
|
|
3130
|
+
}
|
|
3131
|
+
}
|
|
3132
|
+
function macKeychainDelete(service = SERVICE) {
|
|
3133
|
+
if (!nativeKeychainAllowed()) return false;
|
|
3134
|
+
if (process.platform !== "darwin") return false;
|
|
3135
|
+
try {
|
|
3136
|
+
execSync2(
|
|
3137
|
+
`security delete-generic-password -s "${service}" -a "${ACCOUNT}" 2>/dev/null`,
|
|
2951
3138
|
{ timeout: 5e3 }
|
|
2952
3139
|
);
|
|
2953
3140
|
return true;
|
|
@@ -2955,22 +3142,35 @@ function macKeychainSet(value) {
|
|
|
2955
3142
|
return false;
|
|
2956
3143
|
}
|
|
2957
3144
|
}
|
|
2958
|
-
function linuxSecretGet() {
|
|
2959
|
-
if (
|
|
3145
|
+
function linuxSecretGet(service = SERVICE) {
|
|
3146
|
+
if (!linuxSecretAvailable()) return null;
|
|
2960
3147
|
try {
|
|
2961
3148
|
return execSync2(
|
|
2962
|
-
`secret-tool lookup service "${
|
|
3149
|
+
`secret-tool lookup service "${service}" account "${ACCOUNT}" 2>/dev/null`,
|
|
2963
3150
|
{ encoding: "utf-8", timeout: 5e3 }
|
|
2964
3151
|
).trim();
|
|
2965
3152
|
} catch {
|
|
2966
3153
|
return null;
|
|
2967
3154
|
}
|
|
2968
3155
|
}
|
|
2969
|
-
function linuxSecretSet(value) {
|
|
3156
|
+
function linuxSecretSet(value, service = SERVICE) {
|
|
3157
|
+
if (!linuxSecretAvailable()) return false;
|
|
3158
|
+
try {
|
|
3159
|
+
execSync2(
|
|
3160
|
+
`echo -n "${value}" | secret-tool store --label="exe-os master key" service "${service}" account "${ACCOUNT}" 2>/dev/null`,
|
|
3161
|
+
{ timeout: 5e3 }
|
|
3162
|
+
);
|
|
3163
|
+
return true;
|
|
3164
|
+
} catch {
|
|
3165
|
+
return false;
|
|
3166
|
+
}
|
|
3167
|
+
}
|
|
3168
|
+
function linuxSecretDelete(service = SERVICE) {
|
|
3169
|
+
if (!nativeKeychainAllowed()) return false;
|
|
2970
3170
|
if (process.platform !== "linux") return false;
|
|
2971
3171
|
try {
|
|
2972
3172
|
execSync2(
|
|
2973
|
-
`
|
|
3173
|
+
`secret-tool clear service "${service}" account "${ACCOUNT}" 2>/dev/null`,
|
|
2974
3174
|
{ timeout: 5e3 }
|
|
2975
3175
|
);
|
|
2976
3176
|
return true;
|
|
@@ -2979,6 +3179,7 @@ function linuxSecretSet(value) {
|
|
|
2979
3179
|
}
|
|
2980
3180
|
}
|
|
2981
3181
|
async function tryKeytar() {
|
|
3182
|
+
if (!nativeKeychainAllowed()) return null;
|
|
2982
3183
|
try {
|
|
2983
3184
|
return await import("keytar");
|
|
2984
3185
|
} catch {
|
|
@@ -3052,7 +3253,19 @@ async function writeMachineBoundFileFallback(b64) {
|
|
|
3052
3253
|
return "plaintext";
|
|
3053
3254
|
}
|
|
3054
3255
|
async function getMasterKey() {
|
|
3055
|
-
|
|
3256
|
+
let nativeValue = macKeychainGet() ?? linuxSecretGet();
|
|
3257
|
+
if (!nativeValue) {
|
|
3258
|
+
const legacyValue = macKeychainGet(LEGACY_SERVICE) ?? linuxSecretGet(LEGACY_SERVICE);
|
|
3259
|
+
if (legacyValue) {
|
|
3260
|
+
const migrated = macKeychainSet(legacyValue) || linuxSecretSet(legacyValue);
|
|
3261
|
+
if (migrated) {
|
|
3262
|
+
macKeychainDelete(LEGACY_SERVICE);
|
|
3263
|
+
linuxSecretDelete(LEGACY_SERVICE);
|
|
3264
|
+
process.stderr.write("[keychain] Migrated keychain service from exe-mem to exe-os.\n");
|
|
3265
|
+
}
|
|
3266
|
+
nativeValue = legacyValue;
|
|
3267
|
+
}
|
|
3268
|
+
}
|
|
3056
3269
|
if (nativeValue) {
|
|
3057
3270
|
return Buffer.from(nativeValue, "base64");
|
|
3058
3271
|
}
|
|
@@ -3060,12 +3273,17 @@ async function getMasterKey() {
|
|
|
3060
3273
|
if (keytar) {
|
|
3061
3274
|
try {
|
|
3062
3275
|
const keytarValue = await keytar.getPassword(SERVICE, ACCOUNT);
|
|
3063
|
-
|
|
3064
|
-
|
|
3276
|
+
const legacyKeytarValue = keytarValue ?? await keytar.getPassword(LEGACY_SERVICE, ACCOUNT);
|
|
3277
|
+
if (legacyKeytarValue) {
|
|
3278
|
+
const migrated = macKeychainSet(legacyKeytarValue) || linuxSecretSet(legacyKeytarValue);
|
|
3065
3279
|
if (migrated) {
|
|
3066
3280
|
process.stderr.write("[keychain] Migrated key from keytar to native keychain.\n");
|
|
3281
|
+
try {
|
|
3282
|
+
await keytar.deletePassword(LEGACY_SERVICE, ACCOUNT);
|
|
3283
|
+
} catch {
|
|
3284
|
+
}
|
|
3067
3285
|
}
|
|
3068
|
-
return Buffer.from(
|
|
3286
|
+
return Buffer.from(legacyKeytarValue, "base64");
|
|
3069
3287
|
}
|
|
3070
3288
|
} catch {
|
|
3071
3289
|
}
|
|
@@ -3090,7 +3308,7 @@ async function getMasterKey() {
|
|
|
3090
3308
|
const decrypted = decryptWithMachineKey(content, machineKey);
|
|
3091
3309
|
if (!decrypted) {
|
|
3092
3310
|
process.stderr.write(
|
|
3093
|
-
"[keychain] Key decryption failed \u2014 machine may have changed.\n Use your 24-word recovery phrase: exe-os
|
|
3311
|
+
"[keychain] Key decryption failed \u2014 machine may have changed.\n Use your 24-word recovery phrase during setup: exe-os setup\n"
|
|
3094
3312
|
);
|
|
3095
3313
|
return null;
|
|
3096
3314
|
}
|
|
@@ -3099,6 +3317,9 @@ async function getMasterKey() {
|
|
|
3099
3317
|
b64Value = content;
|
|
3100
3318
|
}
|
|
3101
3319
|
const key = Buffer.from(b64Value, "base64");
|
|
3320
|
+
if (!content.startsWith(ENCRYPTED_PREFIX) && isRootOnlyTrustedServerKeyFile(keyPath)) {
|
|
3321
|
+
return key;
|
|
3322
|
+
}
|
|
3102
3323
|
const migrated = macKeychainSet(b64Value) || linuxSecretSet(b64Value);
|
|
3103
3324
|
if (migrated) {
|
|
3104
3325
|
process.stderr.write("[keychain] Migrated key from file to native keychain.\n");
|
|
@@ -3126,12 +3347,14 @@ async function getMasterKey() {
|
|
|
3126
3347
|
return null;
|
|
3127
3348
|
}
|
|
3128
3349
|
}
|
|
3129
|
-
var SERVICE, ACCOUNT, ENCRYPTED_PREFIX;
|
|
3350
|
+
var SERVICE, LEGACY_SERVICE, ACCOUNT, linuxSecretAvailability, ENCRYPTED_PREFIX;
|
|
3130
3351
|
var init_keychain = __esm({
|
|
3131
3352
|
"src/lib/keychain.ts"() {
|
|
3132
3353
|
"use strict";
|
|
3133
|
-
SERVICE = "exe-
|
|
3354
|
+
SERVICE = "exe-os";
|
|
3355
|
+
LEGACY_SERVICE = "exe-mem";
|
|
3134
3356
|
ACCOUNT = "master-key";
|
|
3357
|
+
linuxSecretAvailability = null;
|
|
3135
3358
|
ENCRYPTED_PREFIX = "enc:";
|
|
3136
3359
|
}
|
|
3137
3360
|
});
|
|
@@ -3401,7 +3624,7 @@ __export(shard_manager_exports, {
|
|
|
3401
3624
|
shardExists: () => shardExists
|
|
3402
3625
|
});
|
|
3403
3626
|
import path7 from "path";
|
|
3404
|
-
import { existsSync as existsSync7, mkdirSync as mkdirSync2, readdirSync, renameSync as renameSync3, statSync as
|
|
3627
|
+
import { existsSync as existsSync7, mkdirSync as mkdirSync2, readdirSync, renameSync as renameSync3, statSync as statSync3 } from "fs";
|
|
3405
3628
|
import { createClient as createClient2 } from "@libsql/client";
|
|
3406
3629
|
function initShardManager(encryptionKey) {
|
|
3407
3630
|
_encryptionKey = encryptionKey;
|
|
@@ -3465,7 +3688,7 @@ async function auditShardHealth(options = {}) {
|
|
|
3465
3688
|
const shards = [];
|
|
3466
3689
|
for (const name of names) {
|
|
3467
3690
|
const dbPath = path7.join(SHARDS_DIR, `${name}.db`);
|
|
3468
|
-
const stat =
|
|
3691
|
+
const stat = statSync3(dbPath);
|
|
3469
3692
|
const item = {
|
|
3470
3693
|
name,
|
|
3471
3694
|
path: dbPath,
|
|
@@ -3718,7 +3941,7 @@ async function getReadyShardClient(projectName) {
|
|
|
3718
3941
|
_shardLastAccess.delete(safeName);
|
|
3719
3942
|
const dbPath = path7.join(SHARDS_DIR, `${safeName}.db`);
|
|
3720
3943
|
if (existsSync7(dbPath)) {
|
|
3721
|
-
const stat =
|
|
3944
|
+
const stat = statSync3(dbPath);
|
|
3722
3945
|
const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
3723
3946
|
const archivedPath = path7.join(SHARDS_DIR, `${safeName}.db.broken-${stamp}`);
|
|
3724
3947
|
renameSync3(dbPath, archivedPath);
|
|
@@ -3838,6 +4061,12 @@ var init_platform_procedures = __esm({
|
|
|
3838
4061
|
priority: "p0",
|
|
3839
4062
|
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."
|
|
3840
4063
|
},
|
|
4064
|
+
{
|
|
4065
|
+
title: "Customer orchestration maturity \u2014 recommend, never trap",
|
|
4066
|
+
domain: "workflow",
|
|
4067
|
+
priority: "p1",
|
|
4068
|
+
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."
|
|
4069
|
+
},
|
|
3841
4070
|
{
|
|
3842
4071
|
title: "Single dispatch path \u2014 create_task only",
|
|
3843
4072
|
domain: "workflow",
|
|
@@ -3896,6 +4125,12 @@ var init_platform_procedures = __esm({
|
|
|
3896
4125
|
priority: "p0",
|
|
3897
4126
|
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."
|
|
3898
4127
|
},
|
|
4128
|
+
{
|
|
4129
|
+
title: "Commit discipline \u2014 never leave verified work floating",
|
|
4130
|
+
domain: "workflow",
|
|
4131
|
+
priority: "p1",
|
|
4132
|
+
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."
|
|
4133
|
+
},
|
|
3899
4134
|
{
|
|
3900
4135
|
title: "Desktop and TUI are the same product",
|
|
3901
4136
|
domain: "architecture",
|
|
@@ -4213,6 +4448,274 @@ var init_memory_cards = __esm({
|
|
|
4213
4448
|
}
|
|
4214
4449
|
});
|
|
4215
4450
|
|
|
4451
|
+
// src/lib/agentic-ontology.ts
|
|
4452
|
+
var agentic_ontology_exports = {};
|
|
4453
|
+
__export(agentic_ontology_exports, {
|
|
4454
|
+
clean: () => clean,
|
|
4455
|
+
extractGoalCandidates: () => extractGoalCandidates,
|
|
4456
|
+
inferIntention: () => inferIntention,
|
|
4457
|
+
inferOntologyEventType: () => inferOntologyEventType,
|
|
4458
|
+
inferOutcome: () => inferOutcome,
|
|
4459
|
+
inferSemanticLabel: () => inferSemanticLabel,
|
|
4460
|
+
insertOntologyForBatch: () => insertOntologyForBatch,
|
|
4461
|
+
insertOntologyForMemory: () => insertOntologyForMemory,
|
|
4462
|
+
ontologyPayload: () => ontologyPayload,
|
|
4463
|
+
stableId: () => stableId2
|
|
4464
|
+
});
|
|
4465
|
+
import { createHash as createHash3 } from "crypto";
|
|
4466
|
+
function stableId2(...parts) {
|
|
4467
|
+
return createHash3("sha256").update(parts.map((p) => String(p ?? "")).join("::")).digest("hex").slice(0, 32);
|
|
4468
|
+
}
|
|
4469
|
+
function clean(text, max = 240) {
|
|
4470
|
+
return text.replace(/\u0000/g, "").replace(/```[\s\S]*?```/g, " ").replace(/\s+/g, " ").trim().slice(0, max);
|
|
4471
|
+
}
|
|
4472
|
+
function inferOntologyEventType(row) {
|
|
4473
|
+
const lower = row.raw_text.toLowerCase();
|
|
4474
|
+
if (row.has_error) return "error";
|
|
4475
|
+
if (/\b(done|complete|completed|fixed|resolved|shipped|deployed|pushed|published)\b/.test(lower)) return "milestone";
|
|
4476
|
+
if (/\b(blocked|failed|error|bug|regression|broken)\b/.test(lower)) return "problem";
|
|
4477
|
+
if (/\b(decided|decision|adr|we chose|approved|rejected)\b/.test(lower)) return "decision";
|
|
4478
|
+
if (/\b(goal|need to|we need|want to|trying to|objective)\b/.test(lower)) return "goal_signal";
|
|
4479
|
+
if (["Bash", "Read", "Edit", "Write", "Grep", "Glob"].includes(row.tool_name)) return "tool_action";
|
|
4480
|
+
if (row.tool_name.startsWith("memory_card")) return "memory_card";
|
|
4481
|
+
return "memory_observation";
|
|
4482
|
+
}
|
|
4483
|
+
function inferIntention(row) {
|
|
4484
|
+
if (row.intent) return clean(row.intent, 220);
|
|
4485
|
+
const text = clean(row.raw_text, 1e3);
|
|
4486
|
+
const patterns = [
|
|
4487
|
+
/(?: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,
|
|
4488
|
+
/(?:so that|in order to)\s+([^.!?\n]{8,220})/i,
|
|
4489
|
+
/(?:task|plan):\s*([^.!?\n]{8,220})/i
|
|
4490
|
+
];
|
|
4491
|
+
for (const p of patterns) {
|
|
4492
|
+
const m = text.match(p);
|
|
4493
|
+
if (m?.[1]) return clean(m[1], 220);
|
|
4494
|
+
}
|
|
4495
|
+
if (["Bash", "Read", "Edit", "Write", "Grep", "Glob"].includes(row.tool_name)) {
|
|
4496
|
+
return `${row.tool_name} during ${row.project_name}`;
|
|
4497
|
+
}
|
|
4498
|
+
return null;
|
|
4499
|
+
}
|
|
4500
|
+
function inferOutcome(row) {
|
|
4501
|
+
if (row.outcome) return clean(row.outcome, 220);
|
|
4502
|
+
if (row.has_error) return "error";
|
|
4503
|
+
const lower = row.raw_text.toLowerCase();
|
|
4504
|
+
if (/\b(done|complete|completed|fixed|resolved|shipped|deployed|pushed|published|passed)\b/.test(lower)) return "success_signal";
|
|
4505
|
+
if (/\b(blocked|failed|error|regression|broken|not working|could not)\b/.test(lower)) return "failure_signal";
|
|
4506
|
+
if (/\b(warning|risk|concern|caveat)\b/.test(lower)) return "risk_signal";
|
|
4507
|
+
return null;
|
|
4508
|
+
}
|
|
4509
|
+
function extractGoalCandidates(row) {
|
|
4510
|
+
const text = clean(row.raw_text, 1600);
|
|
4511
|
+
const patterns = [
|
|
4512
|
+
/(?: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,
|
|
4513
|
+
/(?:success means|success criteria|so that)\s+([^.!?\n]{12,220})/gi
|
|
4514
|
+
];
|
|
4515
|
+
const out = [];
|
|
4516
|
+
for (const pattern of patterns) {
|
|
4517
|
+
for (const m of text.matchAll(pattern)) {
|
|
4518
|
+
const candidate = clean(m[1] ?? "", 220);
|
|
4519
|
+
if (candidate.length >= 12 && !out.some((x) => x.toLowerCase() === candidate.toLowerCase())) out.push(candidate);
|
|
4520
|
+
if (out.length >= 3) return out;
|
|
4521
|
+
}
|
|
4522
|
+
}
|
|
4523
|
+
return out;
|
|
4524
|
+
}
|
|
4525
|
+
function uniq(values, max = 6) {
|
|
4526
|
+
const out = [];
|
|
4527
|
+
for (const value of values.map((v) => clean(v, 220)).filter(Boolean)) {
|
|
4528
|
+
if (!out.some((x) => x.toLowerCase() === value.toLowerCase())) out.push(value);
|
|
4529
|
+
if (out.length >= max) break;
|
|
4530
|
+
}
|
|
4531
|
+
return out;
|
|
4532
|
+
}
|
|
4533
|
+
function extractMatches(text, patterns, max = 5) {
|
|
4534
|
+
const out = [];
|
|
4535
|
+
for (const pattern of patterns) {
|
|
4536
|
+
for (const match of text.matchAll(pattern)) {
|
|
4537
|
+
const value = match[1] ?? match[0];
|
|
4538
|
+
if (value) out.push(value);
|
|
4539
|
+
if (out.length >= max) return uniq(out, max);
|
|
4540
|
+
}
|
|
4541
|
+
}
|
|
4542
|
+
return uniq(out, max);
|
|
4543
|
+
}
|
|
4544
|
+
function inferSemanticLabel(row) {
|
|
4545
|
+
const text = clean(row.raw_text, 2400);
|
|
4546
|
+
const eventType = inferOntologyEventType(row);
|
|
4547
|
+
const intention = inferIntention(row);
|
|
4548
|
+
const outcome = inferOutcome(row);
|
|
4549
|
+
const goals = extractGoalCandidates(row);
|
|
4550
|
+
const milestones = extractMatches(text, [
|
|
4551
|
+
/\b(?:completed|finished|fixed|resolved|shipped|deployed|published|pushed|passed)\b([^.!?\n]{0,180})/gi,
|
|
4552
|
+
/(?:milestone|done):\s*([^.!?\n]{8,220})/gi
|
|
4553
|
+
]);
|
|
4554
|
+
const problems = extractMatches(text, [
|
|
4555
|
+
/\b(?:blocked by|failed because|bug|regression|broken|not working|error)\b([^.!?\n]{0,180})/gi,
|
|
4556
|
+
/(?:problem|issue|risk):\s*([^.!?\n]{8,220})/gi
|
|
4557
|
+
]);
|
|
4558
|
+
const decisions = extractMatches(text, [
|
|
4559
|
+
/(?:decided|decision|adr|we chose|approved|rejected)\s+([^.!?\n]{8,220})/gi
|
|
4560
|
+
]);
|
|
4561
|
+
const temporalAnchors = extractMatches(text, [
|
|
4562
|
+
/\b(\d{4}-\d{2}-\d{2}(?:[T ][0-9:.+-Z]+)?)\b/g,
|
|
4563
|
+
/\b(today|yesterday|tomorrow|this week|next week|last week|morning|afternoon|tonight)\b/gi
|
|
4564
|
+
], 8);
|
|
4565
|
+
const nextActions = extractMatches(text, [
|
|
4566
|
+
/(?:next|todo|follow[- ]?up|remaining|need to)\s*:?\s*([^.!?\n]{8,220})/gi
|
|
4567
|
+
]);
|
|
4568
|
+
const actors = uniq([
|
|
4569
|
+
row.agent_id,
|
|
4570
|
+
...extractMatches(text, [/\b(?:agent|employee|owner|assignee)[:= ]+([a-zA-Z][a-zA-Z0-9_-]{1,40})/gi], 5)
|
|
4571
|
+
], 6);
|
|
4572
|
+
const successSignals = milestones.length ? milestones : outcome === "success_signal" ? [clean(text, 180)] : [];
|
|
4573
|
+
const failureSignals = problems.length ? problems : outcome === "failure_signal" || row.has_error ? [clean(text, 180)] : [];
|
|
4574
|
+
const impact = successSignals.length && failureSignals.length ? "mixed" : failureSignals.length ? "negative" : successSignals.length ? "positive" : "neutral";
|
|
4575
|
+
const signalCount = goals.length + milestones.length + problems.length + decisions.length + nextActions.length;
|
|
4576
|
+
return {
|
|
4577
|
+
labeler: "deterministic",
|
|
4578
|
+
schemaVersion: 1,
|
|
4579
|
+
eventType,
|
|
4580
|
+
intention,
|
|
4581
|
+
outcome,
|
|
4582
|
+
impact,
|
|
4583
|
+
confidence: Math.min(0.95, 0.45 + signalCount * 0.08 + (intention ? 0.1 : 0) + (outcome ? 0.1 : 0)),
|
|
4584
|
+
goals,
|
|
4585
|
+
milestones,
|
|
4586
|
+
problems,
|
|
4587
|
+
decisions,
|
|
4588
|
+
actors,
|
|
4589
|
+
temporalAnchors,
|
|
4590
|
+
successSignals,
|
|
4591
|
+
failureSignals,
|
|
4592
|
+
nextActions,
|
|
4593
|
+
summary: clean(text, 280)
|
|
4594
|
+
};
|
|
4595
|
+
}
|
|
4596
|
+
function ontologyPayload(row) {
|
|
4597
|
+
const semantic = inferSemanticLabel(row);
|
|
4598
|
+
return {
|
|
4599
|
+
tool_name: row.tool_name,
|
|
4600
|
+
memory_version: row.version ?? null,
|
|
4601
|
+
domain: row.domain ?? null,
|
|
4602
|
+
trajectory: row.trajectory ? safeJson(row.trajectory) : null,
|
|
4603
|
+
semantic
|
|
4604
|
+
};
|
|
4605
|
+
}
|
|
4606
|
+
function safeJson(value) {
|
|
4607
|
+
try {
|
|
4608
|
+
return JSON.parse(value);
|
|
4609
|
+
} catch {
|
|
4610
|
+
return value.slice(0, 1e3);
|
|
4611
|
+
}
|
|
4612
|
+
}
|
|
4613
|
+
async function resolveClient(client) {
|
|
4614
|
+
if (client) return client;
|
|
4615
|
+
const { getClient: getClient2 } = await Promise.resolve().then(() => (init_database(), database_exports));
|
|
4616
|
+
return getClient2();
|
|
4617
|
+
}
|
|
4618
|
+
async function insertOntologyForMemory(row, client) {
|
|
4619
|
+
const db = await resolveClient(client);
|
|
4620
|
+
const occurredAt = row.timestamp;
|
|
4621
|
+
const sequence = Number(row.version ?? 0) || Math.floor(new Date(occurredAt).getTime() / 1e3);
|
|
4622
|
+
const eventType = inferOntologyEventType(row);
|
|
4623
|
+
const intention = inferIntention(row);
|
|
4624
|
+
const outcome = inferOutcome(row);
|
|
4625
|
+
const eventId = stableId2("event", row.id);
|
|
4626
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
4627
|
+
await db.execute({
|
|
4628
|
+
sql: `INSERT INTO agent_sessions (id, agent_id, project_name, started_at, last_event_at, event_count, properties)
|
|
4629
|
+
VALUES (?, ?, ?, ?, ?, 1, ?)
|
|
4630
|
+
ON CONFLICT(id) DO UPDATE SET last_event_at = MAX(last_event_at, excluded.last_event_at),
|
|
4631
|
+
event_count = event_count + 1`,
|
|
4632
|
+
args: [row.session_id, row.agent_id, row.project_name, occurredAt, occurredAt, JSON.stringify({ agent_role: row.agent_role })]
|
|
4633
|
+
});
|
|
4634
|
+
await db.execute({
|
|
4635
|
+
sql: `INSERT OR IGNORE INTO agent_events
|
|
4636
|
+
(id, event_type, occurred_at, sequence_index, actor_agent_id, agent_role, project_name,
|
|
4637
|
+
session_id, task_id, goal_id, parent_event_id, intention, outcome, evidence_memory_id,
|
|
4638
|
+
impact, payload, created_at)
|
|
4639
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NULL, NULL, ?, ?, ?, ?, ?, ?)`,
|
|
4640
|
+
args: [
|
|
4641
|
+
eventId,
|
|
4642
|
+
eventType,
|
|
4643
|
+
occurredAt,
|
|
4644
|
+
sequence,
|
|
4645
|
+
row.agent_id,
|
|
4646
|
+
row.agent_role,
|
|
4647
|
+
row.project_name,
|
|
4648
|
+
row.session_id,
|
|
4649
|
+
row.task_id ?? null,
|
|
4650
|
+
intention,
|
|
4651
|
+
outcome,
|
|
4652
|
+
row.id,
|
|
4653
|
+
row.has_error ? "negative" : outcome === "success_signal" ? "positive" : "neutral",
|
|
4654
|
+
JSON.stringify(ontologyPayload(row)),
|
|
4655
|
+
now
|
|
4656
|
+
]
|
|
4657
|
+
});
|
|
4658
|
+
const semantic = inferSemanticLabel(row);
|
|
4659
|
+
await db.execute({
|
|
4660
|
+
sql: `INSERT INTO agent_semantic_labels
|
|
4661
|
+
(id, source_memory_id, event_id, labeler, schema_version, confidence, labels, created_at, updated_at)
|
|
4662
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
4663
|
+
ON CONFLICT(id) DO UPDATE SET confidence = excluded.confidence,
|
|
4664
|
+
labels = excluded.labels, updated_at = excluded.updated_at`,
|
|
4665
|
+
args: [
|
|
4666
|
+
stableId2("semantic", row.id, semantic.labeler, semantic.schemaVersion),
|
|
4667
|
+
row.id,
|
|
4668
|
+
eventId,
|
|
4669
|
+
semantic.labeler,
|
|
4670
|
+
semantic.schemaVersion,
|
|
4671
|
+
semantic.confidence,
|
|
4672
|
+
JSON.stringify(semantic),
|
|
4673
|
+
now,
|
|
4674
|
+
now
|
|
4675
|
+
]
|
|
4676
|
+
});
|
|
4677
|
+
for (const statement of extractGoalCandidates(row)) {
|
|
4678
|
+
const goalId = stableId2("goal", row.project_name, statement.toLowerCase());
|
|
4679
|
+
await db.execute({
|
|
4680
|
+
sql: `INSERT INTO agent_goals
|
|
4681
|
+
(id, statement, owner_agent_id, project_name, status, priority, success_criteria,
|
|
4682
|
+
parent_goal_id, due_at, achieved_at, supersedes_id, created_at, updated_at, source_memory_id)
|
|
4683
|
+
VALUES (?, ?, ?, ?, 'open', 5, NULL, NULL, NULL, NULL, NULL, ?, ?, ?)
|
|
4684
|
+
ON CONFLICT(id) DO UPDATE SET updated_at = excluded.updated_at`,
|
|
4685
|
+
args: [goalId, statement, row.agent_id, row.project_name, now, now, row.id]
|
|
4686
|
+
});
|
|
4687
|
+
await db.execute({
|
|
4688
|
+
sql: `INSERT OR IGNORE INTO agent_goal_links
|
|
4689
|
+
(id, goal_id, link_type, target_id, target_type, created_at)
|
|
4690
|
+
VALUES (?, ?, 'evidence', ?, 'memory', ?)`,
|
|
4691
|
+
args: [stableId2("goal_link", goalId, row.id, "memory"), goalId, row.id, now]
|
|
4692
|
+
});
|
|
4693
|
+
await db.execute({
|
|
4694
|
+
sql: `INSERT OR IGNORE INTO agent_goal_links
|
|
4695
|
+
(id, goal_id, link_type, target_id, target_type, created_at)
|
|
4696
|
+
VALUES (?, ?, 'event', ?, 'event', ?)`,
|
|
4697
|
+
args: [stableId2("goal_link", goalId, eventId, "event"), goalId, eventId, now]
|
|
4698
|
+
});
|
|
4699
|
+
}
|
|
4700
|
+
}
|
|
4701
|
+
async function insertOntologyForBatch(rows, client) {
|
|
4702
|
+
const db = await resolveClient(client);
|
|
4703
|
+
let count = 0;
|
|
4704
|
+
for (const row of rows) {
|
|
4705
|
+
try {
|
|
4706
|
+
await insertOntologyForMemory(row, db);
|
|
4707
|
+
count++;
|
|
4708
|
+
} catch {
|
|
4709
|
+
}
|
|
4710
|
+
}
|
|
4711
|
+
return count;
|
|
4712
|
+
}
|
|
4713
|
+
var init_agentic_ontology = __esm({
|
|
4714
|
+
"src/lib/agentic-ontology.ts"() {
|
|
4715
|
+
"use strict";
|
|
4716
|
+
}
|
|
4717
|
+
});
|
|
4718
|
+
|
|
4216
4719
|
// src/lib/store.ts
|
|
4217
4720
|
var store_exports = {};
|
|
4218
4721
|
__export(store_exports, {
|
|
@@ -4556,6 +5059,11 @@ async function flushBatch() {
|
|
|
4556
5059
|
await insertMemoryCardsForBatch2(batch);
|
|
4557
5060
|
} catch {
|
|
4558
5061
|
}
|
|
5062
|
+
try {
|
|
5063
|
+
const { insertOntologyForBatch: insertOntologyForBatch2 } = await Promise.resolve().then(() => (init_agentic_ontology(), agentic_ontology_exports));
|
|
5064
|
+
await insertOntologyForBatch2(batch);
|
|
5065
|
+
} catch {
|
|
5066
|
+
}
|
|
4559
5067
|
schedulePostWriteMemoryHygiene(batch.map((row) => row.id));
|
|
4560
5068
|
_pendingRecords.splice(0, batch.length);
|
|
4561
5069
|
try {
|