@cat-factory/contracts 0.32.0 → 0.33.0

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/dist/index.d.ts CHANGED
@@ -40,6 +40,7 @@ export * from './slack.js';
40
40
  export * from './observability.js';
41
41
  export * from './incident-enrichment.js';
42
42
  export * from './accountSettings.js';
43
+ export * from './localSettings.js';
43
44
  export * from './recurring.js';
44
45
  export * from './tracker.js';
45
46
  export * from './vendor-credentials.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,eAAe,CAAA;AAC7B,cAAc,eAAe,CAAA;AAC7B,cAAc,uBAAuB,CAAA;AACrC,cAAc,eAAe,CAAA;AAC7B,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,aAAa,CAAA;AAC3B,cAAc,sBAAsB,CAAA;AACpC,cAAc,kBAAkB,CAAA;AAChC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA;AAC1B,cAAc,mBAAmB,CAAA;AACjC,cAAc,cAAc,CAAA;AAC5B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,eAAe,CAAA;AAC7B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,oBAAoB,CAAA;AAClC,cAAc,mBAAmB,CAAA;AACjC,cAAc,eAAe,CAAA;AAC7B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,cAAc,CAAA;AAC5B,cAAc,iBAAiB,CAAA;AAC/B,cAAc,WAAW,CAAA;AACzB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,cAAc,CAAA;AAC5B,cAAc,mBAAmB,CAAA;AACjC,cAAc,mBAAmB,CAAA;AACjC,cAAc,yBAAyB,CAAA;AACvC,c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AAA;AACzB,cAAc,gBAAgB,CAAA;AAC9B,cAAc,YAAY,CAAA;AAC1B,cAAc,gBAAgB,CAAA;AAC9B,cAAc,cAAc,CAAA;AAC5B,cAAc,mBAAmB,CAAA;AACjC,cAAc,mBAAmB,CAAA;AACjC,cAAc,yBAAyB,CAAA;AACvC,cAAc,cAAc,CAAA;AAC5B,cAAc,mBAAmB,CAAA;AACjC,cAAc,wBAAwB,CAAA;AACtC,cAAc,oBAAoB,CAAA;AAClC,cAAc,gCAAgC,CAAA;AAC9C,cAAc,oBAAoB,CAAA;AAClC,cAAc,YAAY,CAAA;AAC1B,cAAc,oBAAoB,CAAA;AAClC,cAAc,0BAA0B,CAAA;AACxC,cAAc,sBAAsB,CAAA;AACpC,cAAc,oBAAoB,CAAA;AAClC,cAAc,gBAAgB,CAAA;AAC9B,cAAc,cAAc,CAAA;AAC5B,cAAc,yBAAyB,CAAA;AACvC,cAAc,eAAe,CAAA;AAC7B,cAAc,6BAA6B,CAAA;AAC3C,cAAc,kBAAkB,CAAA;AAChC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,cAAc,CAAA;AAC5B,cAAc,yBAAyB,CAAA;AACvC,cAAc,aAAa,CAAA"}
package/dist/index.js CHANGED
@@ -40,6 +40,7 @@ export * from './slack.js';
40
40
  export * from './observability.js';
41
41
  export * from './incident-enrichment.js';
42
42
  export * from './accountSettings.js';
43
+ export * from './localSettings.js';
43
44
  export * from './recurring.js';
44
45
  export * from './tracker.js';
45
46
  export * from './vendor-credentials.js';
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,eAAe,CAAA;AAC7B,cAAc,eAAe,CAAA;AAC7B,cAAc,uBAAuB,CAAA;AACrC,cAAc,eAAe,CAAA;AAC7B,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CA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AAc,6BAA6B,CAAA;AAC3C,cAAc,kBAAkB,CAAA;AAChC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,cAAc,CAAA;AAC5B,cAAc,yBAAyB,CAAA;AACvC,cAAc,aAAa,CAAA"}
@@ -0,0 +1,75 @@
1
+ import * as v from 'valibot';
2
+ /**
3
+ * Warm-container-pool sizing (the local Docker-family runner). `size: 0` ⇒ pooling OFF —
4
+ * every run cold-starts its own container, the classic behaviour. `> 0` keeps that many
5
+ * idle harness containers warm and re-leases one (preferring repo affinity) to each run.
6
+ */
7
+ export declare const localPoolSettingsSchema: v.ObjectSchema<{
8
+ /** Max idle warm containers kept for re-lease. 0 disables pooling (cold-start per run). */
9
+ readonly size: v.OptionalSchema<v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, v.MaxValueAction<number, 50, undefined>]>, 0>;
10
+ /** Containers pre-warmed when the service starts (clamped to `max`). */
11
+ readonly minWarm: v.OptionalSchema<v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, v.MaxValueAction<number, 50, undefined>]>, 0>;
12
+ /** Hard cap on total containers (leased + idle). `null` ⇒ defaults to `size`. */
13
+ readonly max: v.OptionalSchema<v.NullableSchema<v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, v.MaxValueAction<number, 100, undefined>]>, undefined>, null>;
14
+ /** How long an idle pooled container is kept before eviction (ms). */
15
+ readonly idleTtlMs: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, 600000>;
16
+ }, undefined>;
17
+ export type LocalPoolSettings = v.InferOutput<typeof localPoolSettingsSchema>;
18
+ /**
19
+ * Per-repo checkout-reuse knobs, forwarded into the harness container as env. When the
20
+ * warm pool re-leases a container that already holds the run's repo, the harness reuses
21
+ * its `<workspaceRoot>/<owner>/<repo>` checkout (clean-sweep + fetch + switch branch)
22
+ * instead of cloning fresh; `cleanKeep` are the dep-cache dirs that sweep preserves.
23
+ */
24
+ export declare const localCheckoutSettingsSchema: v.ObjectSchema<{
25
+ /** Absolute in-container dir the reused per-repo checkout lives under. */
26
+ readonly workspaceRoot: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>, v.RegexAction<string, "workspaceRoot must be an absolute (POSIX) path, e.g. /workspace">]>, "/workspace">;
27
+ /** Dep-cache directories the per-run clean sweep keeps (so deps aren't reinstalled). */
28
+ readonly cleanKeep: v.OptionalSchema<v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>, undefined>, readonly ["node_modules", ".venv", "target", ".gradle", ".pnpm-store"]>;
29
+ }, undefined>;
30
+ export type LocalCheckoutSettings = v.InferOutput<typeof localCheckoutSettingsSchema>;
31
+ /** The full local-mode settings blob. Every field defaults, so `{}` parses to defaults. */
32
+ export declare const localSettingsSchema: v.ObjectSchema<{
33
+ readonly pool: v.OptionalSchema<v.ObjectSchema<{
34
+ /** Max idle warm containers kept for re-lease. 0 disables pooling (cold-start per run). */
35
+ readonly size: v.OptionalSchema<v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, v.MaxValueAction<number, 50, undefined>]>, 0>;
36
+ /** Containers pre-warmed when the service starts (clamped to `max`). */
37
+ readonly minWarm: v.OptionalSchema<v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, v.MaxValueAction<number, 50, undefined>]>, 0>;
38
+ /** Hard cap on total containers (leased + idle). `null` ⇒ defaults to `size`. */
39
+ readonly max: v.OptionalSchema<v.NullableSchema<v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, v.MaxValueAction<number, 100, undefined>]>, undefined>, null>;
40
+ /** How long an idle pooled container is kept before eviction (ms). */
41
+ readonly idleTtlMs: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, 600000>;
42
+ }, undefined>, {}>;
43
+ readonly checkout: v.OptionalSchema<v.ObjectSchema<{
44
+ /** Absolute in-container dir the reused per-repo checkout lives under. */
45
+ readonly workspaceRoot: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>, v.RegexAction<string, "workspaceRoot must be an absolute (POSIX) path, e.g. /workspace">]>, "/workspace">;
46
+ /** Dep-cache directories the per-run clean sweep keeps (so deps aren't reinstalled). */
47
+ readonly cleanKeep: v.OptionalSchema<v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>, undefined>, readonly ["node_modules", ".venv", "target", ".gradle", ".pnpm-store"]>;
48
+ }, undefined>, {}>;
49
+ }, undefined>;
50
+ export type LocalSettings = v.InferOutput<typeof localSettingsSchema>;
51
+ /** Built-in config used when no row exists yet (pooling off, harness defaults). */
52
+ export declare const DEFAULT_LOCAL_SETTINGS: LocalSettings;
53
+ /** Parse + fully-default a (possibly partial / absent) stored settings blob. */
54
+ export declare function parseLocalSettings(raw: unknown): LocalSettings;
55
+ /** Admin write: the full settings blob fully replaces the stored config. */
56
+ export declare const updateLocalSettingsSchema: v.ObjectSchema<{
57
+ readonly pool: v.OptionalSchema<v.ObjectSchema<{
58
+ /** Max idle warm containers kept for re-lease. 0 disables pooling (cold-start per run). */
59
+ readonly size: v.OptionalSchema<v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, v.MaxValueAction<number, 50, undefined>]>, 0>;
60
+ /** Containers pre-warmed when the service starts (clamped to `max`). */
61
+ readonly minWarm: v.OptionalSchema<v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, v.MaxValueAction<number, 50, undefined>]>, 0>;
62
+ /** Hard cap on total containers (leased + idle). `null` ⇒ defaults to `size`. */
63
+ readonly max: v.OptionalSchema<v.NullableSchema<v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, v.MaxValueAction<number, 100, undefined>]>, undefined>, null>;
64
+ /** How long an idle pooled container is kept before eviction (ms). */
65
+ readonly idleTtlMs: v.OptionalSchema<v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>, 600000>;
66
+ }, undefined>, {}>;
67
+ readonly checkout: v.OptionalSchema<v.ObjectSchema<{
68
+ /** Absolute in-container dir the reused per-repo checkout lives under. */
69
+ readonly workspaceRoot: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>, v.RegexAction<string, "workspaceRoot must be an absolute (POSIX) path, e.g. /workspace">]>, "/workspace">;
70
+ /** Dep-cache directories the per-run clean sweep keeps (so deps aren't reinstalled). */
71
+ readonly cleanKeep: v.OptionalSchema<v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>]>, undefined>, readonly ["node_modules", ".venv", "target", ".gradle", ".pnpm-store"]>;
72
+ }, undefined>, {}>;
73
+ }, undefined>;
74
+ export type UpdateLocalSettingsInput = v.InferOutput<typeof updateLocalSettingsSchema>;
75
+ //# sourceMappingURL=localSettings.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"localSettings.d.ts","sourceRoot":"","sources":["../src/localSettings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAgB5B;;;;GAIG;AACH,eAAO,MAAM,uBAAuB;IAClC,2FAA2F;;IAE3F,wEAAwE;;IAExE,iFAAiF;;IAEjF,sEAAsE;;aAEtE,CAAA;AACF,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,uBAAuB,CAAC,CAAA;AAE7E;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B;IACtC,0EAA0E;;IAU1E,wFAAwF;;aAQxF,CAAA;AACF,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,2BAA2B,CAAC,CAAA;AAErF,2FAA2F;AAC3F,eAAO,MAAM,mBAAmB;;QAxC9B,2FAA2F;;QAE3F,wEAAwE;;QAExE,iFAAiF;;QAEjF,sEAAsE;;;;QAYtE,0EAA0E;;QAU1E,wFAAwF;;;aAexF,CAAA;AACF,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,mBAAmB,CAAC,CAAA;AAErE,mFAAmF;AACnF,eAAO,MAAM,sBAAsB,EAAE,aAAgD,CAAA;AAErF,gFAAgF;AAChF,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,OAAO,GAAG,aAAa,CAE9D;AAED,4EAA4E;AAC5E,eAAO,MAAM,yBAAyB;;QAvDpC,2FAA2F;;QAE3F,wEAAwE;;QAExE,iFAAiF;;QAEjF,sEAAsE;;;;QAYtE,0EAA0E;;QAU1E,wFAAwF;;;aA2B9B,CAAA;AAC5D,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,yBAAyB,CAAC,CAAA"}
@@ -0,0 +1,60 @@
1
+ import * as v from 'valibot';
2
+ // ---------------------------------------------------------------------------
3
+ // Local-mode operational config, moved out of env vars into a single DB row (a
4
+ // per-DEPLOYMENT singleton — local mode is one developer's machine, so there is no
5
+ // per-account/per-workspace scoping). It is LOCAL-MODE-ONLY: the warm-container pool +
6
+ // per-repo checkout reuse are differentiators of the local facade's Docker/Podman/…
7
+ // runner, so this has NO Cloudflare/D1 mirror (the symmetry rule's runtime-specific
8
+ // carve-out). Surfaced through a dedicated local-mode settings panel rather than the
9
+ // account Deployment-settings panel, because local mode runs with the auth gate OPEN
10
+ // (no signed-in admin account to hang it on). There are no secrets here, so the read
11
+ // view is the plain config.
12
+ // ---------------------------------------------------------------------------
13
+ const nonNegInt = v.pipe(v.number(), v.integer(), v.minValue(0));
14
+ /**
15
+ * Warm-container-pool sizing (the local Docker-family runner). `size: 0` ⇒ pooling OFF —
16
+ * every run cold-starts its own container, the classic behaviour. `> 0` keeps that many
17
+ * idle harness containers warm and re-leases one (preferring repo affinity) to each run.
18
+ */
19
+ export const localPoolSettingsSchema = v.object({
20
+ /** Max idle warm containers kept for re-lease. 0 disables pooling (cold-start per run). */
21
+ size: v.optional(v.pipe(nonNegInt, v.maxValue(50)), 0),
22
+ /** Containers pre-warmed when the service starts (clamped to `max`). */
23
+ minWarm: v.optional(v.pipe(nonNegInt, v.maxValue(50)), 0),
24
+ /** Hard cap on total containers (leased + idle). `null` ⇒ defaults to `size`. */
25
+ max: v.optional(v.nullable(v.pipe(nonNegInt, v.maxValue(100))), null),
26
+ /** How long an idle pooled container is kept before eviction (ms). */
27
+ idleTtlMs: v.optional(nonNegInt, 600_000),
28
+ });
29
+ /**
30
+ * Per-repo checkout-reuse knobs, forwarded into the harness container as env. When the
31
+ * warm pool re-leases a container that already holds the run's repo, the harness reuses
32
+ * its `<workspaceRoot>/<owner>/<repo>` checkout (clean-sweep + fetch + switch branch)
33
+ * instead of cloning fresh; `cleanKeep` are the dep-cache dirs that sweep preserves.
34
+ */
35
+ export const localCheckoutSettingsSchema = v.object({
36
+ /** Absolute in-container dir the reused per-repo checkout lives under. */
37
+ workspaceRoot: v.optional(v.pipe(v.string(), v.trim(), v.minLength(1), v.regex(/^\//, 'workspaceRoot must be an absolute (POSIX) path, e.g. /workspace')), '/workspace'),
38
+ /** Dep-cache directories the per-run clean sweep keeps (so deps aren't reinstalled). */
39
+ cleanKeep: v.optional(v.array(v.pipe(v.string(), v.trim(), v.minLength(1))), [
40
+ 'node_modules',
41
+ '.venv',
42
+ 'target',
43
+ '.gradle',
44
+ '.pnpm-store',
45
+ ]),
46
+ });
47
+ /** The full local-mode settings blob. Every field defaults, so `{}` parses to defaults. */
48
+ export const localSettingsSchema = v.object({
49
+ pool: v.optional(localPoolSettingsSchema, {}),
50
+ checkout: v.optional(localCheckoutSettingsSchema, {}),
51
+ });
52
+ /** Built-in config used when no row exists yet (pooling off, harness defaults). */
53
+ export const DEFAULT_LOCAL_SETTINGS = v.parse(localSettingsSchema, {});
54
+ /** Parse + fully-default a (possibly partial / absent) stored settings blob. */
55
+ export function parseLocalSettings(raw) {
56
+ return v.parse(localSettingsSchema, raw ?? {});
57
+ }
58
+ /** Admin write: the full settings blob fully replaces the stored config. */
59
+ export const updateLocalSettingsSchema = localSettingsSchema;
60
+ //# sourceMappingURL=localSettings.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"localSettings.js","sourceRoot":"","sources":["../src/localSettings.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAE5B,8EAA8E;AAC9E,+EAA+E;AAC/E,mFAAmF;AACnF,uFAAuF;AACvF,oFAAoF;AACpF,oFAAoF;AACpF,qFAAqF;AACrF,qFAAqF;AACrF,qFAAqF;AACrF,4BAA4B;AAC5B,8EAA8E;AAE9E,MAAM,SAAS,GAAG,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,QAAQ,CAAC,CAA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CAAC,CAAC,EAAE;QAC3E,cAAc;QACd,OAAO;QACP,QAAQ;QACR,SAAS;QACT,aAAa;KACd,CAAC;CACH,CAAC,CAAA;AAGF,2FAA2F;AAC3F,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C,IAAI,EAAE,CAAC,CAAC,QAAQ,CAAC,uBAAuB,EAAE,EAAE,CAAC;IAC7C,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,2BAA2B,EAAE,EAAE,CAAC;CACtD,CAAC,CAAA;AAGF,mFAAmF;AACnF,MAAM,CAAC,MAAM,sBAAsB,GAAkB,CAAC,CAAC,KAAK,CAAC,mBAAmB,EAAE,EAAE,CAAC,CAAA;AAErF,gFAAgF;AAChF,MAAM,UAAU,kBAAkB,CAAC,GAAY;IAC7C,OAAO,CAAC,CAAC,KAAK,CAAC,mBAAmB,EAAE,GAAG,IAAI,EAAE,CAAC,CAAA;AAChD,CAAC;AAED,4EAA4E;AAC5E,MAAM,CAAC,MAAM,yBAAyB,GAAG,mBAAmB,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cat-factory/contracts",
3
- "version": "0.32.0",
3
+ "version": "0.33.0",
4
4
  "description": "Valibot wire contract shared between the Agent Architecture Board frontend and backend.",
5
5
  "repository": {
6
6
  "type": "git",