@askexenow/exe-os 0.9.37 → 0.9.39
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 +55 -0
- package/dist/bin/backfill-conversations.js +36 -9
- package/dist/bin/backfill-responses.js +36 -9
- package/dist/bin/backfill-vectors.js +36 -9
- package/dist/bin/cleanup-stale-review-tasks.js +37 -10
- package/dist/bin/cli.js +624 -204
- package/dist/bin/exe-agent.js +13 -5
- package/dist/bin/exe-assign.js +36 -9
- package/dist/bin/exe-boot.js +50 -20
- package/dist/bin/exe-call.js +134 -342
- package/dist/bin/exe-dispatch.js +36 -9
- package/dist/bin/exe-doctor.js +39 -12
- package/dist/bin/exe-export-behaviors.js +38 -11
- package/dist/bin/exe-forget.js +36 -9
- package/dist/bin/exe-gateway.js +64 -15
- package/dist/bin/exe-heartbeat.js +37 -10
- package/dist/bin/exe-kill.js +36 -9
- package/dist/bin/exe-launch-agent.js +287 -1081
- package/dist/bin/exe-new-employee.js +100 -14
- package/dist/bin/exe-pending-messages.js +36 -9
- package/dist/bin/exe-pending-notifications.js +36 -9
- package/dist/bin/exe-pending-reviews.js +36 -9
- package/dist/bin/exe-rename.js +1780 -204
- package/dist/bin/exe-review.js +36 -9
- package/dist/bin/exe-search.js +38 -11
- package/dist/bin/exe-session-cleanup.js +38 -11
- package/dist/bin/exe-start-codex.js +38 -11
- package/dist/bin/exe-start-opencode.js +38 -11
- package/dist/bin/exe-status.js +37 -10
- package/dist/bin/exe-team.js +36 -9
- package/dist/bin/git-sweep.js +36 -9
- package/dist/bin/graph-backfill.js +36 -9
- package/dist/bin/graph-export.js +36 -9
- package/dist/bin/install.js +70 -3
- package/dist/bin/intercom-check.js +38 -11
- package/dist/bin/scan-tasks.js +36 -9
- package/dist/bin/setup.js +20 -19
- package/dist/bin/shard-migrate.js +36 -9
- package/dist/bin/stack-update.js +308 -0
- package/dist/gateway/index.js +62 -13
- package/dist/hooks/bug-report-worker.js +40 -12
- package/dist/hooks/codex-stop-task-finalizer.js +38 -11
- package/dist/hooks/commit-complete.js +36 -9
- package/dist/hooks/error-recall.js +38 -11
- package/dist/hooks/ingest.js +38 -10
- package/dist/hooks/instructions-loaded.js +44 -12
- package/dist/hooks/notification.js +36 -9
- package/dist/hooks/post-compact.js +36 -9
- package/dist/hooks/post-tool-combined.js +39 -12
- package/dist/hooks/pre-compact.js +37 -10
- package/dist/hooks/pre-tool-use.js +38 -10
- package/dist/hooks/prompt-submit.js +43 -15
- package/dist/hooks/session-end.js +37 -10
- package/dist/hooks/session-start.js +49 -16
- package/dist/hooks/stop.js +37 -10
- package/dist/hooks/subagent-stop.js +36 -9
- package/dist/hooks/summary-worker.js +45 -18
- package/dist/index.js +60 -11
- package/dist/lib/consolidation.js +2 -1
- package/dist/lib/employee-templates.js +4 -3
- package/dist/lib/employees.js +2 -1
- package/dist/lib/exe-daemon.js +11229 -10537
- package/dist/lib/hybrid-search.js +38 -11
- package/dist/lib/identity.js +8 -3
- package/dist/lib/schedules.js +36 -9
- package/dist/lib/store.js +36 -9
- package/dist/mcp/server.js +6873 -6249
- package/dist/mcp/tools/create-task.js +10 -4
- package/dist/runtime/index.js +36 -9
- package/dist/tui/App.js +42 -13
- package/package.json +4 -1
- package/stack.release.json +31 -0
- package/stack.release.schema.json +31 -0
|
@@ -603,7 +603,8 @@ function isMultiInstance(agentName, employees) {
|
|
|
603
603
|
return MULTI_INSTANCE_ROLES.has(emp.role.toLowerCase());
|
|
604
604
|
}
|
|
605
605
|
function addEmployee(employees, employee) {
|
|
606
|
-
const
|
|
606
|
+
const { systemPrompt: _legacyPrompt, ...rest } = employee;
|
|
607
|
+
const normalized = { ...rest, name: employee.name.toLowerCase() };
|
|
607
608
|
if (employees.some((e) => e.name.toLowerCase() === normalized.name)) {
|
|
608
609
|
throw new Error(`Employee '${normalized.name}' already exists`);
|
|
609
610
|
}
|
|
@@ -3583,7 +3584,7 @@ __export(shard_manager_exports, {
|
|
|
3583
3584
|
shardExists: () => shardExists
|
|
3584
3585
|
});
|
|
3585
3586
|
import path8 from "path";
|
|
3586
|
-
import { existsSync as existsSync8, mkdirSync as mkdirSync2, readdirSync } from "fs";
|
|
3587
|
+
import { existsSync as existsSync8, mkdirSync as mkdirSync2, readdirSync, renameSync as renameSync3, statSync as statSync2 } from "fs";
|
|
3587
3588
|
import { createClient as createClient2 } from "@libsql/client";
|
|
3588
3589
|
function initShardManager(encryptionKey) {
|
|
3589
3590
|
_encryptionKey = encryptionKey;
|
|
@@ -3605,7 +3606,7 @@ function getShardClient(projectName) {
|
|
|
3605
3606
|
if (!_encryptionKey) {
|
|
3606
3607
|
throw new Error("Shard manager not initialized. Call initShardManager() first.");
|
|
3607
3608
|
}
|
|
3608
|
-
const safeName = projectName
|
|
3609
|
+
const safeName = safeShardName(projectName);
|
|
3609
3610
|
if (!safeName || safeName === "unknown") {
|
|
3610
3611
|
throw new Error(`Invalid project name for shard: "${projectName}" (resolved to "${safeName}")`);
|
|
3611
3612
|
}
|
|
@@ -3627,9 +3628,12 @@ function getShardClient(projectName) {
|
|
|
3627
3628
|
return client;
|
|
3628
3629
|
}
|
|
3629
3630
|
function shardExists(projectName) {
|
|
3630
|
-
const safeName = projectName
|
|
3631
|
+
const safeName = safeShardName(projectName);
|
|
3631
3632
|
return existsSync8(path8.join(SHARDS_DIR, `${safeName}.db`));
|
|
3632
3633
|
}
|
|
3634
|
+
function safeShardName(projectName) {
|
|
3635
|
+
return projectName.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
3636
|
+
}
|
|
3633
3637
|
function listShards() {
|
|
3634
3638
|
if (!existsSync8(SHARDS_DIR)) return [];
|
|
3635
3639
|
return readdirSync(SHARDS_DIR).filter((f) => f.endsWith(".db")).map((f) => f.replace(".db", ""));
|
|
@@ -3723,7 +3727,8 @@ async function ensureShardSchema(client) {
|
|
|
3723
3727
|
"ALTER TABLE memories ADD COLUMN token_cost REAL",
|
|
3724
3728
|
"ALTER TABLE memories ADD COLUMN audience TEXT",
|
|
3725
3729
|
"ALTER TABLE memories ADD COLUMN language_type TEXT",
|
|
3726
|
-
"ALTER TABLE memories ADD COLUMN parent_memory_id TEXT"
|
|
3730
|
+
"ALTER TABLE memories ADD COLUMN parent_memory_id TEXT",
|
|
3731
|
+
"ALTER TABLE memories ADD COLUMN deleted_at TEXT"
|
|
3727
3732
|
]) {
|
|
3728
3733
|
try {
|
|
3729
3734
|
await client.execute(col);
|
|
@@ -3819,9 +3824,32 @@ async function ensureShardSchema(client) {
|
|
|
3819
3824
|
}
|
|
3820
3825
|
}
|
|
3821
3826
|
async function getReadyShardClient(projectName) {
|
|
3822
|
-
const
|
|
3823
|
-
|
|
3824
|
-
|
|
3827
|
+
const safeName = safeShardName(projectName);
|
|
3828
|
+
let client = getShardClient(projectName);
|
|
3829
|
+
try {
|
|
3830
|
+
await ensureShardSchema(client);
|
|
3831
|
+
return client;
|
|
3832
|
+
} catch (err) {
|
|
3833
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
3834
|
+
if (!/SQLITE_NOTADB|file is not a database/i.test(message)) throw err;
|
|
3835
|
+
client.close();
|
|
3836
|
+
_shards.delete(safeName);
|
|
3837
|
+
_shardLastAccess.delete(safeName);
|
|
3838
|
+
const dbPath = path8.join(SHARDS_DIR, `${safeName}.db`);
|
|
3839
|
+
if (existsSync8(dbPath)) {
|
|
3840
|
+
const stat = statSync2(dbPath);
|
|
3841
|
+
const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
3842
|
+
const archivedPath = path8.join(SHARDS_DIR, `${safeName}.db.broken-${stamp}`);
|
|
3843
|
+
renameSync3(dbPath, archivedPath);
|
|
3844
|
+
process.stderr.write(
|
|
3845
|
+
`[shard-manager] Archived unreadable shard ${safeName}: ${archivedPath} (${stat.size} bytes, mtime ${stat.mtime.toISOString()})
|
|
3846
|
+
`
|
|
3847
|
+
);
|
|
3848
|
+
}
|
|
3849
|
+
client = getShardClient(projectName);
|
|
3850
|
+
await ensureShardSchema(client);
|
|
3851
|
+
return client;
|
|
3852
|
+
}
|
|
3825
3853
|
}
|
|
3826
3854
|
function evictLRU() {
|
|
3827
3855
|
let oldest = null;
|
|
@@ -4042,7 +4070,7 @@ var init_platform_procedures = __esm({
|
|
|
4042
4070
|
title: "MCP tools \u2014 wiki, documents, and content",
|
|
4043
4071
|
domain: "tool-use",
|
|
4044
4072
|
priority: "p1",
|
|
4045
|
-
content: "
|
|
4073
|
+
content: "wiki: read/list wiki pages only. Direct wiki write tools are removed; wiki updates flow through raw-data ingestion/projection into the curated wiki store. Legacy aliases: list_wiki_pages/get_wiki_page. crm: read/list/get CRM records from exe-db. raw_data: read capped raw landing-pad events from exe-db with payload opt-in. ingest_document: import a file (PDF, MD, etc.) into memory as chunks. list_documents: browse ingested documents by workspace. purge_document: remove a document and its memory chunks. set_document_importance: adjust chunk importance scores. rerank_documents: re-score document relevance for a query."
|
|
4046
4074
|
},
|
|
4047
4075
|
{
|
|
4048
4076
|
title: "MCP tools \u2014 system, operations, and admin",
|
|
@@ -4060,7 +4088,7 @@ var init_platform_procedures = __esm({
|
|
|
4060
4088
|
title: "MCP tools \u2014 advanced (triggers, skills, orchestration)",
|
|
4061
4089
|
domain: "tool-use",
|
|
4062
4090
|
priority: "p1",
|
|
4063
|
-
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. global_procedure: manage
|
|
4091
|
+
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. global_procedure: manage customer-owned company procedures (Layer 0; actions: store, list, deactivate). Legacy aliases: store_global_procedure, list_global_procedures, deactivate_global_procedure."
|
|
4064
4092
|
}
|
|
4065
4093
|
];
|
|
4066
4094
|
PLATFORM_PROCEDURE_TITLES = new Set(
|
|
@@ -5096,7 +5124,7 @@ __export(file_grep_exports, {
|
|
|
5096
5124
|
grepProjectFiles: () => grepProjectFiles
|
|
5097
5125
|
});
|
|
5098
5126
|
import { execSync as execSync4 } from "child_process";
|
|
5099
|
-
import { readFileSync as readFileSync6, readdirSync as readdirSync2, statSync as
|
|
5127
|
+
import { readFileSync as readFileSync6, readdirSync as readdirSync2, statSync as statSync3, existsSync as existsSync10 } from "fs";
|
|
5100
5128
|
import path11 from "path";
|
|
5101
5129
|
import crypto2 from "crypto";
|
|
5102
5130
|
function hasRipgrep() {
|
|
@@ -5213,7 +5241,7 @@ function grepWithNodeFs(pattern, projectRoot, patterns) {
|
|
|
5213
5241
|
for (const filePath of files.slice(0, MAX_FILES)) {
|
|
5214
5242
|
const absPath = path11.join(projectRoot, filePath);
|
|
5215
5243
|
try {
|
|
5216
|
-
const stat =
|
|
5244
|
+
const stat = statSync3(absPath);
|
|
5217
5245
|
if (stat.size > MAX_FILE_SIZE) continue;
|
|
5218
5246
|
const content = readFileSync6(absPath, "utf8");
|
|
5219
5247
|
const lines = content.split("\n");
|
|
@@ -6237,7 +6265,7 @@ __export(intercom_queue_exports, {
|
|
|
6237
6265
|
queueIntercom: () => queueIntercom,
|
|
6238
6266
|
readQueue: () => readQueue
|
|
6239
6267
|
});
|
|
6240
|
-
import { readFileSync as readFileSync10, writeFileSync as writeFileSync7, renameSync as
|
|
6268
|
+
import { readFileSync as readFileSync10, writeFileSync as writeFileSync7, renameSync as renameSync4, existsSync as existsSync13, mkdirSync as mkdirSync6 } from "fs";
|
|
6241
6269
|
import path15 from "path";
|
|
6242
6270
|
import os8 from "os";
|
|
6243
6271
|
function ensureDir() {
|
|
@@ -6256,7 +6284,7 @@ function writeQueue(queue) {
|
|
|
6256
6284
|
ensureDir();
|
|
6257
6285
|
const tmp = `${QUEUE_PATH}.tmp`;
|
|
6258
6286
|
writeFileSync7(tmp, JSON.stringify(queue, null, 2));
|
|
6259
|
-
|
|
6287
|
+
renameSync4(tmp, QUEUE_PATH);
|
|
6260
6288
|
}
|
|
6261
6289
|
function queueIntercom(targetSession, reason) {
|
|
6262
6290
|
const queue = readQueue();
|
|
@@ -9687,7 +9715,7 @@ var init_messaging = __esm({
|
|
|
9687
9715
|
});
|
|
9688
9716
|
|
|
9689
9717
|
// src/lib/memory-queue.ts
|
|
9690
|
-
import { appendFileSync as appendFileSync2, readFileSync as readFileSync16, renameSync as
|
|
9718
|
+
import { appendFileSync as appendFileSync2, readFileSync as readFileSync16, renameSync as renameSync5, unlinkSync as unlinkSync9, existsSync as existsSync20, statSync as statSync4 } from "fs";
|
|
9691
9719
|
import path24 from "path";
|
|
9692
9720
|
function enqueueMemory(entry) {
|
|
9693
9721
|
appendFileSync2(QUEUE_PATH2, JSON.stringify(entry) + "\n");
|
|
@@ -7142,7 +7142,7 @@ __export(shard_manager_exports, {
|
|
|
7142
7142
|
shardExists: () => shardExists
|
|
7143
7143
|
});
|
|
7144
7144
|
import path21 from "path";
|
|
7145
|
-
import { existsSync as existsSync17, mkdirSync as mkdirSync9, readdirSync as readdirSync5 } from "fs";
|
|
7145
|
+
import { existsSync as existsSync17, mkdirSync as mkdirSync9, readdirSync as readdirSync5, renameSync as renameSync4, statSync as statSync2 } from "fs";
|
|
7146
7146
|
import { createClient as createClient2 } from "@libsql/client";
|
|
7147
7147
|
function initShardManager(encryptionKey) {
|
|
7148
7148
|
_encryptionKey = encryptionKey;
|
|
@@ -7164,7 +7164,7 @@ function getShardClient(projectName) {
|
|
|
7164
7164
|
if (!_encryptionKey) {
|
|
7165
7165
|
throw new Error("Shard manager not initialized. Call initShardManager() first.");
|
|
7166
7166
|
}
|
|
7167
|
-
const safeName = projectName
|
|
7167
|
+
const safeName = safeShardName(projectName);
|
|
7168
7168
|
if (!safeName || safeName === "unknown") {
|
|
7169
7169
|
throw new Error(`Invalid project name for shard: "${projectName}" (resolved to "${safeName}")`);
|
|
7170
7170
|
}
|
|
@@ -7186,9 +7186,12 @@ function getShardClient(projectName) {
|
|
|
7186
7186
|
return client;
|
|
7187
7187
|
}
|
|
7188
7188
|
function shardExists(projectName) {
|
|
7189
|
-
const safeName = projectName
|
|
7189
|
+
const safeName = safeShardName(projectName);
|
|
7190
7190
|
return existsSync17(path21.join(SHARDS_DIR, `${safeName}.db`));
|
|
7191
7191
|
}
|
|
7192
|
+
function safeShardName(projectName) {
|
|
7193
|
+
return projectName.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
7194
|
+
}
|
|
7192
7195
|
function listShards() {
|
|
7193
7196
|
if (!existsSync17(SHARDS_DIR)) return [];
|
|
7194
7197
|
return readdirSync5(SHARDS_DIR).filter((f) => f.endsWith(".db")).map((f) => f.replace(".db", ""));
|
|
@@ -7282,7 +7285,8 @@ async function ensureShardSchema(client) {
|
|
|
7282
7285
|
"ALTER TABLE memories ADD COLUMN token_cost REAL",
|
|
7283
7286
|
"ALTER TABLE memories ADD COLUMN audience TEXT",
|
|
7284
7287
|
"ALTER TABLE memories ADD COLUMN language_type TEXT",
|
|
7285
|
-
"ALTER TABLE memories ADD COLUMN parent_memory_id TEXT"
|
|
7288
|
+
"ALTER TABLE memories ADD COLUMN parent_memory_id TEXT",
|
|
7289
|
+
"ALTER TABLE memories ADD COLUMN deleted_at TEXT"
|
|
7286
7290
|
]) {
|
|
7287
7291
|
try {
|
|
7288
7292
|
await client.execute(col);
|
|
@@ -7378,9 +7382,32 @@ async function ensureShardSchema(client) {
|
|
|
7378
7382
|
}
|
|
7379
7383
|
}
|
|
7380
7384
|
async function getReadyShardClient(projectName) {
|
|
7381
|
-
const
|
|
7382
|
-
|
|
7383
|
-
|
|
7385
|
+
const safeName = safeShardName(projectName);
|
|
7386
|
+
let client = getShardClient(projectName);
|
|
7387
|
+
try {
|
|
7388
|
+
await ensureShardSchema(client);
|
|
7389
|
+
return client;
|
|
7390
|
+
} catch (err) {
|
|
7391
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
7392
|
+
if (!/SQLITE_NOTADB|file is not a database/i.test(message)) throw err;
|
|
7393
|
+
client.close();
|
|
7394
|
+
_shards.delete(safeName);
|
|
7395
|
+
_shardLastAccess.delete(safeName);
|
|
7396
|
+
const dbPath = path21.join(SHARDS_DIR, `${safeName}.db`);
|
|
7397
|
+
if (existsSync17(dbPath)) {
|
|
7398
|
+
const stat = statSync2(dbPath);
|
|
7399
|
+
const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
7400
|
+
const archivedPath = path21.join(SHARDS_DIR, `${safeName}.db.broken-${stamp}`);
|
|
7401
|
+
renameSync4(dbPath, archivedPath);
|
|
7402
|
+
process.stderr.write(
|
|
7403
|
+
`[shard-manager] Archived unreadable shard ${safeName}: ${archivedPath} (${stat.size} bytes, mtime ${stat.mtime.toISOString()})
|
|
7404
|
+
`
|
|
7405
|
+
);
|
|
7406
|
+
}
|
|
7407
|
+
client = getShardClient(projectName);
|
|
7408
|
+
await ensureShardSchema(client);
|
|
7409
|
+
return client;
|
|
7410
|
+
}
|
|
7384
7411
|
}
|
|
7385
7412
|
function evictLRU() {
|
|
7386
7413
|
let oldest = null;
|
|
@@ -7601,7 +7628,7 @@ var init_platform_procedures = __esm({
|
|
|
7601
7628
|
title: "MCP tools \u2014 wiki, documents, and content",
|
|
7602
7629
|
domain: "tool-use",
|
|
7603
7630
|
priority: "p1",
|
|
7604
|
-
content: "
|
|
7631
|
+
content: "wiki: read/list wiki pages only. Direct wiki write tools are removed; wiki updates flow through raw-data ingestion/projection into the curated wiki store. Legacy aliases: list_wiki_pages/get_wiki_page. crm: read/list/get CRM records from exe-db. raw_data: read capped raw landing-pad events from exe-db with payload opt-in. ingest_document: import a file (PDF, MD, etc.) into memory as chunks. list_documents: browse ingested documents by workspace. purge_document: remove a document and its memory chunks. set_document_importance: adjust chunk importance scores. rerank_documents: re-score document relevance for a query."
|
|
7605
7632
|
},
|
|
7606
7633
|
{
|
|
7607
7634
|
title: "MCP tools \u2014 system, operations, and admin",
|
|
@@ -7619,7 +7646,7 @@ var init_platform_procedures = __esm({
|
|
|
7619
7646
|
title: "MCP tools \u2014 advanced (triggers, skills, orchestration)",
|
|
7620
7647
|
domain: "tool-use",
|
|
7621
7648
|
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. global_procedure: manage
|
|
7649
|
+
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. global_procedure: manage customer-owned company procedures (Layer 0; actions: store, list, deactivate). Legacy aliases: store_global_procedure, list_global_procedures, deactivate_global_procedure."
|
|
7623
7650
|
}
|
|
7624
7651
|
];
|
|
7625
7652
|
PLATFORM_PROCEDURE_TITLES = new Set(
|
|
@@ -8385,7 +8412,7 @@ var init_fast_db_init = __esm({
|
|
|
8385
8412
|
});
|
|
8386
8413
|
|
|
8387
8414
|
// src/lib/memory-queue.ts
|
|
8388
|
-
import { appendFileSync as appendFileSync2, readFileSync as readFileSync15, renameSync as
|
|
8415
|
+
import { appendFileSync as appendFileSync2, readFileSync as readFileSync15, renameSync as renameSync5, unlinkSync as unlinkSync9, existsSync as existsSync18, statSync as statSync3 } from "fs";
|
|
8389
8416
|
import path22 from "path";
|
|
8390
8417
|
function enqueueMemory(entry) {
|
|
8391
8418
|
appendFileSync2(QUEUE_PATH2, JSON.stringify(entry) + "\n");
|
|
@@ -594,7 +594,8 @@ function isMultiInstance(agentName, employees) {
|
|
|
594
594
|
return MULTI_INSTANCE_ROLES.has(emp.role.toLowerCase());
|
|
595
595
|
}
|
|
596
596
|
function addEmployee(employees, employee) {
|
|
597
|
-
const
|
|
597
|
+
const { systemPrompt: _legacyPrompt, ...rest } = employee;
|
|
598
|
+
const normalized = { ...rest, name: employee.name.toLowerCase() };
|
|
598
599
|
if (employees.some((e) => e.name.toLowerCase() === normalized.name)) {
|
|
599
600
|
throw new Error(`Employee '${normalized.name}' already exists`);
|
|
600
601
|
}
|
|
@@ -3649,7 +3650,7 @@ __export(shard_manager_exports, {
|
|
|
3649
3650
|
shardExists: () => shardExists
|
|
3650
3651
|
});
|
|
3651
3652
|
import path8 from "path";
|
|
3652
|
-
import { existsSync as existsSync8, mkdirSync as mkdirSync2, readdirSync } from "fs";
|
|
3653
|
+
import { existsSync as existsSync8, mkdirSync as mkdirSync2, readdirSync, renameSync as renameSync3, statSync as statSync2 } from "fs";
|
|
3653
3654
|
import { createClient as createClient2 } from "@libsql/client";
|
|
3654
3655
|
function initShardManager(encryptionKey) {
|
|
3655
3656
|
_encryptionKey = encryptionKey;
|
|
@@ -3671,7 +3672,7 @@ function getShardClient(projectName) {
|
|
|
3671
3672
|
if (!_encryptionKey) {
|
|
3672
3673
|
throw new Error("Shard manager not initialized. Call initShardManager() first.");
|
|
3673
3674
|
}
|
|
3674
|
-
const safeName = projectName
|
|
3675
|
+
const safeName = safeShardName(projectName);
|
|
3675
3676
|
if (!safeName || safeName === "unknown") {
|
|
3676
3677
|
throw new Error(`Invalid project name for shard: "${projectName}" (resolved to "${safeName}")`);
|
|
3677
3678
|
}
|
|
@@ -3693,9 +3694,12 @@ function getShardClient(projectName) {
|
|
|
3693
3694
|
return client;
|
|
3694
3695
|
}
|
|
3695
3696
|
function shardExists(projectName) {
|
|
3696
|
-
const safeName = projectName
|
|
3697
|
+
const safeName = safeShardName(projectName);
|
|
3697
3698
|
return existsSync8(path8.join(SHARDS_DIR, `${safeName}.db`));
|
|
3698
3699
|
}
|
|
3700
|
+
function safeShardName(projectName) {
|
|
3701
|
+
return projectName.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
3702
|
+
}
|
|
3699
3703
|
function listShards() {
|
|
3700
3704
|
if (!existsSync8(SHARDS_DIR)) return [];
|
|
3701
3705
|
return readdirSync(SHARDS_DIR).filter((f) => f.endsWith(".db")).map((f) => f.replace(".db", ""));
|
|
@@ -3789,7 +3793,8 @@ async function ensureShardSchema(client) {
|
|
|
3789
3793
|
"ALTER TABLE memories ADD COLUMN token_cost REAL",
|
|
3790
3794
|
"ALTER TABLE memories ADD COLUMN audience TEXT",
|
|
3791
3795
|
"ALTER TABLE memories ADD COLUMN language_type TEXT",
|
|
3792
|
-
"ALTER TABLE memories ADD COLUMN parent_memory_id TEXT"
|
|
3796
|
+
"ALTER TABLE memories ADD COLUMN parent_memory_id TEXT",
|
|
3797
|
+
"ALTER TABLE memories ADD COLUMN deleted_at TEXT"
|
|
3793
3798
|
]) {
|
|
3794
3799
|
try {
|
|
3795
3800
|
await client.execute(col);
|
|
@@ -3885,9 +3890,32 @@ async function ensureShardSchema(client) {
|
|
|
3885
3890
|
}
|
|
3886
3891
|
}
|
|
3887
3892
|
async function getReadyShardClient(projectName) {
|
|
3888
|
-
const
|
|
3889
|
-
|
|
3890
|
-
|
|
3893
|
+
const safeName = safeShardName(projectName);
|
|
3894
|
+
let client = getShardClient(projectName);
|
|
3895
|
+
try {
|
|
3896
|
+
await ensureShardSchema(client);
|
|
3897
|
+
return client;
|
|
3898
|
+
} catch (err) {
|
|
3899
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
3900
|
+
if (!/SQLITE_NOTADB|file is not a database/i.test(message)) throw err;
|
|
3901
|
+
client.close();
|
|
3902
|
+
_shards.delete(safeName);
|
|
3903
|
+
_shardLastAccess.delete(safeName);
|
|
3904
|
+
const dbPath = path8.join(SHARDS_DIR, `${safeName}.db`);
|
|
3905
|
+
if (existsSync8(dbPath)) {
|
|
3906
|
+
const stat = statSync2(dbPath);
|
|
3907
|
+
const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
3908
|
+
const archivedPath = path8.join(SHARDS_DIR, `${safeName}.db.broken-${stamp}`);
|
|
3909
|
+
renameSync3(dbPath, archivedPath);
|
|
3910
|
+
process.stderr.write(
|
|
3911
|
+
`[shard-manager] Archived unreadable shard ${safeName}: ${archivedPath} (${stat.size} bytes, mtime ${stat.mtime.toISOString()})
|
|
3912
|
+
`
|
|
3913
|
+
);
|
|
3914
|
+
}
|
|
3915
|
+
client = getShardClient(projectName);
|
|
3916
|
+
await ensureShardSchema(client);
|
|
3917
|
+
return client;
|
|
3918
|
+
}
|
|
3891
3919
|
}
|
|
3892
3920
|
function evictLRU() {
|
|
3893
3921
|
let oldest = null;
|
|
@@ -4108,7 +4136,7 @@ var init_platform_procedures = __esm({
|
|
|
4108
4136
|
title: "MCP tools \u2014 wiki, documents, and content",
|
|
4109
4137
|
domain: "tool-use",
|
|
4110
4138
|
priority: "p1",
|
|
4111
|
-
content: "
|
|
4139
|
+
content: "wiki: read/list wiki pages only. Direct wiki write tools are removed; wiki updates flow through raw-data ingestion/projection into the curated wiki store. Legacy aliases: list_wiki_pages/get_wiki_page. crm: read/list/get CRM records from exe-db. raw_data: read capped raw landing-pad events from exe-db with payload opt-in. ingest_document: import a file (PDF, MD, etc.) into memory as chunks. list_documents: browse ingested documents by workspace. purge_document: remove a document and its memory chunks. set_document_importance: adjust chunk importance scores. rerank_documents: re-score document relevance for a query."
|
|
4112
4140
|
},
|
|
4113
4141
|
{
|
|
4114
4142
|
title: "MCP tools \u2014 system, operations, and admin",
|
|
@@ -4126,7 +4154,7 @@ var init_platform_procedures = __esm({
|
|
|
4126
4154
|
title: "MCP tools \u2014 advanced (triggers, skills, orchestration)",
|
|
4127
4155
|
domain: "tool-use",
|
|
4128
4156
|
priority: "p1",
|
|
4129
|
-
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. global_procedure: manage
|
|
4157
|
+
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. global_procedure: manage customer-owned company procedures (Layer 0; actions: store, list, deactivate). Legacy aliases: store_global_procedure, list_global_procedures, deactivate_global_procedure."
|
|
4130
4158
|
}
|
|
4131
4159
|
];
|
|
4132
4160
|
PLATFORM_PROCEDURE_TITLES = new Set(
|
|
@@ -5162,7 +5190,7 @@ __export(file_grep_exports, {
|
|
|
5162
5190
|
grepProjectFiles: () => grepProjectFiles
|
|
5163
5191
|
});
|
|
5164
5192
|
import { execSync as execSync4 } from "child_process";
|
|
5165
|
-
import { readFileSync as readFileSync6, readdirSync as readdirSync2, statSync as
|
|
5193
|
+
import { readFileSync as readFileSync6, readdirSync as readdirSync2, statSync as statSync3, existsSync as existsSync10 } from "fs";
|
|
5166
5194
|
import path11 from "path";
|
|
5167
5195
|
import crypto2 from "crypto";
|
|
5168
5196
|
function hasRipgrep() {
|
|
@@ -5279,7 +5307,7 @@ function grepWithNodeFs(pattern, projectRoot, patterns) {
|
|
|
5279
5307
|
for (const filePath of files.slice(0, MAX_FILES)) {
|
|
5280
5308
|
const absPath = path11.join(projectRoot, filePath);
|
|
5281
5309
|
try {
|
|
5282
|
-
const stat =
|
|
5310
|
+
const stat = statSync3(absPath);
|
|
5283
5311
|
if (stat.size > MAX_FILE_SIZE) continue;
|
|
5284
5312
|
const content = readFileSync6(absPath, "utf8");
|
|
5285
5313
|
const lines = content.split("\n");
|
|
@@ -7006,7 +7034,7 @@ var init_provider_table = __esm({
|
|
|
7006
7034
|
});
|
|
7007
7035
|
|
|
7008
7036
|
// src/lib/intercom-queue.ts
|
|
7009
|
-
import { readFileSync as readFileSync8, writeFileSync as writeFileSync5, renameSync as
|
|
7037
|
+
import { readFileSync as readFileSync8, writeFileSync as writeFileSync5, renameSync as renameSync4, existsSync as existsSync11, mkdirSync as mkdirSync4 } from "fs";
|
|
7010
7038
|
import path14 from "path";
|
|
7011
7039
|
import os7 from "os";
|
|
7012
7040
|
var QUEUE_PATH, TTL_MS, INTERCOM_LOG;
|
|
@@ -7483,6 +7511,9 @@ function ensureDir() {
|
|
|
7483
7511
|
function identityPath(agentId) {
|
|
7484
7512
|
return path19.join(IDENTITY_DIR2, `${agentId}.md`);
|
|
7485
7513
|
}
|
|
7514
|
+
function sanitizeIdentityBody(body) {
|
|
7515
|
+
return body.replace(/<!--[\s\S]*?-->/g, "").trim();
|
|
7516
|
+
}
|
|
7486
7517
|
function parseFrontmatter(raw) {
|
|
7487
7518
|
const match = raw.match(/^---\n([\s\S]*?)\n---\n([\s\S]*)$/);
|
|
7488
7519
|
if (!match) {
|
|
@@ -7495,11 +7526,11 @@ function parseFrontmatter(raw) {
|
|
|
7495
7526
|
created_by: "system",
|
|
7496
7527
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
7497
7528
|
},
|
|
7498
|
-
body: raw
|
|
7529
|
+
body: sanitizeIdentityBody(raw)
|
|
7499
7530
|
};
|
|
7500
7531
|
}
|
|
7501
7532
|
const yamlStr = match[1];
|
|
7502
|
-
const body = match[2]
|
|
7533
|
+
const body = sanitizeIdentityBody(match[2]);
|
|
7503
7534
|
const fm = {};
|
|
7504
7535
|
for (const line of yamlStr.split("\n")) {
|
|
7505
7536
|
const kv = line.match(/^(\w+):\s*(.+)$/);
|
|
@@ -7564,7 +7595,9 @@ function listIdentities() {
|
|
|
7564
7595
|
const summary = lines[0]?.trim().slice(0, 120) ?? identity.frontmatter.title;
|
|
7565
7596
|
results.push({
|
|
7566
7597
|
agentId,
|
|
7567
|
-
title
|
|
7598
|
+
// User-facing/team-facing title only. `frontmatter.role` is internal
|
|
7599
|
+
// routing metadata and must not leak as an external title.
|
|
7600
|
+
title: identity.frontmatter.title,
|
|
7568
7601
|
summary
|
|
7569
7602
|
});
|
|
7570
7603
|
}
|
package/dist/hooks/stop.js
CHANGED
|
@@ -3698,7 +3698,7 @@ __export(shard_manager_exports, {
|
|
|
3698
3698
|
shardExists: () => shardExists
|
|
3699
3699
|
});
|
|
3700
3700
|
import path14 from "path";
|
|
3701
|
-
import { existsSync as existsSync12, mkdirSync as mkdirSync6, readdirSync as readdirSync3 } from "fs";
|
|
3701
|
+
import { existsSync as existsSync12, mkdirSync as mkdirSync6, readdirSync as readdirSync3, renameSync as renameSync4, statSync as statSync2 } from "fs";
|
|
3702
3702
|
import { createClient as createClient2 } from "@libsql/client";
|
|
3703
3703
|
function initShardManager(encryptionKey) {
|
|
3704
3704
|
_encryptionKey = encryptionKey;
|
|
@@ -3720,7 +3720,7 @@ function getShardClient(projectName) {
|
|
|
3720
3720
|
if (!_encryptionKey) {
|
|
3721
3721
|
throw new Error("Shard manager not initialized. Call initShardManager() first.");
|
|
3722
3722
|
}
|
|
3723
|
-
const safeName = projectName
|
|
3723
|
+
const safeName = safeShardName(projectName);
|
|
3724
3724
|
if (!safeName || safeName === "unknown") {
|
|
3725
3725
|
throw new Error(`Invalid project name for shard: "${projectName}" (resolved to "${safeName}")`);
|
|
3726
3726
|
}
|
|
@@ -3742,9 +3742,12 @@ function getShardClient(projectName) {
|
|
|
3742
3742
|
return client;
|
|
3743
3743
|
}
|
|
3744
3744
|
function shardExists(projectName) {
|
|
3745
|
-
const safeName = projectName
|
|
3745
|
+
const safeName = safeShardName(projectName);
|
|
3746
3746
|
return existsSync12(path14.join(SHARDS_DIR, `${safeName}.db`));
|
|
3747
3747
|
}
|
|
3748
|
+
function safeShardName(projectName) {
|
|
3749
|
+
return projectName.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
3750
|
+
}
|
|
3748
3751
|
function listShards() {
|
|
3749
3752
|
if (!existsSync12(SHARDS_DIR)) return [];
|
|
3750
3753
|
return readdirSync3(SHARDS_DIR).filter((f) => f.endsWith(".db")).map((f) => f.replace(".db", ""));
|
|
@@ -3838,7 +3841,8 @@ async function ensureShardSchema(client) {
|
|
|
3838
3841
|
"ALTER TABLE memories ADD COLUMN token_cost REAL",
|
|
3839
3842
|
"ALTER TABLE memories ADD COLUMN audience TEXT",
|
|
3840
3843
|
"ALTER TABLE memories ADD COLUMN language_type TEXT",
|
|
3841
|
-
"ALTER TABLE memories ADD COLUMN parent_memory_id TEXT"
|
|
3844
|
+
"ALTER TABLE memories ADD COLUMN parent_memory_id TEXT",
|
|
3845
|
+
"ALTER TABLE memories ADD COLUMN deleted_at TEXT"
|
|
3842
3846
|
]) {
|
|
3843
3847
|
try {
|
|
3844
3848
|
await client.execute(col);
|
|
@@ -3934,9 +3938,32 @@ async function ensureShardSchema(client) {
|
|
|
3934
3938
|
}
|
|
3935
3939
|
}
|
|
3936
3940
|
async function getReadyShardClient(projectName) {
|
|
3937
|
-
const
|
|
3938
|
-
|
|
3939
|
-
|
|
3941
|
+
const safeName = safeShardName(projectName);
|
|
3942
|
+
let client = getShardClient(projectName);
|
|
3943
|
+
try {
|
|
3944
|
+
await ensureShardSchema(client);
|
|
3945
|
+
return client;
|
|
3946
|
+
} catch (err) {
|
|
3947
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
3948
|
+
if (!/SQLITE_NOTADB|file is not a database/i.test(message)) throw err;
|
|
3949
|
+
client.close();
|
|
3950
|
+
_shards.delete(safeName);
|
|
3951
|
+
_shardLastAccess.delete(safeName);
|
|
3952
|
+
const dbPath = path14.join(SHARDS_DIR, `${safeName}.db`);
|
|
3953
|
+
if (existsSync12(dbPath)) {
|
|
3954
|
+
const stat = statSync2(dbPath);
|
|
3955
|
+
const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
3956
|
+
const archivedPath = path14.join(SHARDS_DIR, `${safeName}.db.broken-${stamp}`);
|
|
3957
|
+
renameSync4(dbPath, archivedPath);
|
|
3958
|
+
process.stderr.write(
|
|
3959
|
+
`[shard-manager] Archived unreadable shard ${safeName}: ${archivedPath} (${stat.size} bytes, mtime ${stat.mtime.toISOString()})
|
|
3960
|
+
`
|
|
3961
|
+
);
|
|
3962
|
+
}
|
|
3963
|
+
client = getShardClient(projectName);
|
|
3964
|
+
await ensureShardSchema(client);
|
|
3965
|
+
return client;
|
|
3966
|
+
}
|
|
3940
3967
|
}
|
|
3941
3968
|
function evictLRU() {
|
|
3942
3969
|
let oldest = null;
|
|
@@ -4157,7 +4184,7 @@ var init_platform_procedures = __esm({
|
|
|
4157
4184
|
title: "MCP tools \u2014 wiki, documents, and content",
|
|
4158
4185
|
domain: "tool-use",
|
|
4159
4186
|
priority: "p1",
|
|
4160
|
-
content: "
|
|
4187
|
+
content: "wiki: read/list wiki pages only. Direct wiki write tools are removed; wiki updates flow through raw-data ingestion/projection into the curated wiki store. Legacy aliases: list_wiki_pages/get_wiki_page. crm: read/list/get CRM records from exe-db. raw_data: read capped raw landing-pad events from exe-db with payload opt-in. ingest_document: import a file (PDF, MD, etc.) into memory as chunks. list_documents: browse ingested documents by workspace. purge_document: remove a document and its memory chunks. set_document_importance: adjust chunk importance scores. rerank_documents: re-score document relevance for a query."
|
|
4161
4188
|
},
|
|
4162
4189
|
{
|
|
4163
4190
|
title: "MCP tools \u2014 system, operations, and admin",
|
|
@@ -4175,7 +4202,7 @@ var init_platform_procedures = __esm({
|
|
|
4175
4202
|
title: "MCP tools \u2014 advanced (triggers, skills, orchestration)",
|
|
4176
4203
|
domain: "tool-use",
|
|
4177
4204
|
priority: "p1",
|
|
4178
|
-
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. global_procedure: manage
|
|
4205
|
+
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. global_procedure: manage customer-owned company procedures (Layer 0; actions: store, list, deactivate). Legacy aliases: store_global_procedure, list_global_procedures, deactivate_global_procedure."
|
|
4179
4206
|
}
|
|
4180
4207
|
];
|
|
4181
4208
|
PLATFORM_PROCEDURE_TITLES = new Set(
|
|
@@ -4941,7 +4968,7 @@ var init_fast_db_init = __esm({
|
|
|
4941
4968
|
});
|
|
4942
4969
|
|
|
4943
4970
|
// src/lib/memory-queue.ts
|
|
4944
|
-
import { appendFileSync as appendFileSync2, readFileSync as readFileSync11, renameSync as
|
|
4971
|
+
import { appendFileSync as appendFileSync2, readFileSync as readFileSync11, renameSync as renameSync5, unlinkSync as unlinkSync4, existsSync as existsSync13, statSync as statSync3 } from "fs";
|
|
4945
4972
|
import path15 from "path";
|
|
4946
4973
|
function enqueueMemory(entry) {
|
|
4947
4974
|
appendFileSync2(QUEUE_PATH2, JSON.stringify(entry) + "\n");
|
|
@@ -3679,7 +3679,7 @@ __export(shard_manager_exports, {
|
|
|
3679
3679
|
shardExists: () => shardExists
|
|
3680
3680
|
});
|
|
3681
3681
|
import path14 from "path";
|
|
3682
|
-
import { existsSync as existsSync12, mkdirSync as mkdirSync6, readdirSync as readdirSync3 } from "fs";
|
|
3682
|
+
import { existsSync as existsSync12, mkdirSync as mkdirSync6, readdirSync as readdirSync3, renameSync as renameSync4, statSync as statSync2 } from "fs";
|
|
3683
3683
|
import { createClient as createClient2 } from "@libsql/client";
|
|
3684
3684
|
function initShardManager(encryptionKey) {
|
|
3685
3685
|
_encryptionKey = encryptionKey;
|
|
@@ -3701,7 +3701,7 @@ function getShardClient(projectName) {
|
|
|
3701
3701
|
if (!_encryptionKey) {
|
|
3702
3702
|
throw new Error("Shard manager not initialized. Call initShardManager() first.");
|
|
3703
3703
|
}
|
|
3704
|
-
const safeName = projectName
|
|
3704
|
+
const safeName = safeShardName(projectName);
|
|
3705
3705
|
if (!safeName || safeName === "unknown") {
|
|
3706
3706
|
throw new Error(`Invalid project name for shard: "${projectName}" (resolved to "${safeName}")`);
|
|
3707
3707
|
}
|
|
@@ -3723,9 +3723,12 @@ function getShardClient(projectName) {
|
|
|
3723
3723
|
return client;
|
|
3724
3724
|
}
|
|
3725
3725
|
function shardExists(projectName) {
|
|
3726
|
-
const safeName = projectName
|
|
3726
|
+
const safeName = safeShardName(projectName);
|
|
3727
3727
|
return existsSync12(path14.join(SHARDS_DIR, `${safeName}.db`));
|
|
3728
3728
|
}
|
|
3729
|
+
function safeShardName(projectName) {
|
|
3730
|
+
return projectName.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
3731
|
+
}
|
|
3729
3732
|
function listShards() {
|
|
3730
3733
|
if (!existsSync12(SHARDS_DIR)) return [];
|
|
3731
3734
|
return readdirSync3(SHARDS_DIR).filter((f) => f.endsWith(".db")).map((f) => f.replace(".db", ""));
|
|
@@ -3819,7 +3822,8 @@ async function ensureShardSchema(client) {
|
|
|
3819
3822
|
"ALTER TABLE memories ADD COLUMN token_cost REAL",
|
|
3820
3823
|
"ALTER TABLE memories ADD COLUMN audience TEXT",
|
|
3821
3824
|
"ALTER TABLE memories ADD COLUMN language_type TEXT",
|
|
3822
|
-
"ALTER TABLE memories ADD COLUMN parent_memory_id TEXT"
|
|
3825
|
+
"ALTER TABLE memories ADD COLUMN parent_memory_id TEXT",
|
|
3826
|
+
"ALTER TABLE memories ADD COLUMN deleted_at TEXT"
|
|
3823
3827
|
]) {
|
|
3824
3828
|
try {
|
|
3825
3829
|
await client.execute(col);
|
|
@@ -3915,9 +3919,32 @@ async function ensureShardSchema(client) {
|
|
|
3915
3919
|
}
|
|
3916
3920
|
}
|
|
3917
3921
|
async function getReadyShardClient(projectName) {
|
|
3918
|
-
const
|
|
3919
|
-
|
|
3920
|
-
|
|
3922
|
+
const safeName = safeShardName(projectName);
|
|
3923
|
+
let client = getShardClient(projectName);
|
|
3924
|
+
try {
|
|
3925
|
+
await ensureShardSchema(client);
|
|
3926
|
+
return client;
|
|
3927
|
+
} catch (err) {
|
|
3928
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
3929
|
+
if (!/SQLITE_NOTADB|file is not a database/i.test(message)) throw err;
|
|
3930
|
+
client.close();
|
|
3931
|
+
_shards.delete(safeName);
|
|
3932
|
+
_shardLastAccess.delete(safeName);
|
|
3933
|
+
const dbPath = path14.join(SHARDS_DIR, `${safeName}.db`);
|
|
3934
|
+
if (existsSync12(dbPath)) {
|
|
3935
|
+
const stat = statSync2(dbPath);
|
|
3936
|
+
const stamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
3937
|
+
const archivedPath = path14.join(SHARDS_DIR, `${safeName}.db.broken-${stamp}`);
|
|
3938
|
+
renameSync4(dbPath, archivedPath);
|
|
3939
|
+
process.stderr.write(
|
|
3940
|
+
`[shard-manager] Archived unreadable shard ${safeName}: ${archivedPath} (${stat.size} bytes, mtime ${stat.mtime.toISOString()})
|
|
3941
|
+
`
|
|
3942
|
+
);
|
|
3943
|
+
}
|
|
3944
|
+
client = getShardClient(projectName);
|
|
3945
|
+
await ensureShardSchema(client);
|
|
3946
|
+
return client;
|
|
3947
|
+
}
|
|
3921
3948
|
}
|
|
3922
3949
|
function evictLRU() {
|
|
3923
3950
|
let oldest = null;
|
|
@@ -4138,7 +4165,7 @@ var init_platform_procedures = __esm({
|
|
|
4138
4165
|
title: "MCP tools \u2014 wiki, documents, and content",
|
|
4139
4166
|
domain: "tool-use",
|
|
4140
4167
|
priority: "p1",
|
|
4141
|
-
content: "
|
|
4168
|
+
content: "wiki: read/list wiki pages only. Direct wiki write tools are removed; wiki updates flow through raw-data ingestion/projection into the curated wiki store. Legacy aliases: list_wiki_pages/get_wiki_page. crm: read/list/get CRM records from exe-db. raw_data: read capped raw landing-pad events from exe-db with payload opt-in. ingest_document: import a file (PDF, MD, etc.) into memory as chunks. list_documents: browse ingested documents by workspace. purge_document: remove a document and its memory chunks. set_document_importance: adjust chunk importance scores. rerank_documents: re-score document relevance for a query."
|
|
4142
4169
|
},
|
|
4143
4170
|
{
|
|
4144
4171
|
title: "MCP tools \u2014 system, operations, and admin",
|
|
@@ -4156,7 +4183,7 @@ var init_platform_procedures = __esm({
|
|
|
4156
4183
|
title: "MCP tools \u2014 advanced (triggers, skills, orchestration)",
|
|
4157
4184
|
domain: "tool-use",
|
|
4158
4185
|
priority: "p1",
|
|
4159
|
-
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. global_procedure: manage
|
|
4186
|
+
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. global_procedure: manage customer-owned company procedures (Layer 0; actions: store, list, deactivate). Legacy aliases: store_global_procedure, list_global_procedures, deactivate_global_procedure."
|
|
4160
4187
|
}
|
|
4161
4188
|
];
|
|
4162
4189
|
PLATFORM_PROCEDURE_TITLES = new Set(
|