@aigile/engine 0.2.3 → 0.4.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 (198) hide show
  1. package/dist/action-item-features.d.ts +33 -0
  2. package/dist/action-item-features.d.ts.map +1 -0
  3. package/dist/action-item-features.js +113 -0
  4. package/dist/action-item-features.js.map +1 -0
  5. package/dist/action-items.d.ts +234 -0
  6. package/dist/action-items.d.ts.map +1 -0
  7. package/dist/action-items.js +722 -0
  8. package/dist/action-items.js.map +1 -0
  9. package/dist/action-sources.d.ts +44 -0
  10. package/dist/action-sources.d.ts.map +1 -0
  11. package/dist/action-sources.js +141 -0
  12. package/dist/action-sources.js.map +1 -0
  13. package/dist/agent-roles.d.ts +9 -0
  14. package/dist/agent-roles.d.ts.map +1 -0
  15. package/dist/agent-roles.js +18 -0
  16. package/dist/agent-roles.js.map +1 -0
  17. package/dist/agent-tasks.d.ts +36 -0
  18. package/dist/agent-tasks.d.ts.map +1 -0
  19. package/dist/agent-tasks.js +151 -0
  20. package/dist/agent-tasks.js.map +1 -0
  21. package/dist/agents/orchestrator.d.ts +26 -6
  22. package/dist/agents/orchestrator.d.ts.map +1 -1
  23. package/dist/agents/orchestrator.js +95 -45
  24. package/dist/agents/orchestrator.js.map +1 -1
  25. package/dist/agents/spec-analyst.d.ts +81 -13
  26. package/dist/agents/spec-analyst.d.ts.map +1 -1
  27. package/dist/agents/spec-analyst.js +350 -89
  28. package/dist/agents/spec-analyst.js.map +1 -1
  29. package/dist/ai-service.d.ts +40 -0
  30. package/dist/ai-service.d.ts.map +1 -1
  31. package/dist/ai-service.js +94 -9
  32. package/dist/ai-service.js.map +1 -1
  33. package/dist/api-tokens.d.ts +67 -0
  34. package/dist/api-tokens.d.ts.map +1 -0
  35. package/dist/api-tokens.js +89 -0
  36. package/dist/api-tokens.js.map +1 -0
  37. package/dist/attachments/extract.d.ts +26 -0
  38. package/dist/attachments/extract.d.ts.map +1 -0
  39. package/dist/attachments/extract.js +160 -0
  40. package/dist/attachments/extract.js.map +1 -0
  41. package/dist/attachments/fixtures.d.ts +9 -0
  42. package/dist/attachments/fixtures.d.ts.map +1 -0
  43. package/dist/attachments/fixtures.js +58 -0
  44. package/dist/attachments/fixtures.js.map +1 -0
  45. package/dist/attachments/service.d.ts +71 -0
  46. package/dist/attachments/service.d.ts.map +1 -0
  47. package/dist/attachments/service.js +220 -0
  48. package/dist/attachments/service.js.map +1 -0
  49. package/dist/build-service.d.ts +1 -1
  50. package/dist/build-service.d.ts.map +1 -1
  51. package/dist/build-service.js +9 -4
  52. package/dist/build-service.js.map +1 -1
  53. package/dist/change-events.d.ts +110 -0
  54. package/dist/change-events.d.ts.map +1 -0
  55. package/dist/change-events.js +238 -0
  56. package/dist/change-events.js.map +1 -0
  57. package/dist/change-sets.d.ts +110 -0
  58. package/dist/change-sets.d.ts.map +1 -0
  59. package/dist/change-sets.js +188 -0
  60. package/dist/change-sets.js.map +1 -0
  61. package/dist/command-runner.d.ts.map +1 -1
  62. package/dist/command-runner.js +2 -1
  63. package/dist/command-runner.js.map +1 -1
  64. package/dist/conversations.d.ts +2 -1
  65. package/dist/conversations.d.ts.map +1 -1
  66. package/dist/conversations.js +1 -1
  67. package/dist/conversations.js.map +1 -1
  68. package/dist/data-access.d.ts +9 -2
  69. package/dist/data-access.d.ts.map +1 -1
  70. package/dist/data-access.js +38 -6
  71. package/dist/data-access.js.map +1 -1
  72. package/dist/decisions.d.ts +56 -0
  73. package/dist/decisions.d.ts.map +1 -0
  74. package/dist/decisions.js +76 -0
  75. package/dist/decisions.js.map +1 -0
  76. package/dist/deliverables.d.ts +96 -0
  77. package/dist/deliverables.d.ts.map +1 -0
  78. package/dist/deliverables.js +344 -0
  79. package/dist/deliverables.js.map +1 -0
  80. package/dist/designs.d.ts +30 -0
  81. package/dist/designs.d.ts.map +1 -0
  82. package/dist/designs.js +154 -0
  83. package/dist/designs.js.map +1 -0
  84. package/dist/git-host.d.ts +10 -0
  85. package/dist/git-host.d.ts.map +1 -1
  86. package/dist/git-host.js +30 -2
  87. package/dist/git-host.js.map +1 -1
  88. package/dist/grounding.d.ts +9 -0
  89. package/dist/grounding.d.ts.map +1 -0
  90. package/dist/grounding.js +12 -0
  91. package/dist/grounding.js.map +1 -0
  92. package/dist/index.d.ts +35 -12
  93. package/dist/index.d.ts.map +1 -1
  94. package/dist/index.js +33 -10
  95. package/dist/index.js.map +1 -1
  96. package/dist/jira-features.d.ts +142 -0
  97. package/dist/jira-features.d.ts.map +1 -0
  98. package/dist/jira-features.js +366 -0
  99. package/dist/jira-features.js.map +1 -0
  100. package/dist/milestones.js +1 -1
  101. package/dist/milestones.js.map +1 -1
  102. package/dist/pull-request-sync.d.ts.map +1 -1
  103. package/dist/pull-request-sync.js +10 -6
  104. package/dist/pull-request-sync.js.map +1 -1
  105. package/dist/questions.d.ts +100 -10
  106. package/dist/questions.d.ts.map +1 -1
  107. package/dist/questions.js +211 -22
  108. package/dist/questions.js.map +1 -1
  109. package/dist/related.d.ts +26 -0
  110. package/dist/related.d.ts.map +1 -0
  111. package/dist/related.js +64 -0
  112. package/dist/related.js.map +1 -0
  113. package/dist/release-gates.d.ts +16 -0
  114. package/dist/release-gates.d.ts.map +1 -0
  115. package/dist/release-gates.js +47 -0
  116. package/dist/release-gates.js.map +1 -0
  117. package/dist/reviews.d.ts.map +1 -1
  118. package/dist/reviews.js +4 -3
  119. package/dist/reviews.js.map +1 -1
  120. package/dist/router.d.ts +2 -2
  121. package/dist/router.d.ts.map +1 -1
  122. package/dist/router.js.map +1 -1
  123. package/dist/scheduler.d.ts +41 -5
  124. package/dist/scheduler.d.ts.map +1 -1
  125. package/dist/scheduler.js +109 -7
  126. package/dist/scheduler.js.map +1 -1
  127. package/dist/services.d.ts +760 -15
  128. package/dist/services.d.ts.map +1 -1
  129. package/dist/services.js +402 -20
  130. package/dist/services.js.map +1 -1
  131. package/dist/source-sync.d.ts +136 -0
  132. package/dist/source-sync.d.ts.map +1 -0
  133. package/dist/source-sync.js +370 -0
  134. package/dist/source-sync.js.map +1 -0
  135. package/dist/sources/front-matter.d.ts +20 -0
  136. package/dist/sources/front-matter.d.ts.map +1 -0
  137. package/dist/sources/front-matter.js +57 -0
  138. package/dist/sources/front-matter.js.map +1 -0
  139. package/dist/sources/git.d.ts +80 -0
  140. package/dist/sources/git.d.ts.map +1 -0
  141. package/dist/sources/git.js +338 -0
  142. package/dist/sources/git.js.map +1 -0
  143. package/dist/sources/http.d.ts +54 -0
  144. package/dist/sources/http.d.ts.map +1 -0
  145. package/dist/sources/http.js +79 -0
  146. package/dist/sources/http.js.map +1 -0
  147. package/dist/spec-cache.d.ts +54 -0
  148. package/dist/spec-cache.d.ts.map +1 -0
  149. package/dist/spec-cache.js +133 -0
  150. package/dist/spec-cache.js.map +1 -0
  151. package/dist/spec-links.d.ts +68 -0
  152. package/dist/spec-links.d.ts.map +1 -0
  153. package/dist/spec-links.js +144 -0
  154. package/dist/spec-links.js.map +1 -0
  155. package/dist/spec-reader.d.ts +44 -0
  156. package/dist/spec-reader.d.ts.map +1 -0
  157. package/dist/spec-reader.js +81 -0
  158. package/dist/spec-reader.js.map +1 -0
  159. package/dist/spec-resolver.d.ts +13 -1
  160. package/dist/spec-resolver.d.ts.map +1 -1
  161. package/dist/spec-resolver.js +45 -8
  162. package/dist/spec-resolver.js.map +1 -1
  163. package/dist/spec-tools.d.ts +10 -0
  164. package/dist/spec-tools.d.ts.map +1 -0
  165. package/dist/spec-tools.js +103 -0
  166. package/dist/spec-tools.js.map +1 -0
  167. package/dist/task-scope.d.ts +11 -0
  168. package/dist/task-scope.d.ts.map +1 -0
  169. package/dist/task-scope.js +11 -0
  170. package/dist/task-scope.js.map +1 -0
  171. package/dist/telemetry.d.ts +34 -0
  172. package/dist/telemetry.d.ts.map +1 -0
  173. package/dist/telemetry.js +72 -0
  174. package/dist/telemetry.js.map +1 -0
  175. package/dist/template.d.ts +341 -0
  176. package/dist/template.d.ts.map +1 -0
  177. package/dist/template.js +142 -0
  178. package/dist/template.js.map +1 -0
  179. package/dist/tool-sandbox.d.ts.map +1 -1
  180. package/dist/tool-sandbox.js +2 -2
  181. package/dist/tool-sandbox.js.map +1 -1
  182. package/dist/tracks.d.ts +3 -3
  183. package/dist/tracks.js +1 -1
  184. package/dist/tracks.js.map +1 -1
  185. package/dist/verifier.d.ts.map +1 -1
  186. package/dist/verifier.js +8 -7
  187. package/dist/verifier.js.map +1 -1
  188. package/dist/vscode-connect.d.ts +48 -0
  189. package/dist/vscode-connect.d.ts.map +1 -0
  190. package/dist/vscode-connect.js +105 -0
  191. package/dist/vscode-connect.js.map +1 -0
  192. package/package.json +14 -3
  193. package/prompts/agent-task.contract.md +9 -0
  194. package/prompts/orchestrator.brief.md +17 -0
  195. package/prompts/orchestrator.contract.md +7 -0
  196. package/prompts/spec-analyst.brief.md +19 -0
  197. package/prompts/spec-analyst.contract.md +5 -0
  198. package/prompts/spec-analyst.sweep.md +2 -0
@@ -1,4 +1,4 @@
1
- import type { Conflict, DataStore, Message, Organization, Project, RevisionMeta, Role, RoleAssignment, Spec, User, WriteAuthor } from '@aigile/core';
1
+ import type { Conflict, DataStore, Message, Organization, Project, RevisionMeta, Role, RoleAssignment, Spec, SpecDraft, SpecSubject, User, WriteAuthor } from '@aigile/core';
2
2
  import { z } from 'zod';
3
3
  import { type DiffLine } from './text-diff.js';
4
4
  /**
@@ -35,7 +35,7 @@ export declare const organizationInputSchema: z.ZodObject<Omit<{
35
35
  } & {
36
36
  name: z.ZodString;
37
37
  parentId: z.ZodDefault<z.ZodNullable<z.ZodString>>;
38
- }, "id" | "createdAt" | "updatedAt">, "strip", z.ZodTypeAny, {
38
+ }, "updatedAt" | "id" | "createdAt">, "strip", z.ZodTypeAny, {
39
39
  name: string;
40
40
  parentId: string | null;
41
41
  }, {
@@ -49,18 +49,44 @@ export declare const profileInputSchema: z.ZodObject<{
49
49
  lastName: z.ZodOptional<z.ZodDefault<z.ZodString>>;
50
50
  organizationId: z.ZodOptional<z.ZodDefault<z.ZodNullable<z.ZodString>>>;
51
51
  jobTitle: z.ZodOptional<z.ZodDefault<z.ZodString>>;
52
+ prioritySetterIds: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString, "many">>>;
53
+ defersTo: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodObject<{
54
+ userId: z.ZodString;
55
+ area: z.ZodString;
56
+ basis: z.ZodEnum<["hierarchy", "dotted-line", "respect"]>;
57
+ }, "strip", z.ZodTypeAny, {
58
+ userId: string;
59
+ area: string;
60
+ basis: "hierarchy" | "dotted-line" | "respect";
61
+ }, {
62
+ userId: string;
63
+ area: string;
64
+ basis: "hierarchy" | "dotted-line" | "respect";
65
+ }>, "many">>>;
52
66
  }, "strip", z.ZodTypeAny, {
53
67
  email?: string | null | undefined;
54
68
  firstName?: string | undefined;
55
69
  lastName?: string | undefined;
56
70
  organizationId?: string | null | undefined;
57
71
  jobTitle?: string | undefined;
72
+ prioritySetterIds?: string[] | undefined;
73
+ defersTo?: {
74
+ userId: string;
75
+ area: string;
76
+ basis: "hierarchy" | "dotted-line" | "respect";
77
+ }[] | undefined;
58
78
  }, {
59
79
  email?: string | null | undefined;
60
80
  firstName?: string | undefined;
61
81
  lastName?: string | undefined;
62
82
  organizationId?: string | null | undefined;
63
83
  jobTitle?: string | undefined;
84
+ prioritySetterIds?: string[] | undefined;
85
+ defersTo?: {
86
+ userId: string;
87
+ area: string;
88
+ basis: "hierarchy" | "dotted-line" | "respect";
89
+ }[] | undefined;
64
90
  }>;
65
91
  export type ProfileInput = z.infer<typeof profileInputSchema>;
66
92
  /** What an admin may change about a user: the profile fields plus `disabled`. */
@@ -72,6 +98,20 @@ export declare const userAdminInputSchema: z.ZodObject<{
72
98
  managerId: z.ZodOptional<z.ZodDefault<z.ZodNullable<z.ZodString>>>;
73
99
  jobTitle: z.ZodOptional<z.ZodDefault<z.ZodString>>;
74
100
  disabled: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
101
+ prioritySetterIds: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString, "many">>>;
102
+ defersTo: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodObject<{
103
+ userId: z.ZodString;
104
+ area: z.ZodString;
105
+ basis: z.ZodEnum<["hierarchy", "dotted-line", "respect"]>;
106
+ }, "strip", z.ZodTypeAny, {
107
+ userId: string;
108
+ area: string;
109
+ basis: "hierarchy" | "dotted-line" | "respect";
110
+ }, {
111
+ userId: string;
112
+ area: string;
113
+ basis: "hierarchy" | "dotted-line" | "respect";
114
+ }>, "many">>>;
75
115
  }, "strip", z.ZodTypeAny, {
76
116
  email?: string | null | undefined;
77
117
  firstName?: string | undefined;
@@ -80,6 +120,12 @@ export declare const userAdminInputSchema: z.ZodObject<{
80
120
  managerId?: string | null | undefined;
81
121
  jobTitle?: string | undefined;
82
122
  disabled?: boolean | undefined;
123
+ prioritySetterIds?: string[] | undefined;
124
+ defersTo?: {
125
+ userId: string;
126
+ area: string;
127
+ basis: "hierarchy" | "dotted-line" | "respect";
128
+ }[] | undefined;
83
129
  }, {
84
130
  email?: string | null | undefined;
85
131
  firstName?: string | undefined;
@@ -88,8 +134,15 @@ export declare const userAdminInputSchema: z.ZodObject<{
88
134
  managerId?: string | null | undefined;
89
135
  jobTitle?: string | undefined;
90
136
  disabled?: boolean | undefined;
137
+ prioritySetterIds?: string[] | undefined;
138
+ defersTo?: {
139
+ userId: string;
140
+ area: string;
141
+ basis: "hierarchy" | "dotted-line" | "respect";
142
+ }[] | undefined;
91
143
  }>;
92
144
  /** The ranking is not typed in: it comes from the order of the roles (RoleService.reorder). */
145
+ /** What a person may set on a role: never its origin or whether it is the seeded instance (the install and a fork set those). */
93
146
  export declare const roleInputSchema: z.ZodObject<Omit<Omit<{
94
147
  id: z.ZodString;
95
148
  createdAt: z.ZodString;
@@ -101,17 +154,28 @@ export declare const roleInputSchema: z.ZodObject<Omit<Omit<{
101
154
  appRole: z.ZodDefault<z.ZodEnum<["owner", "admin", "maintainer", "contributor", "viewer"]>>;
102
155
  kind: z.ZodDefault<z.ZodEnum<["human", "agent"]>>;
103
156
  agentKey: z.ZodDefault<z.ZodNullable<z.ZodString>>;
104
- }, "id" | "createdAt" | "updatedAt">, "ranking">, "strip", z.ZodTypeAny, {
105
- name: string;
157
+ origin: z.ZodDefault<z.ZodNullable<z.ZodObject<{
158
+ templateId: z.ZodString;
159
+ agentKey: z.ZodString;
160
+ }, "strip", z.ZodTypeAny, {
161
+ agentKey: string;
162
+ templateId: string;
163
+ }, {
164
+ agentKey: string;
165
+ templateId: string;
166
+ }>>>;
167
+ seeded: z.ZodDefault<z.ZodBoolean>;
168
+ }, "updatedAt" | "id" | "createdAt">, "ranking" | "origin" | "seeded">, "strip", z.ZodTypeAny, {
169
+ kind: "agent" | "human";
106
170
  description: string;
171
+ name: string;
107
172
  appRole: "owner" | "admin" | "maintainer" | "contributor" | "viewer";
108
- kind: "human" | "agent";
109
173
  agentKey: string | null;
110
174
  }, {
111
175
  name: string;
176
+ kind?: "agent" | "human" | undefined;
112
177
  description?: string | undefined;
113
178
  appRole?: "owner" | "admin" | "maintainer" | "contributor" | "viewer" | undefined;
114
- kind?: "human" | "agent" | undefined;
115
179
  agentKey?: string | null | undefined;
116
180
  }>;
117
181
  export declare const RANKING_STEP = 10;
@@ -125,15 +189,15 @@ export declare const roleAssignmentInputSchema: z.ZodObject<Omit<{
125
189
  organizationIds: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
126
190
  projectIds: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
127
191
  rankingOverride: z.ZodDefault<z.ZodNullable<z.ZodNumber>>;
128
- }, "id" | "createdAt" | "updatedAt">, "strip", z.ZodTypeAny, {
129
- roleId: string;
192
+ }, "updatedAt" | "id" | "createdAt">, "strip", z.ZodTypeAny, {
130
193
  userId: string;
194
+ roleId: string;
131
195
  organizationIds: string[];
132
196
  projectIds: string[];
133
197
  rankingOverride: number | null;
134
198
  }, {
135
- roleId: string;
136
199
  userId: string;
200
+ roleId: string;
137
201
  organizationIds?: string[] | undefined;
138
202
  projectIds?: string[] | undefined;
139
203
  rankingOverride?: number | null | undefined;
@@ -150,21 +214,517 @@ export declare const projectInputSchema: z.ZodObject<Omit<{
150
214
  name: z.ZodString;
151
215
  gitUrl: z.ZodDefault<z.ZodNullable<z.ZodEffects<z.ZodString, string, string>>>;
152
216
  gitBranch: z.ZodDefault<z.ZodString>;
217
+ jiraKey: z.ZodDefault<z.ZodNullable<z.ZodString>>;
153
218
  organizationId: z.ZodString;
154
219
  parentProjectId: z.ZodDefault<z.ZodNullable<z.ZodString>>;
155
- }, "id" | "createdAt" | "updatedAt">, "strip", z.ZodTypeAny, {
220
+ templateId: z.ZodDefault<z.ZodString>;
221
+ templates: z.ZodDefault<z.ZodArray<z.ZodObject<{
222
+ id: z.ZodString;
223
+ seats: z.ZodDefault<z.ZodNullable<z.ZodArray<z.ZodString, "many">>>;
224
+ }, "strip", z.ZodTypeAny, {
225
+ id: string;
226
+ seats: string[] | null;
227
+ }, {
228
+ id: string;
229
+ seats?: string[] | null | undefined;
230
+ }>, "many">>;
231
+ agentRoleIds: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
232
+ agentConfig: z.ZodDefault<z.ZodObject<{
233
+ engineer: z.ZodOptional<z.ZodObject<{
234
+ allow: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString, "many">>>;
235
+ budgetTokens: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
236
+ commandTimeoutMs: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
237
+ buildTimeoutMs: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
238
+ autoBuild: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
239
+ planGate: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
240
+ specs: z.ZodOptional<z.ZodDefault<z.ZodEnum<["inline", "index"]>>>;
241
+ }, "strip", z.ZodTypeAny, {
242
+ allow?: string[] | undefined;
243
+ budgetTokens?: number | undefined;
244
+ commandTimeoutMs?: number | undefined;
245
+ buildTimeoutMs?: number | undefined;
246
+ autoBuild?: boolean | undefined;
247
+ planGate?: boolean | undefined;
248
+ specs?: "inline" | "index" | undefined;
249
+ }, {
250
+ allow?: string[] | undefined;
251
+ budgetTokens?: number | undefined;
252
+ commandTimeoutMs?: number | undefined;
253
+ buildTimeoutMs?: number | undefined;
254
+ autoBuild?: boolean | undefined;
255
+ planGate?: boolean | undefined;
256
+ specs?: "inline" | "index" | undefined;
257
+ }>>;
258
+ sandbox: z.ZodOptional<z.ZodObject<{
259
+ runtime: z.ZodOptional<z.ZodDefault<z.ZodEnum<["auto", "host", "container"]>>>;
260
+ engine: z.ZodOptional<z.ZodDefault<z.ZodEnum<["auto", "podman", "docker"]>>>;
261
+ image: z.ZodOptional<z.ZodDefault<z.ZodString>>;
262
+ imageByProject: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>>;
263
+ memory: z.ZodOptional<z.ZodDefault<z.ZodString>>;
264
+ cpus: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
265
+ pids: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
266
+ extraArgs: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString, "many">>>;
267
+ }, "strip", z.ZodTypeAny, {
268
+ runtime?: "auto" | "host" | "container" | undefined;
269
+ engine?: "auto" | "podman" | "docker" | undefined;
270
+ image?: string | undefined;
271
+ imageByProject?: Record<string, string> | undefined;
272
+ memory?: string | undefined;
273
+ cpus?: number | undefined;
274
+ pids?: number | undefined;
275
+ extraArgs?: string[] | undefined;
276
+ }, {
277
+ runtime?: "auto" | "host" | "container" | undefined;
278
+ engine?: "auto" | "podman" | "docker" | undefined;
279
+ image?: string | undefined;
280
+ imageByProject?: Record<string, string> | undefined;
281
+ memory?: string | undefined;
282
+ cpus?: number | undefined;
283
+ pids?: number | undefined;
284
+ extraArgs?: string[] | undefined;
285
+ }>>;
286
+ pullRequests: z.ZodOptional<z.ZodObject<{
287
+ enabled: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
288
+ }, "strip", z.ZodTypeAny, {
289
+ enabled?: boolean | undefined;
290
+ }, {
291
+ enabled?: boolean | undefined;
292
+ }>>;
293
+ verifier: z.ZodOptional<z.ZodObject<{
294
+ checks: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString, "many">>>;
295
+ checksByProject: z.ZodOptional<z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodArray<z.ZodString, "many">>>>;
296
+ timeoutMs: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
297
+ writeTests: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
298
+ testPaths: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodString, "many">>>;
299
+ }, "strip", z.ZodTypeAny, {
300
+ checks?: string[] | undefined;
301
+ checksByProject?: Record<string, string[]> | undefined;
302
+ timeoutMs?: number | undefined;
303
+ writeTests?: boolean | undefined;
304
+ testPaths?: string[] | undefined;
305
+ }, {
306
+ checks?: string[] | undefined;
307
+ checksByProject?: Record<string, string[]> | undefined;
308
+ timeoutMs?: number | undefined;
309
+ writeTests?: boolean | undefined;
310
+ testPaths?: string[] | undefined;
311
+ }>>;
312
+ monitor: z.ZodOptional<z.ZodObject<{
313
+ probes: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodObject<{
314
+ name: z.ZodString;
315
+ command: z.ZodString;
316
+ projectId: z.ZodDefault<z.ZodNullable<z.ZodString>>;
317
+ }, "strip", z.ZodTypeAny, {
318
+ name: string;
319
+ command: string;
320
+ projectId: string | null;
321
+ }, {
322
+ name: string;
323
+ command: string;
324
+ projectId?: string | null | undefined;
325
+ }>, "many">>>;
326
+ cadenceMinutes: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
327
+ auditDelaysMinutes: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodNumber, "many">>>;
328
+ runtime: z.ZodOptional<z.ZodDefault<z.ZodEnum<["host", "sandbox"]>>>;
329
+ timeoutMs: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
330
+ notifyUserId: z.ZodOptional<z.ZodDefault<z.ZodNullable<z.ZodString>>>;
331
+ }, "strip", z.ZodTypeAny, {
332
+ runtime?: "host" | "sandbox" | undefined;
333
+ timeoutMs?: number | undefined;
334
+ probes?: {
335
+ name: string;
336
+ command: string;
337
+ projectId: string | null;
338
+ }[] | undefined;
339
+ cadenceMinutes?: number | undefined;
340
+ auditDelaysMinutes?: number[] | undefined;
341
+ notifyUserId?: string | null | undefined;
342
+ }, {
343
+ runtime?: "host" | "sandbox" | undefined;
344
+ timeoutMs?: number | undefined;
345
+ probes?: {
346
+ name: string;
347
+ command: string;
348
+ projectId?: string | null | undefined;
349
+ }[] | undefined;
350
+ cadenceMinutes?: number | undefined;
351
+ auditDelaysMinutes?: number[] | undefined;
352
+ notifyUserId?: string | null | undefined;
353
+ }>>;
354
+ release: z.ZodOptional<z.ZodObject<{
355
+ environments: z.ZodOptional<z.ZodDefault<z.ZodArray<z.ZodObject<{
356
+ name: z.ZodString;
357
+ deploy: z.ZodString;
358
+ verify: z.ZodDefault<z.ZodNullable<z.ZodString>>;
359
+ rollback: z.ZodDefault<z.ZodNullable<z.ZodString>>;
360
+ requiresGo: z.ZodDefault<z.ZodBoolean>;
361
+ auditAfter: z.ZodDefault<z.ZodBoolean>;
362
+ }, "strip", z.ZodTypeAny, {
363
+ name: string;
364
+ deploy: string;
365
+ verify: string | null;
366
+ rollback: string | null;
367
+ requiresGo: boolean;
368
+ auditAfter: boolean;
369
+ }, {
370
+ name: string;
371
+ deploy: string;
372
+ verify?: string | null | undefined;
373
+ rollback?: string | null | undefined;
374
+ requiresGo?: boolean | undefined;
375
+ auditAfter?: boolean | undefined;
376
+ }>, "many">>>;
377
+ runtime: z.ZodOptional<z.ZodDefault<z.ZodEnum<["host", "sandbox"]>>>;
378
+ timeoutMs: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
379
+ notifyUserId: z.ZodOptional<z.ZodDefault<z.ZodNullable<z.ZodString>>>;
380
+ }, "strip", z.ZodTypeAny, {
381
+ runtime?: "host" | "sandbox" | undefined;
382
+ timeoutMs?: number | undefined;
383
+ notifyUserId?: string | null | undefined;
384
+ environments?: {
385
+ name: string;
386
+ deploy: string;
387
+ verify: string | null;
388
+ rollback: string | null;
389
+ requiresGo: boolean;
390
+ auditAfter: boolean;
391
+ }[] | undefined;
392
+ }, {
393
+ runtime?: "host" | "sandbox" | undefined;
394
+ timeoutMs?: number | undefined;
395
+ notifyUserId?: string | null | undefined;
396
+ environments?: {
397
+ name: string;
398
+ deploy: string;
399
+ verify?: string | null | undefined;
400
+ rollback?: string | null | undefined;
401
+ requiresGo?: boolean | undefined;
402
+ auditAfter?: boolean | undefined;
403
+ }[] | undefined;
404
+ }>>;
405
+ schedule: z.ZodOptional<z.ZodObject<{
406
+ enabled: z.ZodOptional<z.ZodDefault<z.ZodBoolean>>;
407
+ tickSeconds: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
408
+ quietSeconds: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
409
+ }, "strip", z.ZodTypeAny, {
410
+ enabled?: boolean | undefined;
411
+ tickSeconds?: number | undefined;
412
+ quietSeconds?: number | undefined;
413
+ }, {
414
+ enabled?: boolean | undefined;
415
+ tickSeconds?: number | undefined;
416
+ quietSeconds?: number | undefined;
417
+ }>>;
418
+ specAnalyst: z.ZodOptional<z.ZodObject<{
419
+ reviewChars: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
420
+ sweepChars: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
421
+ sweepDays: z.ZodOptional<z.ZodDefault<z.ZodNumber>>;
422
+ }, "strip", z.ZodTypeAny, {
423
+ reviewChars?: number | undefined;
424
+ sweepChars?: number | undefined;
425
+ sweepDays?: number | undefined;
426
+ }, {
427
+ reviewChars?: number | undefined;
428
+ sweepChars?: number | undefined;
429
+ sweepDays?: number | undefined;
430
+ }>>;
431
+ }, "strip", z.ZodTypeAny, {
432
+ sandbox?: {
433
+ runtime?: "auto" | "host" | "container" | undefined;
434
+ engine?: "auto" | "podman" | "docker" | undefined;
435
+ image?: string | undefined;
436
+ imageByProject?: Record<string, string> | undefined;
437
+ memory?: string | undefined;
438
+ cpus?: number | undefined;
439
+ pids?: number | undefined;
440
+ extraArgs?: string[] | undefined;
441
+ } | undefined;
442
+ engineer?: {
443
+ allow?: string[] | undefined;
444
+ budgetTokens?: number | undefined;
445
+ commandTimeoutMs?: number | undefined;
446
+ buildTimeoutMs?: number | undefined;
447
+ autoBuild?: boolean | undefined;
448
+ planGate?: boolean | undefined;
449
+ specs?: "inline" | "index" | undefined;
450
+ } | undefined;
451
+ pullRequests?: {
452
+ enabled?: boolean | undefined;
453
+ } | undefined;
454
+ verifier?: {
455
+ checks?: string[] | undefined;
456
+ checksByProject?: Record<string, string[]> | undefined;
457
+ timeoutMs?: number | undefined;
458
+ writeTests?: boolean | undefined;
459
+ testPaths?: string[] | undefined;
460
+ } | undefined;
461
+ monitor?: {
462
+ runtime?: "host" | "sandbox" | undefined;
463
+ timeoutMs?: number | undefined;
464
+ probes?: {
465
+ name: string;
466
+ command: string;
467
+ projectId: string | null;
468
+ }[] | undefined;
469
+ cadenceMinutes?: number | undefined;
470
+ auditDelaysMinutes?: number[] | undefined;
471
+ notifyUserId?: string | null | undefined;
472
+ } | undefined;
473
+ release?: {
474
+ runtime?: "host" | "sandbox" | undefined;
475
+ timeoutMs?: number | undefined;
476
+ notifyUserId?: string | null | undefined;
477
+ environments?: {
478
+ name: string;
479
+ deploy: string;
480
+ verify: string | null;
481
+ rollback: string | null;
482
+ requiresGo: boolean;
483
+ auditAfter: boolean;
484
+ }[] | undefined;
485
+ } | undefined;
486
+ schedule?: {
487
+ enabled?: boolean | undefined;
488
+ tickSeconds?: number | undefined;
489
+ quietSeconds?: number | undefined;
490
+ } | undefined;
491
+ specAnalyst?: {
492
+ reviewChars?: number | undefined;
493
+ sweepChars?: number | undefined;
494
+ sweepDays?: number | undefined;
495
+ } | undefined;
496
+ }, {
497
+ sandbox?: {
498
+ runtime?: "auto" | "host" | "container" | undefined;
499
+ engine?: "auto" | "podman" | "docker" | undefined;
500
+ image?: string | undefined;
501
+ imageByProject?: Record<string, string> | undefined;
502
+ memory?: string | undefined;
503
+ cpus?: number | undefined;
504
+ pids?: number | undefined;
505
+ extraArgs?: string[] | undefined;
506
+ } | undefined;
507
+ engineer?: {
508
+ allow?: string[] | undefined;
509
+ budgetTokens?: number | undefined;
510
+ commandTimeoutMs?: number | undefined;
511
+ buildTimeoutMs?: number | undefined;
512
+ autoBuild?: boolean | undefined;
513
+ planGate?: boolean | undefined;
514
+ specs?: "inline" | "index" | undefined;
515
+ } | undefined;
516
+ pullRequests?: {
517
+ enabled?: boolean | undefined;
518
+ } | undefined;
519
+ verifier?: {
520
+ checks?: string[] | undefined;
521
+ checksByProject?: Record<string, string[]> | undefined;
522
+ timeoutMs?: number | undefined;
523
+ writeTests?: boolean | undefined;
524
+ testPaths?: string[] | undefined;
525
+ } | undefined;
526
+ monitor?: {
527
+ runtime?: "host" | "sandbox" | undefined;
528
+ timeoutMs?: number | undefined;
529
+ probes?: {
530
+ name: string;
531
+ command: string;
532
+ projectId?: string | null | undefined;
533
+ }[] | undefined;
534
+ cadenceMinutes?: number | undefined;
535
+ auditDelaysMinutes?: number[] | undefined;
536
+ notifyUserId?: string | null | undefined;
537
+ } | undefined;
538
+ release?: {
539
+ runtime?: "host" | "sandbox" | undefined;
540
+ timeoutMs?: number | undefined;
541
+ notifyUserId?: string | null | undefined;
542
+ environments?: {
543
+ name: string;
544
+ deploy: string;
545
+ verify?: string | null | undefined;
546
+ rollback?: string | null | undefined;
547
+ requiresGo?: boolean | undefined;
548
+ auditAfter?: boolean | undefined;
549
+ }[] | undefined;
550
+ } | undefined;
551
+ schedule?: {
552
+ enabled?: boolean | undefined;
553
+ tickSeconds?: number | undefined;
554
+ quietSeconds?: number | undefined;
555
+ } | undefined;
556
+ specAnalyst?: {
557
+ reviewChars?: number | undefined;
558
+ sweepChars?: number | undefined;
559
+ sweepDays?: number | undefined;
560
+ } | undefined;
561
+ }>>;
562
+ deliverableMode: z.ZodDefault<z.ZodEnum<["one", "selected"]>>;
563
+ holdsTests: z.ZodDefault<z.ZodBoolean>;
564
+ }, "updatedAt" | "id" | "createdAt">, "strip", z.ZodTypeAny, {
156
565
  name: string;
157
566
  organizationId: string;
158
567
  gitUrl: string | null;
159
568
  gitBranch: string;
569
+ jiraKey: string | null;
160
570
  parentProjectId: string | null;
571
+ templateId: string;
572
+ templates: {
573
+ id: string;
574
+ seats: string[] | null;
575
+ }[];
576
+ agentRoleIds: Record<string, string>;
577
+ agentConfig: {
578
+ sandbox?: {
579
+ runtime?: "auto" | "host" | "container" | undefined;
580
+ engine?: "auto" | "podman" | "docker" | undefined;
581
+ image?: string | undefined;
582
+ imageByProject?: Record<string, string> | undefined;
583
+ memory?: string | undefined;
584
+ cpus?: number | undefined;
585
+ pids?: number | undefined;
586
+ extraArgs?: string[] | undefined;
587
+ } | undefined;
588
+ engineer?: {
589
+ allow?: string[] | undefined;
590
+ budgetTokens?: number | undefined;
591
+ commandTimeoutMs?: number | undefined;
592
+ buildTimeoutMs?: number | undefined;
593
+ autoBuild?: boolean | undefined;
594
+ planGate?: boolean | undefined;
595
+ specs?: "inline" | "index" | undefined;
596
+ } | undefined;
597
+ pullRequests?: {
598
+ enabled?: boolean | undefined;
599
+ } | undefined;
600
+ verifier?: {
601
+ checks?: string[] | undefined;
602
+ checksByProject?: Record<string, string[]> | undefined;
603
+ timeoutMs?: number | undefined;
604
+ writeTests?: boolean | undefined;
605
+ testPaths?: string[] | undefined;
606
+ } | undefined;
607
+ monitor?: {
608
+ runtime?: "host" | "sandbox" | undefined;
609
+ timeoutMs?: number | undefined;
610
+ probes?: {
611
+ name: string;
612
+ command: string;
613
+ projectId: string | null;
614
+ }[] | undefined;
615
+ cadenceMinutes?: number | undefined;
616
+ auditDelaysMinutes?: number[] | undefined;
617
+ notifyUserId?: string | null | undefined;
618
+ } | undefined;
619
+ release?: {
620
+ runtime?: "host" | "sandbox" | undefined;
621
+ timeoutMs?: number | undefined;
622
+ notifyUserId?: string | null | undefined;
623
+ environments?: {
624
+ name: string;
625
+ deploy: string;
626
+ verify: string | null;
627
+ rollback: string | null;
628
+ requiresGo: boolean;
629
+ auditAfter: boolean;
630
+ }[] | undefined;
631
+ } | undefined;
632
+ schedule?: {
633
+ enabled?: boolean | undefined;
634
+ tickSeconds?: number | undefined;
635
+ quietSeconds?: number | undefined;
636
+ } | undefined;
637
+ specAnalyst?: {
638
+ reviewChars?: number | undefined;
639
+ sweepChars?: number | undefined;
640
+ sweepDays?: number | undefined;
641
+ } | undefined;
642
+ };
643
+ deliverableMode: "one" | "selected";
644
+ holdsTests: boolean;
161
645
  }, {
162
646
  name: string;
163
647
  organizationId: string;
164
648
  gitUrl?: string | null | undefined;
165
649
  gitBranch?: string | undefined;
650
+ jiraKey?: string | null | undefined;
166
651
  parentProjectId?: string | null | undefined;
652
+ templateId?: string | undefined;
653
+ templates?: {
654
+ id: string;
655
+ seats?: string[] | null | undefined;
656
+ }[] | undefined;
657
+ agentRoleIds?: Record<string, string> | undefined;
658
+ agentConfig?: {
659
+ sandbox?: {
660
+ runtime?: "auto" | "host" | "container" | undefined;
661
+ engine?: "auto" | "podman" | "docker" | undefined;
662
+ image?: string | undefined;
663
+ imageByProject?: Record<string, string> | undefined;
664
+ memory?: string | undefined;
665
+ cpus?: number | undefined;
666
+ pids?: number | undefined;
667
+ extraArgs?: string[] | undefined;
668
+ } | undefined;
669
+ engineer?: {
670
+ allow?: string[] | undefined;
671
+ budgetTokens?: number | undefined;
672
+ commandTimeoutMs?: number | undefined;
673
+ buildTimeoutMs?: number | undefined;
674
+ autoBuild?: boolean | undefined;
675
+ planGate?: boolean | undefined;
676
+ specs?: "inline" | "index" | undefined;
677
+ } | undefined;
678
+ pullRequests?: {
679
+ enabled?: boolean | undefined;
680
+ } | undefined;
681
+ verifier?: {
682
+ checks?: string[] | undefined;
683
+ checksByProject?: Record<string, string[]> | undefined;
684
+ timeoutMs?: number | undefined;
685
+ writeTests?: boolean | undefined;
686
+ testPaths?: string[] | undefined;
687
+ } | undefined;
688
+ monitor?: {
689
+ runtime?: "host" | "sandbox" | undefined;
690
+ timeoutMs?: number | undefined;
691
+ probes?: {
692
+ name: string;
693
+ command: string;
694
+ projectId?: string | null | undefined;
695
+ }[] | undefined;
696
+ cadenceMinutes?: number | undefined;
697
+ auditDelaysMinutes?: number[] | undefined;
698
+ notifyUserId?: string | null | undefined;
699
+ } | undefined;
700
+ release?: {
701
+ runtime?: "host" | "sandbox" | undefined;
702
+ timeoutMs?: number | undefined;
703
+ notifyUserId?: string | null | undefined;
704
+ environments?: {
705
+ name: string;
706
+ deploy: string;
707
+ verify?: string | null | undefined;
708
+ rollback?: string | null | undefined;
709
+ requiresGo?: boolean | undefined;
710
+ auditAfter?: boolean | undefined;
711
+ }[] | undefined;
712
+ } | undefined;
713
+ schedule?: {
714
+ enabled?: boolean | undefined;
715
+ tickSeconds?: number | undefined;
716
+ quietSeconds?: number | undefined;
717
+ } | undefined;
718
+ specAnalyst?: {
719
+ reviewChars?: number | undefined;
720
+ sweepChars?: number | undefined;
721
+ sweepDays?: number | undefined;
722
+ } | undefined;
723
+ } | undefined;
724
+ deliverableMode?: "one" | "selected" | undefined;
725
+ holdsTests?: boolean | undefined;
167
726
  }>;
727
+ /** What a person may set on a spec: never its author or its provenance (the sync sets `source`). */
168
728
  export declare const specInputSchema: z.ZodObject<Omit<Omit<{
169
729
  id: z.ZodString;
170
730
  createdAt: z.ZodString;
@@ -178,22 +738,70 @@ export declare const specInputSchema: z.ZodObject<Omit<Omit<{
178
738
  userIds: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
179
739
  content: z.ZodDefault<z.ZodString>;
180
740
  seed: z.ZodDefault<z.ZodNullable<z.ZodString>>;
181
- }, "id" | "createdAt" | "updatedAt">, "authorUserId">, "strip", z.ZodTypeAny, {
741
+ source: z.ZodDefault<z.ZodNullable<z.ZodObject<{
742
+ sourceId: z.ZodString;
743
+ kind: z.ZodString;
744
+ externalId: z.ZodString;
745
+ version: z.ZodString;
746
+ url: z.ZodDefault<z.ZodNullable<z.ZodString>>;
747
+ syncedAt: z.ZodString;
748
+ removedAt: z.ZodDefault<z.ZodNullable<z.ZodString>>;
749
+ meta: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodString>>;
750
+ }, "strip", z.ZodTypeAny, {
751
+ url: string | null;
752
+ kind: string;
753
+ sourceId: string;
754
+ externalId: string;
755
+ version: string;
756
+ syncedAt: string;
757
+ removedAt: string | null;
758
+ meta: Record<string, string>;
759
+ }, {
760
+ kind: string;
761
+ sourceId: string;
762
+ externalId: string;
763
+ version: string;
764
+ syncedAt: string;
765
+ url?: string | null | undefined;
766
+ removedAt?: string | null | undefined;
767
+ meta?: Record<string, string> | undefined;
768
+ }>>>;
769
+ grounding: z.ZodDefault<z.ZodBoolean>;
770
+ parentId: z.ZodDefault<z.ZodNullable<z.ZodString>>;
771
+ order: z.ZodDefault<z.ZodNullable<z.ZodNumber>>;
772
+ anchored: z.ZodDefault<z.ZodBoolean>;
773
+ subject: z.ZodDefault<z.ZodNullable<z.ZodObject<{
774
+ kind: z.ZodEnum<["organization", "project", "user", "role"]>;
775
+ id: z.ZodString;
776
+ }, "strip", z.ZodTypeAny, {
777
+ kind: "user" | "organization" | "project" | "role";
778
+ id: string;
779
+ }, {
780
+ kind: "user" | "organization" | "project" | "role";
781
+ id: string;
782
+ }>>>;
783
+ }, "updatedAt" | "id" | "createdAt">, "source" | "authorUserId" | "anchored" | "subject">, "strip", z.ZodTypeAny, {
784
+ title: string;
182
785
  content: string;
786
+ parentId: string | null;
183
787
  organizationIds: string[];
184
788
  projectIds: string[];
185
- title: string;
186
789
  roleIds: string[];
187
790
  userIds: string[];
188
791
  seed: string | null;
792
+ grounding: boolean;
793
+ order: number | null;
189
794
  }, {
190
795
  title: string;
191
796
  content?: string | undefined;
797
+ parentId?: string | null | undefined;
192
798
  organizationIds?: string[] | undefined;
193
799
  projectIds?: string[] | undefined;
194
800
  roleIds?: string[] | undefined;
195
801
  userIds?: string[] | undefined;
196
802
  seed?: string | null | undefined;
803
+ grounding?: boolean | undefined;
804
+ order?: number | null | undefined;
197
805
  }>;
198
806
  export type OrganizationInput = z.infer<typeof organizationInputSchema>;
199
807
  export type ProjectInput = z.infer<typeof projectInputSchema>;
@@ -225,6 +833,13 @@ export declare class ProjectService {
225
833
  * organization would widen what they apply to.
226
834
  */
227
835
  delete(id: string, actor: Actor, children?: ChildrenPolicy): Promise<void>;
836
+ /**
837
+ * Which role instance plays a seat for this project (documentation/templates.md
838
+ * "Instances"): a role on that seat, or null to use the installation's shared
839
+ * instance again. Pointing two projects at one role is this call, made on
840
+ * purpose; forking makes them independent again.
841
+ */
842
+ setAgentRole(projectId: string, agentKey: string, roleId: string | null, actor: Actor): Promise<Project>;
228
843
  private assertReferences;
229
844
  }
230
845
  export interface SpecRevision extends RevisionMeta {
@@ -238,11 +853,68 @@ export declare class SpecService {
238
853
  list(): Promise<Spec[]>;
239
854
  get(id: string): Promise<Spec>;
240
855
  create(input: unknown, actor: Actor): Promise<Spec>;
241
- /** Create, and say which revision the datastore gave it (what the Spec Analyst reviews). */
856
+ /**
857
+ * Create, and say which revision it got (what the Spec Analyst reviews).
858
+ * With a writable source configured for new specs (`specs.source`), the
859
+ * document is written there first and the record points at it; otherwise
860
+ * the datastore holds it.
861
+ */
242
862
  createRevision(input: unknown, actor: Actor): Promise<{
243
863
  spec: Spec;
244
864
  revision: RevisionMeta;
245
865
  }>;
866
+ /** The inline spec of an organization, project, user or role (documentation/specs.md "Inline specs"), or null when none is written yet. */
867
+ inline(subject: SpecSubject): Promise<Spec | null>;
868
+ /**
869
+ * Write a subject's inline spec: created on first save, mapped to the
870
+ * subject alone, titled after it ("Project: FD Cloud"); an organization's is
871
+ * its Charter. Kept in the datastore, never sent to a source for new specs.
872
+ */
873
+ saveInline(subject: SpecSubject, name: string, content: string, actor: Actor): Promise<{
874
+ spec: Spec;
875
+ revision: RevisionMeta;
876
+ }>;
877
+ /** The edit in progress on a spec, if any. */
878
+ draft(id: string): Promise<SpecDraft | null>;
879
+ /** Keep an edit in progress beside the spec; nothing reaches the source until `save`. */
880
+ saveDraft(id: string, input: unknown, actor: Actor): Promise<SpecDraft>;
881
+ discardDraft(id: string, actor: Actor): Promise<void>;
882
+ /**
883
+ * Save the draft (or the title and content given) as the spec's next
884
+ * version: at its source when it has one, else in the datastore. The draft
885
+ * goes away; the revision is the source's version id.
886
+ */
887
+ save(id: string, actor: Actor, input?: unknown): Promise<{
888
+ spec: Spec;
889
+ revision: RevisionMeta;
890
+ }>;
891
+ /** Record a version the source now holds (after a save there): the record, the cache, the draft gone. */
892
+ applyWritten(spec: Spec, title: string, content: string, written: {
893
+ externalId: string;
894
+ version: string;
895
+ url: string | null;
896
+ }, actor: Actor, message: string): Promise<{
897
+ spec: Spec;
898
+ revision: RevisionMeta;
899
+ }>;
900
+ /** A record for a document a source now holds (created there by a change set). */
901
+ recordCreated(input: {
902
+ title: string;
903
+ content: string;
904
+ organizationIds: string[];
905
+ projectIds: string[];
906
+ roleIds: string[];
907
+ }, source: {
908
+ id: string;
909
+ kind: string;
910
+ }, written: {
911
+ externalId: string;
912
+ version: string;
913
+ url: string | null;
914
+ }, actor: Actor): Promise<Spec>;
915
+ /** Mark a sourced spec removed after its source dropped the document (the record stays, hidden). */
916
+ recordRemoved(spec: Spec, actor: Actor): Promise<Spec>;
917
+ private writeToSource;
246
918
  /** Every update is a new revision; the author of the spec stays its creator. */
247
919
  update(id: string, input: unknown, actor: Actor): Promise<Spec>;
248
920
  /** Update, and say which revision the datastore gave it. */
@@ -256,6 +928,8 @@ export declare class SpecService {
256
928
  atRevision(id: string, revision: string): Promise<Spec>;
257
929
  /** Line diff of the content from one revision to another (`to` defaults to the current spec). */
258
930
  diff(id: string, from: string, to?: string): Promise<DiffLine[]>;
931
+ /** A parent must exist and must not be the spec itself or one of its descendants. */
932
+ private assertParent;
259
933
  private assertMappings;
260
934
  }
261
935
  export declare class UserService {
@@ -269,6 +943,8 @@ export declare class UserService {
269
943
  adminUpdate(id: string, input: unknown, actor: Actor): Promise<User>;
270
944
  /** A manager must exist, must not be the person, and must not report back to them, however far up. */
271
945
  private assertManager;
946
+ /** The people a person points at (priority setters, deference) must exist and must not be the person. */
947
+ private assertPeople;
272
948
  private apply;
273
949
  }
274
950
  export declare class RoleService {
@@ -278,6 +954,40 @@ export declare class RoleService {
278
954
  get(id: string): Promise<Role>;
279
955
  /** A new role joins at the bottom of the order: one step below the lowest. */
280
956
  create(input: unknown, actor: Actor): Promise<Role>;
957
+ /**
958
+ * The install's seeding of a template seat (documentation/templates.md): the
959
+ * shared instance, with its origin. A role already on the seat is kept (and
960
+ * given its origin if it predates origins); otherwise one is created.
961
+ */
962
+ seedAgent(seed: Omit<RoleInput, 'origin' | 'seeded'> & {
963
+ agentKey: string;
964
+ }, templateId: string, actor: Actor): Promise<{
965
+ role: Role;
966
+ created: boolean;
967
+ }>;
968
+ /**
969
+ * Link a role a person made to a template seat (documentation/templates.md
970
+ * "Linking roles to seats"): it takes the seat's `agentKey` and an `origin`,
971
+ * and becomes the installation's instance of the seat, so `seedAgent` reuses
972
+ * it instead of creating a duplicate. Refused when another role already has
973
+ * the seat, when the role is linked to another seat, or when a human role
974
+ * would take an agent seat (or the reverse).
975
+ */
976
+ link(id: string, seat: {
977
+ templateId: string;
978
+ agentKey: string;
979
+ kind: 'human' | 'agent';
980
+ }, actor: Actor): Promise<Role>;
981
+ /** Undo `link`: the role keeps its name and holders and loses its seat; the next install seeds the seat as a role of its own. */
982
+ unlink(id: string, actor: Actor): Promise<Role>;
983
+ /**
984
+ * An independent copy of a role for one project to customize (documentation/
985
+ * templates.md "Instances"): the same seat and origin, its own name, and its own
986
+ * copy of every brief that applies to the source everywhere (the global ones),
987
+ * so edits diverge from here on. Nobody holds it; nothing points at it until a
988
+ * project does.
989
+ */
990
+ fork(id: string, name: string, actor: Actor): Promise<Role>;
281
991
  update(id: string, input: unknown, actor: Actor): Promise<Role>;
282
992
  /**
283
993
  * Set the precedence from an ordering of every role, strongest first; the
@@ -285,7 +995,7 @@ export declare class RoleService {
285
995
  * appear exactly once.
286
996
  */
287
997
  reorder(ids: string[], actor: Actor): Promise<Role[]>;
288
- /** Only a role nobody holds can go; the package's agents stay (install would seed them again). */
998
+ /** Only a role nobody holds and no project points at can go; a seeded agent stays (install would seed it again). */
289
999
  delete(id: string, actor: Actor): Promise<void>;
290
1000
  private assertNameFree;
291
1001
  }
@@ -334,7 +1044,23 @@ export declare class MessageService {
334
1044
  forConflict(conflictId: string): Promise<Message[]>;
335
1045
  post(conflictId: string, body: unknown, author: Message['author'], actor: Actor): Promise<Message>;
336
1046
  }
337
- /** Who administers the installation. */
1047
+ /**
1048
+ * What an administrator administers: everything (an owner or admin
1049
+ * assignment with no scope, or the bootstrap rule), or the organizations
1050
+ * (with everything below them) and projects (with their children) the
1051
+ * assignment is scoped to. A per-organization admin manages the people of
1052
+ * those organizations and the role assignments inside them; the
1053
+ * installation's own things (role definitions, the AI, unscoped
1054
+ * assignments) stay with the global admins.
1055
+ */
1056
+ export type AdminScope = {
1057
+ all: true;
1058
+ } | {
1059
+ all: false;
1060
+ organizationIds: Set<string>;
1061
+ projectIds: Set<string>;
1062
+ };
1063
+ /** Who administers the installation, and how far. */
338
1064
  export declare class AuthzService {
339
1065
  private readonly store;
340
1066
  constructor(store: DataStore);
@@ -343,8 +1069,25 @@ export declare class AuthzService {
343
1069
  * ranking (spec precedence) and a ranking override play no part. While
344
1070
  * nobody holds such a role, everyone is: a fresh installation has to be set
345
1071
  * up by somebody, and losing the last admin must not lock everyone out.
1072
+ * A scoped admin assignment makes a per-organization admin (`adminScope`).
346
1073
  */
347
1074
  isAdmin(userId: string): Promise<boolean>;
1075
+ /** An admin with no scope at all (or under the bootstrap rule). */
1076
+ isGlobalAdmin(userId: string): Promise<boolean>;
1077
+ /** How far a person administers, or null when they do not. */
1078
+ adminScope(userId: string): Promise<AdminScope | null>;
1079
+ /** True when a scope covers a user: their organization is in it (a user with no organization is the global admins'). */
1080
+ static userInScope(scope: AdminScope, user: Pick<User, 'organizationId'>): boolean;
1081
+ /**
1082
+ * True when a scope covers a thing scoped to organizations and projects: every
1083
+ * organization and project named is inside it, and something is named (an
1084
+ * unscoped thing is the installation's, so the global admins').
1085
+ */
1086
+ static withinScope(scope: AdminScope, target: {
1087
+ organizationIds: readonly string[];
1088
+ projectIds: readonly string[];
1089
+ }): boolean;
1090
+ private adminAssignments;
348
1091
  /** True while the bootstrap rule is in force: nobody holds an owner or admin application role. */
349
1092
  isBootstrap(): Promise<boolean>;
350
1093
  /**
@@ -353,6 +1096,8 @@ export declare class AuthzService {
353
1096
  * everyone decides, as everyone administers.
354
1097
  */
355
1098
  canDecide(userId: string): Promise<boolean>;
1099
+ /** Whether the person holds a role the test accepts (a tester's seat: the QA role, by its agent key or name). */
1100
+ holdsRole(userId: string, test: (role: Role) => boolean): Promise<boolean>;
356
1101
  private adminUserIds;
357
1102
  private userIdsWith;
358
1103
  }