aicms 0.0.0-stage → 0.5.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 (117) hide show
  1. package/ARCHITECTURE.md +467 -0
  2. package/LICENSE +21 -0
  3. package/README.md +200 -2
  4. package/README.uk.md +201 -0
  5. package/dist/cli.d.ts +2 -0
  6. package/dist/cli.js +722 -0
  7. package/dist/config-edit.d.ts +18 -0
  8. package/dist/config-edit.js +201 -0
  9. package/dist/config.d.ts +55 -0
  10. package/dist/config.js +32 -0
  11. package/dist/edge.d.ts +22 -0
  12. package/dist/edge.js +56 -0
  13. package/dist/gates/a2a.d.ts +45 -0
  14. package/dist/gates/a2a.js +126 -0
  15. package/dist/gates/discovery.d.ts +36 -0
  16. package/dist/gates/discovery.js +54 -0
  17. package/dist/gates/events.d.ts +14 -0
  18. package/dist/gates/events.js +86 -0
  19. package/dist/gates/graphql.d.ts +41 -0
  20. package/dist/gates/graphql.js +226 -0
  21. package/dist/gates/mcp.d.ts +8 -0
  22. package/dist/gates/mcp.js +60 -0
  23. package/dist/gates/openapi.d.ts +56 -0
  24. package/dist/gates/openapi.js +61 -0
  25. package/dist/gates/rest.d.ts +21 -0
  26. package/dist/gates/rest.js +263 -0
  27. package/dist/gates/studio.d.ts +21 -0
  28. package/dist/gates/studio.js +107 -0
  29. package/dist/index.d.ts +18 -0
  30. package/dist/index.js +19 -0
  31. package/dist/kernel/action.d.ts +49 -0
  32. package/dist/kernel/action.js +22 -0
  33. package/dist/kernel/briefs.d.ts +161 -0
  34. package/dist/kernel/briefs.js +197 -0
  35. package/dist/kernel/changesets.d.ts +367 -0
  36. package/dist/kernel/changesets.js +765 -0
  37. package/dist/kernel/cms.d.ts +127 -0
  38. package/dist/kernel/cms.js +419 -0
  39. package/dist/kernel/core-actions.d.ts +5 -0
  40. package/dist/kernel/core-actions.js +487 -0
  41. package/dist/kernel/errors.d.ts +14 -0
  42. package/dist/kernel/errors.js +25 -0
  43. package/dist/kernel/install.d.ts +32 -0
  44. package/dist/kernel/install.js +34 -0
  45. package/dist/kernel/model-actions.d.ts +5 -0
  46. package/dist/kernel/model-actions.js +126 -0
  47. package/dist/kernel/modules.d.ts +221 -0
  48. package/dist/kernel/modules.js +207 -0
  49. package/dist/kernel/policy.d.ts +42 -0
  50. package/dist/kernel/policy.js +47 -0
  51. package/dist/load.d.ts +10 -0
  52. package/dist/load.js +63 -0
  53. package/dist/modules/catalog.d.ts +15 -0
  54. package/dist/modules/catalog.js +21 -0
  55. package/dist/modules/commerce.d.ts +67 -0
  56. package/dist/modules/commerce.js +260 -0
  57. package/dist/modules/git-sync.d.ts +20 -0
  58. package/dist/modules/git-sync.js +187 -0
  59. package/dist/modules/i18n.d.ts +6 -0
  60. package/dist/modules/i18n.js +168 -0
  61. package/dist/modules/index.d.ts +9 -0
  62. package/dist/modules/index.js +10 -0
  63. package/dist/modules/lint.d.ts +22 -0
  64. package/dist/modules/lint.js +126 -0
  65. package/dist/modules/media.d.ts +52 -0
  66. package/dist/modules/media.js +319 -0
  67. package/dist/modules/payments.d.ts +19 -0
  68. package/dist/modules/payments.js +110 -0
  69. package/dist/modules/search.d.ts +27 -0
  70. package/dist/modules/search.js +81 -0
  71. package/dist/modules/seo.d.ts +34 -0
  72. package/dist/modules/seo.js +189 -0
  73. package/dist/modules/text.d.ts +10 -0
  74. package/dist/modules/text.js +42 -0
  75. package/dist/node.d.ts +7 -0
  76. package/dist/node.js +11 -0
  77. package/dist/registry.d.ts +57 -0
  78. package/dist/registry.js +110 -0
  79. package/dist/schema/fields.d.ts +100 -0
  80. package/dist/schema/fields.js +134 -0
  81. package/dist/schema/markdown.d.ts +7 -0
  82. package/dist/schema/markdown.js +168 -0
  83. package/dist/schema/model.d.ts +44 -0
  84. package/dist/schema/model.js +104 -0
  85. package/dist/schema/slug.d.ts +2 -0
  86. package/dist/schema/slug.js +40 -0
  87. package/dist/store/d1.d.ts +30 -0
  88. package/dist/store/d1.js +27 -0
  89. package/dist/store/postgres.d.ts +164 -0
  90. package/dist/store/postgres.js +552 -0
  91. package/dist/store/sql.d.ts +135 -0
  92. package/dist/store/sql.js +530 -0
  93. package/dist/store/sqlite.d.ts +14 -0
  94. package/dist/store/sqlite.js +60 -0
  95. package/dist/store/types.d.ts +226 -0
  96. package/dist/store/types.js +21 -0
  97. package/dist/studio/assets/geologica-cyrillic-ext-wght-normal-C8B9Chlh.woff2 +0 -0
  98. package/dist/studio/assets/geologica-cyrillic-wght-normal-DbeVG3Ps.woff2 +0 -0
  99. package/dist/studio/assets/geologica-greek-wght-normal-DPM5d9ub.woff2 +0 -0
  100. package/dist/studio/assets/geologica-latin-ext-wght-normal-DZyYlgcm.woff2 +0 -0
  101. package/dist/studio/assets/geologica-latin-wght-normal-BBL8hQxZ.woff2 +0 -0
  102. package/dist/studio/assets/geologica-vietnamese-wght-normal-DcI17N1q.woff2 +0 -0
  103. package/dist/studio/assets/index-3dJ0YHxb.js +22 -0
  104. package/dist/studio/assets/index-DuyGLFw4.css +1 -0
  105. package/dist/studio/assets/jetbrains-mono-cyrillic-wght-normal-D73BlboJ.woff2 +0 -0
  106. package/dist/studio/assets/jetbrains-mono-greek-wght-normal-Bw9x6K1M.woff2 +0 -0
  107. package/dist/studio/assets/jetbrains-mono-latin-ext-wght-normal-DBQx-q_a.woff2 +0 -0
  108. package/dist/studio/assets/jetbrains-mono-latin-wght-normal-B9CIFXIH.woff2 +0 -0
  109. package/dist/studio/assets/jetbrains-mono-vietnamese-wght-normal-Bt-aOZkq.woff2 +0 -0
  110. package/dist/studio/assets/unbounded-cyrillic-wght-normal-C627f1f8.woff2 +0 -0
  111. package/dist/studio/assets/unbounded-latin-ext-wght-normal-D6H-S6MW.woff2 +0 -0
  112. package/dist/studio/assets/unbounded-latin-wght-normal-D5afBTBx.woff2 +0 -0
  113. package/dist/studio/assets/unbounded-vietnamese-wght-normal-rat7GD3o.woff2 +0 -0
  114. package/dist/studio/index.html +21 -0
  115. package/dist/typegen.d.ts +7 -0
  116. package/dist/typegen.js +55 -0
  117. package/package.json +88 -4
@@ -0,0 +1,197 @@
1
+ // Briefs: work people (or a planning agent) hand to agents. "Write a post about
2
+ // the spring menu, publish Friday 9:00." An agent finds its briefs with
3
+ // cms_briefs, says what it's doing with cms_brief_update, and answers with
4
+ // cms_submit({ brief }). Merging the changeset closes the brief; rejecting it
5
+ // sends the reviewer's comment back as a note.
6
+ import { AicmsError } from "./errors.js";
7
+ import { newId } from "./changesets.js";
8
+ import { allows } from "./policy.js";
9
+ export const BRIEF_STATUSES = ["open", "in_progress", "blocked", "in_review", "done", "canceled"];
10
+ /** What an agent working on a brief may set. The rest follows from its changesets or a person's decision. */
11
+ export const AGENT_BRIEF_STATUSES = ["in_progress", "blocked", "open", "done"];
12
+ const SCOPE = "core:briefs";
13
+ const MAX_NOTES = 100;
14
+ const now = () => new Date().toISOString();
15
+ /** May write and manage briefs: people (the owner) and planning agents with `briefs:write`. */
16
+ export const briefWriter = (a) => allows(a.scopes, "briefs:write");
17
+ /** Is this brief for this agent: assigned to it, taken by it, or open to anyone? */
18
+ export function briefIsFor(b, actor) {
19
+ if (actor.kind !== "agent")
20
+ return false;
21
+ if (b.agent)
22
+ return b.agent === actor.id;
23
+ return !b.claimedBy || b.claimedBy === actor.id;
24
+ }
25
+ const canSee = (b, actor) => briefWriter(actor) || briefIsFor(b, actor) || b.createdBy === actor.id;
26
+ async function load(k, id) {
27
+ return (await k.store.kvGet(SCOPE, id)) ?? null;
28
+ }
29
+ async function save(k, b, event, by) {
30
+ b.updatedAt = now();
31
+ await k.store.kvSet(SCOPE, b.id, b);
32
+ await k.emit(event, { ...briefSummary(b), by });
33
+ return b;
34
+ }
35
+ /** The list view: everything but the notes. */
36
+ export function briefSummary(b) {
37
+ const { notes, ...rest } = b;
38
+ return { ...rest, notes: notes.length, ...(notes.length ? { lastNote: notes[notes.length - 1] } : {}) };
39
+ }
40
+ export async function getBrief(k, actor, id) {
41
+ const b = await load(k, id);
42
+ if (!b || !canSee(b, actor))
43
+ throw new AicmsError("not_found", `No brief ${id}`);
44
+ return b;
45
+ }
46
+ export async function listBriefs(k, actor, q = {}) {
47
+ const all = (await k.store.kvList(SCOPE)).map((r) => r.value);
48
+ const active = (b) => b.status !== "done" && b.status !== "canceled";
49
+ const items = all
50
+ .filter((b) => canSee(b, actor))
51
+ .filter((b) => (q.status?.length ? q.status.includes(b.status) : active(b)))
52
+ .filter((b) => !q.agent || b.agent === q.agent || b.claimedBy === q.agent)
53
+ // Due soonest first, then newest.
54
+ .sort((a, b) => (a.due ?? "~").localeCompare(b.due ?? "~") || b.createdAt.localeCompare(a.createdAt));
55
+ return { briefs: items.slice(0, q.limit ?? 50).map(briefSummary), total: items.length };
56
+ }
57
+ function validDate(label, v) {
58
+ if (v && Number.isNaN(Date.parse(v)))
59
+ throw new AicmsError("invalid", `${label} "${v}" isn't a date. Use ISO 8601, e.g. 2026-12-01 or 2026-12-01T09:00:00Z`);
60
+ }
61
+ /** Create a brief (no id) or change one: people and planning agents. */
62
+ export async function writeBrief(k, actor, id, input) {
63
+ if (input.agent) {
64
+ if (!k.config.agents[input.agent])
65
+ throw new AicmsError("invalid", `No agent "${input.agent}". Agents: ${Object.keys(k.config.agents).join(", ") || "none"}`);
66
+ }
67
+ if (input.model && !k.models.has(input.model))
68
+ throw new AicmsError("invalid", `No model "${input.model}"`);
69
+ if (input.entry && !(await k.store.getEntry(input.entry)))
70
+ throw new AicmsError("invalid", `No entry ${input.entry}`);
71
+ validDate("due", input.due);
72
+ validDate("publishAt", input.publishAt);
73
+ const set = (b, key, v) => {
74
+ if (v === undefined)
75
+ return;
76
+ if (v === null || v === "")
77
+ delete b[key];
78
+ else
79
+ b[key] = v;
80
+ };
81
+ if (!id) {
82
+ if (!input.title?.trim())
83
+ throw new AicmsError("invalid", "A brief needs a title");
84
+ const at = now();
85
+ const b = { id: newId("br"), title: input.title.trim(), status: "open", changesets: [], notes: [], createdBy: actor.id, createdAt: at, updatedAt: at };
86
+ for (const key of ["details", "agent", "model", "entry", "due", "publishAt"])
87
+ set(b, key, input[key] ?? undefined);
88
+ if (input.note)
89
+ b.notes.push({ at, by: actor.id, text: input.note });
90
+ await save(k, b, "brief.created", actor.id);
91
+ return { brief: b, next: b.agent ? `${b.agent} sees it in cms_briefs.` : "Any agent can pick it up from cms_briefs." };
92
+ }
93
+ const b = await getBrief(k, actor, id);
94
+ if (input.title !== undefined) {
95
+ if (!input.title.trim())
96
+ throw new AicmsError("invalid", "A brief needs a title");
97
+ b.title = input.title.trim();
98
+ }
99
+ for (const key of ["details", "agent", "model", "entry", "due", "publishAt"])
100
+ set(b, key, input[key]);
101
+ if (input.agent !== undefined)
102
+ delete b.claimedBy;
103
+ if (input.status)
104
+ b.status = input.status;
105
+ else if (b.status === "blocked" && input.note)
106
+ b.status = b.claimedBy || b.agent ? "in_progress" : "open"; // a person answered
107
+ if (input.note)
108
+ addNote(b, actor.id, input.note);
109
+ await save(k, b, "brief.updated", actor.id);
110
+ return { brief: b };
111
+ }
112
+ function addNote(b, by, text) {
113
+ b.notes.push({ at: now(), by, text });
114
+ if (b.notes.length > MAX_NOTES)
115
+ b.notes.splice(0, b.notes.length - MAX_NOTES);
116
+ }
117
+ /** An agent reports on a brief: takes it, asks a question (blocked), gives it back, or finishes it without content changes. */
118
+ export async function updateBrief(k, actor, id, input) {
119
+ if (briefWriter(actor) && actor.kind !== "agent")
120
+ return writeBrief(k, actor, id, { note: input.note, status: input.status === "done" || input.status === "open" ? input.status : undefined });
121
+ const b = await load(k, id);
122
+ if (!b || !briefIsFor(b, actor))
123
+ throw new AicmsError("not_found", `No brief ${id} for you`);
124
+ if (b.status === "done" || b.status === "canceled")
125
+ throw new AicmsError("invalid", `Brief ${id} is ${b.status}`);
126
+ if (!input.status && !input.note)
127
+ throw new AicmsError("invalid", "Send a status, a note, or both");
128
+ if (input.status === "blocked" && !input.note)
129
+ throw new AicmsError("invalid", "Say what you need in the note: a person reads it");
130
+ if (input.status === "done" && !input.note)
131
+ throw new AicmsError("invalid", "Say what you did in the note");
132
+ if (input.status) {
133
+ b.status = input.status;
134
+ if (input.status === "open")
135
+ delete b.claimedBy;
136
+ else if (!b.agent)
137
+ b.claimedBy = actor.id;
138
+ }
139
+ if (input.note)
140
+ addNote(b, actor.id, input.note);
141
+ await save(k, b, "brief.updated", actor.id);
142
+ return {
143
+ brief: briefSummary(b),
144
+ next: b.status === "blocked"
145
+ ? "A person will answer in the brief's notes. Check cms_briefs { id } later."
146
+ : b.status === "in_progress"
147
+ ? "Draft the work, then cms_submit with { brief } so the reviewer sees what it answers."
148
+ : undefined,
149
+ };
150
+ }
151
+ /** Before cms_submit links a changeset: is the brief this agent's to answer? Returns its publishAt, if any. */
152
+ export async function briefForSubmit(k, actor, id) {
153
+ const b = await load(k, id);
154
+ if (!b || (!briefIsFor(b, actor) && !briefWriter(actor)))
155
+ throw new AicmsError("not_found", `No brief ${id} for you`);
156
+ if (b.status === "done" || b.status === "canceled")
157
+ throw new AicmsError("invalid", `Brief ${id} is already ${b.status}`);
158
+ return b;
159
+ }
160
+ /** After cms_submit: link the changeset and move the brief along. */
161
+ export async function linkSubmission(k, actor, id, changeset, status) {
162
+ const b = await load(k, id);
163
+ if (!b)
164
+ return;
165
+ if (!b.changesets.includes(changeset))
166
+ b.changesets.push(changeset);
167
+ if (!b.agent && actor.kind === "agent")
168
+ b.claimedBy = actor.id;
169
+ b.status = status === "merged" ? "done" : status === "needs_changes" ? "in_progress" : "in_review";
170
+ await save(k, b, "brief.updated", actor.id);
171
+ }
172
+ /** Merges close briefs; rejections bring the reviewer's comment back to the agent. */
173
+ export function watchBriefs(k) {
174
+ k.on("changeset.merged", async (_event, payload) => {
175
+ const p = payload;
176
+ if (!p.brief)
177
+ return;
178
+ const b = await load(k, p.brief);
179
+ if (!b || b.status === "done" || b.status === "canceled")
180
+ return;
181
+ b.status = "done";
182
+ if (!b.changesets.includes(p.changeset))
183
+ b.changesets.push(p.changeset);
184
+ await save(k, b, "brief.updated", p.mergedBy);
185
+ });
186
+ k.on("changeset.rejected", async (_event, payload) => {
187
+ const p = payload;
188
+ if (!p.brief)
189
+ return;
190
+ const b = await load(k, p.brief);
191
+ if (!b || b.status === "done" || b.status === "canceled")
192
+ return;
193
+ b.status = "in_progress";
194
+ addNote(b, p.by, `Changes requested on ${p.id}: ${p.comment}`);
195
+ await save(k, b, "brief.updated", p.by);
196
+ });
197
+ }
@@ -0,0 +1,367 @@
1
+ import type { Model } from "../schema/model.ts";
2
+ import { type ChangesetRow, type CheckIssue, type EntryRow } from "../store/types.ts";
3
+ import { type Actor } from "./policy.ts";
4
+ import type { Kernel } from "./cms.ts";
5
+ export declare const newId: (prefix: string) => string;
6
+ export interface DraftOptions {
7
+ /** Module Actions authorize with their own scope, so model scopes are skipped. */
8
+ trusted?: boolean;
9
+ }
10
+ /** Create or change an entry inside the actor's open changeset. */
11
+ export declare function draftEntry(k: Kernel, actor: Actor, model: Model, input: Record<string, unknown>, opts?: DraftOptions): Promise<{
12
+ changeset: string;
13
+ op: "create" | "update" | "delete" | "install";
14
+ id: string;
15
+ model: string;
16
+ entry: Record<string, unknown>;
17
+ next: string;
18
+ }>;
19
+ /** Drop drafted changes from the actor's open changeset: one entry, or all of them. */
20
+ export declare function discardDrafts(k: Kernel, actor: Actor, id?: string): Promise<{
21
+ changeset: string | null;
22
+ discarded: number;
23
+ left: number;
24
+ }>;
25
+ /** Propose deleting an entry, or drop a draft that was never published. */
26
+ export declare function deleteEntry(k: Kernel, actor: Actor, model: Model, id: string, opts?: DraftOptions): Promise<{
27
+ changeset: string;
28
+ op: string;
29
+ id: string;
30
+ next: string;
31
+ }>;
32
+ /**
33
+ * An entry as this actor sees it: the published version with their open
34
+ * changeset applied on top. `null` if it doesn't exist or they proposed deleting it.
35
+ */
36
+ export declare function entryWithDrafts(k: Kernel, actor: Actor, id: string): Promise<EntryRow | null>;
37
+ /** Schema, uniqueness, reference and conflict checks for every item. */
38
+ export declare function checkChangeset(k: Kernel, cs: ChangesetRow): Promise<CheckIssue[]>;
39
+ /** Module checks on every create and update: errors block, warnings go to the reviewer. A check that throws becomes a warning. */
40
+ export declare function runModuleChecks(k: Kernel, cs: ChangesetRow): Promise<{
41
+ errors: CheckIssue[];
42
+ warnings: CheckIssue[];
43
+ }>;
44
+ /** A future time as ISO, or undefined for "now". Throws on nonsense. */
45
+ export declare function parsePublishAt(at: string | undefined): string | undefined;
46
+ /** Checks on the caller's open changeset, without submitting: what cms_submit would say. */
47
+ export declare function checkDrafts(k: Kernel, actor: Actor): Promise<{
48
+ next: string;
49
+ onSubmit?: string | undefined;
50
+ changeset: string;
51
+ ready: boolean;
52
+ issues: CheckIssue[];
53
+ warnings: CheckIssue[];
54
+ }>;
55
+ export interface SubmitOptions {
56
+ note?: string;
57
+ /** Ask to publish at this time (ISO 8601). A reviewer approves it as a schedule. */
58
+ publishAt?: string;
59
+ /** The brief this answers. */
60
+ brief?: string;
61
+ }
62
+ export declare function submitChangeset(k: Kernel, actor: Actor, input?: string | SubmitOptions): Promise<{
63
+ status: string;
64
+ changeset: string;
65
+ publishAt: string;
66
+ next: string;
67
+ } | {
68
+ next: string;
69
+ warnings?: CheckIssue[] | undefined;
70
+ status: string;
71
+ changeset: string;
72
+ issues: CheckIssue[];
73
+ } | {
74
+ next: string;
75
+ publishAt?: string | undefined;
76
+ warnings?: CheckIssue[] | undefined;
77
+ status: string;
78
+ changeset: string;
79
+ reason: string;
80
+ } | {
81
+ changeset: string;
82
+ actor: string;
83
+ mergedBy: string;
84
+ entries: never[];
85
+ modules: string[];
86
+ installed: {
87
+ note?: string | undefined;
88
+ module: string;
89
+ manifest: {
90
+ provides: string[];
91
+ requires: string[];
92
+ uses: string[];
93
+ models: {
94
+ name: string;
95
+ fields: string[];
96
+ }[];
97
+ actions: {
98
+ destructive?: boolean | undefined;
99
+ readOnly?: boolean | undefined;
100
+ name: string;
101
+ description: string;
102
+ scope: string;
103
+ }[];
104
+ scopes: string[];
105
+ routes: string[];
106
+ hooks: string[];
107
+ checks: string[];
108
+ version?: string | undefined;
109
+ description?: string | undefined;
110
+ name: string;
111
+ };
112
+ persisted: boolean;
113
+ }[];
114
+ status: string;
115
+ } | {
116
+ entries: {
117
+ id: string;
118
+ model: string;
119
+ op: "create" | "update" | "delete" | "install" | undefined;
120
+ version: number;
121
+ }[];
122
+ brief?: string | undefined;
123
+ changeset: string;
124
+ actor: string;
125
+ mergedBy: string;
126
+ status: string;
127
+ }>;
128
+ export interface MergeOptions {
129
+ /**
130
+ * When to publish: an ISO time schedules it, "now" publishes at once.
131
+ * Omitted: at the time the author asked for, if any, else now.
132
+ */
133
+ at?: string;
134
+ }
135
+ export declare function mergeChangeset(k: Kernel, id: string, by: string, opts?: MergeOptions): Promise<{
136
+ status: string;
137
+ changeset: string;
138
+ publishAt: string;
139
+ next: string;
140
+ } | {
141
+ changeset: string;
142
+ actor: string;
143
+ mergedBy: string;
144
+ entries: never[];
145
+ modules: string[];
146
+ installed: {
147
+ note?: string | undefined;
148
+ module: string;
149
+ manifest: {
150
+ provides: string[];
151
+ requires: string[];
152
+ uses: string[];
153
+ models: {
154
+ name: string;
155
+ fields: string[];
156
+ }[];
157
+ actions: {
158
+ destructive?: boolean | undefined;
159
+ readOnly?: boolean | undefined;
160
+ name: string;
161
+ description: string;
162
+ scope: string;
163
+ }[];
164
+ scopes: string[];
165
+ routes: string[];
166
+ hooks: string[];
167
+ checks: string[];
168
+ version?: string | undefined;
169
+ description?: string | undefined;
170
+ name: string;
171
+ };
172
+ persisted: boolean;
173
+ }[];
174
+ } | {
175
+ entries: {
176
+ id: string;
177
+ model: string;
178
+ op: "create" | "update" | "delete" | "install" | undefined;
179
+ version: number;
180
+ }[];
181
+ brief?: string | undefined;
182
+ changeset: string;
183
+ actor: string;
184
+ mergedBy: string;
185
+ }>;
186
+ /** Take a scheduled changeset off the schedule; it waits for review again. */
187
+ export declare function unscheduleChangeset(k: Kernel, id: string, by: string): Promise<{
188
+ changeset: string;
189
+ status: "submitted";
190
+ }>;
191
+ /**
192
+ * Merge every scheduled changeset whose time has come. One that no longer
193
+ * passes its checks goes back to its author, like a manual merge would.
194
+ */
195
+ export declare function publishDue(k: Kernel, at?: Date): Promise<{
196
+ merged: string[];
197
+ failed: {
198
+ changeset: string;
199
+ error: string;
200
+ }[];
201
+ }>;
202
+ /** An agent's request to install a catalog module; it waits in the Inbox for a person. */
203
+ export declare function proposeModule(k: Kernel, actor: Actor, name: string, reason: string): Promise<{
204
+ status: string;
205
+ changeset: string;
206
+ module: {
207
+ provides: string[];
208
+ requires: string[];
209
+ uses: string[];
210
+ models: {
211
+ name: string;
212
+ fields: string[];
213
+ }[];
214
+ actions: {
215
+ destructive?: boolean | undefined;
216
+ readOnly?: boolean | undefined;
217
+ name: string;
218
+ description: string;
219
+ scope: string;
220
+ }[];
221
+ scopes: string[];
222
+ routes: string[];
223
+ hooks: string[];
224
+ checks: string[];
225
+ version?: string | undefined;
226
+ description?: string | undefined;
227
+ name: string;
228
+ };
229
+ next: string;
230
+ }>;
231
+ export declare function rejectChangeset(k: Kernel, id: string, by: string, comment: string, final?: boolean): Promise<{
232
+ changeset: string;
233
+ status: "open" | "rejected";
234
+ reopened: boolean;
235
+ }>;
236
+ export declare function summarize(cs: ChangesetRow): {
237
+ items: {
238
+ fields?: string[] | undefined;
239
+ op: "create" | "update" | "delete" | "install";
240
+ model: string;
241
+ id: string;
242
+ }[];
243
+ updatedAt: string;
244
+ brief?: string | undefined;
245
+ scheduledBy?: string | undefined;
246
+ publishAt?: string | undefined;
247
+ warnings?: CheckIssue[] | undefined;
248
+ issues?: CheckIssue[] | undefined;
249
+ waitingBecause?: string | undefined;
250
+ comment?: string | undefined;
251
+ note?: string | undefined;
252
+ id: string;
253
+ actor: string;
254
+ status: import("../store/types.ts").ChangesetStatus;
255
+ };
256
+ /** Before/after per field, for reviewers. Block fields are shown as Markdown. */
257
+ export declare function diffChangeset(k: Kernel, cs: ChangesetRow): Promise<{
258
+ items: ({
259
+ op: "install";
260
+ model: string;
261
+ id: string;
262
+ title: string;
263
+ summary: string | undefined;
264
+ module: {
265
+ provides: string[];
266
+ requires: string[];
267
+ uses: string[];
268
+ models: {
269
+ name: string;
270
+ fields: string[];
271
+ }[];
272
+ actions: {
273
+ destructive?: boolean | undefined;
274
+ readOnly?: boolean | undefined;
275
+ name: string;
276
+ description: string;
277
+ scope: string;
278
+ }[];
279
+ scopes: string[];
280
+ routes: string[];
281
+ hooks: string[];
282
+ checks: string[];
283
+ version?: string | undefined;
284
+ description?: string | undefined;
285
+ name: string;
286
+ } | null;
287
+ changes: never[];
288
+ } | {
289
+ op: "create" | "update" | "delete";
290
+ model: string;
291
+ id: string;
292
+ title: string;
293
+ changes: {
294
+ field: string;
295
+ before: {} | null;
296
+ after: {} | null;
297
+ }[];
298
+ summary?: undefined;
299
+ module?: undefined;
300
+ })[];
301
+ updatedAt: string;
302
+ brief?: string | undefined;
303
+ scheduledBy?: string | undefined;
304
+ publishAt?: string | undefined;
305
+ warnings?: CheckIssue[] | undefined;
306
+ issues?: CheckIssue[] | undefined;
307
+ waitingBecause?: string | undefined;
308
+ comment?: string | undefined;
309
+ note?: string | undefined;
310
+ id: string;
311
+ actor: string;
312
+ status: import("../store/types.ts").ChangesetStatus;
313
+ }>;
314
+ /** Every version of an entry, newest first, with the fields each one changed. */
315
+ export declare function entryHistory(k: Kernel, actor: Actor, id: string): Promise<{
316
+ id: string;
317
+ model: string;
318
+ locale: string;
319
+ current: number | null;
320
+ versions: ({
321
+ deleted: boolean;
322
+ version: number;
323
+ at: string;
324
+ actor: string;
325
+ changeset: string | null;
326
+ } | {
327
+ changed: string[];
328
+ version: number;
329
+ at: string;
330
+ actor: string;
331
+ changeset: string | null;
332
+ })[];
333
+ }>;
334
+ /** One version's data, for reading or comparing. */
335
+ export declare function entryVersion(k: Kernel, actor: Actor, id: string, version: number): Promise<{
336
+ id: string;
337
+ model: string;
338
+ version: number;
339
+ at: string;
340
+ actor: string;
341
+ changeset: string | null;
342
+ deleted: boolean;
343
+ data: Record<string, unknown> | null;
344
+ }>;
345
+ /**
346
+ * Draft a change that brings an entry back to the state it had at `version`.
347
+ * A deleted entry is re-created with the same id. Replaces any draft of that entry in the caller's changeset.
348
+ */
349
+ export declare function restoreEntry(k: Kernel, actor: Actor, id: string, version: number): Promise<{
350
+ changeset: string;
351
+ op: "create" | "update" | "delete" | "install";
352
+ id: string;
353
+ model: string;
354
+ restores: number;
355
+ fields: string[];
356
+ next: string;
357
+ }>;
358
+ /** Draft the inverse of a merged changeset: creations are deleted, edits and deletions are undone. */
359
+ export declare function revertChangeset(k: Kernel, actor: Actor, id: string): Promise<{
360
+ changeset: string | undefined;
361
+ reverts: string;
362
+ items: {
363
+ op: string;
364
+ id: string;
365
+ }[];
366
+ next: string;
367
+ }>;