@askexenow/exe-os 0.9.60 → 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 +157 -55
  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 +115 -18
  30. package/dist/bin/exe-start-opencode.js +93 -7
  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 +56 -31
  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
@@ -2439,7 +2439,7 @@ async function ensureSchema() {
2439
2439
  ON session_kills(agent_id);
2440
2440
  `);
2441
2441
  await client.execute(`
2442
- CREATE TABLE IF NOT EXISTS global_procedures (
2442
+ CREATE TABLE IF NOT EXISTS company_procedures (
2443
2443
  id TEXT PRIMARY KEY,
2444
2444
  title TEXT NOT NULL,
2445
2445
  content TEXT NOT NULL,
@@ -2450,6 +2450,73 @@ async function ensureSchema() {
2450
2450
  updated_at TEXT NOT NULL
2451
2451
  )
2452
2452
  `);
2453
+ const legacyProcedureObject = await client.execute({
2454
+ sql: "SELECT type FROM sqlite_master WHERE name = 'global_procedures'",
2455
+ args: []
2456
+ });
2457
+ const legacyProcedureType = legacyProcedureObject.rows[0]?.type == null ? null : String(legacyProcedureObject.rows[0].type);
2458
+ if (legacyProcedureType === "table") {
2459
+ await client.execute(`
2460
+ INSERT OR IGNORE INTO company_procedures
2461
+ (id, title, content, priority, domain, active, created_at, updated_at)
2462
+ SELECT id, title, content, priority, domain, active, created_at, updated_at
2463
+ FROM global_procedures
2464
+ `);
2465
+ await client.executeMultiple(`
2466
+ CREATE TRIGGER IF NOT EXISTS global_procedures_mirror_insert
2467
+ AFTER INSERT ON global_procedures
2468
+ BEGIN
2469
+ INSERT OR IGNORE INTO company_procedures
2470
+ (id, title, content, priority, domain, active, created_at, updated_at)
2471
+ VALUES
2472
+ (NEW.id, NEW.title, NEW.content, NEW.priority, NEW.domain, NEW.active, NEW.created_at, NEW.updated_at);
2473
+ END;
2474
+
2475
+ CREATE TRIGGER IF NOT EXISTS global_procedures_mirror_update
2476
+ AFTER UPDATE ON global_procedures
2477
+ BEGIN
2478
+ UPDATE company_procedures
2479
+ SET title = NEW.title,
2480
+ content = NEW.content,
2481
+ priority = NEW.priority,
2482
+ domain = NEW.domain,
2483
+ active = NEW.active,
2484
+ created_at = NEW.created_at,
2485
+ updated_at = NEW.updated_at
2486
+ WHERE id = OLD.id;
2487
+ END;
2488
+ `);
2489
+ } else {
2490
+ await client.execute(`
2491
+ CREATE VIEW IF NOT EXISTS global_procedures AS
2492
+ SELECT id, title, content, priority, domain, active, created_at, updated_at
2493
+ FROM company_procedures
2494
+ `);
2495
+ await client.executeMultiple(`
2496
+ CREATE TRIGGER IF NOT EXISTS global_procedures_insert
2497
+ INSTEAD OF INSERT ON global_procedures
2498
+ BEGIN
2499
+ INSERT INTO company_procedures
2500
+ (id, title, content, priority, domain, active, created_at, updated_at)
2501
+ VALUES
2502
+ (NEW.id, NEW.title, NEW.content, NEW.priority, NEW.domain, NEW.active, NEW.created_at, NEW.updated_at);
2503
+ END;
2504
+
2505
+ CREATE TRIGGER IF NOT EXISTS global_procedures_update
2506
+ INSTEAD OF UPDATE ON global_procedures
2507
+ BEGIN
2508
+ UPDATE company_procedures
2509
+ SET title = NEW.title,
2510
+ content = NEW.content,
2511
+ priority = NEW.priority,
2512
+ domain = NEW.domain,
2513
+ active = NEW.active,
2514
+ created_at = NEW.created_at,
2515
+ updated_at = NEW.updated_at
2516
+ WHERE id = OLD.id;
2517
+ END;
2518
+ `);
2519
+ }
2453
2520
  await client.executeMultiple(`
2454
2521
  CREATE TABLE IF NOT EXISTS conversations (
2455
2522
  id TEXT PRIMARY KEY,
@@ -3326,7 +3393,7 @@ var init_platform_procedures = __esm({
3326
3393
  title: "MCP tools \u2014 advanced (triggers, skills, orchestration)",
3327
3394
  domain: "tool-use",
3328
3395
  priority: "p1",
3329
- 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."
3396
+ 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."
3330
3397
  }
3331
3398
  ];
3332
3399
  PLATFORM_PROCEDURE_TITLES = new Set(
@@ -3347,7 +3414,7 @@ import { randomUUID as randomUUID3 } from "crypto";
3347
3414
  async function loadGlobalProcedures() {
3348
3415
  const client = getClient();
3349
3416
  const result = await client.execute({
3350
- sql: "SELECT * FROM global_procedures WHERE active = 1 ORDER BY priority ASC, created_at ASC",
3417
+ sql: "SELECT * FROM company_procedures WHERE active = 1 ORDER BY priority ASC, created_at ASC",
3351
3418
  args: []
3352
3419
  });
3353
3420
  const allRows = result.rows;
@@ -3376,7 +3443,7 @@ async function storeGlobalProcedure(input) {
3376
3443
  const now = (/* @__PURE__ */ new Date()).toISOString();
3377
3444
  const client = getClient();
3378
3445
  await client.execute({
3379
- sql: `INSERT INTO global_procedures (id, title, content, priority, domain, active, created_at, updated_at)
3446
+ sql: `INSERT INTO company_procedures (id, title, content, priority, domain, active, created_at, updated_at)
3380
3447
  VALUES (?, ?, ?, ?, ?, 1, ?, ?)`,
3381
3448
  args: [id, input.title, input.content, input.priority ?? "p0", input.domain ?? null, now, now]
3382
3449
  });
@@ -3387,7 +3454,7 @@ async function deactivateGlobalProcedure(id) {
3387
3454
  const now = (/* @__PURE__ */ new Date()).toISOString();
3388
3455
  const client = getClient();
3389
3456
  const result = await client.execute({
3390
- sql: "UPDATE global_procedures SET active = 0, updated_at = ? WHERE id = ?",
3457
+ sql: "UPDATE company_procedures SET active = 0, updated_at = ? WHERE id = ?",
3391
3458
  args: [now, id]
3392
3459
  });
3393
3460
  await loadGlobalProcedures();
@@ -2581,7 +2581,7 @@ async function ensureSchema() {
2581
2581
  ON session_kills(agent_id);
2582
2582
  `);
2583
2583
  await client.execute(`
2584
- CREATE TABLE IF NOT EXISTS global_procedures (
2584
+ CREATE TABLE IF NOT EXISTS company_procedures (
2585
2585
  id TEXT PRIMARY KEY,
2586
2586
  title TEXT NOT NULL,
2587
2587
  content TEXT NOT NULL,
@@ -2592,6 +2592,73 @@ async function ensureSchema() {
2592
2592
  updated_at TEXT NOT NULL
2593
2593
  )
2594
2594
  `);
2595
+ const legacyProcedureObject = await client.execute({
2596
+ sql: "SELECT type FROM sqlite_master WHERE name = 'global_procedures'",
2597
+ args: []
2598
+ });
2599
+ const legacyProcedureType = legacyProcedureObject.rows[0]?.type == null ? null : String(legacyProcedureObject.rows[0].type);
2600
+ if (legacyProcedureType === "table") {
2601
+ await client.execute(`
2602
+ INSERT OR IGNORE INTO company_procedures
2603
+ (id, title, content, priority, domain, active, created_at, updated_at)
2604
+ SELECT id, title, content, priority, domain, active, created_at, updated_at
2605
+ FROM global_procedures
2606
+ `);
2607
+ await client.executeMultiple(`
2608
+ CREATE TRIGGER IF NOT EXISTS global_procedures_mirror_insert
2609
+ AFTER INSERT ON global_procedures
2610
+ BEGIN
2611
+ INSERT OR IGNORE INTO company_procedures
2612
+ (id, title, content, priority, domain, active, created_at, updated_at)
2613
+ VALUES
2614
+ (NEW.id, NEW.title, NEW.content, NEW.priority, NEW.domain, NEW.active, NEW.created_at, NEW.updated_at);
2615
+ END;
2616
+
2617
+ CREATE TRIGGER IF NOT EXISTS global_procedures_mirror_update
2618
+ AFTER UPDATE ON global_procedures
2619
+ BEGIN
2620
+ UPDATE company_procedures
2621
+ SET title = NEW.title,
2622
+ content = NEW.content,
2623
+ priority = NEW.priority,
2624
+ domain = NEW.domain,
2625
+ active = NEW.active,
2626
+ created_at = NEW.created_at,
2627
+ updated_at = NEW.updated_at
2628
+ WHERE id = OLD.id;
2629
+ END;
2630
+ `);
2631
+ } else {
2632
+ await client.execute(`
2633
+ CREATE VIEW IF NOT EXISTS global_procedures AS
2634
+ SELECT id, title, content, priority, domain, active, created_at, updated_at
2635
+ FROM company_procedures
2636
+ `);
2637
+ await client.executeMultiple(`
2638
+ CREATE TRIGGER IF NOT EXISTS global_procedures_insert
2639
+ INSTEAD OF INSERT ON global_procedures
2640
+ BEGIN
2641
+ INSERT INTO company_procedures
2642
+ (id, title, content, priority, domain, active, created_at, updated_at)
2643
+ VALUES
2644
+ (NEW.id, NEW.title, NEW.content, NEW.priority, NEW.domain, NEW.active, NEW.created_at, NEW.updated_at);
2645
+ END;
2646
+
2647
+ CREATE TRIGGER IF NOT EXISTS global_procedures_update
2648
+ INSTEAD OF UPDATE ON global_procedures
2649
+ BEGIN
2650
+ UPDATE company_procedures
2651
+ SET title = NEW.title,
2652
+ content = NEW.content,
2653
+ priority = NEW.priority,
2654
+ domain = NEW.domain,
2655
+ active = NEW.active,
2656
+ created_at = NEW.created_at,
2657
+ updated_at = NEW.updated_at
2658
+ WHERE id = OLD.id;
2659
+ END;
2660
+ `);
2661
+ }
2595
2662
  await client.executeMultiple(`
2596
2663
  CREATE TABLE IF NOT EXISTS conversations (
2597
2664
  id TEXT PRIMARY KEY,
@@ -3053,7 +3120,7 @@ var init_platform_procedures = __esm({
3053
3120
  title: "MCP tools \u2014 advanced (triggers, skills, orchestration)",
3054
3121
  domain: "tool-use",
3055
3122
  priority: "p1",
3056
- 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."
3123
+ 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."
3057
3124
  }
3058
3125
  ];
3059
3126
  PLATFORM_PROCEDURE_TITLES = new Set(
@@ -3074,7 +3141,7 @@ import { randomUUID as randomUUID2 } from "crypto";
3074
3141
  async function loadGlobalProcedures() {
3075
3142
  const client = getClient();
3076
3143
  const result = await client.execute({
3077
- sql: "SELECT * FROM global_procedures WHERE active = 1 ORDER BY priority ASC, created_at ASC",
3144
+ sql: "SELECT * FROM company_procedures WHERE active = 1 ORDER BY priority ASC, created_at ASC",
3078
3145
  args: []
3079
3146
  });
3080
3147
  const allRows = result.rows;
@@ -3103,7 +3170,7 @@ async function storeGlobalProcedure(input) {
3103
3170
  const now = (/* @__PURE__ */ new Date()).toISOString();
3104
3171
  const client = getClient();
3105
3172
  await client.execute({
3106
- sql: `INSERT INTO global_procedures (id, title, content, priority, domain, active, created_at, updated_at)
3173
+ sql: `INSERT INTO company_procedures (id, title, content, priority, domain, active, created_at, updated_at)
3107
3174
  VALUES (?, ?, ?, ?, ?, 1, ?, ?)`,
3108
3175
  args: [id, input.title, input.content, input.priority ?? "p0", input.domain ?? null, now, now]
3109
3176
  });
@@ -3114,7 +3181,7 @@ async function deactivateGlobalProcedure(id) {
3114
3181
  const now = (/* @__PURE__ */ new Date()).toISOString();
3115
3182
  const client = getClient();
3116
3183
  const result = await client.execute({
3117
- sql: "UPDATE global_procedures SET active = 0, updated_at = ? WHERE id = ?",
3184
+ sql: "UPDATE company_procedures SET active = 0, updated_at = ? WHERE id = ?",
3118
3185
  args: [now, id]
3119
3186
  });
3120
3187
  await loadGlobalProcedures();
@@ -9332,12 +9399,12 @@ async function cloudSync(config) {
9332
9399
  try {
9333
9400
  await cloudPushGlobalProcedures(config);
9334
9401
  } catch (err) {
9335
- logError(`[cloud-sync] Global procedures push: ${err instanceof Error ? err.message : String(err)}`);
9402
+ logError(`[cloud-sync] Company procedures push: ${err instanceof Error ? err.message : String(err)}`);
9336
9403
  }
9337
9404
  try {
9338
9405
  await cloudPullGlobalProcedures(config);
9339
9406
  } catch (err) {
9340
- logError(`[cloud-sync] Global procedures pull: ${err instanceof Error ? err.message : String(err)}`);
9407
+ logError(`[cloud-sync] Company procedures pull: ${err instanceof Error ? err.message : String(err)}`);
9341
9408
  }
9342
9409
  const countRows = async (sql) => {
9343
9410
  try {
@@ -9746,12 +9813,12 @@ async function cloudPullBlob(route, config) {
9746
9813
  }
9747
9814
  async function cloudPushGlobalProcedures(config) {
9748
9815
  const client = getClient();
9749
- const result = await client.execute("SELECT * FROM global_procedures LIMIT 1000");
9816
+ const result = await client.execute("SELECT * FROM company_procedures LIMIT 1000");
9750
9817
  const rows = result.rows;
9751
9818
  const { ok } = await cloudPushBlob(
9752
9819
  "/sync/push-global-procedures",
9753
9820
  rows,
9754
- "last_global_procedures_push_version",
9821
+ "last_company_procedures_push_version",
9755
9822
  config
9756
9823
  );
9757
9824
  return ok;
@@ -9764,7 +9831,7 @@ async function cloudPullGlobalProcedures(config) {
9764
9831
  if (!remoteProcs || remoteProcs.length === 0) return { pulled: 0 };
9765
9832
  const client = getClient();
9766
9833
  const stmts = remoteProcs.map((p) => ({
9767
- sql: `INSERT INTO global_procedures
9834
+ sql: `INSERT INTO company_procedures
9768
9835
  (id, title, content, priority, domain, active, created_at, updated_at)
9769
9836
  VALUES (?, ?, ?, ?, ?, ?, ?, ?)
9770
9837
  ON CONFLICT(id) DO UPDATE SET
@@ -9774,7 +9841,7 @@ async function cloudPullGlobalProcedures(config) {
9774
9841
  domain = excluded.domain,
9775
9842
  active = excluded.active,
9776
9843
  updated_at = excluded.updated_at
9777
- WHERE excluded.updated_at > global_procedures.updated_at`,
9844
+ WHERE excluded.updated_at > company_procedures.updated_at`,
9778
9845
  args: [
9779
9846
  sqlSafe(p.id),
9780
9847
  sqlSafe(p.title),
@@ -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. global_procedure: manage customer-owned company procedures (Layer 0; actions: store, list, deactivate). Legacy aliases: store_global_procedure, list_global_procedures, deactivate_global_procedure."
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(
@@ -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 global_procedures (
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,
@@ -7619,7 +7686,7 @@ var init_platform_procedures = __esm({
7619
7686
  title: "MCP tools \u2014 advanced (triggers, skills, orchestration)",
7620
7687
  domain: "tool-use",
7621
7688
  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 customer-owned company procedures (Layer 0; actions: store, list, deactivate). Legacy aliases: store_global_procedure, list_global_procedures, deactivate_global_procedure."
7689
+ 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
7690
  }
7624
7691
  ];
7625
7692
  PLATFORM_PROCEDURE_TITLES = new Set(
@@ -7640,7 +7707,7 @@ import { randomUUID as randomUUID3 } from "crypto";
7640
7707
  async function loadGlobalProcedures() {
7641
7708
  const client = getClient();
7642
7709
  const result2 = await client.execute({
7643
- sql: "SELECT * FROM global_procedures WHERE active = 1 ORDER BY priority ASC, created_at ASC",
7710
+ sql: "SELECT * FROM company_procedures WHERE active = 1 ORDER BY priority ASC, created_at ASC",
7644
7711
  args: []
7645
7712
  });
7646
7713
  const allRows = result2.rows;
@@ -7669,7 +7736,7 @@ async function storeGlobalProcedure(input) {
7669
7736
  const now = (/* @__PURE__ */ new Date()).toISOString();
7670
7737
  const client = getClient();
7671
7738
  await client.execute({
7672
- sql: `INSERT INTO global_procedures (id, title, content, priority, domain, active, created_at, updated_at)
7739
+ sql: `INSERT INTO company_procedures (id, title, content, priority, domain, active, created_at, updated_at)
7673
7740
  VALUES (?, ?, ?, ?, ?, 1, ?, ?)`,
7674
7741
  args: [id, input.title, input.content, input.priority ?? "p0", input.domain ?? null, now, now]
7675
7742
  });
@@ -7680,7 +7747,7 @@ async function deactivateGlobalProcedure(id) {
7680
7747
  const now = (/* @__PURE__ */ new Date()).toISOString();
7681
7748
  const client = getClient();
7682
7749
  const result2 = await client.execute({
7683
- sql: "UPDATE global_procedures SET active = 0, updated_at = ? WHERE id = ?",
7750
+ sql: "UPDATE company_procedures SET active = 0, updated_at = ? WHERE id = ?",
7684
7751
  args: [now, id]
7685
7752
  });
7686
7753
  await loadGlobalProcedures();
@@ -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 global_procedures (
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,
@@ -3176,7 +3243,7 @@ var init_platform_procedures = __esm({
3176
3243
  title: "MCP tools \u2014 advanced (triggers, skills, orchestration)",
3177
3244
  domain: "tool-use",
3178
3245
  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. global_procedure: manage customer-owned company procedures (Layer 0; actions: store, list, deactivate). Legacy aliases: store_global_procedure, list_global_procedures, deactivate_global_procedure."
3246
+ 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
3247
  }
3181
3248
  ];
3182
3249
  PLATFORM_PROCEDURE_TITLES = new Set(
@@ -3197,7 +3264,7 @@ import { randomUUID as randomUUID2 } from "crypto";
3197
3264
  async function loadGlobalProcedures() {
3198
3265
  const client = getClient();
3199
3266
  const result = await client.execute({
3200
- sql: "SELECT * FROM global_procedures WHERE active = 1 ORDER BY priority ASC, created_at ASC",
3267
+ sql: "SELECT * FROM company_procedures WHERE active = 1 ORDER BY priority ASC, created_at ASC",
3201
3268
  args: []
3202
3269
  });
3203
3270
  const allRows = result.rows;
@@ -3226,7 +3293,7 @@ async function storeGlobalProcedure(input) {
3226
3293
  const now = (/* @__PURE__ */ new Date()).toISOString();
3227
3294
  const client = getClient();
3228
3295
  await client.execute({
3229
- sql: `INSERT INTO global_procedures (id, title, content, priority, domain, active, created_at, updated_at)
3296
+ sql: `INSERT INTO company_procedures (id, title, content, priority, domain, active, created_at, updated_at)
3230
3297
  VALUES (?, ?, ?, ?, ?, 1, ?, ?)`,
3231
3298
  args: [id, input.title, input.content, input.priority ?? "p0", input.domain ?? null, now, now]
3232
3299
  });
@@ -3237,7 +3304,7 @@ async function deactivateGlobalProcedure(id) {
3237
3304
  const now = (/* @__PURE__ */ new Date()).toISOString();
3238
3305
  const client = getClient();
3239
3306
  const result = await client.execute({
3240
- sql: "UPDATE global_procedures SET active = 0, updated_at = ? WHERE id = ?",
3307
+ sql: "UPDATE company_procedures SET active = 0, updated_at = ? WHERE id = ?",
3241
3308
  args: [now, id]
3242
3309
  });
3243
3310
  await loadGlobalProcedures();
@@ -2570,7 +2570,7 @@ async function ensureSchema() {
2570
2570
  ON session_kills(agent_id);
2571
2571
  `);
2572
2572
  await client.execute(`
2573
- CREATE TABLE IF NOT EXISTS global_procedures (
2573
+ CREATE TABLE IF NOT EXISTS company_procedures (
2574
2574
  id TEXT PRIMARY KEY,
2575
2575
  title TEXT NOT NULL,
2576
2576
  content TEXT NOT NULL,
@@ -2581,6 +2581,73 @@ async function ensureSchema() {
2581
2581
  updated_at TEXT NOT NULL
2582
2582
  )
2583
2583
  `);
2584
+ const legacyProcedureObject = await client.execute({
2585
+ sql: "SELECT type FROM sqlite_master WHERE name = 'global_procedures'",
2586
+ args: []
2587
+ });
2588
+ const legacyProcedureType = legacyProcedureObject.rows[0]?.type == null ? null : String(legacyProcedureObject.rows[0].type);
2589
+ if (legacyProcedureType === "table") {
2590
+ await client.execute(`
2591
+ INSERT OR IGNORE INTO company_procedures
2592
+ (id, title, content, priority, domain, active, created_at, updated_at)
2593
+ SELECT id, title, content, priority, domain, active, created_at, updated_at
2594
+ FROM global_procedures
2595
+ `);
2596
+ await client.executeMultiple(`
2597
+ CREATE TRIGGER IF NOT EXISTS global_procedures_mirror_insert
2598
+ AFTER INSERT ON global_procedures
2599
+ BEGIN
2600
+ INSERT OR IGNORE INTO company_procedures
2601
+ (id, title, content, priority, domain, active, created_at, updated_at)
2602
+ VALUES
2603
+ (NEW.id, NEW.title, NEW.content, NEW.priority, NEW.domain, NEW.active, NEW.created_at, NEW.updated_at);
2604
+ END;
2605
+
2606
+ CREATE TRIGGER IF NOT EXISTS global_procedures_mirror_update
2607
+ AFTER UPDATE ON global_procedures
2608
+ BEGIN
2609
+ UPDATE company_procedures
2610
+ SET title = NEW.title,
2611
+ content = NEW.content,
2612
+ priority = NEW.priority,
2613
+ domain = NEW.domain,
2614
+ active = NEW.active,
2615
+ created_at = NEW.created_at,
2616
+ updated_at = NEW.updated_at
2617
+ WHERE id = OLD.id;
2618
+ END;
2619
+ `);
2620
+ } else {
2621
+ await client.execute(`
2622
+ CREATE VIEW IF NOT EXISTS global_procedures AS
2623
+ SELECT id, title, content, priority, domain, active, created_at, updated_at
2624
+ FROM company_procedures
2625
+ `);
2626
+ await client.executeMultiple(`
2627
+ CREATE TRIGGER IF NOT EXISTS global_procedures_insert
2628
+ INSTEAD OF INSERT ON global_procedures
2629
+ BEGIN
2630
+ INSERT INTO company_procedures
2631
+ (id, title, content, priority, domain, active, created_at, updated_at)
2632
+ VALUES
2633
+ (NEW.id, NEW.title, NEW.content, NEW.priority, NEW.domain, NEW.active, NEW.created_at, NEW.updated_at);
2634
+ END;
2635
+
2636
+ CREATE TRIGGER IF NOT EXISTS global_procedures_update
2637
+ INSTEAD OF UPDATE ON global_procedures
2638
+ BEGIN
2639
+ UPDATE company_procedures
2640
+ SET title = NEW.title,
2641
+ content = NEW.content,
2642
+ priority = NEW.priority,
2643
+ domain = NEW.domain,
2644
+ active = NEW.active,
2645
+ created_at = NEW.created_at,
2646
+ updated_at = NEW.updated_at
2647
+ WHERE id = OLD.id;
2648
+ END;
2649
+ `);
2650
+ }
2584
2651
  await client.executeMultiple(`
2585
2652
  CREATE TABLE IF NOT EXISTS conversations (
2586
2653
  id TEXT PRIMARY KEY,
@@ -3929,7 +3996,7 @@ var init_platform_procedures = __esm({
3929
3996
  title: "MCP tools \u2014 advanced (triggers, skills, orchestration)",
3930
3997
  domain: "tool-use",
3931
3998
  priority: "p1",
3932
- 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."
3999
+ 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."
3933
4000
  }
3934
4001
  ];
3935
4002
  PLATFORM_PROCEDURE_TITLES = new Set(
@@ -3950,7 +4017,7 @@ import { randomUUID as randomUUID2 } from "crypto";
3950
4017
  async function loadGlobalProcedures() {
3951
4018
  const client = getClient();
3952
4019
  const result = await client.execute({
3953
- sql: "SELECT * FROM global_procedures WHERE active = 1 ORDER BY priority ASC, created_at ASC",
4020
+ sql: "SELECT * FROM company_procedures WHERE active = 1 ORDER BY priority ASC, created_at ASC",
3954
4021
  args: []
3955
4022
  });
3956
4023
  const allRows = result.rows;
@@ -3979,7 +4046,7 @@ async function storeGlobalProcedure(input) {
3979
4046
  const now = (/* @__PURE__ */ new Date()).toISOString();
3980
4047
  const client = getClient();
3981
4048
  await client.execute({
3982
- sql: `INSERT INTO global_procedures (id, title, content, priority, domain, active, created_at, updated_at)
4049
+ sql: `INSERT INTO company_procedures (id, title, content, priority, domain, active, created_at, updated_at)
3983
4050
  VALUES (?, ?, ?, ?, ?, 1, ?, ?)`,
3984
4051
  args: [id, input.title, input.content, input.priority ?? "p0", input.domain ?? null, now, now]
3985
4052
  });
@@ -3990,7 +4057,7 @@ async function deactivateGlobalProcedure(id) {
3990
4057
  const now = (/* @__PURE__ */ new Date()).toISOString();
3991
4058
  const client = getClient();
3992
4059
  const result = await client.execute({
3993
- sql: "UPDATE global_procedures SET active = 0, updated_at = ? WHERE id = ?",
4060
+ sql: "UPDATE company_procedures SET active = 0, updated_at = ? WHERE id = ?",
3994
4061
  args: [now, id]
3995
4062
  });
3996
4063
  await loadGlobalProcedures();