@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
@@ -2892,7 +2892,7 @@ async function ensureSchema() {
2892
2892
  ON session_kills(agent_id);
2893
2893
  `);
2894
2894
  await client.execute(`
2895
- CREATE TABLE IF NOT EXISTS global_procedures (
2895
+ CREATE TABLE IF NOT EXISTS company_procedures (
2896
2896
  id TEXT PRIMARY KEY,
2897
2897
  title TEXT NOT NULL,
2898
2898
  content TEXT NOT NULL,
@@ -2903,6 +2903,73 @@ async function ensureSchema() {
2903
2903
  updated_at TEXT NOT NULL
2904
2904
  )
2905
2905
  `);
2906
+ const legacyProcedureObject = await client.execute({
2907
+ sql: "SELECT type FROM sqlite_master WHERE name = 'global_procedures'",
2908
+ args: []
2909
+ });
2910
+ const legacyProcedureType = legacyProcedureObject.rows[0]?.type == null ? null : String(legacyProcedureObject.rows[0].type);
2911
+ if (legacyProcedureType === "table") {
2912
+ await client.execute(`
2913
+ INSERT OR IGNORE INTO company_procedures
2914
+ (id, title, content, priority, domain, active, created_at, updated_at)
2915
+ SELECT id, title, content, priority, domain, active, created_at, updated_at
2916
+ FROM global_procedures
2917
+ `);
2918
+ await client.executeMultiple(`
2919
+ CREATE TRIGGER IF NOT EXISTS global_procedures_mirror_insert
2920
+ AFTER INSERT ON global_procedures
2921
+ BEGIN
2922
+ INSERT OR IGNORE INTO company_procedures
2923
+ (id, title, content, priority, domain, active, created_at, updated_at)
2924
+ VALUES
2925
+ (NEW.id, NEW.title, NEW.content, NEW.priority, NEW.domain, NEW.active, NEW.created_at, NEW.updated_at);
2926
+ END;
2927
+
2928
+ CREATE TRIGGER IF NOT EXISTS global_procedures_mirror_update
2929
+ AFTER UPDATE ON global_procedures
2930
+ BEGIN
2931
+ UPDATE company_procedures
2932
+ SET title = NEW.title,
2933
+ content = NEW.content,
2934
+ priority = NEW.priority,
2935
+ domain = NEW.domain,
2936
+ active = NEW.active,
2937
+ created_at = NEW.created_at,
2938
+ updated_at = NEW.updated_at
2939
+ WHERE id = OLD.id;
2940
+ END;
2941
+ `);
2942
+ } else {
2943
+ await client.execute(`
2944
+ CREATE VIEW IF NOT EXISTS global_procedures AS
2945
+ SELECT id, title, content, priority, domain, active, created_at, updated_at
2946
+ FROM company_procedures
2947
+ `);
2948
+ await client.executeMultiple(`
2949
+ CREATE TRIGGER IF NOT EXISTS global_procedures_insert
2950
+ INSTEAD OF INSERT ON global_procedures
2951
+ BEGIN
2952
+ INSERT INTO company_procedures
2953
+ (id, title, content, priority, domain, active, created_at, updated_at)
2954
+ VALUES
2955
+ (NEW.id, NEW.title, NEW.content, NEW.priority, NEW.domain, NEW.active, NEW.created_at, NEW.updated_at);
2956
+ END;
2957
+
2958
+ CREATE TRIGGER IF NOT EXISTS global_procedures_update
2959
+ INSTEAD OF UPDATE ON global_procedures
2960
+ BEGIN
2961
+ UPDATE company_procedures
2962
+ SET title = NEW.title,
2963
+ content = NEW.content,
2964
+ priority = NEW.priority,
2965
+ domain = NEW.domain,
2966
+ active = NEW.active,
2967
+ created_at = NEW.created_at,
2968
+ updated_at = NEW.updated_at
2969
+ WHERE id = OLD.id;
2970
+ END;
2971
+ `);
2972
+ }
2906
2973
  await client.executeMultiple(`
2907
2974
  CREATE TABLE IF NOT EXISTS conversations (
2908
2975
  id TEXT PRIMARY KEY,
@@ -4598,7 +4665,7 @@ var init_platform_procedures = __esm({
4598
4665
  title: "MCP tools \u2014 advanced (triggers, skills, orchestration)",
4599
4666
  domain: "tool-use",
4600
4667
  priority: "p1",
4601
- 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."
4668
+ 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."
4602
4669
  }
4603
4670
  ];
4604
4671
  PLATFORM_PROCEDURE_TITLES = new Set(
@@ -4619,7 +4686,7 @@ import { randomUUID as randomUUID2 } from "crypto";
4619
4686
  async function loadGlobalProcedures() {
4620
4687
  const client = getClient();
4621
4688
  const result = await client.execute({
4622
- sql: "SELECT * FROM global_procedures WHERE active = 1 ORDER BY priority ASC, created_at ASC",
4689
+ sql: "SELECT * FROM company_procedures WHERE active = 1 ORDER BY priority ASC, created_at ASC",
4623
4690
  args: []
4624
4691
  });
4625
4692
  const allRows = result.rows;
@@ -4648,7 +4715,7 @@ async function storeGlobalProcedure(input) {
4648
4715
  const now = (/* @__PURE__ */ new Date()).toISOString();
4649
4716
  const client = getClient();
4650
4717
  await client.execute({
4651
- sql: `INSERT INTO global_procedures (id, title, content, priority, domain, active, created_at, updated_at)
4718
+ sql: `INSERT INTO company_procedures (id, title, content, priority, domain, active, created_at, updated_at)
4652
4719
  VALUES (?, ?, ?, ?, ?, 1, ?, ?)`,
4653
4720
  args: [id, input.title, input.content, input.priority ?? "p0", input.domain ?? null, now, now]
4654
4721
  });
@@ -4659,7 +4726,7 @@ async function deactivateGlobalProcedure(id) {
4659
4726
  const now = (/* @__PURE__ */ new Date()).toISOString();
4660
4727
  const client = getClient();
4661
4728
  const result = await client.execute({
4662
- sql: "UPDATE global_procedures SET active = 0, updated_at = ? WHERE id = ?",
4729
+ sql: "UPDATE company_procedures SET active = 0, updated_at = ? WHERE id = ?",
4663
4730
  args: [now, id]
4664
4731
  });
4665
4732
  await loadGlobalProcedures();
@@ -22258,12 +22325,12 @@ async function cloudSync(config2) {
22258
22325
  try {
22259
22326
  await cloudPushGlobalProcedures(config2);
22260
22327
  } catch (err) {
22261
- logError(`[cloud-sync] Global procedures push: ${err instanceof Error ? err.message : String(err)}`);
22328
+ logError(`[cloud-sync] Company procedures push: ${err instanceof Error ? err.message : String(err)}`);
22262
22329
  }
22263
22330
  try {
22264
22331
  await cloudPullGlobalProcedures(config2);
22265
22332
  } catch (err) {
22266
- logError(`[cloud-sync] Global procedures pull: ${err instanceof Error ? err.message : String(err)}`);
22333
+ logError(`[cloud-sync] Company procedures pull: ${err instanceof Error ? err.message : String(err)}`);
22267
22334
  }
22268
22335
  const countRows = async (sql) => {
22269
22336
  try {
@@ -22672,12 +22739,12 @@ async function cloudPullBlob(route, config2) {
22672
22739
  }
22673
22740
  async function cloudPushGlobalProcedures(config2) {
22674
22741
  const client = getClient();
22675
- const result = await client.execute("SELECT * FROM global_procedures LIMIT 1000");
22742
+ const result = await client.execute("SELECT * FROM company_procedures LIMIT 1000");
22676
22743
  const rows = result.rows;
22677
22744
  const { ok } = await cloudPushBlob(
22678
22745
  "/sync/push-global-procedures",
22679
22746
  rows,
22680
- "last_global_procedures_push_version",
22747
+ "last_company_procedures_push_version",
22681
22748
  config2
22682
22749
  );
22683
22750
  return ok;
@@ -22690,7 +22757,7 @@ async function cloudPullGlobalProcedures(config2) {
22690
22757
  if (!remoteProcs || remoteProcs.length === 0) return { pulled: 0 };
22691
22758
  const client = getClient();
22692
22759
  const stmts = remoteProcs.map((p) => ({
22693
- sql: `INSERT INTO global_procedures
22760
+ sql: `INSERT INTO company_procedures
22694
22761
  (id, title, content, priority, domain, active, created_at, updated_at)
22695
22762
  VALUES (?, ?, ?, ?, ?, ?, ?, ?)
22696
22763
  ON CONFLICT(id) DO UPDATE SET
@@ -22700,7 +22767,7 @@ async function cloudPullGlobalProcedures(config2) {
22700
22767
  domain = excluded.domain,
22701
22768
  active = excluded.active,
22702
22769
  updated_at = excluded.updated_at
22703
- WHERE excluded.updated_at > global_procedures.updated_at`,
22770
+ WHERE excluded.updated_at > company_procedures.updated_at`,
22704
22771
  args: [
22705
22772
  sqlSafe(p.id),
22706
22773
  sqlSafe(p.title),
@@ -25460,7 +25527,7 @@ async function insertProcedures(procedures, timestamp, options) {
25460
25527
  continue;
25461
25528
  }
25462
25529
  await client.execute({
25463
- sql: `INSERT INTO global_procedures (id, title, content, priority, domain, active, created_at, updated_at)
25530
+ sql: `INSERT INTO company_procedures (id, title, content, priority, domain, active, created_at, updated_at)
25464
25531
  VALUES (?, ?, ?, ?, ?, 1, ?, ?)`,
25465
25532
  args: [
25466
25533
  randomUUID8(),
@@ -25542,7 +25609,7 @@ async function importIdentities(identities, updatedBy) {
25542
25609
  async function getActiveProcedureTitles() {
25543
25610
  const client = getClient();
25544
25611
  const result = await client.execute({
25545
- sql: "SELECT title FROM global_procedures WHERE active = 1",
25612
+ sql: "SELECT title FROM company_procedures WHERE active = 1",
25546
25613
  args: []
25547
25614
  });
25548
25615
  return new Set(result.rows.map((row) => String(row.title)));
@@ -25565,7 +25632,7 @@ async function exportOrchestration(createdBy) {
25565
25632
  args: []
25566
25633
  });
25567
25634
  const procedureResult = await client.execute({
25568
- sql: "SELECT title, content, priority, domain FROM global_procedures WHERE active = 1",
25635
+ sql: "SELECT title, content, priority, domain FROM company_procedures WHERE active = 1",
25569
25636
  args: []
25570
25637
  });
25571
25638
  const behaviors = behaviorResult.rows.map((row) => ({
@@ -25789,9 +25856,9 @@ var init_import_orchestration = __esm({
25789
25856
 
25790
25857
  // src/mcp/tools/global-procedure.ts
25791
25858
  import { z as z71 } from "zod";
25792
- function registerGlobalProcedure(server) {
25859
+ function registerCompanyProcedureTool(server, toolName) {
25793
25860
  server.registerTool(
25794
- "global_procedure",
25861
+ toolName,
25795
25862
  {
25796
25863
  title: "Company Procedure",
25797
25864
  description: "Manage company procedures (customer-owned Layer 0 rules) that supersede identity, expertise, and experience. Actions: store (create new, restricted), list (view all, open), deactivate (soft-delete, restricted).",
@@ -25801,7 +25868,7 @@ function registerGlobalProcedure(server) {
25801
25868
  content: z71.string().max(500).optional().describe("The procedure content \u2014 clear, actionable instruction (store)"),
25802
25869
  priority: z71.enum(["p0", "p1", "p2"]).optional().describe("Priority tier. p0 = always (default). p1 = standard. p2 = nice-to-have."),
25803
25870
  domain: z71.string().optional().describe("Category: workflow, code-style, communication, architecture, testing, security"),
25804
- procedure_id: z71.string().optional().describe("UUID of the global procedure (deactivate)")
25871
+ procedure_id: z71.string().optional().describe("UUID of the company procedure (deactivate)")
25805
25872
  }
25806
25873
  },
25807
25874
  async ({ action, title, content, priority, domain, procedure_id }) => {
@@ -25812,7 +25879,7 @@ function registerGlobalProcedure(server) {
25812
25879
  content: [{
25813
25880
  type: "text",
25814
25881
  text: `No custom company procedures. ${PLATFORM_PROCEDURES.length} platform procedures are active (shipped with exe-os, not editable).
25815
- Use global_procedure with action "store" to add company-specific rules.`
25882
+ Use company_procedure with action "store" to add company-specific rules.`
25816
25883
  }]
25817
25884
  };
25818
25885
  }
@@ -25878,7 +25945,7 @@ Domain: ${domain ?? "none"}`
25878
25945
  }
25879
25946
  const client = getClient();
25880
25947
  const result = await client.execute({
25881
- sql: "SELECT id, title, content, priority, domain FROM global_procedures WHERE id = ?",
25948
+ sql: "SELECT id, title, content, priority, domain FROM company_procedures WHERE id = ?",
25882
25949
  args: [procedure_id]
25883
25950
  });
25884
25951
  if (result.rows.length === 0) {
@@ -25896,7 +25963,7 @@ Domain: ${domain ?? "none"}`
25896
25963
  return {
25897
25964
  content: [{
25898
25965
  type: "text",
25899
- text: `Global procedure ${procedure_id} was already inactive.`
25966
+ text: `Company procedure ${procedure_id} was already inactive.`
25900
25967
  }]
25901
25968
  };
25902
25969
  }
@@ -25914,6 +25981,12 @@ Content: ${row.content}`
25914
25981
  }
25915
25982
  );
25916
25983
  }
25984
+ function registerCompanyProcedure(server) {
25985
+ registerCompanyProcedureTool(server, "company_procedure");
25986
+ }
25987
+ function registerGlobalProcedure(server) {
25988
+ registerCompanyProcedureTool(server, "global_procedure");
25989
+ }
25917
25990
  var init_global_procedure = __esm({
25918
25991
  "src/mcp/tools/global-procedure.ts"() {
25919
25992
  "use strict";
@@ -25960,6 +26033,7 @@ function buildHandlers5() {
25960
26033
  registerLoadSkill(localServer);
25961
26034
  registerExportOrchestration(localServer);
25962
26035
  registerImportOrchestration(localServer);
26036
+ registerCompanyProcedure(localServer);
25963
26037
  registerGlobalProcedure(localServer);
25964
26038
  return tools;
25965
26039
  }
@@ -26000,7 +26074,7 @@ function registerConfig(server) {
26000
26074
  priority: z72.enum(["p0", "p1", "p2"]).optional().describe("Procedure priority"),
26001
26075
  domain: z72.string().optional().describe("Procedure domain"),
26002
26076
  procedure_id: z72.string().optional().describe("Procedure id for deactivate"),
26003
- subaction: z72.enum(["store", "list", "deactivate"]).optional().describe("Nested action for global_procedure"),
26077
+ subaction: z72.enum(["store", "list", "deactivate"]).optional().describe("Nested action for company_procedure/global_procedure"),
26004
26078
  max_clusters: z72.coerce.number().optional().describe("Consolidation max clusters"),
26005
26079
  force: z72.boolean().optional().describe("Force operation where supported"),
26006
26080
  domain_name: z72.string().optional().describe("Client deployment domain")
@@ -26008,14 +26082,14 @@ function registerConfig(server) {
26008
26082
  }, async (input, extra) => {
26009
26083
  const action = input.action;
26010
26084
  const { action: _action, subaction, ...args } = input;
26011
- if (action === "global_procedure") {
26085
+ if (action === "company_procedure" || action === "global_procedure") {
26012
26086
  args.action = subaction ?? "list";
26013
26087
  }
26014
26088
  if (action === "export_orchestration" && !args.output_path) return errorResult8('config action "export_orchestration" requires output_path');
26015
26089
  if (action === "import_orchestration" && !args.input_path) return errorResult8('config action "import_orchestration" requires input_path');
26016
26090
  if (action === "activate_license" && !args.license_key) return errorResult8('config action "activate_license" requires license_key');
26017
26091
  if (action === "create_trigger" && (!args.name || !args.event || !Array.isArray(args.actions))) return errorResult8('config action "create_trigger" requires name, event, and actions');
26018
- if (action === "global_procedure" && args.action === "store" && (!args.title || !args.content)) return errorResult8('config action "global_procedure" subaction=store requires title and content');
26092
+ if ((action === "company_procedure" || action === "global_procedure") && args.action === "store" && (!args.title || !args.content)) return errorResult8(`config action "${action}" subaction=store requires title and content`);
26019
26093
  const toolName = ACTION_TO_TOOL2[action];
26020
26094
  const tool = legacy.get(toolName);
26021
26095
  if (!tool) return errorResult8(`Legacy config handler not found for action "${action}" (${toolName})`);
@@ -26074,6 +26148,7 @@ var init_config2 = __esm({
26074
26148
  load_skill: "load_skill",
26075
26149
  export_orchestration: "export_orchestration",
26076
26150
  import_orchestration: "import_orchestration",
26151
+ company_procedure: "company_procedure",
26077
26152
  global_procedure: "global_procedure"
26078
26153
  };
26079
26154
  }
@@ -26809,7 +26884,7 @@ function registerDeactivateGlobalProcedure(server) {
26809
26884
  title: "Deactivate Company Procedure (use global_procedure instead)",
26810
26885
  description: "DEPRECATED \u2014 use global_procedure with action='deactivate'. Soft-delete a company procedure. RESTRICTED: only coordinator or founder sessions.",
26811
26886
  inputSchema: {
26812
- procedure_id: z79.string().describe("UUID of the global procedure to deactivate")
26887
+ procedure_id: z79.string().describe("UUID of the company procedure to deactivate")
26813
26888
  }
26814
26889
  },
26815
26890
  async ({ procedure_id }) => {
@@ -26826,7 +26901,7 @@ function registerDeactivateGlobalProcedure(server) {
26826
26901
  }
26827
26902
  const client = getClient();
26828
26903
  const result = await client.execute({
26829
- sql: "SELECT id, title, content, priority, domain FROM global_procedures WHERE id = ?",
26904
+ sql: "SELECT id, title, content, priority, domain FROM company_procedures WHERE id = ?",
26830
26905
  args: [procedure_id]
26831
26906
  });
26832
26907
  if (result.rows.length === 0) {
@@ -26844,7 +26919,7 @@ function registerDeactivateGlobalProcedure(server) {
26844
26919
  return {
26845
26920
  content: [{
26846
26921
  type: "text",
26847
- text: `Global procedure ${procedure_id} was already inactive.`
26922
+ text: `Company procedure ${procedure_id} was already inactive.`
26848
26923
  }]
26849
26924
  };
26850
26925
  }
@@ -27865,6 +27940,7 @@ var init_tool_gates = __esm({
27865
27940
  registerLoadSkill: "orchestration",
27866
27941
  registerExportOrchestration: "orchestration",
27867
27942
  registerImportOrchestration: "orchestration",
27943
+ registerCompanyProcedure: "orchestration",
27868
27944
  registerGlobalProcedure: "orchestration",
27869
27945
  registerStoreGlobalProcedure: "orchestration",
27870
27946
  registerListGlobalProcedures: "orchestration",
@@ -28011,6 +28087,7 @@ function registerAllTools(server) {
28011
28087
  gate("registerConsolidateMemories", registerConsolidateMemories);
28012
28088
  }
28013
28089
  if (exposeLegacyConfig) {
28090
+ gate("registerCompanyProcedure", registerCompanyProcedure);
28014
28091
  gate("registerGlobalProcedure", registerGlobalProcedure);
28015
28092
  gate("registerStoreGlobalProcedure", registerStoreGlobalProcedure);
28016
28093
  gate("registerListGlobalProcedures", registerListGlobalProcedures);
@@ -2492,7 +2492,7 @@ async function ensureSchema() {
2492
2492
  ON session_kills(agent_id);
2493
2493
  `);
2494
2494
  await client.execute(`
2495
- CREATE TABLE IF NOT EXISTS global_procedures (
2495
+ CREATE TABLE IF NOT EXISTS company_procedures (
2496
2496
  id TEXT PRIMARY KEY,
2497
2497
  title TEXT NOT NULL,
2498
2498
  content TEXT NOT NULL,
@@ -2503,6 +2503,73 @@ async function ensureSchema() {
2503
2503
  updated_at TEXT NOT NULL
2504
2504
  )
2505
2505
  `);
2506
+ const legacyProcedureObject = await client.execute({
2507
+ sql: "SELECT type FROM sqlite_master WHERE name = 'global_procedures'",
2508
+ args: []
2509
+ });
2510
+ const legacyProcedureType = legacyProcedureObject.rows[0]?.type == null ? null : String(legacyProcedureObject.rows[0].type);
2511
+ if (legacyProcedureType === "table") {
2512
+ await client.execute(`
2513
+ INSERT OR IGNORE INTO company_procedures
2514
+ (id, title, content, priority, domain, active, created_at, updated_at)
2515
+ SELECT id, title, content, priority, domain, active, created_at, updated_at
2516
+ FROM global_procedures
2517
+ `);
2518
+ await client.executeMultiple(`
2519
+ CREATE TRIGGER IF NOT EXISTS global_procedures_mirror_insert
2520
+ AFTER INSERT ON global_procedures
2521
+ BEGIN
2522
+ INSERT OR IGNORE INTO company_procedures
2523
+ (id, title, content, priority, domain, active, created_at, updated_at)
2524
+ VALUES
2525
+ (NEW.id, NEW.title, NEW.content, NEW.priority, NEW.domain, NEW.active, NEW.created_at, NEW.updated_at);
2526
+ END;
2527
+
2528
+ CREATE TRIGGER IF NOT EXISTS global_procedures_mirror_update
2529
+ AFTER UPDATE ON global_procedures
2530
+ BEGIN
2531
+ UPDATE company_procedures
2532
+ SET title = NEW.title,
2533
+ content = NEW.content,
2534
+ priority = NEW.priority,
2535
+ domain = NEW.domain,
2536
+ active = NEW.active,
2537
+ created_at = NEW.created_at,
2538
+ updated_at = NEW.updated_at
2539
+ WHERE id = OLD.id;
2540
+ END;
2541
+ `);
2542
+ } else {
2543
+ await client.execute(`
2544
+ CREATE VIEW IF NOT EXISTS global_procedures AS
2545
+ SELECT id, title, content, priority, domain, active, created_at, updated_at
2546
+ FROM company_procedures
2547
+ `);
2548
+ await client.executeMultiple(`
2549
+ CREATE TRIGGER IF NOT EXISTS global_procedures_insert
2550
+ INSTEAD OF INSERT ON global_procedures
2551
+ BEGIN
2552
+ INSERT INTO company_procedures
2553
+ (id, title, content, priority, domain, active, created_at, updated_at)
2554
+ VALUES
2555
+ (NEW.id, NEW.title, NEW.content, NEW.priority, NEW.domain, NEW.active, NEW.created_at, NEW.updated_at);
2556
+ END;
2557
+
2558
+ CREATE TRIGGER IF NOT EXISTS global_procedures_update
2559
+ INSTEAD OF UPDATE ON global_procedures
2560
+ BEGIN
2561
+ UPDATE company_procedures
2562
+ SET title = NEW.title,
2563
+ content = NEW.content,
2564
+ priority = NEW.priority,
2565
+ domain = NEW.domain,
2566
+ active = NEW.active,
2567
+ created_at = NEW.created_at,
2568
+ updated_at = NEW.updated_at
2569
+ WHERE id = OLD.id;
2570
+ END;
2571
+ `);
2572
+ }
2506
2573
  await client.executeMultiple(`
2507
2574
  CREATE TABLE IF NOT EXISTS conversations (
2508
2575
  id TEXT PRIMARY KEY,
@@ -3851,7 +3918,7 @@ var init_platform_procedures = __esm({
3851
3918
  title: "MCP tools \u2014 advanced (triggers, skills, orchestration)",
3852
3919
  domain: "tool-use",
3853
3920
  priority: "p1",
3854
- 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."
3921
+ 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."
3855
3922
  }
3856
3923
  ];
3857
3924
  PLATFORM_PROCEDURE_TITLES = new Set(
@@ -3872,7 +3939,7 @@ import { randomUUID as randomUUID2 } from "crypto";
3872
3939
  async function loadGlobalProcedures() {
3873
3940
  const client = getClient();
3874
3941
  const result = await client.execute({
3875
- sql: "SELECT * FROM global_procedures WHERE active = 1 ORDER BY priority ASC, created_at ASC",
3942
+ sql: "SELECT * FROM company_procedures WHERE active = 1 ORDER BY priority ASC, created_at ASC",
3876
3943
  args: []
3877
3944
  });
3878
3945
  const allRows = result.rows;
@@ -3901,7 +3968,7 @@ async function storeGlobalProcedure(input) {
3901
3968
  const now = (/* @__PURE__ */ new Date()).toISOString();
3902
3969
  const client = getClient();
3903
3970
  await client.execute({
3904
- sql: `INSERT INTO global_procedures (id, title, content, priority, domain, active, created_at, updated_at)
3971
+ sql: `INSERT INTO company_procedures (id, title, content, priority, domain, active, created_at, updated_at)
3905
3972
  VALUES (?, ?, ?, ?, ?, 1, ?, ?)`,
3906
3973
  args: [id, input.title, input.content, input.priority ?? "p0", input.domain ?? null, now, now]
3907
3974
  });
@@ -3912,7 +3979,7 @@ async function deactivateGlobalProcedure(id) {
3912
3979
  const now = (/* @__PURE__ */ new Date()).toISOString();
3913
3980
  const client = getClient();
3914
3981
  const result = await client.execute({
3915
- sql: "UPDATE global_procedures SET active = 0, updated_at = ? WHERE id = ?",
3982
+ sql: "UPDATE company_procedures SET active = 0, updated_at = ? WHERE id = ?",
3916
3983
  args: [now, id]
3917
3984
  });
3918
3985
  await loadGlobalProcedures();
@@ -2288,7 +2288,7 @@ async function ensureSchema() {
2288
2288
  ON session_kills(agent_id);
2289
2289
  `);
2290
2290
  await client.execute(`
2291
- CREATE TABLE IF NOT EXISTS global_procedures (
2291
+ CREATE TABLE IF NOT EXISTS company_procedures (
2292
2292
  id TEXT PRIMARY KEY,
2293
2293
  title TEXT NOT NULL,
2294
2294
  content TEXT NOT NULL,
@@ -2299,6 +2299,73 @@ async function ensureSchema() {
2299
2299
  updated_at TEXT NOT NULL
2300
2300
  )
2301
2301
  `);
2302
+ const legacyProcedureObject = await client.execute({
2303
+ sql: "SELECT type FROM sqlite_master WHERE name = 'global_procedures'",
2304
+ args: []
2305
+ });
2306
+ const legacyProcedureType = legacyProcedureObject.rows[0]?.type == null ? null : String(legacyProcedureObject.rows[0].type);
2307
+ if (legacyProcedureType === "table") {
2308
+ await client.execute(`
2309
+ INSERT OR IGNORE INTO company_procedures
2310
+ (id, title, content, priority, domain, active, created_at, updated_at)
2311
+ SELECT id, title, content, priority, domain, active, created_at, updated_at
2312
+ FROM global_procedures
2313
+ `);
2314
+ await client.executeMultiple(`
2315
+ CREATE TRIGGER IF NOT EXISTS global_procedures_mirror_insert
2316
+ AFTER INSERT ON global_procedures
2317
+ BEGIN
2318
+ INSERT OR IGNORE INTO company_procedures
2319
+ (id, title, content, priority, domain, active, created_at, updated_at)
2320
+ VALUES
2321
+ (NEW.id, NEW.title, NEW.content, NEW.priority, NEW.domain, NEW.active, NEW.created_at, NEW.updated_at);
2322
+ END;
2323
+
2324
+ CREATE TRIGGER IF NOT EXISTS global_procedures_mirror_update
2325
+ AFTER UPDATE ON global_procedures
2326
+ BEGIN
2327
+ UPDATE company_procedures
2328
+ SET title = NEW.title,
2329
+ content = NEW.content,
2330
+ priority = NEW.priority,
2331
+ domain = NEW.domain,
2332
+ active = NEW.active,
2333
+ created_at = NEW.created_at,
2334
+ updated_at = NEW.updated_at
2335
+ WHERE id = OLD.id;
2336
+ END;
2337
+ `);
2338
+ } else {
2339
+ await client.execute(`
2340
+ CREATE VIEW IF NOT EXISTS global_procedures AS
2341
+ SELECT id, title, content, priority, domain, active, created_at, updated_at
2342
+ FROM company_procedures
2343
+ `);
2344
+ await client.executeMultiple(`
2345
+ CREATE TRIGGER IF NOT EXISTS global_procedures_insert
2346
+ INSTEAD OF INSERT ON global_procedures
2347
+ BEGIN
2348
+ INSERT INTO company_procedures
2349
+ (id, title, content, priority, domain, active, created_at, updated_at)
2350
+ VALUES
2351
+ (NEW.id, NEW.title, NEW.content, NEW.priority, NEW.domain, NEW.active, NEW.created_at, NEW.updated_at);
2352
+ END;
2353
+
2354
+ CREATE TRIGGER IF NOT EXISTS global_procedures_update
2355
+ INSTEAD OF UPDATE ON global_procedures
2356
+ BEGIN
2357
+ UPDATE company_procedures
2358
+ SET title = NEW.title,
2359
+ content = NEW.content,
2360
+ priority = NEW.priority,
2361
+ domain = NEW.domain,
2362
+ active = NEW.active,
2363
+ created_at = NEW.created_at,
2364
+ updated_at = NEW.updated_at
2365
+ WHERE id = OLD.id;
2366
+ END;
2367
+ `);
2368
+ }
2302
2369
  await client.executeMultiple(`
2303
2370
  CREATE TABLE IF NOT EXISTS conversations (
2304
2371
  id TEXT PRIMARY KEY,
@@ -3175,7 +3242,7 @@ var init_platform_procedures = __esm({
3175
3242
  title: "MCP tools \u2014 advanced (triggers, skills, orchestration)",
3176
3243
  domain: "tool-use",
3177
3244
  priority: "p1",
3178
- 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."
3245
+ 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."
3179
3246
  }
3180
3247
  ];
3181
3248
  PLATFORM_PROCEDURE_TITLES = new Set(
@@ -3196,7 +3263,7 @@ import { randomUUID as randomUUID2 } from "crypto";
3196
3263
  async function loadGlobalProcedures() {
3197
3264
  const client = getClient();
3198
3265
  const result = await client.execute({
3199
- sql: "SELECT * FROM global_procedures WHERE active = 1 ORDER BY priority ASC, created_at ASC",
3266
+ sql: "SELECT * FROM company_procedures WHERE active = 1 ORDER BY priority ASC, created_at ASC",
3200
3267
  args: []
3201
3268
  });
3202
3269
  const allRows = result.rows;
@@ -3225,7 +3292,7 @@ async function storeGlobalProcedure(input) {
3225
3292
  const now = (/* @__PURE__ */ new Date()).toISOString();
3226
3293
  const client = getClient();
3227
3294
  await client.execute({
3228
- sql: `INSERT INTO global_procedures (id, title, content, priority, domain, active, created_at, updated_at)
3295
+ sql: `INSERT INTO company_procedures (id, title, content, priority, domain, active, created_at, updated_at)
3229
3296
  VALUES (?, ?, ?, ?, ?, 1, ?, ?)`,
3230
3297
  args: [id, input.title, input.content, input.priority ?? "p0", input.domain ?? null, now, now]
3231
3298
  });
@@ -3236,7 +3303,7 @@ async function deactivateGlobalProcedure(id) {
3236
3303
  const now = (/* @__PURE__ */ new Date()).toISOString();
3237
3304
  const client = getClient();
3238
3305
  const result = await client.execute({
3239
- sql: "UPDATE global_procedures SET active = 0, updated_at = ? WHERE id = ?",
3306
+ sql: "UPDATE company_procedures SET active = 0, updated_at = ? WHERE id = ?",
3240
3307
  args: [now, id]
3241
3308
  });
3242
3309
  await loadGlobalProcedures();