@automagik/omni 2.260908.8 → 2.260908.9

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.
@@ -0,0 +1,32 @@
1
+ -- Manifest-compilation provenance on automations (#986, RFC #925 G4b).
2
+ --
3
+ -- Adds `automations.managed_by_agent_id`: set when the row was COMPILED from
4
+ -- `agents.event_manifest` by the manifest compiler
5
+ -- (packages/api/src/services/manifest-compiler.ts); NULL = hand-made. The
6
+ -- agent's manifest is the source of truth and `automations` becomes the
7
+ -- compiled plan for these rows — the API rejects manual create/update/delete
8
+ -- of a managed automation so the plan cannot drift silently.
9
+ --
10
+ -- The FK is ON DELETE CASCADE so a hard agent delete removes its compiled
11
+ -- plan at the DB level (the service-level soft delete reconciles compiled
12
+ -- rows away explicitly before that ever matters). NOT VALID mirrors the 0041
13
+ -- precedent: no scan on deploy; every new write is checked.
14
+ --
15
+ -- Hand-written following the 0043/0044/0052 precedent (additive, idempotent).
16
+ --
17
+ -- NOTE: no explicit BEGIN/COMMIT — the boot migrator executes this file on a
18
+ -- pooled postgres-js connection, which rejects raw transaction control.
19
+
20
+ ALTER TABLE "automations" ADD COLUMN IF NOT EXISTS "managed_by_agent_id" uuid;
21
+ --> statement-breakpoint
22
+ DO $$
23
+ BEGIN
24
+ IF NOT EXISTS (
25
+ SELECT 1 FROM pg_constraint
26
+ WHERE conname = 'automations_managed_by_agent_fk' AND conrelid = '"automations"'::regclass
27
+ ) THEN
28
+ ALTER TABLE "automations" ADD CONSTRAINT "automations_managed_by_agent_fk" FOREIGN KEY ("managed_by_agent_id") REFERENCES "agents" ("id") ON DELETE CASCADE NOT VALID;
29
+ END IF;
30
+ END $$;
31
+ --> statement-breakpoint
32
+ CREATE INDEX IF NOT EXISTS "automations_managed_by_agent_idx" ON "automations" ("managed_by_agent_id");
@@ -442,6 +442,13 @@
442
442
  "when": 1786200000000,
443
443
  "tag": "0062_agent_event_manifest",
444
444
  "breakpoints": true
445
+ },
446
+ {
447
+ "idx": 63,
448
+ "version": "7",
449
+ "when": 1786300000000,
450
+ "tag": "0063_automation_manifest_provenance",
451
+ "breakpoints": true
445
452
  }
446
453
  ]
447
454
  }
@@ -29,6 +29,7 @@ declare function parseManifestSource(source: string, format: 'json' | 'yaml'): u
29
29
  declare function validateManifestDocument(raw: unknown): AgentEventManifest;
30
30
  /** Minimal agent shape the graph helpers need (matches SDK list output). */
31
31
  interface GraphAgentInput {
32
+ id: string;
32
33
  name: string;
33
34
  eventManifest?: {
34
35
  accepts?: {
@@ -44,12 +45,33 @@ interface GraphRow {
44
45
  agent: string;
45
46
  consumes: string;
46
47
  produces: string;
48
+ compiled: string;
47
49
  }
50
+ /**
51
+ * Count compiled (manifest-managed) automations per owning agent (#986).
52
+ * Input is the SDK automations list; rows without `managedByAgentId` are
53
+ * hand-made and ignored.
54
+ */
55
+ declare function countManagedAutomations(automations: Array<{
56
+ managedByAgentId?: string | null;
57
+ }>): Map<string, number>;
58
+ /**
59
+ * Render the declared-vs-materialized indicator for one agent:
60
+ * - `-` when nothing is declared (nothing to compile),
61
+ * - `unknown` when the automations list was unavailable,
62
+ * - `materialized/declared` otherwise (e.g. `2/2`; `0/2` = declared but
63
+ * not yet compiled — the manifest predates the G4b compiler).
64
+ */
65
+ declare function formatCompiledIndicator(declared: number, materialized: number | undefined): string;
48
66
  /**
49
67
  * Build the producer/consumer table: one row per agent that declares at least
50
68
  * one accepts/publishes entry. Agents without a manifest are omitted.
69
+ *
70
+ * `managedCounts` (from `countManagedAutomations`, #986) drives the
71
+ * `compiled` column — declared vs materialized state; pass undefined when the
72
+ * automations list could not be fetched.
51
73
  */
52
- declare function buildGraphRows(agents: GraphAgentInput[]): GraphRow[];
74
+ declare function buildGraphRows(agents: GraphAgentInput[], managedCounts?: Map<string, number>): GraphRow[];
53
75
  interface TypeGraphRow {
54
76
  agent: string;
55
77
  role: 'consumes' | 'produces';
@@ -67,6 +89,8 @@ export declare const __testables: {
67
89
  validateManifestDocument: typeof validateManifestDocument;
68
90
  buildGraphRows: typeof buildGraphRows;
69
91
  buildTypeRows: typeof buildTypeRows;
92
+ countManagedAutomations: typeof countManagedAutomations;
93
+ formatCompiledIndicator: typeof formatCompiledIndicator;
70
94
  };
71
95
  export declare function createAgentsCommand(): Command;
72
96
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../../src/commands/agents.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAErD,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAsJpC,8EAA8E;AAC9E,iBAAS,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAE/D;AAED;;;;GAIG;AACH,iBAAS,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAS7E;AAED;;;GAGG;AACH,iBAAS,wBAAwB,CAAC,GAAG,EAAE,OAAO,GAAG,kBAAkB,CASlE;AAED,4EAA4E;AAC5E,UAAU,eAAe;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,aAAa,CAAC,EAAE;QACd,OAAO,CAAC,EAAE;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;SAAE,EAAE,CAAC;QAChE,SAAS,CAAC,EAAE;YAAE,KAAK,EAAE,MAAM,CAAA;SAAE,EAAE,CAAC;KACjC,GAAG,IAAI,CAAC;CACV;AAED,UAAU,QAAQ;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAQD;;;GAGG;AACH,iBAAS,cAAc,CAAC,MAAM,EAAE,eAAe,EAAE,GAAG,QAAQ,EAAE,CAc7D;AAED,UAAU,Y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EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;;;GAIG;AACH,iBAAS,uBAAuB,CAAC,WAAW,EAAE,KAAK,CAAC;IAAE,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAQ9G;AAED;;;;;;GAMG;AACH,iBAAS,uBAAuB,CAAC,QAAQ,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAI3F;AAQD;;;;;;;GAOG;AACH,iBAAS,cAAc,CAAC,MAAM,EAAE,eAAe,EAAE,EAAE,aAAa,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,QAAQ,EAAE,CAelG;AAED,UAAU,YAAY;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,UAAU,GAAG,UAAU,CAAC;IAC9B,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,iBAAS,aAAa,CAAC,MAAM,EAAE,eAAe,EAAE,EAAE,SAAS,EAAE,MAAM,GAAG,YAAY,EAAE,CAcnF;AAED,oCAAoC;AACpC,eAAO,MAAM,WAAW;;;;;;;;CAQvB,CAAC;AAEF,wBAAgB,mBAAmB,IAAI,OAAO,CAoR7C"}
@@ -1 +1 @@
1
- {"version":3,"file":"automations.d.ts","sourceRoot":"","sources":["../../src/commands/automations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA0FpC,wBAAgB,wBAAwB,IAAI,OAAO,CAwUlD"}
1
+ {"version":3,"file":"automations.d.ts","sourceRoot":"","sources":["../../src/commands/automations.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA0FpC,wBAAgB,wBAAwB,IAAI,OAAO,CA2UlD"}
package/dist/index.js CHANGED
@@ -82709,6 +82709,7 @@ var init_schema2 = __esm(() => {
82709
82709
  enabled: boolean2("enabled").notNull().default(true),
82710
82710
  priority: integer("priority").notNull().default(0),
82711
82711
  transactionalEmissions: boolean2("transactional_emissions").notNull().default(false),
82712
+ managedByAgentId: uuid("managed_by_agent_id").references(() => agents.id, { onDelete: "cascade" }),
82712
82713
  createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
82713
82714
  updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow(),
82714
82715
  tenantId: uuid("tenant_id").references(() => tenants.id, { onDelete: "restrict" })
@@ -82718,7 +82719,8 @@ var init_schema2 = __esm(() => {
82718
82719
  nameIdx: index("automations_name_idx").on(table3.name),
82719
82720
  triggerIdx: index("automations_trigger_idx").on(table3.triggerEventType),
82720
82721
  enabledIdx: index("automations_enabled_idx").on(table3.enabled),
82721
- priorityIdx: index("automations_priority_idx").on(table3.priority)
82722
+ priorityIdx: index("automations_priority_idx").on(table3.priority),
82723
+ managedByAgentIdx: index("automations_managed_by_agent_idx").on(table3.managedByAgentId)
82722
82724
  }));
82723
82725
  automationLogStatuses = ["success", "failed", "skipped"];
82724
82726
  automationLogs = pgTable("automation_logs", {
@@ -136693,7 +136695,7 @@ import { fileURLToPath } from "url";
136693
136695
  // package.json
136694
136696
  var package_default = {
136695
136697
  name: "@automagik/omni",
136696
- version: "2.260908.8",
136698
+ version: "2.260908.9",
136697
136699
  repository: {
136698
136700
  type: "git",
136699
136701
  url: "git+https://github.com/automagik-dev/omni.git",
@@ -137808,11 +137810,28 @@ ${issues}`);
137808
137810
  }
137809
137811
  return result.data;
137810
137812
  }
137813
+ function countManagedAutomations(automations2) {
137814
+ const counts = new Map;
137815
+ for (const automation of automations2) {
137816
+ const agentId = automation.managedByAgentId;
137817
+ if (!agentId)
137818
+ continue;
137819
+ counts.set(agentId, (counts.get(agentId) ?? 0) + 1);
137820
+ }
137821
+ return counts;
137822
+ }
137823
+ function formatCompiledIndicator(declared, materialized) {
137824
+ if (declared === 0)
137825
+ return "-";
137826
+ if (materialized === undefined)
137827
+ return "unknown";
137828
+ return `${materialized}/${declared}`;
137829
+ }
137811
137830
  function formatAcceptsEntry(entry) {
137812
137831
  const filtered = entry.filter !== undefined && Object.keys(entry.filter).length > 0;
137813
137832
  return filtered ? `${entry.event} (filtered)` : entry.event;
137814
137833
  }
137815
- function buildGraphRows(agents) {
137834
+ function buildGraphRows(agents, managedCounts) {
137816
137835
  const rows = [];
137817
137836
  for (const agent3 of agents) {
137818
137837
  const manifest = agent3.eventManifest;
@@ -137823,7 +137842,8 @@ function buildGraphRows(agents) {
137823
137842
  rows.push({
137824
137843
  agent: agent3.name,
137825
137844
  consumes: accepts.length > 0 ? accepts.map(formatAcceptsEntry).join(", ") : "-",
137826
- produces: publishes.length > 0 ? publishes.map((entry) => entry.event).join(", ") : "-"
137845
+ produces: publishes.length > 0 ? publishes.map((entry) => entry.event).join(", ") : "-",
137846
+ compiled: formatCompiledIndicator(accepts.length, managedCounts ? managedCounts.get(agent3.id) ?? 0 : undefined)
137827
137847
  });
137828
137848
  }
137829
137849
  return rows;
@@ -137991,7 +138011,13 @@ function createAgentsCommand() {
137991
138011
  list(rows2, { emptyMessage: `No agent declares ${options.type}.` });
137992
138012
  return;
137993
138013
  }
137994
- const rows = buildGraphRows(items);
138014
+ let managedCounts;
138015
+ try {
138016
+ managedCounts = countManagedAutomations(await client.automations.list({}));
138017
+ } catch {
138018
+ managedCounts = undefined;
138019
+ }
138020
+ const rows = buildGraphRows(items, managedCounts);
137995
138021
  list(rows, { emptyMessage: "No agent declares an event manifest." });
137996
138022
  } catch (err2) {
137997
138023
  const message2 = err2 instanceof Error ? err2.message : "Unknown error";
@@ -138829,7 +138855,8 @@ function createAutomationsCommand() {
138829
138855
  name: a2.name,
138830
138856
  trigger: a2.triggerEventType,
138831
138857
  enabled: a2.enabled ? "yes" : "no",
138832
- priority: a2.priority
138858
+ priority: a2.priority,
138859
+ managed: a2.managedByAgentId ? "manifest" : "-"
138833
138860
  }));
138834
138861
  list(items, { emptyMessage: "No automations found." });
138835
138862
  } catch (err2) {
@@ -5596,6 +5596,11 @@ export interface components {
5596
5596
  priority: number;
5597
5597
  /** @description Transactional publication (G5, #988): buffer the run's emit_event publishes and flush them in order only when every action succeeded; a failed run publishes zero */
5598
5598
  transactionalEmissions: boolean;
5599
+ /**
5600
+ * Format: uuid
5601
+ * @description Set when this automation was compiled from an agent event manifest (RFC #925 G4b, #986); null = hand-made. Managed automations reject manual mutation — edit the owning agent’s manifest instead
5602
+ */
5603
+ managedByAgentId: string | null;
5599
5604
  /**
5600
5605
  * Format: date-time
5601
5606
  * @description Creation timestamp
@@ -17032,6 +17037,11 @@ export interface operations {
17032
17037
  priority: number;
17033
17038
  /** @description Transactional publication (G5, #988): buffer the run's emit_event publishes and flush them in order only when every action succeeded; a failed run publishes zero */
17034
17039
  transactionalEmissions: boolean;
17040
+ /**
17041
+ * Format: uuid
17042
+ * @description Set when this automation was compiled from an agent event manifest (RFC #925 G4b, #986); null = hand-made. Managed automations reject manual mutation — edit the owning agent’s manifest instead
17043
+ */
17044
+ managedByAgentId: string | null;
17035
17045
  /**
17036
17046
  * Format: date-time
17037
17047
  * @description Creation timestamp
@@ -17315,6 +17325,11 @@ export interface operations {
17315
17325
  priority: number;
17316
17326
  /** @description Transactional publication (G5, #988): buffer the run's emit_event publishes and flush them in order only when every action succeeded; a failed run publishes zero */
17317
17327
  transactionalEmissions: boolean;
17328
+ /**
17329
+ * Format: uuid
17330
+ * @description Set when this automation was compiled from an agent event manifest (RFC #925 G4b, #986); null = hand-made. Managed automations reject manual mutation — edit the owning agent’s manifest instead
17331
+ */
17332
+ managedByAgentId: string | null;
17318
17333
  /**
17319
17334
  * Format: date-time
17320
17335
  * @description Creation timestamp
@@ -17491,6 +17506,11 @@ export interface operations {
17491
17506
  priority: number;
17492
17507
  /** @description Transactional publication (G5, #988): buffer the run's emit_event publishes and flush them in order only when every action succeeded; a failed run publishes zero */
17493
17508
  transactionalEmissions: boolean;
17509
+ /**
17510
+ * Format: uuid
17511
+ * @description Set when this automation was compiled from an agent event manifest (RFC #925 G4b, #986); null = hand-made. Managed automations reject manual mutation — edit the owning agent’s manifest instead
17512
+ */
17513
+ managedByAgentId: string | null;
17494
17514
  /**
17495
17515
  * Format: date-time
17496
17516
  * @description Creation timestamp
@@ -17845,6 +17865,11 @@ export interface operations {
17845
17865
  priority: number;
17846
17866
  /** @description Transactional publication (G5, #988): buffer the run's emit_event publishes and flush them in order only when every action succeeded; a failed run publishes zero */
17847
17867
  transactionalEmissions: boolean;
17868
+ /**
17869
+ * Format: uuid
17870
+ * @description Set when this automation was compiled from an agent event manifest (RFC #925 G4b, #986); null = hand-made. Managed automations reject manual mutation — edit the owning agent’s manifest instead
17871
+ */
17872
+ managedByAgentId: string | null;
17848
17873
  /**
17849
17874
  * Format: date-time
17850
17875
  * @description Creation timestamp
@@ -18021,6 +18046,11 @@ export interface operations {
18021
18046
  priority: number;
18022
18047
  /** @description Transactional publication (G5, #988): buffer the run's emit_event publishes and flush them in order only when every action succeeded; a failed run publishes zero */
18023
18048
  transactionalEmissions: boolean;
18049
+ /**
18050
+ * Format: uuid
18051
+ * @description Set when this automation was compiled from an agent event manifest (RFC #925 G4b, #986); null = hand-made. Managed automations reject manual mutation — edit the owning agent’s manifest instead
18052
+ */
18053
+ managedByAgentId: string | null;
18024
18054
  /**
18025
18055
  * Format: date-time
18026
18056
  * @description Creation timestamp
@@ -18197,6 +18227,11 @@ export interface operations {
18197
18227
  priority: number;
18198
18228
  /** @description Transactional publication (G5, #988): buffer the run's emit_event publishes and flush them in order only when every action succeeded; a failed run publishes zero */
18199
18229
  transactionalEmissions: boolean;
18230
+ /**
18231
+ * Format: uuid
18232
+ * @description Set when this automation was compiled from an agent event manifest (RFC #925 G4b, #986); null = hand-made. Managed automations reject manual mutation — edit the owning agent’s manifest instead
18233
+ */
18234
+ managedByAgentId: string | null;
18200
18235
  /**
18201
18236
  * Format: date-time
18202
18237
  * @description Creation timestamp