@almadar/core 7.10.0 → 7.10.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.
- package/dist/builders.d.ts +71 -1
- package/dist/builders.js.map +1 -1
- package/package.json +1 -1
package/dist/builders.d.ts
CHANGED
|
@@ -4,6 +4,21 @@ export { C as ComposeBehaviorsInput, a as ComposeBehaviorsResult, E as EventWiri
|
|
|
4
4
|
import 'zod';
|
|
5
5
|
import '@almadar/patterns';
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
* Orbital Builders
|
|
9
|
+
*
|
|
10
|
+
* Pure functions for constructing and composing Orbitals.
|
|
11
|
+
* No new types. Everything uses existing core types:
|
|
12
|
+
* Entity, Trait, Page, OrbitalDefinition, OrbitalSchema.
|
|
13
|
+
*
|
|
14
|
+
* Three categories:
|
|
15
|
+
* 1. Builders: construct Entity, Page from common params
|
|
16
|
+
* 2. Utilities: ensureIdField, resolveDefaults
|
|
17
|
+
* 3. Composition: connect, compose, pipe
|
|
18
|
+
*
|
|
19
|
+
* @packageDocumentation
|
|
20
|
+
*/
|
|
21
|
+
|
|
7
22
|
/**
|
|
8
23
|
* Ensure the fields array has an `id` field. Prepends one if missing.
|
|
9
24
|
*/
|
|
@@ -67,6 +82,46 @@ interface MakeTraitRefOpts {
|
|
|
67
82
|
/** Call-site config overrides. Matches {@link TraitReference.config}. */
|
|
68
83
|
config?: TraitConfig;
|
|
69
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* Typed-narrowing variant of {@link MakeTraitRefOpts} for callers that know
|
|
87
|
+
* the imported atom's overridable surfaces — its event-key set, listen-key
|
|
88
|
+
* set, and config shape. Generated std factories use this variant so an LLM
|
|
89
|
+
* tool consumer (orbital-agent) sees the closed event-name set and the
|
|
90
|
+
* config field schema instead of the un-narrowed `Record<string, string>` /
|
|
91
|
+
* `TraitConfig` defaults.
|
|
92
|
+
*
|
|
93
|
+
* Type parameters:
|
|
94
|
+
* - `EventKey` — string union of the atom's emit event names. Narrows the
|
|
95
|
+
* `events` rename map's keys to legal originals only.
|
|
96
|
+
* - `ConfigShape` — typed shape of the trait's `config { ... }` block (literal
|
|
97
|
+
* unions intact). Narrows the `config` override to the atom's actual fields.
|
|
98
|
+
* - `ListenKey` — string union of the atom's listen-key contract. Narrows
|
|
99
|
+
* each listens entry's `event` against the atom's real subscription set.
|
|
100
|
+
*
|
|
101
|
+
* Runtime behavior is unchanged — {@link makeTraitRef} accepts both the
|
|
102
|
+
* narrow and wide forms via the standard structural-typing rules. This is
|
|
103
|
+
* a type-level narrowing only; widening at the call boundary is intentional.
|
|
104
|
+
*/
|
|
105
|
+
interface MakeTraitRefOptsTyped<EventKey extends string = string, ConfigShape extends TraitConfig = Record<string, never>, ListenKey extends string = string> extends Omit<MakeTraitRefOpts, 'events' | 'effects' | 'listens' | 'config'> {
|
|
106
|
+
/** Per-key rename map, narrowed to the atom's actual event keys. */
|
|
107
|
+
events?: Partial<Record<EventKey, string>>;
|
|
108
|
+
/**
|
|
109
|
+
* Per-event SExpression effect replacement. Keys are POST-rename event
|
|
110
|
+
* names so they're caller-defined (no narrowing here); values stay typed
|
|
111
|
+
* as `SExpr[]`.
|
|
112
|
+
*/
|
|
113
|
+
effects?: Partial<Record<string, SExpr[]>>;
|
|
114
|
+
/**
|
|
115
|
+
* Replace the imported trait's `listens` array entirely. Each entry's
|
|
116
|
+
* `event` field is narrowed to {@link ListenKey} where the atom's
|
|
117
|
+
* subscription set is fixed; otherwise this widens to plain string.
|
|
118
|
+
*/
|
|
119
|
+
listens?: Array<TraitEventListener & {
|
|
120
|
+
event?: ListenKey;
|
|
121
|
+
}>;
|
|
122
|
+
/** Typed call-site config overrides — narrowed to {@link ConfigShape}. */
|
|
123
|
+
config?: ConfigShape;
|
|
124
|
+
}
|
|
70
125
|
/**
|
|
71
126
|
* Build a {@link TraitReference} from options.
|
|
72
127
|
*
|
|
@@ -93,6 +148,21 @@ interface MakePageRefOpts {
|
|
|
93
148
|
/** Replace the page's trait list. */
|
|
94
149
|
traits?: TraitRef[];
|
|
95
150
|
}
|
|
151
|
+
/**
|
|
152
|
+
* Typed-narrowing variant of {@link MakePageRefOpts}. Narrows the `traits`
|
|
153
|
+
* override array's entries to the orbital's known trait-name union — so the
|
|
154
|
+
* agent can't pass a trait name that doesn't exist on the page's owning
|
|
155
|
+
* orbital. Generated std page-helpers use this variant to surface the
|
|
156
|
+
* trait set in the tool schema; un-narrowed call sites stay compatible.
|
|
157
|
+
*
|
|
158
|
+
* Type parameter:
|
|
159
|
+
* - `TraitName` — string union of trait names the page may reference.
|
|
160
|
+
*/
|
|
161
|
+
interface MakePageRefOptsTyped<TraitName extends string = string> extends Omit<MakePageRefOpts, 'traits'> {
|
|
162
|
+
traits?: Array<{
|
|
163
|
+
ref: TraitName;
|
|
164
|
+
} | TraitRef>;
|
|
165
|
+
}
|
|
96
166
|
/**
|
|
97
167
|
* Build a {@link PageRefObject} from options. Pass-through factory — omits
|
|
98
168
|
* optional keys that are `undefined`.
|
|
@@ -225,4 +295,4 @@ declare function compose(orbitals: (OrbitalDefinition | OrbitalSchema)[], pages:
|
|
|
225
295
|
*/
|
|
226
296
|
declare function pipe(orbitals: (OrbitalDefinition | OrbitalSchema)[], events: TraitEventContract[], appName?: string): OrbitalSchema;
|
|
227
297
|
|
|
228
|
-
export { type ComposeConnection, type ComposePage, type MakeAtomOrbitalOpts, type MakeAtomOrbitalTraitOverrides, type MakeEntityOpts, type MakeOrbitalWithUsesOpts, type MakePageOpts, type MakePageRefOpts, type MakeTraitRefOpts, compose, connect, ensureIdField, extractTrait, makeAtomOrbital, makeEntity, makeOrbital, makeOrbitalWithUses, makePage, makePageRef, makeSchema, makeTraitRef, mergeOrbitals, pipe, plural, wire };
|
|
298
|
+
export { type ComposeConnection, type ComposePage, type MakeAtomOrbitalOpts, type MakeAtomOrbitalTraitOverrides, type MakeEntityOpts, type MakeOrbitalWithUsesOpts, type MakePageOpts, type MakePageRefOpts, type MakePageRefOptsTyped, type MakeTraitRefOpts, type MakeTraitRefOptsTyped, compose, connect, ensureIdField, extractTrait, makeAtomOrbital, makeEntity, makeOrbital, makeOrbitalWithUses, makePage, makePageRef, makeSchema, makeTraitRef, mergeOrbitals, pipe, plural, wire };
|