@clegra/sdk 0.0.0-stage → 0.1.0-next.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 (81) hide show
  1. package/CHANGELOG.md +152 -0
  2. package/LICENSE +21 -0
  3. package/NOTICE.md +25 -0
  4. package/README.md +258 -2
  5. package/dist/spec/kinds.json +211 -0
  6. package/dist/spec/schema/clegra.schema.json +1249 -0
  7. package/dist/spec/src/cli.d.ts +2 -0
  8. package/dist/spec/src/cli.js +21 -0
  9. package/dist/spec/src/cli.js.map +1 -0
  10. package/dist/spec/src/conformance.d.ts +34 -0
  11. package/dist/spec/src/conformance.js +703 -0
  12. package/dist/spec/src/conformance.js.map +1 -0
  13. package/dist/spec/src/init/index.d.ts +31 -0
  14. package/dist/spec/src/init/index.js +151 -0
  15. package/dist/spec/src/init/index.js.map +1 -0
  16. package/dist/spec/src/init/next-config.d.ts +19 -0
  17. package/dist/spec/src/init/next-config.js +77 -0
  18. package/dist/spec/src/init/next-config.js.map +1 -0
  19. package/dist/spec/src/init/project.d.ts +44 -0
  20. package/dist/spec/src/init/project.js +141 -0
  21. package/dist/spec/src/init/project.js.map +1 -0
  22. package/dist/spec/src/init/templates.d.ts +20 -0
  23. package/dist/spec/src/init/templates.js +166 -0
  24. package/dist/spec/src/init/templates.js.map +1 -0
  25. package/dist/spec/src/init/ui.d.ts +30 -0
  26. package/dist/spec/src/init/ui.js +82 -0
  27. package/dist/spec/src/init/ui.js.map +1 -0
  28. package/dist/spec/src/kinds.d.ts +89 -0
  29. package/dist/spec/src/kinds.js +319 -0
  30. package/dist/spec/src/kinds.js.map +1 -0
  31. package/dist/spec/src/protocol.d.ts +50 -0
  32. package/dist/spec/src/protocol.js +52 -0
  33. package/dist/spec/src/protocol.js.map +1 -0
  34. package/dist/spec/src/rules.d.ts +132 -0
  35. package/dist/spec/src/rules.js +282 -0
  36. package/dist/spec/src/rules.js.map +1 -0
  37. package/dist/src/auth.d.ts +371 -0
  38. package/dist/src/auth.js +964 -0
  39. package/dist/src/auth.js.map +1 -0
  40. package/dist/src/define.d.ts +249 -0
  41. package/dist/src/define.js +83 -0
  42. package/dist/src/define.js.map +1 -0
  43. package/dist/src/embed.d.ts +98 -0
  44. package/dist/src/embed.js +256 -0
  45. package/dist/src/embed.js.map +1 -0
  46. package/dist/src/index.d.ts +11 -0
  47. package/dist/src/index.js +11 -0
  48. package/dist/src/index.js.map +1 -0
  49. package/dist/src/labels.d.ts +10 -0
  50. package/dist/src/labels.js +22 -0
  51. package/dist/src/labels.js.map +1 -0
  52. package/dist/src/manifest.d.ts +499 -0
  53. package/dist/src/manifest.js +188 -0
  54. package/dist/src/manifest.js.map +1 -0
  55. package/dist/src/meaning.d.ts +64 -0
  56. package/dist/src/meaning.js +116 -0
  57. package/dist/src/meaning.js.map +1 -0
  58. package/dist/src/next/index.d.ts +101 -0
  59. package/dist/src/next/index.js +187 -0
  60. package/dist/src/next/index.js.map +1 -0
  61. package/dist/src/node.d.ts +14 -0
  62. package/dist/src/node.js +64 -0
  63. package/dist/src/node.js.map +1 -0
  64. package/dist/src/server.d.ts +229 -0
  65. package/dist/src/server.js +2256 -0
  66. package/dist/src/server.js.map +1 -0
  67. package/dist/src/store.d.ts +129 -0
  68. package/dist/src/store.js +213 -0
  69. package/dist/src/store.js.map +1 -0
  70. package/dist/src/testing.d.ts +133 -0
  71. package/dist/src/testing.js +81 -0
  72. package/dist/src/testing.js.map +1 -0
  73. package/dist/src/types.d.ts +352 -0
  74. package/dist/src/types.js +2 -0
  75. package/dist/src/types.js.map +1 -0
  76. package/dist/src/view.d.ts +35 -0
  77. package/dist/src/view.js +442 -0
  78. package/dist/src/view.js.map +1 -0
  79. package/docs/quickstart.md +350 -0
  80. package/docs/spec.md +997 -0
  81. package/package.json +89 -4
@@ -0,0 +1,132 @@
1
+ /**
2
+ * THE MANIFEST'S RULES BEYOND ITS SCHEMA, IN ONE PLACE: the publisher, navigation, page actions and badges, app-only items, schedules,
3
+ * notification types, targets, later runs and the reserved tools. The SDK runs them at definition time (a wrong name
4
+ * fails when the app starts) and the conformance checks run them from outside (`manifest.references`), so the two
5
+ * never disagree. Each problem names its place: `page "x": …`. No dependencies.
6
+ */
7
+ import { type KindDef } from "./kinds.js";
8
+ /** The bounds of the rules below (the JSON Schema carries the same ones). */
9
+ export declare const LIMITS: {
10
+ readonly pageActions: 8;
11
+ readonly schedules: 10;
12
+ readonly scheduleEvery: {
13
+ readonly min: 5;
14
+ readonly max: 1440;
15
+ };
16
+ readonly scheduleSeconds: {
17
+ readonly min: 1;
18
+ readonly max: 300;
19
+ readonly default: 60;
20
+ };
21
+ readonly targetsPerAction: 4;
22
+ readonly targetsPerApp: 12;
23
+ readonly targetLabel: 40;
24
+ readonly laterWindow: {
25
+ readonly min: 10;
26
+ readonly max: 10080;
27
+ readonly default: 60;
28
+ };
29
+ /** How often the SDK's own later schedule runs, in minutes. */
30
+ readonly laterEvery: 5;
31
+ readonly publisherName: 100;
32
+ readonly publisherUrl: 300;
33
+ };
34
+ /** The fields of an email a target may need (`mail.message`). */
35
+ export declare const MAIL_FIELDS: readonly ["subject", "from", "to", "date", "text", "attachments"];
36
+ /** A placeholder in a target's input template: `{field}` or `{field.sub}`. */
37
+ export declare const PLACEHOLDER: RegExp;
38
+ type Label = Record<string, string>;
39
+ type ToolRef = {
40
+ name: string;
41
+ plain: boolean;
42
+ };
43
+ type InputSchema = {
44
+ properties?: Record<string, {
45
+ type?: unknown;
46
+ format?: unknown;
47
+ }>;
48
+ required?: unknown;
49
+ };
50
+ /** What the rules read of a manifest (a subset of its shape). */
51
+ export type RulesManifest = {
52
+ publisher?: {
53
+ name: string;
54
+ url: string;
55
+ };
56
+ kinds?: Record<string, KindDef>;
57
+ entities: {
58
+ name: string;
59
+ tools: {
60
+ list: ToolRef;
61
+ get: ToolRef;
62
+ };
63
+ visibility?: string;
64
+ }[];
65
+ actions: {
66
+ name: string;
67
+ entity?: string;
68
+ input: InputSchema;
69
+ readOnly: boolean;
70
+ confirm: string;
71
+ tool: ToolRef;
72
+ visibility?: string;
73
+ targets?: {
74
+ target: string;
75
+ needs: string[];
76
+ input?: Record<string, unknown>;
77
+ label?: Label;
78
+ }[];
79
+ later?: {
80
+ at: string;
81
+ window: number;
82
+ };
83
+ }[];
84
+ pages: {
85
+ name: string;
86
+ kind: string;
87
+ tool: ToolRef;
88
+ actions?: string[];
89
+ badge?: string;
90
+ }[];
91
+ fragments: {
92
+ type: string;
93
+ entity?: string;
94
+ template?: string;
95
+ params: InputSchema;
96
+ tool: ToolRef;
97
+ visibility?: string;
98
+ }[];
99
+ agents: {
100
+ name: string;
101
+ tools: string[];
102
+ }[];
103
+ permissions: {
104
+ id: string;
105
+ }[];
106
+ nav?: {
107
+ section?: Label;
108
+ pages: string[];
109
+ }[];
110
+ schedules?: {
111
+ name: string;
112
+ action?: string;
113
+ tool: string;
114
+ every: number;
115
+ maxSeconds: number;
116
+ }[];
117
+ notifications?: {
118
+ type: string;
119
+ label: Label;
120
+ permission?: string;
121
+ }[];
122
+ };
123
+ /** The tools of the app-only items (entities' list and get, actions, fragments): what no model is ever given. */
124
+ export declare function appOnlyTools(m: Pick<RulesManifest, "entities" | "actions" | "fragments">): Map<string, string>;
125
+ /** The publisher's problems: a name (trimmed, no control characters) and an absolute https URL with a host. */
126
+ export declare function publisherProblems(publisher: {
127
+ name: string;
128
+ url: string;
129
+ }): string[];
130
+ /** Every rule of the list above that doesn't hold, each naming its place. Empty: they all hold. */
131
+ export declare function manifestRuleProblems(m: RulesManifest): string[];
132
+ export {};
@@ -0,0 +1,282 @@
1
+ /**
2
+ * THE MANIFEST'S RULES BEYOND ITS SCHEMA, IN ONE PLACE: the publisher, navigation, page actions and badges, app-only items, schedules,
3
+ * notification types, targets, later runs and the reserved tools. The SDK runs them at definition time (a wrong name
4
+ * fails when the app starts) and the conformance checks run them from outside (`manifest.references`), so the two
5
+ * never disagree. Each problem names its place: `page "x": …`. No dependencies.
6
+ */
7
+ import { KINDS, kindNameProblem, NAMESPACED_KIND, PROPERTY_NAME, propertyOf } from "./kinds.js";
8
+ import { INSTALLATION_TOOLS, LATER_TOOL } from "./protocol.js";
9
+ /** The bounds of the rules below (the JSON Schema carries the same ones). */
10
+ export const LIMITS = {
11
+ pageActions: 8,
12
+ schedules: 10,
13
+ scheduleEvery: { min: 5, max: 1440 },
14
+ scheduleSeconds: { min: 1, max: 300, default: 60 },
15
+ targetsPerAction: 4,
16
+ targetsPerApp: 12,
17
+ targetLabel: 40,
18
+ laterWindow: { min: 10, max: 10080, default: 60 },
19
+ /** How often the SDK's own later schedule runs, in minutes. */
20
+ laterEvery: 5,
21
+ publisherName: 100,
22
+ publisherUrl: 300,
23
+ };
24
+ /** The fields of an email a target may need (`mail.message`). */
25
+ export const MAIL_FIELDS = ["subject", "from", "to", "date", "text", "attachments"];
26
+ const IDENT = /^[a-z][a-z0-9_]{0,39}$/;
27
+ /** A placeholder in a target's input template: `{field}` or `{field.sub}`. */
28
+ export const PLACEHOLDER = /\{([A-Za-z][A-Za-z0-9_]*)(?:\.([A-Za-z][A-Za-z0-9_]*))?\}/g;
29
+ const requiredOf = (schema) => (Array.isArray(schema?.required) ? schema.required.filter((r) => typeof r === "string") : []);
30
+ const isInt = (n, min, max) => typeof n === "number" && Number.isInteger(n) && n >= min && n <= max;
31
+ /** The tools of the app-only items (entities' list and get, actions, fragments): what no model is ever given. */
32
+ export function appOnlyTools(m) {
33
+ const out = new Map();
34
+ for (const e of m.entities)
35
+ if (e.visibility === "app")
36
+ for (const t of [e.tools.list, e.tools.get])
37
+ out.set(t.name, `entity "${e.name}"`);
38
+ for (const a of m.actions)
39
+ if (a.visibility === "app")
40
+ out.set(a.tool.name, `action "${a.name}"`);
41
+ for (const f of m.fragments)
42
+ if (f.visibility === "app" && !f.entity)
43
+ out.set(f.tool.name, `fragment "${f.type}"`);
44
+ return out;
45
+ }
46
+ /** What a target may name in its input template: `uri`, a record's `title`, and the fields it needs. */
47
+ function targetProblems(where, t, input, own) {
48
+ const p = [];
49
+ let fields = null;
50
+ if (t.target === "mail.message")
51
+ fields = MAIL_FIELDS;
52
+ else if (t.target.startsWith("record:")) {
53
+ const kind = t.target.slice("record:".length);
54
+ const why = kindNameProblem(kind);
55
+ if (why)
56
+ return [`${where}: ${why}`];
57
+ // A kind this app defines or a published one: its properties are known. A namespaced kind of another app: only the names' form is.
58
+ const known = Object.hasOwn(KINDS, kind) || Boolean(own && Object.hasOwn(own, kind));
59
+ for (const n of t.needs) {
60
+ if (known ? !propertyOf(n, [kind], own) : !NAMESPACED_KIND.test(kind) || !PROPERTY_NAME.test(n))
61
+ p.push(known ? `${where}: "${n}" is not a property of kind ${kind}` : `${where}: "${n}" is not a property name`);
62
+ }
63
+ }
64
+ else
65
+ return [`${where}: target is mail.message or record:<kind>`];
66
+ if (fields)
67
+ for (const n of t.needs)
68
+ if (!fields.includes(n))
69
+ p.push(`${where}: "${n}" is not a field of ${t.target} (${fields.join(", ")})`);
70
+ if (new Set(t.needs).size !== t.needs.length)
71
+ p.push(`${where}: needs names a field twice`);
72
+ const record = t.target.startsWith("record:");
73
+ const available = new Set([...t.needs, "uri", ...(record ? ["title"] : [])]);
74
+ const props = input.properties ?? {};
75
+ const walk = (value, at) => {
76
+ if (typeof value === "string") {
77
+ for (const m of value.matchAll(PLACEHOLDER))
78
+ if (!available.has(m[1]))
79
+ p.push(`${where}: input ${at}: {${m[0].slice(1, -1)}} names "${m[1]}", which is not uri${record ? ", title" : ""} or a needed field`);
80
+ }
81
+ else if (Array.isArray(value))
82
+ value.forEach((v, i) => walk(v, `${at}[${i}]`));
83
+ else if (value && typeof value === "object")
84
+ for (const [k, v] of Object.entries(value))
85
+ walk(v, `${at}.${k}`);
86
+ };
87
+ for (const [k, v] of Object.entries(t.input ?? {})) {
88
+ if (!Object.hasOwn(props, k))
89
+ p.push(`${where}: input "${k}" is not an input of the action`);
90
+ walk(v, `"${k}"`);
91
+ }
92
+ for (const [locale, text] of Object.entries(t.label ?? {}))
93
+ if (text.length > LIMITS.targetLabel)
94
+ p.push(`${where}: label (${locale}) is longer than ${LIMITS.targetLabel} characters`);
95
+ return p;
96
+ }
97
+ /** The publisher's problems: a name (trimmed, no control characters) and an absolute https URL with a host. */
98
+ export function publisherProblems(publisher) {
99
+ const p = [];
100
+ const name = publisher.name;
101
+ if (name.trim() !== name || !name.length)
102
+ p.push("publisher: the name is empty or has spaces around it");
103
+ if (/[\u0000-\u001f\u007f]/.test(name))
104
+ p.push("publisher: the name has control characters");
105
+ if (name.length > LIMITS.publisherName)
106
+ p.push(`publisher: the name is longer than ${LIMITS.publisherName} characters`);
107
+ let url = null;
108
+ try {
109
+ url = new URL(publisher.url);
110
+ }
111
+ catch { }
112
+ if (!url || url.protocol !== "https:" || !url.hostname)
113
+ p.push(`publisher: url "${publisher.url}" is not an absolute https address`);
114
+ else if (url.username || url.password)
115
+ p.push("publisher: url carries credentials");
116
+ if (publisher.url.length > LIMITS.publisherUrl)
117
+ p.push(`publisher: url is longer than ${LIMITS.publisherUrl} characters`);
118
+ return p;
119
+ }
120
+ /** Every rule of the list above that doesn't hold, each naming its place. Empty: they all hold. */
121
+ export function manifestRuleProblems(m) {
122
+ const p = [];
123
+ const pages = new Map(m.pages.map((x) => [x.name, x]));
124
+ const actions = new Map(m.actions.map((a) => [a.name, a]));
125
+ const fragments = new Map(m.fragments.map((f) => [f.type, f]));
126
+ const permissions = new Set(m.permissions.map((x) => x.id));
127
+ // Reserved tools: the installation-level caller's, never an app's own.
128
+ const tools = [...m.entities.flatMap((e) => [e.tools.list.name, e.tools.get.name]), ...m.actions.map((a) => a.tool.name), ...m.pages.filter((x) => x.kind !== "record").map((x) => x.tool.name), ...m.fragments.filter((f) => !f.entity).map((f) => f.tool.name)];
129
+ for (const t of tools)
130
+ if (INSTALLATION_TOOLS.includes(t))
131
+ p.push(`tool "${t}" is reserved (the installation's own tools)`);
132
+ // The publisher: a claim, well-formed (spec §2).
133
+ if (m.publisher)
134
+ p.push(...publisherProblems(m.publisher));
135
+ // Navigation.
136
+ const seen = new Set();
137
+ for (const [i, s] of (m.nav ?? []).entries()) {
138
+ const where = `nav section ${i + 1}`;
139
+ if (!s.pages.length)
140
+ p.push(`${where}: no pages`);
141
+ for (const name of s.pages) {
142
+ const page = pages.get(name);
143
+ if (!page)
144
+ p.push(`${where}: "${name}" is not a page of this app`);
145
+ else if (page.kind === "record")
146
+ p.push(`${where}: "${name}" is a record page (records open from lists and links)`);
147
+ if (seen.has(name))
148
+ p.push(`${where}: page "${name}" is in the navigation twice`);
149
+ seen.add(name);
150
+ }
151
+ }
152
+ // Page actions and badges.
153
+ for (const page of m.pages) {
154
+ const where = `page "${page.name}"`;
155
+ if (page.actions?.length) {
156
+ if (page.kind === "record")
157
+ p.push(`${where}: a record page has no page actions (its record's actions are there)`);
158
+ if (page.actions.length > LIMITS.pageActions)
159
+ p.push(`${where}: at most ${LIMITS.pageActions} actions`);
160
+ if (new Set(page.actions).size !== page.actions.length)
161
+ p.push(`${where}: an action is named twice`);
162
+ for (const name of page.actions) {
163
+ const a = actions.get(name);
164
+ if (!a)
165
+ p.push(`${where}: "${name}" is not an action of this app`);
166
+ else if (a.entity)
167
+ p.push(`${where}: "${name}" works on one ${a.entity}: a page offers global actions`);
168
+ }
169
+ }
170
+ if (page.badge !== undefined) {
171
+ const f = fragments.get(page.badge);
172
+ if (page.kind === "record")
173
+ p.push(`${where}: a record page has no badge`);
174
+ if (!f || f.entity)
175
+ p.push(`${where}: badge "${page.badge}" is not a fragment type of this app`);
176
+ else {
177
+ if (f.template !== "stat")
178
+ p.push(`${where}: badge "${page.badge}" is not a stat fragment (its data.value is the count)`);
179
+ if (requiredOf(f.params).length)
180
+ p.push(`${where}: badge "${page.badge}" has required params (${requiredOf(f.params).join(", ")}); a badge is shown with none`);
181
+ }
182
+ }
183
+ }
184
+ // App-only items: no model gets them, the app's own agents included.
185
+ const appOnly = appOnlyTools(m);
186
+ for (const a of m.agents)
187
+ for (const t of a.tools)
188
+ if (appOnly.has(t))
189
+ p.push(`agent "${a.name}": ${t} is the tool of ${appOnly.get(t)}, which is app-only (visibility: "app"): no model gets it`);
190
+ // Targets.
191
+ let targets = 0;
192
+ for (const a of m.actions) {
193
+ const list = a.targets ?? [];
194
+ targets += list.length;
195
+ if (!list.length)
196
+ continue;
197
+ if (a.entity)
198
+ p.push(`action "${a.name}": targets are for global actions (a record action has its record already)`);
199
+ if (list.length > LIMITS.targetsPerAction)
200
+ p.push(`action "${a.name}": at most ${LIMITS.targetsPerAction} targets`);
201
+ for (const [i, t] of list.entries())
202
+ p.push(...targetProblems(`action "${a.name}", target ${i + 1} (${t.target})`, t, a.input, m.kinds));
203
+ }
204
+ if (targets > LIMITS.targetsPerApp)
205
+ p.push(`targets: at most ${LIMITS.targetsPerApp} in an app (${targets})`);
206
+ // Later runs.
207
+ const later = m.actions.filter((a) => a.later);
208
+ for (const a of later) {
209
+ const where = `action "${a.name}": later`;
210
+ if (a.readOnly || a.confirm !== "always")
211
+ p.push(`${where} is for a write the person confirms (confirm "always")`);
212
+ const at = a.input.properties?.[a.later.at];
213
+ if (!at)
214
+ p.push(`${where}: "${a.later.at}" is not an input of the action`);
215
+ else {
216
+ if (!requiredOf(a.input).includes(a.later.at))
217
+ p.push(`${where}: "${a.later.at}" must be a required input`);
218
+ if (at.type !== "string" || at.format !== "date-time")
219
+ p.push(`${where}: "${a.later.at}" must be a date-time string (z.iso.datetime())`);
220
+ }
221
+ if (!isInt(a.later.window, LIMITS.laterWindow.min, LIMITS.laterWindow.max))
222
+ p.push(`${where}: window is whole minutes from ${LIMITS.laterWindow.min} to ${LIMITS.laterWindow.max}`);
223
+ }
224
+ // Schedules.
225
+ const schedules = m.schedules ?? [];
226
+ const own = schedules.filter((s) => s.name !== LATER_TOOL);
227
+ if (own.length > LIMITS.schedules)
228
+ p.push(`schedules: at most ${LIMITS.schedules}`);
229
+ const names = new Set();
230
+ for (const s of schedules) {
231
+ const where = `schedule "${s.name}"`;
232
+ if (!IDENT.test(s.name))
233
+ p.push(`${where}: lowercase letters, digits and _, starting with a letter`);
234
+ if (names.has(s.name))
235
+ p.push(`${where} is declared twice`);
236
+ names.add(s.name);
237
+ if (!isInt(s.every, LIMITS.scheduleEvery.min, LIMITS.scheduleEvery.max))
238
+ p.push(`${where}: every is whole minutes from ${LIMITS.scheduleEvery.min} to ${LIMITS.scheduleEvery.max}`);
239
+ if (!isInt(s.maxSeconds, LIMITS.scheduleSeconds.min, LIMITS.scheduleSeconds.max))
240
+ p.push(`${where}: maxSeconds is whole seconds from ${LIMITS.scheduleSeconds.min} to ${LIMITS.scheduleSeconds.max}`);
241
+ if (s.name === LATER_TOOL) {
242
+ if (s.action !== undefined || s.tool !== LATER_TOOL || s.every !== LIMITS.laterEvery)
243
+ p.push(`${where} is reserved: the SDK's own, { tool: "${LATER_TOOL}", every: ${LIMITS.laterEvery} }, with no action`);
244
+ continue;
245
+ }
246
+ const a = s.action === undefined ? undefined : actions.get(s.action);
247
+ if (!a) {
248
+ p.push(`${where}: "${s.action ?? ""}" is not an action of this app`);
249
+ continue;
250
+ }
251
+ if (a.entity)
252
+ p.push(`${where}: "${a.name}" works on one ${a.entity}; a schedule runs a global action`);
253
+ if (requiredOf(a.input).length)
254
+ p.push(`${where}: "${a.name}" has required inputs (${requiredOf(a.input).join(", ")}); a schedule calls it with {}`);
255
+ if (!a.readOnly && a.confirm === "always")
256
+ p.push(`${where}: "${a.name}" is a write the person confirms (confirm "always"): nobody is there to confirm a scheduled run; use later for an approved write that runs afterwards`);
257
+ if (s.tool !== a.tool.name)
258
+ p.push(`${where}: tool ${s.tool} is not the tool of "${a.name}" (${a.tool.name})`);
259
+ }
260
+ if (later.length && !names.has(LATER_TOOL))
261
+ p.push(`schedules: actions with later need the schedule "${LATER_TOOL}"`);
262
+ if (!later.length && names.has(LATER_TOOL))
263
+ p.push(`schedule "${LATER_TOOL}": no action has later`);
264
+ // Notification types (the SDK's own `clegra_later` is there exactly when an action has later).
265
+ const types = new Set();
266
+ for (const n of m.notifications ?? []) {
267
+ const where = `notification "${n.type}"`;
268
+ if (n.type === LATER_TOOL && !later.length)
269
+ p.push(`${where} is reserved: the SDK's own, for later runs that did not run`);
270
+ if (!IDENT.test(n.type))
271
+ p.push(`${where}: lowercase letters, digits and _, starting with a letter`);
272
+ if (types.has(n.type))
273
+ p.push(`${where} is declared twice`);
274
+ types.add(n.type);
275
+ if (n.permission !== undefined && !permissions.has(n.permission))
276
+ p.push(`${where}: permission "${n.permission}" is not declared`);
277
+ }
278
+ if (later.length && !types.has(LATER_TOOL))
279
+ p.push(`notifications: actions with later need the type "${LATER_TOOL}" (their author is told when a run did not run)`);
280
+ return p;
281
+ }
282
+ //# sourceMappingURL=rules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rules.js","sourceRoot":"","sources":["../../../spec/src/rules.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,aAAa,EAAE,UAAU,EAAgB,MAAM,SAAS,CAAA;AAC1G,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA;AAE3D,6EAA6E;AAC7E,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,WAAW,EAAE,CAAC;IACd,SAAS,EAAE,EAAE;IACb,aAAa,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,IAAI,EAAE;IACpC,eAAe,EAAE,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE;IAClD,gBAAgB,EAAE,CAAC;IACnB,aAAa,EAAE,EAAE;IACjB,WAAW,EAAE,EAAE;IACf,WAAW,EAAE,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE;IACjD,+DAA+D;IAC/D,UAAU,EAAE,CAAC;IACb,aAAa,EAAE,GAAG;IAClB,YAAY,EAAE,GAAG;CACT,C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AAA;IACnK,OAAO,CAAC,CAAA;AACV,CAAC","sourcesContent":["/**\n * THE MANIFEST'S RULES BEYOND ITS SCHEMA, IN ONE PLACE: the publisher, navigation, page actions and badges, app-only items, schedules,\n * notification types, targets, later runs and the reserved tools. The SDK runs them at definition time (a wrong name\n * fails when the app starts) and the conformance checks run them from outside (`manifest.references`), so the two\n * never disagree. Each problem names its place: `page \"x\": …`. No dependencies.\n */\n\nimport { KINDS, kindNameProblem, NAMESPACED_KIND, PROPERTY_NAME, propertyOf, type KindDef } from \"./kinds\"\nimport { INSTALLATION_TOOLS, LATER_TOOL } from \"./protocol\"\n\n/** The bounds of the rules below (the JSON Schema carries the same ones). */\nexport const LIMITS = {\n pageActions: 8,\n schedules: 10,\n scheduleEvery: { min: 5, max: 1440 },\n scheduleSeconds: { min: 1, max: 300, default: 60 },\n targetsPerAction: 4,\n targetsPerApp: 12,\n targetLabel: 40,\n laterWindow: { min: 10, max: 10080, default: 60 },\n /** How often the SDK's own later schedule runs, in minutes. */\n laterEvery: 5,\n publisherName: 100,\n publisherUrl: 300,\n} as const\n\n/** The fields of an email a target may need (`mail.message`). */\nexport const MAIL_FIELDS = [\"subject\", \"from\", \"to\", \"date\", \"text\", \"attachments\"] as const\n\nconst IDENT = /^[a-z][a-z0-9_]{0,39}$/\n/** A placeholder in a target's input template: `{field}` or `{field.sub}`. */\nexport const PLACEHOLDER = /\\{([A-Za-z][A-Za-z0-9_]*)(?:\\.([A-Za-z][A-Za-z0-9_]*))?\\}/g\n\ntype Label = Record<string, string>\ntype ToolRef = { name: string; plain: boolean }\ntype InputSchema = { properties?: Record<string, { type?: unknown; format?: unknown }>; required?: unknown }\n\n/** What the rules read of a manifest (a subset of its shape). */\nexport type RulesManifest = {\n publisher?: { name: string; url: string }\n kinds?: Record<string, KindDef>\n entities: { name: string; tools: { list: ToolRef; get: ToolRef }; visibility?: string }[]\n actions: {\n name: string\n entity?: string\n input: InputSchema\n readOnly: boolean\n confirm: string\n tool: ToolRef\n visibility?: string\n targets?: { target: string; needs: string[]; input?: Record<string, unknown>; label?: Label }[]\n later?: { at: string; window: number }\n }[]\n pages: { name: string; kind: string; tool: ToolRef; actions?: string[]; badge?: string }[]\n fragments: { type: string; entity?: string; template?: string; params: InputSchema; tool: ToolRef; visibility?: string }[]\n agents: { name: string; tools: string[] }[]\n permissions: { id: string }[]\n nav?: { section?: Label; pages: string[] }[]\n schedules?: { name: string; action?: string; tool: string; every: number; maxSeconds: number }[]\n notifications?: { type: string; label: Label; permission?: string }[]\n}\n\nconst requiredOf = (schema: InputSchema | undefined): string[] => (Array.isArray(schema?.required) ? (schema!.required as unknown[]).filter((r): r is string => typeof r === \"string\") : [])\nconst isInt = (n: unknown, min: number, max: number) => typeof n === \"number\" && Number.isInteger(n) && n >= min && n <= max\n\n/** The tools of the app-only items (entities' list and get, actions, fragments): what no model is ever given. */\nexport function appOnlyTools(m: Pick<RulesManifest, \"entities\" | \"actions\" | \"fragments\">): Map<string, string> {\n const out = new Map<string, string>()\n for (const e of m.entities) if (e.visibility === \"app\") for (const t of [e.tools.list, e.tools.get]) out.set(t.name, `entity \"${e.name}\"`)\n for (const a of m.actions) if (a.visibility === \"app\") out.set(a.tool.name, `action \"${a.name}\"`)\n for (const f of m.fragments) if (f.visibility === \"app\" && !f.entity) out.set(f.tool.name, `fragment \"${f.type}\"`)\n return out\n}\n\n/** What a target may name in its input template: `uri`, a record's `title`, and the fields it needs. */\nfunction targetProblems(where: string, t: NonNullable<RulesManifest[\"actions\"][number][\"targets\"]>[number], input: InputSchema, own: Record<string, KindDef> | undefined): string[] {\n const p: string[] = []\n let fields: readonly string[] | null = null\n if (t.target === \"mail.message\") fields = MAIL_FIELDS\n else if (t.target.startsWith(\"record:\")) {\n const kind = t.target.slice(\"record:\".length)\n const why = kindNameProblem(kind)\n if (why) return [`${where}: ${why}`]\n // A kind this app defines or a published one: its properties are known. A namespaced kind of another app: only the names' form is.\n const known = Object.hasOwn(KINDS, kind) || Boolean(own && Object.hasOwn(own, kind))\n for (const n of t.needs) {\n if (known ? !propertyOf(n, [kind], own) : !NAMESPACED_KIND.test(kind) || !PROPERTY_NAME.test(n)) p.push(known ? `${where}: \"${n}\" is not a property of kind ${kind}` : `${where}: \"${n}\" is not a property name`)\n }\n } else return [`${where}: target is mail.message or record:<kind>`]\n if (fields) for (const n of t.needs) if (!fields.includes(n)) p.push(`${where}: \"${n}\" is not a field of ${t.target} (${fields.join(\", \")})`)\n if (new Set(t.needs).size !== t.needs.length) p.push(`${where}: needs names a field twice`)\n const record = t.target.startsWith(\"record:\")\n const available = new Set([...t.needs, \"uri\", ...(record ? [\"title\"] : [])])\n const props = input.properties ?? {}\n const walk = (value: unknown, at: string) => {\n if (typeof value === \"string\") {\n for (const m of value.matchAll(PLACEHOLDER)) if (!available.has(m[1]!)) p.push(`${where}: input ${at}: {${m[0].slice(1, -1)}} names \"${m[1]}\", which is not uri${record ? \", title\" : \"\"} or a needed field`)\n } else if (Array.isArray(value)) value.forEach((v, i) => walk(v, `${at}[${i}]`))\n else if (value && typeof value === \"object\") for (const [k, v] of Object.entries(value)) walk(v, `${at}.${k}`)\n }\n for (const [k, v] of Object.entries(t.input ?? {})) {\n if (!Object.hasOwn(props, k)) p.push(`${where}: input \"${k}\" is not an input of the action`)\n walk(v, `\"${k}\"`)\n }\n for (const [locale, text] of Object.entries(t.label ?? {})) if (text.length > LIMITS.targetLabel) p.push(`${where}: label (${locale}) is longer than ${LIMITS.targetLabel} characters`)\n return p\n}\n\n/** The publisher's problems: a name (trimmed, no control characters) and an absolute https URL with a host. */\nexport function publisherProblems(publisher: { name: string; url: string }): string[] {\n const p: string[] = []\n const name = publisher.name\n if (name.trim() !== name || !name.length) p.push(\"publisher: the name is empty or has spaces around it\")\n if (/[\\u0000-\\u001f\\u007f]/.test(name)) p.push(\"publisher: the name has control characters\")\n if (name.length > LIMITS.publisherName) p.push(`publisher: the name is longer than ${LIMITS.publisherName} characters`)\n let url: URL | null = null\n try {\n url = new URL(publisher.url)\n } catch {}\n if (!url || url.protocol !== \"https:\" || !url.hostname) p.push(`publisher: url \"${publisher.url}\" is not an absolute https address`)\n else if (url.username || url.password) p.push(\"publisher: url carries credentials\")\n if (publisher.url.length > LIMITS.publisherUrl) p.push(`publisher: url is longer than ${LIMITS.publisherUrl} characters`)\n return p\n}\n\n/** Every rule of the list above that doesn't hold, each naming its place. Empty: they all hold. */\nexport function manifestRuleProblems(m: RulesManifest): string[] {\n const p: string[] = []\n const pages = new Map(m.pages.map((x) => [x.name, x]))\n const actions = new Map(m.actions.map((a) => [a.name, a]))\n const fragments = new Map(m.fragments.map((f) => [f.type, f]))\n const permissions = new Set(m.permissions.map((x) => x.id))\n\n // Reserved tools: the installation-level caller's, never an app's own.\n const tools = [...m.entities.flatMap((e) => [e.tools.list.name, e.tools.get.name]), ...m.actions.map((a) => a.tool.name), ...m.pages.filter((x) => x.kind !== \"record\").map((x) => x.tool.name), ...m.fragments.filter((f) => !f.entity).map((f) => f.tool.name)]\n for (const t of tools) if ((INSTALLATION_TOOLS as readonly string[]).includes(t)) p.push(`tool \"${t}\" is reserved (the installation's own tools)`)\n\n // The publisher: a claim, well-formed (spec §2).\n if (m.publisher) p.push(...publisherProblems(m.publisher))\n\n // Navigation.\n const seen = new Set<string>()\n for (const [i, s] of (m.nav ?? []).entries()) {\n const where = `nav section ${i + 1}`\n if (!s.pages.length) p.push(`${where}: no pages`)\n for (const name of s.pages) {\n const page = pages.get(name)\n if (!page) p.push(`${where}: \"${name}\" is not a page of this app`)\n else if (page.kind === \"record\") p.push(`${where}: \"${name}\" is a record page (records open from lists and links)`)\n if (seen.has(name)) p.push(`${where}: page \"${name}\" is in the navigation twice`)\n seen.add(name)\n }\n }\n\n // Page actions and badges.\n for (const page of m.pages) {\n const where = `page \"${page.name}\"`\n if (page.actions?.length) {\n if (page.kind === \"record\") p.push(`${where}: a record page has no page actions (its record's actions are there)`)\n if (page.actions.length > LIMITS.pageActions) p.push(`${where}: at most ${LIMITS.pageActions} actions`)\n if (new Set(page.actions).size !== page.actions.length) p.push(`${where}: an action is named twice`)\n for (const name of page.actions) {\n const a = actions.get(name)\n if (!a) p.push(`${where}: \"${name}\" is not an action of this app`)\n else if (a.entity) p.push(`${where}: \"${name}\" works on one ${a.entity}: a page offers global actions`)\n }\n }\n if (page.badge !== undefined) {\n const f = fragments.get(page.badge)\n if (page.kind === \"record\") p.push(`${where}: a record page has no badge`)\n if (!f || f.entity) p.push(`${where}: badge \"${page.badge}\" is not a fragment type of this app`)\n else {\n if (f.template !== \"stat\") p.push(`${where}: badge \"${page.badge}\" is not a stat fragment (its data.value is the count)`)\n if (requiredOf(f.params).length) p.push(`${where}: badge \"${page.badge}\" has required params (${requiredOf(f.params).join(\", \")}); a badge is shown with none`)\n }\n }\n }\n\n // App-only items: no model gets them, the app's own agents included.\n const appOnly = appOnlyTools(m)\n for (const a of m.agents) for (const t of a.tools) if (appOnly.has(t)) p.push(`agent \"${a.name}\": ${t} is the tool of ${appOnly.get(t)}, which is app-only (visibility: \"app\"): no model gets it`)\n\n // Targets.\n let targets = 0\n for (const a of m.actions) {\n const list = a.targets ?? []\n targets += list.length\n if (!list.length) continue\n if (a.entity) p.push(`action \"${a.name}\": targets are for global actions (a record action has its record already)`)\n if (list.length > LIMITS.targetsPerAction) p.push(`action \"${a.name}\": at most ${LIMITS.targetsPerAction} targets`)\n for (const [i, t] of list.entries()) p.push(...targetProblems(`action \"${a.name}\", target ${i + 1} (${t.target})`, t, a.input, m.kinds))\n }\n if (targets > LIMITS.targetsPerApp) p.push(`targets: at most ${LIMITS.targetsPerApp} in an app (${targets})`)\n\n // Later runs.\n const later = m.actions.filter((a) => a.later)\n for (const a of later) {\n const where = `action \"${a.name}\": later`\n if (a.readOnly || a.confirm !== \"always\") p.push(`${where} is for a write the person confirms (confirm \"always\")`)\n const at = a.input.properties?.[a.later!.at]\n if (!at) p.push(`${where}: \"${a.later!.at}\" is not an input of the action`)\n else {\n if (!requiredOf(a.input).includes(a.later!.at)) p.push(`${where}: \"${a.later!.at}\" must be a required input`)\n if (at.type !== \"string\" || at.format !== \"date-time\") p.push(`${where}: \"${a.later!.at}\" must be a date-time string (z.iso.datetime())`)\n }\n if (!isInt(a.later!.window, LIMITS.laterWindow.min, LIMITS.laterWindow.max)) p.push(`${where}: window is whole minutes from ${LIMITS.laterWindow.min} to ${LIMITS.laterWindow.max}`)\n }\n\n // Schedules.\n const schedules = m.schedules ?? []\n const own = schedules.filter((s) => s.name !== LATER_TOOL)\n if (own.length > LIMITS.schedules) p.push(`schedules: at most ${LIMITS.schedules}`)\n const names = new Set<string>()\n for (const s of schedules) {\n const where = `schedule \"${s.name}\"`\n if (!IDENT.test(s.name)) p.push(`${where}: lowercase letters, digits and _, starting with a letter`)\n if (names.has(s.name)) p.push(`${where} is declared twice`)\n names.add(s.name)\n if (!isInt(s.every, LIMITS.scheduleEvery.min, LIMITS.scheduleEvery.max)) p.push(`${where}: every is whole minutes from ${LIMITS.scheduleEvery.min} to ${LIMITS.scheduleEvery.max}`)\n if (!isInt(s.maxSeconds, LIMITS.scheduleSeconds.min, LIMITS.scheduleSeconds.max)) p.push(`${where}: maxSeconds is whole seconds from ${LIMITS.scheduleSeconds.min} to ${LIMITS.scheduleSeconds.max}`)\n if (s.name === LATER_TOOL) {\n if (s.action !== undefined || s.tool !== LATER_TOOL || s.every !== LIMITS.laterEvery) p.push(`${where} is reserved: the SDK's own, { tool: \"${LATER_TOOL}\", every: ${LIMITS.laterEvery} }, with no action`)\n continue\n }\n const a = s.action === undefined ? undefined : actions.get(s.action)\n if (!a) {\n p.push(`${where}: \"${s.action ?? \"\"}\" is not an action of this app`)\n continue\n }\n if (a.entity) p.push(`${where}: \"${a.name}\" works on one ${a.entity}; a schedule runs a global action`)\n if (requiredOf(a.input).length) p.push(`${where}: \"${a.name}\" has required inputs (${requiredOf(a.input).join(\", \")}); a schedule calls it with {}`)\n if (!a.readOnly && a.confirm === \"always\") p.push(`${where}: \"${a.name}\" is a write the person confirms (confirm \"always\"): nobody is there to confirm a scheduled run; use later for an approved write that runs afterwards`)\n if (s.tool !== a.tool.name) p.push(`${where}: tool ${s.tool} is not the tool of \"${a.name}\" (${a.tool.name})`)\n }\n if (later.length && !names.has(LATER_TOOL)) p.push(`schedules: actions with later need the schedule \"${LATER_TOOL}\"`)\n if (!later.length && names.has(LATER_TOOL)) p.push(`schedule \"${LATER_TOOL}\": no action has later`)\n\n // Notification types (the SDK's own `clegra_later` is there exactly when an action has later).\n const types = new Set<string>()\n for (const n of m.notifications ?? []) {\n const where = `notification \"${n.type}\"`\n if (n.type === LATER_TOOL && !later.length) p.push(`${where} is reserved: the SDK's own, for later runs that did not run`)\n if (!IDENT.test(n.type)) p.push(`${where}: lowercase letters, digits and _, starting with a letter`)\n if (types.has(n.type)) p.push(`${where} is declared twice`)\n types.add(n.type)\n if (n.permission !== undefined && !permissions.has(n.permission)) p.push(`${where}: permission \"${n.permission}\" is not declared`)\n }\n if (later.length && !types.has(LATER_TOOL)) p.push(`notifications: actions with later need the type \"${LATER_TOOL}\" (their author is told when a run did not run)`)\n return p\n}\n"]}