@yaks/host 0.0.0-stage → 0.2.36

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 (69) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +306 -2
  3. package/_dist/anatomy.d.ts +35 -0
  4. package/_dist/anatomy.d.ts.map +1 -0
  5. package/_dist/assembly.d.ts +94 -0
  6. package/_dist/assembly.d.ts.map +1 -0
  7. package/_dist/config.d.ts +150 -0
  8. package/_dist/config.d.ts.map +1 -0
  9. package/_dist/documents.d.ts +9 -0
  10. package/_dist/documents.d.ts.map +1 -0
  11. package/_dist/facets.d.ts +164 -0
  12. package/_dist/facets.d.ts.map +1 -0
  13. package/_dist/keepers.d.ts +15 -0
  14. package/_dist/keepers.d.ts.map +1 -0
  15. package/_dist/keywords.d.ts +3 -0
  16. package/_dist/keywords.d.ts.map +1 -0
  17. package/_dist/lending.d.ts +34 -0
  18. package/_dist/lending.d.ts.map +1 -0
  19. package/_dist/mod.d.ts +260 -0
  20. package/_dist/mod.d.ts.map +1 -0
  21. package/_dist/payments.d.ts +501 -0
  22. package/_dist/payments.d.ts.map +1 -0
  23. package/_dist/roles.d.ts +10 -0
  24. package/_dist/roles.d.ts.map +1 -0
  25. package/_dist/senders.d.ts +180 -0
  26. package/_dist/senders.d.ts.map +1 -0
  27. package/_dist/words.d.ts +27 -0
  28. package/_dist/words.d.ts.map +1 -0
  29. package/anatomy.js +432 -0
  30. package/anatomy.js.map +1 -0
  31. package/anatomy.ts +439 -0
  32. package/assembly.js +737 -0
  33. package/assembly.js.map +1 -0
  34. package/assembly.ts +930 -0
  35. package/config.js +149 -0
  36. package/config.js.map +1 -0
  37. package/config.ts +287 -0
  38. package/deno.json +1 -0
  39. package/documents.js +80 -0
  40. package/documents.js.map +1 -0
  41. package/documents.ts +105 -0
  42. package/facets.js +2 -0
  43. package/facets.js.map +1 -0
  44. package/facets.ts +236 -0
  45. package/keepers.js +7 -0
  46. package/keepers.js.map +1 -0
  47. package/keepers.ts +17 -0
  48. package/keywords.js +24 -0
  49. package/keywords.js.map +1 -0
  50. package/keywords.ts +25 -0
  51. package/lending.js +46 -0
  52. package/lending.js.map +1 -0
  53. package/lending.ts +77 -0
  54. package/mod.js +5 -0
  55. package/mod.js.map +1 -0
  56. package/mod.ts +356 -0
  57. package/package.json +79 -4
  58. package/payments.js +66 -0
  59. package/payments.js.map +1 -0
  60. package/payments.ts +665 -0
  61. package/roles.js +22 -0
  62. package/roles.js.map +1 -0
  63. package/roles.ts +18 -0
  64. package/senders.js +58 -0
  65. package/senders.js.map +1 -0
  66. package/senders.ts +272 -0
  67. package/words.js +134 -0
  68. package/words.js.map +1 -0
  69. package/words.ts +210 -0
@@ -0,0 +1,180 @@
1
+ /** The portable mail sender capability: a composed message and its receipt.
2
+ * Hosts own sender construction, credentials, metering and lifetime. */ /** One message, composed and ready to leave. */ export type Message = {
3
+ /** the caller's letter UUID, for asynchronous delivery receipts */ id?: string;
4
+ /** the address it is from */ from: string;
5
+ /** a connection the host selected for this letter */ connection?: string;
6
+ /** the name it is from, as the reader's mail shows it beside the address */ name?: string;
7
+ /** the address it is going to */ to: string | string[];
8
+ /** the address copied on it, who sees it and its replies */ cc?: string;
9
+ /** the subject line */ subject: string;
10
+ /** the body as plain text */ text: string;
11
+ /** the same body as HTML */ html: string;
12
+ /** the Message-ID it answers, unbracketed, when it answers one */ replyTo?: string;
13
+ /** the address replies go to, when different from the sender */ replyAddress?: string;
14
+ };
15
+ /** What a sender reports about a message it accepted. */ export type Receipt = {
16
+ /** the Message-ID the sender gave the letter, unbracketed, if any */ id?: string;
17
+ };
18
+ /** A sender resolves when the message is away and rejects when it is not.
19
+ * The rejection's message is what lands in `bounced.reason`, unless it is
20
+ * {@link Unsent}: then the letter is tried again. */ export type Sender = {
21
+ send: (message: Message) => Promise<Receipt>;
22
+ /** Why it cannot send yet, such as a credential not set; asked before each
23
+ * letter, so the letter waits instead. Absent or empty, it can send. */ waiting?: () => string | undefined;
24
+ };
25
+ /** A sender, or why one cannot be built from its options yet. */ export type Built = {
26
+ sender?: Sender;
27
+ waiting?: string;
28
+ };
29
+ /** A {@link Sender} built again from `build` at every use, so options read
30
+ * then, such as a secret set after start-up, take effect at once. Until it
31
+ * builds, it is {@link Sender.waiting} and a letter handed to it is
32
+ * {@link Unsent}.
33
+ *
34
+ * ```ts
35
+ * import { afresh } from '@yaks/host/senders'
36
+ * import { equal } from '@yaks/testing'
37
+ *
38
+ * let options: { token?: string } = {}
39
+ * let sender = afresh(() =>
40
+ * options.token
41
+ * ? { sender: { send: () => Promise.resolve({ id: options.token }) } }
42
+ * : { waiting: 'waiting for a token' }
43
+ * )
44
+ * equal(sender.waiting?.(), 'waiting for a token')
45
+ * options.token = 't'
46
+ * equal(sender.waiting?.(), undefined)
47
+ * ```
48
+ */ export declare let afresh: (build: () => Built) => Sender;
49
+ /** One text message, composed and ready to leave: the portable texter
50
+ * capability, which @yaks/phone sends through. */ export type Text = {
51
+ /** the number it goes to, in E.164 form */ to: string;
52
+ /** the words */ text: string;
53
+ /** the number it is from; absent, the texter's own */ from?: string;
54
+ /** an RCS agent to send it as, with the text going as SMS from `from`
55
+ * where the phone has no RCS */ agent?: string;
56
+ /** everyone else in the group text it answers, who get it too, as one
57
+ * group message: given only to a texter whose provider hears group texts */ group?: string[];
58
+ };
59
+ /** What a texter reports about a text it accepted. */ export type TextReceipt = {
60
+ /** The transport that accepted it; an opaque provider name. */ via?: string;
61
+ /** the provider's id for the message, which its outcome names */ id?: string;
62
+ /** the number it left from, when the texter chose it */ from?: string;
63
+ };
64
+ /** A texter resolves when the text is accepted and rejects when it is not,
65
+ * as a {@link Sender} does for a letter. */ export type Texter = {
66
+ send: (text: Text) => Promise<TextReceipt>;
67
+ /** Why it cannot send yet, such as a credential not set; asked before each
68
+ * text, so the text waits instead. Absent or empty, it can send. */ waiting?: () => string | undefined;
69
+ };
70
+ /** One message to post in a room of a chat platform (@yaks/chat), by the
71
+ * bot of a connection: the portable chatter capability. */ export type Chat = {
72
+ /** the connection whose bot speaks it, absent for the host's own bot in a DM */ connection?: string;
73
+ /** the platform's id for the room */ room: string;
74
+ /** the words */ text: string;
75
+ /** the platform's id for the message it answers */ reply_to?: string;
76
+ /** the platform's id for the first message of the thread, where required */ thread?: string;
77
+ /** the platform's id for the one account it names, which alone is
78
+ * pinged */ ping?: string;
79
+ /** the buttons posted with it */ controls?: Control[];
80
+ };
81
+ /** A button posted with a chat message: its label, and the id a press of it
82
+ * names (@yaks/chat `Press`). */ export type Control = {
83
+ id: string;
84
+ label: string;
85
+ };
86
+ /** A chatter posts a message for one chat platform, resolving with the
87
+ * platform's id for it and rejecting as a {@link Texter} does. Which bot's
88
+ * credential posts it is the host's to know from the connection. */ export type Chatter = {
89
+ post: (chat: Chat) => Promise<{
90
+ id?: string;
91
+ }>;
92
+ /** Show a room that the connection's bot is working on an answer, where
93
+ * its platform can: a show lasts `every` milliseconds (@yaks/chat
94
+ * `showing`). */ working?: {
95
+ every: number;
96
+ show: (at: Pick<Chat, 'connection' | 'room'>) => Promise<void>;
97
+ };
98
+ /** Why it cannot post yet; absent or empty, it can. */ waiting?: () => string | undefined;
99
+ };
100
+ /** A rejection that knows the message never left: the connection was never
101
+ * made, or the provider refused to take it yet. Sending is at most once, so
102
+ * only this rejection lets a letter be handed over again, no sooner than
103
+ * `retry.after` milliseconds; any other rejection is a bounce. */ export declare class Unsent extends Error {
104
+ retry: {
105
+ after: number;
106
+ };
107
+ constructor(message: string, after?: number);
108
+ }
109
+ /** A rejection that knows the letter as written can never go: its provider
110
+ * refused an address on it, such as one at a domain that takes no mail. The
111
+ * letter bounces with this message as its reason, and that bounce is the
112
+ * letter's outcome, answered on the letter: the writer's input, not a failure
113
+ * of the sender. Any other rejection that is not {@link Unsent} is both. */ export declare class Undeliverable extends Error {
114
+ constructor(message: string);
115
+ }
116
+ /** An original part of a delivery, retained without interpreting its bytes. */ export type MailSource = {
117
+ name: string;
118
+ type: string;
119
+ bytes: Uint8Array<ArrayBuffer>;
120
+ };
121
+ /** An incoming letter at the portable mail boundary. Authentication is a
122
+ * provider's verdict, never inferred from a stranger's supplied headers. */ export type Incoming = {
123
+ /** the name in the message's From header, if any */ name?: string;
124
+ from: string;
125
+ to: string;
126
+ headers: {
127
+ get(name: string): string | null;
128
+ entries?(): IterableIterator<[string, string]>;
129
+ };
130
+ text: string;
131
+ html?: string;
132
+ /** the receiving server's DKIM verdict; unset where nobody checked */ verified?: boolean;
133
+ /** the receiving server's DMARC pass, aligned with the From domain: that
134
+ * domain vouches its author wrote the letter */ vouched?: boolean;
135
+ attachments: MailSource[];
136
+ /** Original MIME or provider responses, before decoding or selecting fields. */ sources?: MailSource[];
137
+ };
138
+ /** A provider's signed word on a letter it carried: the receipt @yaks/mail's
139
+ * `receipted` applies, if it names one, and the tags the letter was sent
140
+ * with, which say whose letter it was. Or the letters it received, for a
141
+ * provider that takes mail in by webhook. */ export type Notice = {
142
+ receipt?: {
143
+ letter: string;
144
+ id: string;
145
+ };
146
+ tags?: Record<string, string>;
147
+ /** the letters it received, one for each recipient, read in full */ letters?: Incoming[];
148
+ /** An authenticated arrival that still needs to be retrieved. */ pending?: string;
149
+ };
150
+ /** Reads one request a provider posted about the letters it carried. A
151
+ * request the provider did not sign rejects as {@link Unsigned}. */ export type Notices = (request: Request) => Promise<Notice>;
152
+ /** A request that does not carry its provider's signature: the caller is
153
+ * refused, never retried. */ export declare class Unsigned extends Error {
154
+ constructor(message: string);
155
+ }
156
+ /** Reads one letter a runtime handed its host, in the runtime's own shape,
157
+ * as an {@link Incoming}. Only the provider knows that shape. */ export type Arrival = (message: unknown) => Promise<Incoming>;
158
+ /** A DNS record a mail domain needs, and whether its provider has seen it. */ export type DomainRecord = {
159
+ /** `MX`, `TXT` or `CNAME` */ type: string;
160
+ /** the name it is written at, fully qualified */ name: string;
161
+ /** what it holds */ value: string;
162
+ /** an MX record's priority */ priority?: number;
163
+ /** whether the provider has found it in DNS as given */ arrived: boolean;
164
+ };
165
+ /** A domain a provider sends and receives mail at, and the records it needs. */ export type MailDomain = {
166
+ name: string;
167
+ records: DomainRecord[];
168
+ };
169
+ /** A provider's mail domains, each named by its domain name: the provider's
170
+ * own ids for them stay with the provider. Every verb rejects when the
171
+ * provider refuses it, its message naming no secret. */ export type MailDomains = {
172
+ /** Set a domain up for sending and receiving, or answer it as it is when
173
+ * it already is. */ setup: (name: string) => Promise<MailDomain>;
174
+ /** The domain's records as they stand, or none when it is not set up. A
175
+ * read asks the provider to look again for any record not yet arrived. */ read: (name: string) => Promise<MailDomain | undefined>;
176
+ /** Remove the domain; removing one not set up does nothing. */ remove: (name: string) => Promise<void>;
177
+ /** Why it cannot reach the provider yet, such as a credential not set.
178
+ * Absent or empty, it can. */ waiting?: () => string | undefined;
179
+ };
180
+ //# sourceMappingURL=senders.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"senders.d.ts","sources":["../senders.ts"],"names":[],"mappings":"AAAA;sEACsE,GAEtE,8CAA8C,GAC9C,YAAY;EACV,iEAAiE,GACjE,KAAK,MAAM;EACX,2BAA2B,GAC3B,MAAM,MAAM;EACZ,mDAAmD,GACnD,aAAa,MAAM;EACnB,0EAA0E,GAC1E,OAAO,MAAM;EACb,+BAA+B,GAC/B,IAAI,MAAM,GAAG,MAAM;EACnB,0DAA0D,GAC1D,KAAK,MAAM;EACX,qBAAqB,GACrB,SAAS,MAAM;EACf,2BAA2B,GAC3B,MAAM,MAAM;EACZ,0BAA0B,GAC1B,MAAM,MAAM;EACZ,gEAAgE,GAChE,UAAU,MAAM;EAChB,8DAA8D,GAC9D,eAAe,MAAM;;AAGvB,uDAAuD,GACvD,YAAY;EACV,mEAAmE,GACnE,KAAK,MAAM;;AAGb;;mDAEmD,GACnD,YAAY;EACV,OAAO,SAAS,YAAY,QAAQ;EACpC;wEACsE,GACtE,gBAAgB,MAAM,GAAG,SAAS;;AAGpC,+DAA+D,GAC/D,YAAY;EAAU,SAAS;EAAQ,UAAU,MAAM;;AA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,GAAG,SAAS"}
@@ -0,0 +1,27 @@
1
+ import type { NamedTool } from "@yaks/graph";
2
+ import { type Keywords, type Vocab, type VocabDoc } from "@yaks/vocab/runtime";
3
+ import { type Backings, type Derived } from "@yaks/sql";
4
+ import type { Configured, Options } from "./config.js";
5
+ import type { FacetName, Facets, Load } from "./facets.js";
6
+ export type Taken<F extends FacetName> = [Facets[F], Options, string, string[]?, FacetName[]?][];
7
+ export declare let taking: <F extends FacetName>(plugins: Configured[], name: F, load: Load) => Promise<Taken<F>>;
8
+ /** What a config's plugins declare, read without opening anything: their
9
+ * vocabulary documents (each written with the package that brought it), the
10
+ * vocabulary they load into, and the tools they declare. What a command line
11
+ * lists, and what a graph is then built over. */ export type Words = {
12
+ docs: VocabDoc[];
13
+ vocab: Vocab;
14
+ /** the properties the store computes rather than stores */ derived: Derived;
15
+ /** the rows the computed components are read from */ backed: Backings;
16
+ /** the tools the graph these words describe offers, declared and not
17
+ * implemented: the generic tier where the vocabulary gives it one, then every
18
+ * plugin's */ tools: () => Declared[];
19
+ };
20
+ /** A tool as declared, without the code behind it. */ export type Declared = Omit<NamedTool, 'run'>;
21
+ /** A concrete host may compose only the words it explicitly configured.
22
+ * Keywords supplied here likewise replace the plugins' keyword registrations. */ export type WordsOpts = {
23
+ implicit?: boolean;
24
+ keywords?: Keywords[];
25
+ };
26
+ export declare let wordsOf: (vocabs: Taken<'vocab'>, own?: VocabDoc[], opts?: WordsOpts) => Words;
27
+ //# sourceMappingURL=words.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"words.d.ts","sources":["../words.ts"],"names":[],"mappings":"AACA,cAAc,SAAS,2BAAgC;AAKvD,SACE,KAAK,QAAQ,EAEb,KAAK,KAAK,EACV,KAAK,QAAQ,mCACwB;AAEvC,SAAS,KAAK,QAAQ,EAAc,KAAK,OAAO,yBAAyC;AACzF,cAAc,UAAU,EAAE,OAAO,sBAAqB;AACtD,cAAc,SAAS,EAAE,MAAM,EAAE,IAAI,sBAAiC;AAQtE,YAAY,MAAM,UAAU,cAC1B,OAAO,IACP,SACA,MAAM,EACN,MAAM,KACN;AAGF,OAAO,YAAI,SAAgB,UAAU,WACnC,SAAS,cACT,MAAM,GACN,MAAM,SACL,QAAQ,MAAM,IAiBH;AAEd;;;+CAG+C,GAC/C,YAAY;EACV,MAAM;EACN,OAAO;EACP,yDAAyD,GACzD,SAAS;EACT,mDAAmD,GACnD,QAAQ;EACR;;cAEY,GACZ,aAAa;;AAGf,oDAAoD,GACpD,YAAY,WAAW,KAAK,WAAW;AAiBvC;+EAC+E,GAC/E,YAAY;EAAc,WAAW,OAAO;EAAE,WAAW;;AAGzD,OAAO,YAAI,UACT,QAAQ,MAAM,UACd,MAAM,YACN,OAAM,cACL,MAwCF"}
package/anatomy.js ADDED
@@ -0,0 +1,432 @@
1
+ /** Per-composition evidence, separate from the shared vocabulary cache. */ import { groupBy } from "@yaks/fp";
2
+ import { anatomy, anatomyData, anatomyDocuments, anatomyPlugin } from "@yaks/code/anatomy";
3
+ // Options have not been revealed yet. Inspect data descriptors only: a getter
4
+ // on resolved options is a vault read, not a secret-name declaration.
5
+ export let secretNames = (source, seen = new Set())=>{
6
+ if (!source || typeof source != 'object' || seen.has(source)) return [];
7
+ seen.add(source);
8
+ let ds = Object.getOwnPropertyDescriptors(source);
9
+ let keys = Object.keys(ds).filter((k)=>ds[k].enumerable);
10
+ let secret = ds.secret;
11
+ if (keys.length == 1 && keys[0] == 'secret' && secret && 'value' in secret && typeof secret.value == 'string') return [
12
+ secret.value
13
+ ];
14
+ return keys.flatMap((k)=>'value' in ds[k] ? secretNames(ds[k].value, seen) : []);
15
+ };
16
+ let hints = [
17
+ 'title',
18
+ 'options',
19
+ 'readOnly',
20
+ 'destructive',
21
+ 'idempotent',
22
+ 'openWorld',
23
+ 'surfaces',
24
+ 'roles'
25
+ ];
26
+ /** Capture only already-made contributions; none of these methods runs code.
27
+ * What a composition observes is kept as it arrives and applied when its
28
+ * anatomy is read: projecting the vocabulary's declarations is tens of
29
+ * milliseconds of every command, and almost no command reads its anatomy.
30
+ * Package descriptors carry names and allowed facets, never resolved options.
31
+ * Repeated entries select the union of their facets. */ export let compositionAnatomy = (packages, roles, common, secrets = [], where = {
32
+ host: 'native',
33
+ scope: 'native'
34
+ })=>{
35
+ let byPackage = groupBy(packages, (p)=>p.name);
36
+ let names = [
37
+ ...byPackage.keys()
38
+ ];
39
+ let source = {
40
+ ...where,
41
+ observed: {
42
+ packages: true,
43
+ roles: true,
44
+ facets: true,
45
+ comps: true,
46
+ tools: true,
47
+ effects: true,
48
+ rules: true,
49
+ hooks: true,
50
+ routes: true,
51
+ secrets: true,
52
+ commands: false,
53
+ views: false,
54
+ inspectViews: false,
55
+ tui: false,
56
+ kits: false,
57
+ themes: false,
58
+ skills: false
59
+ },
60
+ packages: names.map((name)=>({
61
+ name,
62
+ configured: true,
63
+ declared: true
64
+ })),
65
+ roles: [
66
+ ...Object.keys(common),
67
+ ...names
68
+ ].map((name)=>({
69
+ name,
70
+ ...common[name] ? {} : {
71
+ package: name
72
+ },
73
+ facets: [
74
+ ...common[name] ?? [
75
+ 'service'
76
+ ]
77
+ ],
78
+ declared: true,
79
+ loaded: roles.includes(name),
80
+ bound: roles.includes(name)
81
+ })),
82
+ secrets: secrets.map((s)=>({
83
+ ...s,
84
+ declared: true
85
+ }))
86
+ };
87
+ let facets = new Map();
88
+ let forFacet = (owner, name)=>{
89
+ let key = `${owner}/${name}`;
90
+ let had = facets.get(key);
91
+ if (had) return had;
92
+ let configured = byPackage.get(owner) ?? [];
93
+ let allowed = !configured.length || configured.some((p)=>p.facets === undefined || p.facets.includes(name));
94
+ let selected = allowed && (Object.entries(common).some(([r, fs])=>roles.includes(r) && fs.includes(name)) || name == 'service' && roles.includes(owner));
95
+ let made = {
96
+ name,
97
+ package: owner,
98
+ selected,
99
+ attempted: false
100
+ };
101
+ facets.set(key, made);
102
+ return made;
103
+ };
104
+ for (let owner of names){
105
+ for (let name of [
106
+ 'vocab',
107
+ 'graph',
108
+ 'tools',
109
+ 'effects',
110
+ 'routes',
111
+ 'ui',
112
+ 'service',
113
+ 'cli',
114
+ 'views',
115
+ 'tui'
116
+ ]){
117
+ forFacet(owner, name);
118
+ }
119
+ }
120
+ let registered = new Set();
121
+ let vocabulary = new Set();
122
+ let ownerOf = (name)=>{
123
+ let had = source.packages.find((p)=>p.name == name);
124
+ if (had) return had;
125
+ let made = {
126
+ name,
127
+ configured: false,
128
+ declared: true,
129
+ loaded: false,
130
+ bound: false
131
+ };
132
+ source.packages.push(made);
133
+ return made;
134
+ };
135
+ let binding = (owner, name)=>{
136
+ let f = forFacet(owner, name);
137
+ f.declared = f.loaded = f.bound = true;
138
+ let p = ownerOf(owner);
139
+ p.loaded = p.bound = true;
140
+ };
141
+ let readValue = (input, name)=>{
142
+ if (!input || typeof input != 'object') return undefined;
143
+ let d = Object.getOwnPropertyDescriptor(input, name);
144
+ return d && 'value' in d ? d.value : undefined;
145
+ };
146
+ let entries = (input)=>{
147
+ if (!input || typeof input != 'object') return [];
148
+ return Object.entries(Object.getOwnPropertyDescriptors(input)).filter(([, d])=>d.enumerable && 'value' in d).map(([k, d])=>[
149
+ k,
150
+ d.value
151
+ ]);
152
+ };
153
+ let values = (input)=>Array.isArray(input) ? entries(input).map(([, v])=>v) : [];
154
+ let observe = (o)=>{
155
+ let f = forFacet(o.package, o.facet);
156
+ f.attempted = true;
157
+ f.loaded = o.loaded;
158
+ if (!o.loaded) return;
159
+ f.declared = true;
160
+ ownerOf(o.package).loaded = true;
161
+ if (o.bound) binding(o.package, o.facet);
162
+ let common = {
163
+ package: o.package,
164
+ facet: o.facet,
165
+ declared: true,
166
+ loaded: true,
167
+ bound: o.bound
168
+ };
169
+ if (o.facet == 'ui') {
170
+ for (let group of [
171
+ 'kits',
172
+ 'themes'
173
+ ]){
174
+ source.observed[group] = true;
175
+ source[group] = [
176
+ ...source[group]?.filter((p)=>p.package != o.package) ?? [],
177
+ ...entries(readValue(o.value, group)).map(([name])=>({
178
+ ...common,
179
+ name
180
+ }))
181
+ ];
182
+ }
183
+ return;
184
+ }
185
+ if (o.facet == 'cli') {
186
+ source.observed.commands = true;
187
+ source.commands = [
188
+ ...source.commands?.filter((p)=>p.package != o.package) ?? [],
189
+ ...values(readValue(o.value, 'commands')).flatMap((c, i)=>{
190
+ let name = readValue(c, 'name');
191
+ if (typeof name != 'string') return [];
192
+ let description = readValue(c, 'description');
193
+ return [
194
+ {
195
+ ...common,
196
+ name,
197
+ key: String(i),
198
+ schema: anatomyData(readValue(c, 'inputSchema')),
199
+ ...typeof description == 'string' ? {
200
+ description
201
+ } : {}
202
+ }
203
+ ];
204
+ })
205
+ ];
206
+ return;
207
+ }
208
+ for (let group of o.facet == 'tui' ? [
209
+ 'tui'
210
+ ] : [
211
+ 'views',
212
+ 'inspectViews'
213
+ ]){
214
+ let raw = group == 'inspectViews' ? readValue(o.value, 'inspectViews') : readValue(readValue(o.value, 'views'), 'renderers');
215
+ // A module without inspectViews is not evidence about its page's own
216
+ // curated registry; an exported empty list is evidence of no additions.
217
+ if (raw === undefined || typeof raw == 'function') continue;
218
+ source.observed[group] = true;
219
+ source[group] = [
220
+ ...source[group]?.filter((p)=>p.package != o.package) ?? [],
221
+ ...values(raw).flatMap((r, i)=>{
222
+ let name = readValue(r, 'view');
223
+ if (typeof name != 'string') return [];
224
+ return [
225
+ {
226
+ ...common,
227
+ name,
228
+ key: String(i)
229
+ }
230
+ ];
231
+ })
232
+ ];
233
+ }
234
+ };
235
+ let declarations = (docs, vocab)=>{
236
+ let projected = anatomyDocuments(docs);
237
+ source.comps = projected.comps;
238
+ source.tools = projected.tools;
239
+ source.effects = projected.effects;
240
+ source.rules = projected.rules;
241
+ for (let doc of docs){
242
+ if (!doc.label) continue;
243
+ vocabulary.add(doc.label);
244
+ let f = forFacet(doc.label, 'vocab');
245
+ f.declared = f.loaded = true;
246
+ ownerOf(doc.label).loaded = true;
247
+ }
248
+ for (let c of source.comps ?? []){
249
+ let info = vocab.comp(c.name);
250
+ if (info && !c.extends) c.rules = anatomyData(info);
251
+ for (let p of c.props){
252
+ if (!c.extends) p.rules = anatomyData(vocab.prop(c.name, p.name));
253
+ }
254
+ c.refs = [
255
+ ...new Set(c.props.flatMap((p)=>{
256
+ let ref = vocab.prop(c.name, p.name)?.ref;
257
+ p.refs = ref ? [
258
+ ref
259
+ ] : p.refs;
260
+ return p.refs;
261
+ }))
262
+ ];
263
+ if (!c.extends) {
264
+ c.indexes = vocab.indexes(c.name);
265
+ c.identity = vocab.identity(c.name);
266
+ c.assocs = vocab.assocs().filter(([, a])=>a.comp == c.name).map(([name, a])=>({
267
+ name,
268
+ prop: a.prop
269
+ }));
270
+ }
271
+ }
272
+ };
273
+ let tool = (owner, t, tier)=>{
274
+ // Do not traverse a tool object: even a discarded field could be its host.
275
+ let ds = Object.getOwnPropertyDescriptors(t);
276
+ let data = anatomyData(Object.fromEntries([
277
+ 'name',
278
+ 'inputSchema',
279
+ 'outputSchema',
280
+ 'description',
281
+ ...hints
282
+ ].flatMap((k)=>{
283
+ let d = ds[k];
284
+ return d && 'value' in d ? [
285
+ [
286
+ k,
287
+ d.value
288
+ ]
289
+ ] : [];
290
+ })));
291
+ let kept = Object.fromEntries(hints.flatMap((k)=>data[k] === undefined ? [] : [
292
+ [
293
+ k,
294
+ data[k]
295
+ ]
296
+ ]));
297
+ return {
298
+ name: typeof data.name == 'string' ? data.name : '',
299
+ package: owner,
300
+ facet: 'tools',
301
+ inputSchema: anatomyData(data.inputSchema),
302
+ ...data.outputSchema ? {
303
+ outputSchema: anatomyData(data.outputSchema)
304
+ } : {},
305
+ ...typeof data.description == 'string' ? {
306
+ description: data.description
307
+ } : {},
308
+ hints: kept,
309
+ ...tier ? {
310
+ tier
311
+ } : {},
312
+ declared: true,
313
+ loaded: !!tier,
314
+ bound: !!tier
315
+ };
316
+ };
317
+ // Applied in the order they were observed, the first time anybody reads.
318
+ let pending = [];
319
+ let snapshot;
320
+ let later = (step)=>(...args)=>{
321
+ pending.push(()=>step(...args));
322
+ };
323
+ return {
324
+ read: ()=>{
325
+ if (!snapshot || pending.length) {
326
+ snapshot = undefined;
327
+ for (let step of pending.splice(0))step();
328
+ snapshot = anatomy({
329
+ ...source,
330
+ facets: [
331
+ ...facets.values()
332
+ ]
333
+ });
334
+ }
335
+ // A composition changes only when evidence arrives. Each reader receives
336
+ // an independent value, even while the projection remains current.
337
+ return structuredClone(snapshot);
338
+ },
339
+ observe: later(observe),
340
+ attempted: later((owner, name)=>{
341
+ forFacet(owner, name).attempted = true;
342
+ }),
343
+ loaded: later((owner, name, present)=>{
344
+ let f = forFacet(owner, name);
345
+ f.loaded = f.declared = present;
346
+ if (present) ownerOf(owner).loaded = true;
347
+ }),
348
+ binding: later(binding),
349
+ declarations: later(declarations),
350
+ graph: later((owner, plugins)=>{
351
+ plugins.forEach((p, i)=>{
352
+ let made = anatomyPlugin(owner, p, String(i));
353
+ source.rules = [
354
+ ...source.rules ?? [],
355
+ ...made.rules.map((r)=>({
356
+ ...r,
357
+ bound: false
358
+ }))
359
+ ];
360
+ source.hooks = [
361
+ ...source.hooks ?? [],
362
+ ...made.hooks.map((h)=>({
363
+ ...h,
364
+ bound: false
365
+ }))
366
+ ];
367
+ });
368
+ if (plugins.length) {
369
+ registered.add(owner);
370
+ ownerOf(owner).loaded = true;
371
+ }
372
+ }),
373
+ graphed: later(()=>{
374
+ for (let r of source.rules ?? [])r.bound = true;
375
+ for (let h of source.hooks ?? [])h.bound = true;
376
+ for (let c of source.comps ?? [])c.bound = true;
377
+ for (let owner of vocabulary)binding(owner, 'vocab');
378
+ for (let owner of registered)binding(owner, 'graph');
379
+ }),
380
+ tier: later((tools, owner = '@yaks/graph')=>{
381
+ ownerOf(owner);
382
+ binding(owner, 'tools');
383
+ source.tools = [
384
+ ...source.tools ?? [],
385
+ ...tools.map((t)=>tool(owner, t, owner == '@yaks/graph' ? 'graph' : 'tools'))
386
+ ];
387
+ }),
388
+ runs: later((owner, names, joined)=>{
389
+ if (joined.length) binding(owner, 'tools');
390
+ for (let t of source.tools ?? []){
391
+ if (t.package != owner) continue;
392
+ t.loaded = names.includes(t.name);
393
+ t.bound = joined.includes(t.name);
394
+ }
395
+ }),
396
+ effects: later((handlers, serving)=>{
397
+ for (let e of source.effects ?? []){
398
+ e.handler = handlers.get(e.name);
399
+ e.loaded = !!e.handler;
400
+ e.bound = serving;
401
+ e.noop = serving && !e.handler;
402
+ if (e.handler) binding(e.handler, 'effects');
403
+ }
404
+ }),
405
+ due: later((names)=>{
406
+ for (let e of source.effects ?? []){
407
+ if (!names.includes(e.name)) continue;
408
+ e.handler = '@yaks/tools';
409
+ e.noop = false;
410
+ e.loaded = e.bound = true;
411
+ }
412
+ if (names.length) binding('@yaks/tools', 'effects');
413
+ }),
414
+ routes: later((owner, routes)=>{
415
+ source.routes = [
416
+ ...source.routes ?? [],
417
+ ...routes.map((r, i)=>({
418
+ name: `${r.method} ${r.path}`,
419
+ package: owner,
420
+ facet: 'routes',
421
+ key: String(i),
422
+ method: r.method,
423
+ path: r.path,
424
+ loaded: true,
425
+ bound: true
426
+ }))
427
+ ];
428
+ binding(owner, 'routes');
429
+ })
430
+ };
431
+ };
432
+ //# sourceMappingURL=anatomy.js.map
package/anatomy.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"anatomy.js","sources":["./anatomy.ts"],"names":[],"mappings":"AAAA,yEAAyE,GACzE,SAAS,OAAO,wBAA6B;AAC7C,SAEE,OAAO,EACP,WAAW,EACX,gBAAgB,EAEhB,aAAa,kCAGuB;AAItC,8EAA8E;AAC9E,sEAAsE;AACtE,OAAO,IAAI,cAAc,CACvB,QACA,OAAoB,IAAI,KAAa;EAErC,IAAI,CAAC,UAAU,OAAO,UAAU,YAAY,KAAK,GAAG,CAAC,SAAS,OAAO,EAAE;EACvE,KAAK,GAAG,CAAC;EACT,IAAI,KAAK,OAAO,yBAAyB,CAAC;EAC1C,IAAI,OAAO,OAAO,IAAI,CAAC,IAAI,MAAM,CAAC,CAAC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