@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
|
@@ -123,6 +123,11 @@ function normalizeAutoUpdate(raw) {
|
|
|
123
123
|
const userAU = raw.autoUpdate ?? {};
|
|
124
124
|
raw.autoUpdate = { ...defaultAU, ...userAU };
|
|
125
125
|
}
|
|
126
|
+
function normalizeOrchestration(raw) {
|
|
127
|
+
const defaultOrg = DEFAULT_CONFIG.orchestration;
|
|
128
|
+
const userOrg = raw.orchestration ?? {};
|
|
129
|
+
raw.orchestration = { ...defaultOrg, ...userOrg };
|
|
130
|
+
}
|
|
126
131
|
async function loadConfig() {
|
|
127
132
|
const dir = process.env.EXE_OS_DIR ?? process.env.EXE_MEM_DIR ?? EXE_AI_DIR;
|
|
128
133
|
await ensurePrivateDir(dir);
|
|
@@ -147,10 +152,15 @@ async function loadConfig() {
|
|
|
147
152
|
normalizeScalingRoadmap(migratedCfg);
|
|
148
153
|
normalizeSessionLifecycle(migratedCfg);
|
|
149
154
|
normalizeAutoUpdate(migratedCfg);
|
|
155
|
+
normalizeOrchestration(migratedCfg);
|
|
150
156
|
const config = { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db"), ...migratedCfg };
|
|
151
157
|
if (config.dbPath.startsWith("~")) {
|
|
152
158
|
config.dbPath = config.dbPath.replace(/^~/, os.homedir());
|
|
153
159
|
}
|
|
160
|
+
const envDbPath = path.join(dir, "memories.db");
|
|
161
|
+
if (process.env.EXE_OS_DIR && config.dbPath !== envDbPath && !existsSync2(config.dbPath) && existsSync2(envDbPath)) {
|
|
162
|
+
config.dbPath = envDbPath;
|
|
163
|
+
}
|
|
154
164
|
return config;
|
|
155
165
|
} catch {
|
|
156
166
|
return { ...DEFAULT_CONFIG, dbPath: path.join(dir, "memories.db") };
|
|
@@ -222,6 +232,10 @@ var init_config = __esm({
|
|
|
222
232
|
checkOnBoot: true,
|
|
223
233
|
autoInstall: false,
|
|
224
234
|
checkIntervalMs: 24 * 60 * 60 * 1e3
|
|
235
|
+
},
|
|
236
|
+
orchestration: {
|
|
237
|
+
phase: "phase_1_coo",
|
|
238
|
+
phaseSetBy: "default"
|
|
225
239
|
}
|
|
226
240
|
};
|
|
227
241
|
CONFIG_MIGRATIONS = [
|
|
@@ -1736,6 +1750,9 @@ function getClient() {
|
|
|
1736
1750
|
if (_daemonClient && _daemonClient._isDaemonActive()) {
|
|
1737
1751
|
return _daemonClient;
|
|
1738
1752
|
}
|
|
1753
|
+
if (!_resilientClient) {
|
|
1754
|
+
return _adapterClient;
|
|
1755
|
+
}
|
|
1739
1756
|
return _resilientClient;
|
|
1740
1757
|
}
|
|
1741
1758
|
async function initDaemonClient() {
|
|
@@ -2768,6 +2785,127 @@ async function ensureSchema() {
|
|
|
2768
2785
|
VALUES (new.rowid, new.content, new.subject, new.predicate, new.object);
|
|
2769
2786
|
END;
|
|
2770
2787
|
`);
|
|
2788
|
+
await client.executeMultiple(`
|
|
2789
|
+
CREATE TABLE IF NOT EXISTS agent_sessions (
|
|
2790
|
+
id TEXT PRIMARY KEY,
|
|
2791
|
+
agent_id TEXT NOT NULL,
|
|
2792
|
+
project_name TEXT,
|
|
2793
|
+
started_at TEXT NOT NULL,
|
|
2794
|
+
last_event_at TEXT NOT NULL,
|
|
2795
|
+
event_count INTEGER NOT NULL DEFAULT 0,
|
|
2796
|
+
properties TEXT DEFAULT '{}'
|
|
2797
|
+
);
|
|
2798
|
+
|
|
2799
|
+
CREATE INDEX IF NOT EXISTS idx_agent_sessions_agent_time
|
|
2800
|
+
ON agent_sessions(agent_id, started_at);
|
|
2801
|
+
|
|
2802
|
+
CREATE TABLE IF NOT EXISTS agent_goals (
|
|
2803
|
+
id TEXT PRIMARY KEY,
|
|
2804
|
+
statement TEXT NOT NULL,
|
|
2805
|
+
owner_agent_id TEXT,
|
|
2806
|
+
project_name TEXT,
|
|
2807
|
+
status TEXT NOT NULL DEFAULT 'open',
|
|
2808
|
+
priority INTEGER NOT NULL DEFAULT 5,
|
|
2809
|
+
success_criteria TEXT,
|
|
2810
|
+
parent_goal_id TEXT,
|
|
2811
|
+
due_at TEXT,
|
|
2812
|
+
achieved_at TEXT,
|
|
2813
|
+
supersedes_id TEXT,
|
|
2814
|
+
created_at TEXT NOT NULL,
|
|
2815
|
+
updated_at TEXT NOT NULL,
|
|
2816
|
+
source_memory_id TEXT
|
|
2817
|
+
);
|
|
2818
|
+
|
|
2819
|
+
CREATE INDEX IF NOT EXISTS idx_agent_goals_project_status
|
|
2820
|
+
ON agent_goals(project_name, status, priority);
|
|
2821
|
+
|
|
2822
|
+
CREATE TABLE IF NOT EXISTS agent_events (
|
|
2823
|
+
id TEXT PRIMARY KEY,
|
|
2824
|
+
event_type TEXT NOT NULL,
|
|
2825
|
+
occurred_at TEXT NOT NULL,
|
|
2826
|
+
sequence_index INTEGER NOT NULL,
|
|
2827
|
+
actor_agent_id TEXT,
|
|
2828
|
+
agent_role TEXT,
|
|
2829
|
+
project_name TEXT,
|
|
2830
|
+
session_id TEXT,
|
|
2831
|
+
task_id TEXT,
|
|
2832
|
+
goal_id TEXT,
|
|
2833
|
+
parent_event_id TEXT,
|
|
2834
|
+
intention TEXT,
|
|
2835
|
+
outcome TEXT,
|
|
2836
|
+
evidence_memory_id TEXT,
|
|
2837
|
+
impact TEXT,
|
|
2838
|
+
payload TEXT DEFAULT '{}',
|
|
2839
|
+
created_at TEXT NOT NULL
|
|
2840
|
+
);
|
|
2841
|
+
|
|
2842
|
+
CREATE INDEX IF NOT EXISTS idx_agent_events_time
|
|
2843
|
+
ON agent_events(occurred_at, sequence_index);
|
|
2844
|
+
|
|
2845
|
+
CREATE INDEX IF NOT EXISTS idx_agent_events_session_seq
|
|
2846
|
+
ON agent_events(session_id, sequence_index);
|
|
2847
|
+
|
|
2848
|
+
CREATE INDEX IF NOT EXISTS idx_agent_events_goal_time
|
|
2849
|
+
ON agent_events(goal_id, occurred_at);
|
|
2850
|
+
|
|
2851
|
+
CREATE INDEX IF NOT EXISTS idx_agent_events_memory
|
|
2852
|
+
ON agent_events(evidence_memory_id);
|
|
2853
|
+
|
|
2854
|
+
CREATE TABLE IF NOT EXISTS agent_goal_links (
|
|
2855
|
+
id TEXT PRIMARY KEY,
|
|
2856
|
+
goal_id TEXT NOT NULL,
|
|
2857
|
+
link_type TEXT NOT NULL,
|
|
2858
|
+
target_id TEXT NOT NULL,
|
|
2859
|
+
target_type TEXT NOT NULL,
|
|
2860
|
+
created_at TEXT NOT NULL
|
|
2861
|
+
);
|
|
2862
|
+
|
|
2863
|
+
CREATE INDEX IF NOT EXISTS idx_agent_goal_links_goal
|
|
2864
|
+
ON agent_goal_links(goal_id, target_type);
|
|
2865
|
+
|
|
2866
|
+
CREATE TABLE IF NOT EXISTS agent_semantic_labels (
|
|
2867
|
+
id TEXT PRIMARY KEY,
|
|
2868
|
+
source_memory_id TEXT NOT NULL,
|
|
2869
|
+
event_id TEXT,
|
|
2870
|
+
labeler TEXT NOT NULL,
|
|
2871
|
+
schema_version INTEGER NOT NULL DEFAULT 1,
|
|
2872
|
+
confidence REAL NOT NULL DEFAULT 0,
|
|
2873
|
+
labels TEXT NOT NULL,
|
|
2874
|
+
created_at TEXT NOT NULL,
|
|
2875
|
+
updated_at TEXT NOT NULL
|
|
2876
|
+
);
|
|
2877
|
+
|
|
2878
|
+
CREATE INDEX IF NOT EXISTS idx_agent_semantic_labels_memory
|
|
2879
|
+
ON agent_semantic_labels(source_memory_id, labeler);
|
|
2880
|
+
|
|
2881
|
+
CREATE INDEX IF NOT EXISTS idx_agent_semantic_labels_event
|
|
2882
|
+
ON agent_semantic_labels(event_id);
|
|
2883
|
+
|
|
2884
|
+
CREATE TABLE IF NOT EXISTS agent_reflection_checkpoints (
|
|
2885
|
+
id TEXT PRIMARY KEY,
|
|
2886
|
+
project_name TEXT,
|
|
2887
|
+
session_id TEXT,
|
|
2888
|
+
window_start_at TEXT NOT NULL,
|
|
2889
|
+
window_end_at TEXT NOT NULL,
|
|
2890
|
+
event_count INTEGER NOT NULL DEFAULT 0,
|
|
2891
|
+
goal_count INTEGER NOT NULL DEFAULT 0,
|
|
2892
|
+
success_count INTEGER NOT NULL DEFAULT 0,
|
|
2893
|
+
failure_count INTEGER NOT NULL DEFAULT 0,
|
|
2894
|
+
risk_count INTEGER NOT NULL DEFAULT 0,
|
|
2895
|
+
summary TEXT NOT NULL,
|
|
2896
|
+
learnings TEXT NOT NULL DEFAULT '[]',
|
|
2897
|
+
next_actions TEXT NOT NULL DEFAULT '[]',
|
|
2898
|
+
evidence_event_ids TEXT NOT NULL DEFAULT '[]',
|
|
2899
|
+
confidence REAL NOT NULL DEFAULT 0,
|
|
2900
|
+
created_at TEXT NOT NULL
|
|
2901
|
+
);
|
|
2902
|
+
|
|
2903
|
+
CREATE INDEX IF NOT EXISTS idx_agent_reflection_project_time
|
|
2904
|
+
ON agent_reflection_checkpoints(project_name, window_end_at);
|
|
2905
|
+
|
|
2906
|
+
CREATE INDEX IF NOT EXISTS idx_agent_reflection_session_time
|
|
2907
|
+
ON agent_reflection_checkpoints(session_id, window_end_at);
|
|
2908
|
+
`);
|
|
2771
2909
|
try {
|
|
2772
2910
|
await client.execute({
|
|
2773
2911
|
sql: `ALTER TABLE memories ADD COLUMN tier INTEGER DEFAULT 3`,
|
|
@@ -2917,7 +3055,7 @@ var init_database = __esm({
|
|
|
2917
3055
|
|
|
2918
3056
|
// src/lib/keychain.ts
|
|
2919
3057
|
import { readFile as readFile3, writeFile as writeFile3, unlink, mkdir as mkdir3, chmod as chmod2 } from "fs/promises";
|
|
2920
|
-
import { existsSync as existsSync6 } from "fs";
|
|
3058
|
+
import { existsSync as existsSync6, statSync as statSync2 } from "fs";
|
|
2921
3059
|
import { execSync as execSync4 } from "child_process";
|
|
2922
3060
|
import path7 from "path";
|
|
2923
3061
|
import os5 from "os";
|
|
@@ -2927,29 +3065,78 @@ function getKeyDir() {
|
|
|
2927
3065
|
function getKeyPath() {
|
|
2928
3066
|
return path7.join(getKeyDir(), "master.key");
|
|
2929
3067
|
}
|
|
2930
|
-
function
|
|
3068
|
+
function nativeKeychainAllowed() {
|
|
3069
|
+
return process.env.EXE_OS_DISABLE_NATIVE_KEYCHAIN !== "1";
|
|
3070
|
+
}
|
|
3071
|
+
function linuxSecretAvailable() {
|
|
3072
|
+
if (!nativeKeychainAllowed()) return false;
|
|
3073
|
+
if (process.platform !== "linux") return false;
|
|
3074
|
+
if (linuxSecretAvailability !== null) return linuxSecretAvailability;
|
|
3075
|
+
try {
|
|
3076
|
+
execSync4("command -v secret-tool >/dev/null 2>&1", { timeout: 1e3 });
|
|
3077
|
+
} catch {
|
|
3078
|
+
linuxSecretAvailability = false;
|
|
3079
|
+
return false;
|
|
3080
|
+
}
|
|
3081
|
+
try {
|
|
3082
|
+
execSync4("secret-tool search --all exe-os probe >/dev/null 2>&1", { timeout: 1e3 });
|
|
3083
|
+
linuxSecretAvailability = true;
|
|
3084
|
+
} catch {
|
|
3085
|
+
linuxSecretAvailability = false;
|
|
3086
|
+
}
|
|
3087
|
+
return linuxSecretAvailability;
|
|
3088
|
+
}
|
|
3089
|
+
function isRootOnlyTrustedServerKeyFile(keyPath) {
|
|
3090
|
+
if (process.platform !== "linux") return false;
|
|
3091
|
+
try {
|
|
3092
|
+
const uid = typeof os5.userInfo().uid === "number" ? os5.userInfo().uid : -1;
|
|
3093
|
+
const st = statSync2(keyPath);
|
|
3094
|
+
if (!st.isFile() || (st.mode & 63) !== 0) return false;
|
|
3095
|
+
if (uid === 0) return true;
|
|
3096
|
+
const exeOsDir = process.env.EXE_OS_DIR;
|
|
3097
|
+
return Boolean(exeOsDir && path7.resolve(keyPath).startsWith(path7.resolve(exeOsDir) + path7.sep));
|
|
3098
|
+
} catch {
|
|
3099
|
+
return false;
|
|
3100
|
+
}
|
|
3101
|
+
}
|
|
3102
|
+
function macKeychainGet(service = SERVICE) {
|
|
3103
|
+
if (!nativeKeychainAllowed()) return null;
|
|
2931
3104
|
if (process.platform !== "darwin") return null;
|
|
2932
3105
|
try {
|
|
2933
3106
|
return execSync4(
|
|
2934
|
-
`security find-generic-password -s "${
|
|
3107
|
+
`security find-generic-password -s "${service}" -a "${ACCOUNT}" -w 2>/dev/null`,
|
|
2935
3108
|
{ encoding: "utf-8", timeout: 5e3 }
|
|
2936
3109
|
).trim();
|
|
2937
3110
|
} catch {
|
|
2938
3111
|
return null;
|
|
2939
3112
|
}
|
|
2940
3113
|
}
|
|
2941
|
-
function macKeychainSet(value) {
|
|
3114
|
+
function macKeychainSet(value, service = SERVICE) {
|
|
3115
|
+
if (!nativeKeychainAllowed()) return false;
|
|
2942
3116
|
if (process.platform !== "darwin") return false;
|
|
2943
3117
|
try {
|
|
2944
3118
|
try {
|
|
2945
3119
|
execSync4(
|
|
2946
|
-
`security delete-generic-password -s "${
|
|
3120
|
+
`security delete-generic-password -s "${service}" -a "${ACCOUNT}" 2>/dev/null`,
|
|
2947
3121
|
{ timeout: 5e3 }
|
|
2948
3122
|
);
|
|
2949
3123
|
} catch {
|
|
2950
3124
|
}
|
|
2951
3125
|
execSync4(
|
|
2952
|
-
`security add-generic-password -s "${
|
|
3126
|
+
`security add-generic-password -s "${service}" -a "${ACCOUNT}" -w "${value}"`,
|
|
3127
|
+
{ timeout: 5e3 }
|
|
3128
|
+
);
|
|
3129
|
+
return true;
|
|
3130
|
+
} catch {
|
|
3131
|
+
return false;
|
|
3132
|
+
}
|
|
3133
|
+
}
|
|
3134
|
+
function macKeychainDelete(service = SERVICE) {
|
|
3135
|
+
if (!nativeKeychainAllowed()) return false;
|
|
3136
|
+
if (process.platform !== "darwin") return false;
|
|
3137
|
+
try {
|
|
3138
|
+
execSync4(
|
|
3139
|
+
`security delete-generic-password -s "${service}" -a "${ACCOUNT}" 2>/dev/null`,
|
|
2953
3140
|
{ timeout: 5e3 }
|
|
2954
3141
|
);
|
|
2955
3142
|
return true;
|
|
@@ -2957,22 +3144,35 @@ function macKeychainSet(value) {
|
|
|
2957
3144
|
return false;
|
|
2958
3145
|
}
|
|
2959
3146
|
}
|
|
2960
|
-
function linuxSecretGet() {
|
|
2961
|
-
if (
|
|
3147
|
+
function linuxSecretGet(service = SERVICE) {
|
|
3148
|
+
if (!linuxSecretAvailable()) return null;
|
|
2962
3149
|
try {
|
|
2963
3150
|
return execSync4(
|
|
2964
|
-
`secret-tool lookup service "${
|
|
3151
|
+
`secret-tool lookup service "${service}" account "${ACCOUNT}" 2>/dev/null`,
|
|
2965
3152
|
{ encoding: "utf-8", timeout: 5e3 }
|
|
2966
3153
|
).trim();
|
|
2967
3154
|
} catch {
|
|
2968
3155
|
return null;
|
|
2969
3156
|
}
|
|
2970
3157
|
}
|
|
2971
|
-
function linuxSecretSet(value) {
|
|
3158
|
+
function linuxSecretSet(value, service = SERVICE) {
|
|
3159
|
+
if (!linuxSecretAvailable()) return false;
|
|
3160
|
+
try {
|
|
3161
|
+
execSync4(
|
|
3162
|
+
`echo -n "${value}" | secret-tool store --label="exe-os master key" service "${service}" account "${ACCOUNT}" 2>/dev/null`,
|
|
3163
|
+
{ timeout: 5e3 }
|
|
3164
|
+
);
|
|
3165
|
+
return true;
|
|
3166
|
+
} catch {
|
|
3167
|
+
return false;
|
|
3168
|
+
}
|
|
3169
|
+
}
|
|
3170
|
+
function linuxSecretDelete(service = SERVICE) {
|
|
3171
|
+
if (!nativeKeychainAllowed()) return false;
|
|
2972
3172
|
if (process.platform !== "linux") return false;
|
|
2973
3173
|
try {
|
|
2974
3174
|
execSync4(
|
|
2975
|
-
`
|
|
3175
|
+
`secret-tool clear service "${service}" account "${ACCOUNT}" 2>/dev/null`,
|
|
2976
3176
|
{ timeout: 5e3 }
|
|
2977
3177
|
);
|
|
2978
3178
|
return true;
|
|
@@ -2981,6 +3181,7 @@ function linuxSecretSet(value) {
|
|
|
2981
3181
|
}
|
|
2982
3182
|
}
|
|
2983
3183
|
async function tryKeytar() {
|
|
3184
|
+
if (!nativeKeychainAllowed()) return null;
|
|
2984
3185
|
try {
|
|
2985
3186
|
return await import("keytar");
|
|
2986
3187
|
} catch {
|
|
@@ -3054,7 +3255,19 @@ async function writeMachineBoundFileFallback(b64) {
|
|
|
3054
3255
|
return "plaintext";
|
|
3055
3256
|
}
|
|
3056
3257
|
async function getMasterKey() {
|
|
3057
|
-
|
|
3258
|
+
let nativeValue = macKeychainGet() ?? linuxSecretGet();
|
|
3259
|
+
if (!nativeValue) {
|
|
3260
|
+
const legacyValue = macKeychainGet(LEGACY_SERVICE) ?? linuxSecretGet(LEGACY_SERVICE);
|
|
3261
|
+
if (legacyValue) {
|
|
3262
|
+
const migrated = macKeychainSet(legacyValue) || linuxSecretSet(legacyValue);
|
|
3263
|
+
if (migrated) {
|
|
3264
|
+
macKeychainDelete(LEGACY_SERVICE);
|
|
3265
|
+
linuxSecretDelete(LEGACY_SERVICE);
|
|
3266
|
+
process.stderr.write("[keychain] Migrated keychain service from exe-mem to exe-os.\n");
|
|
3267
|
+
}
|
|
3268
|
+
nativeValue = legacyValue;
|
|
3269
|
+
}
|
|
3270
|
+
}
|
|
3058
3271
|
if (nativeValue) {
|
|
3059
3272
|
return Buffer.from(nativeValue, "base64");
|
|
3060
3273
|
}
|
|
@@ -3062,12 +3275,17 @@ async function getMasterKey() {
|
|
|
3062
3275
|
if (keytar) {
|
|
3063
3276
|
try {
|
|
3064
3277
|
const keytarValue = await keytar.getPassword(SERVICE, ACCOUNT);
|
|
3065
|
-
|
|
3066
|
-
|
|
3278
|
+
const legacyKeytarValue = keytarValue ?? await keytar.getPassword(LEGACY_SERVICE, ACCOUNT);
|
|
3279
|
+
if (legacyKeytarValue) {
|
|
3280
|
+
const migrated = macKeychainSet(legacyKeytarValue) || linuxSecretSet(legacyKeytarValue);
|
|
3067
3281
|
if (migrated) {
|
|
3068
3282
|
process.stderr.write("[keychain] Migrated key from keytar to native keychain.\n");
|
|
3283
|
+
try {
|
|
3284
|
+
await keytar.deletePassword(LEGACY_SERVICE, ACCOUNT);
|
|
3285
|
+
} catch {
|
|
3286
|
+
}
|
|
3069
3287
|
}
|
|
3070
|
-
return Buffer.from(
|
|
3288
|
+
return Buffer.from(legacyKeytarValue, "base64");
|
|
3071
3289
|
}
|
|
3072
3290
|
} catch {
|
|
3073
3291
|
}
|
|
@@ -3092,7 +3310,7 @@ async function getMasterKey() {
|
|
|
3092
3310
|
const decrypted = decryptWithMachineKey(content, machineKey);
|
|
3093
3311
|
if (!decrypted) {
|
|
3094
3312
|
process.stderr.write(
|
|
3095
|
-
"[keychain] Key decryption failed \u2014 machine may have changed.\n Use your 24-word recovery phrase: exe-os
|
|
3313
|
+
"[keychain] Key decryption failed \u2014 machine may have changed.\n Use your 24-word recovery phrase during setup: exe-os setup\n"
|
|
3096
3314
|
);
|
|
3097
3315
|
return null;
|
|
3098
3316
|
}
|
|
@@ -3101,6 +3319,9 @@ async function getMasterKey() {
|
|
|
3101
3319
|
b64Value = content;
|
|
3102
3320
|
}
|
|
3103
3321
|
const key = Buffer.from(b64Value, "base64");
|
|
3322
|
+
if (!content.startsWith(ENCRYPTED_PREFIX) && isRootOnlyTrustedServerKeyFile(keyPath)) {
|
|
3323
|
+
return key;
|
|
3324
|
+
}
|
|
3104
3325
|
const migrated = macKeychainSet(b64Value) || linuxSecretSet(b64Value);
|
|
3105
3326
|
if (migrated) {
|
|
3106
3327
|
process.stderr.write("[keychain] Migrated key from file to native keychain.\n");
|
|
@@ -3128,12 +3349,14 @@ async function getMasterKey() {
|
|
|
3128
3349
|
return null;
|
|
3129
3350
|
}
|
|
3130
3351
|
}
|
|
3131
|
-
var SERVICE, ACCOUNT, ENCRYPTED_PREFIX;
|
|
3352
|
+
var SERVICE, LEGACY_SERVICE, ACCOUNT, linuxSecretAvailability, ENCRYPTED_PREFIX;
|
|
3132
3353
|
var init_keychain = __esm({
|
|
3133
3354
|
"src/lib/keychain.ts"() {
|
|
3134
3355
|
"use strict";
|
|
3135
|
-
SERVICE = "exe-
|
|
3356
|
+
SERVICE = "exe-os";
|
|
3357
|
+
LEGACY_SERVICE = "exe-mem";
|
|
3136
3358
|
ACCOUNT = "master-key";
|
|
3359
|
+
linuxSecretAvailability = null;
|
|
3137
3360
|
ENCRYPTED_PREFIX = "enc:";
|
|
3138
3361
|
}
|
|
3139
3362
|
});
|
|
@@ -3403,7 +3626,7 @@ __export(shard_manager_exports, {
|
|
|
3403
3626
|
shardExists: () => shardExists
|
|
3404
3627
|
});
|
|
3405
3628
|
import path8 from "path";
|
|
3406
|
-
import { existsSync as existsSync7, mkdirSync as mkdirSync3, readdirSync as readdirSync2, renameSync as renameSync3, statSync as
|
|
3629
|
+
import { existsSync as existsSync7, mkdirSync as mkdirSync3, readdirSync as readdirSync2, renameSync as renameSync3, statSync as statSync3 } from "fs";
|
|
3407
3630
|
import { createClient as createClient2 } from "@libsql/client";
|
|
3408
3631
|
function initShardManager(encryptionKey) {
|
|
3409
3632
|
_encryptionKey = encryptionKey;
|
|
@@ -3467,7 +3690,7 @@ async function auditShardHealth(options = {}) {
|
|
|
3467
3690
|
const shards = [];
|
|
3468
3691
|
for (const name of names) {
|
|
3469
3692
|
const dbPath = path8.join(SHARDS_DIR, `${name}.db`);
|
|
3470
|
-
const stat =
|
|
3693
|
+
const stat = statSync3(dbPath);
|
|
3471
3694
|
const item = {
|
|
3472
3695
|
name,
|
|
3473
3696
|
path: dbPath,
|
|
@@ -3720,7 +3943,7 @@ async function getReadyShardClient(projectName) {
|
|
|
3720
3943
|
_shardLastAccess.delete(safeName);
|
|
3721
3944
|
const dbPath = path8.join(SHARDS_DIR, `${safeName}.db`);
|
|
3722
3945
|
if (existsSync7(dbPath)) {
|
|
3723
|
-
const stat =
|
|
3946
|
+
const stat = statSync3(dbPath);
|
|
3724
3947
|
const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
3725
3948
|
const archivedPath = path8.join(SHARDS_DIR, `${safeName}.db.broken-${stamp}`);
|
|
3726
3949
|
renameSync3(dbPath, archivedPath);
|
|
@@ -3840,6 +4063,12 @@ var init_platform_procedures = __esm({
|
|
|
3840
4063
|
priority: "p0",
|
|
3841
4064
|
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."
|
|
3842
4065
|
},
|
|
4066
|
+
{
|
|
4067
|
+
title: "Customer orchestration maturity \u2014 recommend, never trap",
|
|
4068
|
+
domain: "workflow",
|
|
4069
|
+
priority: "p1",
|
|
4070
|
+
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."
|
|
4071
|
+
},
|
|
3843
4072
|
{
|
|
3844
4073
|
title: "Single dispatch path \u2014 create_task only",
|
|
3845
4074
|
domain: "workflow",
|
|
@@ -3898,6 +4127,12 @@ var init_platform_procedures = __esm({
|
|
|
3898
4127
|
priority: "p0",
|
|
3899
4128
|
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."
|
|
3900
4129
|
},
|
|
4130
|
+
{
|
|
4131
|
+
title: "Commit discipline \u2014 never leave verified work floating",
|
|
4132
|
+
domain: "workflow",
|
|
4133
|
+
priority: "p1",
|
|
4134
|
+
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."
|
|
4135
|
+
},
|
|
3901
4136
|
{
|
|
3902
4137
|
title: "Desktop and TUI are the same product",
|
|
3903
4138
|
domain: "architecture",
|
|
@@ -4215,6 +4450,274 @@ var init_memory_cards = __esm({
|
|
|
4215
4450
|
}
|
|
4216
4451
|
});
|
|
4217
4452
|
|
|
4453
|
+
// src/lib/agentic-ontology.ts
|
|
4454
|
+
var agentic_ontology_exports = {};
|
|
4455
|
+
__export(agentic_ontology_exports, {
|
|
4456
|
+
clean: () => clean,
|
|
4457
|
+
extractGoalCandidates: () => extractGoalCandidates,
|
|
4458
|
+
inferIntention: () => inferIntention,
|
|
4459
|
+
inferOntologyEventType: () => inferOntologyEventType,
|
|
4460
|
+
inferOutcome: () => inferOutcome,
|
|
4461
|
+
inferSemanticLabel: () => inferSemanticLabel,
|
|
4462
|
+
insertOntologyForBatch: () => insertOntologyForBatch,
|
|
4463
|
+
insertOntologyForMemory: () => insertOntologyForMemory,
|
|
4464
|
+
ontologyPayload: () => ontologyPayload,
|
|
4465
|
+
stableId: () => stableId2
|
|
4466
|
+
});
|
|
4467
|
+
import { createHash as createHash3 } from "crypto";
|
|
4468
|
+
function stableId2(...parts) {
|
|
4469
|
+
return createHash3("sha256").update(parts.map((p) => String(p ?? "")).join("::")).digest("hex").slice(0, 32);
|
|
4470
|
+
}
|
|
4471
|
+
function clean(text, max = 240) {
|
|
4472
|
+
return text.replace(/\u0000/g, "").replace(/```[\s\S]*?```/g, " ").replace(/\s+/g, " ").trim().slice(0, max);
|
|
4473
|
+
}
|
|
4474
|
+
function inferOntologyEventType(row) {
|
|
4475
|
+
const lower = row.raw_text.toLowerCase();
|
|
4476
|
+
if (row.has_error) return "error";
|
|
4477
|
+
if (/\b(done|complete|completed|fixed|resolved|shipped|deployed|pushed|published)\b/.test(lower)) return "milestone";
|
|
4478
|
+
if (/\b(blocked|failed|error|bug|regression|broken)\b/.test(lower)) return "problem";
|
|
4479
|
+
if (/\b(decided|decision|adr|we chose|approved|rejected)\b/.test(lower)) return "decision";
|
|
4480
|
+
if (/\b(goal|need to|we need|want to|trying to|objective)\b/.test(lower)) return "goal_signal";
|
|
4481
|
+
if (["Bash", "Read", "Edit", "Write", "Grep", "Glob"].includes(row.tool_name)) return "tool_action";
|
|
4482
|
+
if (row.tool_name.startsWith("memory_card")) return "memory_card";
|
|
4483
|
+
return "memory_observation";
|
|
4484
|
+
}
|
|
4485
|
+
function inferIntention(row) {
|
|
4486
|
+
if (row.intent) return clean(row.intent, 220);
|
|
4487
|
+
const text = clean(row.raw_text, 1e3);
|
|
4488
|
+
const patterns = [
|
|
4489
|
+
/(?: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,
|
|
4490
|
+
/(?:so that|in order to)\s+([^.!?\n]{8,220})/i,
|
|
4491
|
+
/(?:task|plan):\s*([^.!?\n]{8,220})/i
|
|
4492
|
+
];
|
|
4493
|
+
for (const p of patterns) {
|
|
4494
|
+
const m = text.match(p);
|
|
4495
|
+
if (m?.[1]) return clean(m[1], 220);
|
|
4496
|
+
}
|
|
4497
|
+
if (["Bash", "Read", "Edit", "Write", "Grep", "Glob"].includes(row.tool_name)) {
|
|
4498
|
+
return `${row.tool_name} during ${row.project_name}`;
|
|
4499
|
+
}
|
|
4500
|
+
return null;
|
|
4501
|
+
}
|
|
4502
|
+
function inferOutcome(row) {
|
|
4503
|
+
if (row.outcome) return clean(row.outcome, 220);
|
|
4504
|
+
if (row.has_error) return "error";
|
|
4505
|
+
const lower = row.raw_text.toLowerCase();
|
|
4506
|
+
if (/\b(done|complete|completed|fixed|resolved|shipped|deployed|pushed|published|passed)\b/.test(lower)) return "success_signal";
|
|
4507
|
+
if (/\b(blocked|failed|error|regression|broken|not working|could not)\b/.test(lower)) return "failure_signal";
|
|
4508
|
+
if (/\b(warning|risk|concern|caveat)\b/.test(lower)) return "risk_signal";
|
|
4509
|
+
return null;
|
|
4510
|
+
}
|
|
4511
|
+
function extractGoalCandidates(row) {
|
|
4512
|
+
const text = clean(row.raw_text, 1600);
|
|
4513
|
+
const patterns = [
|
|
4514
|
+
/(?: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,
|
|
4515
|
+
/(?:success means|success criteria|so that)\s+([^.!?\n]{12,220})/gi
|
|
4516
|
+
];
|
|
4517
|
+
const out = [];
|
|
4518
|
+
for (const pattern of patterns) {
|
|
4519
|
+
for (const m of text.matchAll(pattern)) {
|
|
4520
|
+
const candidate = clean(m[1] ?? "", 220);
|
|
4521
|
+
if (candidate.length >= 12 && !out.some((x) => x.toLowerCase() === candidate.toLowerCase())) out.push(candidate);
|
|
4522
|
+
if (out.length >= 3) return out;
|
|
4523
|
+
}
|
|
4524
|
+
}
|
|
4525
|
+
return out;
|
|
4526
|
+
}
|
|
4527
|
+
function uniq(values, max = 6) {
|
|
4528
|
+
const out = [];
|
|
4529
|
+
for (const value of values.map((v) => clean(v, 220)).filter(Boolean)) {
|
|
4530
|
+
if (!out.some((x) => x.toLowerCase() === value.toLowerCase())) out.push(value);
|
|
4531
|
+
if (out.length >= max) break;
|
|
4532
|
+
}
|
|
4533
|
+
return out;
|
|
4534
|
+
}
|
|
4535
|
+
function extractMatches(text, patterns, max = 5) {
|
|
4536
|
+
const out = [];
|
|
4537
|
+
for (const pattern of patterns) {
|
|
4538
|
+
for (const match of text.matchAll(pattern)) {
|
|
4539
|
+
const value = match[1] ?? match[0];
|
|
4540
|
+
if (value) out.push(value);
|
|
4541
|
+
if (out.length >= max) return uniq(out, max);
|
|
4542
|
+
}
|
|
4543
|
+
}
|
|
4544
|
+
return uniq(out, max);
|
|
4545
|
+
}
|
|
4546
|
+
function inferSemanticLabel(row) {
|
|
4547
|
+
const text = clean(row.raw_text, 2400);
|
|
4548
|
+
const eventType = inferOntologyEventType(row);
|
|
4549
|
+
const intention = inferIntention(row);
|
|
4550
|
+
const outcome = inferOutcome(row);
|
|
4551
|
+
const goals = extractGoalCandidates(row);
|
|
4552
|
+
const milestones = extractMatches(text, [
|
|
4553
|
+
/\b(?:completed|finished|fixed|resolved|shipped|deployed|published|pushed|passed)\b([^.!?\n]{0,180})/gi,
|
|
4554
|
+
/(?:milestone|done):\s*([^.!?\n]{8,220})/gi
|
|
4555
|
+
]);
|
|
4556
|
+
const problems = extractMatches(text, [
|
|
4557
|
+
/\b(?:blocked by|failed because|bug|regression|broken|not working|error)\b([^.!?\n]{0,180})/gi,
|
|
4558
|
+
/(?:problem|issue|risk):\s*([^.!?\n]{8,220})/gi
|
|
4559
|
+
]);
|
|
4560
|
+
const decisions = extractMatches(text, [
|
|
4561
|
+
/(?:decided|decision|adr|we chose|approved|rejected)\s+([^.!?\n]{8,220})/gi
|
|
4562
|
+
]);
|
|
4563
|
+
const temporalAnchors = extractMatches(text, [
|
|
4564
|
+
/\b(\d{4}-\d{2}-\d{2}(?:[T ][0-9:.+-Z]+)?)\b/g,
|
|
4565
|
+
/\b(today|yesterday|tomorrow|this week|next week|last week|morning|afternoon|tonight)\b/gi
|
|
4566
|
+
], 8);
|
|
4567
|
+
const nextActions = extractMatches(text, [
|
|
4568
|
+
/(?:next|todo|follow[- ]?up|remaining|need to)\s*:?\s*([^.!?\n]{8,220})/gi
|
|
4569
|
+
]);
|
|
4570
|
+
const actors = uniq([
|
|
4571
|
+
row.agent_id,
|
|
4572
|
+
...extractMatches(text, [/\b(?:agent|employee|owner|assignee)[:= ]+([a-zA-Z][a-zA-Z0-9_-]{1,40})/gi], 5)
|
|
4573
|
+
], 6);
|
|
4574
|
+
const successSignals = milestones.length ? milestones : outcome === "success_signal" ? [clean(text, 180)] : [];
|
|
4575
|
+
const failureSignals = problems.length ? problems : outcome === "failure_signal" || row.has_error ? [clean(text, 180)] : [];
|
|
4576
|
+
const impact = successSignals.length && failureSignals.length ? "mixed" : failureSignals.length ? "negative" : successSignals.length ? "positive" : "neutral";
|
|
4577
|
+
const signalCount = goals.length + milestones.length + problems.length + decisions.length + nextActions.length;
|
|
4578
|
+
return {
|
|
4579
|
+
labeler: "deterministic",
|
|
4580
|
+
schemaVersion: 1,
|
|
4581
|
+
eventType,
|
|
4582
|
+
intention,
|
|
4583
|
+
outcome,
|
|
4584
|
+
impact,
|
|
4585
|
+
confidence: Math.min(0.95, 0.45 + signalCount * 0.08 + (intention ? 0.1 : 0) + (outcome ? 0.1 : 0)),
|
|
4586
|
+
goals,
|
|
4587
|
+
milestones,
|
|
4588
|
+
problems,
|
|
4589
|
+
decisions,
|
|
4590
|
+
actors,
|
|
4591
|
+
temporalAnchors,
|
|
4592
|
+
successSignals,
|
|
4593
|
+
failureSignals,
|
|
4594
|
+
nextActions,
|
|
4595
|
+
summary: clean(text, 280)
|
|
4596
|
+
};
|
|
4597
|
+
}
|
|
4598
|
+
function ontologyPayload(row) {
|
|
4599
|
+
const semantic = inferSemanticLabel(row);
|
|
4600
|
+
return {
|
|
4601
|
+
tool_name: row.tool_name,
|
|
4602
|
+
memory_version: row.version ?? null,
|
|
4603
|
+
domain: row.domain ?? null,
|
|
4604
|
+
trajectory: row.trajectory ? safeJson(row.trajectory) : null,
|
|
4605
|
+
semantic
|
|
4606
|
+
};
|
|
4607
|
+
}
|
|
4608
|
+
function safeJson(value) {
|
|
4609
|
+
try {
|
|
4610
|
+
return JSON.parse(value);
|
|
4611
|
+
} catch {
|
|
4612
|
+
return value.slice(0, 1e3);
|
|
4613
|
+
}
|
|
4614
|
+
}
|
|
4615
|
+
async function resolveClient(client) {
|
|
4616
|
+
if (client) return client;
|
|
4617
|
+
const { getClient: getClient2 } = await Promise.resolve().then(() => (init_database(), database_exports));
|
|
4618
|
+
return getClient2();
|
|
4619
|
+
}
|
|
4620
|
+
async function insertOntologyForMemory(row, client) {
|
|
4621
|
+
const db = await resolveClient(client);
|
|
4622
|
+
const occurredAt = row.timestamp;
|
|
4623
|
+
const sequence = Number(row.version ?? 0) || Math.floor(new Date(occurredAt).getTime() / 1e3);
|
|
4624
|
+
const eventType = inferOntologyEventType(row);
|
|
4625
|
+
const intention = inferIntention(row);
|
|
4626
|
+
const outcome = inferOutcome(row);
|
|
4627
|
+
const eventId = stableId2("event", row.id);
|
|
4628
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
4629
|
+
await db.execute({
|
|
4630
|
+
sql: `INSERT INTO agent_sessions (id, agent_id, project_name, started_at, last_event_at, event_count, properties)
|
|
4631
|
+
VALUES (?, ?, ?, ?, ?, 1, ?)
|
|
4632
|
+
ON CONFLICT(id) DO UPDATE SET last_event_at = MAX(last_event_at, excluded.last_event_at),
|
|
4633
|
+
event_count = event_count + 1`,
|
|
4634
|
+
args: [row.session_id, row.agent_id, row.project_name, occurredAt, occurredAt, JSON.stringify({ agent_role: row.agent_role })]
|
|
4635
|
+
});
|
|
4636
|
+
await db.execute({
|
|
4637
|
+
sql: `INSERT OR IGNORE INTO agent_events
|
|
4638
|
+
(id, event_type, occurred_at, sequence_index, actor_agent_id, agent_role, project_name,
|
|
4639
|
+
session_id, task_id, goal_id, parent_event_id, intention, outcome, evidence_memory_id,
|
|
4640
|
+
impact, payload, created_at)
|
|
4641
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, NULL, NULL, ?, ?, ?, ?, ?, ?)`,
|
|
4642
|
+
args: [
|
|
4643
|
+
eventId,
|
|
4644
|
+
eventType,
|
|
4645
|
+
occurredAt,
|
|
4646
|
+
sequence,
|
|
4647
|
+
row.agent_id,
|
|
4648
|
+
row.agent_role,
|
|
4649
|
+
row.project_name,
|
|
4650
|
+
row.session_id,
|
|
4651
|
+
row.task_id ?? null,
|
|
4652
|
+
intention,
|
|
4653
|
+
outcome,
|
|
4654
|
+
row.id,
|
|
4655
|
+
row.has_error ? "negative" : outcome === "success_signal" ? "positive" : "neutral",
|
|
4656
|
+
JSON.stringify(ontologyPayload(row)),
|
|
4657
|
+
now
|
|
4658
|
+
]
|
|
4659
|
+
});
|
|
4660
|
+
const semantic = inferSemanticLabel(row);
|
|
4661
|
+
await db.execute({
|
|
4662
|
+
sql: `INSERT INTO agent_semantic_labels
|
|
4663
|
+
(id, source_memory_id, event_id, labeler, schema_version, confidence, labels, created_at, updated_at)
|
|
4664
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
4665
|
+
ON CONFLICT(id) DO UPDATE SET confidence = excluded.confidence,
|
|
4666
|
+
labels = excluded.labels, updated_at = excluded.updated_at`,
|
|
4667
|
+
args: [
|
|
4668
|
+
stableId2("semantic", row.id, semantic.labeler, semantic.schemaVersion),
|
|
4669
|
+
row.id,
|
|
4670
|
+
eventId,
|
|
4671
|
+
semantic.labeler,
|
|
4672
|
+
semantic.schemaVersion,
|
|
4673
|
+
semantic.confidence,
|
|
4674
|
+
JSON.stringify(semantic),
|
|
4675
|
+
now,
|
|
4676
|
+
now
|
|
4677
|
+
]
|
|
4678
|
+
});
|
|
4679
|
+
for (const statement of extractGoalCandidates(row)) {
|
|
4680
|
+
const goalId = stableId2("goal", row.project_name, statement.toLowerCase());
|
|
4681
|
+
await db.execute({
|
|
4682
|
+
sql: `INSERT INTO agent_goals
|
|
4683
|
+
(id, statement, owner_agent_id, project_name, status, priority, success_criteria,
|
|
4684
|
+
parent_goal_id, due_at, achieved_at, supersedes_id, created_at, updated_at, source_memory_id)
|
|
4685
|
+
VALUES (?, ?, ?, ?, 'open', 5, NULL, NULL, NULL, NULL, NULL, ?, ?, ?)
|
|
4686
|
+
ON CONFLICT(id) DO UPDATE SET updated_at = excluded.updated_at`,
|
|
4687
|
+
args: [goalId, statement, row.agent_id, row.project_name, now, now, row.id]
|
|
4688
|
+
});
|
|
4689
|
+
await db.execute({
|
|
4690
|
+
sql: `INSERT OR IGNORE INTO agent_goal_links
|
|
4691
|
+
(id, goal_id, link_type, target_id, target_type, created_at)
|
|
4692
|
+
VALUES (?, ?, 'evidence', ?, 'memory', ?)`,
|
|
4693
|
+
args: [stableId2("goal_link", goalId, row.id, "memory"), goalId, row.id, now]
|
|
4694
|
+
});
|
|
4695
|
+
await db.execute({
|
|
4696
|
+
sql: `INSERT OR IGNORE INTO agent_goal_links
|
|
4697
|
+
(id, goal_id, link_type, target_id, target_type, created_at)
|
|
4698
|
+
VALUES (?, ?, 'event', ?, 'event', ?)`,
|
|
4699
|
+
args: [stableId2("goal_link", goalId, eventId, "event"), goalId, eventId, now]
|
|
4700
|
+
});
|
|
4701
|
+
}
|
|
4702
|
+
}
|
|
4703
|
+
async function insertOntologyForBatch(rows, client) {
|
|
4704
|
+
const db = await resolveClient(client);
|
|
4705
|
+
let count = 0;
|
|
4706
|
+
for (const row of rows) {
|
|
4707
|
+
try {
|
|
4708
|
+
await insertOntologyForMemory(row, db);
|
|
4709
|
+
count++;
|
|
4710
|
+
} catch {
|
|
4711
|
+
}
|
|
4712
|
+
}
|
|
4713
|
+
return count;
|
|
4714
|
+
}
|
|
4715
|
+
var init_agentic_ontology = __esm({
|
|
4716
|
+
"src/lib/agentic-ontology.ts"() {
|
|
4717
|
+
"use strict";
|
|
4718
|
+
}
|
|
4719
|
+
});
|
|
4720
|
+
|
|
4218
4721
|
// src/lib/store.ts
|
|
4219
4722
|
var store_exports = {};
|
|
4220
4723
|
__export(store_exports, {
|
|
@@ -4558,6 +5061,11 @@ async function flushBatch() {
|
|
|
4558
5061
|
await insertMemoryCardsForBatch2(batch);
|
|
4559
5062
|
} catch {
|
|
4560
5063
|
}
|
|
5064
|
+
try {
|
|
5065
|
+
const { insertOntologyForBatch: insertOntologyForBatch2 } = await Promise.resolve().then(() => (init_agentic_ontology(), agentic_ontology_exports));
|
|
5066
|
+
await insertOntologyForBatch2(batch);
|
|
5067
|
+
} catch {
|
|
5068
|
+
}
|
|
4561
5069
|
schedulePostWriteMemoryHygiene(batch.map((row) => row.id));
|
|
4562
5070
|
_pendingRecords.splice(0, batch.length);
|
|
4563
5071
|
try {
|