@cat-factory/contracts 0.6.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.
Files changed (166) hide show
  1. package/LICENSE +21 -0
  2. package/dist/accounts.d.ts +103 -0
  3. package/dist/accounts.d.ts.map +1 -0
  4. package/dist/accounts.js +102 -0
  5. package/dist/accounts.js.map +1 -0
  6. package/dist/agent-config.d.ts +77 -0
  7. package/dist/agent-config.d.ts.map +1 -0
  8. package/dist/agent-config.js +78 -0
  9. package/dist/agent-config.js.map +1 -0
  10. package/dist/api-keys.d.ts +44 -0
  11. package/dist/api-keys.d.ts.map +1 -0
  12. package/dist/api-keys.js +49 -0
  13. package/dist/api-keys.js.map +1 -0
  14. package/dist/auth.d.ts +24 -0
  15. package/dist/auth.d.ts.map +1 -0
  16. package/dist/auth.js +15 -0
  17. package/dist/auth.js.map +1 -0
  18. package/dist/board-scan.d.ts +89 -0
  19. package/dist/board-scan.d.ts.map +1 -0
  20. package/dist/board-scan.js +122 -0
  21. package/dist/board-scan.js.map +1 -0
  22. package/dist/bootstrap.d.ts +168 -0
  23. package/dist/bootstrap.d.ts.map +1 -0
  24. package/dist/bootstrap.js +148 -0
  25. package/dist/bootstrap.js.map +1 -0
  26. package/dist/clarity.d.ts +75 -0
  27. package/dist/clarity.d.ts.map +1 -0
  28. package/dist/clarity.js +66 -0
  29. package/dist/clarity.js.map +1 -0
  30. package/dist/companion.d.ts +32 -0
  31. package/dist/companion.d.ts.map +1 -0
  32. package/dist/companion.js +43 -0
  33. package/dist/companion.js.map +1 -0
  34. package/dist/consensus.d.ts +195 -0
  35. package/dist/consensus.d.ts.map +1 -0
  36. package/dist/consensus.js +164 -0
  37. package/dist/consensus.js.map +1 -0
  38. package/dist/documents.d.ts +197 -0
  39. package/dist/documents.d.ts.map +1 -0
  40. package/dist/documents.js +161 -0
  41. package/dist/documents.js.map +1 -0
  42. package/dist/entities.d.ts +1691 -0
  43. package/dist/entities.d.ts.map +1 -0
  44. package/dist/entities.js +853 -0
  45. package/dist/entities.js.map +1 -0
  46. package/dist/environments.d.ts +426 -0
  47. package/dist/environments.d.ts.map +1 -0
  48. package/dist/environments.js +190 -0
  49. package/dist/environments.js.map +1 -0
  50. package/dist/events.d.ts +98 -0
  51. package/dist/events.d.ts.map +1 -0
  52. package/dist/events.js +2 -0
  53. package/dist/events.js.map +1 -0
  54. package/dist/fragment-library.d.ts +123 -0
  55. package/dist/fragment-library.d.ts.map +1 -0
  56. package/dist/fragment-library.js +88 -0
  57. package/dist/fragment-library.js.map +1 -0
  58. package/dist/github.d.ts +215 -0
  59. package/dist/github.d.ts.map +1 -0
  60. package/dist/github.js +204 -0
  61. package/dist/github.js.map +1 -0
  62. package/dist/index.d.ts +41 -0
  63. package/dist/index.d.ts.map +1 -0
  64. package/dist/index.js +41 -0
  65. package/dist/index.js.map +1 -0
  66. package/dist/iteration-cap.d.ts +17 -0
  67. package/dist/iteration-cap.d.ts.map +1 -0
  68. package/dist/iteration-cap.js +25 -0
  69. package/dist/iteration-cap.js.map +1 -0
  70. package/dist/localModels.d.ts +54 -0
  71. package/dist/localModels.d.ts.map +1 -0
  72. package/dist/localModels.js +79 -0
  73. package/dist/localModels.js.map +1 -0
  74. package/dist/merge.d.ts +106 -0
  75. package/dist/merge.d.ts.map +1 -0
  76. package/dist/merge.js +129 -0
  77. package/dist/merge.js.map +1 -0
  78. package/dist/model-defaults.d.ts +23 -0
  79. package/dist/model-defaults.d.ts.map +1 -0
  80. package/dist/model-defaults.js +34 -0
  81. package/dist/model-defaults.js.map +1 -0
  82. package/dist/notifications.d.ts +136 -0
  83. package/dist/notifications.d.ts.map +1 -0
  84. package/dist/notifications.js +125 -0
  85. package/dist/notifications.js.map +1 -0
  86. package/dist/observability.d.ts +271 -0
  87. package/dist/observability.d.ts.map +1 -0
  88. package/dist/observability.js +152 -0
  89. package/dist/observability.js.map +1 -0
  90. package/dist/personal-subscriptions.d.ts +66 -0
  91. package/dist/personal-subscriptions.d.ts.map +1 -0
  92. package/dist/personal-subscriptions.js +70 -0
  93. package/dist/personal-subscriptions.js.map +1 -0
  94. package/dist/primitives.d.ts +57 -0
  95. package/dist/primitives.d.ts.map +1 -0
  96. package/dist/primitives.js +66 -0
  97. package/dist/primitives.js.map +1 -0
  98. package/dist/provisioning.d.ts +46 -0
  99. package/dist/provisioning.d.ts.map +1 -0
  100. package/dist/provisioning.js +107 -0
  101. package/dist/provisioning.js.map +1 -0
  102. package/dist/recurring.d.ts +117 -0
  103. package/dist/recurring.d.ts.map +1 -0
  104. package/dist/recurring.js +99 -0
  105. package/dist/recurring.js.map +1 -0
  106. package/dist/release.d.ts +60 -0
  107. package/dist/release.d.ts.map +1 -0
  108. package/dist/release.js +75 -0
  109. package/dist/release.js.map +1 -0
  110. package/dist/requests.d.ts +451 -0
  111. package/dist/requests.d.ts.map +1 -0
  112. package/dist/requests.js +231 -0
  113. package/dist/requests.js.map +1 -0
  114. package/dist/requirements.d.ts +127 -0
  115. package/dist/requirements.d.ts.map +1 -0
  116. package/dist/requirements.js +137 -0
  117. package/dist/requirements.js.map +1 -0
  118. package/dist/runners.d.ts +387 -0
  119. package/dist/runners.d.ts.map +1 -0
  120. package/dist/runners.js +117 -0
  121. package/dist/runners.js.map +1 -0
  122. package/dist/sandbox.d.ts +300 -0
  123. package/dist/sandbox.d.ts.map +1 -0
  124. package/dist/sandbox.js +243 -0
  125. package/dist/sandbox.js.map +1 -0
  126. package/dist/service-fragment-defaults.d.ts +16 -0
  127. package/dist/service-fragment-defaults.d.ts.map +1 -0
  128. package/dist/service-fragment-defaults.js +23 -0
  129. package/dist/service-fragment-defaults.js.map +1 -0
  130. package/dist/services.d.ts +81 -0
  131. package/dist/services.d.ts.map +1 -0
  132. package/dist/services.js +77 -0
  133. package/dist/services.js.map +1 -0
  134. package/dist/slack.d.ts +104 -0
  135. package/dist/slack.d.ts.map +1 -0
  136. package/dist/slack.js +98 -0
  137. package/dist/slack.js.map +1 -0
  138. package/dist/snapshot.d.ts +522 -0
  139. package/dist/snapshot.d.ts.map +1 -0
  140. package/dist/snapshot.js +104 -0
  141. package/dist/snapshot.js.map +1 -0
  142. package/dist/spec.d.ts +174 -0
  143. package/dist/spec.d.ts.map +1 -0
  144. package/dist/spec.js +173 -0
  145. package/dist/spec.js.map +1 -0
  146. package/dist/tasks.d.ts +150 -0
  147. package/dist/tasks.d.ts.map +1 -0
  148. package/dist/tasks.js +146 -0
  149. package/dist/tasks.js.map +1 -0
  150. package/dist/testing.d.ts +67 -0
  151. package/dist/testing.d.ts.map +1 -0
  152. package/dist/testing.js +64 -0
  153. package/dist/testing.js.map +1 -0
  154. package/dist/tracker.d.ts +18 -0
  155. package/dist/tracker.d.ts.map +1 -0
  156. package/dist/tracker.js +24 -0
  157. package/dist/tracker.js.map +1 -0
  158. package/dist/vendor-credentials.d.ts +37 -0
  159. package/dist/vendor-credentials.d.ts.map +1 -0
  160. package/dist/vendor-credentials.js +40 -0
  161. package/dist/vendor-credentials.js.map +1 -0
  162. package/dist/workspace-settings.d.ts +36 -0
  163. package/dist/workspace-settings.d.ts.map +1 -0
  164. package/dist/workspace-settings.js +41 -0
  165. package/dist/workspace-settings.js.map +1 -0
  166. package/package.json +31 -0
@@ -0,0 +1,89 @@
1
+ import * as v from 'valibot';
2
+ /** A cohesive area of the service (e.g. `auth`, `billing`). */
3
+ export declare const blueprintModuleSchema: v.ObjectSchema<{
4
+ /** Module name, typically the owning directory's domain (e.g. `Auth`). */
5
+ readonly name: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 120, undefined>]>;
6
+ /** One or two sentences on the module's responsibility. */
7
+ readonly summary: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 2000, undefined>]>, "">;
8
+ /** Repo-relative paths the module owns (its directories / key files). */
9
+ readonly references: v.OptionalSchema<v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 400, undefined>]>, undefined>, readonly []>;
10
+ }, undefined>;
11
+ export type BlueprintModule = v.InferOutput<typeof blueprintModuleSchema>;
12
+ /** The repository as a single top-level service frame with its modules. */
13
+ export declare const blueprintServiceSchema: v.ObjectSchema<{
14
+ /** Board frame type the repo presents as (service / api / frontend / …). */
15
+ readonly type: v.PicklistSchema<["frontend", "service", "api", "database", "queue", "integration", "external", "environment"], undefined>;
16
+ /** Human name for the service (defaults to the repo name). */
17
+ readonly name: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 120, undefined>]>;
18
+ /** One or two sentences describing the service overall. */
19
+ readonly summary: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 2000, undefined>]>, "">;
20
+ /** Repo-relative entrypoints / root files (e.g. `package.json`, `src/index.ts`). */
21
+ readonly references: v.OptionalSchema<v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 400, undefined>]>, undefined>, readonly []>;
22
+ readonly modules: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
23
+ /** Module name, typically the owning directory's domain (e.g. `Auth`). */
24
+ readonly name: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 120, undefined>]>;
25
+ /** One or two sentences on the module's responsibility. */
26
+ readonly summary: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 2000, undefined>]>, "">;
27
+ /** Repo-relative paths the module owns (its directories / key files). */
28
+ readonly references: v.OptionalSchema<v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 400, undefined>]>, undefined>, readonly []>;
29
+ }, undefined>, undefined>, readonly []>;
30
+ }, undefined>;
31
+ export type BlueprintService = v.InferOutput<typeof blueprintServiceSchema>;
32
+ /** How a blueprint was produced: an LLM scan, or the deterministic tree heuristic. */
33
+ export declare const blueprintSourceSchema: v.PicklistSchema<["llm", "heuristic"], undefined>;
34
+ export type BlueprintSource = v.InferOutput<typeof blueprintSourceSchema>;
35
+ /**
36
+ * Counts of board blocks touched when the `blueprints` pipeline step materialises
37
+ * (or reconciles) a decomposition onto the board: the service frame and its modules.
38
+ */
39
+ export declare const boardScanSpawnResultSchema: v.ObjectSchema<{
40
+ /** Id of the service frame the blueprint was reconciled onto / spawned as. */
41
+ readonly frameId: v.StringSchema<undefined>;
42
+ readonly modules: v.NumberSchema<undefined>;
43
+ }, undefined>;
44
+ export type BoardScanSpawnResult = v.InferOutput<typeof boardScanSpawnResultSchema>;
45
+ /** Folder, relative to the repo root, that holds the persisted blueprint. */
46
+ export declare const BLUEPRINT_DIR = "blueprints";
47
+ /** Canonical machine-readable blueprint file (the BlueprintService tree). */
48
+ export declare const BLUEPRINT_JSON_PATH = "blueprints/blueprint.json";
49
+ /** High-level overview markdown — the file agents read first. */
50
+ export declare const BLUEPRINT_OVERVIEW_PATH = "blueprints/overview.md";
51
+ /** Sub-folder holding one deep-dive markdown per module. */
52
+ export declare const BLUEPRINT_MODULES_DIR = "blueprints/modules";
53
+ /** Tiny manifest read for quick staleness checks without parsing the full tree. */
54
+ export declare const BLUEPRINT_VERSION_PATH = "blueprints/version.json";
55
+ /**
56
+ * The lightweight `version.json` manifest committed alongside the blueprint. It
57
+ * carries a monotonic version counter, the generation timestamp, and a content
58
+ * hash of the canonical tree, so staleness checks are a tiny read rather than a
59
+ * full parse of `blueprint.json`.
60
+ */
61
+ export declare const blueprintVersionSchema: v.ObjectSchema<{
62
+ readonly version: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
63
+ readonly generatedAt: v.StringSchema<undefined>;
64
+ /** sha256 (hex) of the canonical `blueprint.json` bytes. */
65
+ readonly hash: v.StringSchema<undefined>;
66
+ readonly modules: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.IntegerAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
67
+ }, undefined>;
68
+ export type BlueprintVersion = v.InferOutput<typeof blueprintVersionSchema>;
69
+ /**
70
+ * Strictly parse an arbitrary value (e.g. the JSON read from `blueprint.json`, or
71
+ * a tree returned by the Blueprinter container) into a {@link BlueprintService},
72
+ * enforcing the exact schema shape. Unlike the harness's lenient coercion (which
73
+ * silently drops malformed nodes), this **throws** on any shape violation, so a
74
+ * bad payload can never be materialised onto the board. Use it at every trust
75
+ * boundary that ingests a blueprint.
76
+ */
77
+ export declare function parseBlueprintService(value: unknown): BlueprintService;
78
+ /** Non-throwing variant: returns the parsed service or `undefined` when invalid. */
79
+ export declare function safeParseBlueprintService(value: unknown): BlueprintService | undefined;
80
+ /**
81
+ * Render a {@link BlueprintService} as readable markdown for HUMAN + COMPANION
82
+ * review — the descriptive counterpart of {@link renderSpecForReview}. A Blueprinter
83
+ * is a container agent whose reviewable work product is the decomposition tree, not
84
+ * its raw Pi transcript summary, so any companion grading it (today or in future)
85
+ * must see the tree itself: the service, its entrypoints, and each module with its
86
+ * responsibility and owned paths. Deterministic and dependency-free.
87
+ */
88
+ export declare function renderBlueprintForReview(service: BlueprintService): string;
89
+ //# sourceMappingURL=board-scan.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"board-scan.d.ts","sourceRoot":"","sources":["../src/board-scan.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAyB5B,+DAA+D;AAC/D,eAAO,MAAM,qBAAqB;IAChC,0EAA0E;;IAE1E,2DAA2D;;IAE3D,yEAAyE;;aAEzE,CAAA;AACF,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,WAAW,CAAC,O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AAC,OAAO,EAAE,gBAAgB,GAAG,MAAM,CAU1E"}
@@ -0,0 +1,122 @@
1
+ import * as v from 'valibot';
2
+ import { blockTypeSchema } from './primitives.js';
3
+ // ---------------------------------------------------------------------------
4
+ // Service-blueprint wire contracts. The `blueprints` pipeline step decomposes a
5
+ // repository into one canonical board structure — a single service and the modules
6
+ // inside it — anchored to the codebase by explicit file/directory references on
7
+ // every node. The agent commits the decomposition into the repo (`blueprints/`)
8
+ // and returns the tree, which the engine reconciles onto the run's service frame.
9
+ //
10
+ // The shape is deliberately shallow and uniform (service → modules), mirroring the
11
+ // board's frame → module levels, so a blueprint reconciles directly onto the board
12
+ // and reads the same way an LLM would navigate the code. Individual tasks are
13
+ // authored by people, not derived from the map.
14
+ // ---------------------------------------------------------------------------
15
+ const nameField = v.pipe(v.string(), v.trim(), v.minLength(1), v.maxLength(120));
16
+ const summaryField = v.pipe(v.string(), v.maxLength(2000));
17
+ /** A single codebase reference: a repo-relative file or directory path. */
18
+ const referenceField = v.pipe(v.string(), v.trim(), v.minLength(1), v.maxLength(400));
19
+ /** The file/directory paths a node maps to — what to read to work on it. */
20
+ const referencesField = v.array(referenceField);
21
+ // ---- Blueprint tree (service → modules) -----------------------------------
22
+ /** A cohesive area of the service (e.g. `auth`, `billing`). */
23
+ export const blueprintModuleSchema = v.object({
24
+ /** Module name, typically the owning directory's domain (e.g. `Auth`). */
25
+ name: nameField,
26
+ /** One or two sentences on the module's responsibility. */
27
+ summary: v.optional(summaryField, ''),
28
+ /** Repo-relative paths the module owns (its directories / key files). */
29
+ references: v.optional(referencesField, []),
30
+ });
31
+ /** The repository as a single top-level service frame with its modules. */
32
+ export const blueprintServiceSchema = v.object({
33
+ /** Board frame type the repo presents as (service / api / frontend / …). */
34
+ type: blockTypeSchema,
35
+ /** Human name for the service (defaults to the repo name). */
36
+ name: nameField,
37
+ /** One or two sentences describing the service overall. */
38
+ summary: v.optional(summaryField, ''),
39
+ /** Repo-relative entrypoints / root files (e.g. `package.json`, `src/index.ts`). */
40
+ references: v.optional(referencesField, []),
41
+ modules: v.optional(v.array(blueprintModuleSchema), []),
42
+ });
43
+ /** How a blueprint was produced: an LLM scan, or the deterministic tree heuristic. */
44
+ export const blueprintSourceSchema = v.picklist(['llm', 'heuristic']);
45
+ /**
46
+ * Counts of board blocks touched when the `blueprints` pipeline step materialises
47
+ * (or reconciles) a decomposition onto the board: the service frame and its modules.
48
+ */
49
+ export const boardScanSpawnResultSchema = v.object({
50
+ /** Id of the service frame the blueprint was reconciled onto / spawned as. */
51
+ frameId: v.string(),
52
+ modules: v.number(),
53
+ });
54
+ // ---- In-repo blueprint artifact -------------------------------------------
55
+ // The Blueprinter agent persists the decomposition in the repository itself,
56
+ // under a dedicated folder, so it travels with the code and every agent can read
57
+ // it. The canonical, machine-readable file is `blueprint.json` (a BlueprintService
58
+ // tree); the markdown files are deterministic, human/agent-friendly renderings of
59
+ // the same tree (high-level overview + per-module deep dives).
60
+ /** Folder, relative to the repo root, that holds the persisted blueprint. */
61
+ export const BLUEPRINT_DIR = 'blueprints';
62
+ /** Canonical machine-readable blueprint file (the BlueprintService tree). */
63
+ export const BLUEPRINT_JSON_PATH = `${BLUEPRINT_DIR}/blueprint.json`;
64
+ /** High-level overview markdown — the file agents read first. */
65
+ export const BLUEPRINT_OVERVIEW_PATH = `${BLUEPRINT_DIR}/overview.md`;
66
+ /** Sub-folder holding one deep-dive markdown per module. */
67
+ export const BLUEPRINT_MODULES_DIR = `${BLUEPRINT_DIR}/modules`;
68
+ /** Tiny manifest read for quick staleness checks without parsing the full tree. */
69
+ export const BLUEPRINT_VERSION_PATH = `${BLUEPRINT_DIR}/version.json`;
70
+ /**
71
+ * The lightweight `version.json` manifest committed alongside the blueprint. It
72
+ * carries a monotonic version counter, the generation timestamp, and a content
73
+ * hash of the canonical tree, so staleness checks are a tiny read rather than a
74
+ * full parse of `blueprint.json`.
75
+ */
76
+ export const blueprintVersionSchema = v.object({
77
+ version: v.pipe(v.number(), v.integer(), v.minValue(0)),
78
+ generatedAt: v.string(),
79
+ /** sha256 (hex) of the canonical `blueprint.json` bytes. */
80
+ hash: v.string(),
81
+ modules: v.pipe(v.number(), v.integer(), v.minValue(0)),
82
+ });
83
+ /**
84
+ * Strictly parse an arbitrary value (e.g. the JSON read from `blueprint.json`, or
85
+ * a tree returned by the Blueprinter container) into a {@link BlueprintService},
86
+ * enforcing the exact schema shape. Unlike the harness's lenient coercion (which
87
+ * silently drops malformed nodes), this **throws** on any shape violation, so a
88
+ * bad payload can never be materialised onto the board. Use it at every trust
89
+ * boundary that ingests a blueprint.
90
+ */
91
+ export function parseBlueprintService(value) {
92
+ return v.parse(blueprintServiceSchema, value);
93
+ }
94
+ /** Non-throwing variant: returns the parsed service or `undefined` when invalid. */
95
+ export function safeParseBlueprintService(value) {
96
+ const result = v.safeParse(blueprintServiceSchema, value);
97
+ return result.success ? result.output : undefined;
98
+ }
99
+ /**
100
+ * Render a {@link BlueprintService} as readable markdown for HUMAN + COMPANION
101
+ * review — the descriptive counterpart of {@link renderSpecForReview}. A Blueprinter
102
+ * is a container agent whose reviewable work product is the decomposition tree, not
103
+ * its raw Pi transcript summary, so any companion grading it (today or in future)
104
+ * must see the tree itself: the service, its entrypoints, and each module with its
105
+ * responsibility and owned paths. Deterministic and dependency-free.
106
+ */
107
+ export function renderBlueprintForReview(service) {
108
+ const lines = [`# Service: ${service.name} (${service.type})`];
109
+ if (service.summary)
110
+ lines.push('', service.summary);
111
+ if (service.references?.length)
112
+ lines.push('', `Entrypoints: ${service.references.join(', ')}`);
113
+ for (const mod of service.modules ?? []) {
114
+ lines.push('', `## Module: ${mod.name}`);
115
+ if (mod.summary)
116
+ lines.push('', mod.summary);
117
+ if (mod.references?.length)
118
+ lines.push('', `Paths: ${mod.references.join(', ')}`);
119
+ }
120
+ return lines.join('\n');
121
+ }
122
+ //# sourceMappingURL=board-scan.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"board-scan.js","sourceRoot":"","sources":["../src/board-scan.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CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IAC/F,KAAK,MAAM,GAAG,IAAI,OAAO,CAAC,OAAO,IAAI,EAAE,EAAE,CAAC;QACxC,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,cAAc,GAAG,CAAC,IAAI,EAAE,CAAC,CAAA;QACxC,IAAI,GAAG,CAAC,OAAO;YAAE,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,GAAG,CAAC,OAAO,CAAC,CAAA;QAC5C,IAAI,GAAG,CAAC,UAAU,EAAE,MAAM;YAAE,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,UAAU,GAAG,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IACnF,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACzB,CAAC"}
@@ -0,0 +1,168 @@
1
+ import * as v from 'valibot';
2
+ /** A managed base repository new repos are bootstrapped from. */
3
+ export declare const referenceArchitectureSchema: v.ObjectSchema<{
4
+ readonly id: v.StringSchema<undefined>;
5
+ readonly workspaceId: v.StringSchema<undefined>;
6
+ readonly name: v.StringSchema<undefined>;
7
+ readonly description: v.StringSchema<undefined>;
8
+ /** GitHub owner of the base repo (e.g. `acme`). */
9
+ readonly repoOwner: v.StringSchema<undefined>;
10
+ /** GitHub name of the base repo (e.g. `service-template`). */
11
+ readonly repoName: v.StringSchema<undefined>;
12
+ /** Default bootstrapper instructions, prepended to any per-run instructions. */
13
+ readonly defaultInstructions: v.StringSchema<undefined>;
14
+ readonly createdAt: v.NumberSchema<undefined>;
15
+ readonly updatedAt: v.NumberSchema<undefined>;
16
+ }, undefined>;
17
+ export type ReferenceArchitecture = v.InferOutput<typeof referenceArchitectureSchema>;
18
+ /** Register a new reference architecture. */
19
+ export declare const createReferenceArchitectureSchema: v.ObjectSchema<{
20
+ readonly name: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 120, undefined>]>;
21
+ readonly description: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 2000, undefined>]>, "">;
22
+ readonly repoOwner: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.RegexAction<string, "Only letters, digits, '.', '_' and '-' are allowed">, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 100, undefined>]>;
23
+ readonly repoName: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.RegexAction<string, "Only letters, digits, '.', '_' and '-' are allowed">, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 100, undefined>]>;
24
+ readonly defaultInstructions: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 8000, undefined>]>, "">;
25
+ }, undefined>;
26
+ export type CreateReferenceArchitectureInput = v.InferOutput<typeof createReferenceArchitectureSchema>;
27
+ /** Patch an existing reference architecture (only the supplied fields change). */
28
+ export declare const updateReferenceArchitectureSchema: v.ObjectSchema<{
29
+ readonly name: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 120, undefined>]>, undefined>;
30
+ readonly description: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 2000, undefined>]>, undefined>;
31
+ readonly repoOwner: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.RegexAction<string, "Only letters, digits, '.', '_' and '-' are allowed">, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 100, undefined>]>, undefined>;
32
+ readonly repoName: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.RegexAction<string, "Only letters, digits, '.', '_' and '-' are allowed">, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 100, undefined>]>, undefined>;
33
+ readonly defaultInstructions: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 8000, undefined>]>, undefined>;
34
+ }, undefined>;
35
+ export type UpdateReferenceArchitectureInput = v.InferOutput<typeof updateReferenceArchitectureSchema>;
36
+ /** Lifecycle of a single "bootstrap repo" run. */
37
+ export declare const bootstrapStatusSchema: v.PicklistSchema<["pending", "running", "succeeded", "failed"], undefined>;
38
+ export type BootstrapStatus = v.InferOutput<typeof bootstrapStatusSchema>;
39
+ /**
40
+ * How a bootstrap run faulted, so the board can classify the failure (and decide
41
+ * whether a retry is likely to help):
42
+ * - `preflight` — rejected before dispatch (repo missing/not empty, not connected).
43
+ * - `dispatch` — the container accepted-request itself failed (HTTP / network).
44
+ * - `evicted` — the container vanished mid-run (eviction/crash): its in-memory
45
+ * job was gone on the next poll. Retrying spins a fresh container.
46
+ * - `timeout` — a container watchdog fired (inactivity or max-duration).
47
+ * - `agent` — the bootstrapper agent / git push reported a failure.
48
+ * - `cancelled` — the user (or an orphan sweep) explicitly stopped the run.
49
+ * - `unknown` — anything not otherwise classified.
50
+ */
51
+ export declare const bootstrapFailureKindSchema: v.PicklistSchema<["preflight", "dispatch", "evicted", "timeout", "agent", "cancelled", "unknown"], undefined>;
52
+ export type BootstrapFailureKind = v.InferOutput<typeof bootstrapFailureKindSchema>;
53
+ /**
54
+ * Structured diagnostics captured when a bootstrap run fails. This is now the
55
+ * shared {@link agentFailureSchema} (the same shape execution runs use), so the
56
+ * board renders one failure banner + retry for any agent. `bootstrapFailureKind`
57
+ * stays a narrow alias documenting the subset a bootstrap run actually produces.
58
+ */
59
+ export declare const bootstrapFailureSchema: v.ObjectSchema<{
60
+ readonly kind: v.PicklistSchema<["preflight", "dispatch", "evicted", "timeout", "agent", "job_failed", "rejected", "companion_rejected", "cancelled", "unknown"], undefined>;
61
+ readonly message: v.StringSchema<undefined>;
62
+ readonly detail: v.NullableSchema<v.StringSchema<undefined>, undefined>;
63
+ readonly hint: v.NullableSchema<v.StringSchema<undefined>, undefined>;
64
+ readonly occurredAt: v.NumberSchema<undefined>;
65
+ readonly lastSubtasks: v.NullableSchema<v.ObjectSchema<{
66
+ readonly completed: v.NumberSchema<undefined>;
67
+ readonly inProgress: v.NumberSchema<undefined>;
68
+ readonly total: v.NumberSchema<undefined>;
69
+ readonly items: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
70
+ readonly label: v.StringSchema<undefined>;
71
+ readonly status: v.PicklistSchema<["pending", "in_progress", "completed"], undefined>;
72
+ }, undefined>, undefined>, undefined>;
73
+ }, undefined>, undefined>;
74
+ }, undefined>;
75
+ export type BootstrapFailure = v.InferOutput<typeof bootstrapFailureSchema>;
76
+ /** One "bootstrap repo" run, with its outcome. */
77
+ export declare const bootstrapJobSchema: v.ObjectSchema<{
78
+ readonly id: v.StringSchema<undefined>;
79
+ readonly workspaceId: v.StringSchema<undefined>;
80
+ /** Reference architecture the run was based on, or null for a from-scratch (freeform) run. */
81
+ readonly referenceArchitectureId: v.NullableSchema<v.StringSchema<undefined>, undefined>;
82
+ /** Denormalized at creation so the job is self-describing even if the base is later removed; null for from-scratch runs. */
83
+ readonly referenceArchitectureName: v.NullableSchema<v.StringSchema<undefined>, undefined>;
84
+ /** Name of the new repository being created. */
85
+ readonly repoName: v.StringSchema<undefined>;
86
+ /** Owner the new repo was created under (resolved at run time), or null until known. */
87
+ readonly repoOwner: v.NullableSchema<v.StringSchema<undefined>, undefined>;
88
+ /** Web URL of the created repository, or null until/unless it succeeds. */
89
+ readonly repoUrl: v.NullableSchema<v.StringSchema<undefined>, undefined>;
90
+ /** Effective bootstrapper instructions (defaults + per-run), for transparency. */
91
+ readonly instructions: v.StringSchema<undefined>;
92
+ readonly status: v.PicklistSchema<["pending", "running", "succeeded", "failed"], undefined>;
93
+ /**
94
+ * The board service frame this run materialises. Created up front (in
95
+ * `running` state) so the bootstrap shows on the board immediately as a
96
+ * provisional "bootstrapping…" card; on success the frame is linked to the new
97
+ * repo and becomes a normal, droppable service. Null only if frame creation
98
+ * was skipped (e.g. an older job recorded before this field existed).
99
+ */
100
+ readonly blockId: v.NullableSchema<v.StringSchema<undefined>, undefined>;
101
+ /**
102
+ * Live subtask counts from the bootstrapper agent's todo list while the
103
+ * container runs, so the board can render an "N/M done" progress bar
104
+ * identically to a pipeline step. Null until the agent first reports.
105
+ */
106
+ readonly subtasks: v.NullableSchema<v.ObjectSchema<{
107
+ readonly completed: v.NumberSchema<undefined>;
108
+ readonly inProgress: v.NumberSchema<undefined>;
109
+ readonly total: v.NumberSchema<undefined>;
110
+ readonly items: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
111
+ readonly label: v.StringSchema<undefined>;
112
+ readonly status: v.PicklistSchema<["pending", "in_progress", "completed"], undefined>;
113
+ }, undefined>, undefined>, undefined>;
114
+ }, undefined>, undefined>;
115
+ /** Failure reason when `status` is `failed` (one-line; see `failure` for detail). */
116
+ readonly error: v.NullableSchema<v.StringSchema<undefined>, undefined>;
117
+ /** Structured failure diagnostics when `status` is `failed`; null otherwise. */
118
+ readonly failure: v.NullableSchema<v.ObjectSchema<{
119
+ readonly kind: v.PicklistSchema<["preflight", "dispatch", "evicted", "timeout", "agent", "job_failed", "rejected", "companion_rejected", "cancelled", "unknown"], undefined>;
120
+ readonly message: v.StringSchema<undefined>;
121
+ readonly detail: v.NullableSchema<v.StringSchema<undefined>, undefined>;
122
+ readonly hint: v.NullableSchema<v.StringSchema<undefined>, undefined>;
123
+ readonly occurredAt: v.NumberSchema<undefined>;
124
+ readonly lastSubtasks: v.NullableSchema<v.ObjectSchema<{
125
+ readonly completed: v.NumberSchema<undefined>;
126
+ readonly inProgress: v.NumberSchema<undefined>;
127
+ readonly total: v.NumberSchema<undefined>;
128
+ readonly items: v.OptionalSchema<v.ArraySchema<v.ObjectSchema<{
129
+ readonly label: v.StringSchema<undefined>;
130
+ readonly status: v.PicklistSchema<["pending", "in_progress", "completed"], undefined>;
131
+ }, undefined>, undefined>, undefined>;
132
+ }, undefined>, undefined>;
133
+ }, undefined>, undefined>;
134
+ readonly createdAt: v.NumberSchema<undefined>;
135
+ readonly updatedAt: v.NumberSchema<undefined>;
136
+ }, undefined>;
137
+ export type BootstrapJob = v.InferOutput<typeof bootstrapJobSchema>;
138
+ /**
139
+ * Kick off a "bootstrap repo" run. Two modes are supported:
140
+ * - from a reference architecture: supply `referenceArchitectureId` (its base
141
+ * repo is cloned and adapted), optionally with extra `instructions`.
142
+ * - from scratch: omit `referenceArchitectureId` and describe the new service
143
+ * entirely in `instructions` (the bootstrapper scaffolds an empty repo).
144
+ * Either a reference architecture or non-empty instructions must be provided.
145
+ */
146
+ export declare const bootstrapRepoSchema: v.SchemaWithPipe<readonly [v.ObjectSchema<{
147
+ /** Reference architecture to clone from; omit to bootstrap from a freeform prompt. */
148
+ readonly referenceArchitectureId: v.OptionalSchema<v.NullableSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MinLengthAction<string, 1, undefined>]>, undefined>, undefined>;
149
+ /** Name for the new repository. */
150
+ readonly repoName: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.TrimAction, v.RegexAction<string, "Only letters, digits, '.', '_' and '-' are allowed">, v.MinLengthAction<string, 1, undefined>, v.MaxLengthAction<string, 100, undefined>]>;
151
+ /** Description applied to the new repository. */
152
+ readonly description: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 2000, undefined>]>, "">;
153
+ /** Whether the new repository is private (defaults to private). */
154
+ readonly private: v.OptionalSchema<v.BooleanSchema<undefined>, true>;
155
+ /**
156
+ * Instructions for the bootstrapper agent. With a reference architecture these
157
+ * are appended to its defaults; with no reference they are the whole brief.
158
+ */
159
+ readonly instructions: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.MaxLengthAction<string, 8000, undefined>]>, "">;
160
+ }, undefined>, v.CheckAction<{
161
+ referenceArchitectureId?: string | null | undefined;
162
+ repoName: string;
163
+ description: string;
164
+ private: boolean;
165
+ instructions: string;
166
+ }, "Provide a reference architecture or freeform instructions to bootstrap from.">]>;
167
+ export type BootstrapRepoInput = v.InferOutput<typeof bootstrapRepoSchema>;
168
+ //# sourceMappingURL=bootstrap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bootstrap.d.ts","sourceRoot":"","sources":["../src/bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAkC5B,iEAAiE;AACjE,eAAO,MAAM,2BAA2B;;;;;IAKtC,mDAAmD;;IAEnD,8DAA8D;;IAE9D,gFAAgF;;;;aAIhF,CAAA;AACF,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,2BAA2B,CAAC,CAAA;AAErF,6CAA6C;AAC7C,eAAO,MAAM,iCAAiC;;;;;;aAM5C,CAAA;AACF,MAAM,MAAM,gCAAgC,GAAG,CAAC,CAAC,WAAW,CAC1D,OAAO,iCAAiC,CACzC,CAAA;AAED,kFAAkF;AAClF,eAAO,MAAM,iCAAiC;;;;;;aAM5C,CAAA;AACF,MAAM,MAAM,gCAAgC,GAAG,CAAC,CAAC,WAAW,CAC1D,OAAO,iCAAiC,CACzC,CAAA;AAID,kDAAkD;AAClD,eAAO,MAAM,qBAAqB,4EAA4D,CAAA;AAC9F,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,qBAAqB,CAAC,CAAA;AAEzE;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,0BAA0B,+GAQrC,CAAA;AACF,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,0BAA0B,CAAC,CAAA;AAEnF;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;aAAqB,CAAA;AACxD,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,sBAAsB,CAAC,CAAA;AAE3E,kDAAkD;AAClD,eAAO,MAAM,kBAAkB;;;IAG7B,8FAA8F;;IAE9F,4HAA4H;;IAE5H,gDAAgD;;IAEhD,wFAAwF;;IAExF,2EAA2E;;IAE3E,kFAAkF;;;IAGlF;;;;;;OAMG;;IAEH;;;;OAIG;;;;;;;;;;IAEH,qFAAqF;;IAErF,gFAAgF;;;;;;;;;;;;;;;;;;;aAIhF,CAAA;AACF,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,kBAAkB,CAAC,CAAA;AAEnE;;;;;;;GAOG;AACH,eAAO,MAAM,mBAAmB;IAE5B,sFAAsF;;IAEtF,mCAAmC;;IAEnC,iDAAiD;;IAEjD,mEAAmE;;IAEnE;;;OAGG;;;;;;;;oFAON,CAAA;AACD,MAAM,MAAM,kBAAkB,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,mBAAmB,CAAC,CAAA"}
@@ -0,0 +1,148 @@
1
+ import * as v from 'valibot';
2
+ import { agentFailureSchema, stepSubtasksSchema } from './entities.js';
3
+ // ---------------------------------------------------------------------------
4
+ // Repo-bootstrap wire contracts. A "reference architecture" is a named base repo
5
+ // (an opinionated starter / golden template an org wants new services to follow)
6
+ // that the platform clones to spin up a brand-new repository. The bootstrap task
7
+ // creates that new repo from the chosen reference architecture and runs a
8
+ // bootstrapper agent inside a sandbox container to adapt it per free-form
9
+ // instructions (rename packages, prune unused pieces, wire in the new domain…).
10
+ //
11
+ // Two managed resources live here:
12
+ // - reference architectures: a workspace-scoped, CRUD-managed list of bases.
13
+ // - bootstrap jobs: one record per "bootstrap repo" run, tracking its outcome.
14
+ // ---------------------------------------------------------------------------
15
+ const nameField = v.pipe(v.string(), v.trim(), v.minLength(1), v.maxLength(120));
16
+ /**
17
+ * A single GitHub owner OR repository segment (the `owner` or the `name` in
18
+ * `owner/name`), validated on its own — never the combined `owner/name`, so a
19
+ * slash is not allowed. The message reflects exactly what the regex accepts.
20
+ */
21
+ const slugField = v.pipe(v.string(), v.trim(), v.regex(/^[A-Za-z0-9_.-]+$/, "Only letters, digits, '.', '_' and '-' are allowed"), v.minLength(1), v.maxLength(100));
22
+ const descriptionField = v.pipe(v.string(), v.maxLength(2000));
23
+ const instructionsField = v.pipe(v.string(), v.maxLength(8000));
24
+ // ---- Reference architectures ----------------------------------------------
25
+ /** A managed base repository new repos are bootstrapped from. */
26
+ export const referenceArchitectureSchema = v.object({
27
+ id: v.string(),
28
+ workspaceId: v.string(),
29
+ name: v.string(),
30
+ description: v.string(),
31
+ /** GitHub owner of the base repo (e.g. `acme`). */
32
+ repoOwner: v.string(),
33
+ /** GitHub name of the base repo (e.g. `service-template`). */
34
+ repoName: v.string(),
35
+ /** Default bootstrapper instructions, prepended to any per-run instructions. */
36
+ defaultInstructions: v.string(),
37
+ createdAt: v.number(),
38
+ updatedAt: v.number(),
39
+ });
40
+ /** Register a new reference architecture. */
41
+ export const createReferenceArchitectureSchema = v.object({
42
+ name: nameField,
43
+ description: v.optional(descriptionField, ''),
44
+ repoOwner: slugField,
45
+ repoName: slugField,
46
+ defaultInstructions: v.optional(instructionsField, ''),
47
+ });
48
+ /** Patch an existing reference architecture (only the supplied fields change). */
49
+ export const updateReferenceArchitectureSchema = v.object({
50
+ name: v.optional(nameField),
51
+ description: v.optional(descriptionField),
52
+ repoOwner: v.optional(slugField),
53
+ repoName: v.optional(slugField),
54
+ defaultInstructions: v.optional(instructionsField),
55
+ });
56
+ // ---- Bootstrap jobs --------------------------------------------------------
57
+ /** Lifecycle of a single "bootstrap repo" run. */
58
+ export const bootstrapStatusSchema = v.picklist(['pending', 'running', 'succeeded', 'failed']);
59
+ /**
60
+ * How a bootstrap run faulted, so the board can classify the failure (and decide
61
+ * whether a retry is likely to help):
62
+ * - `preflight` — rejected before dispatch (repo missing/not empty, not connected).
63
+ * - `dispatch` — the container accepted-request itself failed (HTTP / network).
64
+ * - `evicted` — the container vanished mid-run (eviction/crash): its in-memory
65
+ * job was gone on the next poll. Retrying spins a fresh container.
66
+ * - `timeout` — a container watchdog fired (inactivity or max-duration).
67
+ * - `agent` — the bootstrapper agent / git push reported a failure.
68
+ * - `cancelled` — the user (or an orphan sweep) explicitly stopped the run.
69
+ * - `unknown` — anything not otherwise classified.
70
+ */
71
+ export const bootstrapFailureKindSchema = v.picklist([
72
+ 'preflight',
73
+ 'dispatch',
74
+ 'evicted',
75
+ 'timeout',
76
+ 'agent',
77
+ 'cancelled',
78
+ 'unknown',
79
+ ]);
80
+ /**
81
+ * Structured diagnostics captured when a bootstrap run fails. This is now the
82
+ * shared {@link agentFailureSchema} (the same shape execution runs use), so the
83
+ * board renders one failure banner + retry for any agent. `bootstrapFailureKind`
84
+ * stays a narrow alias documenting the subset a bootstrap run actually produces.
85
+ */
86
+ export const bootstrapFailureSchema = agentFailureSchema;
87
+ /** One "bootstrap repo" run, with its outcome. */
88
+ export const bootstrapJobSchema = v.object({
89
+ id: v.string(),
90
+ workspaceId: v.string(),
91
+ /** Reference architecture the run was based on, or null for a from-scratch (freeform) run. */
92
+ referenceArchitectureId: v.nullable(v.string()),
93
+ /** Denormalized at creation so the job is self-describing even if the base is later removed; null for from-scratch runs. */
94
+ referenceArchitectureName: v.nullable(v.string()),
95
+ /** Name of the new repository being created. */
96
+ repoName: v.string(),
97
+ /** Owner the new repo was created under (resolved at run time), or null until known. */
98
+ repoOwner: v.nullable(v.string()),
99
+ /** Web URL of the created repository, or null until/unless it succeeds. */
100
+ repoUrl: v.nullable(v.string()),
101
+ /** Effective bootstrapper instructions (defaults + per-run), for transparency. */
102
+ instructions: v.string(),
103
+ status: bootstrapStatusSchema,
104
+ /**
105
+ * The board service frame this run materialises. Created up front (in
106
+ * `running` state) so the bootstrap shows on the board immediately as a
107
+ * provisional "bootstrapping…" card; on success the frame is linked to the new
108
+ * repo and becomes a normal, droppable service. Null only if frame creation
109
+ * was skipped (e.g. an older job recorded before this field existed).
110
+ */
111
+ blockId: v.nullable(v.string()),
112
+ /**
113
+ * Live subtask counts from the bootstrapper agent's todo list while the
114
+ * container runs, so the board can render an "N/M done" progress bar
115
+ * identically to a pipeline step. Null until the agent first reports.
116
+ */
117
+ subtasks: v.nullable(stepSubtasksSchema),
118
+ /** Failure reason when `status` is `failed` (one-line; see `failure` for detail). */
119
+ error: v.nullable(v.string()),
120
+ /** Structured failure diagnostics when `status` is `failed`; null otherwise. */
121
+ failure: v.nullable(bootstrapFailureSchema),
122
+ createdAt: v.number(),
123
+ updatedAt: v.number(),
124
+ });
125
+ /**
126
+ * Kick off a "bootstrap repo" run. Two modes are supported:
127
+ * - from a reference architecture: supply `referenceArchitectureId` (its base
128
+ * repo is cloned and adapted), optionally with extra `instructions`.
129
+ * - from scratch: omit `referenceArchitectureId` and describe the new service
130
+ * entirely in `instructions` (the bootstrapper scaffolds an empty repo).
131
+ * Either a reference architecture or non-empty instructions must be provided.
132
+ */
133
+ export const bootstrapRepoSchema = v.pipe(v.object({
134
+ /** Reference architecture to clone from; omit to bootstrap from a freeform prompt. */
135
+ referenceArchitectureId: v.optional(v.nullable(v.pipe(v.string(), v.minLength(1)))),
136
+ /** Name for the new repository. */
137
+ repoName: slugField,
138
+ /** Description applied to the new repository. */
139
+ description: v.optional(descriptionField, ''),
140
+ /** Whether the new repository is private (defaults to private). */
141
+ private: v.optional(v.boolean(), true),
142
+ /**
143
+ * Instructions for the bootstrapper agent. With a reference architecture these
144
+ * are appended to its defaults; with no reference they are the whole brief.
145
+ */
146
+ instructions: v.optional(instructionsField, ''),
147
+ }), v.check((input) => Boolean(input.referenceArchitectureId) || input.instructions.trim().length > 0, 'Provide a reference architecture or freeform instructions to bootstrap from.'));
148
+ //# sourceMappingURL=bootstrap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bootstrap.js","sourceRoot":"","sources":["../src/bootstrap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAC5B,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAEtE,8EAA8E;A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