@askexenow/exe-os 0.9.60 → 0.9.62
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 +62 -13
- package/dist/bin/backfill-conversations.js +282 -7
- package/dist/bin/backfill-responses.js +282 -7
- package/dist/bin/backfill-vectors.js +119 -7
- package/dist/bin/cc-doctor.js +376 -0
- package/dist/bin/cleanup-stale-review-tasks.js +282 -7
- package/dist/bin/cli.js +455 -77
- package/dist/bin/customer-readiness.js +33 -0
- package/dist/bin/exe-agent-config.js +2 -2
- package/dist/bin/exe-agent.js +3 -3
- package/dist/bin/exe-assign.js +282 -7
- package/dist/bin/exe-boot.js +125 -13
- package/dist/bin/exe-call.js +3 -3
- package/dist/bin/exe-cloud.js +2 -2
- package/dist/bin/exe-dispatch.js +282 -7
- package/dist/bin/exe-doctor.js +119 -7
- package/dist/bin/exe-export-behaviors.js +282 -7
- package/dist/bin/exe-forget.js +336 -7
- package/dist/bin/exe-gateway.js +282 -7
- package/dist/bin/exe-heartbeat.js +284 -9
- package/dist/bin/exe-kill.js +282 -7
- package/dist/bin/exe-launch-agent.js +282 -7
- package/dist/bin/exe-link.js +121 -9
- package/dist/bin/exe-new-employee.js +50 -21
- package/dist/bin/exe-pending-messages.js +282 -7
- package/dist/bin/exe-pending-notifications.js +282 -7
- package/dist/bin/exe-pending-reviews.js +282 -7
- package/dist/bin/exe-rename.js +282 -7
- package/dist/bin/exe-review.js +282 -7
- package/dist/bin/exe-search.js +306 -8
- package/dist/bin/exe-session-cleanup.js +282 -7
- package/dist/bin/exe-settings.js +2 -2
- package/dist/bin/exe-start-codex.js +326 -21
- package/dist/bin/exe-start-opencode.js +304 -10
- package/dist/bin/exe-status.js +282 -7
- package/dist/bin/exe-team.js +282 -7
- package/dist/bin/git-sweep.js +282 -7
- package/dist/bin/graph-backfill.js +282 -7
- package/dist/bin/graph-export.js +282 -7
- package/dist/bin/install.js +58 -33
- package/dist/bin/intercom-check.js +282 -7
- package/dist/bin/pre-build-guard.js +98 -0
- package/dist/bin/scan-tasks.js +282 -7
- package/dist/bin/setup.js +122 -10
- package/dist/bin/shard-migrate.js +282 -7
- package/dist/bin/stack-update.js +79 -11
- package/dist/bin/update.js +2 -2
- package/dist/gateway/index.js +288 -13
- package/dist/hooks/bug-report-worker.js +282 -7
- package/dist/hooks/codex-stop-task-finalizer.js +282 -7
- package/dist/hooks/commit-complete.js +282 -7
- package/dist/hooks/error-recall.js +306 -8
- package/dist/hooks/exe-heartbeat-hook.js +2 -2
- package/dist/hooks/ingest-worker.js +2 -2
- package/dist/hooks/ingest.js +282 -7
- package/dist/hooks/instructions-loaded.js +282 -7
- package/dist/hooks/notification.js +282 -7
- package/dist/hooks/post-compact.js +282 -7
- package/dist/hooks/post-tool-combined.js +306 -8
- package/dist/hooks/pre-compact.js +282 -7
- package/dist/hooks/pre-tool-use.js +282 -7
- package/dist/hooks/prompt-submit.js +306 -8
- package/dist/hooks/session-end.js +282 -7
- package/dist/hooks/session-start.js +308 -10
- package/dist/hooks/stop.js +282 -7
- package/dist/hooks/subagent-stop.js +282 -7
- package/dist/hooks/summary-worker.js +125 -13
- package/dist/index.js +288 -13
- package/dist/lib/agent-config.js +2 -2
- package/dist/lib/cloud-sync.js +121 -9
- package/dist/lib/config.js +2 -2
- package/dist/lib/consolidation.js +2 -2
- package/dist/lib/database.js +115 -3
- package/dist/lib/db-daemon-client.js +2 -2
- package/dist/lib/db.js +115 -3
- package/dist/lib/device-registry.js +115 -3
- package/dist/lib/embedder.js +2 -2
- package/dist/lib/employee-templates.js +3 -3
- package/dist/lib/employees.js +2 -2
- package/dist/lib/exe-daemon-client.js +2 -2
- package/dist/lib/exe-daemon.js +339 -31
- package/dist/lib/hybrid-search.js +306 -8
- package/dist/lib/identity.js +2 -2
- package/dist/lib/license.js +2 -2
- package/dist/lib/messaging.js +2 -2
- package/dist/lib/reminders.js +2 -2
- package/dist/lib/schedules.js +119 -7
- package/dist/lib/skill-learning.js +2 -2
- package/dist/lib/store.js +282 -7
- package/dist/lib/task-router.js +2 -2
- package/dist/lib/tasks.js +2 -2
- package/dist/lib/tmux-routing.js +2 -2
- package/dist/lib/token-spend.js +2 -2
- package/dist/mcp/server.js +339 -31
- package/dist/mcp/tools/complete-reminder.js +2 -2
- package/dist/mcp/tools/create-reminder.js +2 -2
- package/dist/mcp/tools/create-task.js +2 -2
- package/dist/mcp/tools/deactivate-behavior.js +2 -2
- package/dist/mcp/tools/list-reminders.js +2 -2
- package/dist/mcp/tools/list-tasks.js +2 -2
- package/dist/mcp/tools/send-message.js +2 -2
- package/dist/mcp/tools/update-task.js +2 -2
- package/dist/runtime/index.js +282 -7
- package/dist/tui/App.js +290 -15
- package/package.json +3 -2
- package/stack.release.json +23 -7
package/dist/bin/exe-call.js
CHANGED
|
@@ -90,8 +90,8 @@ var init_config = __esm({
|
|
|
90
90
|
rerankerAutoTrigger: {
|
|
91
91
|
enabled: true,
|
|
92
92
|
broadQueryMinCardinality: 5e4,
|
|
93
|
-
fetchTopK:
|
|
94
|
-
returnTopK:
|
|
93
|
+
fetchTopK: 200,
|
|
94
|
+
returnTopK: 20
|
|
95
95
|
}
|
|
96
96
|
},
|
|
97
97
|
graphRagEnabled: true,
|
|
@@ -400,7 +400,7 @@ var init_platform_procedures = __esm({
|
|
|
400
400
|
title: "MCP tools \u2014 advanced (triggers, skills, orchestration)",
|
|
401
401
|
domain: "tool-use",
|
|
402
402
|
priority: "p1",
|
|
403
|
-
content: "create_trigger: set up a scheduled recurring agent job (cron). list_triggers: view active triggers. load_skill: load a slash-command skill dynamically. apply_starter_pack: import a pre-built behavior + identity pack for a role. export_orchestration: export full org state (tasks, behaviors, identities) as portable JSON. import_orchestration: import org state into a new instance. deploy_client: deploy a customer client instance. query_company_brain: unified RAG query across all company knowledge. create_reminder: set a text reminder (shown in boot brief). list_reminders: view pending reminders. complete_reminder: mark a reminder done.
|
|
403
|
+
content: "create_trigger: set up a scheduled recurring agent job (cron). list_triggers: view active triggers. load_skill: load a slash-command skill dynamically. apply_starter_pack: import a pre-built behavior + identity pack for a role. export_orchestration: export full org state (tasks, behaviors, identities) as portable JSON. import_orchestration: import org state into a new instance. deploy_client: deploy a customer client instance. query_company_brain: unified RAG query across all company knowledge. create_reminder: set a text reminder (shown in boot brief). list_reminders: view pending reminders. complete_reminder: mark a reminder done. company_procedure: manage customer-owned company procedures (Layer 0; actions: store, list, deactivate). Legacy aliases: global_procedure, store_global_procedure, list_global_procedures, deactivate_global_procedure."
|
|
404
404
|
}
|
|
405
405
|
];
|
|
406
406
|
PLATFORM_PROCEDURE_TITLES = new Set(
|
package/dist/bin/exe-cloud.js
CHANGED
package/dist/bin/exe-dispatch.js
CHANGED
|
@@ -550,8 +550,8 @@ var init_config = __esm({
|
|
|
550
550
|
rerankerAutoTrigger: {
|
|
551
551
|
enabled: true,
|
|
552
552
|
broadQueryMinCardinality: 5e4,
|
|
553
|
-
fetchTopK:
|
|
554
|
-
returnTopK:
|
|
553
|
+
fetchTopK: 200,
|
|
554
|
+
returnTopK: 20
|
|
555
555
|
}
|
|
556
556
|
},
|
|
557
557
|
graphRagEnabled: true,
|
|
@@ -3083,7 +3083,7 @@ async function ensureSchema() {
|
|
|
3083
3083
|
ON session_kills(agent_id);
|
|
3084
3084
|
`);
|
|
3085
3085
|
await client.execute(`
|
|
3086
|
-
CREATE TABLE IF NOT EXISTS
|
|
3086
|
+
CREATE TABLE IF NOT EXISTS company_procedures (
|
|
3087
3087
|
id TEXT PRIMARY KEY,
|
|
3088
3088
|
title TEXT NOT NULL,
|
|
3089
3089
|
content TEXT NOT NULL,
|
|
@@ -3094,6 +3094,73 @@ async function ensureSchema() {
|
|
|
3094
3094
|
updated_at TEXT NOT NULL
|
|
3095
3095
|
)
|
|
3096
3096
|
`);
|
|
3097
|
+
const legacyProcedureObject = await client.execute({
|
|
3098
|
+
sql: "SELECT type FROM sqlite_master WHERE name = 'global_procedures'",
|
|
3099
|
+
args: []
|
|
3100
|
+
});
|
|
3101
|
+
const legacyProcedureType = legacyProcedureObject.rows[0]?.type == null ? null : String(legacyProcedureObject.rows[0].type);
|
|
3102
|
+
if (legacyProcedureType === "table") {
|
|
3103
|
+
await client.execute(`
|
|
3104
|
+
INSERT OR IGNORE INTO company_procedures
|
|
3105
|
+
(id, title, content, priority, domain, active, created_at, updated_at)
|
|
3106
|
+
SELECT id, title, content, priority, domain, active, created_at, updated_at
|
|
3107
|
+
FROM global_procedures
|
|
3108
|
+
`);
|
|
3109
|
+
await client.executeMultiple(`
|
|
3110
|
+
CREATE TRIGGER IF NOT EXISTS global_procedures_mirror_insert
|
|
3111
|
+
AFTER INSERT ON global_procedures
|
|
3112
|
+
BEGIN
|
|
3113
|
+
INSERT OR IGNORE INTO company_procedures
|
|
3114
|
+
(id, title, content, priority, domain, active, created_at, updated_at)
|
|
3115
|
+
VALUES
|
|
3116
|
+
(NEW.id, NEW.title, NEW.content, NEW.priority, NEW.domain, NEW.active, NEW.created_at, NEW.updated_at);
|
|
3117
|
+
END;
|
|
3118
|
+
|
|
3119
|
+
CREATE TRIGGER IF NOT EXISTS global_procedures_mirror_update
|
|
3120
|
+
AFTER UPDATE ON global_procedures
|
|
3121
|
+
BEGIN
|
|
3122
|
+
UPDATE company_procedures
|
|
3123
|
+
SET title = NEW.title,
|
|
3124
|
+
content = NEW.content,
|
|
3125
|
+
priority = NEW.priority,
|
|
3126
|
+
domain = NEW.domain,
|
|
3127
|
+
active = NEW.active,
|
|
3128
|
+
created_at = NEW.created_at,
|
|
3129
|
+
updated_at = NEW.updated_at
|
|
3130
|
+
WHERE id = OLD.id;
|
|
3131
|
+
END;
|
|
3132
|
+
`);
|
|
3133
|
+
} else {
|
|
3134
|
+
await client.execute(`
|
|
3135
|
+
CREATE VIEW IF NOT EXISTS global_procedures AS
|
|
3136
|
+
SELECT id, title, content, priority, domain, active, created_at, updated_at
|
|
3137
|
+
FROM company_procedures
|
|
3138
|
+
`);
|
|
3139
|
+
await client.executeMultiple(`
|
|
3140
|
+
CREATE TRIGGER IF NOT EXISTS global_procedures_insert
|
|
3141
|
+
INSTEAD OF INSERT ON global_procedures
|
|
3142
|
+
BEGIN
|
|
3143
|
+
INSERT INTO company_procedures
|
|
3144
|
+
(id, title, content, priority, domain, active, created_at, updated_at)
|
|
3145
|
+
VALUES
|
|
3146
|
+
(NEW.id, NEW.title, NEW.content, NEW.priority, NEW.domain, NEW.active, NEW.created_at, NEW.updated_at);
|
|
3147
|
+
END;
|
|
3148
|
+
|
|
3149
|
+
CREATE TRIGGER IF NOT EXISTS global_procedures_update
|
|
3150
|
+
INSTEAD OF UPDATE ON global_procedures
|
|
3151
|
+
BEGIN
|
|
3152
|
+
UPDATE company_procedures
|
|
3153
|
+
SET title = NEW.title,
|
|
3154
|
+
content = NEW.content,
|
|
3155
|
+
priority = NEW.priority,
|
|
3156
|
+
domain = NEW.domain,
|
|
3157
|
+
active = NEW.active,
|
|
3158
|
+
created_at = NEW.created_at,
|
|
3159
|
+
updated_at = NEW.updated_at
|
|
3160
|
+
WHERE id = OLD.id;
|
|
3161
|
+
END;
|
|
3162
|
+
`);
|
|
3163
|
+
}
|
|
3097
3164
|
await client.executeMultiple(`
|
|
3098
3165
|
CREATE TABLE IF NOT EXISTS conversations (
|
|
3099
3166
|
id TEXT PRIMARY KEY,
|
|
@@ -3233,6 +3300,51 @@ async function ensureSchema() {
|
|
|
3233
3300
|
VALUES (new.rowid, new.content_text, new.sender_name, new.agent_response);
|
|
3234
3301
|
END;
|
|
3235
3302
|
`);
|
|
3303
|
+
await client.executeMultiple(`
|
|
3304
|
+
CREATE TABLE IF NOT EXISTS memory_cards (
|
|
3305
|
+
id TEXT PRIMARY KEY,
|
|
3306
|
+
memory_id TEXT NOT NULL,
|
|
3307
|
+
agent_id TEXT NOT NULL,
|
|
3308
|
+
session_id TEXT NOT NULL,
|
|
3309
|
+
project_name TEXT,
|
|
3310
|
+
timestamp TEXT NOT NULL,
|
|
3311
|
+
card_type TEXT NOT NULL,
|
|
3312
|
+
subject TEXT,
|
|
3313
|
+
predicate TEXT,
|
|
3314
|
+
object TEXT,
|
|
3315
|
+
content TEXT NOT NULL,
|
|
3316
|
+
source_ref TEXT,
|
|
3317
|
+
confidence REAL DEFAULT 0.6,
|
|
3318
|
+
active INTEGER DEFAULT 1,
|
|
3319
|
+
created_at TEXT NOT NULL
|
|
3320
|
+
);
|
|
3321
|
+
|
|
3322
|
+
CREATE INDEX IF NOT EXISTS idx_memory_cards_agent
|
|
3323
|
+
ON memory_cards(agent_id, active, timestamp);
|
|
3324
|
+
|
|
3325
|
+
CREATE INDEX IF NOT EXISTS idx_memory_cards_memory
|
|
3326
|
+
ON memory_cards(memory_id);
|
|
3327
|
+
|
|
3328
|
+
CREATE VIRTUAL TABLE IF NOT EXISTS memory_cards_fts
|
|
3329
|
+
USING fts5(content, subject, predicate, object, content='memory_cards', content_rowid='rowid');
|
|
3330
|
+
|
|
3331
|
+
CREATE TRIGGER IF NOT EXISTS memory_cards_fts_ai AFTER INSERT ON memory_cards BEGIN
|
|
3332
|
+
INSERT INTO memory_cards_fts(rowid, content, subject, predicate, object)
|
|
3333
|
+
VALUES (new.rowid, new.content, new.subject, new.predicate, new.object);
|
|
3334
|
+
END;
|
|
3335
|
+
|
|
3336
|
+
CREATE TRIGGER IF NOT EXISTS memory_cards_fts_ad AFTER DELETE ON memory_cards BEGIN
|
|
3337
|
+
INSERT INTO memory_cards_fts(memory_cards_fts, rowid, content, subject, predicate, object)
|
|
3338
|
+
VALUES('delete', old.rowid, old.content, old.subject, old.predicate, old.object);
|
|
3339
|
+
END;
|
|
3340
|
+
|
|
3341
|
+
CREATE TRIGGER IF NOT EXISTS memory_cards_fts_au AFTER UPDATE ON memory_cards BEGIN
|
|
3342
|
+
INSERT INTO memory_cards_fts(memory_cards_fts, rowid, content, subject, predicate, object)
|
|
3343
|
+
VALUES('delete', old.rowid, old.content, old.subject, old.predicate, old.object);
|
|
3344
|
+
INSERT INTO memory_cards_fts(rowid, content, subject, predicate, object)
|
|
3345
|
+
VALUES (new.rowid, new.content, new.subject, new.predicate, new.object);
|
|
3346
|
+
END;
|
|
3347
|
+
`);
|
|
3236
3348
|
try {
|
|
3237
3349
|
await client.execute({
|
|
3238
3350
|
sql: `ALTER TABLE memories ADD COLUMN tier INTEGER DEFAULT 3`,
|
|
@@ -7619,7 +7731,7 @@ var init_platform_procedures = __esm({
|
|
|
7619
7731
|
title: "MCP tools \u2014 advanced (triggers, skills, orchestration)",
|
|
7620
7732
|
domain: "tool-use",
|
|
7621
7733
|
priority: "p1",
|
|
7622
|
-
content: "create_trigger: set up a scheduled recurring agent job (cron). list_triggers: view active triggers. load_skill: load a slash-command skill dynamically. apply_starter_pack: import a pre-built behavior + identity pack for a role. export_orchestration: export full org state (tasks, behaviors, identities) as portable JSON. import_orchestration: import org state into a new instance. deploy_client: deploy a customer client instance. query_company_brain: unified RAG query across all company knowledge. create_reminder: set a text reminder (shown in boot brief). list_reminders: view pending reminders. complete_reminder: mark a reminder done.
|
|
7734
|
+
content: "create_trigger: set up a scheduled recurring agent job (cron). list_triggers: view active triggers. load_skill: load a slash-command skill dynamically. apply_starter_pack: import a pre-built behavior + identity pack for a role. export_orchestration: export full org state (tasks, behaviors, identities) as portable JSON. import_orchestration: import org state into a new instance. deploy_client: deploy a customer client instance. query_company_brain: unified RAG query across all company knowledge. create_reminder: set a text reminder (shown in boot brief). list_reminders: view pending reminders. complete_reminder: mark a reminder done. company_procedure: manage customer-owned company procedures (Layer 0; actions: store, list, deactivate). Legacy aliases: global_procedure, store_global_procedure, list_global_procedures, deactivate_global_procedure."
|
|
7623
7735
|
}
|
|
7624
7736
|
];
|
|
7625
7737
|
PLATFORM_PROCEDURE_TITLES = new Set(
|
|
@@ -7640,7 +7752,7 @@ import { randomUUID as randomUUID3 } from "crypto";
|
|
|
7640
7752
|
async function loadGlobalProcedures() {
|
|
7641
7753
|
const client = getClient();
|
|
7642
7754
|
const result2 = await client.execute({
|
|
7643
|
-
sql: "SELECT * FROM
|
|
7755
|
+
sql: "SELECT * FROM company_procedures WHERE active = 1 ORDER BY priority ASC, created_at ASC",
|
|
7644
7756
|
args: []
|
|
7645
7757
|
});
|
|
7646
7758
|
const allRows = result2.rows;
|
|
@@ -7669,7 +7781,7 @@ async function storeGlobalProcedure(input) {
|
|
|
7669
7781
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
7670
7782
|
const client = getClient();
|
|
7671
7783
|
await client.execute({
|
|
7672
|
-
sql: `INSERT INTO
|
|
7784
|
+
sql: `INSERT INTO company_procedures (id, title, content, priority, domain, active, created_at, updated_at)
|
|
7673
7785
|
VALUES (?, ?, ?, ?, ?, 1, ?, ?)`,
|
|
7674
7786
|
args: [id, input.title, input.content, input.priority ?? "p0", input.domain ?? null, now, now]
|
|
7675
7787
|
});
|
|
@@ -7680,7 +7792,7 @@ async function deactivateGlobalProcedure(id) {
|
|
|
7680
7792
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
7681
7793
|
const client = getClient();
|
|
7682
7794
|
const result2 = await client.execute({
|
|
7683
|
-
sql: "UPDATE
|
|
7795
|
+
sql: "UPDATE company_procedures SET active = 0, updated_at = ? WHERE id = ?",
|
|
7684
7796
|
args: [now, id]
|
|
7685
7797
|
});
|
|
7686
7798
|
await loadGlobalProcedures();
|
|
@@ -7699,6 +7811,164 @@ ${p.content}`).join("\n\n");
|
|
|
7699
7811
|
}
|
|
7700
7812
|
});
|
|
7701
7813
|
|
|
7814
|
+
// src/lib/memory-cards.ts
|
|
7815
|
+
var memory_cards_exports = {};
|
|
7816
|
+
__export(memory_cards_exports, {
|
|
7817
|
+
extractMemoryCards: () => extractMemoryCards,
|
|
7818
|
+
insertMemoryCardsForBatch: () => insertMemoryCardsForBatch,
|
|
7819
|
+
searchMemoryCards: () => searchMemoryCards
|
|
7820
|
+
});
|
|
7821
|
+
import { createHash as createHash2 } from "crypto";
|
|
7822
|
+
function stableId(memoryId, type, content) {
|
|
7823
|
+
return createHash2("sha256").update(`${memoryId}:${type}:${content}`).digest("hex").slice(0, 32);
|
|
7824
|
+
}
|
|
7825
|
+
function cleanText(text) {
|
|
7826
|
+
return text.replace(/```[\s\S]*?```/g, " ").replace(/<[^>]+>/g, " ").replace(/\s+/g, " ").trim();
|
|
7827
|
+
}
|
|
7828
|
+
function splitSentences(text) {
|
|
7829
|
+
return cleanText(text).split(/(?<=[.!?])\s+|\n+/).map((s) => s.trim()).filter((s) => s.length >= 24 && s.length <= MAX_SENTENCE_CHARS);
|
|
7830
|
+
}
|
|
7831
|
+
function inferCardType(sentence, toolName) {
|
|
7832
|
+
const lower = sentence.toLowerCase();
|
|
7833
|
+
if (toolName === "store_decision" || /\b(decided|decision|adr|approved|rejected)\b/.test(lower)) return "decision";
|
|
7834
|
+
if (/\b(prefers|preference|likes|dislikes|wants|doesn't want|does not want)\b/.test(lower)) return "preference";
|
|
7835
|
+
if (/\b(changed|updated|replaced|now|no longer|instead|supersedes)\b/.test(lower)) return "belief_update";
|
|
7836
|
+
if (toolName && ["Read", "Write", "Edit", "Bash"].includes(toolName)) return "code";
|
|
7837
|
+
if (/\b(meeting|deadline|shipped|launched|completed|failed|blocked|assigned|created)\b/.test(lower)) return "event";
|
|
7838
|
+
return "fact";
|
|
7839
|
+
}
|
|
7840
|
+
function extractSubject(sentence, agentId) {
|
|
7841
|
+
const explicit = sentence.match(/\b([A-Z][a-zA-Z0-9_-]{2,}(?:\s+[A-Z][a-zA-Z0-9_-]{2,})?)\b/);
|
|
7842
|
+
return explicit?.[1] ?? agentId;
|
|
7843
|
+
}
|
|
7844
|
+
function predicateFor(type) {
|
|
7845
|
+
switch (type) {
|
|
7846
|
+
case "preference":
|
|
7847
|
+
return "prefers";
|
|
7848
|
+
case "belief_update":
|
|
7849
|
+
return "updated";
|
|
7850
|
+
case "decision":
|
|
7851
|
+
return "decided";
|
|
7852
|
+
case "event":
|
|
7853
|
+
return "happened";
|
|
7854
|
+
case "code":
|
|
7855
|
+
return "implemented";
|
|
7856
|
+
default:
|
|
7857
|
+
return "states";
|
|
7858
|
+
}
|
|
7859
|
+
}
|
|
7860
|
+
function extractMemoryCards(row) {
|
|
7861
|
+
const sentences = splitSentences(row.raw_text);
|
|
7862
|
+
const cards = [];
|
|
7863
|
+
for (const sentence of sentences) {
|
|
7864
|
+
const type = inferCardType(sentence, row.tool_name);
|
|
7865
|
+
const subject = extractSubject(sentence, row.agent_id);
|
|
7866
|
+
const content = sentence.length > MAX_SENTENCE_CHARS ? `${sentence.slice(0, MAX_SENTENCE_CHARS - 1)}\u2026` : sentence;
|
|
7867
|
+
cards.push({
|
|
7868
|
+
id: stableId(row.id, type, content),
|
|
7869
|
+
memory_id: row.id,
|
|
7870
|
+
agent_id: row.agent_id,
|
|
7871
|
+
session_id: row.session_id,
|
|
7872
|
+
project_name: row.project_name ?? null,
|
|
7873
|
+
timestamp: row.timestamp,
|
|
7874
|
+
card_type: type,
|
|
7875
|
+
subject,
|
|
7876
|
+
predicate: predicateFor(type),
|
|
7877
|
+
object: content,
|
|
7878
|
+
content,
|
|
7879
|
+
source_ref: row.id,
|
|
7880
|
+
confidence: type === "fact" ? 0.55 : 0.65
|
|
7881
|
+
});
|
|
7882
|
+
if (cards.length >= MAX_CARDS_PER_MEMORY) break;
|
|
7883
|
+
}
|
|
7884
|
+
return cards;
|
|
7885
|
+
}
|
|
7886
|
+
async function insertMemoryCardsForBatch(rows) {
|
|
7887
|
+
const cards = rows.flatMap(extractMemoryCards);
|
|
7888
|
+
if (cards.length === 0) return 0;
|
|
7889
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
7890
|
+
const client = getClient();
|
|
7891
|
+
const stmts = cards.map((card) => ({
|
|
7892
|
+
sql: `INSERT OR IGNORE INTO memory_cards
|
|
7893
|
+
(id, memory_id, agent_id, session_id, project_name, timestamp, card_type,
|
|
7894
|
+
subject, predicate, object, content, source_ref, confidence, active, created_at)
|
|
7895
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 1, ?)`,
|
|
7896
|
+
args: [
|
|
7897
|
+
card.id,
|
|
7898
|
+
card.memory_id,
|
|
7899
|
+
card.agent_id,
|
|
7900
|
+
card.session_id,
|
|
7901
|
+
card.project_name,
|
|
7902
|
+
card.timestamp,
|
|
7903
|
+
card.card_type,
|
|
7904
|
+
card.subject,
|
|
7905
|
+
card.predicate,
|
|
7906
|
+
card.object,
|
|
7907
|
+
card.content,
|
|
7908
|
+
card.source_ref,
|
|
7909
|
+
card.confidence,
|
|
7910
|
+
now
|
|
7911
|
+
]
|
|
7912
|
+
}));
|
|
7913
|
+
await client.batch(stmts, "write");
|
|
7914
|
+
return cards.length;
|
|
7915
|
+
}
|
|
7916
|
+
function buildMatchExpr(queryText) {
|
|
7917
|
+
const terms = queryText.toLowerCase().split(/\s+/).filter((t) => t.length >= 3).map((t) => t.replace(/[^a-z0-9_]/g, "")).filter((t) => t.length >= 3).slice(0, 12);
|
|
7918
|
+
if (terms.length === 0) return null;
|
|
7919
|
+
return terms.map((t) => `${t}*`).join(terms.length >= 3 ? " AND " : " OR ");
|
|
7920
|
+
}
|
|
7921
|
+
async function searchMemoryCards(queryText, agentId, options) {
|
|
7922
|
+
const limit = options?.limit ?? 10;
|
|
7923
|
+
const matchExpr = buildMatchExpr(queryText);
|
|
7924
|
+
if (!matchExpr) return [];
|
|
7925
|
+
let sql = `SELECT c.id, c.memory_id, c.agent_id, c.session_id, c.project_name,
|
|
7926
|
+
c.timestamp, c.card_type, c.content, c.source_ref, c.confidence
|
|
7927
|
+
FROM memory_cards c
|
|
7928
|
+
JOIN memory_cards_fts fts ON c.rowid = fts.rowid
|
|
7929
|
+
WHERE memory_cards_fts MATCH ?
|
|
7930
|
+
AND c.agent_id = ?
|
|
7931
|
+
AND COALESCE(c.active, 1) = 1`;
|
|
7932
|
+
const args = [matchExpr, agentId];
|
|
7933
|
+
if (options?.projectName) {
|
|
7934
|
+
sql += ` AND c.project_name = ?`;
|
|
7935
|
+
args.push(options.projectName);
|
|
7936
|
+
}
|
|
7937
|
+
if (options?.since) {
|
|
7938
|
+
sql += ` AND c.timestamp >= ?`;
|
|
7939
|
+
args.push(options.since);
|
|
7940
|
+
}
|
|
7941
|
+
sql += ` ORDER BY rank LIMIT ?`;
|
|
7942
|
+
args.push(limit);
|
|
7943
|
+
const result2 = await getClient().execute({ sql, args });
|
|
7944
|
+
return result2.rows.map((row) => ({
|
|
7945
|
+
id: `card:${String(row.id)}`,
|
|
7946
|
+
agent_id: String(row.agent_id),
|
|
7947
|
+
agent_role: "memory_card",
|
|
7948
|
+
session_id: String(row.session_id),
|
|
7949
|
+
timestamp: String(row.timestamp),
|
|
7950
|
+
tool_name: `memory_card:${String(row.card_type)}`,
|
|
7951
|
+
project_name: row.project_name == null ? "" : String(row.project_name),
|
|
7952
|
+
has_error: false,
|
|
7953
|
+
raw_text: `[${String(row.card_type)}] ${String(row.content)}
|
|
7954
|
+
Source memory: ${String(row.source_ref ?? row.memory_id)}`,
|
|
7955
|
+
vector: [],
|
|
7956
|
+
importance: 6,
|
|
7957
|
+
status: "active",
|
|
7958
|
+
confidence: Number(row.confidence ?? 0.6),
|
|
7959
|
+
last_accessed: String(row.timestamp)
|
|
7960
|
+
}));
|
|
7961
|
+
}
|
|
7962
|
+
var MAX_CARDS_PER_MEMORY, MAX_SENTENCE_CHARS;
|
|
7963
|
+
var init_memory_cards = __esm({
|
|
7964
|
+
"src/lib/memory-cards.ts"() {
|
|
7965
|
+
"use strict";
|
|
7966
|
+
init_database();
|
|
7967
|
+
MAX_CARDS_PER_MEMORY = 6;
|
|
7968
|
+
MAX_SENTENCE_CHARS = 360;
|
|
7969
|
+
}
|
|
7970
|
+
});
|
|
7971
|
+
|
|
7702
7972
|
// src/lib/store.ts
|
|
7703
7973
|
var store_exports = {};
|
|
7704
7974
|
__export(store_exports, {
|
|
@@ -8037,6 +8307,11 @@ async function flushBatch() {
|
|
|
8037
8307
|
const globalClient = getClient();
|
|
8038
8308
|
const globalStmts = batch.map(buildStmt);
|
|
8039
8309
|
await globalClient.batch(globalStmts, "write");
|
|
8310
|
+
try {
|
|
8311
|
+
const { insertMemoryCardsForBatch: insertMemoryCardsForBatch2 } = await Promise.resolve().then(() => (init_memory_cards(), memory_cards_exports));
|
|
8312
|
+
await insertMemoryCardsForBatch2(batch);
|
|
8313
|
+
} catch {
|
|
8314
|
+
}
|
|
8040
8315
|
schedulePostWriteMemoryHygiene(batch.map((row) => row.id));
|
|
8041
8316
|
_pendingRecords.splice(0, batch.length);
|
|
8042
8317
|
try {
|
package/dist/bin/exe-doctor.js
CHANGED
|
@@ -256,8 +256,8 @@ var init_config = __esm({
|
|
|
256
256
|
rerankerAutoTrigger: {
|
|
257
257
|
enabled: true,
|
|
258
258
|
broadQueryMinCardinality: 5e4,
|
|
259
|
-
fetchTopK:
|
|
260
|
-
returnTopK:
|
|
259
|
+
fetchTopK: 200,
|
|
260
|
+
returnTopK: 20
|
|
261
261
|
}
|
|
262
262
|
},
|
|
263
263
|
graphRagEnabled: true,
|
|
@@ -2289,7 +2289,7 @@ async function ensureSchema() {
|
|
|
2289
2289
|
ON session_kills(agent_id);
|
|
2290
2290
|
`);
|
|
2291
2291
|
await client.execute(`
|
|
2292
|
-
CREATE TABLE IF NOT EXISTS
|
|
2292
|
+
CREATE TABLE IF NOT EXISTS company_procedures (
|
|
2293
2293
|
id TEXT PRIMARY KEY,
|
|
2294
2294
|
title TEXT NOT NULL,
|
|
2295
2295
|
content TEXT NOT NULL,
|
|
@@ -2300,6 +2300,73 @@ async function ensureSchema() {
|
|
|
2300
2300
|
updated_at TEXT NOT NULL
|
|
2301
2301
|
)
|
|
2302
2302
|
`);
|
|
2303
|
+
const legacyProcedureObject = await client.execute({
|
|
2304
|
+
sql: "SELECT type FROM sqlite_master WHERE name = 'global_procedures'",
|
|
2305
|
+
args: []
|
|
2306
|
+
});
|
|
2307
|
+
const legacyProcedureType = legacyProcedureObject.rows[0]?.type == null ? null : String(legacyProcedureObject.rows[0].type);
|
|
2308
|
+
if (legacyProcedureType === "table") {
|
|
2309
|
+
await client.execute(`
|
|
2310
|
+
INSERT OR IGNORE INTO company_procedures
|
|
2311
|
+
(id, title, content, priority, domain, active, created_at, updated_at)
|
|
2312
|
+
SELECT id, title, content, priority, domain, active, created_at, updated_at
|
|
2313
|
+
FROM global_procedures
|
|
2314
|
+
`);
|
|
2315
|
+
await client.executeMultiple(`
|
|
2316
|
+
CREATE TRIGGER IF NOT EXISTS global_procedures_mirror_insert
|
|
2317
|
+
AFTER INSERT ON global_procedures
|
|
2318
|
+
BEGIN
|
|
2319
|
+
INSERT OR IGNORE INTO company_procedures
|
|
2320
|
+
(id, title, content, priority, domain, active, created_at, updated_at)
|
|
2321
|
+
VALUES
|
|
2322
|
+
(NEW.id, NEW.title, NEW.content, NEW.priority, NEW.domain, NEW.active, NEW.created_at, NEW.updated_at);
|
|
2323
|
+
END;
|
|
2324
|
+
|
|
2325
|
+
CREATE TRIGGER IF NOT EXISTS global_procedures_mirror_update
|
|
2326
|
+
AFTER UPDATE ON global_procedures
|
|
2327
|
+
BEGIN
|
|
2328
|
+
UPDATE company_procedures
|
|
2329
|
+
SET title = NEW.title,
|
|
2330
|
+
content = NEW.content,
|
|
2331
|
+
priority = NEW.priority,
|
|
2332
|
+
domain = NEW.domain,
|
|
2333
|
+
active = NEW.active,
|
|
2334
|
+
created_at = NEW.created_at,
|
|
2335
|
+
updated_at = NEW.updated_at
|
|
2336
|
+
WHERE id = OLD.id;
|
|
2337
|
+
END;
|
|
2338
|
+
`);
|
|
2339
|
+
} else {
|
|
2340
|
+
await client.execute(`
|
|
2341
|
+
CREATE VIEW IF NOT EXISTS global_procedures AS
|
|
2342
|
+
SELECT id, title, content, priority, domain, active, created_at, updated_at
|
|
2343
|
+
FROM company_procedures
|
|
2344
|
+
`);
|
|
2345
|
+
await client.executeMultiple(`
|
|
2346
|
+
CREATE TRIGGER IF NOT EXISTS global_procedures_insert
|
|
2347
|
+
INSTEAD OF INSERT ON global_procedures
|
|
2348
|
+
BEGIN
|
|
2349
|
+
INSERT INTO company_procedures
|
|
2350
|
+
(id, title, content, priority, domain, active, created_at, updated_at)
|
|
2351
|
+
VALUES
|
|
2352
|
+
(NEW.id, NEW.title, NEW.content, NEW.priority, NEW.domain, NEW.active, NEW.created_at, NEW.updated_at);
|
|
2353
|
+
END;
|
|
2354
|
+
|
|
2355
|
+
CREATE TRIGGER IF NOT EXISTS global_procedures_update
|
|
2356
|
+
INSTEAD OF UPDATE ON global_procedures
|
|
2357
|
+
BEGIN
|
|
2358
|
+
UPDATE company_procedures
|
|
2359
|
+
SET title = NEW.title,
|
|
2360
|
+
content = NEW.content,
|
|
2361
|
+
priority = NEW.priority,
|
|
2362
|
+
domain = NEW.domain,
|
|
2363
|
+
active = NEW.active,
|
|
2364
|
+
created_at = NEW.created_at,
|
|
2365
|
+
updated_at = NEW.updated_at
|
|
2366
|
+
WHERE id = OLD.id;
|
|
2367
|
+
END;
|
|
2368
|
+
`);
|
|
2369
|
+
}
|
|
2303
2370
|
await client.executeMultiple(`
|
|
2304
2371
|
CREATE TABLE IF NOT EXISTS conversations (
|
|
2305
2372
|
id TEXT PRIMARY KEY,
|
|
@@ -2439,6 +2506,51 @@ async function ensureSchema() {
|
|
|
2439
2506
|
VALUES (new.rowid, new.content_text, new.sender_name, new.agent_response);
|
|
2440
2507
|
END;
|
|
2441
2508
|
`);
|
|
2509
|
+
await client.executeMultiple(`
|
|
2510
|
+
CREATE TABLE IF NOT EXISTS memory_cards (
|
|
2511
|
+
id TEXT PRIMARY KEY,
|
|
2512
|
+
memory_id TEXT NOT NULL,
|
|
2513
|
+
agent_id TEXT NOT NULL,
|
|
2514
|
+
session_id TEXT NOT NULL,
|
|
2515
|
+
project_name TEXT,
|
|
2516
|
+
timestamp TEXT NOT NULL,
|
|
2517
|
+
card_type TEXT NOT NULL,
|
|
2518
|
+
subject TEXT,
|
|
2519
|
+
predicate TEXT,
|
|
2520
|
+
object TEXT,
|
|
2521
|
+
content TEXT NOT NULL,
|
|
2522
|
+
source_ref TEXT,
|
|
2523
|
+
confidence REAL DEFAULT 0.6,
|
|
2524
|
+
active INTEGER DEFAULT 1,
|
|
2525
|
+
created_at TEXT NOT NULL
|
|
2526
|
+
);
|
|
2527
|
+
|
|
2528
|
+
CREATE INDEX IF NOT EXISTS idx_memory_cards_agent
|
|
2529
|
+
ON memory_cards(agent_id, active, timestamp);
|
|
2530
|
+
|
|
2531
|
+
CREATE INDEX IF NOT EXISTS idx_memory_cards_memory
|
|
2532
|
+
ON memory_cards(memory_id);
|
|
2533
|
+
|
|
2534
|
+
CREATE VIRTUAL TABLE IF NOT EXISTS memory_cards_fts
|
|
2535
|
+
USING fts5(content, subject, predicate, object, content='memory_cards', content_rowid='rowid');
|
|
2536
|
+
|
|
2537
|
+
CREATE TRIGGER IF NOT EXISTS memory_cards_fts_ai AFTER INSERT ON memory_cards BEGIN
|
|
2538
|
+
INSERT INTO memory_cards_fts(rowid, content, subject, predicate, object)
|
|
2539
|
+
VALUES (new.rowid, new.content, new.subject, new.predicate, new.object);
|
|
2540
|
+
END;
|
|
2541
|
+
|
|
2542
|
+
CREATE TRIGGER IF NOT EXISTS memory_cards_fts_ad AFTER DELETE ON memory_cards BEGIN
|
|
2543
|
+
INSERT INTO memory_cards_fts(memory_cards_fts, rowid, content, subject, predicate, object)
|
|
2544
|
+
VALUES('delete', old.rowid, old.content, old.subject, old.predicate, old.object);
|
|
2545
|
+
END;
|
|
2546
|
+
|
|
2547
|
+
CREATE TRIGGER IF NOT EXISTS memory_cards_fts_au AFTER UPDATE ON memory_cards BEGIN
|
|
2548
|
+
INSERT INTO memory_cards_fts(memory_cards_fts, rowid, content, subject, predicate, object)
|
|
2549
|
+
VALUES('delete', old.rowid, old.content, old.subject, old.predicate, old.object);
|
|
2550
|
+
INSERT INTO memory_cards_fts(rowid, content, subject, predicate, object)
|
|
2551
|
+
VALUES (new.rowid, new.content, new.subject, new.predicate, new.object);
|
|
2552
|
+
END;
|
|
2553
|
+
`);
|
|
2442
2554
|
try {
|
|
2443
2555
|
await client.execute({
|
|
2444
2556
|
sql: `ALTER TABLE memories ADD COLUMN tier INTEGER DEFAULT 3`,
|
|
@@ -3176,7 +3288,7 @@ var init_platform_procedures = __esm({
|
|
|
3176
3288
|
title: "MCP tools \u2014 advanced (triggers, skills, orchestration)",
|
|
3177
3289
|
domain: "tool-use",
|
|
3178
3290
|
priority: "p1",
|
|
3179
|
-
content: "create_trigger: set up a scheduled recurring agent job (cron). list_triggers: view active triggers. load_skill: load a slash-command skill dynamically. apply_starter_pack: import a pre-built behavior + identity pack for a role. export_orchestration: export full org state (tasks, behaviors, identities) as portable JSON. import_orchestration: import org state into a new instance. deploy_client: deploy a customer client instance. query_company_brain: unified RAG query across all company knowledge. create_reminder: set a text reminder (shown in boot brief). list_reminders: view pending reminders. complete_reminder: mark a reminder done.
|
|
3291
|
+
content: "create_trigger: set up a scheduled recurring agent job (cron). list_triggers: view active triggers. load_skill: load a slash-command skill dynamically. apply_starter_pack: import a pre-built behavior + identity pack for a role. export_orchestration: export full org state (tasks, behaviors, identities) as portable JSON. import_orchestration: import org state into a new instance. deploy_client: deploy a customer client instance. query_company_brain: unified RAG query across all company knowledge. create_reminder: set a text reminder (shown in boot brief). list_reminders: view pending reminders. complete_reminder: mark a reminder done. company_procedure: manage customer-owned company procedures (Layer 0; actions: store, list, deactivate). Legacy aliases: global_procedure, store_global_procedure, list_global_procedures, deactivate_global_procedure."
|
|
3180
3292
|
}
|
|
3181
3293
|
];
|
|
3182
3294
|
PLATFORM_PROCEDURE_TITLES = new Set(
|
|
@@ -3197,7 +3309,7 @@ import { randomUUID as randomUUID2 } from "crypto";
|
|
|
3197
3309
|
async function loadGlobalProcedures() {
|
|
3198
3310
|
const client = getClient();
|
|
3199
3311
|
const result = await client.execute({
|
|
3200
|
-
sql: "SELECT * FROM
|
|
3312
|
+
sql: "SELECT * FROM company_procedures WHERE active = 1 ORDER BY priority ASC, created_at ASC",
|
|
3201
3313
|
args: []
|
|
3202
3314
|
});
|
|
3203
3315
|
const allRows = result.rows;
|
|
@@ -3226,7 +3338,7 @@ async function storeGlobalProcedure(input) {
|
|
|
3226
3338
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
3227
3339
|
const client = getClient();
|
|
3228
3340
|
await client.execute({
|
|
3229
|
-
sql: `INSERT INTO
|
|
3341
|
+
sql: `INSERT INTO company_procedures (id, title, content, priority, domain, active, created_at, updated_at)
|
|
3230
3342
|
VALUES (?, ?, ?, ?, ?, 1, ?, ?)`,
|
|
3231
3343
|
args: [id, input.title, input.content, input.priority ?? "p0", input.domain ?? null, now, now]
|
|
3232
3344
|
});
|
|
@@ -3237,7 +3349,7 @@ async function deactivateGlobalProcedure(id) {
|
|
|
3237
3349
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
3238
3350
|
const client = getClient();
|
|
3239
3351
|
const result = await client.execute({
|
|
3240
|
-
sql: "UPDATE
|
|
3352
|
+
sql: "UPDATE company_procedures SET active = 0, updated_at = ? WHERE id = ?",
|
|
3241
3353
|
args: [now, id]
|
|
3242
3354
|
});
|
|
3243
3355
|
await loadGlobalProcedures();
|