@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
@@ -3149,7 +3149,7 @@ async function ensureSchema() {
3149
3149
  ON session_kills(agent_id);
3150
3150
  `);
3151
3151
  await client.execute(`
3152
- CREATE TABLE IF NOT EXISTS global_procedures (
3152
+ CREATE TABLE IF NOT EXISTS company_procedures (
3153
3153
  id TEXT PRIMARY KEY,
3154
3154
  title TEXT NOT NULL,
3155
3155
  content TEXT NOT NULL,
@@ -3160,6 +3160,73 @@ async function ensureSchema() {
3160
3160
  updated_at TEXT NOT NULL
3161
3161
  )
3162
3162
  `);
3163
+ const legacyProcedureObject = await client.execute({
3164
+ sql: "SELECT type FROM sqlite_master WHERE name = 'global_procedures'",
3165
+ args: []
3166
+ });
3167
+ const legacyProcedureType = legacyProcedureObject.rows[0]?.type == null ? null : String(legacyProcedureObject.rows[0].type);
3168
+ if (legacyProcedureType === "table") {
3169
+ await client.execute(`
3170
+ INSERT OR IGNORE INTO company_procedures
3171
+ (id, title, content, priority, domain, active, created_at, updated_at)
3172
+ SELECT id, title, content, priority, domain, active, created_at, updated_at
3173
+ FROM global_procedures
3174
+ `);
3175
+ await client.executeMultiple(`
3176
+ CREATE TRIGGER IF NOT EXISTS global_procedures_mirror_insert
3177
+ AFTER INSERT ON global_procedures
3178
+ BEGIN
3179
+ INSERT OR IGNORE INTO company_procedures
3180
+ (id, title, content, priority, domain, active, created_at, updated_at)
3181
+ VALUES
3182
+ (NEW.id, NEW.title, NEW.content, NEW.priority, NEW.domain, NEW.active, NEW.created_at, NEW.updated_at);
3183
+ END;
3184
+
3185
+ CREATE TRIGGER IF NOT EXISTS global_procedures_mirror_update
3186
+ AFTER UPDATE ON global_procedures
3187
+ BEGIN
3188
+ UPDATE company_procedures
3189
+ SET title = NEW.title,
3190
+ content = NEW.content,
3191
+ priority = NEW.priority,
3192
+ domain = NEW.domain,
3193
+ active = NEW.active,
3194
+ created_at = NEW.created_at,
3195
+ updated_at = NEW.updated_at
3196
+ WHERE id = OLD.id;
3197
+ END;
3198
+ `);
3199
+ } else {
3200
+ await client.execute(`
3201
+ CREATE VIEW IF NOT EXISTS global_procedures AS
3202
+ SELECT id, title, content, priority, domain, active, created_at, updated_at
3203
+ FROM company_procedures
3204
+ `);
3205
+ await client.executeMultiple(`
3206
+ CREATE TRIGGER IF NOT EXISTS global_procedures_insert
3207
+ INSTEAD OF INSERT ON global_procedures
3208
+ BEGIN
3209
+ INSERT INTO company_procedures
3210
+ (id, title, content, priority, domain, active, created_at, updated_at)
3211
+ VALUES
3212
+ (NEW.id, NEW.title, NEW.content, NEW.priority, NEW.domain, NEW.active, NEW.created_at, NEW.updated_at);
3213
+ END;
3214
+
3215
+ CREATE TRIGGER IF NOT EXISTS global_procedures_update
3216
+ INSTEAD OF UPDATE ON global_procedures
3217
+ BEGIN
3218
+ UPDATE company_procedures
3219
+ SET title = NEW.title,
3220
+ content = NEW.content,
3221
+ priority = NEW.priority,
3222
+ domain = NEW.domain,
3223
+ active = NEW.active,
3224
+ created_at = NEW.created_at,
3225
+ updated_at = NEW.updated_at
3226
+ WHERE id = OLD.id;
3227
+ END;
3228
+ `);
3229
+ }
3163
3230
  await client.executeMultiple(`
3164
3231
  CREATE TABLE IF NOT EXISTS conversations (
3165
3232
  id TEXT PRIMARY KEY,
@@ -4521,7 +4588,7 @@ var init_platform_procedures = __esm({
4521
4588
  title: "MCP tools \u2014 advanced (triggers, skills, orchestration)",
4522
4589
  domain: "tool-use",
4523
4590
  priority: "p1",
4524
- 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."
4591
+ 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."
4525
4592
  }
4526
4593
  ];
4527
4594
  PLATFORM_PROCEDURE_TITLES = new Set(
@@ -4542,7 +4609,7 @@ import { randomUUID as randomUUID2 } from "crypto";
4542
4609
  async function loadGlobalProcedures() {
4543
4610
  const client = getClient();
4544
4611
  const result = await client.execute({
4545
- sql: "SELECT * FROM global_procedures WHERE active = 1 ORDER BY priority ASC, created_at ASC",
4612
+ sql: "SELECT * FROM company_procedures WHERE active = 1 ORDER BY priority ASC, created_at ASC",
4546
4613
  args: []
4547
4614
  });
4548
4615
  const allRows = result.rows;
@@ -4571,7 +4638,7 @@ async function storeGlobalProcedure(input) {
4571
4638
  const now = (/* @__PURE__ */ new Date()).toISOString();
4572
4639
  const client = getClient();
4573
4640
  await client.execute({
4574
- sql: `INSERT INTO global_procedures (id, title, content, priority, domain, active, created_at, updated_at)
4641
+ sql: `INSERT INTO company_procedures (id, title, content, priority, domain, active, created_at, updated_at)
4575
4642
  VALUES (?, ?, ?, ?, ?, 1, ?, ?)`,
4576
4643
  args: [id, input.title, input.content, input.priority ?? "p0", input.domain ?? null, now, now]
4577
4644
  });
@@ -4582,7 +4649,7 @@ async function deactivateGlobalProcedure(id) {
4582
4649
  const now = (/* @__PURE__ */ new Date()).toISOString();
4583
4650
  const client = getClient();
4584
4651
  const result = await client.execute({
4585
- sql: "UPDATE global_procedures SET active = 0, updated_at = ? WHERE id = ?",
4652
+ sql: "UPDATE company_procedures SET active = 0, updated_at = ? WHERE id = ?",
4586
4653
  args: [now, id]
4587
4654
  });
4588
4655
  await loadGlobalProcedures();
@@ -11425,12 +11492,12 @@ Rules:
11425
11492
  };
11426
11493
  }
11427
11494
 
11428
- // src/gateway/providers/anthropic.ts
11495
+ // src/lib/providers/anthropic.ts
11429
11496
  import Anthropic2 from "@anthropic-ai/sdk";
11430
11497
  var AnthropicProvider = class {
11431
11498
  name;
11432
- client;
11433
11499
  defaultModel;
11500
+ client;
11434
11501
  constructor(name, config2) {
11435
11502
  this.name = name;
11436
11503
  this.defaultModel = config2.defaultModel ?? "claude-sonnet-4-20250514";
@@ -11521,13 +11588,13 @@ var AnthropicProvider = class {
11521
11588
  }
11522
11589
  };
11523
11590
 
11524
- // src/gateway/providers/openai-compat.ts
11591
+ // src/lib/providers/openai-compat.ts
11525
11592
  import OpenAI from "openai";
11526
11593
  import { randomUUID as randomUUID3 } from "crypto";
11527
11594
  var OpenAICompatProvider = class {
11528
11595
  name;
11529
- client;
11530
11596
  defaultModel;
11597
+ client;
11531
11598
  constructor(name, config2) {
11532
11599
  this.name = name;
11533
11600
  this.defaultModel = config2.defaultModel ?? "gpt-4o";
@@ -11657,12 +11724,12 @@ var OpenAICompatProvider = class {
11657
11724
  }
11658
11725
  };
11659
11726
 
11660
- // src/gateway/providers/ollama.ts
11727
+ // src/lib/providers/ollama.ts
11661
11728
  import { randomUUID as randomUUID4 } from "crypto";
11662
11729
  var OllamaProvider = class {
11663
11730
  name;
11664
- host;
11665
11731
  defaultModel;
11732
+ host;
11666
11733
  constructor(name, config2 = {}) {
11667
11734
  this.name = name;
11668
11735
  this.host = (config2.host ?? "http://localhost:11434").replace(/\/+$/, "");
@@ -2904,7 +2904,7 @@ async function ensureSchema() {
2904
2904
  ON session_kills(agent_id);
2905
2905
  `);
2906
2906
  await client.execute(`
2907
- CREATE TABLE IF NOT EXISTS global_procedures (
2907
+ CREATE TABLE IF NOT EXISTS company_procedures (
2908
2908
  id TEXT PRIMARY KEY,
2909
2909
  title TEXT NOT NULL,
2910
2910
  content TEXT NOT NULL,
@@ -2915,6 +2915,73 @@ async function ensureSchema() {
2915
2915
  updated_at TEXT NOT NULL
2916
2916
  )
2917
2917
  `);
2918
+ const legacyProcedureObject = await client.execute({
2919
+ sql: "SELECT type FROM sqlite_master WHERE name = 'global_procedures'",
2920
+ args: []
2921
+ });
2922
+ const legacyProcedureType = legacyProcedureObject.rows[0]?.type == null ? null : String(legacyProcedureObject.rows[0].type);
2923
+ if (legacyProcedureType === "table") {
2924
+ await client.execute(`
2925
+ INSERT OR IGNORE INTO company_procedures
2926
+ (id, title, content, priority, domain, active, created_at, updated_at)
2927
+ SELECT id, title, content, priority, domain, active, created_at, updated_at
2928
+ FROM global_procedures
2929
+ `);
2930
+ await client.executeMultiple(`
2931
+ CREATE TRIGGER IF NOT EXISTS global_procedures_mirror_insert
2932
+ AFTER INSERT ON global_procedures
2933
+ BEGIN
2934
+ INSERT OR IGNORE INTO company_procedures
2935
+ (id, title, content, priority, domain, active, created_at, updated_at)
2936
+ VALUES
2937
+ (NEW.id, NEW.title, NEW.content, NEW.priority, NEW.domain, NEW.active, NEW.created_at, NEW.updated_at);
2938
+ END;
2939
+
2940
+ CREATE TRIGGER IF NOT EXISTS global_procedures_mirror_update
2941
+ AFTER UPDATE ON global_procedures
2942
+ BEGIN
2943
+ UPDATE company_procedures
2944
+ SET title = NEW.title,
2945
+ content = NEW.content,
2946
+ priority = NEW.priority,
2947
+ domain = NEW.domain,
2948
+ active = NEW.active,
2949
+ created_at = NEW.created_at,
2950
+ updated_at = NEW.updated_at
2951
+ WHERE id = OLD.id;
2952
+ END;
2953
+ `);
2954
+ } else {
2955
+ await client.execute(`
2956
+ CREATE VIEW IF NOT EXISTS global_procedures AS
2957
+ SELECT id, title, content, priority, domain, active, created_at, updated_at
2958
+ FROM company_procedures
2959
+ `);
2960
+ await client.executeMultiple(`
2961
+ CREATE TRIGGER IF NOT EXISTS global_procedures_insert
2962
+ INSTEAD OF INSERT ON global_procedures
2963
+ BEGIN
2964
+ INSERT INTO company_procedures
2965
+ (id, title, content, priority, domain, active, created_at, updated_at)
2966
+ VALUES
2967
+ (NEW.id, NEW.title, NEW.content, NEW.priority, NEW.domain, NEW.active, NEW.created_at, NEW.updated_at);
2968
+ END;
2969
+
2970
+ CREATE TRIGGER IF NOT EXISTS global_procedures_update
2971
+ INSTEAD OF UPDATE ON global_procedures
2972
+ BEGIN
2973
+ UPDATE company_procedures
2974
+ SET title = NEW.title,
2975
+ content = NEW.content,
2976
+ priority = NEW.priority,
2977
+ domain = NEW.domain,
2978
+ active = NEW.active,
2979
+ created_at = NEW.created_at,
2980
+ updated_at = NEW.updated_at
2981
+ WHERE id = OLD.id;
2982
+ END;
2983
+ `);
2984
+ }
2918
2985
  await client.executeMultiple(`
2919
2986
  CREATE TABLE IF NOT EXISTS conversations (
2920
2987
  id TEXT PRIMARY KEY,
@@ -4263,7 +4330,7 @@ var init_platform_procedures = __esm({
4263
4330
  title: "MCP tools \u2014 advanced (triggers, skills, orchestration)",
4264
4331
  domain: "tool-use",
4265
4332
  priority: "p1",
4266
- 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."
4333
+ 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."
4267
4334
  }
4268
4335
  ];
4269
4336
  PLATFORM_PROCEDURE_TITLES = new Set(
@@ -4284,7 +4351,7 @@ import { randomUUID as randomUUID2 } from "crypto";
4284
4351
  async function loadGlobalProcedures() {
4285
4352
  const client = getClient();
4286
4353
  const result = await client.execute({
4287
- sql: "SELECT * FROM global_procedures WHERE active = 1 ORDER BY priority ASC, created_at ASC",
4354
+ sql: "SELECT * FROM company_procedures WHERE active = 1 ORDER BY priority ASC, created_at ASC",
4288
4355
  args: []
4289
4356
  });
4290
4357
  const allRows = result.rows;
@@ -4313,7 +4380,7 @@ async function storeGlobalProcedure(input) {
4313
4380
  const now = (/* @__PURE__ */ new Date()).toISOString();
4314
4381
  const client = getClient();
4315
4382
  await client.execute({
4316
- sql: `INSERT INTO global_procedures (id, title, content, priority, domain, active, created_at, updated_at)
4383
+ sql: `INSERT INTO company_procedures (id, title, content, priority, domain, active, created_at, updated_at)
4317
4384
  VALUES (?, ?, ?, ?, ?, 1, ?, ?)`,
4318
4385
  args: [id, input.title, input.content, input.priority ?? "p0", input.domain ?? null, now, now]
4319
4386
  });
@@ -4324,7 +4391,7 @@ async function deactivateGlobalProcedure(id) {
4324
4391
  const now = (/* @__PURE__ */ new Date()).toISOString();
4325
4392
  const client = getClient();
4326
4393
  const result = await client.execute({
4327
- sql: "UPDATE global_procedures SET active = 0, updated_at = ? WHERE id = ?",
4394
+ sql: "UPDATE company_procedures SET active = 0, updated_at = ? WHERE id = ?",
4328
4395
  args: [now, id]
4329
4396
  });
4330
4397
  await loadGlobalProcedures();
@@ -2587,7 +2587,7 @@ async function ensureSchema() {
2587
2587
  ON session_kills(agent_id);
2588
2588
  `);
2589
2589
  await client.execute(`
2590
- CREATE TABLE IF NOT EXISTS global_procedures (
2590
+ CREATE TABLE IF NOT EXISTS company_procedures (
2591
2591
  id TEXT PRIMARY KEY,
2592
2592
  title TEXT NOT NULL,
2593
2593
  content TEXT NOT NULL,
@@ -2598,6 +2598,73 @@ async function ensureSchema() {
2598
2598
  updated_at TEXT NOT NULL
2599
2599
  )
2600
2600
  `);
2601
+ const legacyProcedureObject = await client.execute({
2602
+ sql: "SELECT type FROM sqlite_master WHERE name = 'global_procedures'",
2603
+ args: []
2604
+ });
2605
+ const legacyProcedureType = legacyProcedureObject.rows[0]?.type == null ? null : String(legacyProcedureObject.rows[0].type);
2606
+ if (legacyProcedureType === "table") {
2607
+ await client.execute(`
2608
+ INSERT OR IGNORE INTO company_procedures
2609
+ (id, title, content, priority, domain, active, created_at, updated_at)
2610
+ SELECT id, title, content, priority, domain, active, created_at, updated_at
2611
+ FROM global_procedures
2612
+ `);
2613
+ await client.executeMultiple(`
2614
+ CREATE TRIGGER IF NOT EXISTS global_procedures_mirror_insert
2615
+ AFTER INSERT ON global_procedures
2616
+ BEGIN
2617
+ INSERT OR IGNORE INTO company_procedures
2618
+ (id, title, content, priority, domain, active, created_at, updated_at)
2619
+ VALUES
2620
+ (NEW.id, NEW.title, NEW.content, NEW.priority, NEW.domain, NEW.active, NEW.created_at, NEW.updated_at);
2621
+ END;
2622
+
2623
+ CREATE TRIGGER IF NOT EXISTS global_procedures_mirror_update
2624
+ AFTER UPDATE ON global_procedures
2625
+ BEGIN
2626
+ UPDATE company_procedures
2627
+ SET title = NEW.title,
2628
+ content = NEW.content,
2629
+ priority = NEW.priority,
2630
+ domain = NEW.domain,
2631
+ active = NEW.active,
2632
+ created_at = NEW.created_at,
2633
+ updated_at = NEW.updated_at
2634
+ WHERE id = OLD.id;
2635
+ END;
2636
+ `);
2637
+ } else {
2638
+ await client.execute(`
2639
+ CREATE VIEW IF NOT EXISTS global_procedures AS
2640
+ SELECT id, title, content, priority, domain, active, created_at, updated_at
2641
+ FROM company_procedures
2642
+ `);
2643
+ await client.executeMultiple(`
2644
+ CREATE TRIGGER IF NOT EXISTS global_procedures_insert
2645
+ INSTEAD OF INSERT ON global_procedures
2646
+ BEGIN
2647
+ INSERT INTO company_procedures
2648
+ (id, title, content, priority, domain, active, created_at, updated_at)
2649
+ VALUES
2650
+ (NEW.id, NEW.title, NEW.content, NEW.priority, NEW.domain, NEW.active, NEW.created_at, NEW.updated_at);
2651
+ END;
2652
+
2653
+ CREATE TRIGGER IF NOT EXISTS global_procedures_update
2654
+ INSTEAD OF UPDATE ON global_procedures
2655
+ BEGIN
2656
+ UPDATE company_procedures
2657
+ SET title = NEW.title,
2658
+ content = NEW.content,
2659
+ priority = NEW.priority,
2660
+ domain = NEW.domain,
2661
+ active = NEW.active,
2662
+ created_at = NEW.created_at,
2663
+ updated_at = NEW.updated_at
2664
+ WHERE id = OLD.id;
2665
+ END;
2666
+ `);
2667
+ }
2601
2668
  await client.executeMultiple(`
2602
2669
  CREATE TABLE IF NOT EXISTS conversations (
2603
2670
  id TEXT PRIMARY KEY,
@@ -3946,7 +4013,7 @@ var init_platform_procedures = __esm({
3946
4013
  title: "MCP tools \u2014 advanced (triggers, skills, orchestration)",
3947
4014
  domain: "tool-use",
3948
4015
  priority: "p1",
3949
- 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."
4016
+ 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."
3950
4017
  }
3951
4018
  ];
3952
4019
  PLATFORM_PROCEDURE_TITLES = new Set(
@@ -3967,7 +4034,7 @@ import { randomUUID as randomUUID2 } from "crypto";
3967
4034
  async function loadGlobalProcedures() {
3968
4035
  const client = getClient();
3969
4036
  const result = await client.execute({
3970
- sql: "SELECT * FROM global_procedures WHERE active = 1 ORDER BY priority ASC, created_at ASC",
4037
+ sql: "SELECT * FROM company_procedures WHERE active = 1 ORDER BY priority ASC, created_at ASC",
3971
4038
  args: []
3972
4039
  });
3973
4040
  const allRows = result.rows;
@@ -3996,7 +4063,7 @@ async function storeGlobalProcedure(input) {
3996
4063
  const now = (/* @__PURE__ */ new Date()).toISOString();
3997
4064
  const client = getClient();
3998
4065
  await client.execute({
3999
- sql: `INSERT INTO global_procedures (id, title, content, priority, domain, active, created_at, updated_at)
4066
+ sql: `INSERT INTO company_procedures (id, title, content, priority, domain, active, created_at, updated_at)
4000
4067
  VALUES (?, ?, ?, ?, ?, 1, ?, ?)`,
4001
4068
  args: [id, input.title, input.content, input.priority ?? "p0", input.domain ?? null, now, now]
4002
4069
  });
@@ -4007,7 +4074,7 @@ async function deactivateGlobalProcedure(id) {
4007
4074
  const now = (/* @__PURE__ */ new Date()).toISOString();
4008
4075
  const client = getClient();
4009
4076
  const result = await client.execute({
4010
- sql: "UPDATE global_procedures SET active = 0, updated_at = ? WHERE id = ?",
4077
+ sql: "UPDATE company_procedures SET active = 0, updated_at = ? WHERE id = ?",
4011
4078
  args: [now, id]
4012
4079
  });
4013
4080
  await loadGlobalProcedures();
@@ -3082,7 +3082,7 @@ async function ensureSchema() {
3082
3082
  ON session_kills(agent_id);
3083
3083
  `);
3084
3084
  await client.execute(`
3085
- CREATE TABLE IF NOT EXISTS global_procedures (
3085
+ CREATE TABLE IF NOT EXISTS company_procedures (
3086
3086
  id TEXT PRIMARY KEY,
3087
3087
  title TEXT NOT NULL,
3088
3088
  content TEXT NOT NULL,
@@ -3093,6 +3093,73 @@ async function ensureSchema() {
3093
3093
  updated_at TEXT NOT NULL
3094
3094
  )
3095
3095
  `);
3096
+ const legacyProcedureObject = await client.execute({
3097
+ sql: "SELECT type FROM sqlite_master WHERE name = 'global_procedures'",
3098
+ args: []
3099
+ });
3100
+ const legacyProcedureType = legacyProcedureObject.rows[0]?.type == null ? null : String(legacyProcedureObject.rows[0].type);
3101
+ if (legacyProcedureType === "table") {
3102
+ await client.execute(`
3103
+ INSERT OR IGNORE INTO company_procedures
3104
+ (id, title, content, priority, domain, active, created_at, updated_at)
3105
+ SELECT id, title, content, priority, domain, active, created_at, updated_at
3106
+ FROM global_procedures
3107
+ `);
3108
+ await client.executeMultiple(`
3109
+ CREATE TRIGGER IF NOT EXISTS global_procedures_mirror_insert
3110
+ AFTER INSERT ON global_procedures
3111
+ BEGIN
3112
+ INSERT OR IGNORE INTO company_procedures
3113
+ (id, title, content, priority, domain, active, created_at, updated_at)
3114
+ VALUES
3115
+ (NEW.id, NEW.title, NEW.content, NEW.priority, NEW.domain, NEW.active, NEW.created_at, NEW.updated_at);
3116
+ END;
3117
+
3118
+ CREATE TRIGGER IF NOT EXISTS global_procedures_mirror_update
3119
+ AFTER UPDATE ON global_procedures
3120
+ BEGIN
3121
+ UPDATE company_procedures
3122
+ SET title = NEW.title,
3123
+ content = NEW.content,
3124
+ priority = NEW.priority,
3125
+ domain = NEW.domain,
3126
+ active = NEW.active,
3127
+ created_at = NEW.created_at,
3128
+ updated_at = NEW.updated_at
3129
+ WHERE id = OLD.id;
3130
+ END;
3131
+ `);
3132
+ } else {
3133
+ await client.execute(`
3134
+ CREATE VIEW IF NOT EXISTS global_procedures AS
3135
+ SELECT id, title, content, priority, domain, active, created_at, updated_at
3136
+ FROM company_procedures
3137
+ `);
3138
+ await client.executeMultiple(`
3139
+ CREATE TRIGGER IF NOT EXISTS global_procedures_insert
3140
+ INSTEAD OF INSERT ON global_procedures
3141
+ BEGIN
3142
+ INSERT INTO company_procedures
3143
+ (id, title, content, priority, domain, active, created_at, updated_at)
3144
+ VALUES
3145
+ (NEW.id, NEW.title, NEW.content, NEW.priority, NEW.domain, NEW.active, NEW.created_at, NEW.updated_at);
3146
+ END;
3147
+
3148
+ CREATE TRIGGER IF NOT EXISTS global_procedures_update
3149
+ INSTEAD OF UPDATE ON global_procedures
3150
+ BEGIN
3151
+ UPDATE company_procedures
3152
+ SET title = NEW.title,
3153
+ content = NEW.content,
3154
+ priority = NEW.priority,
3155
+ domain = NEW.domain,
3156
+ active = NEW.active,
3157
+ created_at = NEW.created_at,
3158
+ updated_at = NEW.updated_at
3159
+ WHERE id = OLD.id;
3160
+ END;
3161
+ `);
3162
+ }
3096
3163
  await client.executeMultiple(`
3097
3164
  CREATE TABLE IF NOT EXISTS conversations (
3098
3165
  id TEXT PRIMARY KEY,
@@ -7634,7 +7701,7 @@ var init_platform_procedures = __esm({
7634
7701
  title: "MCP tools \u2014 advanced (triggers, skills, orchestration)",
7635
7702
  domain: "tool-use",
7636
7703
  priority: "p1",
7637
- 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."
7704
+ 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."
7638
7705
  }
7639
7706
  ];
7640
7707
  PLATFORM_PROCEDURE_TITLES = new Set(
@@ -7655,7 +7722,7 @@ import { randomUUID as randomUUID3 } from "crypto";
7655
7722
  async function loadGlobalProcedures() {
7656
7723
  const client = getClient();
7657
7724
  const result = await client.execute({
7658
- sql: "SELECT * FROM global_procedures WHERE active = 1 ORDER BY priority ASC, created_at ASC",
7725
+ sql: "SELECT * FROM company_procedures WHERE active = 1 ORDER BY priority ASC, created_at ASC",
7659
7726
  args: []
7660
7727
  });
7661
7728
  const allRows = result.rows;
@@ -7684,7 +7751,7 @@ async function storeGlobalProcedure(input) {
7684
7751
  const now = (/* @__PURE__ */ new Date()).toISOString();
7685
7752
  const client = getClient();
7686
7753
  await client.execute({
7687
- sql: `INSERT INTO global_procedures (id, title, content, priority, domain, active, created_at, updated_at)
7754
+ sql: `INSERT INTO company_procedures (id, title, content, priority, domain, active, created_at, updated_at)
7688
7755
  VALUES (?, ?, ?, ?, ?, 1, ?, ?)`,
7689
7756
  args: [id, input.title, input.content, input.priority ?? "p0", input.domain ?? null, now, now]
7690
7757
  });
@@ -7695,7 +7762,7 @@ async function deactivateGlobalProcedure(id) {
7695
7762
  const now = (/* @__PURE__ */ new Date()).toISOString();
7696
7763
  const client = getClient();
7697
7764
  const result = await client.execute({
7698
- sql: "UPDATE global_procedures SET active = 0, updated_at = ? WHERE id = ?",
7765
+ sql: "UPDATE company_procedures SET active = 0, updated_at = ? WHERE id = ?",
7699
7766
  args: [now, id]
7700
7767
  });
7701
7768
  await loadGlobalProcedures();
@@ -2495,7 +2495,7 @@ async function ensureSchema() {
2495
2495
  ON session_kills(agent_id);
2496
2496
  `);
2497
2497
  await client.execute(`
2498
- CREATE TABLE IF NOT EXISTS global_procedures (
2498
+ CREATE TABLE IF NOT EXISTS company_procedures (
2499
2499
  id TEXT PRIMARY KEY,
2500
2500
  title TEXT NOT NULL,
2501
2501
  content TEXT NOT NULL,
@@ -2506,6 +2506,73 @@ async function ensureSchema() {
2506
2506
  updated_at TEXT NOT NULL
2507
2507
  )
2508
2508
  `);
2509
+ const legacyProcedureObject = await client.execute({
2510
+ sql: "SELECT type FROM sqlite_master WHERE name = 'global_procedures'",
2511
+ args: []
2512
+ });
2513
+ const legacyProcedureType = legacyProcedureObject.rows[0]?.type == null ? null : String(legacyProcedureObject.rows[0].type);
2514
+ if (legacyProcedureType === "table") {
2515
+ await client.execute(`
2516
+ INSERT OR IGNORE INTO company_procedures
2517
+ (id, title, content, priority, domain, active, created_at, updated_at)
2518
+ SELECT id, title, content, priority, domain, active, created_at, updated_at
2519
+ FROM global_procedures
2520
+ `);
2521
+ await client.executeMultiple(`
2522
+ CREATE TRIGGER IF NOT EXISTS global_procedures_mirror_insert
2523
+ AFTER INSERT ON global_procedures
2524
+ BEGIN
2525
+ INSERT OR IGNORE INTO company_procedures
2526
+ (id, title, content, priority, domain, active, created_at, updated_at)
2527
+ VALUES
2528
+ (NEW.id, NEW.title, NEW.content, NEW.priority, NEW.domain, NEW.active, NEW.created_at, NEW.updated_at);
2529
+ END;
2530
+
2531
+ CREATE TRIGGER IF NOT EXISTS global_procedures_mirror_update
2532
+ AFTER UPDATE ON global_procedures
2533
+ BEGIN
2534
+ UPDATE company_procedures
2535
+ SET title = NEW.title,
2536
+ content = NEW.content,
2537
+ priority = NEW.priority,
2538
+ domain = NEW.domain,
2539
+ active = NEW.active,
2540
+ created_at = NEW.created_at,
2541
+ updated_at = NEW.updated_at
2542
+ WHERE id = OLD.id;
2543
+ END;
2544
+ `);
2545
+ } else {
2546
+ await client.execute(`
2547
+ CREATE VIEW IF NOT EXISTS global_procedures AS
2548
+ SELECT id, title, content, priority, domain, active, created_at, updated_at
2549
+ FROM company_procedures
2550
+ `);
2551
+ await client.executeMultiple(`
2552
+ CREATE TRIGGER IF NOT EXISTS global_procedures_insert
2553
+ INSTEAD OF INSERT ON global_procedures
2554
+ BEGIN
2555
+ INSERT INTO company_procedures
2556
+ (id, title, content, priority, domain, active, created_at, updated_at)
2557
+ VALUES
2558
+ (NEW.id, NEW.title, NEW.content, NEW.priority, NEW.domain, NEW.active, NEW.created_at, NEW.updated_at);
2559
+ END;
2560
+
2561
+ CREATE TRIGGER IF NOT EXISTS global_procedures_update
2562
+ INSTEAD OF UPDATE ON global_procedures
2563
+ BEGIN
2564
+ UPDATE company_procedures
2565
+ SET title = NEW.title,
2566
+ content = NEW.content,
2567
+ priority = NEW.priority,
2568
+ domain = NEW.domain,
2569
+ active = NEW.active,
2570
+ created_at = NEW.created_at,
2571
+ updated_at = NEW.updated_at
2572
+ WHERE id = OLD.id;
2573
+ END;
2574
+ `);
2575
+ }
2509
2576
  await client.executeMultiple(`
2510
2577
  CREATE TABLE IF NOT EXISTS conversations (
2511
2578
  id TEXT PRIMARY KEY,
@@ -3854,7 +3921,7 @@ var init_platform_procedures = __esm({
3854
3921
  title: "MCP tools \u2014 advanced (triggers, skills, orchestration)",
3855
3922
  domain: "tool-use",
3856
3923
  priority: "p1",
3857
- 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."
3924
+ 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."
3858
3925
  }
3859
3926
  ];
3860
3927
  PLATFORM_PROCEDURE_TITLES = new Set(
@@ -3875,7 +3942,7 @@ import { randomUUID as randomUUID2 } from "crypto";
3875
3942
  async function loadGlobalProcedures() {
3876
3943
  const client = getClient();
3877
3944
  const result = await client.execute({
3878
- sql: "SELECT * FROM global_procedures WHERE active = 1 ORDER BY priority ASC, created_at ASC",
3945
+ sql: "SELECT * FROM company_procedures WHERE active = 1 ORDER BY priority ASC, created_at ASC",
3879
3946
  args: []
3880
3947
  });
3881
3948
  const allRows = result.rows;
@@ -3904,7 +3971,7 @@ async function storeGlobalProcedure(input2) {
3904
3971
  const now = (/* @__PURE__ */ new Date()).toISOString();
3905
3972
  const client = getClient();
3906
3973
  await client.execute({
3907
- sql: `INSERT INTO global_procedures (id, title, content, priority, domain, active, created_at, updated_at)
3974
+ sql: `INSERT INTO company_procedures (id, title, content, priority, domain, active, created_at, updated_at)
3908
3975
  VALUES (?, ?, ?, ?, ?, 1, ?, ?)`,
3909
3976
  args: [id, input2.title, input2.content, input2.priority ?? "p0", input2.domain ?? null, now, now]
3910
3977
  });
@@ -3915,7 +3982,7 @@ async function deactivateGlobalProcedure(id) {
3915
3982
  const now = (/* @__PURE__ */ new Date()).toISOString();
3916
3983
  const client = getClient();
3917
3984
  const result = await client.execute({
3918
- sql: "UPDATE global_procedures SET active = 0, updated_at = ? WHERE id = ?",
3985
+ sql: "UPDATE company_procedures SET active = 0, updated_at = ? WHERE id = ?",
3919
3986
  args: [now, id]
3920
3987
  });
3921
3988
  await loadGlobalProcedures();