@askexenow/exe-os 0.9.59 → 0.9.61

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.
Files changed (73) hide show
  1. package/dist/bin/backfill-conversations.js +72 -5
  2. package/dist/bin/backfill-responses.js +72 -5
  3. package/dist/bin/backfill-vectors.js +72 -5
  4. package/dist/bin/cc-doctor.js +376 -0
  5. package/dist/bin/cleanup-stale-review-tasks.js +72 -5
  6. package/dist/bin/cli.js +180 -50
  7. package/dist/bin/customer-readiness.js +33 -0
  8. package/dist/bin/exe-agent.js +1 -1
  9. package/dist/bin/exe-assign.js +72 -5
  10. package/dist/bin/exe-boot.js +78 -11
  11. package/dist/bin/exe-call.js +1 -1
  12. package/dist/bin/exe-dispatch.js +72 -5
  13. package/dist/bin/exe-doctor.js +72 -5
  14. package/dist/bin/exe-export-behaviors.js +72 -5
  15. package/dist/bin/exe-forget.js +72 -5
  16. package/dist/bin/exe-gateway.js +72 -5
  17. package/dist/bin/exe-heartbeat.js +72 -5
  18. package/dist/bin/exe-kill.js +72 -5
  19. package/dist/bin/exe-launch-agent.js +72 -5
  20. package/dist/bin/exe-link.js +74 -7
  21. package/dist/bin/exe-new-employee.js +48 -19
  22. package/dist/bin/exe-pending-messages.js +72 -5
  23. package/dist/bin/exe-pending-notifications.js +72 -5
  24. package/dist/bin/exe-pending-reviews.js +72 -5
  25. package/dist/bin/exe-rename.js +72 -5
  26. package/dist/bin/exe-review.js +72 -5
  27. package/dist/bin/exe-search.js +72 -5
  28. package/dist/bin/exe-session-cleanup.js +72 -5
  29. package/dist/bin/exe-start-codex.js +128 -10
  30. package/dist/bin/exe-start-opencode.js +103 -10
  31. package/dist/bin/exe-status.js +72 -5
  32. package/dist/bin/exe-team.js +72 -5
  33. package/dist/bin/git-sweep.js +72 -5
  34. package/dist/bin/graph-backfill.js +72 -5
  35. package/dist/bin/graph-export.js +72 -5
  36. package/dist/bin/install.js +69 -23
  37. package/dist/bin/intercom-check.js +72 -5
  38. package/dist/bin/pre-build-guard.js +98 -0
  39. package/dist/bin/scan-tasks.js +72 -5
  40. package/dist/bin/setup.js +75 -8
  41. package/dist/bin/shard-migrate.js +72 -5
  42. package/dist/gateway/index.js +78 -11
  43. package/dist/hooks/bug-report-worker.js +72 -5
  44. package/dist/hooks/codex-stop-task-finalizer.js +72 -5
  45. package/dist/hooks/commit-complete.js +72 -5
  46. package/dist/hooks/error-recall.js +72 -5
  47. package/dist/hooks/ingest.js +72 -5
  48. package/dist/hooks/instructions-loaded.js +72 -5
  49. package/dist/hooks/notification.js +72 -5
  50. package/dist/hooks/post-compact.js +72 -5
  51. package/dist/hooks/post-tool-combined.js +72 -5
  52. package/dist/hooks/pre-compact.js +72 -5
  53. package/dist/hooks/pre-tool-use.js +72 -5
  54. package/dist/hooks/prompt-submit.js +72 -5
  55. package/dist/hooks/session-end.js +72 -5
  56. package/dist/hooks/session-start.js +72 -5
  57. package/dist/hooks/stop.js +72 -5
  58. package/dist/hooks/subagent-stop.js +72 -5
  59. package/dist/hooks/summary-worker.js +78 -11
  60. package/dist/index.js +78 -11
  61. package/dist/lib/cloud-sync.js +74 -7
  62. package/dist/lib/database.js +68 -1
  63. package/dist/lib/db.js +68 -1
  64. package/dist/lib/device-registry.js +68 -1
  65. package/dist/lib/employee-templates.js +1 -1
  66. package/dist/lib/exe-daemon.js +103 -26
  67. package/dist/lib/hybrid-search.js +72 -5
  68. package/dist/lib/schedules.js +72 -5
  69. package/dist/lib/store.js +72 -5
  70. package/dist/mcp/server.js +103 -26
  71. package/dist/runtime/index.js +72 -5
  72. package/dist/tui/App.js +80 -13
  73. package/package.json +1 -1
@@ -0,0 +1,376 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/bin/exe-healthcheck.ts
4
+ import { existsSync, readFileSync, readdirSync } from "fs";
5
+ import path from "path";
6
+ import { execSync } from "child_process";
7
+ import { fileURLToPath as fileURLToPath2 } from "url";
8
+
9
+ // src/lib/is-main.ts
10
+ import { realpathSync } from "fs";
11
+ import { fileURLToPath } from "url";
12
+ function isMainModule(importMetaUrl) {
13
+ if (process.argv[1] == null) return false;
14
+ if (process.argv[1].includes("mcp/server")) return false;
15
+ try {
16
+ const scriptPath = realpathSync(process.argv[1]);
17
+ const modulePath = realpathSync(fileURLToPath(importMetaUrl));
18
+ return scriptPath === modulePath;
19
+ } catch {
20
+ return importMetaUrl === `file://${process.argv[1]}` || importMetaUrl === new URL(process.argv[1], "file://").href;
21
+ }
22
+ }
23
+
24
+ // src/bin/exe-healthcheck.ts
25
+ function findPackageRoot() {
26
+ let dir = path.dirname(fileURLToPath2(import.meta.url));
27
+ const { root } = path.parse(dir);
28
+ while (dir !== root) {
29
+ if (existsSync(path.join(dir, "package.json"))) return dir;
30
+ dir = path.dirname(dir);
31
+ }
32
+ throw new Error("Cannot find package root");
33
+ }
34
+ function checkBuildIntegrity(pkgRoot) {
35
+ const results = [];
36
+ const tsupConfig = path.join(pkgRoot, "tsup.config.ts");
37
+ if (!existsSync(tsupConfig)) {
38
+ return [{ name: "build/tsup-config", pass: false, detail: "tsup.config.ts not found" }];
39
+ }
40
+ const configContent = readFileSync(tsupConfig, "utf-8");
41
+ const entryMatches = configContent.matchAll(/"([^"]+)":\s*"src\//g);
42
+ const missing = [];
43
+ let total = 0;
44
+ for (const match of entryMatches) {
45
+ const outputKey = match[1];
46
+ const expectedPath = path.join(pkgRoot, "dist", `${outputKey}.js`);
47
+ total++;
48
+ if (!existsSync(expectedPath)) {
49
+ missing.push(`dist/${outputKey}.js`);
50
+ }
51
+ }
52
+ if (missing.length > 0) {
53
+ results.push({
54
+ name: "build/entry-points",
55
+ pass: false,
56
+ detail: `${missing.length}/${total} entry points missing:
57
+ ${missing.join("\n ")}`
58
+ });
59
+ } else {
60
+ results.push({
61
+ name: "build/entry-points",
62
+ pass: true,
63
+ detail: `${total} entry points verified`
64
+ });
65
+ }
66
+ return results;
67
+ }
68
+ function checkEmbedPipeline(pkgRoot) {
69
+ const results = [];
70
+ const daemonPath = path.join(pkgRoot, "dist", "lib", "exe-daemon.js");
71
+ if (!existsSync(daemonPath)) {
72
+ results.push({
73
+ name: "exed/daemon-exists",
74
+ pass: false,
75
+ detail: `exe-daemon.js not found at ${daemonPath}`
76
+ });
77
+ return results;
78
+ }
79
+ results.push({ name: "exed/daemon-exists", pass: true, detail: "dist/lib/exe-daemon.js exists" });
80
+ const entryDirs = ["dist/hooks", "dist/bin", "dist/mcp"];
81
+ for (const dir of entryDirs) {
82
+ const fullDir = path.join(pkgRoot, dir);
83
+ if (!existsSync(fullDir)) continue;
84
+ let walkDir = fullDir;
85
+ const { root } = path.parse(walkDir);
86
+ let foundRoot = null;
87
+ while (walkDir !== root) {
88
+ if (existsSync(path.join(walkDir, "package.json"))) {
89
+ foundRoot = walkDir;
90
+ break;
91
+ }
92
+ walkDir = path.dirname(walkDir);
93
+ }
94
+ if (!foundRoot) {
95
+ results.push({
96
+ name: `exed/reachable-from-${dir}`,
97
+ pass: false,
98
+ detail: `Cannot find package root from ${dir}`
99
+ });
100
+ continue;
101
+ }
102
+ const resolvedDaemon = path.join(foundRoot, "dist", "lib", "exe-daemon.js");
103
+ const reachable = existsSync(resolvedDaemon);
104
+ results.push({
105
+ name: `exed/reachable-from-${dir}`,
106
+ pass: reachable,
107
+ detail: reachable ? `Resolves to ${resolvedDaemon}` : `NOT FOUND: ${resolvedDaemon}`
108
+ });
109
+ }
110
+ return results;
111
+ }
112
+ function checkTaskSystem(pkgRoot) {
113
+ const results = [];
114
+ const scannerPath = path.join(pkgRoot, "dist", "bin", "scan-tasks.js");
115
+ if (!existsSync(scannerPath)) {
116
+ results.push({ name: "tasks/scanner", pass: false, detail: "scan-tasks.js not found" });
117
+ return results;
118
+ }
119
+ try {
120
+ execSync(`node "${scannerPath}" /tmp/nonexistent-healthcheck-test --format=json 2>/dev/null`, {
121
+ timeout: 1e4,
122
+ encoding: "utf-8"
123
+ });
124
+ results.push({ name: "tasks/scanner", pass: true, detail: "scan-tasks.js runs without import errors" });
125
+ } catch (err) {
126
+ const msg = err instanceof Error ? err.message : String(err);
127
+ if (msg.includes("Cannot find module") || msg.includes("ERR_MODULE_NOT_FOUND") || msg.includes("SyntaxError")) {
128
+ results.push({ name: "tasks/scanner", pass: false, detail: `Import error: ${msg.slice(0, 200)}` });
129
+ } else {
130
+ results.push({ name: "tasks/scanner", pass: true, detail: "scan-tasks.js runs (no import errors)" });
131
+ }
132
+ }
133
+ return results;
134
+ }
135
+ function checkWorkerSpawning(pkgRoot) {
136
+ const results = [];
137
+ const workerPath = path.join(pkgRoot, "dist", "hooks", "ingest-worker.js");
138
+ if (!existsSync(workerPath)) {
139
+ results.push({ name: "workers/ingest-worker", pass: false, detail: "ingest-worker.js not found" });
140
+ return results;
141
+ }
142
+ try {
143
+ execSync(`node --check "${workerPath}" 2>&1`, { timeout: 1e4, encoding: "utf-8" });
144
+ results.push({ name: "workers/ingest-worker", pass: true, detail: "ingest-worker.js parses OK" });
145
+ } catch (err) {
146
+ results.push({
147
+ name: "workers/ingest-worker",
148
+ pass: false,
149
+ detail: `Parse error: ${err instanceof Error ? err.message.slice(0, 200) : String(err)}`
150
+ });
151
+ }
152
+ const hooksDir = path.join(pkgRoot, "dist", "hooks");
153
+ if (existsSync(hooksDir)) {
154
+ const hookFiles = readdirSync(hooksDir).filter((f) => f.endsWith(".js") && !f.endsWith(".js.map"));
155
+ let hooksPassed = 0;
156
+ const hooksFailed = [];
157
+ for (const hook of hookFiles) {
158
+ try {
159
+ execSync(`node --check "${path.join(hooksDir, hook)}" 2>&1`, { timeout: 1e4, encoding: "utf-8" });
160
+ hooksPassed++;
161
+ } catch {
162
+ hooksFailed.push(hook);
163
+ }
164
+ }
165
+ if (hooksFailed.length > 0) {
166
+ results.push({
167
+ name: "workers/hooks-parse",
168
+ pass: false,
169
+ detail: `${hooksFailed.length}/${hookFiles.length} hooks fail to parse: ${hooksFailed.join(", ")}`
170
+ });
171
+ } else {
172
+ results.push({
173
+ name: "workers/hooks-parse",
174
+ pass: true,
175
+ detail: `${hooksPassed} hook entry points parse OK`
176
+ });
177
+ }
178
+ }
179
+ return results;
180
+ }
181
+ function checkClaudeCodeInstall() {
182
+ const results = [];
183
+ const execPath = process.env.CLAUDE_CODE_EXECPATH ?? "";
184
+ if (execPath.length > 0 && (execPath.includes("claude/versions/") || execPath.includes("claude.exe") || execPath.includes("claude-native"))) {
185
+ results.push({
186
+ name: "cc/execpath-clean",
187
+ pass: false,
188
+ detail: `CLAUDE_CODE_EXECPATH points to native binary: "${execPath}" \u2014 20K phantom billing risk. Unset it: unset CLAUDE_CODE_EXECPATH`
189
+ });
190
+ } else {
191
+ results.push({
192
+ name: "cc/execpath-clean",
193
+ pass: true,
194
+ detail: execPath ? `CLAUDE_CODE_EXECPATH=${execPath} (node runtime, OK)` : "CLAUDE_CODE_EXECPATH is unset"
195
+ });
196
+ }
197
+ try {
198
+ const claudePath = execSync("which claude 2>/dev/null || true", { encoding: "utf8", timeout: 5e3 }).trim();
199
+ if (!claudePath) {
200
+ results.push({
201
+ name: "cc/cli-binary",
202
+ pass: false,
203
+ detail: "claude not found in PATH"
204
+ });
205
+ } else {
206
+ let resolved = claudePath;
207
+ try {
208
+ resolved = execSync(`readlink -f "${claudePath}" 2>/dev/null || readlink "${claudePath}" 2>/dev/null || echo "${claudePath}"`, {
209
+ encoding: "utf8",
210
+ timeout: 5e3
211
+ }).trim();
212
+ } catch {
213
+ }
214
+ if (resolved.includes("bin/claude.exe") || resolved.includes("bin/claude-native")) {
215
+ results.push({
216
+ name: "cc/cli-binary",
217
+ pass: false,
218
+ detail: `claude resolves to native binary: ${resolved}. Should be cli.js. Run: npm install -g @anthropic-ai/claude-code@2.1.98`
219
+ });
220
+ } else {
221
+ results.push({
222
+ name: "cc/cli-binary",
223
+ pass: true,
224
+ detail: `claude resolves to: ${resolved}`
225
+ });
226
+ }
227
+ }
228
+ } catch {
229
+ results.push({
230
+ name: "cc/cli-binary",
231
+ pass: false,
232
+ detail: "Failed to check claude binary path"
233
+ });
234
+ }
235
+ const versionsDir = path.join(
236
+ process.env.HOME ?? process.env.USERPROFILE ?? "",
237
+ ".local",
238
+ "share",
239
+ "claude",
240
+ "versions"
241
+ );
242
+ if (existsSync(versionsDir)) {
243
+ try {
244
+ const entries = readdirSync(versionsDir);
245
+ if (entries.length > 0) {
246
+ results.push({
247
+ name: "cc/native-cache-clean",
248
+ pass: false,
249
+ detail: `${entries.length} cached native version(s) found in ${versionsDir}: ${entries.slice(0, 3).join(", ")}${entries.length > 3 ? "..." : ""}. Remove: rm -rf "${versionsDir}"`
250
+ });
251
+ } else {
252
+ results.push({
253
+ name: "cc/native-cache-clean",
254
+ pass: true,
255
+ detail: `${versionsDir} is empty`
256
+ });
257
+ }
258
+ } catch {
259
+ results.push({
260
+ name: "cc/native-cache-clean",
261
+ pass: true,
262
+ detail: `${versionsDir} not readable (OK)`
263
+ });
264
+ }
265
+ } else {
266
+ results.push({
267
+ name: "cc/native-cache-clean",
268
+ pass: true,
269
+ detail: `${versionsDir} does not exist`
270
+ });
271
+ }
272
+ const disableOld = process.env.DISABLE_AUTOUPDATER === "1";
273
+ const disableNew = process.env.CLAUDE_CODE_AUTOUPDATER_DISABLED === "1";
274
+ if (!disableOld && !disableNew) {
275
+ results.push({
276
+ name: "cc/autoupdater-disabled",
277
+ pass: false,
278
+ detail: "Neither DISABLE_AUTOUPDATER=1 nor CLAUDE_CODE_AUTOUPDATER_DISABLED=1 is set. Auto-updater may install infected native binary. Export both in your shell profile."
279
+ });
280
+ } else {
281
+ const which = [
282
+ disableOld ? "DISABLE_AUTOUPDATER=1" : null,
283
+ disableNew ? "CLAUDE_CODE_AUTOUPDATER_DISABLED=1" : null
284
+ ].filter(Boolean).join(" + ");
285
+ results.push({
286
+ name: "cc/autoupdater-disabled",
287
+ pass: true,
288
+ detail: `Auto-updater disabled via ${which}`
289
+ });
290
+ }
291
+ try {
292
+ const ccVersion = execSync("claude --version 2>/dev/null || echo unknown", {
293
+ encoding: "utf8",
294
+ timeout: 5e3
295
+ }).trim();
296
+ const versionMatch = ccVersion.match(/(\d+\.\d+\.\d+)/);
297
+ if (versionMatch) {
298
+ const ver = versionMatch[1];
299
+ const [, minor] = ver.split(".").map(Number);
300
+ const isRisky = minor !== void 0 && minor >= 1 && parseInt(ver.split(".")[2] ?? "0") >= 119;
301
+ results.push({
302
+ name: "cc/version",
303
+ pass: !isRisky,
304
+ detail: isRisky ? `CC version ${ver} \u2014 \u22652.1.119 ships native binary only. Pin: npm install -g @anthropic-ai/claude-code@2.1.98` : `CC version ${ver}`
305
+ });
306
+ }
307
+ } catch {
308
+ }
309
+ return results;
310
+ }
311
+ function runHealthCheck() {
312
+ const pkgRoot = findPackageRoot();
313
+ const results = [
314
+ ...checkBuildIntegrity(pkgRoot),
315
+ ...checkEmbedPipeline(pkgRoot),
316
+ ...checkTaskSystem(pkgRoot),
317
+ ...checkWorkerSpawning(pkgRoot),
318
+ ...checkClaudeCodeInstall()
319
+ ];
320
+ const passed = results.filter((r) => r.pass).length;
321
+ const failed = results.filter((r) => !r.pass).length;
322
+ return { results, passed, failed };
323
+ }
324
+ if (isMainModule(import.meta.url)) {
325
+ const { results, passed, failed } = runHealthCheck();
326
+ console.log("\n exe-os Health Check\n");
327
+ for (const r of results) {
328
+ const icon = r.pass ? "\x1B[32m\u2713\x1B[0m" : "\x1B[31m\u2717\x1B[0m";
329
+ console.log(` ${icon} ${r.name}`);
330
+ console.log(` ${r.detail}`);
331
+ }
332
+ console.log(`
333
+ ${passed} passed, ${failed} failed
334
+ `);
335
+ process.exit(failed > 0 ? 1 : 0);
336
+ }
337
+
338
+ // src/bin/cc-doctor.ts
339
+ var LABELS = {
340
+ "cc/execpath-clean": "EXECPATH",
341
+ "cc/cli-binary": "Symlink",
342
+ "cc/native-cache-clean": "Native cache",
343
+ "cc/autoupdater-disabled": "Auto-updater",
344
+ "cc/version": "Version"
345
+ };
346
+ function formatResult(r) {
347
+ const icon = r.pass ? "\x1B[32m\u2713\x1B[0m" : "\x1B[31m\u2717\x1B[0m";
348
+ const label = LABELS[r.name] ?? r.name;
349
+ return `${icon} ${label}: ${r.detail}`;
350
+ }
351
+ function runCcDoctor() {
352
+ const results = checkClaudeCodeInstall();
353
+ const passed = results.filter((r) => r.pass).length;
354
+ const failed = results.filter((r) => !r.pass).length;
355
+ return { results, passed, failed };
356
+ }
357
+ if (isMainModule(import.meta.url)) {
358
+ const { results, passed, failed } = runCcDoctor();
359
+ console.log("\n CC Install Health Check\n");
360
+ for (const r of results) {
361
+ console.log(` ${formatResult(r)}`);
362
+ }
363
+ if (failed === 0) {
364
+ console.log(`
365
+ \x1B[32mStatus: CLEAN\x1B[0m \u2014 no 20K billing risk (${passed} checks passed)
366
+ `);
367
+ } else {
368
+ console.log(`
369
+ \x1B[31mStatus: ${failed} ISSUE${failed > 1 ? "S" : ""} FOUND\x1B[0m \u2014 ${passed} passed, ${failed} failed`);
370
+ console.log(" Fix: npm install -g @anthropic-ai/claude-code@2.1.98\n");
371
+ }
372
+ process.exit(failed > 0 ? 1 : 0);
373
+ }
374
+ export {
375
+ runCcDoctor
376
+ };
@@ -2515,7 +2515,7 @@ async function ensureSchema() {
2515
2515
  ON session_kills(agent_id);
2516
2516
  `);
2517
2517
  await client.execute(`
2518
- CREATE TABLE IF NOT EXISTS global_procedures (
2518
+ CREATE TABLE IF NOT EXISTS company_procedures (
2519
2519
  id TEXT PRIMARY KEY,
2520
2520
  title TEXT NOT NULL,
2521
2521
  content TEXT NOT NULL,
@@ -2526,6 +2526,73 @@ async function ensureSchema() {
2526
2526
  updated_at TEXT NOT NULL
2527
2527
  )
2528
2528
  `);
2529
+ const legacyProcedureObject = await client.execute({
2530
+ sql: "SELECT type FROM sqlite_master WHERE name = 'global_procedures'",
2531
+ args: []
2532
+ });
2533
+ const legacyProcedureType = legacyProcedureObject.rows[0]?.type == null ? null : String(legacyProcedureObject.rows[0].type);
2534
+ if (legacyProcedureType === "table") {
2535
+ await client.execute(`
2536
+ INSERT OR IGNORE INTO company_procedures
2537
+ (id, title, content, priority, domain, active, created_at, updated_at)
2538
+ SELECT id, title, content, priority, domain, active, created_at, updated_at
2539
+ FROM global_procedures
2540
+ `);
2541
+ await client.executeMultiple(`
2542
+ CREATE TRIGGER IF NOT EXISTS global_procedures_mirror_insert
2543
+ AFTER INSERT ON global_procedures
2544
+ BEGIN
2545
+ INSERT OR IGNORE INTO company_procedures
2546
+ (id, title, content, priority, domain, active, created_at, updated_at)
2547
+ VALUES
2548
+ (NEW.id, NEW.title, NEW.content, NEW.priority, NEW.domain, NEW.active, NEW.created_at, NEW.updated_at);
2549
+ END;
2550
+
2551
+ CREATE TRIGGER IF NOT EXISTS global_procedures_mirror_update
2552
+ AFTER UPDATE ON global_procedures
2553
+ BEGIN
2554
+ UPDATE company_procedures
2555
+ SET title = NEW.title,
2556
+ content = NEW.content,
2557
+ priority = NEW.priority,
2558
+ domain = NEW.domain,
2559
+ active = NEW.active,
2560
+ created_at = NEW.created_at,
2561
+ updated_at = NEW.updated_at
2562
+ WHERE id = OLD.id;
2563
+ END;
2564
+ `);
2565
+ } else {
2566
+ await client.execute(`
2567
+ CREATE VIEW IF NOT EXISTS global_procedures AS
2568
+ SELECT id, title, content, priority, domain, active, created_at, updated_at
2569
+ FROM company_procedures
2570
+ `);
2571
+ await client.executeMultiple(`
2572
+ CREATE TRIGGER IF NOT EXISTS global_procedures_insert
2573
+ INSTEAD OF INSERT ON global_procedures
2574
+ BEGIN
2575
+ INSERT INTO company_procedures
2576
+ (id, title, content, priority, domain, active, created_at, updated_at)
2577
+ VALUES
2578
+ (NEW.id, NEW.title, NEW.content, NEW.priority, NEW.domain, NEW.active, NEW.created_at, NEW.updated_at);
2579
+ END;
2580
+
2581
+ CREATE TRIGGER IF NOT EXISTS global_procedures_update
2582
+ INSTEAD OF UPDATE ON global_procedures
2583
+ BEGIN
2584
+ UPDATE company_procedures
2585
+ SET title = NEW.title,
2586
+ content = NEW.content,
2587
+ priority = NEW.priority,
2588
+ domain = NEW.domain,
2589
+ active = NEW.active,
2590
+ created_at = NEW.created_at,
2591
+ updated_at = NEW.updated_at
2592
+ WHERE id = OLD.id;
2593
+ END;
2594
+ `);
2595
+ }
2529
2596
  await client.executeMultiple(`
2530
2597
  CREATE TABLE IF NOT EXISTS conversations (
2531
2598
  id TEXT PRIMARY KEY,
@@ -3874,7 +3941,7 @@ var init_platform_procedures = __esm({
3874
3941
  title: "MCP tools \u2014 advanced (triggers, skills, orchestration)",
3875
3942
  domain: "tool-use",
3876
3943
  priority: "p1",
3877
- 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."
3944
+ 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."
3878
3945
  }
3879
3946
  ];
3880
3947
  PLATFORM_PROCEDURE_TITLES = new Set(
@@ -3895,7 +3962,7 @@ import { randomUUID as randomUUID2 } from "crypto";
3895
3962
  async function loadGlobalProcedures() {
3896
3963
  const client = getClient();
3897
3964
  const result = await client.execute({
3898
- sql: "SELECT * FROM global_procedures WHERE active = 1 ORDER BY priority ASC, created_at ASC",
3965
+ sql: "SELECT * FROM company_procedures WHERE active = 1 ORDER BY priority ASC, created_at ASC",
3899
3966
  args: []
3900
3967
  });
3901
3968
  const allRows = result.rows;
@@ -3924,7 +3991,7 @@ async function storeGlobalProcedure(input) {
3924
3991
  const now = (/* @__PURE__ */ new Date()).toISOString();
3925
3992
  const client = getClient();
3926
3993
  await client.execute({
3927
- sql: `INSERT INTO global_procedures (id, title, content, priority, domain, active, created_at, updated_at)
3994
+ sql: `INSERT INTO company_procedures (id, title, content, priority, domain, active, created_at, updated_at)
3928
3995
  VALUES (?, ?, ?, ?, ?, 1, ?, ?)`,
3929
3996
  args: [id, input.title, input.content, input.priority ?? "p0", input.domain ?? null, now, now]
3930
3997
  });
@@ -3935,7 +4002,7 @@ async function deactivateGlobalProcedure(id) {
3935
4002
  const now = (/* @__PURE__ */ new Date()).toISOString();
3936
4003
  const client = getClient();
3937
4004
  const result = await client.execute({
3938
- sql: "UPDATE global_procedures SET active = 0, updated_at = ? WHERE id = ?",
4005
+ sql: "UPDATE company_procedures SET active = 0, updated_at = ? WHERE id = ?",
3939
4006
  args: [now, id]
3940
4007
  });
3941
4008
  await loadGlobalProcedures();