@automagik/omni 2.260908.8 → 2.260908.10
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.
- package/db/drizzle/0063_automation_manifest_provenance.sql +32 -0
- package/db/drizzle/meta/_journal.json +7 -0
- package/dist/commands/agents.d.ts +25 -1
- package/dist/commands/agents.d.ts.map +1 -1
- package/dist/commands/automations.d.ts.map +1 -1
- package/dist/commands/webhooks.d.ts +46 -1
- package/dist/commands/webhooks.d.ts.map +1 -1
- package/dist/index.js +84 -10
- package/dist/sdk/client.d.ts +13 -0
- package/dist/sdk/client.d.ts.map +1 -1
- package/dist/sdk/index.d.ts +1 -1
- package/dist/sdk/index.d.ts.map +1 -1
- package/dist/sdk/types.generated.d.ts +35 -0
- package/dist/sdk/types.generated.d.ts.map +1 -1
- package/dist/server/index.js +202 -33
- package/package.json +1 -1
|
@@ -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
|
|
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,M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G,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,
|
|
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"}
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* shell history and `ps`), an environment variable (`--signature-secret-env`),
|
|
13
13
|
* or stdin (`--signature-secret-stdin`, for `pass show ... | omni webhooks ...`).
|
|
14
14
|
*/
|
|
15
|
-
import type { WebhookSignatureConfigBody } from '@omni/sdk';
|
|
15
|
+
import type { WebhookEventTypeMappingBody, WebhookSignatureConfigBody } from '@omni/sdk';
|
|
16
16
|
import { Command } from 'commander';
|
|
17
17
|
interface SignatureSecretOptions {
|
|
18
18
|
signatureSecret?: string;
|
|
@@ -32,6 +32,47 @@ declare function buildSignatureConfig(options: {
|
|
|
32
32
|
signatureHeader?: string;
|
|
33
33
|
signaturePrefix?: string;
|
|
34
34
|
}): WebhookSignatureConfigBody | undefined;
|
|
35
|
+
/**
|
|
36
|
+
* Parse `--event-type-mapping` — inline JSON, or `@path/to/file.json` (the
|
|
37
|
+
* repo's existing @file convention, cf. follow-up's JSON args) — and validate
|
|
38
|
+
* it against the API's mapping schema. Returns undefined when the flag was
|
|
39
|
+
* not given; throws (caught by the command's error path) BEFORE any request
|
|
40
|
+
* is sent on an unreadable file, invalid JSON, or a schema-invalid mapping.
|
|
41
|
+
*/
|
|
42
|
+
declare function resolveEventTypeMapping(raw: string | undefined): WebhookEventTypeMappingBody | undefined;
|
|
43
|
+
interface UpdateSourceOptions extends SignatureSecretOptions {
|
|
44
|
+
name?: string;
|
|
45
|
+
description?: string;
|
|
46
|
+
enable?: boolean;
|
|
47
|
+
disable?: boolean;
|
|
48
|
+
signatureAlgorithm?: string;
|
|
49
|
+
signatureHeader?: string;
|
|
50
|
+
signaturePrefix?: string;
|
|
51
|
+
clearSignature?: boolean;
|
|
52
|
+
idempotencyKeyTemplate?: string;
|
|
53
|
+
strictSchemas?: boolean;
|
|
54
|
+
eventTypeMapping?: string;
|
|
55
|
+
clearEventTypeMapping?: boolean;
|
|
56
|
+
expectedInterval?: string;
|
|
57
|
+
clearCadence?: boolean;
|
|
58
|
+
windowSemantics?: string;
|
|
59
|
+
mutationPolicy?: string;
|
|
60
|
+
}
|
|
61
|
+
interface UpdateSourcePatch {
|
|
62
|
+
name?: string;
|
|
63
|
+
description?: string;
|
|
64
|
+
enabled?: boolean;
|
|
65
|
+
signatureConfig?: WebhookSignatureConfigBody | null;
|
|
66
|
+
signatureSecret?: string;
|
|
67
|
+
idempotencyKeyTemplate?: string;
|
|
68
|
+
strictSchemas?: boolean;
|
|
69
|
+
eventTypeMapping?: WebhookEventTypeMappingBody | null;
|
|
70
|
+
expectedIntervalSeconds?: number | null;
|
|
71
|
+
windowSemantics?: (typeof WINDOW_SEMANTICS)[number];
|
|
72
|
+
mutationPolicy?: (typeof MUTATION_POLICIES)[number];
|
|
73
|
+
}
|
|
74
|
+
/** Assemble the PATCH body from the update flags (only touched fields). */
|
|
75
|
+
declare function buildUpdateSourcePatch(options: UpdateSourceOptions): Promise<UpdateSourcePatch>;
|
|
35
76
|
/**
|
|
36
77
|
* Create-only pairing: the API rejects a `signatureConfig` without a secret
|
|
37
78
|
* and a secret without a config (CreateWebhookSourceSchema). Fail here, before
|
|
@@ -39,12 +80,16 @@ declare function buildSignatureConfig(options: {
|
|
|
39
80
|
* covered — a secret-only update rotates the secret against the stored config.
|
|
40
81
|
*/
|
|
41
82
|
declare function assertPairedSignatureOnCreate(signatureConfig: WebhookSignatureConfigBody | undefined, signatureSecret: string | undefined): void;
|
|
83
|
+
declare const WINDOW_SEMANTICS: readonly ["future_only", "includes_in_progress"];
|
|
84
|
+
declare const MUTATION_POLICIES: readonly ["same_id", "new_id"];
|
|
42
85
|
export declare function createWebhooksCommand(): Command;
|
|
43
86
|
/** Test-only surface — not part of the CLI contract. */
|
|
44
87
|
export declare const __testables: {
|
|
45
88
|
resolveSignatureSecret: typeof resolveSignatureSecret;
|
|
46
89
|
buildSignatureConfig: typeof buildSignatureConfig;
|
|
47
90
|
assertPairedSignatureOnCreate: typeof assertPairedSignatureOnCreate;
|
|
91
|
+
resolveEventTypeMapping: typeof resolveEventTypeMapping;
|
|
92
|
+
buildUpdateSourcePatch: typeof buildUpdateSourcePatch;
|
|
48
93
|
};
|
|
49
94
|
export {};
|
|
50
95
|
//# sourceMappingURL=webhooks.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webhooks.d.ts","sourceRoot":"","sources":["../../src/commands/webhooks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;
|
|
1
|
+
{"version":3,"file":"webhooks.d.ts","sourceRoot":"","sources":["../../src/commands/webhooks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAGH,OAAO,KAAK,EAAE,2BAA2B,EAAE,0BAA0B,EAAE,MAAM,W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AO,CAAC;IACvB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,UAAU,iBAAiB;IACzB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,eAAe,CAAC,EAAE,0BAA0B,GAAG,IAAI,CAAC;IACpD,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,sBAAsB,CAAC,EAAE,MAAM,CAAC;IAChC,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,gBAAgB,CAAC,EAAE,2BAA2B,GAAG,IAAI,CAAC;IACtD,uBAAuB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACxC,eAAe,CAAC,EAAE,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC;IACpD,cAAc,CAAC,EAAE,CAAC,OAAO,iBAAiB,CAAC,CAAC,MAAM,CAAC,CAAC;CACrD;AAED,2EAA2E;AAC3E,iBAAe,sBAAsB,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAuB9F;AAED;;;;;GAKG;AACH,iBAAS,6BAA6B,CACpC,eAAe,EAAE,0BAA0B,GAAG,SAAS,EACvD,eAAe,EAAE,MAAM,GAAG,SAAS,GAClC,IAAI,CAQN;AAID,QAAA,MAAM,gBAAgB,kDAAmD,CAAC;AAC1E,QAAA,MAAM,iBAAiB,gCAAiC,CAAC;AAuDzD,wBAAgB,qBAAqB,IAAI,OAAO,CA4S/C;AAED,wDAAwD;AACxD,eAAO,MAAM,WAAW;;;;;;CAMvB,CAAC"}
|
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.
|
|
136698
|
+
version: "2.260908.10",
|
|
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
|
-
|
|
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) {
|
|
@@ -151728,6 +151755,7 @@ ${lines.join(`
|
|
|
151728
151755
|
}
|
|
151729
151756
|
|
|
151730
151757
|
// src/commands/webhooks.ts
|
|
151758
|
+
import { readFileSync as readFileSync18 } from "fs";
|
|
151731
151759
|
init_zod();
|
|
151732
151760
|
init_output();
|
|
151733
151761
|
var SIGNATURE_ALGORITHMS = ["hmac-sha256", "hmac-sha1", "token-match"];
|
|
@@ -151797,6 +151825,43 @@ function buildSignatureConfig(options3) {
|
|
|
151797
151825
|
}
|
|
151798
151826
|
return { algorithm, header: signatureHeader, prefix: signaturePrefix };
|
|
151799
151827
|
}
|
|
151828
|
+
var eventTypeMappingSchema = exports_external.discriminatedUnion("source", [
|
|
151829
|
+
exports_external.object({
|
|
151830
|
+
source: exports_external.literal("header"),
|
|
151831
|
+
header: exports_external.string().min(1, "header must be 1-200 characters").max(200, "header must be 1-200 characters")
|
|
151832
|
+
}),
|
|
151833
|
+
exports_external.object({
|
|
151834
|
+
source: exports_external.literal("body"),
|
|
151835
|
+
path: exports_external.string().min(1, "path must be 1-200 characters").max(200, "path must be 1-200 characters")
|
|
151836
|
+
})
|
|
151837
|
+
]);
|
|
151838
|
+
var EVENT_TYPE_MAPPING_HINT = 'expected {"source":"header","header":"X-GitHub-Event"} or {"source":"body","path":"event"}';
|
|
151839
|
+
function resolveEventTypeMapping(raw2) {
|
|
151840
|
+
if (raw2 === undefined)
|
|
151841
|
+
return;
|
|
151842
|
+
let text3 = raw2;
|
|
151843
|
+
if (raw2.startsWith("@")) {
|
|
151844
|
+
const path = raw2.slice(1);
|
|
151845
|
+
try {
|
|
151846
|
+
text3 = readFileSync18(path, "utf-8");
|
|
151847
|
+
} catch (err2) {
|
|
151848
|
+
const reason = err2 instanceof Error ? err2.message : "Unknown error";
|
|
151849
|
+
throw new Error(`Cannot read --event-type-mapping file '${path}': ${reason}`);
|
|
151850
|
+
}
|
|
151851
|
+
}
|
|
151852
|
+
let parsed;
|
|
151853
|
+
try {
|
|
151854
|
+
parsed = JSON.parse(text3);
|
|
151855
|
+
} catch {
|
|
151856
|
+
throw new Error(`Invalid JSON for --event-type-mapping; ${EVENT_TYPE_MAPPING_HINT}`);
|
|
151857
|
+
}
|
|
151858
|
+
const result = eventTypeMappingSchema.safeParse(parsed);
|
|
151859
|
+
if (!result.success) {
|
|
151860
|
+
const reason = result.error.issues.map((issue) => issue.path.length > 0 ? `${issue.path.join(".")}: ${issue.message}` : issue.message).join("; ");
|
|
151861
|
+
throw new Error(`Invalid --event-type-mapping: ${reason}; ${EVENT_TYPE_MAPPING_HINT}`);
|
|
151862
|
+
}
|
|
151863
|
+
return result.data;
|
|
151864
|
+
}
|
|
151800
151865
|
async function buildUpdateSourcePatch(options3) {
|
|
151801
151866
|
const updates = buildLifecycleUpdates(options3);
|
|
151802
151867
|
if (options3.name)
|
|
@@ -151807,6 +151872,14 @@ async function buildUpdateSourcePatch(options3) {
|
|
|
151807
151872
|
updates.idempotencyKeyTemplate = options3.idempotencyKeyTemplate;
|
|
151808
151873
|
if (options3.strictSchemas !== undefined)
|
|
151809
151874
|
updates.strictSchemas = options3.strictSchemas;
|
|
151875
|
+
if (options3.clearEventTypeMapping && options3.eventTypeMapping !== undefined) {
|
|
151876
|
+
throw new Error("Use only one of --event-type-mapping and --clear-event-type-mapping");
|
|
151877
|
+
}
|
|
151878
|
+
if (options3.clearEventTypeMapping)
|
|
151879
|
+
updates.eventTypeMapping = null;
|
|
151880
|
+
const eventTypeMapping = resolveEventTypeMapping(options3.eventTypeMapping);
|
|
151881
|
+
if (eventTypeMapping !== undefined)
|
|
151882
|
+
updates.eventTypeMapping = eventTypeMapping;
|
|
151810
151883
|
if (options3.enable)
|
|
151811
151884
|
updates.enabled = true;
|
|
151812
151885
|
if (options3.disable)
|
|
@@ -151916,7 +151989,7 @@ function createWebhooksCommand() {
|
|
|
151916
151989
|
error(`Failed to get webhook source: ${message2}`);
|
|
151917
151990
|
}
|
|
151918
151991
|
});
|
|
151919
|
-
webhooks.command("create").description("Create a webhook source").requiredOption("--name <name>", "Webhook source name").option("--description <desc>", "Description").option("--disabled", "Create in disabled state").option("--headers <json>", `Expected headers as JSON (e.g., '{"X-Secret": true}')`).option("--signature-algorithm <alg>", "Signature verification: hmac-sha256, hmac-sha1, or token-match").option("--signature-header <name>", "Header carrying the signature/token (e.g., X-Hub-Signature-256)").option("--signature-prefix <prefix>", "Prefix before the hex digest (e.g., 'sha256=')").option("--signature-secret <secret>", "Shared secret for signature verification (write-only). Visible in shell history and process lists \u2014 prefer --signature-secret-env or --signature-secret-stdin").option("--signature-secret-env <VAR>", "Read the shared secret from environment variable VAR").option("--signature-secret-stdin", "Read the shared secret from stdin (trailing newline stripped)").option("--idempotency-key-template <template>", "Delivery-identity key template for redelivery dedup (#958). Placeholders: {source}, {sha256(body)}, " + "{headers.<name>}, {payload.<dot.path>}. Defaults to '{source}:{sha256(body)}'").option("--strict-schemas", "Refuse deliveries whose event type has no enabled registered schema (dead-lettered as " + "schema_not_registered, #1000). Recommended for new sources. Defaults to off").option("--expected-interval <seconds>", "Declared cadence: >=1 event or heartbeat per N seconds. Arms liveness supervision (#961)").option("--window-semantics <value>", `Declared window semantics: ${WINDOW_SEMANTICS.join(" or ")}`).option("--mutation-policy <value>", `Declared mutation re-emit policy: ${MUTATION_POLICIES.join(" or ")}`).action(async (options3) => {
|
|
151992
|
+
webhooks.command("create").description("Create a webhook source").requiredOption("--name <name>", "Webhook source name").option("--description <desc>", "Description").option("--disabled", "Create in disabled state").option("--headers <json>", `Expected headers as JSON (e.g., '{"X-Secret": true}')`).option("--signature-algorithm <alg>", "Signature verification: hmac-sha256, hmac-sha1, or token-match").option("--signature-header <name>", "Header carrying the signature/token (e.g., X-Hub-Signature-256)").option("--signature-prefix <prefix>", "Prefix before the hex digest (e.g., 'sha256=')").option("--signature-secret <secret>", "Shared secret for signature verification (write-only). Visible in shell history and process lists \u2014 prefer --signature-secret-env or --signature-secret-stdin").option("--signature-secret-env <VAR>", "Read the shared secret from environment variable VAR").option("--signature-secret-stdin", "Read the shared secret from stdin (trailing newline stripped)").option("--idempotency-key-template <template>", "Delivery-identity key template for redelivery dedup (#958). Placeholders: {source}, {sha256(body)}, " + "{headers.<name>}, {payload.<dot.path>}. Defaults to '{source}:{sha256(body)}'").option("--strict-schemas", "Refuse deliveries whose event type has no enabled registered schema (dead-lettered as " + "schema_not_registered, #1000). Recommended for new sources. Defaults to off").option("--event-type-mapping <json>", "Semantic event-type extraction (#959): inline JSON or @path/to/file.json, e.g. " + `'{"source":"header","header":"X-GitHub-Event"}' or '{"source":"body","path":"event"}'. ` + "A mapped source emits custom.{source}.{event} instead of the collapsed custom.webhook.{source}").option("--expected-interval <seconds>", "Declared cadence: >=1 event or heartbeat per N seconds. Arms liveness supervision (#961)").option("--window-semantics <value>", `Declared window semantics: ${WINDOW_SEMANTICS.join(" or ")}`).option("--mutation-policy <value>", `Declared mutation re-emit policy: ${MUTATION_POLICIES.join(" or ")}`).action(async (options3) => {
|
|
151920
151993
|
const client = getClient();
|
|
151921
151994
|
try {
|
|
151922
151995
|
let expectedHeaders;
|
|
@@ -151939,6 +152012,7 @@ function createWebhooksCommand() {
|
|
|
151939
152012
|
signatureSecret,
|
|
151940
152013
|
idempotencyKeyTemplate: options3.idempotencyKeyTemplate,
|
|
151941
152014
|
strictSchemas: options3.strictSchemas,
|
|
152015
|
+
eventTypeMapping: resolveEventTypeMapping(options3.eventTypeMapping),
|
|
151942
152016
|
expectedIntervalSeconds: parseExpectedInterval(options3.expectedInterval),
|
|
151943
152017
|
windowSemantics: parseWindowSemantics(options3.windowSemantics),
|
|
151944
152018
|
mutationPolicy: parseMutationPolicy(options3.mutationPolicy)
|
|
@@ -151957,7 +152031,7 @@ function createWebhooksCommand() {
|
|
|
151957
152031
|
error(`Failed to create webhook source: ${message2}`);
|
|
151958
152032
|
}
|
|
151959
152033
|
});
|
|
151960
|
-
webhooks.command("update <id>").description("Update a webhook source").option("--name <name>", "New name").option("--description <desc>", "New description").option("--enable", "Enable the webhook").option("--disable", "Disable the webhook").option("--signature-algorithm <alg>", "Signature verification: hmac-sha256, hmac-sha1, or token-match").option("--signature-header <name>", "Header carrying the signature/token (e.g., X-Hub-Signature-256)").option("--signature-prefix <prefix>", "Prefix before the hex digest (e.g., 'sha256=')").option("--signature-secret <secret>", "Shared secret for signature verification (write-only). Visible in shell history and process lists \u2014 prefer --signature-secret-env or --signature-secret-stdin").option("--signature-secret-env <VAR>", "Read the shared secret from environment variable VAR").option("--signature-secret-stdin", "Read the shared secret from stdin (trailing newline stripped)").option("--clear-signature", "Remove the signature config and stored secret").option("--idempotency-key-template <template>", "Delivery-identity key template for redelivery dedup (#958). Placeholders: {source}, {sha256(body)}, " + "{headers.<name>}, {payload.<dot.path>}").option("--strict-schemas", "Refuse deliveries whose event type has no enabled registered schema (dead-lettered as " + "schema_not_registered, #1000)").option("--no-strict-schemas", "Return the source to opt-in pass-through for unregistered event types").option("--expected-interval <seconds>", "Declared cadence: >=1 event or heartbeat per N seconds. (Re)arms liveness supervision (#961)").option("--clear-cadence", "Remove the declared cadence (disarms liveness supervision)").option("--window-semantics <value>", `Declared window semantics: ${WINDOW_SEMANTICS.join(" or ")}`).option("--mutation-policy <value>", `Declared mutation re-emit policy: ${MUTATION_POLICIES.join(" or ")}`).action(async (id, options3) => {
|
|
152034
|
+
webhooks.command("update <id>").description("Update a webhook source").option("--name <name>", "New name").option("--description <desc>", "New description").option("--enable", "Enable the webhook").option("--disable", "Disable the webhook").option("--signature-algorithm <alg>", "Signature verification: hmac-sha256, hmac-sha1, or token-match").option("--signature-header <name>", "Header carrying the signature/token (e.g., X-Hub-Signature-256)").option("--signature-prefix <prefix>", "Prefix before the hex digest (e.g., 'sha256=')").option("--signature-secret <secret>", "Shared secret for signature verification (write-only). Visible in shell history and process lists \u2014 prefer --signature-secret-env or --signature-secret-stdin").option("--signature-secret-env <VAR>", "Read the shared secret from environment variable VAR").option("--signature-secret-stdin", "Read the shared secret from stdin (trailing newline stripped)").option("--clear-signature", "Remove the signature config and stored secret").option("--idempotency-key-template <template>", "Delivery-identity key template for redelivery dedup (#958). Placeholders: {source}, {sha256(body)}, " + "{headers.<name>}, {payload.<dot.path>}").option("--strict-schemas", "Refuse deliveries whose event type has no enabled registered schema (dead-lettered as " + "schema_not_registered, #1000)").option("--no-strict-schemas", "Return the source to opt-in pass-through for unregistered event types").option("--event-type-mapping <json>", "Semantic event-type extraction (#959): inline JSON or @path/to/file.json, e.g. " + `'{"source":"header","header":"X-GitHub-Event"}' or '{"source":"body","path":"event"}'`).option("--clear-event-type-mapping", "Remove the mapping (deliveries fall back to the collapsed custom.webhook.{source} type)").option("--expected-interval <seconds>", "Declared cadence: >=1 event or heartbeat per N seconds. (Re)arms liveness supervision (#961)").option("--clear-cadence", "Remove the declared cadence (disarms liveness supervision)").option("--window-semantics <value>", `Declared window semantics: ${WINDOW_SEMANTICS.join(" or ")}`).option("--mutation-policy <value>", `Declared mutation re-emit policy: ${MUTATION_POLICIES.join(" or ")}`).action(async (id, options3) => {
|
|
151961
152035
|
const resolvedId = await resolveWebhookId(id);
|
|
151962
152036
|
const client = getClient();
|
|
151963
152037
|
try {
|
|
@@ -152055,7 +152129,7 @@ init_config();
|
|
|
152055
152129
|
init_output();
|
|
152056
152130
|
|
|
152057
152131
|
// src/manifest-pin.ts
|
|
152058
|
-
import { existsSync as existsSync21, readFileSync as
|
|
152132
|
+
import { existsSync as existsSync21, readFileSync as readFileSync19, renameSync as renameSync3, writeFileSync as writeFileSync12 } from "fs";
|
|
152059
152133
|
import { homedir as homedir14 } from "os";
|
|
152060
152134
|
import { join as join20 } from "path";
|
|
152061
152135
|
var PACKAGE_NAME2 = "@automagik/omni";
|
|
@@ -152065,7 +152139,7 @@ function pinManifestEntry(manifestPath, exactVersion) {
|
|
|
152065
152139
|
return false;
|
|
152066
152140
|
let manifest;
|
|
152067
152141
|
try {
|
|
152068
|
-
manifest = JSON.parse(
|
|
152142
|
+
manifest = JSON.parse(readFileSync19(manifestPath, "utf-8"));
|
|
152069
152143
|
} catch {
|
|
152070
152144
|
return false;
|
|
152071
152145
|
}
|
package/dist/sdk/client.d.ts
CHANGED
|
@@ -645,6 +645,12 @@ export interface ListWebhookSourcesParams {
|
|
|
645
645
|
* Derived from the generated OpenAPI component so it cannot drift from the API.
|
|
646
646
|
*/
|
|
647
647
|
export type WebhookSignatureConfigBody = components['schemas']['WebhookSignatureConfig'];
|
|
648
|
+
/**
|
|
649
|
+
* Semantic event-type extraction contract for a webhook source (#959/#984):
|
|
650
|
+
* header-source or body-source. Derived from the generated OpenAPI component
|
|
651
|
+
* so it cannot drift from the API.
|
|
652
|
+
*/
|
|
653
|
+
export type WebhookEventTypeMappingBody = components['schemas']['WebhookEventTypeMapping'];
|
|
648
654
|
/**
|
|
649
655
|
* Body for creating a webhook source.
|
|
650
656
|
*
|
|
@@ -681,6 +687,13 @@ export interface CreateWebhookSourceBody {
|
|
|
681
687
|
* passing through. Defaults to false server-side (opt-in pass-through).
|
|
682
688
|
*/
|
|
683
689
|
strictSchemas?: boolean;
|
|
690
|
+
/**
|
|
691
|
+
* Semantic event-type extraction (#959/#984): a mapped source emits
|
|
692
|
+
* `custom.{source}.{event}` (event name read from a header or a body
|
|
693
|
+
* dot-path) instead of the collapsed `custom.webhook.{source}`. Null or
|
|
694
|
+
* absent keeps the collapsed type; null clears it on update.
|
|
695
|
+
*/
|
|
696
|
+
eventTypeMapping?: WebhookEventTypeMappingBody | null;
|
|
684
697
|
/** Defaults to true server-side */
|
|
685
698
|
enabled?: boolean;
|
|
686
699
|
/**
|