@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/exe-team.js
CHANGED
|
@@ -124,6 +124,11 @@ function normalizeAutoUpdate(raw) {
|
|
|
124
124
|
const userAU = raw.autoUpdate ?? {};
|
|
125
125
|
raw.autoUpdate = { ...defaultAU, ...userAU };
|
|
126
126
|
}
|
|
127
|
+
function normalizeOrchestration(raw) {
|
|
128
|
+
const defaultOrg = DEFAULT_CONFIG.orchestration;
|
|
129
|
+
const userOrg = raw.orchestration ?? {};
|
|
130
|
+
raw.orchestration = { ...defaultOrg, ...userOrg };
|
|
131
|
+
}
|
|
127
132
|
async function loadConfig() {
|
|
128
133
|
const dir = process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? EXE_AI_DIR;
|
|
129
134
|
await ensurePrivateDir(dir);
|
|
@@ -148,10 +153,15 @@ async function loadConfig() {
|
|
|
148
153
|
normalizeScalingRoadmap(migratedCfg);
|
|
149
154
|
normalizeSessionLifecycle(migratedCfg);
|
|
150
155
|
normalizeAutoUpdate(migratedCfg);
|
|
156
|
+
normalizeOrchestration(migratedCfg);
|
|
151
157
|
const config = { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db"), ...migratedCfg };
|
|
152
158
|
if (config.dbPath.startsWith("~")) {
|
|
153
159
|
config.dbPath = config.dbPath.replace(/^~/, os.homedir());
|
|
154
160
|
}
|
|
161
|
+
const envDbPath = path.join(dir, "memories.db");
|
|
162
|
+
if (process.env.EXE_OS_DIR && config.dbPath !== envDbPath && !existsSync2(config.dbPath) && existsSync2(envDbPath)) {
|
|
163
|
+
config.dbPath = envDbPath;
|
|
164
|
+
}
|
|
155
165
|
return config;
|
|
156
166
|
} catch {
|
|
157
167
|
return { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db") };
|
|
@@ -223,6 +233,10 @@ var init_config = __esm({
|
|
|
223
233
|
checkOnBoot: true,
|
|
224
234
|
autoInstall: false,
|
|
225
235
|
checkIntervalMs: 24 * 60 * 60 * 1e3
|
|
236
|
+
},
|
|
237
|
+
orchestration: {
|
|
238
|
+
phase: "phase_1_coo",
|
|
239
|
+
phaseSetBy: "default"
|
|
226
240
|
}
|
|
227
241
|
};
|
|
228
242
|
CONFIG_MIGRATIONS = [
|
|
@@ -1745,6 +1759,9 @@ function getClient() {
|
|
|
1745
1759
|
if (_daemonClient && _daemonClient._isDaemonActive()) {
|
|
1746
1760
|
return _daemonClient;
|
|
1747
1761
|
}
|
|
1762
|
+
if (!_resilientClient) {
|
|
1763
|
+
return _adapterClient;
|
|
1764
|
+
}
|
|
1748
1765
|
return _resilientClient;
|
|
1749
1766
|
}
|
|
1750
1767
|
async function initDaemonClient() {
|
|
@@ -2777,6 +2794,127 @@ async function ensureSchema() {
|
|
|
2777
2794
|
VALUES (new.rowid, new.content, new.subject, new.predicate, new.object);
|
|
2778
2795
|
END;
|
|
2779
2796
|
`);
|
|
2797
|
+
await client.executeMultiple(`
|
|
2798
|
+
CREATE TABLE IF NOT EXISTS agent_sessions (
|
|
2799
|
+
id TEXT PRIMARY KEY,
|
|
2800
|
+
agent_id TEXT NOT NULL,
|
|
2801
|
+
project_name TEXT,
|
|
2802
|
+
started_at TEXT NOT NULL,
|
|
2803
|
+
last_event_at TEXT NOT NULL,
|
|
2804
|
+
event_count INTEGER NOT NULL DEFAULT 0,
|
|
2805
|
+
properties TEXT DEFAULT '{}'
|
|
2806
|
+
);
|
|
2807
|
+
|
|
2808
|
+
CREATE INDEX IF NOT EXISTS idx_agent_sessions_agent_time
|
|
2809
|
+
ON agent_sessions(agent_id, started_at);
|
|
2810
|
+
|
|
2811
|
+
CREATE TABLE IF NOT EXISTS agent_goals (
|
|
2812
|
+
id TEXT PRIMARY KEY,
|
|
2813
|
+
statement TEXT NOT NULL,
|
|
2814
|
+
owner_agent_id TEXT,
|
|
2815
|
+
project_name TEXT,
|
|
2816
|
+
status TEXT NOT NULL DEFAULT 'open',
|
|
2817
|
+
priority INTEGER NOT NULL DEFAULT 5,
|
|
2818
|
+
success_criteria TEXT,
|
|
2819
|
+
parent_goal_id TEXT,
|
|
2820
|
+
due_at TEXT,
|
|
2821
|
+
achieved_at TEXT,
|
|
2822
|
+
supersedes_id TEXT,
|
|
2823
|
+
created_at TEXT NOT NULL,
|
|
2824
|
+
updated_at TEXT NOT NULL,
|
|
2825
|
+
source_memory_id TEXT
|
|
2826
|
+
);
|
|
2827
|
+
|
|
2828
|
+
CREATE INDEX IF NOT EXISTS idx_agent_goals_project_status
|
|
2829
|
+
ON agent_goals(project_name, status, priority);
|
|
2830
|
+
|
|
2831
|
+
CREATE TABLE IF NOT EXISTS agent_events (
|
|
2832
|
+
id TEXT PRIMARY KEY,
|
|
2833
|
+
event_type TEXT NOT NULL,
|
|
2834
|
+
occurred_at TEXT NOT NULL,
|
|
2835
|
+
sequence_index INTEGER NOT NULL,
|
|
2836
|
+
actor_agent_id TEXT,
|
|
2837
|
+
agent_role TEXT,
|
|
2838
|
+
project_name TEXT,
|
|
2839
|
+
session_id TEXT,
|
|
2840
|
+
task_id TEXT,
|
|
2841
|
+
goal_id TEXT,
|
|
2842
|
+
parent_event_id TEXT,
|
|
2843
|
+
intention TEXT,
|
|
2844
|
+
outcome TEXT,
|
|
2845
|
+
evidence_memory_id TEXT,
|
|
2846
|
+
impact TEXT,
|
|
2847
|
+
payload TEXT DEFAULT '{}',
|
|
2848
|
+
created_at TEXT NOT NULL
|
|
2849
|
+
);
|
|
2850
|
+
|
|
2851
|
+
CREATE INDEX IF NOT EXISTS idx_agent_events_time
|
|
2852
|
+
ON agent_events(occurred_at, sequence_index);
|
|
2853
|
+
|
|
2854
|
+
CREATE INDEX IF NOT EXISTS idx_agent_events_session_seq
|
|
2855
|
+
ON agent_events(session_id, sequence_index);
|
|
2856
|
+
|
|
2857
|
+
CREATE INDEX IF NOT EXISTS idx_agent_events_goal_time
|
|
2858
|
+
ON agent_events(goal_id, occurred_at);
|
|
2859
|
+
|
|
2860
|
+
CREATE INDEX IF NOT EXISTS idx_agent_events_memory
|
|
2861
|
+
ON agent_events(evidence_memory_id);
|
|
2862
|
+
|
|
2863
|
+
CREATE TABLE IF NOT EXISTS agent_goal_links (
|
|
2864
|
+
id TEXT PRIMARY KEY,
|
|
2865
|
+
goal_id TEXT NOT NULL,
|
|
2866
|
+
link_type TEXT NOT NULL,
|
|
2867
|
+
target_id TEXT NOT NULL,
|
|
2868
|
+
target_type TEXT NOT NULL,
|
|
2869
|
+
created_at TEXT NOT NULL
|
|
2870
|
+
);
|
|
2871
|
+
|
|
2872
|
+
CREATE INDEX IF NOT EXISTS idx_agent_goal_links_goal
|
|
2873
|
+
ON agent_goal_links(goal_id, target_type);
|
|
2874
|
+
|
|
2875
|
+
CREATE TABLE IF NOT EXISTS agent_semantic_labels (
|
|
2876
|
+
id TEXT PRIMARY KEY,
|
|
2877
|
+
source_memory_id TEXT NOT NULL,
|
|
2878
|
+
event_id TEXT,
|
|
2879
|
+
labeler TEXT NOT NULL,
|
|
2880
|
+
schema_version INTEGER NOT NULL DEFAULT 1,
|
|
2881
|
+
confidence REAL NOT NULL DEFAULT 0,
|
|
2882
|
+
labels TEXT NOT NULL,
|
|
2883
|
+
created_at TEXT NOT NULL,
|
|
2884
|
+
updated_at TEXT NOT NULL
|
|
2885
|
+
);
|
|
2886
|
+
|
|
2887
|
+
CREATE INDEX IF NOT EXISTS idx_agent_semantic_labels_memory
|
|
2888
|
+
ON agent_semantic_labels(source_memory_id, labeler);
|
|
2889
|
+
|
|
2890
|
+
CREATE INDEX IF NOT EXISTS idx_agent_semantic_labels_event
|
|
2891
|
+
ON agent_semantic_labels(event_id);
|
|
2892
|
+
|
|
2893
|
+
CREATE TABLE IF NOT EXISTS agent_reflection_checkpoints (
|
|
2894
|
+
id TEXT PRIMARY KEY,
|
|
2895
|
+
project_name TEXT,
|
|
2896
|
+
session_id TEXT,
|
|
2897
|
+
window_start_at TEXT NOT NULL,
|
|
2898
|
+
window_end_at TEXT NOT NULL,
|
|
2899
|
+
event_count INTEGER NOT NULL DEFAULT 0,
|
|
2900
|
+
goal_count INTEGER NOT NULL DEFAULT 0,
|
|
2901
|
+
success_count INTEGER NOT NULL DEFAULT 0,
|
|
2902
|
+
failure_count INTEGER NOT NULL DEFAULT 0,
|
|
2903
|
+
risk_count INTEGER NOT NULL DEFAULT 0,
|
|
2904
|
+
summary TEXT NOT NULL,
|
|
2905
|
+
learnings TEXT NOT NULL DEFAULT '[]',
|
|
2906
|
+
next_actions TEXT NOT NULL DEFAULT '[]',
|
|
2907
|
+
evidence_event_ids TEXT NOT NULL DEFAULT '[]',
|
|
2908
|
+
confidence REAL NOT NULL DEFAULT 0,
|
|
2909
|
+
created_at TEXT NOT NULL
|
|
2910
|
+
);
|
|
2911
|
+
|
|
2912
|
+
CREATE INDEX IF NOT EXISTS idx_agent_reflection_project_time
|
|
2913
|
+
ON agent_reflection_checkpoints(project_name, window_end_at);
|
|
2914
|
+
|
|
2915
|
+
CREATE INDEX IF NOT EXISTS idx_agent_reflection_session_time
|
|
2916
|
+
ON agent_reflection_checkpoints(session_id, window_end_at);
|
|
2917
|
+
`);
|
|
2780
2918
|
try {
|
|
2781
2919
|
await client.execute({
|
|
2782
2920
|
sql: `ALTER TABLE memories ADD COLUMN tier INTEGER DEFAULT 3`,
|
|
@@ -2926,7 +3064,7 @@ var init_database = __esm({
|
|
|
2926
3064
|
|
|
2927
3065
|
// src/lib/keychain.ts
|
|
2928
3066
|
import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2 } from "fs/promises";
|
|
2929
|
-
import { existsSync as existsSync6 } from "fs";
|
|
3067
|
+
import { existsSync as existsSync6, statSync as statSync2 } from "fs";
|
|
2930
3068
|
import { execSync as execSync2 } from "child_process";
|
|
2931
3069
|
import path6 from "path";
|
|
2932
3070
|
import os5 from "os";
|
|
@@ -2936,29 +3074,78 @@ function getKeyDir() {
|
|
|
2936
3074
|
function getKeyPath() {
|
|
2937
3075
|
return path6.join(getKeyDir(), "master.key");
|
|
2938
3076
|
}
|
|
2939
|
-
function
|
|
3077
|
+
function nativeKeychainAllowed() {
|
|
3078
|
+
return process.env.EXE_OS_DISABLE_NATIVE_KEYCHAIN !== "1";
|
|
3079
|
+
}
|
|
3080
|
+
function linuxSecretAvailable() {
|
|
3081
|
+
if (!nativeKeychainAllowed()) return false;
|
|
3082
|
+
if (process.platform !== "linux") return false;
|
|
3083
|
+
if (linuxSecretAvailability !== null) return linuxSecretAvailability;
|
|
3084
|
+
try {
|
|
3085
|
+
execSync2("command -v secret-tool >/dev/null 2>&1", { timeout: 1e3 });
|
|
3086
|
+
} catch {
|
|
3087
|
+
linuxSecretAvailability = false;
|
|
3088
|
+
return false;
|
|
3089
|
+
}
|
|
3090
|
+
try {
|
|
3091
|
+
execSync2("secret-tool search --all exe-os probe >/dev/null 2>&1", { timeout: 1e3 });
|
|
3092
|
+
linuxSecretAvailability = true;
|
|
3093
|
+
} catch {
|
|
3094
|
+
linuxSecretAvailability = false;
|
|
3095
|
+
}
|
|
3096
|
+
return linuxSecretAvailability;
|
|
3097
|
+
}
|
|
3098
|
+
function isRootOnlyTrustedServerKeyFile(keyPath) {
|
|
3099
|
+
if (process.platform !== "linux") return false;
|
|
3100
|
+
try {
|
|
3101
|
+
const uid = typeof os5.userInfo().uid === "number" ? os5.userInfo().uid : -1;
|
|
3102
|
+
const st = statSync2(keyPath);
|
|
3103
|
+
if (!st.isFile() || (st.mode & 63) !== 0) return false;
|
|
3104
|
+
if (uid === 0) return true;
|
|
3105
|
+
const exeOsDir = process.env.EXE_OS_DIR;
|
|
3106
|
+
return Boolean(exeOsDir && path6.resolve(keyPath).startsWith(path6.resolve(exeOsDir) + path6.sep));
|
|
3107
|
+
} catch {
|
|
3108
|
+
return false;
|
|
3109
|
+
}
|
|
3110
|
+
}
|
|
3111
|
+
function macKeychainGet(service = SERVICE) {
|
|
3112
|
+
if (!nativeKeychainAllowed()) return null;
|
|
2940
3113
|
if (process.platform !== "darwin") return null;
|
|
2941
3114
|
try {
|
|
2942
3115
|
return execSync2(
|
|
2943
|
-
`security find-generic-password -s "${
|
|
3116
|
+
`security find-generic-password -s "${service}" -a "${ACCOUNT}" -w 2>/dev/null`,
|
|
2944
3117
|
{ encoding: "utf-8", timeout: 5e3 }
|
|
2945
3118
|
).trim();
|
|
2946
3119
|
} catch {
|
|
2947
3120
|
return null;
|
|
2948
3121
|
}
|
|
2949
3122
|
}
|
|
2950
|
-
function macKeychainSet(value) {
|
|
3123
|
+
function macKeychainSet(value, service = SERVICE) {
|
|
3124
|
+
if (!nativeKeychainAllowed()) return false;
|
|
2951
3125
|
if (process.platform !== "darwin") return false;
|
|
2952
3126
|
try {
|
|
2953
3127
|
try {
|
|
2954
3128
|
execSync2(
|
|
2955
|
-
`security delete-generic-password -s "${
|
|
3129
|
+
`security delete-generic-password -s "${service}" -a "${ACCOUNT}" 2>/dev/null`,
|
|
2956
3130
|
{ timeout: 5e3 }
|
|
2957
3131
|
);
|
|
2958
3132
|
} catch {
|
|
2959
3133
|
}
|
|
2960
3134
|
execSync2(
|
|
2961
|
-
`security add-generic-password -s "${
|
|
3135
|
+
`security add-generic-password -s "${service}" -a "${ACCOUNT}" -w "${value}"`,
|
|
3136
|
+
{ timeout: 5e3 }
|
|
3137
|
+
);
|
|
3138
|
+
return true;
|
|
3139
|
+
} catch {
|
|
3140
|
+
return false;
|
|
3141
|
+
}
|
|
3142
|
+
}
|
|
3143
|
+
function macKeychainDelete(service = SERVICE) {
|
|
3144
|
+
if (!nativeKeychainAllowed()) return false;
|
|
3145
|
+
if (process.platform !== "darwin") return false;
|
|
3146
|
+
try {
|
|
3147
|
+
execSync2(
|
|
3148
|
+
`security delete-generic-password -s "${service}" -a "${ACCOUNT}" 2>/dev/null`,
|
|
2962
3149
|
{ timeout: 5e3 }
|
|
2963
3150
|
);
|
|
2964
3151
|
return true;
|
|
@@ -2966,22 +3153,35 @@ function macKeychainSet(value) {
|
|
|
2966
3153
|
return false;
|
|
2967
3154
|
}
|
|
2968
3155
|
}
|
|
2969
|
-
function linuxSecretGet() {
|
|
2970
|
-
if (
|
|
3156
|
+
function linuxSecretGet(service = SERVICE) {
|
|
3157
|
+
if (!linuxSecretAvailable()) return null;
|
|
2971
3158
|
try {
|
|
2972
3159
|
return execSync2(
|
|
2973
|
-
`secret-tool lookup service "${
|
|
3160
|
+
`secret-tool lookup service "${service}" account "${ACCOUNT}" 2>/dev/null`,
|
|
2974
3161
|
{ encoding: "utf-8", timeout: 5e3 }
|
|
2975
3162
|
).trim();
|
|
2976
3163
|
} catch {
|
|
2977
3164
|
return null;
|
|
2978
3165
|
}
|
|
2979
3166
|
}
|
|
2980
|
-
function linuxSecretSet(value) {
|
|
3167
|
+
function linuxSecretSet(value, service = SERVICE) {
|
|
3168
|
+
if (!linuxSecretAvailable()) return false;
|
|
3169
|
+
try {
|
|
3170
|
+
execSync2(
|
|
3171
|
+
`echo -n "${value}" | secret-tool store --label="exe-os master key" service "${service}" account "${ACCOUNT}" 2>/dev/null`,
|
|
3172
|
+
{ timeout: 5e3 }
|
|
3173
|
+
);
|
|
3174
|
+
return true;
|
|
3175
|
+
} catch {
|
|
3176
|
+
return false;
|
|
3177
|
+
}
|
|
3178
|
+
}
|
|
3179
|
+
function linuxSecretDelete(service = SERVICE) {
|
|
3180
|
+
if (!nativeKeychainAllowed()) return false;
|
|
2981
3181
|
if (process.platform !== "linux") return false;
|
|
2982
3182
|
try {
|
|
2983
3183
|
execSync2(
|
|
2984
|
-
`
|
|
3184
|
+
`secret-tool clear service "${service}" account "${ACCOUNT}" 2>/dev/null`,
|
|
2985
3185
|
{ timeout: 5e3 }
|
|
2986
3186
|
);
|
|
2987
3187
|
return true;
|
|
@@ -2990,6 +3190,7 @@ function linuxSecretSet(value) {
|
|
|
2990
3190
|
}
|
|
2991
3191
|
}
|
|
2992
3192
|
async function tryKeytar() {
|
|
3193
|
+
if (!nativeKeychainAllowed()) return null;
|
|
2993
3194
|
try {
|
|
2994
3195
|
return await import("keytar");
|
|
2995
3196
|
} catch {
|
|
@@ -3063,7 +3264,19 @@ async function writeMachineBoundFileFallback(b64) {
|
|
|
3063
3264
|
return "plaintext";
|
|
3064
3265
|
}
|
|
3065
3266
|
async function getMasterKey() {
|
|
3066
|
-
|
|
3267
|
+
let nativeValue = macKeychainGet() ?? linuxSecretGet();
|
|
3268
|
+
if (!nativeValue) {
|
|
3269
|
+
const legacyValue = macKeychainGet(LEGACY_SERVICE) ?? linuxSecretGet(LEGACY_SERVICE);
|
|
3270
|
+
if (legacyValue) {
|
|
3271
|
+
const migrated = macKeychainSet(legacyValue) || linuxSecretSet(legacyValue);
|
|
3272
|
+
if (migrated) {
|
|
3273
|
+
macKeychainDelete(LEGACY_SERVICE);
|
|
3274
|
+
linuxSecretDelete(LEGACY_SERVICE);
|
|
3275
|
+
process.stderr.write("[keychain] Migrated keychain service from exe-mem to exe-os.\n");
|
|
3276
|
+
}
|
|
3277
|
+
nativeValue = legacyValue;
|
|
3278
|
+
}
|
|
3279
|
+
}
|
|
3067
3280
|
if (nativeValue) {
|
|
3068
3281
|
return Buffer.from(nativeValue, "base64");
|
|
3069
3282
|
}
|
|
@@ -3071,12 +3284,17 @@ async function getMasterKey() {
|
|
|
3071
3284
|
if (keytar) {
|
|
3072
3285
|
try {
|
|
3073
3286
|
const keytarValue = await keytar.getPassword(SERVICE, ACCOUNT);
|
|
3074
|
-
|
|
3075
|
-
|
|
3287
|
+
const legacyKeytarValue = keytarValue ?? await keytar.getPassword(LEGACY_SERVICE, ACCOUNT);
|
|
3288
|
+
if (legacyKeytarValue) {
|
|
3289
|
+
const migrated = macKeychainSet(legacyKeytarValue) || linuxSecretSet(legacyKeytarValue);
|
|
3076
3290
|
if (migrated) {
|
|
3077
3291
|
process.stderr.write("[keychain] Migrated key from keytar to native keychain.\n");
|
|
3292
|
+
try {
|
|
3293
|
+
await keytar.deletePassword(LEGACY_SERVICE, ACCOUNT);
|
|
3294
|
+
} catch {
|
|
3295
|
+
}
|
|
3078
3296
|
}
|
|
3079
|
-
return Buffer.from(
|
|
3297
|
+
return Buffer.from(legacyKeytarValue, "base64");
|
|
3080
3298
|
}
|
|
3081
3299
|
} catch {
|
|
3082
3300
|
}
|
|
@@ -3101,7 +3319,7 @@ async function getMasterKey() {
|
|
|
3101
3319
|
const decrypted = decryptWithMachineKey(content, machineKey);
|
|
3102
3320
|
if (!decrypted) {
|
|
3103
3321
|
process.stderr.write(
|
|
3104
|
-
"[keychain] Key decryption failed \u2014 machine may have changed.\n Use your 24-word recovery phrase: exe-os
|
|
3322
|
+
"[keychain] Key decryption failed \u2014 machine may have changed.\n Use your 24-word recovery phrase during setup: exe-os setup\n"
|
|
3105
3323
|
);
|
|
3106
3324
|
return null;
|
|
3107
3325
|
}
|
|
@@ -3110,6 +3328,9 @@ async function getMasterKey() {
|
|
|
3110
3328
|
b64Value = content;
|
|
3111
3329
|
}
|
|
3112
3330
|
const key = Buffer.from(b64Value, "base64");
|
|
3331
|
+
if (!content.startsWith(ENCRYPTED_PREFIX) && isRootOnlyTrustedServerKeyFile(keyPath)) {
|
|
3332
|
+
return key;
|
|
3333
|
+
}
|
|
3113
3334
|
const migrated = macKeychainSet(b64Value) || linuxSecretSet(b64Value);
|
|
3114
3335
|
if (migrated) {
|
|
3115
3336
|
process.stderr.write("[keychain] Migrated key from file to native keychain.\n");
|
|
@@ -3137,12 +3358,14 @@ async function getMasterKey() {
|
|
|
3137
3358
|
return null;
|
|
3138
3359
|
}
|
|
3139
3360
|
}
|
|
3140
|
-
var SERVICE, ACCOUNT, ENCRYPTED_PREFIX;
|
|
3361
|
+
var SERVICE, LEGACY_SERVICE, ACCOUNT, linuxSecretAvailability, ENCRYPTED_PREFIX;
|
|
3141
3362
|
var init_keychain = __esm({
|
|
3142
3363
|
"src/lib/keychain.ts"() {
|
|
3143
3364
|
"use strict";
|
|
3144
|
-
SERVICE = "exe-
|
|
3365
|
+
SERVICE = "exe-os";
|
|
3366
|
+
LEGACY_SERVICE = "exe-mem";
|
|
3145
3367
|
ACCOUNT = "master-key";
|
|
3368
|
+
linuxSecretAvailability = null;
|
|
3146
3369
|
ENCRYPTED_PREFIX = "enc:";
|
|
3147
3370
|
}
|
|
3148
3371
|
});
|
|
@@ -3412,7 +3635,7 @@ __export(shard_manager_exports, {
|
|
|
3412
3635
|
shardExists: () => shardExists
|
|
3413
3636
|
});
|
|
3414
3637
|
import path7 from "path";
|
|
3415
|
-
import { existsSync as existsSync7, mkdirSync as mkdirSync2, readdirSync, renameSync as renameSync3, statSync as
|
|
3638
|
+
import { existsSync as existsSync7, mkdirSync as mkdirSync2, readdirSync, renameSync as renameSync3, statSync as statSync3 } from "fs";
|
|
3416
3639
|
import { createClient as createClient2 } from "@libsql/client";
|
|
3417
3640
|
function initShardManager(encryptionKey) {
|
|
3418
3641
|
_encryptionKey = encryptionKey;
|
|
@@ -3476,7 +3699,7 @@ async function auditShardHealth(options = {}) {
|
|
|
3476
3699
|
const shards = [];
|
|
3477
3700
|
for (const name of names) {
|
|
3478
3701
|
const dbPath = path7.join(SHARDS_DIR, `${name}.db`);
|
|
3479
|
-
const stat =
|
|
3702
|
+
const stat = statSync3(dbPath);
|
|
3480
3703
|
const item = {
|
|
3481
3704
|
name,
|
|
3482
3705
|
path: dbPath,
|
|
@@ -3729,7 +3952,7 @@ async function getReadyShardClient(projectName) {
|
|
|
3729
3952
|
_shardLastAccess.delete(safeName);
|
|
3730
3953
|
const dbPath = path7.join(SHARDS_DIR, `${safeName}.db`);
|
|
3731
3954
|
if (existsSync7(dbPath)) {
|
|
3732
|
-
const stat =
|
|
3955
|
+
const stat = statSync3(dbPath);
|
|
3733
3956
|
const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
3734
3957
|
const archivedPath = path7.join(SHARDS_DIR, `${safeName}.db.broken-${stamp}`);
|
|
3735
3958
|
renameSync3(dbPath, archivedPath);
|
|
@@ -3849,6 +4072,12 @@ var init_platform_procedures = __esm({
|
|
|
3849
4072
|
priority: "p0",
|
|
3850
4073
|
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."
|
|
3851
4074
|
},
|
|
4075
|
+
{
|
|
4076
|
+
title: "Customer orchestration maturity \u2014 recommend, never trap",
|
|
4077
|
+
domain: "workflow",
|
|
4078
|
+
priority: "p1",
|
|
4079
|
+
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."
|
|
4080
|
+
},
|
|
3852
4081
|
{
|
|
3853
4082
|
title: "Single dispatch path \u2014 create_task only",
|
|
3854
4083
|
domain: "workflow",
|
|
@@ -3907,6 +4136,12 @@ var init_platform_procedures = __esm({
|
|
|
3907
4136
|
priority: "p0",
|
|
3908
4137
|
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."
|
|
3909
4138
|
},
|
|
4139
|
+
{
|
|
4140
|
+
title: "Commit discipline \u2014 never leave verified work floating",
|
|
4141
|
+
domain: "workflow",
|
|
4142
|
+
priority: "p1",
|
|
4143
|
+
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."
|
|
4144
|
+
},
|
|
3910
4145
|
{
|
|
3911
4146
|
title: "Desktop and TUI are the same product",
|
|
3912
4147
|
domain: "architecture",
|
|
@@ -4224,6 +4459,274 @@ var init_memory_cards = __esm({
|
|
|
4224
4459
|
}
|
|
4225
4460
|
});
|
|
4226
4461
|
|
|
4462
|
+
// src/lib/agentic-ontology.ts
|
|
4463
|
+
var agentic_ontology_exports = {};
|
|
4464
|
+
__export(agentic_ontology_exports, {
|
|
4465
|
+
clean: () => clean,
|
|
4466
|
+
extractGoalCandidates: () => extractGoalCandidates,
|
|
4467
|
+
inferIntention: () => inferIntention,
|
|
4468
|
+
inferOntologyEventType: () => inferOntologyEventType,
|
|
4469
|
+
inferOutcome: () => inferOutcome,
|
|
4470
|
+
inferSemanticLabel: () => inferSemanticLabel,
|
|
4471
|
+
insertOntologyForBatch: () => insertOntologyForBatch,
|
|
4472
|
+
insertOntologyForMemory: () => insertOntologyForMemory,
|
|
4473
|
+
ontologyPayload: () => ontologyPayload,
|
|
4474
|
+
stableId: () => stableId2
|
|
4475
|
+
});
|
|
4476
|
+
import { createHash as createHash3 } from "crypto";
|
|
4477
|
+
function stableId2(...parts) {
|
|
4478
|
+
return createHash3("sha256").update(parts.map((p) => String(p ?? "")).join("::")).digest("hex").slice(0, 32);
|
|
4479
|
+
}
|
|
4480
|
+
function clean(text, max = 240) {
|
|
4481
|
+
return text.replace(/\u0000/g, "").replace(/```[\s\S]*?```/g, " ").replace(/\s+/g, " ").trim().slice(0, max);
|
|
4482
|
+
}
|
|
4483
|
+
function inferOntologyEventType(row) {
|
|
4484
|
+
const lower = row.raw_text.toLowerCase();
|
|
4485
|
+
if (row.has_error) return "error";
|
|
4486
|
+
if (/\b(done|complete|completed|fixed|resolved|shipped|deployed|pushed|published)\b/.test(lower)) return "milestone";
|
|
4487
|
+
if (/\b(blocked|failed|error|bug|regression|broken)\b/.test(lower)) return "problem";
|
|
4488
|
+
if (/\b(decided|decision|adr|we chose|approved|rejected)\b/.test(lower)) return "decision";
|
|
4489
|
+
if (/\b(goal|need to|we need|want to|trying to|objective)\b/.test(lower)) return "goal_signal";
|
|
4490
|
+
if (["Bash", "Read", "Edit", "Write", "Grep", "Glob"].includes(row.tool_name)) return "tool_action";
|
|
4491
|
+
if (row.tool_name.startsWith("memory_card")) return "memory_card";
|
|
4492
|
+
return "memory_observation";
|
|
4493
|
+
}
|
|
4494
|
+
function inferIntention(row) {
|
|
4495
|
+
if (row.intent) return clean(row.intent, 220);
|
|
4496
|
+
const text = clean(row.raw_text, 1e3);
|
|
4497
|
+
const patterns = [
|
|
4498
|
+
/(?: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,
|
|
4499
|
+
/(?:so that|in order to)\s+([^.!?\n]{8,220})/i,
|
|
4500
|
+
/(?:task|plan):\s*([^.!?\n]{8,220})/i
|
|
4501
|
+
];
|
|
4502
|
+
for (const p of patterns) {
|
|
4503
|
+
const m = text.match(p);
|
|
4504
|
+
if (m?.[1]) return clean(m[1], 220);
|
|
4505
|
+
}
|
|
4506
|
+
if (["Bash", "Read", "Edit", "Write", "Grep", "Glob"].includes(row.tool_name)) {
|
|
4507
|
+
return `${row.tool_name} during ${row.project_name}`;
|
|
4508
|
+
}
|
|
4509
|
+
return null;
|
|
4510
|
+
}
|
|
4511
|
+
function inferOutcome(row) {
|
|
4512
|
+
if (row.outcome) return clean(row.outcome, 220);
|
|
4513
|
+
if (row.has_error) return "error";
|
|
4514
|
+
const lower = row.raw_text.toLowerCase();
|
|
4515
|
+
if (/\b(done|complete|completed|fixed|resolved|shipped|deployed|pushed|published|passed)\b/.test(lower)) return "success_signal";
|
|
4516
|
+
if (/\b(blocked|failed|error|regression|broken|not working|could not)\b/.test(lower)) return "failure_signal";
|
|
4517
|
+
if (/\b(warning|risk|concern|caveat)\b/.test(lower)) return "risk_signal";
|
|
4518
|
+
return null;
|
|
4519
|
+
}
|
|
4520
|
+
function extractGoalCandidates(row) {
|
|
4521
|
+
const text = clean(row.raw_text, 1600);
|
|
4522
|
+
const patterns = [
|
|
4523
|
+
/(?: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,
|
|
4524
|
+
/(?:success means|success criteria|so that)\s+([^.!?\n]{12,220})/gi
|
|
4525
|
+
];
|
|
4526
|
+
const out = [];
|
|
4527
|
+
for (const pattern of patterns) {
|
|
4528
|
+
for (const m of text.matchAll(pattern)) {
|
|
4529
|
+
const candidate = clean(m[1] ?? "", 220);
|
|
4530
|
+
if (candidate.length >= 12 && !out.some((x) => x.toLowerCase() === candidate.toLowerCase())) out.push(candidate);
|
|
4531
|
+
if (out.length >= 3) return out;
|
|
4532
|
+
}
|
|
4533
|
+
}
|
|
4534
|
+
return out;
|
|
4535
|
+
}
|
|
4536
|
+
function uniq(values, max = 6) {
|
|
4537
|
+
const out = [];
|
|
4538
|
+
for (const value of values.map((v) => clean(v, 220)).filter(Boolean)) {
|
|
4539
|
+
if (!out.some((x) => x.toLowerCase() === value.toLowerCase())) out.push(value);
|
|
4540
|
+
if (out.length >= max) break;
|
|
4541
|
+
}
|
|
4542
|
+
return out;
|
|
4543
|
+
}
|
|
4544
|
+
function extractMatches(text, patterns, max = 5) {
|
|
4545
|
+
const out = [];
|
|
4546
|
+
for (const pattern of patterns) {
|
|
4547
|
+
for (const match of text.matchAll(pattern)) {
|
|
4548
|
+
const value = match[1] ?? match[0];
|
|
4549
|
+
if (value) out.push(value);
|
|
4550
|
+
if (out.length >= max) return uniq(out, max);
|
|
4551
|
+
}
|
|
4552
|
+
}
|
|
4553
|
+
return uniq(out, max);
|
|
4554
|
+
}
|
|
4555
|
+
function inferSemanticLabel(row) {
|
|
4556
|
+
const text = clean(row.raw_text, 2400);
|
|
4557
|
+
const eventType = inferOntologyEventType(row);
|
|
4558
|
+
const intention = inferIntention(row);
|
|
4559
|
+
const outcome = inferOutcome(row);
|
|
4560
|
+
const goals = extractGoalCandidates(row);
|
|
4561
|
+
const milestones = extractMatches(text, [
|
|
4562
|
+
/\b(?:completed|finished|fixed|resolved|shipped|deployed|published|pushed|passed)\b([^.!?\n]{0,180})/gi,
|
|
4563
|
+
/(?:milestone|done):\s*([^.!?\n]{8,220})/gi
|
|
4564
|
+
]);
|
|
4565
|
+
const problems = extractMatches(text, [
|
|
4566
|
+
/\b(?:blocked by|failed because|bug|regression|broken|not working|error)\b([^.!?\n]{0,180})/gi,
|
|
4567
|
+
/(?:problem|issue|risk):\s*([^.!?\n]{8,220})/gi
|
|
4568
|
+
]);
|
|
4569
|
+
const decisions = extractMatches(text, [
|
|
4570
|
+
/(?:decided|decision|adr|we chose|approved|rejected)\s+([^.!?\n]{8,220})/gi
|
|
4571
|
+
]);
|
|
4572
|
+
const temporalAnchors = extractMatches(text, [
|
|
4573
|
+
/\b(\d{4}-\d{2}-\d{2}(?:[T ][0-9:.+-Z]+)?)\b/g,
|
|
4574
|
+
/\b(today|yesterday|tomorrow|this week|next week|last week|morning|afternoon|tonight)\b/gi
|
|
4575
|
+
], 8);
|
|
4576
|
+
const nextActions = extractMatches(text, [
|
|
4577
|
+
/(?:next|todo|follow[- ]?up|remaining|need to)\s*:?\s*([^.!?\n]{8,220})/gi
|
|
4578
|
+
]);
|
|
4579
|
+
const actors = uniq([
|
|
4580
|
+
row.agent_id,
|
|
4581
|
+
...extractMatches(text, [/\b(?:agent|employee|owner|assignee)[:= ]+([a-zA-Z][a-zA-Z0-9_-]{1,40})/gi], 5)
|
|
4582
|
+
], 6);
|
|
4583
|
+
const successSignals = milestones.length ? milestones : outcome === "success_signal" ? [clean(text, 180)] : [];
|
|
4584
|
+
const failureSignals = problems.length ? problems : outcome === "failure_signal" || row.has_error ? [clean(text, 180)] : [];
|
|
4585
|
+
const impact = successSignals.length && failureSignals.length ? "mixed" : failureSignals.length ? "negative" : successSignals.length ? "positive" : "neutral";
|
|
4586
|
+
const signalCount = goals.length + milestones.length + problems.length + decisions.length + nextActions.length;
|
|
4587
|
+
return {
|
|
4588
|
+
labeler: "deterministic",
|
|
4589
|
+
schemaVersion: 1,
|
|
4590
|
+
eventType,
|
|
4591
|
+
intention,
|
|
4592
|
+
outcome,
|
|
4593
|
+
impact,
|
|
4594
|
+
confidence: Math.min(0.95, 0.45 + signalCount * 0.08 + (intention ? 0.1 : 0) + (outcome ? 0.1 : 0)),
|
|
4595
|
+
goals,
|
|
4596
|
+
milestones,
|
|
4597
|
+
problems,
|
|
4598
|
+
decisions,
|
|
4599
|
+
actors,
|
|
4600
|
+
temporalAnchors,
|
|
4601
|
+
successSignals,
|
|
4602
|
+
failureSignals,
|
|
4603
|
+
nextActions,
|
|
4604
|
+
summary: clean(text, 280)
|
|
4605
|
+
};
|
|
4606
|
+
}
|
|
4607
|
+
function ontologyPayload(row) {
|
|
4608
|
+
const semantic = inferSemanticLabel(row);
|
|
4609
|
+
return {
|
|
4610
|
+
tool_name: row.tool_name,
|
|
4611
|
+
memory_version: row.version ?? null,
|
|
4612
|
+
domain: row.domain ?? null,
|
|
4613
|
+
trajectory: row.trajectory ? safeJson(row.trajectory) : null,
|
|
4614
|
+
semantic
|
|
4615
|
+
};
|
|
4616
|
+
}
|
|
4617
|
+
function safeJson(value) {
|
|
4618
|
+
try {
|
|
4619
|
+
return JSON.parse(value);
|
|
4620
|
+
} catch {
|
|
4621
|
+
return value.slice(0, 1e3);
|
|
4622
|
+
}
|
|
4623
|
+
}
|
|
4624
|
+
async function resolveClient(client) {
|
|
4625
|
+
if (client) return client;
|
|
4626
|
+
const { getClient: getClient2 } = await Promise.resolve().then(() => (init_database(), database_exports));
|
|
4627
|
+
return getClient2();
|
|
4628
|
+
}
|
|
4629
|
+
async function insertOntologyForMemory(row, client) {
|
|
4630
|
+
const db = await resolveClient(client);
|
|
4631
|
+
const occurredAt = row.timestamp;
|
|
4632
|
+
const sequence = Number(row.version ?? 0) || Math.floor(new Date(occurredAt).getTime() / 1e3);
|
|
4633
|
+
const eventType = inferOntologyEventType(row);
|
|
4634
|
+
const intention = inferIntention(row);
|
|
4635
|
+
const outcome = inferOutcome(row);
|
|
4636
|
+
const eventId = stableId2("event", row.id);
|
|
4637
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
4638
|
+
await db.execute({
|
|
4639
|
+
sql: `INSERT INTO agent_sessions (id, agent_id, project_name, started_at, last_event_at, event_count, properties)
|
|
4640
|
+
VALUES (?, ?, ?, ?, ?, 1, ?)
|
|
4641
|
+
ON CONFLICT(id) DO UPDATE SET last_event_at = MAX(last_event_at, excluded.last_event_at),
|
|
4642
|
+
event_count = event_count + 1`,
|
|
4643
|
+
args: [row.session_id, row.agent_id, row.project_name, occurredAt, occurredAt, JSON.stringify({ agent_role: row.agent_role })]
|
|
4644
|
+
});
|
|
4645
|
+
await db.execute({
|
|
4646
|
+
sql: `INSERT OR IGNORE INTO agent_events
|
|
4647
|
+
(id, event_type, occurred_at, sequence_index, actor_agent_id, agent_role, project_name,
|
|
4648
|
+
session_id, task_id, goal_id, parent_event_id, intention, outcome, evidence_memory_id,
|
|
4649
|
+
impact, payload, created_at)
|
|
4650
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NULL, NULL, ?, ?, ?, ?, ?, ?)`,
|
|
4651
|
+
args: [
|
|
4652
|
+
eventId,
|
|
4653
|
+
eventType,
|
|
4654
|
+
occurredAt,
|
|
4655
|
+
sequence,
|
|
4656
|
+
row.agent_id,
|
|
4657
|
+
row.agent_role,
|
|
4658
|
+
row.project_name,
|
|
4659
|
+
row.session_id,
|
|
4660
|
+
row.task_id ?? null,
|
|
4661
|
+
intention,
|
|
4662
|
+
outcome,
|
|
4663
|
+
row.id,
|
|
4664
|
+
row.has_error ? "negative" : outcome === "success_signal" ? "positive" : "neutral",
|
|
4665
|
+
JSON.stringify(ontologyPayload(row)),
|
|
4666
|
+
now
|
|
4667
|
+
]
|
|
4668
|
+
});
|
|
4669
|
+
const semantic = inferSemanticLabel(row);
|
|
4670
|
+
await db.execute({
|
|
4671
|
+
sql: `INSERT INTO agent_semantic_labels
|
|
4672
|
+
(id, source_memory_id, event_id, labeler, schema_version, confidence, labels, created_at, updated_at)
|
|
4673
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
4674
|
+
ON CONFLICT(id) DO UPDATE SET confidence = excluded.confidence,
|
|
4675
|
+
labels = excluded.labels, updated_at = excluded.updated_at`,
|
|
4676
|
+
args: [
|
|
4677
|
+
stableId2("semantic", row.id, semantic.labeler, semantic.schemaVersion),
|
|
4678
|
+
row.id,
|
|
4679
|
+
eventId,
|
|
4680
|
+
semantic.labeler,
|
|
4681
|
+
semantic.schemaVersion,
|
|
4682
|
+
semantic.confidence,
|
|
4683
|
+
JSON.stringify(semantic),
|
|
4684
|
+
now,
|
|
4685
|
+
now
|
|
4686
|
+
]
|
|
4687
|
+
});
|
|
4688
|
+
for (const statement of extractGoalCandidates(row)) {
|
|
4689
|
+
const goalId = stableId2("goal", row.project_name, statement.toLowerCase());
|
|
4690
|
+
await db.execute({
|
|
4691
|
+
sql: `INSERT INTO agent_goals
|
|
4692
|
+
(id, statement, owner_agent_id, project_name, status, priority, success_criteria,
|
|
4693
|
+
parent_goal_id, due_at, achieved_at, supersedes_id, created_at, updated_at, source_memory_id)
|
|
4694
|
+
VALUES (?, ?, ?, ?, 'open', 5, NULL, NULL, NULL, NULL, NULL, ?, ?, ?)
|
|
4695
|
+
ON CONFLICT(id) DO UPDATE SET updated_at = excluded.updated_at`,
|
|
4696
|
+
args: [goalId, statement, row.agent_id, row.project_name, now, now, row.id]
|
|
4697
|
+
});
|
|
4698
|
+
await db.execute({
|
|
4699
|
+
sql: `INSERT OR IGNORE INTO agent_goal_links
|
|
4700
|
+
(id, goal_id, link_type, target_id, target_type, created_at)
|
|
4701
|
+
VALUES (?, ?, 'evidence', ?, 'memory', ?)`,
|
|
4702
|
+
args: [stableId2("goal_link", goalId, row.id, "memory"), goalId, row.id, now]
|
|
4703
|
+
});
|
|
4704
|
+
await db.execute({
|
|
4705
|
+
sql: `INSERT OR IGNORE INTO agent_goal_links
|
|
4706
|
+
(id, goal_id, link_type, target_id, target_type, created_at)
|
|
4707
|
+
VALUES (?, ?, 'event', ?, 'event', ?)`,
|
|
4708
|
+
args: [stableId2("goal_link", goalId, eventId, "event"), goalId, eventId, now]
|
|
4709
|
+
});
|
|
4710
|
+
}
|
|
4711
|
+
}
|
|
4712
|
+
async function insertOntologyForBatch(rows, client) {
|
|
4713
|
+
const db = await resolveClient(client);
|
|
4714
|
+
let count = 0;
|
|
4715
|
+
for (const row of rows) {
|
|
4716
|
+
try {
|
|
4717
|
+
await insertOntologyForMemory(row, db);
|
|
4718
|
+
count++;
|
|
4719
|
+
} catch {
|
|
4720
|
+
}
|
|
4721
|
+
}
|
|
4722
|
+
return count;
|
|
4723
|
+
}
|
|
4724
|
+
var init_agentic_ontology = __esm({
|
|
4725
|
+
"src/lib/agentic-ontology.ts"() {
|
|
4726
|
+
"use strict";
|
|
4727
|
+
}
|
|
4728
|
+
});
|
|
4729
|
+
|
|
4227
4730
|
// src/lib/store.ts
|
|
4228
4731
|
var store_exports = {};
|
|
4229
4732
|
__export(store_exports, {
|
|
@@ -4567,6 +5070,11 @@ async function flushBatch() {
|
|
|
4567
5070
|
await insertMemoryCardsForBatch2(batch);
|
|
4568
5071
|
} catch {
|
|
4569
5072
|
}
|
|
5073
|
+
try {
|
|
5074
|
+
const { insertOntologyForBatch: insertOntologyForBatch2 } = await Promise.resolve().then(() => (init_agentic_ontology(), agentic_ontology_exports));
|
|
5075
|
+
await insertOntologyForBatch2(batch);
|
|
5076
|
+
} catch {
|
|
5077
|
+
}
|
|
4570
5078
|
schedulePostWriteMemoryHygiene(batch.map((row) => row.id));
|
|
4571
5079
|
_pendingRecords.splice(0, batch.length);
|
|
4572
5080
|
try {
|