@kici-dev/engine 0.1.22 → 0.1.24

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 (72) hide show
  1. package/dist/approval/types.d.ts +1 -1
  2. package/dist/audit/access-log-policy.d.ts +4 -1
  3. package/dist/audit/access-log-policy.js +11 -1
  4. package/dist/audit/activity.d.ts +3 -1
  5. package/dist/audit/activity.js +8 -16
  6. package/dist/audit/retention-policy.js +6 -0
  7. package/dist/environment/host-match.d.ts +25 -0
  8. package/dist/environment/host-match.js +67 -0
  9. package/dist/environment/index.d.ts +3 -0
  10. package/dist/environment/index.js +3 -1
  11. package/dist/environment/multi-env.d.ts +30 -0
  12. package/dist/environment/multi-env.js +38 -0
  13. package/dist/environment/scope-resolver.d.ts +15 -4
  14. package/dist/environment/scope-resolver.js +55 -15
  15. package/dist/environment/scope-template.d.ts +18 -0
  16. package/dist/environment/scope-template.js +43 -0
  17. package/dist/environment/types.d.ts +15 -2
  18. package/dist/environment/types.js +18 -1
  19. package/dist/fanout/materialize.d.ts +34 -0
  20. package/dist/fanout/materialize.js +72 -45
  21. package/dist/index.d.ts +5 -1
  22. package/dist/index.js +21 -10
  23. package/dist/inputs/build.d.ts +9 -0
  24. package/dist/inputs/build.js +44 -0
  25. package/dist/inputs/coerce.d.ts +25 -0
  26. package/dist/inputs/coerce.js +51 -0
  27. package/dist/inputs/descriptor.d.ts +53 -0
  28. package/dist/inputs/descriptor.js +42 -0
  29. package/dist/inputs/extract.d.ts +15 -0
  30. package/dist/inputs/extract.js +117 -0
  31. package/dist/inputs/index.d.ts +6 -0
  32. package/dist/inputs/index.js +7 -0
  33. package/dist/inputs/schedule.d.ts +19 -0
  34. package/dist/inputs/schedule.js +33 -0
  35. package/dist/labels/compile.d.ts +9 -0
  36. package/dist/labels/compile.js +10 -1
  37. package/dist/labels.d.ts +29 -0
  38. package/dist/labels.js +32 -1
  39. package/dist/mcp/tool-schemas.d.ts +41 -0
  40. package/dist/mcp/tool-schemas.js +49 -0
  41. package/dist/metrics/catalog-policy.d.ts +7 -0
  42. package/dist/metrics/catalog-policy.js +11 -12
  43. package/dist/metrics/metric-catalog.generated.d.ts +22 -2
  44. package/dist/metrics/metric-catalog.generated.js +34 -2
  45. package/dist/protocol/messages/access-log.d.ts +39 -10
  46. package/dist/protocol/messages/access-log.js +7 -2
  47. package/dist/protocol/messages/actor.d.ts +8 -0
  48. package/dist/protocol/messages/actor.js +17 -3
  49. package/dist/protocol/messages/agent-run-result.d.ts +350 -0
  50. package/dist/protocol/messages/agent-run-result.js +123 -0
  51. package/dist/protocol/messages/auth.d.ts +2 -0
  52. package/dist/protocol/messages/auth.js +10 -1
  53. package/dist/protocol/messages/capabilities.d.ts +2 -0
  54. package/dist/protocol/messages/capabilities.js +15 -2
  55. package/dist/protocol/messages/dashboard-global-workflows.d.ts +8 -0
  56. package/dist/protocol/messages/dashboard.d.ts +1513 -39
  57. package/dist/protocol/messages/dashboard.js +210 -15
  58. package/dist/protocol/messages/execution-status.d.ts +52 -1
  59. package/dist/protocol/messages/execution-status.js +115 -54
  60. package/dist/protocol/messages/orchestrator-agent.d.ts +21 -5
  61. package/dist/protocol/messages/orchestrator-agent.js +5 -1
  62. package/dist/protocol/messages/pat-kind.d.ts +16 -0
  63. package/dist/protocol/messages/pat-kind.js +17 -0
  64. package/dist/protocol/messages/peer.d.ts +7 -7
  65. package/dist/protocol/messages/platform-orchestrator.d.ts +424 -8
  66. package/dist/protocol/messages/platform-orchestrator.js +3 -3
  67. package/dist/protocol/messages/run-events.d.ts +5 -1
  68. package/dist/provider/check-run-conclusion.d.ts +1 -1
  69. package/dist/trigger/types.d.ts +75 -7
  70. package/dist/trigger/types.js +19 -2
  71. package/package.json +9 -1
  72. package/sbom.spdx.json +5 -5
@@ -0,0 +1,15 @@
1
+ import type { InputDescriptorT, InputsDescriptorMap } from './descriptor.js';
2
+ /** Thrown when a declared dispatch input falls outside the closed Zod subset. */
3
+ export declare class UnsupportedDispatchInputError extends Error {
4
+ readonly construct: string;
5
+ readonly key?: string | undefined;
6
+ constructor(construct: string, key?: string | undefined);
7
+ }
8
+ /**
9
+ * Walk a Zod schema's `_zod.def`, reject any construct outside the closed
10
+ * subset, and extract a JSON-safe `InputDescriptor`.
11
+ */
12
+ export declare function extractInputDescriptor(schema: unknown, key?: string): InputDescriptorT;
13
+ /** Extract a descriptor for every key in a `{ name: ZodSchema }` map. */
14
+ export declare function extractInputsDescriptorMap(map: Record<string, unknown>): InputsDescriptorMap;
15
+ //# sourceMappingURL=extract.d.ts.map
@@ -0,0 +1,117 @@
1
+ import "../chunk-BTugEXQM.js";
2
+ //#region src/inputs/extract.ts
3
+ /** Thrown when a declared dispatch input falls outside the closed Zod subset. */
4
+ var UnsupportedDispatchInputError = class extends Error {
5
+ construct;
6
+ key;
7
+ constructor(construct, key) {
8
+ super(`Unsupported dispatch input${key ? ` "${key}"` : ""}: ${construct}. Allowed: z.string/number/boolean/enum/literal with .optional/.nullable/.default/.min/.max/.regex/.int.`);
9
+ this.construct = construct;
10
+ this.key = key;
11
+ this.name = "UnsupportedDispatchInputError";
12
+ }
13
+ };
14
+ const defOf = (s) => s?._zod?.def;
15
+ const checkDefOf = (c) => c?._zod?.def;
16
+ /** Pull string/number checks (min/max/int/regex) into descriptor fields. */
17
+ function applyChecks(d, checks, key) {
18
+ for (const c of checks ?? []) {
19
+ const cd = checkDefOf(c);
20
+ switch (cd?.check) {
21
+ case "greater_than":
22
+ d.min = Number(cd.value);
23
+ break;
24
+ case "less_than":
25
+ d.max = Number(cd.value);
26
+ break;
27
+ case "min_length":
28
+ d.min = Number(cd.minimum);
29
+ break;
30
+ case "max_length":
31
+ d.max = Number(cd.maximum);
32
+ break;
33
+ case "string_format":
34
+ if (cd.format === "regex" && cd.pattern) d.pattern = String(typeof cd.pattern === "object" ? cd.pattern.source ?? cd.pattern : cd.pattern);
35
+ else throw new UnsupportedDispatchInputError(`string format:${cd.format ?? "unknown"}`, key);
36
+ break;
37
+ case "number_format":
38
+ if (cd.format === "safeint" || cd.format === "int") d.type = "integer";
39
+ else throw new UnsupportedDispatchInputError(`number format:${cd.format ?? "unknown"}`, key);
40
+ break;
41
+ default: throw new UnsupportedDispatchInputError(`check:${cd?.check ?? "unknown"}`, key);
42
+ }
43
+ }
44
+ }
45
+ /**
46
+ * Walk a Zod schema's `_zod.def`, reject any construct outside the closed
47
+ * subset, and extract a JSON-safe `InputDescriptor`.
48
+ */
49
+ function extractInputDescriptor(schema, key) {
50
+ let cur = schema;
51
+ let optional = false;
52
+ let nullable = false;
53
+ let hasDefault = false;
54
+ let defaultValue;
55
+ for (;;) {
56
+ const d = defOf(cur);
57
+ if (!d) throw new UnsupportedDispatchInputError("non-zod value", key);
58
+ if (d.type === "optional") {
59
+ optional = true;
60
+ cur = d.innerType;
61
+ continue;
62
+ }
63
+ if (d.type === "nullable") {
64
+ nullable = true;
65
+ cur = d.innerType;
66
+ continue;
67
+ }
68
+ if (d.type === "default") {
69
+ hasDefault = true;
70
+ defaultValue = typeof d.defaultValue === "function" ? d.defaultValue() : d.defaultValue;
71
+ cur = d.innerType;
72
+ continue;
73
+ }
74
+ break;
75
+ }
76
+ const d = defOf(cur);
77
+ if (!d) throw new UnsupportedDispatchInputError("non-zod value", key);
78
+ const out = {
79
+ type: "string",
80
+ optional,
81
+ nullable
82
+ };
83
+ if (hasDefault) out.default = defaultValue;
84
+ switch (d.type) {
85
+ case "string":
86
+ out.type = "string";
87
+ applyChecks(out, d.checks, key);
88
+ break;
89
+ case "number":
90
+ out.type = "number";
91
+ applyChecks(out, d.checks, key);
92
+ break;
93
+ case "boolean":
94
+ out.type = "boolean";
95
+ break;
96
+ case "enum":
97
+ out.type = "enum";
98
+ out.values = Object.values(d.entries ?? {});
99
+ break;
100
+ case "literal":
101
+ out.type = "literal";
102
+ out.literal = d.values?.[0] ?? d.value;
103
+ break;
104
+ default: throw new UnsupportedDispatchInputError(`z.${d.type}`, key);
105
+ }
106
+ return out;
107
+ }
108
+ /** Extract a descriptor for every key in a `{ name: ZodSchema }` map. */
109
+ function extractInputsDescriptorMap(map) {
110
+ const out = {};
111
+ for (const [k, v] of Object.entries(map)) out[k] = extractInputDescriptor(v, k);
112
+ return out;
113
+ }
114
+ //#endregion
115
+ export { UnsupportedDispatchInputError, extractInputDescriptor, extractInputsDescriptorMap };
116
+
117
+ //# sourceMappingURL=extract.js.map
@@ -0,0 +1,6 @@
1
+ export * from './descriptor.js';
2
+ export * from './extract.js';
3
+ export * from './build.js';
4
+ export * from './coerce.js';
5
+ export * from './schedule.js';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,7 @@
1
+ import "../chunk-BTugEXQM.js";
2
+ import { DispatchInputType, InputDescriptor, InputsDescriptorMapSchema } from "./descriptor.js";
3
+ import { UnsupportedDispatchInputError, extractInputDescriptor, extractInputsDescriptorMap } from "./extract.js";
4
+ import { buildZodFromDescriptor, buildZodObjectFromMap } from "./build.js";
5
+ import { DispatchInputError, coerceDispatchInputs, parseInputPairs } from "./coerce.js";
6
+ import { assertScheduleInputsSatisfiable, isInputSatisfiableFromDefaults, resolveScheduleInputs } from "./schedule.js";
7
+ export { DispatchInputError, DispatchInputType, InputDescriptor, InputsDescriptorMapSchema, UnsupportedDispatchInputError, assertScheduleInputsSatisfiable, buildZodFromDescriptor, buildZodObjectFromMap, coerceDispatchInputs, extractInputDescriptor, extractInputsDescriptorMap, isInputSatisfiableFromDefaults, parseInputPairs, resolveScheduleInputs };
@@ -0,0 +1,19 @@
1
+ import type { InputDescriptorT, InputsDescriptorMap } from './descriptor.js';
2
+ /**
3
+ * A schedule input resolves with no operator value, so it must be satisfiable
4
+ * from an empty value set: it either declares a default or is optional. Bare
5
+ * required and bare nullable inputs are not satisfiable (Zod still requires the
6
+ * key to be present).
7
+ */
8
+ export declare function isInputSatisfiableFromDefaults(d: InputDescriptorT): boolean;
9
+ /** Throw naming the first schedule input that can never resolve on a fire. */
10
+ export declare function assertScheduleInputsSatisfiable(map: InputsDescriptorMap): void;
11
+ /**
12
+ * Resolve defaults-only schedule inputs (no operator pairs). Returns undefined
13
+ * when the trigger declares no inputs or nothing resolves to a value. Throws
14
+ * `DispatchInputError` on an invalid descriptor — compile-time validation
15
+ * (`assertScheduleInputsSatisfiable`) makes this unreachable for a
16
+ * freshly-compiled lock; no silent fallback.
17
+ */
18
+ export declare function resolveScheduleInputs(map: InputsDescriptorMap | undefined): Record<string, unknown> | undefined;
19
+ //# sourceMappingURL=schedule.d.ts.map
@@ -0,0 +1,33 @@
1
+ import "../chunk-BTugEXQM.js";
2
+ import { coerceDispatchInputs } from "./coerce.js";
3
+ //#region src/inputs/schedule.ts
4
+ /**
5
+ * A schedule input resolves with no operator value, so it must be satisfiable
6
+ * from an empty value set: it either declares a default or is optional. Bare
7
+ * required and bare nullable inputs are not satisfiable (Zod still requires the
8
+ * key to be present).
9
+ */
10
+ function isInputSatisfiableFromDefaults(d) {
11
+ return d.default !== void 0 || d.optional === true;
12
+ }
13
+ /** Throw naming the first schedule input that can never resolve on a fire. */
14
+ function assertScheduleInputsSatisfiable(map) {
15
+ for (const [name, d] of Object.entries(map)) if (!isInputSatisfiableFromDefaults(d)) throw new Error(`schedule input "${name}" must declare a .default() or be .optional() — schedule triggers fire with no operator input`);
16
+ }
17
+ /**
18
+ * Resolve defaults-only schedule inputs (no operator pairs). Returns undefined
19
+ * when the trigger declares no inputs or nothing resolves to a value. Throws
20
+ * `DispatchInputError` on an invalid descriptor — compile-time validation
21
+ * (`assertScheduleInputsSatisfiable`) makes this unreachable for a
22
+ * freshly-compiled lock; no silent fallback.
23
+ */
24
+ function resolveScheduleInputs(map) {
25
+ if (!map || Object.keys(map).length === 0) return void 0;
26
+ const r = coerceDispatchInputs({}, map);
27
+ if ("error" in r) throw r.error;
28
+ return Object.keys(r.values).length > 0 ? r.values : void 0;
29
+ }
30
+ //#endregion
31
+ export { assertScheduleInputsSatisfiable, isInputSatisfiableFromDefaults, resolveScheduleInputs };
32
+
33
+ //# sourceMappingURL=schedule.js.map
@@ -15,9 +15,12 @@ export declare function assertSafeRegex(source: string, flags: string, ctx: stri
15
15
  */
16
16
  export declare function toLabelMatcher(el: string | RegExp, ctx: string): LabelMatcher;
17
17
  export type SelectorEl = string | RegExp;
18
+ /** Single-agent selection policy when multiple agents match a `runsOn` selector. */
19
+ export type RunsOnPickInput = 'deterministic' | 'any';
18
20
  export type RunsOnAuthorInput = SelectorEl | readonly SelectorEl[] | {
19
21
  labels: SelectorEl | readonly SelectorEl[];
20
22
  exclude?: SelectorEl | readonly SelectorEl[];
23
+ pick?: RunsOnPickInput;
21
24
  };
22
25
  export type RunsOnAllAuthorInput = string | RegExp | readonly SelectorEl[] | {
23
26
  include: readonly {
@@ -30,6 +33,12 @@ export declare function normalizeRunsOnToMatchers(runsOn: RunsOnAuthorInput, ctx
30
33
  include: LabelMatcher[];
31
34
  exclude: LabelMatcher[];
32
35
  };
36
+ /**
37
+ * Resolve a `runsOn` author value's single-agent selection policy, defaulting to
38
+ * `'deterministic'` for every form (string / array shorthand inherit the default
39
+ * after normalization; the selector object's explicit `pick` wins).
40
+ */
41
+ export declare function runsOnPickFromInput(runsOn: RunsOnAuthorInput): RunsOnPickInput;
33
42
  /** Normalize a `runsOnAll` author value into include groups + exclude matchers. */
34
43
  export declare function normalizeRunsOnAllToMatchers(input: RunsOnAllAuthorInput, ctx: string): {
35
44
  include: LabelMatcher[][];
@@ -59,6 +59,15 @@ function normalizeRunsOnToMatchers(runsOn, ctx) {
59
59
  exclude: sel.exclude ? asArray(sel.exclude).map((e) => toLabelMatcher(e, ctx)) : []
60
60
  };
61
61
  }
62
+ /**
63
+ * Resolve a `runsOn` author value's single-agent selection policy, defaulting to
64
+ * `'deterministic'` for every form (string / array shorthand inherit the default
65
+ * after normalization; the selector object's explicit `pick` wins).
66
+ */
67
+ function runsOnPickFromInput(runsOn) {
68
+ if (typeof runsOn === "string" || runsOn instanceof RegExp || Array.isArray(runsOn)) return "deterministic";
69
+ return runsOn.pick ?? "deterministic";
70
+ }
62
71
  /** Normalize a `runsOnAll` author value into include groups + exclude matchers. */
63
72
  function normalizeRunsOnAllToMatchers(input, ctx) {
64
73
  if (typeof input === "string" || input instanceof RegExp) return {
@@ -86,6 +95,6 @@ function assertMatchersSafe(matchers, ctx) {
86
95
  for (const m of matchers) if (m.kind === "regex") assertSafeRegex(m.source, m.flags, ctx);
87
96
  }
88
97
  //#endregion
89
- export { assertMatchersSafe, assertSafeRegex, normalizeRunsOnAllToMatchers, normalizeRunsOnToMatchers, toLabelMatcher };
98
+ export { assertMatchersSafe, assertSafeRegex, normalizeRunsOnAllToMatchers, normalizeRunsOnToMatchers, runsOnPickFromInput, toLabelMatcher };
90
99
 
91
100
  //# sourceMappingURL=compile.js.map
package/dist/labels.d.ts CHANGED
@@ -79,6 +79,35 @@ export declare const KNOWN_ROLES: readonly ["builder", "init-runner"];
79
79
  export type AgentRole = (typeof KNOWN_ROLES)[number];
80
80
  /** Reserved label prefix — labels starting with this are system-managed. */
81
81
  export declare const RESERVED_LABEL_PREFIX = "kici:";
82
+ /**
83
+ * Capability label prefix — `kici:capability:<name>` grants an agent a
84
+ * privileged capability beyond plain execution. Distinct from `kici:role:`
85
+ * (which gates which internal job kinds an agent runs).
86
+ */
87
+ export declare const CAPABILITY_LABEL_PREFIX = "kici:capability:";
88
+ /** Build a `kici:capability:<name>` label. */
89
+ export declare function capabilityLabel(name: string): string;
90
+ /**
91
+ * The `ssh-transport` capability: an agent holding this may run the bootstrap
92
+ * bring-up (`ctx.kici.bootstrap.ensureInitRunner` / `preBootSend`) — i.e. SSH
93
+ * to a declared-but-un-agented host. The orchestrator refuses to run a
94
+ * bring-up on an agent that lacks it. Prod-critical: such an agent custodies
95
+ * the bootstrap SSH key.
96
+ */
97
+ export declare const SSH_TRANSPORT_CAPABILITY = "kici:capability:ssh-transport";
98
+ /**
99
+ * The `kici:init` lifecycle label carried by a temporary init-runner agent
100
+ * brought up on a fresh box for bootstrap. Marks it as ephemeral + privileged;
101
+ * it dies on reboot and is reaped. Distinct from `kici:role:init-runner`
102
+ * (which is the per-job `__init__` workspace-init capability — a different
103
+ * concept entirely).
104
+ */
105
+ export declare const INIT_LABEL = "kici:init";
106
+ /**
107
+ * The `kici:privileged:root` label a bootstrap init-runner carries — it runs
108
+ * as root in the target's rescue env to partition / format / install.
109
+ */
110
+ export declare const PRIVILEGED_ROOT_LABEL = "kici:privileged:root";
82
111
  /** Role label prefix — used to generate role-specific labels. */
83
112
  export declare const ROLE_LABEL_PREFIX = "kici:role:";
84
113
  /**
package/dist/labels.js CHANGED
@@ -116,6 +116,37 @@ function normalizeRunsOn(runsOn) {
116
116
  const KNOWN_ROLES = ["builder", "init-runner"];
117
117
  /** Reserved label prefix — labels starting with this are system-managed. */
118
118
  const RESERVED_LABEL_PREFIX = "kici:";
119
+ /**
120
+ * Capability label prefix — `kici:capability:<name>` grants an agent a
121
+ * privileged capability beyond plain execution. Distinct from `kici:role:`
122
+ * (which gates which internal job kinds an agent runs).
123
+ */
124
+ const CAPABILITY_LABEL_PREFIX = "kici:capability:";
125
+ /** Build a `kici:capability:<name>` label. */
126
+ function capabilityLabel(name) {
127
+ return `${CAPABILITY_LABEL_PREFIX}${name}`;
128
+ }
129
+ /**
130
+ * The `ssh-transport` capability: an agent holding this may run the bootstrap
131
+ * bring-up (`ctx.kici.bootstrap.ensureInitRunner` / `preBootSend`) — i.e. SSH
132
+ * to a declared-but-un-agented host. The orchestrator refuses to run a
133
+ * bring-up on an agent that lacks it. Prod-critical: such an agent custodies
134
+ * the bootstrap SSH key.
135
+ */
136
+ const SSH_TRANSPORT_CAPABILITY = "kici:capability:ssh-transport";
137
+ /**
138
+ * The `kici:init` lifecycle label carried by a temporary init-runner agent
139
+ * brought up on a fresh box for bootstrap. Marks it as ephemeral + privileged;
140
+ * it dies on reboot and is reaped. Distinct from `kici:role:init-runner`
141
+ * (which is the per-job `__init__` workspace-init capability — a different
142
+ * concept entirely).
143
+ */
144
+ const INIT_LABEL = "kici:init";
145
+ /**
146
+ * The `kici:privileged:root` label a bootstrap init-runner carries — it runs
147
+ * as root in the target's rescue env to partition / format / install.
148
+ */
149
+ const PRIVILEGED_ROOT_LABEL = "kici:privileged:root";
119
150
  /** Role label prefix — used to generate role-specific labels. */
120
151
  const ROLE_LABEL_PREFIX = "kici:role:";
121
152
  /**
@@ -203,6 +234,6 @@ function separateLabels(labels) {
203
234
  };
204
235
  }
205
236
  //#endregion
206
- export { HOST_LABEL_PREFIX, KNOWN_ROLES, RESERVED_LABEL_PREFIX, ROLE_LABEL_PREFIX, SELF_REPORTED_LABEL_PREFIXES, agentTypeLabel, deriveOsArchLabels, hostLabel, isAutoLabel, isSelfReportedLabel, mergeAutoLabels, normalizeRunsOn, parseHostLabel, resolveRoleLabels, roleToLabel, scalerAgentLabels, scalerLabel, separateLabels, validateNoReservedLabels };
237
+ export { CAPABILITY_LABEL_PREFIX, HOST_LABEL_PREFIX, INIT_LABEL, KNOWN_ROLES, PRIVILEGED_ROOT_LABEL, RESERVED_LABEL_PREFIX, ROLE_LABEL_PREFIX, SELF_REPORTED_LABEL_PREFIXES, SSH_TRANSPORT_CAPABILITY, agentTypeLabel, capabilityLabel, deriveOsArchLabels, hostLabel, isAutoLabel, isSelfReportedLabel, mergeAutoLabels, normalizeRunsOn, parseHostLabel, resolveRoleLabels, roleToLabel, scalerAgentLabels, scalerLabel, separateLabels, validateNoReservedLabels };
207
238
 
208
239
  //# sourceMappingURL=labels.js.map
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Zod argument schemas for the KiCI MCP tools.
3
+ *
4
+ * Browser-safe (zod only) and shared between the Platform-hosted developer MCP
5
+ * and the sibling orchestrator-side admin MCP so both expose an identical tool
6
+ * argument contract. Each export is a Zod *raw shape* (a plain object of Zod
7
+ * fields) so it can be passed directly as an MCP tool `inputSchema`.
8
+ */
9
+ import { z } from 'zod';
10
+ export declare const listRunsToolSchema: {
11
+ orgId: z.ZodOptional<z.ZodString>;
12
+ status: z.ZodOptional<z.ZodString>;
13
+ limit: z.ZodOptional<z.ZodNumber>;
14
+ };
15
+ export declare const getRunToolSchema: {
16
+ orgId: z.ZodOptional<z.ZodString>;
17
+ runId: z.ZodString;
18
+ };
19
+ export declare const getStepLogsToolSchema: {
20
+ orgId: z.ZodOptional<z.ZodString>;
21
+ runId: z.ZodString;
22
+ jobId: z.ZodString;
23
+ stepIndex: z.ZodNumber;
24
+ };
25
+ export declare const listWorkflowsToolSchema: {
26
+ orgId: z.ZodOptional<z.ZodString>;
27
+ };
28
+ export declare const cancelRunToolSchema: {
29
+ orgId: z.ZodOptional<z.ZodString>;
30
+ runId: z.ZodString;
31
+ force: z.ZodOptional<z.ZodBoolean>;
32
+ };
33
+ export declare const rerunRunToolSchema: {
34
+ orgId: z.ZodOptional<z.ZodString>;
35
+ runId: z.ZodString;
36
+ };
37
+ export declare const triggerRunToolSchema: {
38
+ orgId: z.ZodOptional<z.ZodString>;
39
+ registrationId: z.ZodString;
40
+ };
41
+ //# sourceMappingURL=tool-schemas.d.ts.map
@@ -0,0 +1,49 @@
1
+ import "../chunk-BTugEXQM.js";
2
+ import { z } from "zod";
3
+ //#region src/mcp/tool-schemas.ts
4
+ /**
5
+ * Zod argument schemas for the KiCI MCP tools.
6
+ *
7
+ * Browser-safe (zod only) and shared between the Platform-hosted developer MCP
8
+ * and the sibling orchestrator-side admin MCP so both expose an identical tool
9
+ * argument contract. Each export is a Zod *raw shape* (a plain object of Zod
10
+ * fields) so it can be passed directly as an MCP tool `inputSchema`.
11
+ */
12
+ /**
13
+ * Optional organization id. When the calling user belongs to exactly one org
14
+ * it is resolved automatically; pass it explicitly when a member of several.
15
+ */
16
+ const orgIdArg = z.string().min(1).optional().describe("Organization id. Optional when you belong to exactly one organization.");
17
+ const listRunsToolSchema = {
18
+ orgId: orgIdArg,
19
+ status: z.string().optional().describe("Filter by run status (e.g. success, failed, running)."),
20
+ limit: z.number().int().min(1).max(100).optional().describe("Maximum number of runs to return (default 20).")
21
+ };
22
+ const getRunToolSchema = {
23
+ orgId: orgIdArg,
24
+ runId: z.string().min(1).describe("The run id to fetch.")
25
+ };
26
+ const getStepLogsToolSchema = {
27
+ orgId: orgIdArg,
28
+ runId: z.string().min(1).describe("The run id."),
29
+ jobId: z.string().min(1).describe("The job id within the run."),
30
+ stepIndex: z.number().int().min(0).describe("Zero-based step index within the job.")
31
+ };
32
+ const listWorkflowsToolSchema = { orgId: orgIdArg };
33
+ const cancelRunToolSchema = {
34
+ orgId: orgIdArg,
35
+ runId: z.string().min(1).describe("The run id to cancel."),
36
+ force: z.boolean().optional().describe("Force-cancel (SIGKILL, skip cleanup hooks).")
37
+ };
38
+ const rerunRunToolSchema = {
39
+ orgId: orgIdArg,
40
+ runId: z.string().min(1).describe("The run id to re-run.")
41
+ };
42
+ const triggerRunToolSchema = {
43
+ orgId: orgIdArg,
44
+ registrationId: z.string().min(1).describe("The workflow registration id to trigger.")
45
+ };
46
+ //#endregion
47
+ export { cancelRunToolSchema, getRunToolSchema, getStepLogsToolSchema, listRunsToolSchema, listWorkflowsToolSchema, rerunRunToolSchema, triggerRunToolSchema };
48
+
49
+ //# sourceMappingURL=tool-schemas.js.map
@@ -52,6 +52,13 @@ export declare const OVERFLOW_LABEL_VALUE = "__overflow__";
52
52
  * so they are valid push payloads alongside `kici_orch_*`.
53
53
  */
54
54
  export declare const ORCH_PUSHED_METRIC_NAMES: ReadonlySet<MetricName>;
55
+ /**
56
+ * Closed enum of scaler-backend TYPE values the orchestrator's own
57
+ * resource-usage gauges carry on their `scalerType` rollup label.
58
+ * `__global__` is the orchestrator-wide rollup row; the other four match
59
+ * `AGENT_SCALER_VALUES`. Exported so the policy tests can assert against it.
60
+ */
61
+ export declare const ORCH_SCALER_VALUES: readonly ["__global__", "stateful", "container", "firecracker", "bare-metal"];
55
62
  /**
56
63
  * Per-metric, per-label value policy. Missing entries (or missing label
57
64
  * keys within an entry) mean "no value-level constraint" — the label key
@@ -1,4 +1,5 @@
1
1
  import "../chunk-BTugEXQM.js";
2
+ import { ExecutionRunStatus } from "../protocol/messages/execution-status.js";
2
3
  import { MetricNames, MetricService } from "./metric-catalog.generated.js";
3
4
  //#region src/metrics/catalog-policy.ts
4
5
  /**
@@ -48,9 +49,10 @@ const AGENT_SCALER_VALUES = [
48
49
  "bare-metal"
49
50
  ];
50
51
  /**
51
- * Closed enum of scaler values the orchestrator's own resource-usage
52
- * gauges emit. `__global__` is the orchestrator-wide rollup row; the
53
- * other four match `AGENT_SCALER_VALUES`.
52
+ * Closed enum of scaler-backend TYPE values the orchestrator's own
53
+ * resource-usage gauges carry on their `scalerType` rollup label.
54
+ * `__global__` is the orchestrator-wide rollup row; the other four match
55
+ * `AGENT_SCALER_VALUES`. Exported so the policy tests can assert against it.
54
56
  */
55
57
  const ORCH_SCALER_VALUES = ["__global__", ...AGENT_SCALER_VALUES];
56
58
  /** Closed enum of the five scheduled jobs the orchestrator runs (mirrors `OrchestratorScheduledJobName`). */
@@ -94,12 +96,7 @@ const METRIC_LABEL_POLICY = {
94
96
  "handled",
95
97
  "dispatched"
96
98
  ] } },
97
- kici_orch_executions_total: { status: { values: [
98
- "running",
99
- "success",
100
- "failed",
101
- "cancelled"
102
- ] } },
99
+ kici_orch_executions_total: { status: { values: ExecutionRunStatus.options } },
103
100
  kici_orch_steps_total: { status: { values: [
104
101
  "running",
105
102
  "success",
@@ -130,11 +127,13 @@ const METRIC_LABEL_POLICY = {
130
127
  ] }
131
128
  },
132
129
  kici_orch_scaler_cpus_used: {
133
- scaler: { values: ORCH_SCALER_VALUES },
130
+ scaler: { maxUniqueValues: 50 },
131
+ scalerType: { values: ORCH_SCALER_VALUES },
134
132
  machinePool: { maxUniqueValues: 50 }
135
133
  },
136
134
  kici_orch_scaler_memory_bytes_used: {
137
- scaler: { values: ORCH_SCALER_VALUES },
135
+ scaler: { maxUniqueValues: 50 },
136
+ scalerType: { values: ORCH_SCALER_VALUES },
138
137
  machinePool: { maxUniqueValues: 50 }
139
138
  },
140
139
  kici_orch_install_secrets_decisions_total: {
@@ -278,6 +277,6 @@ const METRIC_LABEL_POLICY = {
278
277
  }
279
278
  };
280
279
  //#endregion
281
- export { METRIC_LABEL_POLICY, ORCH_PUSHED_METRIC_NAMES, OVERFLOW_LABEL_VALUE };
280
+ export { METRIC_LABEL_POLICY, ORCH_PUSHED_METRIC_NAMES, ORCH_SCALER_VALUES, OVERFLOW_LABEL_VALUE };
282
281
 
283
282
  //# sourceMappingURL=catalog-policy.js.map
@@ -86,13 +86,17 @@ export declare const MetricNames: {
86
86
  readonly KICI_PLATFORM_LOG_LINES_FORWARDED_TOTAL: "kici_platform_log_lines_forwarded_total";
87
87
  readonly KICI_PLATFORM_METRICS_QUERY_RATE_LIMITED_TOTAL: "kici_platform_metrics_query_rate_limited_total";
88
88
  readonly KICI_PLATFORM_MIMIR_RELAY_ERRORS_TOTAL: "kici_platform_mimir_relay_errors_total";
89
+ readonly KICI_PLATFORM_NOTIFICATIONS_DELIVERED_TOTAL: "kici_platform_notifications_delivered_total";
90
+ readonly KICI_PLATFORM_NOTIFICATIONS_SUPPRESSED_TOTAL: "kici_platform_notifications_suppressed_total";
89
91
  readonly KICI_PLATFORM_ORCH_METRICS_FILTERED_TOTAL: "kici_platform_orch_metrics_filtered_total";
90
92
  readonly KICI_PLATFORM_ORPHAN_CONNECTIONS_SWEPT_TOTAL: "kici_platform_orphan_connections_swept_total";
91
93
  readonly KICI_PLATFORM_PG_POOL_CLIENT_ERRORS_TOTAL: "kici_platform_pg_pool_client_errors_total";
94
+ readonly KICI_PLATFORM_PLAN_CAP_CHECK_ERRORS_TOTAL: "kici_platform_plan_cap_check_errors_total";
92
95
  readonly KICI_PLATFORM_STALE_ORCHESTRATORS_TOTAL: "kici_platform_stale_orchestrators_total";
93
96
  readonly KICI_PLATFORM_STALE_PLATFORM_CONNECTIONS_EVICTED_TOTAL: "kici_platform_stale_platform_connections_evicted_total";
94
97
  readonly KICI_PLATFORM_STALE_RUNS_FAILED_TOTAL: "kici_platform_stale_runs_failed_total";
95
98
  readonly KICI_PLATFORM_STEP_STATUS_FORWARDS_TOTAL: "kici_platform_step_status_forwards_total";
99
+ readonly KICI_PLATFORM_WS_ORG_RATE_LIMITED_TOTAL: "kici_platform_ws_org_rate_limited_total";
96
100
  readonly KICI_REGISTRATIONS_TOTAL: "kici_registrations_total";
97
101
  readonly KICI_UNIVERSAL_GIT_REGISTRATION_ERRORS_TOTAL: "kici_universal_git_registration_errors_total";
98
102
  readonly KICI_USER_REGISTRATION_NOTIFY_TOTAL: "kici_user_registration_notify_total";
@@ -183,8 +187,8 @@ export declare const MetricLabels: {
183
187
  readonly KICI_ORCH_LOG_CHUNKS_RECEIVED_TOTAL: readonly [];
184
188
  readonly KICI_ORCH_PG_POOL_CLIENT_ERRORS_TOTAL: readonly ["source"];
185
189
  readonly KICI_ORCH_SCALER_CONFIG_RELOADS_TOTAL: readonly ["result"];
186
- readonly KICI_ORCH_SCALER_CPUS_USED: readonly ["scaler", "machinePool"];
187
- readonly KICI_ORCH_SCALER_MEMORY_BYTES_USED: readonly ["scaler", "machinePool"];
190
+ readonly KICI_ORCH_SCALER_CPUS_USED: readonly ["scaler", "scalerType", "machinePool"];
191
+ readonly KICI_ORCH_SCALER_MEMORY_BYTES_USED: readonly ["scaler", "scalerType", "machinePool"];
188
192
  readonly KICI_ORCH_SCALER_SPAWN_FAILURES_TOTAL: readonly ["backend", "bound"];
189
193
  readonly KICI_ORCH_SCALER_SPAWN_REFUSALS_TOTAL: readonly [];
190
194
  readonly KICI_ORCH_SOURCE_CACHE_HITS_TOTAL: readonly [];
@@ -222,13 +226,17 @@ export declare const MetricLabels: {
222
226
  readonly KICI_PLATFORM_LOG_LINES_FORWARDED_TOTAL: readonly [];
223
227
  readonly KICI_PLATFORM_METRICS_QUERY_RATE_LIMITED_TOTAL: readonly ["org_id"];
224
228
  readonly KICI_PLATFORM_MIMIR_RELAY_ERRORS_TOTAL: readonly ["reason"];
229
+ readonly KICI_PLATFORM_NOTIFICATIONS_DELIVERED_TOTAL: readonly ["channel_type", "result"];
230
+ readonly KICI_PLATFORM_NOTIFICATIONS_SUPPRESSED_TOTAL: readonly ["org_id"];
225
231
  readonly KICI_PLATFORM_ORCH_METRICS_FILTERED_TOTAL: readonly ["reason", "metric"];
226
232
  readonly KICI_PLATFORM_ORPHAN_CONNECTIONS_SWEPT_TOTAL: readonly [];
227
233
  readonly KICI_PLATFORM_PG_POOL_CLIENT_ERRORS_TOTAL: readonly ["source"];
234
+ readonly KICI_PLATFORM_PLAN_CAP_CHECK_ERRORS_TOTAL: readonly ["org_id"];
228
235
  readonly KICI_PLATFORM_STALE_ORCHESTRATORS_TOTAL: readonly [];
229
236
  readonly KICI_PLATFORM_STALE_PLATFORM_CONNECTIONS_EVICTED_TOTAL: readonly ["org_id"];
230
237
  readonly KICI_PLATFORM_STALE_RUNS_FAILED_TOTAL: readonly [];
231
238
  readonly KICI_PLATFORM_STEP_STATUS_FORWARDS_TOTAL: readonly ["state"];
239
+ readonly KICI_PLATFORM_WS_ORG_RATE_LIMITED_TOTAL: readonly ["org_id"];
232
240
  readonly KICI_REGISTRATIONS_TOTAL: readonly [];
233
241
  readonly KICI_UNIVERSAL_GIT_REGISTRATION_ERRORS_TOTAL: readonly ["reason"];
234
242
  readonly KICI_USER_REGISTRATION_NOTIFY_TOTAL: readonly ["result"];
@@ -357,13 +365,17 @@ export declare const MetricKind: {
357
365
  readonly KICI_PLATFORM_LOG_LINES_FORWARDED_TOTAL: "counter";
358
366
  readonly KICI_PLATFORM_METRICS_QUERY_RATE_LIMITED_TOTAL: "counter";
359
367
  readonly KICI_PLATFORM_MIMIR_RELAY_ERRORS_TOTAL: "counter";
368
+ readonly KICI_PLATFORM_NOTIFICATIONS_DELIVERED_TOTAL: "counter";
369
+ readonly KICI_PLATFORM_NOTIFICATIONS_SUPPRESSED_TOTAL: "counter";
360
370
  readonly KICI_PLATFORM_ORCH_METRICS_FILTERED_TOTAL: "counter";
361
371
  readonly KICI_PLATFORM_ORPHAN_CONNECTIONS_SWEPT_TOTAL: "counter";
362
372
  readonly KICI_PLATFORM_PG_POOL_CLIENT_ERRORS_TOTAL: "counter";
373
+ readonly KICI_PLATFORM_PLAN_CAP_CHECK_ERRORS_TOTAL: "counter";
363
374
  readonly KICI_PLATFORM_STALE_ORCHESTRATORS_TOTAL: "counter";
364
375
  readonly KICI_PLATFORM_STALE_PLATFORM_CONNECTIONS_EVICTED_TOTAL: "counter";
365
376
  readonly KICI_PLATFORM_STALE_RUNS_FAILED_TOTAL: "counter";
366
377
  readonly KICI_PLATFORM_STEP_STATUS_FORWARDS_TOTAL: "counter";
378
+ readonly KICI_PLATFORM_WS_ORG_RATE_LIMITED_TOTAL: "counter";
367
379
  readonly KICI_REGISTRATIONS_TOTAL: "counter";
368
380
  readonly KICI_UNIVERSAL_GIT_REGISTRATION_ERRORS_TOTAL: "counter";
369
381
  readonly KICI_USER_REGISTRATION_NOTIFY_TOTAL: "counter";
@@ -492,13 +504,17 @@ export declare const MetricDescription: {
492
504
  readonly KICI_PLATFORM_LOG_LINES_FORWARDED_TOTAL: "Total log lines forwarded from orchestrators";
493
505
  readonly KICI_PLATFORM_METRICS_QUERY_RATE_LIMITED_TOTAL: "Total dashboard metric-query requests rate-limited (429).";
494
506
  readonly KICI_PLATFORM_MIMIR_RELAY_ERRORS_TOTAL: "Total Mimir push-relay errors (Platform-embedded metrics). Labels: reason.";
507
+ readonly KICI_PLATFORM_NOTIFICATIONS_DELIVERED_TOTAL: "Notification delivery attempts that reached a terminal outcome";
508
+ readonly KICI_PLATFORM_NOTIFICATIONS_SUPPRESSED_TOTAL: "Run-terminal notifications suppressed by the per-org notification quota";
495
509
  readonly KICI_PLATFORM_ORCH_METRICS_FILTERED_TOTAL: "Orchestrator-pushed metric data points dropped or rewritten by the catalog allow-list. Labels: reason, metric.";
496
510
  readonly KICI_PLATFORM_ORPHAN_CONNECTIONS_SWEPT_TOTAL: "Total orphan connections swept from platform_connections";
497
511
  readonly KICI_PLATFORM_PG_POOL_CLIENT_ERRORS_TOTAL: "Total pg connection errors absorbed without a process restart";
512
+ readonly KICI_PLATFORM_PLAN_CAP_CHECK_ERRORS_TOTAL: "WS connection rejected because the plan-limit check errored (fail-closed)";
498
513
  readonly KICI_PLATFORM_STALE_ORCHESTRATORS_TOTAL: "Total orchestrators detected as permanently disconnected";
499
514
  readonly KICI_PLATFORM_STALE_PLATFORM_CONNECTIONS_EVICTED_TOTAL: "platform_connections rows evicted by source.register DB dedup (same-instance reconnect path)";
500
515
  readonly KICI_PLATFORM_STALE_RUNS_FAILED_TOTAL: "Total execution runs failed due to orchestrator staleness";
501
516
  readonly KICI_PLATFORM_STEP_STATUS_FORWARDS_TOTAL: "Total step status forwards received";
517
+ readonly KICI_PLATFORM_WS_ORG_RATE_LIMITED_TOTAL: "Inbound orchestrator messages dropped by the per-org aggregate WS rate limit";
502
518
  readonly KICI_REGISTRATIONS_TOTAL: "Total user registrations (new personal orgs created on first login)";
503
519
  readonly KICI_UNIVERSAL_GIT_REGISTRATION_ERRORS_TOTAL: "Errors encountered while registering universal-git provider bundles";
504
520
  readonly KICI_USER_REGISTRATION_NOTIFY_TOTAL: "New-user Telegram notifications by result (sent|failed)";
@@ -634,13 +650,17 @@ export declare const MetricService: {
634
650
  readonly KICI_PLATFORM_LOG_LINES_FORWARDED_TOTAL: "platform";
635
651
  readonly KICI_PLATFORM_METRICS_QUERY_RATE_LIMITED_TOTAL: "platform";
636
652
  readonly KICI_PLATFORM_MIMIR_RELAY_ERRORS_TOTAL: "platform";
653
+ readonly KICI_PLATFORM_NOTIFICATIONS_DELIVERED_TOTAL: "platform";
654
+ readonly KICI_PLATFORM_NOTIFICATIONS_SUPPRESSED_TOTAL: "platform";
637
655
  readonly KICI_PLATFORM_ORCH_METRICS_FILTERED_TOTAL: "platform";
638
656
  readonly KICI_PLATFORM_ORPHAN_CONNECTIONS_SWEPT_TOTAL: "platform";
639
657
  readonly KICI_PLATFORM_PG_POOL_CLIENT_ERRORS_TOTAL: "platform";
658
+ readonly KICI_PLATFORM_PLAN_CAP_CHECK_ERRORS_TOTAL: "platform";
640
659
  readonly KICI_PLATFORM_STALE_ORCHESTRATORS_TOTAL: "platform";
641
660
  readonly KICI_PLATFORM_STALE_PLATFORM_CONNECTIONS_EVICTED_TOTAL: "platform";
642
661
  readonly KICI_PLATFORM_STALE_RUNS_FAILED_TOTAL: "platform";
643
662
  readonly KICI_PLATFORM_STEP_STATUS_FORWARDS_TOTAL: "platform";
663
+ readonly KICI_PLATFORM_WS_ORG_RATE_LIMITED_TOTAL: "platform";
644
664
  readonly KICI_REGISTRATIONS_TOTAL: "platform";
645
665
  readonly KICI_UNIVERSAL_GIT_REGISTRATION_ERRORS_TOTAL: "orchestrator";
646
666
  readonly KICI_USER_REGISTRATION_NOTIFY_TOTAL: "platform";