@quixotic_mnemonics/swastik 0.0.0-stage → 0.1.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 (66) hide show
  1. package/_template/README.md +34 -0
  2. package/_template/assets/.gitkeep +1 -0
  3. package/_template/commands/.gitkeep +1 -0
  4. package/_template/config/.gitkeep +1 -0
  5. package/_template/events/.gitkeep +1 -0
  6. package/_template/jobs/.gitkeep +1 -0
  7. package/_template/locales/.gitkeep +1 -0
  8. package/_template/manifest.ts +13 -0
  9. package/_template/migrations/.gitkeep +1 -0
  10. package/_template/repositories/.gitkeep +1 -0
  11. package/_template/services/.gitkeep +1 -0
  12. package/_template/tests/.gitkeep +1 -0
  13. package/_template/ui/.gitkeep +1 -0
  14. package/dist/capabilities.d.ts +110 -0
  15. package/dist/capabilities.js +107 -0
  16. package/dist/commands.d.ts +157 -0
  17. package/dist/commands.js +9 -0
  18. package/dist/components-v2.d.ts +252 -0
  19. package/dist/components-v2.js +263 -0
  20. package/dist/components.d.ts +142 -0
  21. package/dist/components.js +11 -0
  22. package/dist/context.d.ts +59 -0
  23. package/dist/context.js +29 -0
  24. package/dist/entrypoints/admin.d.ts +26 -0
  25. package/dist/entrypoints/admin.js +2 -0
  26. package/dist/entrypoints/core.d.ts +31 -0
  27. package/dist/entrypoints/core.js +2 -0
  28. package/dist/entrypoints/marketplace.d.ts +30 -0
  29. package/dist/entrypoints/marketplace.js +2 -0
  30. package/dist/entrypoints/standard.d.ts +36 -0
  31. package/dist/entrypoints/standard.js +2 -0
  32. package/dist/events.d.ts +15 -0
  33. package/dist/events.js +19 -0
  34. package/dist/index.d.ts +27 -0
  35. package/dist/index.js +21 -0
  36. package/dist/manifest-schema.d.ts +261 -0
  37. package/dist/manifest-schema.js +297 -0
  38. package/dist/manifest.d.ts +47 -0
  39. package/dist/manifest.js +6 -0
  40. package/dist/pages.d.ts +274 -0
  41. package/dist/pages.js +3 -0
  42. package/dist/paging.d.ts +32 -0
  43. package/dist/paging.js +59 -0
  44. package/dist/permits.d.ts +222 -0
  45. package/dist/permits.js +16 -0
  46. package/dist/validate.d.ts +21 -0
  47. package/dist/validate.js +33 -0
  48. package/package.json +78 -4
  49. package/src/capabilities.ts +196 -0
  50. package/src/commands.ts +181 -0
  51. package/src/components-v2.ts +533 -0
  52. package/src/components.ts +162 -0
  53. package/src/context.ts +83 -0
  54. package/src/entrypoints/admin.ts +36 -0
  55. package/src/entrypoints/core.ts +41 -0
  56. package/src/entrypoints/marketplace.ts +38 -0
  57. package/src/entrypoints/standard.ts +44 -0
  58. package/src/events.ts +34 -0
  59. package/src/index.ts +159 -0
  60. package/src/manifest-schema.ts +340 -0
  61. package/src/manifest.ts +68 -0
  62. package/src/pages.ts +282 -0
  63. package/src/paging.ts +72 -0
  64. package/src/permits.ts +250 -0
  65. package/src/validate.ts +42 -0
  66. package/README.md +0 -3
@@ -0,0 +1,59 @@
1
+ import type { ExecutionIdentity, ModuleStanding } from './commands.js';
2
+ /**
3
+ * UR-20261012-070 — the module EXECUTION CONTEXT, for entry points that are not a command.
4
+ *
5
+ * UR-20261012-067 gave a command an `identity` and a `module` standing, because a command has an
6
+ * interaction to carry them. A module's other entry points do not: a gateway event handler receives
7
+ * Discord's own arguments, a job processor receives its payload, and a cron task receives nothing at
8
+ * all. So the same question — *which profile is running this, and where* — had no answer on three of
9
+ * the four paths, and the answer is exactly what a module needs to behave correctly when the main bot
10
+ * and a persona both run it in different guilds.
11
+ *
12
+ * Passing a context as a parameter was rejected for the event path: a handler already receives a
13
+ * variable argument list, so an appended context is invisible to a rest parameter and a prepended one
14
+ * silently breaks every existing handler. The context is therefore carried out-of-band — but the SDK
15
+ * stays environment-neutral (no Node builtins, no `@types/node`), so the CARRIER is installed by the
16
+ * host and the SDK only declares the shape. See `ModuleContextStore`.
17
+ *
18
+ * ```ts
19
+ * const context = currentModuleContext();
20
+ * if (context?.standing.ownedByCaller) {
21
+ * // this profile holds the module in this guild
22
+ * }
23
+ * ```
24
+ */
25
+ export type ModuleEntryPoint = 'command' | 'event' | 'job' | 'task';
26
+ export interface ModuleExecutionContext {
27
+ /** The module this work belongs to. */
28
+ readonly moduleId: string;
29
+ /** Which of the four paths is running it. */
30
+ readonly source: ModuleEntryPoint;
31
+ /** Who is running it and where — the same shape a command receives. */
32
+ readonly identity: ExecutionIdentity;
33
+ /** This module's own standing in that guild — the same shape a command receives. */
34
+ readonly standing: ModuleStanding;
35
+ }
36
+ /**
37
+ * The carrier. The host installs an implementation (the app uses `AsyncLocalStorage`, so the context
38
+ * propagates through awaits and callbacks); the SDK never depends on one, which is what keeps this
39
+ * package free of Node builtins.
40
+ */
41
+ export interface ModuleContextStore {
42
+ get(): ModuleExecutionContext | undefined;
43
+ run<T>(context: ModuleExecutionContext, fn: () => T): T;
44
+ }
45
+ /** Install the carrier. Called once by the host at boot. */
46
+ export declare function installModuleContextStore(next: ModuleContextStore): void;
47
+ /**
48
+ * Run `fn` with the module context attached. The HOST calls this, once per entry point; a module
49
+ * never calls it. With no store installed this is a plain call, so the framework behaves exactly as
50
+ * it did before.
51
+ */
52
+ export declare function runWithModuleContext<T>(context: ModuleExecutionContext, fn: () => T): T;
53
+ /** The context of the work currently running, or `undefined` outside a module entry point. */
54
+ export declare function currentModuleContext(): ModuleExecutionContext | undefined;
55
+ /**
56
+ * The context, or a throw naming the reason. For a module whose logic is meaningless without knowing
57
+ * whose signal it is answering — better a loud failure than a silent guess at the wrong guild.
58
+ */
59
+ export declare function requireModuleContext(): ModuleExecutionContext;
@@ -0,0 +1,29 @@
1
+ let store;
2
+ /** Install the carrier. Called once by the host at boot. */
3
+ export function installModuleContextStore(next) {
4
+ store = next;
5
+ }
6
+ /**
7
+ * Run `fn` with the module context attached. The HOST calls this, once per entry point; a module
8
+ * never calls it. With no store installed this is a plain call, so the framework behaves exactly as
9
+ * it did before.
10
+ */
11
+ export function runWithModuleContext(context, fn) {
12
+ return store === undefined ? fn() : store.run(context, fn);
13
+ }
14
+ /** The context of the work currently running, or `undefined` outside a module entry point. */
15
+ export function currentModuleContext() {
16
+ return store?.get();
17
+ }
18
+ /**
19
+ * The context, or a throw naming the reason. For a module whose logic is meaningless without knowing
20
+ * whose signal it is answering — better a loud failure than a silent guess at the wrong guild.
21
+ */
22
+ export function requireModuleContext() {
23
+ const context = store?.get();
24
+ if (context === undefined) {
25
+ throw new Error('No module execution context is active. This work is not running inside a module entry point, ' +
26
+ 'so the framework cannot say which profile is running it or where.');
27
+ }
28
+ return context;
29
+ }
@@ -0,0 +1,26 @@
1
+ /**
2
+ * DEPRECATED — nothing imports this file, and the tier distinction it was built to express is not the
3
+ * one the framework now enforces (recorded 2026-11-16).
4
+ *
5
+ * The four tier entrypoints were byte-identical apart from their doc comments: they re-exported the
6
+ * same surface, so a module's tier differed in name only. The framework has since moved the tier
7
+ * decision off the import path entirely — `capabilitiesForTier` returns the same baseline for every
8
+ * tier, and what a module may actually reach is decided by the guarded container at load time, not by
9
+ * which entrypoint it imported. `moduleTiers` (the list) is live and used; these files are not.
10
+ *
11
+ * It is kept, not deleted, because the four subpaths are declared in `package.json` and withdrawing a
12
+ * published subpath is a breaking change for a consumer that names one — and the package has not yet
13
+ * been published, so the removal can be taken deliberately with a version bump rather than by
14
+ * accident. Nothing should start importing this file: take behaviour from the SDK root and reach the
15
+ * container through the capabilities the loader grants.
16
+ */
17
+ /**
18
+ * The ADMIN tier entrypoint — identical in surface to `core.ts`, and deliberately so.
19
+ *
20
+ * POLICY (operator directive, 2026-10-27): the admin tier is the operator's own tier. It holds the
21
+ * same capabilities as core, plus the tier rules the manifest schema enforces (`devGuildOnly: true`).
22
+ * It is not a wider surface than core: no tier reaches further than the internal core base.
23
+ */
24
+ export type { ModuleCommandManifest, ModuleManifest, SwastikModule } from '../manifest.js';
25
+ export { defineModule } from '../manifest.js';
26
+ export { baselineCapabilities, coreOnlyCapabilities, moduleCapabilities, type GlobalDataDelivery, type GlobalDataEmit, type JsonValue, type ModuleCapability, type ModuleRuntime, type ModuleRuntimeExtras, } from '../capabilities.js';
@@ -0,0 +1,2 @@
1
+ export { defineModule } from '../manifest.js';
2
+ export { baselineCapabilities, coreOnlyCapabilities, moduleCapabilities, } from '../capabilities.js';
@@ -0,0 +1,31 @@
1
+ /**
2
+ * DEPRECATED — nothing imports this file, and the tier distinction it was built to express is not the
3
+ * one the framework now enforces (recorded 2026-11-16).
4
+ *
5
+ * The four tier entrypoints were byte-identical apart from their doc comments: they re-exported the
6
+ * same surface, so a module's tier differed in name only. The framework has since moved the tier
7
+ * decision off the import path entirely — `capabilitiesForTier` returns the same baseline for every
8
+ * tier, and what a module may actually reach is decided by the guarded container at load time, not by
9
+ * which entrypoint it imported. `moduleTiers` (the list) is live and used; these files are not.
10
+ *
11
+ * It is kept, not deleted, because the four subpaths are declared in `package.json` and withdrawing a
12
+ * published subpath is a breaking change for a consumer that names one — and the package has not yet
13
+ * been published, so the removal can be taken deliberately with a version bump rather than by
14
+ * accident. Nothing should start importing this file: take behaviour from the SDK root and reach the
15
+ * container through the capabilities the loader grants.
16
+ */
17
+ /**
18
+ * The CORE tier entrypoint — for a module that owns part of the internal core base.
19
+ *
20
+ * POLICY (operator directive, 2026-10-27): core and admin modules are specialised and optimised for
21
+ * the framework. They may reach the database, the command registry and router, the scheduler, the
22
+ * queue, the internal event bus and router, personas, the admin eval gate, OAuth2, the MTP token
23
+ * calculator and the interaction registry — because administering those surfaces IS their job.
24
+ *
25
+ * A standard or marketplace module must not import this file. The static half of that rule is
26
+ * enforced by `packages/modules/eslint.config.mjs`; the runtime half by the guarded container the
27
+ * loader hands every module, which refuses a capability its tier does not hold.
28
+ */
29
+ export type { ModuleCommandManifest, ModuleManifest, SwastikModule } from '../manifest.js';
30
+ export { defineModule } from '../manifest.js';
31
+ export { baselineCapabilities, coreOnlyCapabilities, moduleCapabilities, type GlobalDataDelivery, type GlobalDataEmit, type JsonValue, type ModuleCapability, type ModuleRuntime, type ModuleRuntimeExtras, } from '../capabilities.js';
@@ -0,0 +1,2 @@
1
+ export { defineModule } from '../manifest.js';
2
+ export { baselineCapabilities, coreOnlyCapabilities, moduleCapabilities, } from '../capabilities.js';
@@ -0,0 +1,30 @@
1
+ /**
2
+ * DEPRECATED — nothing imports this file, and the tier distinction it was built to express is not the
3
+ * one the framework now enforces (recorded 2026-11-16).
4
+ *
5
+ * The four tier entrypoints were byte-identical apart from their doc comments: they re-exported the
6
+ * same surface, so a module's tier differed in name only. The framework has since moved the tier
7
+ * decision off the import path entirely — `capabilitiesForTier` returns the same baseline for every
8
+ * tier, and what a module may actually reach is decided by the guarded container at load time, not by
9
+ * which entrypoint it imported. `moduleTiers` (the list) is live and used; these files are not.
10
+ *
11
+ * It is kept, not deleted, because the four subpaths are declared in `package.json` and withdrawing a
12
+ * published subpath is a breaking change for a consumer that names one — and the package has not yet
13
+ * been published, so the removal can be taken deliberately with a version bump rather than by
14
+ * accident. Nothing should start importing this file: take behaviour from the SDK root and reach the
15
+ * container through the capabilities the loader grants.
16
+ */
17
+ /**
18
+ * The MARKETPLACE tier entrypoint — for a third-party module.
19
+ *
20
+ * POLICY (operator directive, 2026-10-27): a marketplace module is a guest in the framework. Its
21
+ * surface is the BASELINE only, exactly as a standard module's, and the internal core base is not
22
+ * part of it. It cannot reach the database, the command registry, the scheduler, the queue, the
23
+ * internal event bus or another module's code — and the framework refuses those at runtime rather
24
+ * than trusting the module not to ask.
25
+ *
26
+ * Sharing with another module happens on the global data emit channel and nowhere else.
27
+ */
28
+ export type { ModuleCommandManifest, ModuleManifest, SwastikModule } from '../manifest.js';
29
+ export { defineModule } from '../manifest.js';
30
+ export { baselineCapabilities, type GlobalDataDelivery, type GlobalDataEmit, type JsonValue, type ModuleCapability, type ModuleRuntime, type ModuleRuntimeExtras, } from '../capabilities.js';
@@ -0,0 +1,2 @@
1
+ export { defineModule } from '../manifest.js';
2
+ export { baselineCapabilities, } from '../capabilities.js';
@@ -0,0 +1,36 @@
1
+ /**
2
+ * DEPRECATED — nothing imports this file, and the tier distinction it was built to express is not the
3
+ * one the framework now enforces (recorded 2026-11-16).
4
+ *
5
+ * The four tier entrypoints were byte-identical apart from their doc comments: they re-exported the
6
+ * same surface, so a module's tier differed in name only. The framework has since moved the tier
7
+ * decision off the import path entirely — `capabilitiesForTier` returns the same baseline for every
8
+ * tier, and what a module may actually reach is decided by the guarded container at load time, not by
9
+ * which entrypoint it imported. `moduleTiers` (the list) is live and used; these files are not.
10
+ *
11
+ * It is kept, not deleted, because the four subpaths are declared in `package.json` and withdrawing a
12
+ * published subpath is a breaking change for a consumer that names one — and the package has not yet
13
+ * been published, so the removal can be taken deliberately with a version bump rather than by
14
+ * accident. Nothing should start importing this file: take behaviour from the SDK root and reach the
15
+ * container through the capabilities the loader grants.
16
+ */
17
+ /**
18
+ * The STANDARD tier entrypoint — for a first-party feature module.
19
+ *
20
+ * POLICY (operator directive, 2026-10-27): a standard module is a feature, not part of the framework.
21
+ * Its surface is the BASELINE only: it logs, reads its own config, caches its own values, measures
22
+ * itself, translates its own strings, renders through the core renderer, asks the permission
23
+ * resolver, and shares data on the global emit channel.
24
+ *
25
+ * It does NOT hold `data.sql`, `commands.registry`, `commands.router`, `events.bus`, `events.router`,
26
+ * `process.schedule`, `process.queue`, `modules.registry`, `personas`, `admin.eval`, `auth.oauth2`,
27
+ * `analytics.mtp` or `interactions.registry`. Those are listed in `coreOnlyCapabilities` and are
28
+ * refused at runtime by the guarded container, so reaching for one fails during the module's own load
29
+ * rather than quietly succeeding.
30
+ *
31
+ * Sharing with another module happens on the global data emit channel and nowhere else: no imports,
32
+ * no direct calls, no subscribing to another module's internal events.
33
+ */
34
+ export type { ModuleCommandManifest, ModuleManifest, SwastikModule } from '../manifest.js';
35
+ export { defineModule } from '../manifest.js';
36
+ export { baselineCapabilities, type GlobalDataDelivery, type GlobalDataEmit, type JsonValue, type ModuleCapability, type ModuleRuntime, type ModuleRuntimeExtras, } from '../capabilities.js';
@@ -0,0 +1,2 @@
1
+ export { defineModule } from '../manifest.js';
2
+ export { baselineCapabilities, } from '../capabilities.js';
@@ -0,0 +1,15 @@
1
+ import type { z } from 'zod';
2
+ import { eventCatalogEntrySchema } from './manifest-schema.js';
3
+ /**
4
+ * §18 — the events-catalog declaration helpers. A module declares every event it emits (with a
5
+ * payload schema) in its manifest `eventsCatalog`; the emit/subscribe surface is checked against
6
+ * that catalog, so a module cannot emit an undeclared event.
7
+ */
8
+ export type EventCatalogEntry = z.infer<typeof eventCatalogEntrySchema>;
9
+ export declare function defineEvent(name: string, description: string, payload: Record<string, unknown>): EventCatalogEntry;
10
+ export declare class EventCatalogError extends Error {
11
+ readonly missing: readonly string[];
12
+ constructor(missing: readonly string[]);
13
+ }
14
+ /** Every emitted event name must name a catalog entry (enforced at Stage 11 / module review). */
15
+ export declare function assertCatalogCoversEvents(emittedEventNames: readonly string[], catalog: readonly EventCatalogEntry[]): void;
package/dist/events.js ADDED
@@ -0,0 +1,19 @@
1
+ import { eventCatalogEntrySchema } from './manifest-schema.js';
2
+ export function defineEvent(name, description, payload) {
3
+ return eventCatalogEntrySchema.parse({ name, description, payload });
4
+ }
5
+ export class EventCatalogError extends Error {
6
+ missing;
7
+ constructor(missing) {
8
+ super(`eventsCatalog is missing entries for emitted events: ${missing.join(', ')}`);
9
+ this.missing = missing;
10
+ this.name = 'EventCatalogError';
11
+ }
12
+ }
13
+ /** Every emitted event name must name a catalog entry (enforced at Stage 11 / module review). */
14
+ export function assertCatalogCoversEvents(emittedEventNames, catalog) {
15
+ const declared = new Set(catalog.map((entry) => entry.name));
16
+ const missing = emittedEventNames.filter((name) => !declared.has(name));
17
+ if (missing.length > 0)
18
+ throw new EventCatalogError(missing);
19
+ }
@@ -0,0 +1,27 @@
1
+ export type { ModuleCommandManifest, ModuleLifecycle, ModuleManifest, ModuleTier, SwastikModule, } from './manifest.js';
2
+ export { defineModule, isRequiredTier, moduleTiers, moduleManifestSchema } from './manifest.js';
3
+ export { validateManifest } from './validate.js';
4
+ export type { CommandContext, ExecutionIdentity, ModuleStanding, CommandDeclaration, CommandHandler, CommandPageData, CommandPermissionsDeclaration, CommandRbacRequirement, } from './commands.js';
5
+ export { defineCommand } from './commands.js';
6
+ export type { CommandProfile, CommandDefinitionLike, CommandRegistryLike } from './commands.js';
7
+ export { assertCatalogCoversEvents, defineEvent, EventCatalogError, type EventCatalogEntry, } from './events.js';
8
+ export type { ModuleEntryPoint, ModuleExecutionContext, ModuleContextStore } from './context.js';
9
+ export { currentModuleContext, installModuleContextStore, requireModuleContext, runWithModuleContext, } from './context.js';
10
+ export { baselineCapabilities, GLOBAL_DATA_BUILTIN_VERBS, coreOnlyCapabilities, moduleCapabilities, type GlobalDataDelivery, type GlobalDataEmit, type GlobalDataReply, type GlobalDataRequestVerb, type JsonValue, type ModuleCapability, type ModuleRuntime, type ModuleRuntimeExtras, } from './capabilities.js';
11
+ export { componentParams, type ComponentAck, type ComponentHandlerDefinition, type ComponentRbacRequirement, type ComponentHandlers, type ComponentInvocation, } from './components.js';
12
+ export { definePage, type ActingProfileFacts, type GuildCounts, type HostProcessFacts, type PendingQueueEntry, type PersonaBinding, type PersonaRecord, type ModulePage, type ModulePageContext, type ModulePageReadModel, type ModuleSummary, type SubsystemState, } from './pages.js';
13
+ export { modulePageNavigation, romanNumeral, type PageSlide } from './paging.js';
14
+ /**
15
+ * UR-20261031-120 — the Components V2 primitive vocabulary.
16
+ *
17
+ * A module returns DATA and BLOCKS, and the framework renders them. That left one surface unable to
18
+ * leave the core: a module-specific card that builds a message directly (`persona-setup`) could not
19
+ * move into its module without importing the core, and the import gate refuses exactly that.
20
+ *
21
+ * The operator's decision: the SDK owns the vocabulary, and rendering stays in the core as a library
22
+ * modules call. So the primitives live here, a module imports them from `@quixotic_mnemonics/swastik`, and the
23
+ * core imports the same file — one definition, no duplication, no core dependency for a module.
24
+ */
25
+ export { textDisplay, mediaGallery, separator, container, stringSelect, userSelect, roleSelect, mentionableSelect, channelSelect, button, linkButton, actionRow, thumbnail, section, textInputModal, multiInputModal, buildComponentsV2, createBannerMediaGallery, getDefaultBannerUrl, createTitleBlock, createMarketplaceTitleBlock, createSectionHeader, createKeyValueDisplay, IS_COMPONENTS_V2, EPHEMERAL, ComponentType, DEFAULT_ACCENT_COLOR, DEFAULT_PERSONA_ACCENT, type ComponentTypeValue, type ComponentBase, type TextDisplayComponent, type MediaGalleryComponent, type SeparatorComponent, type ContainerComponent, type StringSelectComponent, type EntitySelectComponent, type ButtonComponent, type ActionRowComponent, type ThumbnailComponent, type SectionComponent, type Component, type ComponentsV2Message, type ModalTextInput, type ModalPayload, } from './components-v2.js';
26
+ export type { BlockPayload, NoticePayload } from './components.js';
27
+ export type { PermitSurface, PixelSummary, PixelTarget, PixelTargetInput, PixelTargetKind, PixelEffect, PixelQuota, PixelState, PixelErrorCode, PixelResult, GrantableCommand, PermitV2Surface, PermitKind, PermitRule, PermitQuotaV2, PermitCommandRef, PermitMemberRef, PermitSummary, PermitNoticeCode, PermitResult, } from './permits.js';
package/dist/index.js ADDED
@@ -0,0 +1,21 @@
1
+ export { defineModule, isRequiredTier, moduleTiers, moduleManifestSchema } from './manifest.js';
2
+ export { validateManifest } from './validate.js';
3
+ export { defineCommand } from './commands.js';
4
+ export { assertCatalogCoversEvents, defineEvent, EventCatalogError, } from './events.js';
5
+ export { currentModuleContext, installModuleContextStore, requireModuleContext, runWithModuleContext, } from './context.js';
6
+ export { baselineCapabilities, GLOBAL_DATA_BUILTIN_VERBS, coreOnlyCapabilities, moduleCapabilities, } from './capabilities.js';
7
+ export { componentParams, } from './components.js';
8
+ export { definePage, } from './pages.js';
9
+ export { modulePageNavigation, romanNumeral } from './paging.js';
10
+ /**
11
+ * UR-20261031-120 — the Components V2 primitive vocabulary.
12
+ *
13
+ * A module returns DATA and BLOCKS, and the framework renders them. That left one surface unable to
14
+ * leave the core: a module-specific card that builds a message directly (`persona-setup`) could not
15
+ * move into its module without importing the core, and the import gate refuses exactly that.
16
+ *
17
+ * The operator's decision: the SDK owns the vocabulary, and rendering stays in the core as a library
18
+ * modules call. So the primitives live here, a module imports them from `@quixotic_mnemonics/swastik`, and the
19
+ * core imports the same file — one definition, no duplication, no core dependency for a module.
20
+ */
21
+ export { textDisplay, mediaGallery, separator, container, stringSelect, userSelect, roleSelect, mentionableSelect, channelSelect, button, linkButton, actionRow, thumbnail, section, textInputModal, multiInputModal, buildComponentsV2, createBannerMediaGallery, getDefaultBannerUrl, createTitleBlock, createMarketplaceTitleBlock, createSectionHeader, createKeyValueDisplay, IS_COMPONENTS_V2, EPHEMERAL, ComponentType, DEFAULT_ACCENT_COLOR, DEFAULT_PERSONA_ACCENT, } from './components-v2.js';
@@ -0,0 +1,261 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * The module manifest — the specified contract.
4
+ *
5
+ * Authority: `docs/spec/modules/module-anatomy-manifest.md` (SPEC-03-MODULES) and
6
+ * `docs/contracts/module-manifest.schema.json`. Where the two once disagreed with this file, this
7
+ * file was the gap; it now expresses the contract.
8
+ *
9
+ * The shape is a **discriminated union on `hardcoded`**: a `hardcoded: true` build is a private
10
+ * build pinned to one guild, so it carries `hardcodeGuildId` and admits only `releaseStatus:
11
+ * 'private'`; a `hardcoded: false` build forbids `hardcodeGuildId` and admits either release status.
12
+ * On top of the union the **visibility triad** runs as one `superRefine`, so a violating manifest
13
+ * fails with a single error naming the conflicting fields together rather than three independent
14
+ * ones.
15
+ */
16
+ export declare const moduleTierSchema: z.ZodEnum<{
17
+ admin: "admin";
18
+ core: "core";
19
+ standard: "standard";
20
+ marketplace: "marketplace";
21
+ }>;
22
+ export declare const moduleVisibilitySchema: z.ZodEnum<{
23
+ public: "public";
24
+ unlisted: "unlisted";
25
+ private: "private";
26
+ }>;
27
+ /**
28
+ * UR-20261119-145 — DEPRECATED, and kept only because it is public API.
29
+ *
30
+ * `releaseStatus` left the manifest in UR-20261118-138: nothing read it, and the runtime gate it was meant
31
+ * to be is deferred in `ADR-017`. This schema and its `ModuleReleaseStatus` type are still exported from
32
+ * `@quixotic_mnemonics/swastik`, so deleting them is a breaking change for any module author who imported the name —
33
+ * and there are none yet, which is exactly why it should be done deliberately rather than as a tidy-up.
34
+ *
35
+ * Nothing in the framework references either one. When the gate in ADR-017 is built, this either returns as
36
+ * a real field or is removed in the same change; until then it is a name with no behaviour, and it says so.
37
+ */
38
+ export declare const moduleReleaseStatusSchema: z.ZodEnum<{
39
+ public: "public";
40
+ private: "private";
41
+ }>;
42
+ export declare const marketplaceCategorySchema: z.ZodEnum<{
43
+ audio: "audio";
44
+ community: "community";
45
+ security: "security";
46
+ integrations: "integrations";
47
+ utility: "utility";
48
+ }>;
49
+ /** Mirrors the DI container's `Lifetime` (src/di/container.ts). */
50
+ export declare const serviceLifetimeSchema: z.ZodEnum<{
51
+ singleton: "singleton";
52
+ transient: "transient";
53
+ scoped: "scoped";
54
+ }>;
55
+ export declare const commandManifestSchema: z.ZodObject<{
56
+ name: z.ZodString;
57
+ description: z.ZodString;
58
+ guildOnly: z.ZodDefault<z.ZodBoolean>;
59
+ requiresDefer: z.ZodDefault<z.ZodBoolean>;
60
+ ephemeral: z.ZodDefault<z.ZodBoolean>;
61
+ nsfw: z.ZodDefault<z.ZodBoolean>;
62
+ permissions: z.ZodDefault<z.ZodObject<{
63
+ discord: z.ZodDefault<z.ZodArray<z.ZodString>>;
64
+ }, z.core.$strip>>;
65
+ defaultMemberPermissions: z.ZodOptional<z.ZodNullable<z.ZodString>>;
66
+ }, z.core.$strip>;
67
+ export declare const eventCatalogEntrySchema: z.ZodObject<{
68
+ name: z.ZodString;
69
+ description: z.ZodString;
70
+ payload: z.ZodRecord<z.ZodString, z.ZodUnknown>;
71
+ }, z.core.$strip>;
72
+ export declare const crossModuleReadSchema: z.ZodObject<{
73
+ targetModule: z.ZodString;
74
+ accessor: z.ZodString;
75
+ }, z.core.$strip>;
76
+ /**
77
+ * `depends` entries are `{ token, version }` pins, never bare tokens: Stage 11 runs a
78
+ * range-satisfaction evaluator over them (see `topo-sort.ts`).
79
+ */
80
+ export declare const dependencyEntrySchema: z.ZodObject<{
81
+ token: z.ZodString;
82
+ version: z.ZodString;
83
+ }, z.core.$strict>;
84
+ /** `provides` entries are `{ token, contract }` — the contract names a TS interface `tsc` checks. */
85
+ export declare const providedServiceSchema: z.ZodObject<{
86
+ token: z.ZodString;
87
+ contract: z.ZodString;
88
+ }, z.core.$strict>;
89
+ /** `services` entries are `{ token, class, lifetime, deps }`. */
90
+ export declare const declaredServiceSchema: z.ZodObject<{
91
+ token: z.ZodString;
92
+ class: z.ZodString;
93
+ lifetime: z.ZodEnum<{
94
+ singleton: "singleton";
95
+ transient: "transient";
96
+ scoped: "scoped";
97
+ }>;
98
+ deps: z.ZodDefault<z.ZodArray<z.ZodString>>;
99
+ }, z.core.$strict>;
100
+ /** §1.3 / ADR-012 / ADR-013 — a module's declared UI identity: banner, accent, logo icon, name. */
101
+ export declare const moduleUiSchema: z.ZodObject<{
102
+ banner: z.ZodOptional<z.ZodString>;
103
+ accent: z.ZodOptional<z.ZodString>;
104
+ icon: z.ZodOptional<z.ZodString>;
105
+ iconAsset: z.ZodOptional<z.ZodString>;
106
+ icons: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
107
+ displayName: z.ZodOptional<z.ZodString>;
108
+ }, z.core.$strict>;
109
+ /**
110
+ * UR-20261118-138 - the union is gone with `hardcoded`.
111
+ *
112
+ * The schema used to be a discriminated union on `hardcoded`, and `hardcoded`, `releaseStatus` and
113
+ * `visibility` were then validated against each other as a "triad". Tracing every consumer showed the
114
+ * shape of the problem: `hardcoded` was read by NOTHING, `releaseStatus` was read by NOTHING, and the
115
+ * triad rule was therefore three fields keeping each other consistent, two of which nothing consumed.
116
+ * It looked meaningful because it validated, and it meant nothing because nothing read it - the same
117
+ * defect class as `RenderDescriptor.buildId` (REC-049).
118
+ *
119
+ * `hardcodeGuildId` existed only to pair with `hardcoded` and had no consumer either, so it went too.
120
+ *
121
+ * What remains is what the code actually uses: `tier` (fatal-vs-degraded, privilege), `visibility` (the
122
+ * catalogue filter in mdis.service.ts), `devUsername` (the developer's account name, optional and absent
123
+ * for first-party) and `devGuildId` (the admin tier's guild binding). `required` is derived from `tier` at
124
+ * the loader rather than declared.
125
+ */
126
+ export declare const moduleManifestSchema: z.ZodObject<{
127
+ name: z.ZodString;
128
+ version: z.ZodString;
129
+ description: z.ZodString;
130
+ tier: z.ZodEnum<{
131
+ admin: "admin";
132
+ core: "core";
133
+ standard: "standard";
134
+ marketplace: "marketplace";
135
+ }>;
136
+ devGuildOnly: z.ZodOptional<z.ZodBoolean>;
137
+ devUsername: z.ZodOptional<z.ZodString>;
138
+ devGuildId: z.ZodOptional<z.ZodString>;
139
+ visibility: z.ZodEnum<{
140
+ public: "public";
141
+ unlisted: "unlisted";
142
+ private: "private";
143
+ }>;
144
+ marketplaceCategory: z.ZodOptional<z.ZodEnum<{
145
+ audio: "audio";
146
+ community: "community";
147
+ security: "security";
148
+ integrations: "integrations";
149
+ utility: "utility";
150
+ }>>;
151
+ depends: z.ZodDefault<z.ZodArray<z.ZodObject<{
152
+ token: z.ZodString;
153
+ version: z.ZodString;
154
+ }, z.core.$strict>>>;
155
+ provides: z.ZodDefault<z.ZodArray<z.ZodObject<{
156
+ token: z.ZodString;
157
+ contract: z.ZodString;
158
+ }, z.core.$strict>>>;
159
+ intents: z.ZodDefault<z.ZodArray<z.ZodString>>;
160
+ partials: z.ZodDefault<z.ZodArray<z.ZodString>>;
161
+ commands: z.ZodDefault<z.ZodArray<z.ZodObject<{
162
+ name: z.ZodString;
163
+ description: z.ZodString;
164
+ guildOnly: z.ZodDefault<z.ZodBoolean>;
165
+ requiresDefer: z.ZodDefault<z.ZodBoolean>;
166
+ ephemeral: z.ZodDefault<z.ZodBoolean>;
167
+ nsfw: z.ZodDefault<z.ZodBoolean>;
168
+ permissions: z.ZodDefault<z.ZodObject<{
169
+ discord: z.ZodDefault<z.ZodArray<z.ZodString>>;
170
+ }, z.core.$strip>>;
171
+ defaultMemberPermissions: z.ZodOptional<z.ZodNullable<z.ZodString>>;
172
+ }, z.core.$strip>>>;
173
+ events: z.ZodDefault<z.ZodArray<z.ZodString>>;
174
+ services: z.ZodDefault<z.ZodArray<z.ZodObject<{
175
+ token: z.ZodString;
176
+ class: z.ZodString;
177
+ lifetime: z.ZodEnum<{
178
+ singleton: "singleton";
179
+ transient: "transient";
180
+ scoped: "scoped";
181
+ }>;
182
+ deps: z.ZodDefault<z.ZodArray<z.ZodString>>;
183
+ }, z.core.$strict>>>;
184
+ repositories: z.ZodDefault<z.ZodArray<z.ZodString>>;
185
+ jobs: z.ZodDefault<z.ZodArray<z.ZodString>>;
186
+ tasks: z.ZodDefault<z.ZodArray<z.ZodString>>;
187
+ routes: z.ZodDefault<z.ZodArray<z.ZodString>>;
188
+ middleware: z.ZodDefault<z.ZodArray<z.ZodString>>;
189
+ components: z.ZodDefault<z.ZodArray<z.ZodString>>;
190
+ migrations: z.ZodDefault<z.ZodArray<z.ZodString>>;
191
+ locales: z.ZodDefault<z.ZodArray<z.ZodString>>;
192
+ config: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
193
+ eventsCatalog: z.ZodDefault<z.ZodArray<z.ZodObject<{
194
+ name: z.ZodString;
195
+ description: z.ZodString;
196
+ payload: z.ZodRecord<z.ZodString, z.ZodUnknown>;
197
+ }, z.core.$strip>>>;
198
+ dashboardSchema: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
199
+ ui: z.ZodOptional<z.ZodObject<{
200
+ banner: z.ZodOptional<z.ZodString>;
201
+ accent: z.ZodOptional<z.ZodString>;
202
+ icon: z.ZodOptional<z.ZodString>;
203
+ iconAsset: z.ZodOptional<z.ZodString>;
204
+ icons: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
205
+ displayName: z.ZodOptional<z.ZodString>;
206
+ }, z.core.$strict>>;
207
+ render: z.ZodOptional<z.ZodObject<{
208
+ contract: z.ZodEnum<{
209
+ blocks: "blocks";
210
+ }>;
211
+ }, z.core.$strict>>;
212
+ crossModuleReads: z.ZodDefault<z.ZodArray<z.ZodObject<{
213
+ targetModule: z.ZodString;
214
+ accessor: z.ZodString;
215
+ }, z.core.$strip>>>;
216
+ }, z.core.$strict>;
217
+ /**
218
+ * 2026-11-16 — the service seam, closed at validation (`REC-052`).
219
+ *
220
+ * `provides` used to accept any non-empty token for any module, and the registry resolved it
221
+ * last-wins, so a licensed module could declare `core.PersonaRuntime` and take a core capability by
222
+ * loading later. Three rules now, all refused at validation rather than at load:
223
+ *
224
+ * 1. A `core.*` token is FIRST-PARTY ONLY. The discriminator is `devId: 'dev_first_party'`, which is
225
+ * safe to key on because the manifest's `devId` is checked against the authenticated principal at
226
+ * upload and at deploy — a licensed developer cannot claim it and have the claim survive the
227
+ * endpoint. It is not trusted here on its own; it is trusted because the endpoint already proved it.
228
+ * 2. A `core.*` token requires `tier: 'core'`. A first-party standard-tier module (hello-world) may
229
+ * not reach the core base through the service seam any more than through an import.
230
+ * 3. Every token is NAMESPACED — `core.*` or `module.<slug>.*` — and no manifest may declare the same
231
+ * token twice. The guard's `MODULE_TOKEN_PATTERN` already gave module-namespaced tokens their own
232
+ * namespace; this is the same rule, stated where the manifest is validated.
233
+ */
234
+ export declare const providesIsNamespacedAndFirstParty: (manifest: {
235
+ readonly name: string;
236
+ readonly devUsername?: string | undefined;
237
+ readonly tier: string;
238
+ readonly provides: readonly {
239
+ readonly token: string;
240
+ }[];
241
+ }) => readonly string[];
242
+ export type ModuleManifest = z.infer<typeof moduleManifestSchema>;
243
+ export type DependencyEntry = z.infer<typeof dependencyEntrySchema>;
244
+ export type ProvidedService = z.infer<typeof providedServiceSchema>;
245
+ export type DeclaredService = z.infer<typeof declaredServiceSchema>;
246
+ export type ModuleVisibility = z.infer<typeof moduleVisibilitySchema>;
247
+ export type ModuleReleaseStatus = z.infer<typeof moduleReleaseStatusSchema>;
248
+ /**
249
+ * UR-20261118-138 - `required` is DERIVED, not declared.
250
+ *
251
+ * It used to be a manifest field, and every manifest restated its own tier with it: all seven core
252
+ * modules said `required: true`, `hello-world` said `false`. The loader's only use for it was deciding
253
+ * fatal-versus-degraded on a load failure, and core/admin are already the tiers §13.2 makes permanent
254
+ * and un-disableable. So the field was a second way to say `tier`, and a manifest could say it WRONGLY -
255
+ * `tier: standard, required: true` was schema-valid and would have made a marketplace module fatal to
256
+ * the boot.
257
+ *
258
+ * One function, so there is one answer.
259
+ */
260
+ export declare function isRequiredTier(tier: z.infer<typeof moduleTierSchema>): boolean;
261
+ export type MarketplaceCategory = z.infer<typeof marketplaceCategorySchema>;