@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,150 @@
1
+ import type { FacetName } from "./facets.js";
2
+ import { CallError } from "@yaks/tools/errors";
3
+ import type { Vocab } from "@yaks/vocab";
4
+ /** The options a config passes to one plugin, given to each of that plugin's
5
+ * exported factories as the second argument, after the host. A value written
6
+ * `{"secret": "NAME"}` is that secret's value, read every time it is accessed
7
+ * ({@link revealed}), so a config names a secret without holding one — and
8
+ * a factory that re-reads its options picks up a secret written after the host
9
+ * started. A runtime that holds bindings lends one written `{"binding":
10
+ * "NAME"}` the same way. */ export type Options = Record<string, unknown>;
11
+ /** A plugin a config names: a bare specifier, or one with options and chosen words. */ export type Plug = string | {
12
+ use: string;
13
+ with?: Options;
14
+ words?: string[];
15
+ /** The facets this host composes; omitted takes all exported facets. */ facets?: FacetName[];
16
+ };
17
+ /** A resolved plugin, its options and optional word and facet selections. */ export type Configured = [string, Options, string[]?, FacetName[]?];
18
+ /** A config file: where the graph lives, and what reads and writes it. */ export type Config = {
19
+ /** Systemd unit templates rolled by `yak restart`. A worker selects its
20
+ * entry with `yak work --process <unit>`; omitted roles takes all duties
21
+ * except those explicitly excluded. Optional entries roll only if active. */ processes?: {
22
+ unit: string;
23
+ roles?: string[];
24
+ except?: string[];
25
+ optional?: boolean;
26
+ }[];
27
+ /** Explicit connector bindings for file-and-command workspace targets. */ workspaces?: {
28
+ connectors: Record<string, {
29
+ use: string;
30
+ with?: Record<string, unknown>;
31
+ }>;
32
+ receipts: string;
33
+ };
34
+ /** Sandbox adapters, separate from computer connection transports. */ sandboxes?: import("@yaks/sandbox/lifecycle").Configuration & {
35
+ defaultProvider?: string;
36
+ };
37
+ /** the SQLite file, or `:memory:` for a graph that lasts as long as the
38
+ * process. Required — a host never guesses a database. */ db?: string;
39
+ /** Report to this durable spool without opening the tracker graph. */ tracker?: {
40
+ spool: string;
41
+ commit?: string;
42
+ };
43
+ /** the plugin packages, by import specifier. A relative specifier is
44
+ * resolved against the config file itself; `{use, with, words, facets}` names one
45
+ * with options and an optional list of its vocabulary definitions. Omitted
46
+ * `words` takes its whole vocabulary; `[]` takes none of its definitions.
47
+ * `facets` restricts which subpaths are imported; omitted takes all. */ plugins?: Plug[];
48
+ /** the kinds of store one host serves, each by its own config: a Worker
49
+ * whose one object class opens a recipe app's store and the platform's
50
+ * directory alike gives each kind its own plugins. A store reads its
51
+ * kind's; the host's own `plugins` are what serves them. */ stores?: Record<string, Config>;
52
+ /** what `yak serve` listens on (default @yaks/api's `PORT`) */ port?: number;
53
+ /** which interface it binds (default @yaks/api's `HOSTNAME`, this machine
54
+ * alone; `0.0.0.0` offers it to every network the machine is on) */ hostname?: string;
55
+ /** whether the store mints a short human-readable number beside each entity
56
+ * id, in the series of the letter its component declares (@yaks/id). Opt-in:
57
+ * left out, no entity gets one, because a number exists for a person to type
58
+ * and most hosts have nobody typing. */ numbers?: boolean;
59
+ /** what the MCP server calls itself (default `yak`) */ name?: string;
60
+ /** the person who works at this machine, as any id the graph resolves (an
61
+ * eid, a human id, a name). What they type here is signed with them: a
62
+ * prompt their harness's transcript marks as typed (@yaks/session
63
+ * `service`), a line typed into the harness's terminal (@yaks/harness), and
64
+ * a command line run at a terminal that names no session (./local.ts
65
+ * `signer`). Left out, nothing is signed as a person: a machine never
66
+ * guesses who is at its keyboard (./host.ts `person`). */ person?: string;
67
+ /** how long this process's lease on a duty, or its claim on an effect
68
+ * run, stands before another process may take it over, in milliseconds
69
+ * (default 30_000 for a duty, 60_000 for a run). A holder still doing the
70
+ * work renews it on a timer; one that was killed leaves a lease that
71
+ * expires, which is how a second long-running process takes over without
72
+ * anybody having to reap the first. */ lease?: number;
73
+ /** whether this process runs its duties: the effect pool, each plugin's
74
+ * `./service`, and the start-up passes a plugin holds a lease for (default
75
+ * true). `false` takes no lease, works no effects and runs none of them, so
76
+ * the process answers what it is asked and nothing else — what its writes
77
+ * owe is left written down for a process that does — what `yak --no-duties`
78
+ * sets. */ duties?: boolean;
79
+ };
80
+ /** How a config's store numbers its entities (@yaks/sqlite `Numbering`):
81
+ * not at all, or in the series of each letter a component declares (@yaks/id).
82
+ *
83
+ * ```ts
84
+ * import { numbering } from '@yaks/host/config'
85
+ * import { idKeywords } from '@yaks/id'
86
+ * import { loadVocab } from '@yaks/vocab'
87
+ * import { equal } from '@yaks/testing'
88
+ *
89
+ * const vocab = loadVocab({
90
+ * $defs: {
91
+ * task: { component: true, prefix: 'T', properties: {} },
92
+ * edge: { component: true, properties: {} },
93
+ * },
94
+ * }, [idKeywords])
95
+ * equal(numbering(vocab, undefined), false)
96
+ * equal(numbering(vocab, true), { task: 'T' })
97
+ * ```
98
+ */ export declare let numbering: (vocab: Vocab, numbers: Config['numbers']) => false | Record<string, string>;
99
+ /** The package a plugin entry names. */ export declare let used: (plug: Plug) => string;
100
+ /** The options passed to its factories. */ export declare let given: (plug: Plug) => Options;
101
+ /** The definitions selected from its vocabulary, or all when omitted. */ export declare let chosen: (plug: Plug) => string[] | undefined;
102
+ /** The facets selected for this host, or all when omitted. */ export declare let facetsOf: (plug: Plug) => FacetName[] | undefined;
103
+ /** How a host reads what a config names without holding: each kind of
104
+ * reference (`secret`, `binding`) it can read, by the name written in it. */ export type Reveal = Partial<Record<'secret' | 'binding', (name: string) => unknown>>;
105
+ /**
106
+ * Options with each reference in them read by `reveal` at the moment it is
107
+ * accessed, so a value that arrives after the host started is read the next
108
+ * time. A reference whose kind the host does not read stays as written.
109
+ *
110
+ * ```ts
111
+ * import { revealed } from '@yaks/host/config'
112
+ * import { equal } from '@yaks/testing'
113
+ *
114
+ * let env: Record<string, unknown> = { TOKEN: 't' }
115
+ * let options = revealed(
116
+ * { token: { secret: 'TOKEN' }, mail: { binding: 'MAIL' }, base: 'x' },
117
+ * { secret: (name) => env[name] },
118
+ * ) as Record<string, unknown>
119
+ * equal(options, { token: 't', mail: { binding: 'MAIL' }, base: 'x' })
120
+ * env.TOKEN = 'u'
121
+ * equal(options.token, 'u')
122
+ * ```
123
+ */ export declare let revealed: (value: unknown, reveal: Reveal) => unknown;
124
+ /** A {@link Reveal} that reads every kind from one record by name: a Worker's
125
+ * env, which holds its secrets and its bindings alike. */ export declare let holding: (held: object) => Reveal;
126
+ /** Live bindings with a second source taking precedence for its own keys. */ export declare let overlaid: <Base extends object, Extra extends object>(base: Base, extra: () => Extra) => Base & Extra;
127
+ /** Each plugin a config names, with its options, each reference among them
128
+ * read by `reveal` when accessed. */ export declare let configured: (config: Config, reveal?: Reveal) => Configured[];
129
+ /**
130
+ * Refuse a store whose data requires a plugin this config does not compose:
131
+ * one it does not list, or lists with its graph facet left out, which is where
132
+ * a plugin's writes are shaped. `requirements` is what the store recorded
133
+ * (@yaks/sqlite `requirements`), and the error names every one missing.
134
+ *
135
+ * ```ts
136
+ * import { meet } from '@yaks/host/config'
137
+ * import { throws } from '@yaks/testing'
138
+ *
139
+ * meet({ plugins: ['@yaks/blob'] }, ['@yaks/blob'])
140
+ * await throws(
141
+ * () => meet({ plugins: ['@yaks/doc'] }, ['@yaks/blob', '@yaks/journal']),
142
+ * 'requires @yaks/blob and @yaks/journal,',
143
+ * )
144
+ * ```
145
+ */ export declare let meet: (config: Config, requirements: readonly string[]) => void;
146
+ /** A store requires plugins its opener's config does not compose. */ export declare class Unmet extends CallError {
147
+ plugins: string[];
148
+ constructor(plugins: string[]);
149
+ }
150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M,EAAsC;AAEtE,sCAAsC,GACtC,OAAO,YAAI,OAAQ,MAAM,SAAO,MAAM,CACK;AAC3C,yCAAyC,GACzC,OAAO,YAAI,QAAS,MAAM,SAAO,QACe;AAChD,uEAAuE,GACvE,OAAO,YAAI,SAAU,MAAM,SAAO,MAAM,KAAK,SAAS,CACJ;AAElD,4DAA4D,GAC5D,OAAO,YAAI,WAAY,MAAM,SAAO,cAAc,SAAS,CACR;AAEnD;2EAC2E,GAC3E,YAAY,SAAS,QACnB,OAAO,WAAW,YAAY,MAAM,MAAM,KAAK,OAAO;AAoBxD;;;;;;;;;;;;;;;;;;CAkBC,GACD,OAAO,YAAI,WAAY,OAAO,OAAO,EAAE,QAAQ,WAAS,OAAO,CAkB9D;AAED;wDACwD,GACxD,OAAO,YAAI,UAAW,MAAM,MAAM,KAAG,OAGpC;AAED,2EAA2E,GAC3E,OAAO,YAAI,WAAY,aAAa,MAAM,EAAE,cAAc,MAAM,EAC9D,MAAM,MACN,aAAa,UACZ,OAAO,MAiBT;AAED;mCACmC,GACnC,OAAO,YAAI,aAAc,QAAQ,QAAQ,SAAQ,WAAc,aAQ3D;AAEJ;;;;;;;;;;;;;;;;CAgBC,GACD,OAAO,YAAI,OAAQ,QAAQ,QAAQ,uBAAuB,MAAM,OAAK,IAAI,CAOxE;AAQD,mEAAmE,GACnE,OAAO,cAAM,cAAc;EACN,SAAS,MAAM;EAAlC,YAAY,AAAO,SAAS,MAAM,EAAE;AAYtC"}
@@ -0,0 +1,9 @@
1
+ import { type VocabDoc } from "@yaks/vocab/runtime";
2
+ /** Select definitions without changing their schemas or document metadata.
3
+ * Every name must exist: a misspelled selection must not silently lose words.
4
+ * A kind a document declares of another document's component is kept with it
5
+ * (@yaks/vocab `narrow`), since no pick of this plugin's words names it. */ export declare let selected: (docs: VocabDoc[], names: string[] | undefined, plugin: string) => VocabDoc[];
6
+ /** A graph's own component declarations replace the plugins' declarations
7
+ * and extensions of those components. Its extensions still add to plugins. */ export declare let beneath: (docs: VocabDoc[], own: VocabDoc[]) => VocabDoc[];
8
+ export declare let docsOf: (docs: VocabDoc[]) => VocabDoc[];
9
+ //# sourceMappingURL=documents.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"documents.d.ts","sources":["../documents.ts"],"names":[],"mappings":"AAUA,SAAiB,KAAK,QAAQ,mCAAwC;AAEtE;;;0EAG0E,GAC1E,OAAO,YAAI,WACT,MAAM,YACN,OAAO,MAAM,KAAK,SAAS,EAC3B,QAAQ,MAAM,KACb,WAWF;AAED;4EAC4E,GAC5E,OAAO,YAAI,UAAW,MAAM,YAAY,KAAK,eAAa,WA8BzD;AAED,OAAO,YAAI,SAAU,MAAM,eAAa,WAqCvC"}
@@ -0,0 +1,164 @@
1
+ /** The subpaths a plugin contributes to a composed graph. */ import type { Arrived, Authenticate, Filter, Handler, Offers, Route, Told } from "@yaks/api";
2
+ import type { Eid, Plugin } from "@yaks/graph";
3
+ import type { Backings, Derived, Extension, History, Stmt } from "@yaks/sql";
4
+ import type { Handlers } from "@yaks/effects";
5
+ import type { Reply } from "@yaks/tools";
6
+ import type { Runs } from "@yaks/graph/tools";
7
+ import type { Contributions } from "@yaks/ui/contributions";
8
+ import type { Keywords, Vocab, VocabDoc } from "@yaks/vocab";
9
+ import type { Embedding, Feed, Host } from "./mod.js";
10
+ import type { Arrival, Chatter, MailDomains, Notices, Sender, Texter } from "./senders.js";
11
+ import type { Payments } from "./payments.js";
12
+ import type { Keeper } from "./keepers.js";
13
+ import type { Options } from "./config.js";
14
+ /** `<plugin>/vocab` — what the plugin declares, and nothing that could not
15
+ * run in a browser tab: a page importing this must never reach SQL, a database
16
+ * driver or a server runtime. */ export type VocabFacet = {
17
+ /** what the plugin is: its package's own description, from its package.json,
18
+ * written on each of its documents beside its name */ description?: string;
19
+ /** the components and tools this plugin declares */ docs?: VocabDoc[];
20
+ /** the JSON Schema keywords those documents use (@yaks/vocab `loadVocab`) */ keywords?: Keywords[];
21
+ /** properties the store computes rather than stores, written as SQL */ derived?: (vocab: Vocab) => Derived;
22
+ /** the rows each computed component this plugin declares is read from
23
+ * (@yaks/sql `Backing`), given the store's read overrides */ backed?: (vocab: Vocab, derived: Derived) => Backings;
24
+ };
25
+ /** `<plugin>/graph` — what a write means, what a query may ask for, and who
26
+ * is writing. `schema` says, as data, the tables of its own the plugin's store
27
+ * needs, which a writing host adds with the rest of its composed schema
28
+ * (@yaks/sqlite `follow`); `plugins` binds hooks without changing storage. `extend` contributes the clause
29
+ * compilers every read path consults (@yaks/sql `Extension`), which is how a
30
+ * package holding an index of its own — a text search, a vector, a link table
31
+ * — can answer a clause the compiler would otherwise reject.
32
+ *
33
+ * `authenticate` names the caller behind a request, for every door over this
34
+ * graph: a command line asks it about the session it speaks for exactly as an
35
+ * HTTP request is asked (the concrete host's signer), so it belongs to the graph role
36
+ * rather than to the routes. It is a factory like every other plugin export,
37
+ * because naming a caller is a read: @yaks/session resolves a request to the
38
+ * session it claims to speak for, which it can only do through the host's own
39
+ * graph. It is handed the host with nothing open on it yet — keep the
40
+ * reference, do not call it. At most one plugin may answer it. */ export type GraphFacet = {
41
+ /** The statements creating this plugin's own tables, each of which only adds
42
+ * what is missing; a table that stands gains the columns it lacks. */ schema?: (host: Host, options: Options) => Stmt[];
43
+ plugins?: (host: Host, options: Options) => Plugin[];
44
+ /** Bundles owed to a caller beside the answer to a direct tool call. */ reply?: (host: Host, options: Options) => Reply;
45
+ extend?: (host: Host, options: Options) => Extension[];
46
+ /** Search a phrase by meaning through this plugin's own index. */ meaning?: (host: Host, options: Options) => Meaning;
47
+ /** Read into memory what this plugin's reads would otherwise read from
48
+ * disk each time, for a process that answers many reads
49
+ * ({@link Host.preload}): @yaks/embedding's vectors. */ preload?: (host: Host, options: Options) => () => void | Promise<void>;
50
+ /** The mail senders this plugin lends, by name ({@link Host.senders}): a
51
+ * provider's, built from its options. One name has one sender. */ senders?: (host: Host, options: Options) => Record<string, Sender>;
52
+ /** The texters this plugin lends, by name ({@link Host.texters}). */ texters?: (host: Host, options: Options) => Record<string, Texter>;
53
+ /** The chatters this plugin lends, by platform ({@link Host.chatters}). */ chatters?: (host: Host, options: Options) => Record<string, Chatter>;
54
+ /** The embedders this plugin lends, by name ({@link Host.embedders}). */ embedders?: (host: Host, options: Options) => Record<string, Embedding>;
55
+ /** The keepers this plugin lends, by name ({@link Host.keepers}). */ keepers?: (host: Host, options: Options) => Record<string, Keeper>;
56
+ /** The readers of a provider's signed notices about the letters it
57
+ * carried, by name, for a host that routes them itself (./lending.ts). */ notices?: (host: Host, options: Options) => Record<string, Notices>;
58
+ /** The readers of a letter a runtime handed its host, by name, for a host
59
+ * that receives one itself (./lending.ts). */ arrivals?: (host: Host, options: Options) => Record<string, Arrival>;
60
+ /** The mail domains this plugin's provider sets up, reads and removes, by
61
+ * name, for a host that gives its people mail at their own domains
62
+ * (./lending.ts). */ mailDomains?: (host: Host, options: Options) => Record<string, MailDomains>;
63
+ /** The payment providers this plugin lends, by name, for a host that takes
64
+ * money itself (./payments.ts). */ payments?: (host: Host, options: Options) => Record<string, Payments>;
65
+ /** who a request is from, or none where these options name nobody to ask */ authenticate?: (host: Host, options: Options) => Authenticate | undefined;
66
+ /** the commits other hosts make to this store (@yaks/journal's feed), or
67
+ * none where these options keep no feed */ feed?: (host: Host, options: Options) => Feed | undefined;
68
+ /** Whether a store this plugin writes to, configured with `options`, is
69
+ * shaped so that only this plugin reads or writes it correctly from then
70
+ * on. A writing host records it in the store, and a host whose config leaves
71
+ * the plugin out refuses to open the store (./config.ts `meet`). */ required?: (options: Options) => boolean;
72
+ /** What the store keeps every version a write replaces with, where this
73
+ * plugin's options ask it to (@yaks/journal's versions). Asked before the
74
+ * store is opened; at most one plugin answers. */ history?: (options: Options) => History | undefined;
75
+ };
76
+ /** A result from a plugin's meaning index, with an excerpt of its source. */ export type MeaningHit = {
77
+ entity: Eid;
78
+ similarity: number;
79
+ excerpt: string;
80
+ };
81
+ /** Words → the entities nearest them in meaning, closest first, at most
82
+ * `limit` of them. `within` is a filter line naming the entities a hit must be
83
+ * among; its directives are ignored. */ export type Meaning = (words: string, opts?: {
84
+ limit?: number;
85
+ within?: string;
86
+ }) => Promise<MeaningHit[]>;
87
+ /** `<plugin>/tools` — the functions behind its `tool: true` declarations,
88
+ * keyed by tool name.
89
+ *
90
+ * A factory, like every other plugin export, because a tool function needs the
91
+ * same things the others do: a check over a package's own SQL table reaches it
92
+ * through `host.storage` (@yaks/sqlite's storage scan, @yaks/embedding's vector
93
+ * index), and a threshold or a relation name belongs in the config, not the
94
+ * code. What a tool function is handed per call — the graph, the caller, the
95
+ * arguments — still arrives on the tool context. */ export type ToolsFacet = {
96
+ runs?: (host: Host, options: Options) => Runs;
97
+ };
98
+ /** `<plugin>/effects` — the code behind effects the composed vocabulary
99
+ * declares (`effect: true`), keyed by the name each is declared under. A mail
100
+ * sender, a process launcher: what an effect acts on is named in this
101
+ * plugin's options. Usually the code is the declaring plugin's own; a plugin
102
+ * may instead handle one another declares, lending what only it has (the
103
+ * machine a transcript's run is given, @yaks/harness). Each effect has one
104
+ * handler, and a declared effect this process gives no code owes no run. */ export type EffectsFacet = {
105
+ effects?: (host: Host, options: Options) => Handlers;
106
+ };
107
+ /** `<plugin>/routes` — the HTTP a plugin adds, and, for the one plugin that
108
+ * hosts them, what answers a request at all.
109
+ *
110
+ * `handler` is exported by at most one plugin per host; it is called last,
111
+ * with the graph open and `host.routes` holding every listed plugin's routes,
112
+ * and what it returns is {@link Host.handler}. @yaks/api is that plugin, so a
113
+ * config naming it serves HTTP and a config leaving it out has a host that
114
+ * answers no request and never asks the others for routes. */ export type RoutesFacet = {
115
+ routes?: (host: Host, options: Options) => Route[];
116
+ /** a check every request passes before any route answers it; a plugin's
117
+ * word on which requests reach this host at all (@yaks/tunnel's link) */ filter?: (host: Host, options: Options) => Filter;
118
+ /** who a request that came through this plugin's link is from, asked
119
+ * before the graph's own `authenticate` ({@link Host.who}) */ arrived?: (host: Host, options: Options) => Arrived;
120
+ /** the tools a request that came through this plugin's link is offered
121
+ * ({@link Host.offers}) */ offers?: (host: Host, options: Options) => Offers;
122
+ /** what a request that came through this plugin's link is told before a
123
+ * door's own instructions ({@link Host.told}) */ told?: (host: Host, options: Options) => Told;
124
+ handler?: (host: Host, options: Options) => Handler;
125
+ };
126
+ /** One duty that exactly one process at a time runs: the lease name
127
+ * to hold it under, and the work. `run` does at least one pass and then keeps
128
+ * going until the signal aborts — a loop on a timer, or a single pass followed
129
+ * by a wait — so the lease stays this process's for as long as it is up. */ export type Duty = {
130
+ /** the lease name it is held under: the package that owns the work */ name: string;
131
+ run: (signal: AbortSignal) => void | Promise<void>;
132
+ };
133
+ /** `<plugin>/service` — the work this plugin keeps doing while a process
134
+ * serving that plugin's role is up: a timer, a poll, a sweep. It is neither a
135
+ * request nor what a commit owes, which is why neither `routes` nor `effects`
136
+ * could hold it: a scheduled wake coming due, and a mailbox that has to be
137
+ * polled, are things nobody is calling about.
138
+ *
139
+ * It does at least one pass and then keeps going until the signal aborts, so
140
+ * one function serves a process of either shape: a server holds it open for as
141
+ * long as it is up, and a one-shot command hands it a signal that has already
142
+ * aborted and gets the single pass. Of the processes serving that role over
143
+ * one graph, which one is doing it is settled by a lease
144
+ * ({@link Host.duties}). */ export type ServiceFacet = {
145
+ service?: (host: Host, options: Options, signal: AbortSignal) => void | Promise<void>;
146
+ };
147
+ /** What each subpath a role imports is expected to export. Every field is
148
+ * optional: a plugin exports what it has, and the host uses what it finds. */ export type Facets = {
149
+ vocab: VocabFacet;
150
+ graph: GraphFacet;
151
+ tools: ToolsFacet;
152
+ effects: EffectsFacet;
153
+ ui: Contributions;
154
+ routes: RoutesFacet;
155
+ service: ServiceFacet;
156
+ };
157
+ /** How one of a plugin's subpaths becomes a module. `null` means the package
158
+ * does not export that subpath. Injectable, so a test can assemble a host from
159
+ * modules it wrote inline rather than files on disk. */ export type FacetName = keyof Facets;
160
+ export type Load<Extra extends object = Record<never, never>> = {
161
+ <F extends keyof (Facets & Extra)>(plugin: string, facet: F) : Promise<(Facets & Extra)[F] | null>;
162
+ /** Import exactly the selected facets in one dependency graph, if supported. */ together?: (requests: readonly (readonly [string, keyof (Facets & Extra)])[]) => Promise<unknown>;
163
+ };
164
+ //# sourceMappingURL=facets.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"facets.d.ts","sources":["../facets.ts"],"names":[],"mappings":"AAAA,2DAA2D,GAC3D,cACE,OAAO,EACP,YAAY,EACZ,MAAM,EACN,OAAO,EACP,MAAM,EACN,KAAK,EACL,IAAI,yBACuB;AAC7B,cAAc,GAAG,EAAE,MAAM,2BAAgC;AACzD,cAAc,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,yBAA8B;AACvF,cAAc,QAAQ,6BAAkC;AACxD,cAAc,KAAK,2BAAgC;AACnD,cAAc,IAAI,iCAAsC;AACxD,cAAc,aAAa,sCAA2C;AACtE,cAAc,QAAQ,EAAE,KAAK,EAAE,QAAQ,2BAAgC;AACvE,cAAc,SAAS,EAAE,IAAI,EAAE,IAAI,mBAAkB;AACrD,cACE,OAAO,EACP,OAAO,EACP,WAAW,EACX,OAAO,EACP,MAAM,EACN,MAAM,uBACa;AACrB,cAAc,QAAQ,wBAAuB;AAC7C,cAAc,MAAM,uBAAsB;AAC1C,cAAc,OAAO,sBAAqB;AAC1C;;+BAE+B,GAC/B,YAAY;EACV;sDACoD,GACpD,cAAc,MAAM;EACpB,kDAAkD,GAClD,OAAO;EACP,2EAA2E,GAC3E,WAAW;EACX,qEAAqE,GACrE,WAAW,OAAO,UAAU;EAC5B;6DAC2D,GAC3D,UAAU,OAAO,OAAO,SAAS,YAAY;;AAG/C;;;;;;;;;;;;;;;gEAegE,GAChE,YAAY;EACV;sEACoE,GACpE,UAAU,MAAM,MAAM,SAAS,YAAY;EAC3C,WAAW,MAAM,MAAM,SAAS,YAAY;EAC5C,sEAAsE,GACtE,SAAS,MAAM,MAAM,SAAS,YAAY;EAC1C,UAAU,MAAM,MAAM,SAAS,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SAAS,YAAY;;AAEpE;;;;;;0EAM0E,GAC1E,YAAY;EACV,WAAW,MAAM,MAAM,SAAS,YAAY;;AAG9C;;;;;;;4DAO4D,GAC5D,YAAY;EACV,UAAU,MAAM,MAAM,SAAS,YAAY;EAC3C;yEACuE,GACvE,UAAU,MAAM,MAAM,SAAS,YAAY;EAC3C;8DAC4D,GAC5D,WAAW,MAAM,MAAM,SAAS,YAAY;EAC5C;2BACyB,GACzB,UAAU,MAAM,MAAM,SAAS,YAAY;EAC3C;iDAC+C,GAC/C,QAAQ,MAAM,MAAM,SAAS,YAAY;EACzC,WAAW,MAAM,MAAM,SAAS,YAAY;;AAG9C;;;0EAG0E,GAC1E,YAAY;EACV,oEAAoE,GACpE,MAAM,MAAM;EACZ,MAAM,QAAQ,gBAAgB,IAAI,GAAG,QAAQ,IAAI;;AAGnD;;;;;;;;;;;0BAW0B,GAC1B,YAAY;EACV,WACE,MAAM,MACN,SAAS,SACT,QAAQ,gBACL,IAAI,GAAG,QAAQ,IAAI;;AAG1B;4EAC4E,GAC5E,YAAY;EACV,OAAO;EACP,OAAO;EACP,OAAO;EACP,SAAS;EACT,IAAI;EACJ,QAAQ;EACR,SAAS;;AAGX;;sDAEsD,GACtD,YAAY,kBAAkB;AAE9B,YAAY,KAAK,cAAc,MAAM,GAAG,OAAO,KAAK,EAAE,KAAK;GACxD,iBAAiB,SAAS,QACzB,QAAQ,MAAM,EACd,OAAO,KACN,SAAS,SAAS,OAAO,KAAK,IAAI;EACrC,8EAA8E,GAC9E,YACE,8BAA8B,MAAM,SAAS,SAAS,eACnD,QAAQ,OAAO"}
@@ -0,0 +1,15 @@
1
+ /** Where a key goes besides the graph's own vault: a keeper puts a value at
2
+ * one of its own places (a password manager's item, a Worker's secret). A
3
+ * plugin lends one by name, and whoever asks for a key names the keepers and
4
+ * places it goes to as data (@yaks/connections `connection.keep`). The host
5
+ * owns the keeper's own credentials. */ /** One place a key is kept, as an ask names it: the keeper's name, and the
6
+ * keeper's own address for the key there. */ export type Place = {
7
+ via: string;
8
+ at: string;
9
+ };
10
+ /** Puts a value at a place of its own, resolving once it is there and
11
+ * rejecting with why it is not. Putting the same value again is harmless. */ export type Keeper = {
12
+ keep: (at: string, value: string) => Promise<void>;
13
+ /** Why it cannot keep anything yet, such as its own credential not set. */ waiting?: () => string | undefined;
14
+ };
15
+ //# sourceMappingURL=keepers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keepers.d.ts","sources":["../keepers.ts"],"names":[],"mappings":"AAAA;;;;sCAIsC,GAEtC;2CAC2C,GAC3C,YAAY;EAAU,KAAK,MAAM;EAAE,IAAI,MAAM;;AAE7C;2EAC2E,GAC3E,YAAY;EACV,OAAO,IAAI,MAAM,EAAE,OAAO,MAAM,KAAK,QAAQ,IAAI;EACjD,yEAAyE,GACzE,gBAAgB,MAAM,GAAG,SAAS"}
@@ -0,0 +1,3 @@
1
+ import type { Keywords } from "@yaks/vocab";
2
+ /** The keywords brought, and the ones every host understands beside them. */ export declare let understood: (brought?: Keywords[]) => Keywords[];
3
+ //# sourceMappingURL=keywords.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"keywords.d.ts","sources":["../keywords.ts"],"names":[],"mappings":"AAaA,cAAc,QAAQ,2BAAgC;AAEtD,2EAA2E,GAC3E,OAAO,YAAI,aAAc,UAAS,eAAkB,WAQnD"}
@@ -0,0 +1,34 @@
1
+ import type { Embedding, Host } from "./mod.js";
2
+ import type { Arrival, Chatter, MailDomains, Notices, Sender, Texter } from "./senders.js";
3
+ import type { Payments } from "./payments.js";
4
+ import type { Keeper } from "./keepers.js";
5
+ import type { Taken } from "./words.js";
6
+ /** What each kind of loan is. */ export type Lends = {
7
+ senders: Sender;
8
+ texters: Texter;
9
+ chatters: Chatter;
10
+ embedders: Embedding;
11
+ notices: Notices;
12
+ arrivals: Arrival;
13
+ mailDomains: MailDomains;
14
+ payments: Payments;
15
+ keepers: Keeper;
16
+ };
17
+ /** The loans of one kind the graph facets make, beside the host's own
18
+ * `lent`, or `lent` itself where no plugin makes one. A name lent twice is
19
+ * refused.
20
+ *
21
+ * ```ts
22
+ * import { lending } from '@yaks/host/lending'
23
+ * import { equal, throws } from '@yaks/testing'
24
+ *
25
+ * let sender = { send: () => Promise.resolve({}) }
26
+ * let lends = { senders: () => ({ post: sender }) }
27
+ * equal(Object.keys(lending([[lends, {}, '@a/post']], {}, 'senders')!), ['post'])
28
+ * throws(
29
+ * () => lending([[lends, {}, '@a/post']], {}, 'senders', { post: sender }),
30
+ * 'the sender post is lent by both the host and @a/post',
31
+ * )
32
+ * ```
33
+ */ export declare let lending: <K extends keyof Lends>(graphs: Taken<'graph'>, host: Partial<Host>, kind: K, lent?: Readonly<Record<string, Lends[K]>>) => Readonly<Record<string, Lends[K]>> | undefined;
34
+ //# sourceMappingURL=lending.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lending.d.ts","sources":["../lending.ts"],"names":[],"mappings":"AAQA,cAAc,SAAS,EAAE,IAAI,mBAAkB;AAC/C,cACE,OAAO,EACP,OAAO,EACP,WAAW,EACX,OAAO,EACP,MAAM,EACN,MAAM,uBACa;AACrB,cAAc,QAAQ,wBAAuB;AAC7C,cAAc,MAAM,uBAAsB;AAC1C,cAAc,KAAK,qBAAoB;AAEvC,+BAA+B,GAC/B,YAAY;EACV,SAAS;EACT,SAAS;EACT,UAAU;EACV,WAAW;EACX,SAAS;EACT,UAAU;EACV,aAAa;EACb,UAAU;EACV,SAAS;;AAGX;;;;;;;;;;;;;;;;CAgBC,GACD,OAAO,YAAI,UAAW,gBAAgB,OACpC,QAAQ,MAAM,UACd,MAAM,QAAQ,OACd,MAAM,GACN,OAAO,SAAS,OAAO,MAAM,EAAE,MAAM,SACpC,SAAS,OAAO,MAAM,EAAE,MAAM,OAAO,SAAS,CAoBhD"}