@serene-pub/sdk 0.6.0-pr-1

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 (187) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +17 -0
  3. package/README.md +368 -0
  4. package/dist/actions.d.ts +572 -0
  5. package/dist/actions.js +829 -0
  6. package/dist/annexFields.d.ts +234 -0
  7. package/dist/annexFields.js +413 -0
  8. package/dist/announce.d.ts +464 -0
  9. package/dist/announce.js +426 -0
  10. package/dist/attributes.d.ts +670 -0
  11. package/dist/attributes.js +904 -0
  12. package/dist/bands.d.ts +125 -0
  13. package/dist/bands.js +256 -0
  14. package/dist/builder.d.ts +683 -0
  15. package/dist/builder.js +677 -0
  16. package/dist/candidates.d.ts +109 -0
  17. package/dist/candidates.js +118 -0
  18. package/dist/capabilities.d.ts +744 -0
  19. package/dist/capabilities.js +679 -0
  20. package/dist/channels.d.ts +106 -0
  21. package/dist/channels.js +129 -0
  22. package/dist/clauses.d.ts +40 -0
  23. package/dist/clauses.js +43 -0
  24. package/dist/component.d.ts +33 -0
  25. package/dist/component.js +27 -0
  26. package/dist/componentBuild.d.ts +48 -0
  27. package/dist/componentBuild.js +84 -0
  28. package/dist/componentClient.d.ts +100 -0
  29. package/dist/componentClient.js +13 -0
  30. package/dist/componentImports.d.ts +51 -0
  31. package/dist/componentImports.js +106 -0
  32. package/dist/componentModule.d.ts +8 -0
  33. package/dist/componentModule.js +270 -0
  34. package/dist/componentWire.d.ts +130 -0
  35. package/dist/componentWire.js +280 -0
  36. package/dist/config.d.ts +295 -0
  37. package/dist/config.js +231 -0
  38. package/dist/connections.d.ts +89 -0
  39. package/dist/connections.js +131 -0
  40. package/dist/declarations.d.ts +290 -0
  41. package/dist/declarations.js +794 -0
  42. package/dist/descriptors.d.ts +1774 -0
  43. package/dist/descriptors.js +1329 -0
  44. package/dist/dev.d.ts +136 -0
  45. package/dist/dev.js +161 -0
  46. package/dist/document.d.ts +202 -0
  47. package/dist/document.js +312 -0
  48. package/dist/engines.d.ts +117 -0
  49. package/dist/engines.js +203 -0
  50. package/dist/eventMapLaws.d.ts +63 -0
  51. package/dist/eventMapLaws.js +128 -0
  52. package/dist/events.d.ts +554 -0
  53. package/dist/events.js +633 -0
  54. package/dist/executor.d.ts +771 -0
  55. package/dist/executor.js +1829 -0
  56. package/dist/extension.d.ts +448 -0
  57. package/dist/extension.js +315 -0
  58. package/dist/facets.d.ts +53 -0
  59. package/dist/facets.js +60 -0
  60. package/dist/foldedSections.d.ts +74 -0
  61. package/dist/foldedSections.js +161 -0
  62. package/dist/genres.d.ts +507 -0
  63. package/dist/genres.js +633 -0
  64. package/dist/guardedConnection.d.ts +138 -0
  65. package/dist/guardedConnection.js +341 -0
  66. package/dist/handlebarsReach.d.ts +122 -0
  67. package/dist/handlebarsReach.js +222 -0
  68. package/dist/hash.d.ts +146 -0
  69. package/dist/hash.js +166 -0
  70. package/dist/hookGrants.d.ts +47 -0
  71. package/dist/hookGrants.js +68 -0
  72. package/dist/hooks.d.ts +290 -0
  73. package/dist/hooks.js +113 -0
  74. package/dist/hostElements.d.ts +447 -0
  75. package/dist/hostElements.js +702 -0
  76. package/dist/i18n.d.ts +94 -0
  77. package/dist/i18n.js +123 -0
  78. package/dist/identity.d.ts +93 -0
  79. package/dist/identity.js +135 -0
  80. package/dist/index.d.ts +85 -0
  81. package/dist/index.js +176 -0
  82. package/dist/layout.d.ts +194 -0
  83. package/dist/layout.js +40 -0
  84. package/dist/media.d.ts +202 -0
  85. package/dist/media.js +70 -0
  86. package/dist/messageBlocks.d.ts +487 -0
  87. package/dist/messageBlocks.js +683 -0
  88. package/dist/migration.d.ts +128 -0
  89. package/dist/migration.js +261 -0
  90. package/dist/names.d.ts +78 -0
  91. package/dist/names.js +136 -0
  92. package/dist/nodeInput.d.ts +399 -0
  93. package/dist/nodeInput.js +178 -0
  94. package/dist/participants.d.ts +291 -0
  95. package/dist/participants.js +252 -0
  96. package/dist/personGate.d.ts +62 -0
  97. package/dist/personGate.js +77 -0
  98. package/dist/pick.d.ts +84 -0
  99. package/dist/pick.js +103 -0
  100. package/dist/pluginHarness.d.ts +235 -0
  101. package/dist/pluginHarness.js +558 -0
  102. package/dist/pluginPermissions.d.ts +25 -0
  103. package/dist/pluginPermissions.js +97 -0
  104. package/dist/pluginRuleRef.d.ts +13 -0
  105. package/dist/pluginRuleRef.js +10 -0
  106. package/dist/predicates.d.ts +182 -0
  107. package/dist/predicates.js +249 -0
  108. package/dist/preview.d.ts +120 -0
  109. package/dist/preview.js +82 -0
  110. package/dist/promptBlocks.d.ts +130 -0
  111. package/dist/promptBlocks.js +197 -0
  112. package/dist/rankingDecisions.d.ts +60 -0
  113. package/dist/rankingDecisions.js +48 -0
  114. package/dist/receipt.d.ts +313 -0
  115. package/dist/receipt.js +60 -0
  116. package/dist/receiverRules.d.ts +24 -0
  117. package/dist/receiverRules.js +94 -0
  118. package/dist/refs.d.ts +117 -0
  119. package/dist/refs.js +137 -0
  120. package/dist/registry.d.ts +230 -0
  121. package/dist/registry.js +273 -0
  122. package/dist/review.d.ts +108 -0
  123. package/dist/review.js +97 -0
  124. package/dist/sampling.d.ts +152 -0
  125. package/dist/sampling.js +712 -0
  126. package/dist/scope.d.ts +65 -0
  127. package/dist/scope.js +128 -0
  128. package/dist/scripts.d.ts +243 -0
  129. package/dist/scripts.js +326 -0
  130. package/dist/sessionLayout.d.ts +339 -0
  131. package/dist/sessionLayout.js +503 -0
  132. package/dist/sessionSettings.d.ts +70 -0
  133. package/dist/sessionSettings.js +2 -0
  134. package/dist/settings.d.ts +501 -0
  135. package/dist/settings.js +604 -0
  136. package/dist/settingsSlot.d.ts +108 -0
  137. package/dist/settingsSlot.js +166 -0
  138. package/dist/shapes.d.ts +373 -0
  139. package/dist/shapes.js +408 -0
  140. package/dist/sheets.d.ts +165 -0
  141. package/dist/sheets.js +251 -0
  142. package/dist/statShapes.d.ts +96 -0
  143. package/dist/statShapes.js +112 -0
  144. package/dist/status.d.ts +103 -0
  145. package/dist/status.js +125 -0
  146. package/dist/storage.d.ts +145 -0
  147. package/dist/storage.js +33 -0
  148. package/dist/storyTime.d.ts +308 -0
  149. package/dist/storyTime.js +560 -0
  150. package/dist/surfaces.d.ts +501 -0
  151. package/dist/surfaces.js +292 -0
  152. package/dist/template.d.ts +312 -0
  153. package/dist/template.js +554 -0
  154. package/dist/templateCheck.d.ts +60 -0
  155. package/dist/templateCheck.js +516 -0
  156. package/dist/templateFit.d.ts +157 -0
  157. package/dist/templateFit.js +349 -0
  158. package/dist/templateIds.d.ts +138 -0
  159. package/dist/templateIds.js +144 -0
  160. package/dist/templateScopeAt.d.ts +131 -0
  161. package/dist/templateScopeAt.js +354 -0
  162. package/dist/testing.d.ts +177 -0
  163. package/dist/testing.js +383 -0
  164. package/dist/tokenizers.d.ts +113 -0
  165. package/dist/tokenizers.js +184 -0
  166. package/dist/turnLock.d.ts +96 -0
  167. package/dist/turnLock.js +79 -0
  168. package/dist/turnOrder.d.ts +143 -0
  169. package/dist/turnOrder.js +128 -0
  170. package/dist/validate.d.ts +74 -0
  171. package/dist/validate.js +1399 -0
  172. package/dist/values.d.ts +212 -0
  173. package/dist/values.js +390 -0
  174. package/dist/variables.d.ts +493 -0
  175. package/dist/variables.js +662 -0
  176. package/dist/verdicts.d.ts +275 -0
  177. package/dist/verdicts.js +348 -0
  178. package/dist/widgetDecls.d.ts +88 -0
  179. package/dist/widgetDecls.js +119 -0
  180. package/dist/widgets.d.ts +1527 -0
  181. package/dist/widgets.js +208 -0
  182. package/dist/wire.d.ts +126 -0
  183. package/dist/wire.js +140 -0
  184. package/dist/worldinfo.d.ts +150 -0
  185. package/dist/worldinfo.js +212 -0
  186. package/host-elements.d.ts +914 -0
  187. package/package.json +67 -0
package/dist/i18n.d.ts ADDED
@@ -0,0 +1,94 @@
1
+ /**
2
+ * Display text (plans/29 R-20; plans/30 U5i) — one type, one check, one
3
+ * resolver.
4
+ *
5
+ * Every string an author writes for a person to read — a definition's name, a
6
+ * slot's description, an action's label, a preset's title, a status — is
7
+ * `I18n`: a bare string or a **locale map**. The two spellings are one value:
8
+ * `title: 'Title'` is `title: { en: 'Title' }` (ruled 2026-09-17, which
9
+ * supersedes 09-B B11's "a bare string is refused"). A bare string reads as
10
+ * `en`, and `en` is the locale every other falls back to.
11
+ *
12
+ * ## Enforced at publish
13
+ *
14
+ * A publish refuses exactly four things, each with a sentence that names the
15
+ * field and says what to write instead:
16
+ *
17
+ * · a locale map without a string `en`;
18
+ * · an `en` (or a bare string) that is empty or whitespace;
19
+ * · any other value — a number, an array, `null`, an object without `en`;
20
+ * · absence, where the field is required.
21
+ *
22
+ * Every door runs `i18nFindings`: `register()` for a definition and its slots,
23
+ * `genre()` and `envoyFindings`, the attribute slot and sheet doors,
24
+ * `defineScriptKind`, a value declaration, `config()` / `preset()` /
25
+ * `announce.build()`, the widget declarations a shape carries, an action's
26
+ * label, an enabled-when's reason, `validate()` for a stored document, the CLI
27
+ * packager for a manifest, and the executor for a status (a note on the
28
+ * receipt, the status dropped — a status is advisory and never halts a run).
29
+ *
30
+ * ## Exempt by rule
31
+ *
32
+ * Not everything a person reads is display text an author declared. A **slash
33
+ * name** is an id (`/narrate`); a **receipt note** is the executor's record;
34
+ * a form block's `question`, its option labels, a `kv` or `stat` label are the
35
+ * runtime output of a pipeline; **message content** is the user's; a
36
+ * **permission id** is an address. None of these is localised and none is
37
+ * checked here.
38
+ *
39
+ * ## Reading it
40
+ *
41
+ * `i18nText(v, language)` is the one resolver: a bare string is itself; a map
42
+ * answers the requested locale, else `en`. After publish enforcement a
43
+ * malformed value cannot reach a reader, so a malformed value answers
44
+ * `undefined` rather than being patched over — nothing swallows one silently.
45
+ */
46
+ /** A locale map: `en` required, any other language code beside it. @public */
47
+ export type LocaleMap = {
48
+ en: string;
49
+ } & Record<string, string>;
50
+ /** Author-facing display text: a bare string (read as `en`) or a locale map. @public */
51
+ export type I18n = string | LocaleMap;
52
+ /**
53
+ * `I18nText` is the settings vocabulary's spelling of the same type — one
54
+ * definition, two names, so every contract written against either keeps
55
+ * compiling.
56
+ * @experimental
57
+ */
58
+ export type I18nText = I18n;
59
+ /** Has the value the shape of a locale map — an object, not an array, with a string `en`? @experimental */
60
+ export declare const isLocaleMap: (v: unknown) => v is LocaleMap;
61
+ /**
62
+ * Is this display text a publish accepts — a non-blank string, or a locale map
63
+ * whose `en` is non-blank? A map with only `fr` is not: `en` is the fallback
64
+ * every other locale rests on.
65
+ * @experimental
66
+ */
67
+ export declare const isI18n: (v: unknown) => v is I18n;
68
+ /** A bare `en` string is the short spelling of `{ en }`; a map is itself. @internal */
69
+ export declare const localeMapOf: (v: I18n) => LocaleMap;
70
+ /**
71
+ * Every fault in one display-text value, as sentences that name the field and
72
+ * say what to write instead (the teaching-error pattern, 15 §1.3). Empty when
73
+ * the value is sound, and for an absent optional value; `required` makes
74
+ * absence a finding.
75
+ *
76
+ * `where` is the field's address as the author sees it (`acme:task/roll@1
77
+ * i18n.name`, `contributes.actions[roll].label`), so the sentence can be
78
+ * acted on without a search.
79
+ * @experimental
80
+ */
81
+ export declare function i18nFindings(v: unknown, where: string, opts?: {
82
+ required?: boolean;
83
+ }): string[];
84
+ /**
85
+ * The display text of an `I18n` in `language`: a bare string is itself; a map
86
+ * answers the requested locale, else `en`. A locale the map carries as blank
87
+ * counts as absent — a half-translated map is the normal state of one, and a
88
+ * blank label is never the right answer. `undefined` for a value that is not
89
+ * `I18n` at all: publish enforcement keeps those from a reader, so a reader
90
+ * does not paper over one.
91
+ * @public
92
+ */
93
+ export declare function i18nText(v: I18n | undefined, language?: string): string | undefined;
94
+ //# sourceMappingURL=i18n.d.ts.map
package/dist/i18n.js ADDED
@@ -0,0 +1,123 @@
1
+ /**
2
+ * Display text (plans/29 R-20; plans/30 U5i) — one type, one check, one
3
+ * resolver.
4
+ *
5
+ * Every string an author writes for a person to read — a definition's name, a
6
+ * slot's description, an action's label, a preset's title, a status — is
7
+ * `I18n`: a bare string or a **locale map**. The two spellings are one value:
8
+ * `title: 'Title'` is `title: { en: 'Title' }` (ruled 2026-09-17, which
9
+ * supersedes 09-B B11's "a bare string is refused"). A bare string reads as
10
+ * `en`, and `en` is the locale every other falls back to.
11
+ *
12
+ * ## Enforced at publish
13
+ *
14
+ * A publish refuses exactly four things, each with a sentence that names the
15
+ * field and says what to write instead:
16
+ *
17
+ * · a locale map without a string `en`;
18
+ * · an `en` (or a bare string) that is empty or whitespace;
19
+ * · any other value — a number, an array, `null`, an object without `en`;
20
+ * · absence, where the field is required.
21
+ *
22
+ * Every door runs `i18nFindings`: `register()` for a definition and its slots,
23
+ * `genre()` and `envoyFindings`, the attribute slot and sheet doors,
24
+ * `defineScriptKind`, a value declaration, `config()` / `preset()` /
25
+ * `announce.build()`, the widget declarations a shape carries, an action's
26
+ * label, an enabled-when's reason, `validate()` for a stored document, the CLI
27
+ * packager for a manifest, and the executor for a status (a note on the
28
+ * receipt, the status dropped — a status is advisory and never halts a run).
29
+ *
30
+ * ## Exempt by rule
31
+ *
32
+ * Not everything a person reads is display text an author declared. A **slash
33
+ * name** is an id (`/narrate`); a **receipt note** is the executor's record;
34
+ * a form block's `question`, its option labels, a `kv` or `stat` label are the
35
+ * runtime output of a pipeline; **message content** is the user's; a
36
+ * **permission id** is an address. None of these is localised and none is
37
+ * checked here.
38
+ *
39
+ * ## Reading it
40
+ *
41
+ * `i18nText(v, language)` is the one resolver: a bare string is itself; a map
42
+ * answers the requested locale, else `en`. After publish enforcement a
43
+ * malformed value cannot reach a reader, so a malformed value answers
44
+ * `undefined` rather than being patched over — nothing swallows one silently.
45
+ */
46
+ const blank = (s) => s.trim().length === 0;
47
+ /** Has the value the shape of a locale map — an object, not an array, with a string `en`? @experimental */
48
+ export const isLocaleMap = (v) => !!v && typeof v === 'object' && !Array.isArray(v) && typeof v.en === 'string';
49
+ /**
50
+ * Is this display text a publish accepts — a non-blank string, or a locale map
51
+ * whose `en` is non-blank? A map with only `fr` is not: `en` is the fallback
52
+ * every other locale rests on.
53
+ * @experimental
54
+ */
55
+ export const isI18n = (v) => typeof v === 'string' ? !blank(v) : isLocaleMap(v) && !blank(v.en);
56
+ /** A bare `en` string is the short spelling of `{ en }`; a map is itself. @internal */
57
+ export const localeMapOf = (v) => (typeof v === 'string' ? { en: v } : v);
58
+ /** What the author wrote, named for the sentence — never the value itself, which may be long. */
59
+ const describe = (v) => {
60
+ if (v === null)
61
+ return 'null';
62
+ if (Array.isArray(v))
63
+ return 'an array';
64
+ if (typeof v === 'object')
65
+ return "an object without 'en'";
66
+ return `a ${typeof v}`;
67
+ };
68
+ /**
69
+ * Every fault in one display-text value, as sentences that name the field and
70
+ * say what to write instead (the teaching-error pattern, 15 §1.3). Empty when
71
+ * the value is sound, and for an absent optional value; `required` makes
72
+ * absence a finding.
73
+ *
74
+ * `where` is the field's address as the author sees it (`acme:task/roll@1
75
+ * i18n.name`, `contributes.actions[roll].label`), so the sentence can be
76
+ * acted on without a search.
77
+ * @experimental
78
+ */
79
+ export function i18nFindings(v, where, opts = {}) {
80
+ if (v === undefined) {
81
+ return opts.required
82
+ ? [
83
+ `${where} is required — display text, a string ('Title') or a locale map with ` +
84
+ `'en' ({ en: 'Title', fr: 'Titre' }) (R-20)`,
85
+ ]
86
+ : [];
87
+ }
88
+ if (typeof v === 'string') {
89
+ return blank(v)
90
+ ? [`${where} is empty — give it text a person reads, 'Title' or { en: 'Title' } (R-20)`]
91
+ : [];
92
+ }
93
+ if (isLocaleMap(v)) {
94
+ return blank(v.en)
95
+ ? [
96
+ `${where}.en is empty — 'en' is the text every other locale falls back to; ` +
97
+ `write { en: 'Title' } (R-20)`,
98
+ ]
99
+ : [];
100
+ }
101
+ return [
102
+ `${where}: a locale map with a required 'en' (R-20) — got ${describe(v)}; write ` +
103
+ `'Title' or { en: 'Title', fr: 'Titre' }`,
104
+ ];
105
+ }
106
+ /**
107
+ * The display text of an `I18n` in `language`: a bare string is itself; a map
108
+ * answers the requested locale, else `en`. A locale the map carries as blank
109
+ * counts as absent — a half-translated map is the normal state of one, and a
110
+ * blank label is never the right answer. `undefined` for a value that is not
111
+ * `I18n` at all: publish enforcement keeps those from a reader, so a reader
112
+ * does not paper over one.
113
+ * @public
114
+ */
115
+ export function i18nText(v, language = 'en') {
116
+ if (typeof v === 'string')
117
+ return v;
118
+ if (!isLocaleMap(v))
119
+ return undefined;
120
+ const wanted = v[language];
121
+ return typeof wanted === 'string' && !blank(wanted) ? wanted : v.en;
122
+ }
123
+ //# sourceMappingURL=i18n.js.map
@@ -0,0 +1,93 @@
1
+ /**
2
+ * Spec identity: **owner + slug + version** (12 §3b, 02 §3).
3
+ *
4
+ * Two versioning schemes live in this system and conflating them causes real confusion,
5
+ * so they are stated apart:
6
+ *
7
+ * - **Types pin at an integer version** — `core:query/session-history@1`. A pin is exact;
8
+ * a spec references one version and never floats.
9
+ * - **Specs upgrade at semver** — `1.2.0`. An import replaces the installed copy when it
10
+ * is newer and is ignored when it is not, which is the rule already ruled for imported
11
+ * pipelines.
12
+ *
13
+ * So a spec id carries **no `@N` suffix**. The version is not part of the identity; it is
14
+ * what the identity is compared *at*.
15
+ * @experimental
16
+ */
17
+ export interface SpecIdentity {
18
+ /** Who ships it: a plugin slug, `core`, or absent for a hand-imported document. */
19
+ owner?: string;
20
+ /** Stable, PK-agnostic reference. Unique per owner. */
21
+ slug: string;
22
+ version: string;
23
+ }
24
+ /**
25
+ * Parse `owner:slug` — `chariot.rp:chat`, `core:chat-turn`, or a bare `chat-turn` for a
26
+ * document someone hand-wrote and imported.
27
+ * @experimental
28
+ */
29
+ export declare function parseSpecId(id: string): {
30
+ owner?: string;
31
+ slug: string;
32
+ };
33
+ /** @experimental */
34
+ export declare function assertSpecId(id: string): void;
35
+ /** −1, 0, 1. A prerelease sorts below the release it leads to. @experimental */
36
+ export declare function compareVersions(a: string, b: string): number;
37
+ /** @experimental */
38
+ export type ImportDecision = {
39
+ action: 'install';
40
+ reason: string;
41
+ } | {
42
+ action: 'replace';
43
+ reason: string;
44
+ } | {
45
+ action: 'ignore';
46
+ reason: string;
47
+ } | {
48
+ action: 'conflict';
49
+ reason: string;
50
+ };
51
+ /**
52
+ * The import rule, already ruled: **a newer version replaces the installed copy; an equal
53
+ * or older one is ignored.** Ownership is checked first, because "newer" is not a licence
54
+ * to overwrite somebody else's row — a plugin update must not silently take over a spec
55
+ * an admin imported by hand, or one another plugin ships.
56
+ * @experimental
57
+ */
58
+ export declare function decideImport(incoming: SpecIdentity, installed?: SpecIdentity): ImportDecision;
59
+ /** Display form for logs and diffs — never a storage key. @experimental */
60
+ export declare const qualify: (i: SpecIdentity) => string;
61
+ /** The spec id core's own verbs are listed under — a name, not a row. @internal */
62
+ export declare const CORE_ACTION_SPEC_ID = "core";
63
+ /**
64
+ * An action's **identity** on the wire: `<spec slug>#<key>` — a spec slug
65
+ * (`core`, `core:spec/narrate`, `acme:spec/roll`; versionless, so no `@`)
66
+ * and a key (a lowercase kebab token), joined by `#`. One string names one
67
+ * declaration; everything that keys on an action keys on this — a binding's
68
+ * subject, a preset's included set, a session's enablement row, a genre's
69
+ * enabled-when default, the fire, a block's `action`, the *new* mark (plans/31
70
+ * V2: the one key; there is no bare function beside it). The host's
71
+ * `shared/actions/identity.ts` reads the same grammar from here.
72
+ * @internal
73
+ */
74
+ export declare const ACTION_IDENTITY: RegExp;
75
+ /** The longest identity the wire accepts; a spec slug is never near this. @internal */
76
+ export declare const ACTION_IDENTITY_MAX_LENGTH = 200;
77
+ /** Is this string an action identity — `<spec slug>#<key>`, within the wire's length? @experimental */
78
+ export declare function isActionIdentity(v: unknown): v is string;
79
+ /** An action's identity from its two halves: `{ specSlug: 'core', key: 'edit' }` → `core#edit`. @experimental */
80
+ export declare const actionIdentity: (a: {
81
+ specSlug: string;
82
+ key: string;
83
+ }) => string;
84
+ /**
85
+ * The two halves of an action identity, or null for anything that is not one.
86
+ * Split at the last `#` — neither half may hold one, so it is the only one.
87
+ * @experimental
88
+ */
89
+ export declare function parseActionIdentity(raw: unknown): {
90
+ specSlug: string;
91
+ key: string;
92
+ } | null;
93
+ //# sourceMappingURL=identity.d.ts.map
@@ -0,0 +1,135 @@
1
+ /**
2
+ * Spec identity: **owner + slug + version** (12 §3b, 02 §3).
3
+ *
4
+ * Two versioning schemes live in this system and conflating them causes real confusion,
5
+ * so they are stated apart:
6
+ *
7
+ * - **Types pin at an integer version** — `core:query/session-history@1`. A pin is exact;
8
+ * a spec references one version and never floats.
9
+ * - **Specs upgrade at semver** — `1.2.0`. An import replaces the installed copy when it
10
+ * is newer and is ignored when it is not, which is the rule already ruled for imported
11
+ * pipelines.
12
+ *
13
+ * So a spec id carries **no `@N` suffix**. The version is not part of the identity; it is
14
+ * what the identity is compared *at*.
15
+ * @experimental
16
+ */
17
+ const SLUG_PART = /^[a-z0-9]+([./-][a-z0-9]+)*$/;
18
+ /**
19
+ * Parse `owner:slug` — `chariot.rp:chat`, `core:chat-turn`, or a bare `chat-turn` for a
20
+ * document someone hand-wrote and imported.
21
+ * @experimental
22
+ */
23
+ export function parseSpecId(id) {
24
+ // Tolerated and ignored: a trailing @N. It is type-pin syntax that reads like a
25
+ // version here, and silently treating it as one is how a spec ends up with two.
26
+ // `SpecBuilder` strips it the same way before storing the id, so a document's
27
+ // `id` is always the versionless slug and an action's identity (`<slug>#<key>`)
28
+ // never carries an `@`. An `@` anywhere else fails `SLUG_PART` below.
29
+ const withoutPin = id.replace(/@\d+$/, '');
30
+ const i = withoutPin.indexOf(':');
31
+ if (i === -1)
32
+ return { slug: withoutPin };
33
+ return { owner: withoutPin.slice(0, i), slug: withoutPin.slice(i + 1) };
34
+ }
35
+ /** @experimental */
36
+ export function assertSpecId(id) {
37
+ const { owner, slug } = parseSpecId(id);
38
+ if (!SLUG_PART.test(slug) || (owner !== undefined && !SLUG_PART.test(owner))) {
39
+ throw new Error(`'${id}' is not a valid spec id. Use 'owner:slug' — 'chariot.rp:chat', 'core:chat-turn' — ` +
40
+ `or a bare slug for a hand-imported document. Lowercase, digits, hyphens and dots only. ` +
41
+ `The **semver** goes in meta.version, never in the id: a spec upgrades by version, and an ` +
42
+ `id that carries one cannot be matched across upgrades.`);
43
+ }
44
+ }
45
+ // ── Semver, only as much as the upgrade rule needs ──────────────────────────
46
+ const parts = (v) => {
47
+ const m = /^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?/.exec(v);
48
+ if (!m)
49
+ return null;
50
+ return { major: +m[1], minor: +m[2], patch: +m[3], pre: m[4] };
51
+ };
52
+ /** −1, 0, 1. A prerelease sorts below the release it leads to. @experimental */
53
+ export function compareVersions(a, b) {
54
+ const x = parts(a);
55
+ const y = parts(b);
56
+ if (!x || !y)
57
+ return a === b ? 0 : a < b ? -1 : 1;
58
+ for (const k of ['major', 'minor', 'patch']) {
59
+ if (x[k] !== y[k])
60
+ return x[k] < y[k] ? -1 : 1;
61
+ }
62
+ if (x.pre === y.pre)
63
+ return 0;
64
+ if (x.pre === undefined)
65
+ return 1;
66
+ if (y.pre === undefined)
67
+ return -1;
68
+ return x.pre < y.pre ? -1 : 1;
69
+ }
70
+ /**
71
+ * The import rule, already ruled: **a newer version replaces the installed copy; an equal
72
+ * or older one is ignored.** Ownership is checked first, because "newer" is not a licence
73
+ * to overwrite somebody else's row — a plugin update must not silently take over a spec
74
+ * an admin imported by hand, or one another plugin ships.
75
+ * @experimental
76
+ */
77
+ export function decideImport(incoming, installed) {
78
+ if (!installed)
79
+ return { action: 'install', reason: 'nothing installed under this slug' };
80
+ if ((incoming.owner ?? null) !== (installed.owner ?? null)) {
81
+ return {
82
+ action: 'conflict',
83
+ reason: `'${incoming.slug}' is installed under owner '${installed.owner ?? '(none)'}' and the ` +
84
+ `import claims '${incoming.owner ?? '(none)'}'. Ownership is not transferred by importing — ` +
85
+ `rename the slug, or remove the installed copy deliberately`,
86
+ };
87
+ }
88
+ const c = compareVersions(incoming.version, installed.version);
89
+ if (c > 0)
90
+ return {
91
+ action: 'replace',
92
+ reason: `${incoming.version} is newer than ${installed.version}`,
93
+ };
94
+ return {
95
+ action: 'ignore',
96
+ reason: `${incoming.version} is not newer than the installed ${installed.version}`,
97
+ };
98
+ }
99
+ /** Display form for logs and diffs — never a storage key. @experimental */
100
+ export const qualify = (i) => `${i.owner ? `${i.owner}:` : ''}${i.slug}@${i.version}`;
101
+ /* ── Action identity ─────────────────────────────────────────────────────── */
102
+ /** The spec id core's own verbs are listed under — a name, not a row. @internal */
103
+ export const CORE_ACTION_SPEC_ID = 'core';
104
+ /**
105
+ * An action's **identity** on the wire: `<spec slug>#<key>` — a spec slug
106
+ * (`core`, `core:spec/narrate`, `acme:spec/roll`; versionless, so no `@`)
107
+ * and a key (a lowercase kebab token), joined by `#`. One string names one
108
+ * declaration; everything that keys on an action keys on this — a binding's
109
+ * subject, a preset's included set, a session's enablement row, a genre's
110
+ * enabled-when default, the fire, a block's `action`, the *new* mark (plans/31
111
+ * V2: the one key; there is no bare function beside it). The host's
112
+ * `shared/actions/identity.ts` reads the same grammar from here.
113
+ * @internal
114
+ */
115
+ export const ACTION_IDENTITY = /^[a-z0-9:./-]+#[a-z0-9-]+$/;
116
+ /** The longest identity the wire accepts; a spec slug is never near this. @internal */
117
+ export const ACTION_IDENTITY_MAX_LENGTH = 200;
118
+ /** Is this string an action identity — `<spec slug>#<key>`, within the wire's length? @experimental */
119
+ export function isActionIdentity(v) {
120
+ return (typeof v === 'string' && v.length <= ACTION_IDENTITY_MAX_LENGTH && ACTION_IDENTITY.test(v));
121
+ }
122
+ /** An action's identity from its two halves: `{ specSlug: 'core', key: 'edit' }` → `core#edit`. @experimental */
123
+ export const actionIdentity = (a) => `${a.specSlug}#${a.key}`;
124
+ /**
125
+ * The two halves of an action identity, or null for anything that is not one.
126
+ * Split at the last `#` — neither half may hold one, so it is the only one.
127
+ * @experimental
128
+ */
129
+ export function parseActionIdentity(raw) {
130
+ if (!isActionIdentity(raw))
131
+ return null;
132
+ const i = raw.lastIndexOf('#');
133
+ return { specSlug: raw.slice(0, i), key: raw.slice(i + 1) };
134
+ }
135
+ //# sourceMappingURL=identity.js.map
@@ -0,0 +1,85 @@
1
+ export * from './shapes.js';
2
+ export * from './candidates.js';
3
+ export * from './i18n.js';
4
+ export * from './verdicts.js';
5
+ export * from './descriptors.js';
6
+ export * from './nodeInput.js';
7
+ export * from './refs.js';
8
+ export * from './media.js';
9
+ export * from './storage.js';
10
+ export * from './scope.js';
11
+ export * from './builder.js';
12
+ export * from './document.js';
13
+ export * from './connections.js';
14
+ export * from './registry.js';
15
+ export * from './dev.js';
16
+ export * from './validate.js';
17
+ export * from './config.js';
18
+ export * from './executor.js';
19
+ export * from './receipt.js';
20
+ export * from './review.js';
21
+ export * from './clauses.js';
22
+ export * from './settingsSlot.js';
23
+ export * from './messageBlocks.js';
24
+ export * from './foldedSections.js';
25
+ export * from './promptBlocks.js';
26
+ export * from './facets.js';
27
+ export * from './template.js';
28
+ export * from './engines.js';
29
+ export * from './templateIds.js';
30
+ export * from './variables.js';
31
+ export * from './bands.js';
32
+ export * from './templateScopeAt.js';
33
+ export * from './templateFit.js';
34
+ export * from './handlebarsReach.js';
35
+ export * from './attributes.js';
36
+ export * from './sheets.js';
37
+ export * from './statShapes.js';
38
+ export * from './storyTime.js';
39
+ export * from './turnLock.js';
40
+ export * from './scripts.js';
41
+ export * from './wire.js';
42
+ export * from './preview.js';
43
+ export * from './migration.js';
44
+ export * from './extension.js';
45
+ export * from './identity.js';
46
+ export * from './events.js';
47
+ export * from './eventMapLaws.js';
48
+ export * from './rankingDecisions.js';
49
+ export * from './values.js';
50
+ export * from './genres.js';
51
+ export * from './announce.js';
52
+ export * from './declarations.js';
53
+ export * from './hooks.js';
54
+ export * from './settings.js';
55
+ export * from './sampling.js';
56
+ export * from './capabilities.js';
57
+ export * from './hookGrants.js';
58
+ export * from './pluginPermissions.js';
59
+ export * from './worldinfo.js';
60
+ export * from './widgets.js';
61
+ export * from './personGate.js';
62
+ export * from './annexFields.js';
63
+ export * from './surfaces.js';
64
+ export * from './layout.js';
65
+ export * from './sessionLayout.js';
66
+ export * from './hostElements.js';
67
+ export * from './componentBuild.js';
68
+ export * from './receiverRules.js';
69
+ export * from './guardedConnection.js';
70
+ export * from './componentImports.js';
71
+ export * from './componentClient.js';
72
+ export * from './componentWire.js';
73
+ export * from './componentModule.js';
74
+ export * from './channels.js';
75
+ export * from './participants.js';
76
+ export * from './turnOrder.js';
77
+ export * from './sessionSettings.js';
78
+ export * from './actions.js';
79
+ export * from './predicates.js';
80
+ export * from './status.js';
81
+ export * from './hash.js';
82
+ export * from './pick.js';
83
+ export * from './names.js';
84
+ export * from './widgetDecls.js';
85
+ //# sourceMappingURL=index.d.ts.map