@yaks/tools 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 (138) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +870 -2
  3. package/_dist/access.d.ts +3 -0
  4. package/_dist/access.d.ts.map +1 -0
  5. package/_dist/app-view.d.ts +27 -0
  6. package/_dist/app-view.d.ts.map +1 -0
  7. package/_dist/args.d.ts +23 -0
  8. package/_dist/args.d.ts.map +1 -0
  9. package/_dist/check.d.ts +32 -0
  10. package/_dist/check.d.ts.map +1 -0
  11. package/_dist/declared.d.ts +66 -0
  12. package/_dist/declared.d.ts.map +1 -0
  13. package/_dist/display.d.ts +2 -0
  14. package/_dist/display.d.ts.map +1 -0
  15. package/_dist/errors.d.ts +46 -0
  16. package/_dist/errors.d.ts.map +1 -0
  17. package/_dist/fault.d.ts +4 -0
  18. package/_dist/fault.d.ts.map +1 -0
  19. package/_dist/invoke.d.ts +13 -0
  20. package/_dist/invoke.d.ts.map +1 -0
  21. package/_dist/mod.d.ts +31 -0
  22. package/_dist/mod.d.ts.map +1 -0
  23. package/_dist/outlast.d.ts +89 -0
  24. package/_dist/outlast.d.ts.map +1 -0
  25. package/_dist/persist.d.ts +5 -0
  26. package/_dist/persist.d.ts.map +1 -0
  27. package/_dist/read.d.ts +4 -0
  28. package/_dist/read.d.ts.map +1 -0
  29. package/_dist/readable.d.ts +59 -0
  30. package/_dist/readable.d.ts.map +1 -0
  31. package/_dist/registry.d.ts +53 -0
  32. package/_dist/registry.d.ts.map +1 -0
  33. package/_dist/result.d.ts +154 -0
  34. package/_dist/result.d.ts.map +1 -0
  35. package/_dist/routes.d.ts +11 -0
  36. package/_dist/routes.d.ts.map +1 -0
  37. package/_dist/runner.d.ts +161 -0
  38. package/_dist/runner.d.ts.map +1 -0
  39. package/_dist/said.d.ts +4 -0
  40. package/_dist/said.d.ts.map +1 -0
  41. package/_dist/schema.d.ts +76 -0
  42. package/_dist/schema.d.ts.map +1 -0
  43. package/_dist/state.d.ts +9 -0
  44. package/_dist/state.d.ts.map +1 -0
  45. package/_dist/title.d.ts +20 -0
  46. package/_dist/title.d.ts.map +1 -0
  47. package/_dist/value.d.ts +43 -0
  48. package/_dist/value.d.ts.map +1 -0
  49. package/_dist/views.d.ts +5 -0
  50. package/_dist/views.d.ts.map +1 -0
  51. package/_dist/vocab.d.ts +9 -0
  52. package/_dist/vocab.d.ts.map +1 -0
  53. package/_dist/watch.d.ts +28 -0
  54. package/_dist/watch.d.ts.map +1 -0
  55. package/access.js +3 -0
  56. package/access.js.map +1 -0
  57. package/access.ts +11 -0
  58. package/app-view.js +26 -0
  59. package/app-view.js.map +1 -0
  60. package/app-view.ts +41 -0
  61. package/args.js +136 -0
  62. package/args.js.map +1 -0
  63. package/args.ts +187 -0
  64. package/body.js +14 -0
  65. package/body.js.map +1 -0
  66. package/body.ts +15 -0
  67. package/check.js +67 -0
  68. package/check.js.map +1 -0
  69. package/check.ts +92 -0
  70. package/declared.js +529 -0
  71. package/declared.js.map +1 -0
  72. package/declared.ts +719 -0
  73. package/deno.json +1 -0
  74. package/display.js +21 -0
  75. package/display.js.map +1 -0
  76. package/display.ts +39 -0
  77. package/errors.js +99 -0
  78. package/errors.js.map +1 -0
  79. package/errors.ts +127 -0
  80. package/fault.js +17 -0
  81. package/fault.js.map +1 -0
  82. package/fault.ts +24 -0
  83. package/invoke.js +207 -0
  84. package/invoke.js.map +1 -0
  85. package/invoke.ts +210 -0
  86. package/mod.js +31 -0
  87. package/mod.js.map +1 -0
  88. package/mod.ts +78 -0
  89. package/outlast.js +416 -0
  90. package/outlast.js.map +1 -0
  91. package/outlast.ts +551 -0
  92. package/package.json +109 -4
  93. package/persist.js +18 -0
  94. package/persist.js.map +1 -0
  95. package/persist.ts +26 -0
  96. package/read.js +50 -0
  97. package/read.js.map +1 -0
  98. package/read.ts +58 -0
  99. package/readable.js +118 -0
  100. package/readable.js.map +1 -0
  101. package/readable.ts +134 -0
  102. package/registry.js +162 -0
  103. package/registry.js.map +1 -0
  104. package/registry.ts +207 -0
  105. package/result.js +497 -0
  106. package/result.js.map +1 -0
  107. package/result.ts +540 -0
  108. package/routes.js +46 -0
  109. package/routes.js.map +1 -0
  110. package/routes.ts +50 -0
  111. package/runner.js +748 -0
  112. package/runner.js.map +1 -0
  113. package/runner.ts +910 -0
  114. package/said.js +15 -0
  115. package/said.js.map +1 -0
  116. package/said.ts +12 -0
  117. package/schema.js +137 -0
  118. package/schema.js.map +1 -0
  119. package/schema.ts +134 -0
  120. package/state.js +69 -0
  121. package/state.js.map +1 -0
  122. package/state.ts +108 -0
  123. package/title.js +222 -0
  124. package/title.js.map +1 -0
  125. package/title.ts +257 -0
  126. package/value.js +57 -0
  127. package/value.js.map +1 -0
  128. package/value.ts +74 -0
  129. package/views.js +131 -0
  130. package/views.js.map +1 -0
  131. package/views.ts +125 -0
  132. package/vocab.js +22 -0
  133. package/vocab.js.map +1 -0
  134. package/vocab.json +268 -0
  135. package/vocab.ts +22 -0
  136. package/watch.js +64 -0
  137. package/watch.js.map +1 -0
  138. package/watch.ts +74 -0
@@ -0,0 +1,154 @@
1
+ import type { Bundle, Declared, Eid, Ready, Tool } from "@yaks/graph";
2
+ import { type Vocab } from "@yaks/vocab";
3
+ import { type Clock } from "@yaks/fp";
4
+ /** A runner's clock unless it is given one: the runtime's timers, and
5
+ * `performance.now`, which the wall clock's adjustments never move, for how
6
+ * long a call took. */ export declare let measuring: Clock;
7
+ /** The two effects this package declares, as written in the vocabulary: the
8
+ * call that is due now, and the one that is due once its wake has fired —
9
+ * each a query the runner also asks on its own, for what a crash left. */ export declare let RULES: Declared[];
10
+ /** Every call claimed and not yet answered: the identities explicit recovery
11
+ * asks for beside the rules, which owe nothing for a claimed call. A call its
12
+ * writer runs by an effect of its own (`tool_async`, @yaks/session) is that
13
+ * effect's to recover, as it is that effect's to run (`call_ready`). */ export declare let HELD: string;
14
+ /** The rule that selects a call due now — the one whose emit names the result
15
+ * entity. */ export declare let READY: string;
16
+ /** The rule that selects a deferred call once its wake has fired. */ export declare let WOKEN: string;
17
+ /** The entity id a call points at for a tool of this name: the id the
18
+ * vocabulary's `identity` on `tool.name` derives, so a graph's tool rows are
19
+ * the same rows every time a runner is built. */ export declare let toolEid: (name: string) => Eid;
20
+ export declare let toolNameAt: (eid: Eid) => string | undefined;
21
+ /** The row a registered tool advertises to stored calls and builders. */ export declare let toolRow: (tool: Tool) => Bundle;
22
+ /** The most characters of an answer's text {@link worded} says: the copy on
23
+ * the result entity, what a model reads over MCP, a transcript's line. What
24
+ * lies past it is counted, not said — the answer itself is the bundles. */ export declare let WORDS: any;
25
+ /** The most characters an answer may take as JSON before the runner refuses
26
+ * it as `too_large`: far below the longest string a JavaScript engine can
27
+ * build, so a door that sends an answer whole (MCP, `/apply`, `--json`) never
28
+ * fails to. */ export declare let MOST: any;
29
+ /**
30
+ * A tool's answer as text: each bundle as a line where it is one — a text
31
+ * answer's `content{body}`, or a compact `hit` line for a search result — and
32
+ * the rest as JSON, each run of data bundles one JSON array, so the data in an
33
+ * answer always parses and the lines between read as lines. An answer of data
34
+ * alone is one array, `JSON.stringify(answer, null, 2)`. A component's prose
35
+ * (a string that breaks lines or runs past 200 characters, such as a
36
+ * `doc.body`) is said as plain text: its JSON string holds the tag of a block
37
+ * that follows the bundle, which ends the array. An entity that carries words
38
+ * among other components (a transcript entry, a comment) is data: said whole,
39
+ * its eid and its writer with its words. It is copied onto the result entity
40
+ * as `content{body}` so a model, a terminal and a transcript all read the
41
+ * answer the same way. It says at most `most` characters, each bundle only
42
+ * once it is reached, and counts the rest, so an answer of any size words in
43
+ * bounded time and space.
44
+ *
45
+ * ```ts
46
+ * import { assertEquals } from '@std/assert'
47
+ * let said = (body: string) => ({
48
+ * entity: { eid: '$said' },
49
+ * content: { body },
50
+ * output: { source: 'c1' },
51
+ * })
52
+ * assertEquals(worded([said('one'), said('two')]), 'one\ntwo')
53
+ * let value = { entity: { eid: '$said' }, output: { value: { n: 1 } } }
54
+ * assertEquals(worded([value]), '{"n":1}')
55
+ * let entry = { ...said('hi'), entry: { session: 's', seq: 2 } }
56
+ * assertEquals(
57
+ * worded([said('one'), entry, said('two')]),
58
+ * 'one\n' + JSON.stringify([entry], null, 2) + '\ntwo',
59
+ * )
60
+ * let task = { entity: { eid: 't1' }, doc: { body: 'Two\n"lines"' } }
61
+ * assertEquals(
62
+ * worded([task]),
63
+ * JSON.stringify([{ ...task, doc: { body: '<doc.body t1>' } }], null, 2) +
64
+ * '\n<doc.body t1>\nTwo\n"lines"\n</doc.body>',
65
+ * )
66
+ * assertEquals(
67
+ * worded([said('one'), said('two'), said('three')], 5),
68
+ * 'one\nt\n… 2 of 3 not said: an answer is worded in 5 characters',
69
+ * )
70
+ * ```
71
+ */ export declare let worded: (answer: Bundle[]) => string;
72
+ /**
73
+ * A tool's answer as the texts a door that sends several sends (MCP's content
74
+ * blocks): its data first, as JSON, then the prose held out of it, then the
75
+ * lines said beside it, so a reader that parses the first text finds the data
76
+ * and nothing glued onto it. An answer of one kind without prose is one text,
77
+ * {@link worded}.
78
+ *
79
+ * ```ts
80
+ * import { assertEquals } from '@std/assert'
81
+ * let row = { entity: { eid: 't1' }, doc: { title: 'Mossvale' } }
82
+ * let note = { entity: { eid: '$said' }, content: { body: 'Checked.' } }
83
+ * assertEquals(texts([row, note]), [JSON.stringify([row], null, 2), 'Checked.'])
84
+ * assertEquals(texts([row]), [worded([row])])
85
+ * let task = { entity: { eid: 't2' }, doc: { body: 'One\ntwo' } }
86
+ * assertEquals(texts([task]), [
87
+ * JSON.stringify([{ ...task, doc: { body: '<doc.body t2>' } }], null, 2),
88
+ * '<doc.body t2>\nOne\ntwo\n</doc.body>',
89
+ * ])
90
+ * ```
91
+ */ export declare let texts: (answer: Bundle[]) => string[];
92
+ /**
93
+ * A tool's answer as data, for a reader that parses rather than reads: the
94
+ * bundles under `result`, or, from a tool that declares an `outputSchema`
95
+ * because its answer is not entities, the {@link valueIn} it answered in that
96
+ * shape. A refusal carries no such value, and is its bundles like any other.
97
+ * MCP sends this as `structuredContent`; `yak … --json` prints it.
98
+ */ export declare let structured: (tool: {
99
+ outputSchema?: Record<string, unknown>;
100
+ }, answer: Bundle[]) => Record<string, unknown>;
101
+ /**
102
+ * What a tool's {@link texts} say that its {@link structured} answer does not
103
+ * hold, worded, for a door that sends both to a reader that reads only the
104
+ * data. An answer of entities holds every bundle under `result`, so nothing;
105
+ * a value holds only itself, so the words beside it and every other bundle
106
+ * are said here. Images are sent as images, not words.
107
+ *
108
+ * ```ts
109
+ * import { assertEquals } from '@std/assert'
110
+ * let schema = { outputSchema: { type: 'object' } }
111
+ * let said = {
112
+ * entity: { eid: '$said' },
113
+ * content: { body: 'Two components.' },
114
+ * output: { source: 'c1', value: { n: 2 } },
115
+ * }
116
+ * assertEquals(aside(schema, [said]), 'Two components.')
117
+ * assertEquals(aside(schema, [{ ...said, content: undefined }]), undefined)
118
+ * assertEquals(aside({}, [said]), undefined)
119
+ * ```
120
+ */ export declare let aside: (tool: {
121
+ outputSchema?: Record<string, unknown>;
122
+ }, answer: Bundle[]) => string | undefined;
123
+ /**
124
+ * Did this call fail? Read from the runner's own record — `execution{state}`
125
+ * on the call — rather than guessed from the shape of the answer: a tool that
126
+ * queries for broken rows (or failed calls) returns entities carrying `error`,
127
+ * `exception` and `execution`, and reporting faults is not itself a fault.
128
+ */ export declare let faulted: (landed: Bundle[], call: Eid) => boolean;
129
+ /**
130
+ * Is the call still running in what came back? A stopping server answers a
131
+ * call whose tool has not returned with the call as it stands, claimed and
132
+ * unanswered, and where its answer will be kept (@yaks/tools
133
+ * `Invocation.call`). Read from the runner's own record, as {@link faulted}.
134
+ */ export declare let pending: (landed: Bundle[], call: Eid) => boolean;
135
+ /**
136
+ * The fault a failed call left, aimed at it: its `refusal{code}`, its
137
+ * `exception` or its interruption's `notice`, beside the words it said. None
138
+ * for a call that answered, however its answer is shaped ({@link faulted}).
139
+ */ export declare let faultOf: (landed: Bundle[], call: Eid) => Bundle | undefined;
140
+ /**
141
+ * What a call answered, for display: the tool's own bundles, without the
142
+ * runner's record of this call — the call itself and its result, which
143
+ * carries a copy of the answer's text so a transcript can show one line per
144
+ * result; a caller rendering the answer itself would otherwise show it twice.
145
+ */ export declare let answerOf: (landed: Bundle[], call: Eid) => Bundle[];
146
+ /** Plan invocation receipts from the declared rules, including their stable IDs. */ export declare let results: (vocab: Vocab, now: () => number) => {
147
+ rules: Ready[];
148
+ /** {@link HELD}, as this graph can query it, or nothing where a graph
149
+ * records no claims */ held?: Ready['plan']['patterns'][number]['filter'];
150
+ ending: (call: Bundle, started: number | undefined, state: string, said: Bundle[], before?: string | null) => Bundle[];
151
+ };
152
+ export { said } from "./said.js";
153
+ export { display } from "./display.js";
154
+ //# sourceMappingURL=result.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"result.d.ts","sources":["../result.ts"],"names":[],"mappings":"AACA,cAAc,MAAM,EAAQ,QAAQ,EAAE,GAAG,EAAE,KAAK,EAAE,IAAI,2BAAgC;AAMtF,SAAoB,KAAK,KAAK,2BAAgC;AAI9D,SAAS,KAAK,KAAK,wBAAqC;AAExD;;qBAEqB,GACrB,OAAO,YAAI,WAAW,MAAmD;AAEzE;;wEAEwE,GACxE,OAAO,YAAI,OAAO,WACkD;AAEpE;;;sEAGsE,GACtE,OAAO,YAAI,aAAuD;AAElE;WACW,GACX,OAAO,YAAI,cAAoB;AAE/B,mEAAmE,GACnE,OAAO,YAAI,cAAoB;AAO/B;;+CAE+C,GAC/C,OAAO,YAAI,UAAW,MAAM,MAAM,KAAG,IAOpC;AAGD,OAAO,YAAI,aAAc,KAAK,QAAM,MAAM,GAAG,SAAS,CAAkB;AAExE,uEAAuE,GACvE,OAAO,YAAI,UAAW,MAAM,SAAO,OAUlC;AAED;;yEAEyE,GACzE,OAAO,YAAI,WAAkB;AAE7B;;;aAGa,GACb,OAAO,YAAI,UAAuB;AAkJlC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0CC,GACD,OAAO,YAAI,SAAU,QAAQ,aAAyB,MAAM,CAuB3D;AAWD;;;;;;;;;;;;;;;;;;;CAmBC,GACD,OAAO,YAAI,QAAS,QAAQ,aAAyB,MAAM,GAK1D;AAiBD;;;;;;CAMC,GACD,OAAO,YAAI,aACT;EAAQ,eAAe,OAAO,MAAM,EAAE,OAAO;GAC7C,QAAQ,aACP,OAAO,MAAM,EAAE,OAAO,EAEuB;AAUhD;;;;;;;;;;;;;;;;;;;CAmBC,GACD,OAAO,YAAI,QACT;EAAQ,eAAe,OAAO,MAAM,EAAE,OAAO;GAC7C,QAAQ,aAEP,MAAM,GAAG,SAAS,CAapB;AAQD;;;;;CAKC,GACD,OAAO,YAAI,UAAW,QAAQ,UAAU,MAAM,QAAM,OAAO,CAK1D;AAED;;;;;CAKC,GACD,OAAO,YAAI,UAAW,QAAQ,UAAU,MAAM,QAAM,OAAO,CAG1D;AAED;;;;CAIC,GACD,OAAO,YAAI,UAAW,QAAQ,UAAU,MAAM,QAAM,SAAS,SAAS,CAMvD;AAEf;;;;;CAKC,GACD,OAAO,YAAI,WAAY,QAAQ,UAAU,MAAM,QAAM,SACd;AAEvC,kFAAkF,GAClF,OAAO,YAAI,UACT,OAAO,OACP,WAAW,MAAM;EAEjB,OAAO;EACP;uBACqB,GACrB,OAAO,MAAM,QAAQ,YAAY,MAAM,EAAE;EACzC,SACE,MAAM,QACN,SAAS,MAAM,GAAG,SAAS,EAC3B,OAAO,MAAM,EACb,MAAM,UACN,SAAS,MAAM,GAAG,IAAI,KACnB;EAgEN;AAED,SAAS,IAAI,oBAAmB;AAChC,SAAS,OAAO,uBAAsB"}
@@ -0,0 +1,11 @@
1
+ type Handler = (request: Request) => Response | Promise<Response>;
2
+ type Route = {
3
+ method: string;
4
+ path: string;
5
+ handle: Handler;
6
+ };
7
+ type Run = (name: string, args: Record<string, unknown>, at?: string) => Promise<Record<string, unknown>>;
8
+ /** One HTTP route for a host that offers declared command invocation. */ export declare let routes: (host: {
9
+ command?: Run;
10
+ }) => Route[];
11
+ //# sourceMappingURL=routes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routes.d.ts","sources":["../routes.ts"],"names":[],"mappings":"KAKK,WAAW,SAAS,YAAY,WAAW,QAAQ;KACnD;EAAU,QAAQ,MAAM;EAAE,MAAM,MAAM;EAAE,QAAQ;;KAMhD,OACH,MAAM,MAAM,EACZ,MAAM,OAAO,MAAM,EAAE,OAAO,GAC5B,KAAK,MAAM,KACR,QAAQ,OAAO,MAAM,EAAE,OAAO;AA6BnC,uEAAuE,GACvE,OAAO,YAAI,SAAU;EAAQ,UAAU;MAAQ,QAGvC"}
@@ -0,0 +1,161 @@
1
+ import { type Bundle, type Comp, type Eid, type Graph, type NamedTool, type Ready, type Tool } from "@yaks/graph";
2
+ export { UnfinishedCall } from "./errors.js";
3
+ import type { Clock } from "@yaks/fp";
4
+ import type { Vocab } from "@yaks/vocab";
5
+ import { type Registry } from "./registry.js";
6
+ /** A refusal as its answer says it: the code that classes it and its words. */ export type Refusal = {
7
+ code: string;
8
+ said: string;
9
+ summary?: string;
10
+ };
11
+ type Defer = (delay: number, reason: string) => Promise<void>;
12
+ /** What hears a refusal: the refusal, the call it answered and the tool. */ export type Refused = (refusal: Refusal, call: Bundle, tool?: string) => unknown;
13
+ /** What a runner is built with. */ export type Opts = {
14
+ /** what it can run: a function makes them only once a call asks for a
15
+ * tool, so a process that runs none builds none */ tools: Tool[] | Registry | (() => Tool[] | Registry);
16
+ /** the graph the tools read and write, when that is not the graph the calls
17
+ * are recorded in (a server that keeps its call records separately) */ host?: Graph;
18
+ /** where caught failures are reported with the original thrown value, the
19
+ * call and the tool it asked for, independently of recording its answer.
20
+ * A refusal (a `CallError`, or an error @yaks/graph's
21
+ * `status` puts below 500) is never reported. A report that answers a
22
+ * promise is awaited before the call's answer is. */ report?: (err: unknown, call: Bundle, tool?: string) => unknown;
23
+ /** what hears each refusal a call is answered with, apart from
24
+ * {@link report}: arguments its schema refuses, a tool named that this
25
+ * runner lacks (answered by {@link otherwise}), the tool's own `CallError`,
26
+ * a write the graph refuses. It is told the code and words of the refusal,
27
+ * the call and the tool it asked for: the name the call keeps
28
+ * (`call.name`), or else the tool that answered. Awaited like a report; what it
29
+ * throws is reported, and never changes the call's answer. */ refused?: Refused;
30
+ /** what answers a call naming a tool this runner does not have. Omitted,
31
+ * nothing does: the call is left for whichever runner has that tool. */ otherwise?: Tool;
32
+ /** which calls are this runner's to run. One it does not take is left
33
+ * alone, the way a call naming a tool it lacks is: a transcript's calls,
34
+ * say, which the transcript's own runner runs in the order the model asked
35
+ * (@yaks/session). Omitted, it takes every call it has a tool for. */ takes?: (call: Bundle) => boolean;
36
+ /** the clock a runner keeps: `result.ms` is measured by its `now`, and a
37
+ * write storage refused is tried again after its `after` (default
38
+ * {@link measuring}) */ clock?: Clock;
39
+ /** the most characters an answer may take as JSON; past it the call is
40
+ * refused as `too_large` (default {@link MOST}) */ most?: number;
41
+ /** which entity this runner runs as: its claims record it in
42
+ * `execution.by`, and a call held by anyone else is left alone — a
43
+ * transcript imported from elsewhere arrives already executed, held by the
44
+ * process that made the calls, and no boot pass here re-runs it. A holder
45
+ * that has written an `exit` row holds nothing: its calls are free. A claim
46
+ * naming this owner that this runner is not running is left alone too: it
47
+ * is running in another runner under the same name. Omitted, this runner
48
+ * claims anonymously and takes any call nobody else holds. */ owner?: Eid;
49
+ /** whether a holder other than {@link owner} is known to have ended without
50
+ * writing its `exit` (a Durable Object reset under a call): its calls are
51
+ * free, as an exited holder's are. The host says; this package never
52
+ * looks. */ gone?: (holder: Eid) => boolean | Promise<boolean>;
53
+ /** the program running these calls on this machine, as @yaks/process
54
+ * records one — `{pid, command, cwd}` — put on every call a tool is handed,
55
+ * for a tool that acts on the machine rather than the graph. The caller
56
+ * supplies it; this package touches no runtime API and never looks it up. */ process?: Comp;
57
+ /** Extra bundles a direct caller is owed beside a tool's answer. A plugin
58
+ * may supply them without the tool or its transport knowing about them. */ reply?: Reply;
59
+ /** record what a lone answer marks on the call's result, as a transcript
60
+ * keeps it, one entry per answer (@yaks/session): a refusal is
61
+ * `refusal{code}` beside `result{call}` and its words rather than an entity
62
+ * of its own, and a `$said` answer's components beside its words and source
63
+ * (an image it shows) are the result's ({@link ridden}). A defect keeps its
64
+ * own `exception` entity either way. */ onResult?: boolean;
65
+ };
66
+ /** What a direct caller is owed beside a tool's answer: the call, what the
67
+ * tool answered, and what the call's own write applied, in; the bundles to add
68
+ * after that answer, out. `wrote` is the answer where the tool wrote and the
69
+ * write was kept, so an entity it created wears the `created` its write was
70
+ * stamped with, and it is empty for a read, a rehearsal or a refusal, whose
71
+ * answer is entities that were there already or were never written. */ export type Reply = (call: Bundle, answer: Bundle[], wrote: Bundle[]) => Promise<Bundle[]>;
72
+ /** The kind a written bundle made its entity, if it made one: a created
73
+ * entity's kind, or a kind that is a mark (@yaks/vocab `CompInfo.mark`) whose
74
+ * `at` this write stamped, so marked for the first time. What a {@link Reply}
75
+ * reads of `wrote` to find the entities its call made. */ export declare let became: (vocab: Vocab, b: Bundle) => string | undefined;
76
+ /** One admitted call, retaining its tool through execution while registration
77
+ * advertises the provider's current declaration at the stable tool identity. */ export type Invocation = {
78
+ tool: NamedTool;
79
+ ensure: () => Promise<Bundle[]>;
80
+ /** Run it recorded. Once `cut` aborts, a stopping server's request lets go
81
+ * of the call. One whose answer is kept is answered without its
82
+ * {@link Reply}: the write stands, and only the extras read beside it are
83
+ * dropped, as a stopping server drops its reads. One whose tool has not
84
+ * returned is answered with the call, claimed and unanswered
85
+ * ({@link pending}), and where its answer will be kept; the tool runs on,
86
+ * and a host that closes first ends it as interrupted. */ call: (o?: {
87
+ cut?: AbortSignal;
88
+ }) => Promise<Bundle[]>;
89
+ read: () => Promise<Bundle[]>;
90
+ };
91
+ /** A live runner: the rules a sweep queries, and the functions a caller
92
+ * invokes. */ export type Runner = {
93
+ /** the queries a deferred call is found by — the two declared effects, by
94
+ * name */ rules: Ready[];
95
+ /** The shared discovery and lookup catalog. */ registry: Registry;
96
+ admit: (asked: Bundle) => Invocation | undefined;
97
+ /** the tools it runs, named */ tools: NamedTool[];
98
+ /** write the `tool` rows that calls point at: the named tools', or every
99
+ * tool's. Each row is written at most once per runner however many times it
100
+ * is asked for, so a request handler may call it on the way into every
101
+ * call, naming the one tool that call points at. Answers what the rows it
102
+ * asked about were written as. */ ensure: (names?: string[]) => Promise<Bundle[]>;
103
+ /** invoke a tool: the call in, the answer's bundles out. The call is
104
+ * written claimed and runs here; an `$alias` eid is given a fresh one. */ call: (asked: Bundle) => Promise<Bundle[]>;
105
+ /** Run a read-only tool without recording a call, claim, result or reply. */ read: (asked: Bundle) => Promise<Bundle[]>;
106
+ /** run one call that is already in the graph: its answer if it has one, the
107
+ * same promise if it is in flight here, nothing if a live process holds it,
108
+ * and {@link UnfinishedCall} if it was claimed anonymously and never
109
+ * answered */ run: (call: Eid, opts?: {
110
+ redrive?: boolean;
111
+ defer?: Defer;
112
+ }) => Promise<Bundle[]>;
113
+ /** run one call a rule selected, if it is this runner's to take: what an
114
+ * effect handler calls. A held call, including one in flight here, or one
115
+ * removed since selection returns an empty answer. */ due: (call: Eid, opts?: {
116
+ redrive?: boolean;
117
+ defer?: Defer;
118
+ }) => Promise<Bundle[]>;
119
+ /** Explicit recovery over eligible call identities, including unanswered
120
+ * claims. Durable effect hosts recover recorded runs instead of sweeping. */ drive: (opts?: {
121
+ redrive?: boolean;
122
+ }) => Promise<Bundle[]>;
123
+ /** end every call this runner claimed and is still running, as
124
+ * `interrupted{code}` saying `why`: what a process that is ending
125
+ * before its tools returned writes, so no claim of its own is left to lapse
126
+ * and run again somewhere it was never asked. Given a `holder`, the calls
127
+ * that holder claimed and never answered instead, read from the graph: what
128
+ * is written for a process that ended without writing it itself. */ interrupt: (why: string, holder?: Eid) => Promise<Bundle[]>;
129
+ /** Give an unstarted or abandoned, anonymously claimed call a result
130
+ * without invoking its tool. A claimed call's effects may have landed. */ interruptCall: (call: Eid, why: string, answer?: Bundle[]) => Promise<Bundle[]>;
131
+ };
132
+ /** Whether the runner writes what `tool` answered, ending in `state`, or
133
+ * hands the answer back as the tool built it. A read-only tool's answer is
134
+ * entities that already exist, and writing them would patch every row the
135
+ * query found and move its `updated` stamp; an applied tool's host has written
136
+ * its own. So the runner writes only its bookkeeping for either. A failure is
137
+ * written whatever the tool was: an error is worth recording. */ export declare let keeps: (tool: Pick<Tool, 'readOnly' | 'applied'>, state: string) => boolean;
138
+ /**
139
+ * Build a runner over a graph.
140
+ *
141
+ * ```ts ignore
142
+ * let r = runner(g, { tools })
143
+ * await r.ensure()
144
+ * // the call entity is the record; the answer is the tool's own bundles
145
+ * let id = mint()
146
+ * let landed = await r.call({
147
+ * entity: { eid: id },
148
+ * call: { to: toolEid('text_echo'), args: {} },
149
+ * })
150
+ * answerOf(landed, id)
151
+ * ```
152
+ *
153
+ * Nothing polls the graph for calls. A server that wants the deferred ones too
154
+ * handles the two effects ./vocab.json declares — `fx.handle({ [r.rule.name]:
155
+ * (e) => run.due(e.entity.eid) })` for each of `run.rules`. A durable effect
156
+ * pool recovers recorded runs after a crash; it needs no startup reconcile.
157
+ * `reconcile()` is explicit recovery for calls without a recorded effect.
158
+ */ export declare let runner: (g: Graph, opts: Opts) => Runner;
159
+ /** Explicitly recover eligible calls and unanswered claims. A durable effect
160
+ * host recovers its recorded runs instead; it needs no startup scan. */ export declare let reconcile: (r: Runner) => Promise<Bundle[]>;
161
+ //# sourceMappingURL=runner.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runner.d.ts","sources":["../runner.ts"],"names":[],"mappings":"AA0DA,SACE,KAAK,MAAM,EACX,KAAK,IAAI,EAET,KAAK,GAAG,EACR,KAAK,KAAK,EAEV,KAAK,SAAS,EAEd,KAAK,KAAK,EAGV,KAAK,IAAI,2BAEoB;AAI/B,SAAS,cAAc,sBAAqB;AAW5C,cAAc,KAAK,wBAA6B;AAChD,cAAc,KAAK,2BAAgC;AACnD,SAAS,KAAK,QAAQ,wBAAmC;AAQzD,6EAA6E,GAC7E,YAAY;EAAY,MAAM,MAAM;EAAE,MAAM,MAAM;EAAE,UAAU,MAAM;;KAE/D,SAAS,OAAO,MAAM,EAAE,QAAQ,MAAM,KAAK,QAAQ,IAAI;AAE5D,0EAA0E,GAC1E,YAAY,WACV,SAAS,SACT,MAAM,QACN,OAAO,MAAM,KACV,OAAO;AAEZ,iCAAiC,GACjC,YAAY;EACV;mDACiD,GACjD,OAAO,SAAS,kBAAkB,SAAS;EAC3C;uEACqE,GACrE,OAAO;EACP;;;;qDAImD,GACnD,UAAU,KAAK,OAAO,EAAE,MAAM,QAAQ,OAAO,MAAM,KAAK,OAAO;EAC/D;;;;;;8DAM4D,GAC5D,UAAU;EACV;wEACsE,GACtE,YAAY;EACZ;;;sEAGoE,GACpE,SAAS,MAAM,WAAW,OAAO;EACjC;;wBAEsB,GACtB,QAAQ;EACR;mDACiD,GACjD,OAAO,MAAM;EACb;;;;;;;8DAO4D,GAC5D,QAAQ;EACR;;;YAGU,GACV,QAAQ,QAAQ,QAAQ,OAAO,GAAG,QAAQ,OAAO;EACjD;;;6EAG2E,GAC3E,UAAU;EACV;2EACyE,GACzE,QAAQ;EACR;;;;;wCAKsC,GACtC,WAAW,OAAO;;AAGpB;;;;;qEAKqE,GACrE,YAAY,SACV,MAAM,QACN,QAAQ,UACR,OAAO,aACJ,QAAQ;AAEb;;;wDAGwD,GACxD,OAAO,YAAI,SAAU,OAAO,OAAO,GAAG,WAAS,MAAM,GAAG,SAAS,CAOhE;AAqCD;8EAC8E,GAC9E,YAAY;EACV,MAAM;EACN,cAAc,QAAQ;EACtB;;;;;;0DAMwD,GACxD,OAAO;IAAM,MAAM;QAAkB,QAAQ;EAC7C,YAAY,QAAQ;;AAGtB;YACY,GACZ,YAAY;EACV;UACQ,GACR,OAAO;EACP,6CAA6C,GAC7C,UAAU;EACV,QAAQ,OAAO,WAAW,aAAa,SAAS;EAChD,6BAA6B,GAC7B,OAAO;EACP;;;;kCAIgC,GAChC,SAAS,QAAQ,MAAM,OAAO,QAAQ;EACtC;0EACwE,GACxE,OAAO,OAAO,WAAW,QAAQ;EACjC,2EAA2E,GAC3E,OAAO,OAAO,WAAW,QAAQ;EACjC;;;cAGY,GACZ,MACE,MAAM,KACN;IAAS,UAAU,OAAO;IAAE,QAAQ;QACjC,QAAQ;EACb;;sDAEoD,GACpD,MACE,MAAM,KACN;IAAS,UAAU,OAAO;IAAE,QAAQ;QACjC,QAAQ;EACb;6EAC2E,GAC3E,QAAQ;IAAS,UAAU,OAAO;QAAO,QAAQ;EACjD;;;;;oEAKkE,GAClE,YAAY,KAAK,MAAM,EAAE,SAAS,QAAQ,QAAQ;EAClD;0EACwE,GACxE,gBACE,MAAM,KACN,KAAK,MAAM,EACX,SAAS,aACN,QAAQ;;AAoEf;;;;;+DAK+D,GAC/D,OAAO,YAAI,QACT,MAAM,KAAK,MAAM,aAAa,YAC9B,OAAO,MAAM,KACZ,OAAO,CAEc;AAExB;;;;;;;;;;;;;;;;;;;;CAoBC,GACD,OAAO,YAAI,SAAU,GAAG,OAAO,MAAM,SAAO,OA+d3C;AAED;sEACsE,GACtE,OAAO,YAAI,YAAa,GAAG,WAAS,QAAQ,UAChB"}
@@ -0,0 +1,4 @@
1
+ import type { Bundle } from "@yaks/graph";
2
+ /** What a tool says as its answer: `body`, lines joined by newlines, in a
3
+ * bundle whose `output.source` is the call. */ export declare let said: (call: Bundle, body: string | string[]) => Bundle;
4
+ //# sourceMappingURL=said.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"said.d.ts","sources":["../said.ts"],"names":[],"mappings":"AAGA,cAAc,MAAM,2BAAgC;AAEpD;6CAC6C,GAC7C,OAAO,YAAI,OAAQ,MAAM,QAAQ,MAAM,MAAM,GAAG,MAAM,OAAK,OAIzD"}
@@ -0,0 +1,76 @@
1
+ import type { Tool } from "@yaks/graph";
2
+ /**
3
+ * A tool's arguments as JSON Schema: its own `inputSchema`, published (the
4
+ * command-line `short` letters a CLI reads stay off the wire), or none for a
5
+ * tool that takes no arguments. This is exactly what `tools/list` sends, so
6
+ * anything else that needs a tool's argument grammar — a CLI mapping a
7
+ * command onto it, say — reads what an MCP client reads.
8
+ *
9
+ * ```ts
10
+ * import { assertEquals } from '@std/assert'
11
+ * import { inputSchemaOf } from '@yaks/tools/schema'
12
+ *
13
+ * let tool = {
14
+ * name: 'write',
15
+ * description: 'Write a doc',
16
+ * inputSchema: {
17
+ * type: 'object',
18
+ * properties: { title: { type: 'string', short: 't' } },
19
+ * },
20
+ * run: () => [],
21
+ * }
22
+ * assertEquals(inputSchemaOf(tool).properties, { title: { type: 'string' } })
23
+ * ```
24
+ */ export declare let inputSchemaOf: (tool: Tool) => {
25
+ type: 'object';
26
+ [key: string]: unknown;
27
+ };
28
+ type Json = {
29
+ [key: string]: unknown;
30
+ };
31
+ /**
32
+ * The bundle answer for a door whose rows say words of their own beside their
33
+ * components: {@link answerSchema}, with each of those words declared on the
34
+ * row under its own schema. A client checks every answer against the schema
35
+ * its tool is listed with, so a row word left undeclared reads to it as a
36
+ * component that is not an object, and the whole answer is refused. yaks.app's
37
+ * rows name what each entity is (`kind`), for one.
38
+ */ export declare let answerWith: (words: Record<string, Json>) => {
39
+ type: 'object';
40
+ [key: string]: unknown;
41
+ };
42
+ /**
43
+ * The default output schema: returned bundles under `result`, shared by tool
44
+ * discovery and transports that send structured answers.
45
+ *
46
+ * Every tool whose answer is entities answers this one shape, so it is written
47
+ * once and listed on all of them, a plugin's tool included without declaring
48
+ * anything; a tool whose answer is not entities declares its own
49
+ * `outputSchema` (`graph_schema`, a vocabulary document). It says what a
50
+ * bundle is and not what any component holds: a fully typed bundle is tens of
51
+ * kilobytes of vocabulary, and `tools/list` would carry a copy per tool before
52
+ * the agent has asked its first question. What a component holds is
53
+ * `graph_schema`'s answer, asked for when it is wanted. It carries no prose
54
+ * for the same reason: it rides on every tool, and `graph_apply`'s
55
+ * description says what a bundle is once. A door whose rows carry words of
56
+ * their own lists {@link answerWith} instead.
57
+ */ export declare let answerSchema: {
58
+ type: 'object';
59
+ [key: string]: unknown;
60
+ };
61
+ /**
62
+ * A tool's output schema as a door lists it when its structured answer also
63
+ * carries `said`: the words its text says beside the data (@yaks/tools/result
64
+ * `aside`) and any news the door adds, for a client that gives a model the
65
+ * structured answer alone. A schema whose answer is not an object has nowhere
66
+ * to say it, and is listed as declared. The same schema is answered with the
67
+ * same object, so a check compiled from it is compiled once.
68
+ *
69
+ * ```ts
70
+ * import { assertEquals } from '@std/assert'
71
+ * let listed = saying(answerSchema)
72
+ * assertEquals((listed.properties as Record<string, unknown>).said, { type: 'string' })
73
+ * assertEquals(saying(answerSchema), listed)
74
+ * ```
75
+ */ export declare let saying: (schema: Json) => Json;
76
+ //# sourceMappingURL=schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema.d.ts","sources":["../schema.ts"],"names":[],"mappings":"AACA,cAAc,IAAI,2BAAgC;AAMlD;;;;;;;;;;;;;;;;;;;;;;CAsBC,GACD,OAAO,YAAI,gBACT,MAAM;EACH,MAAM;GAAW,KAAK,MAAM,GAAG,OAAO;EAIxC;KAEE;GAAU,KAAK,MAAM,GAAG,OAAO;;AAEpC;;;;;;;CAOC,GACD,OAAO,YAAI,aACT,OAAO,OAAO,MAAM,EAAE;EACnB,MAAM;GAAW,KAAK,MAAM,GAAG,OAAO;EA4BzC;AAEF;;;;;;;;;;;;;;;CAeC,GACD,OAAO,YAAI;EAAgB,MAAM;GAAW,KAAK,MAAM,GAAG,OAAO;EACjD;AAIhB;;;;;;;;;;;;;;CAcC,GACD,OAAO,YAAI,SACT,QAAQ,SACP,KAeF"}
@@ -0,0 +1,9 @@
1
+ import type { Bundle } from "@yaks/graph";
2
+ import type { Computed } from "@yaks/match";
3
+ import type { Vocab } from "@yaks/vocab";
4
+ import { type Derived } from "@yaks/sql/core";
5
+ export declare let executionState: (call: Bundle, answers?: readonly Bundle[]) => 'interrupted' | 'failed' | 'done' | 'running' | null;
6
+ export declare let executionDerived: (vocab: Vocab) => Derived;
7
+ export declare let executionComputed: Computed;
8
+ export { Interrupted } from "./errors.js";
9
+ //# sourceMappingURL=state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state.d.ts","sources":["../state.ts"],"names":[],"mappings":"AAGA,cAAc,MAAM,2BAAsC;AAC1D,cAAc,QAAQ,2BAAgC;AACtD,cAAc,KAAK,2BAAgC;AACnD,SAGE,KAAK,OAAO,8BAUoB;AAKlC,OAAO,YAAI,iBACT,MAAM,QACN,mBAAkB,aACjB,gBAAgB,WAAW,SAAS,YAAY,IAAI,CActD;AAED,OAAO,YAAI,mBAAoB,OAAO,UAAQ,QA0D7C;AAED,OAAO,YAAI,mBAAmB,SAE7B;AAED,SAAS,WAAW,sBAAqB"}
@@ -0,0 +1,20 @@
1
+ /** How a call reads: while it runs, and once it answered. */ export type Step = {
2
+ doing: string;
3
+ done: string;
4
+ };
5
+ /** A tool's step, and under `by` the step of each thing its arguments choose. */ export type Steps = Step & {
6
+ by?: Record<string, Record<string, Step>>;
7
+ };
8
+ /** A tool's English name: its title, or its name in words. */ export declare let titleOf: (t: {
9
+ name?: string | null;
10
+ title?: string | null;
11
+ }) => string;
12
+ /** How one call reads to the person: the step its arguments chose, its
13
+ * tool's step, or its title in the tense of the call. */ export declare let stepOf: (t: {
14
+ name?: string | null;
15
+ title?: string | null;
16
+ step?: Steps | null;
17
+ }, args?: Record<string, unknown> | null, known?: Record<string, string>) => Step;
18
+ /** The call while it runs: "Listing app versions…". */ export declare let doing: (title: string) => string;
19
+ /** The call once it answered: "Listed app versions". */ export declare let did: (title: string) => string;
20
+ //# sourceMappingURL=title.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"title.d.ts","sources":["../title.ts"],"names":[],"mappings":"AAcA,2DAA2D,GAC3D,YAAY;EAAS,OAAO,MAAM;EAAE,MAAM,MAAM;;AAEhD,+EAA+E,GAC/E,YAAY,QAAQ;EAAS,KAAK,OAAO,MAAM,EAAE,OAAO,MAAM,EAAE;;AAEhE,4DAA4D,GAC5D,OAAO,YAAI,UACT;EAAK,OAAO,MAAM,GAAG,IAAI;EAAE,QAAQ,MAAM,GAAG,IAAI;MAC/C,MAAM,CAKN;AAiBH;uDACuD,GACvD,OAAO,YAAI,SACT;EAAK,OAAO,MAAM,GAAG,IAAI;EAAE,QAAQ,MAAM,GAAG,IAAI;EAAE,OAAO,QAAQ,IAAI;GACrE,OAAO,OAAO,MAAM,EAAE,OAAO,IAAI,IAAI,EACrC,QAAO,OAAO,MAAM,EAAE,MAAM,MAC3B,KAcF;AA0LD,qDAAqD,GACrD,OAAO,YAAI,QAAS,OAAO,MAAM,KAAG,MAAM,CACL;AAErC,sDAAsD,GACtD,OAAO,YAAI,MAAO,OAAO,MAAM,KAAG,MAAM,CAA8B"}
@@ -0,0 +1,43 @@
1
+ import type { Bundle } from "@yaks/graph";
2
+ /** An image answered beside a tool's text and structured value. */ export type Image = {
3
+ data: string;
4
+ mime_type: string;
5
+ };
6
+ /** Images a tool answered, for a door that displays them inline. */ export declare let imagesIn: (answer: Bundle[]) => Image[];
7
+ /**
8
+ * A tool's answer that is a value: one bundle aimed at the call, carrying the
9
+ * value once, in `output{value}`. A door that sends text says it as
10
+ * {@link json}; one that sends data sends it as it is.
11
+ *
12
+ * ```ts
13
+ * import { assertEquals } from '@std/assert'
14
+ * assertEquals(valued({ entity: { eid: 'c1' } }, { n: 1 }), {
15
+ * entity: { eid: '$said' },
16
+ * output: { source: 'c1', value: { n: 1 } },
17
+ * })
18
+ * ```
19
+ */ export declare let valued: (call: Bundle, value: unknown) => Bundle;
20
+ /**
21
+ * A value as the text a door that sends text says: one line where it fits in
22
+ * 80 characters, indented JSON where it does not.
23
+ *
24
+ * ```ts
25
+ * import { assertEquals } from '@std/assert'
26
+ * assertEquals(json({ count: 2 }), '{"count":2}')
27
+ * assertEquals(json({ s: 'x'.repeat(80) }).split('\n').length, 3)
28
+ * ```
29
+ */ export declare let json: (value: unknown) => string;
30
+ /**
31
+ * The `output{value}` an answer carries: the same answer as data, beside the
32
+ * words a person reads. A caller that wants the answer's facts reads them here,
33
+ * never out of the words, which may carry more than the answer.
34
+ *
35
+ * ```ts
36
+ * import { assertEquals } from '@std/assert'
37
+ * let said = { entity: { eid: '$said' }, content: { body: 'a.txt' } }
38
+ * let files = { files: [{ path: 'a.txt' }] }
39
+ * assertEquals(valueIn([{ ...said, output: { value: files } }]), files)
40
+ * assertEquals(valueIn([said]), undefined)
41
+ * ```
42
+ */ export declare let valueIn: (answer: Bundle[]) => Record<string, unknown> | undefined;
43
+ //# sourceMappingURL=value.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"value.d.ts","sources":["../value.ts"],"names":[],"mappings":"AAKA,cAAc,MAAM,2BAAsC;AAE1D,iEAAiE,GACjE,YAAY;EAAU,MAAM,MAAM;EAAE,WAAW,MAAM;;AAErD,kEAAkE,GAClE,OAAO,YAAI,WAAY,QAAQ,aAAW,QAStC;AAEJ;;;;;;;;;;;;CAYC,GACD,OAAO,YAAI,SAAU,MAAM,QAAQ,OAAO,OAAO,KAAG,OAGlD;AAEF;;;;;;;;;CASC,GACD,OAAO,YAAI,OAAQ,OAAO,OAAO,KAAG,MAAM,CAGzC;AAED;;;;;;;;;;;;CAYC,GACD,OAAO,YAAI,UACT,QAAQ,aACP,OAAO,MAAM,EAAE,OAAO,IAAI,SAAS,CAGqC"}
@@ -0,0 +1,5 @@
1
+ import { type Registry } from "@yaks/render";
2
+ /** `Title`, `Body`, `Gist`, `Tile` and `List.Tile` for a registered tool;
3
+ * `Tile` and `Page` for an entity that carries a tool's text, and `Tile` for
4
+ * one the graph keeps. */ export declare let views: Registry;
5
+ //# sourceMappingURL=views.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"views.d.ts","sources":["../views.ts"],"names":[],"mappings":"AAoBA,SAGE,KAAK,QAAQ,4BAGiB;AAqEhC;;wBAEwB,GACxB,OAAO,YAAI,OAAO,SA0BhB"}
@@ -0,0 +1,9 @@
1
+ import { type VocabDoc } from "@yaks/vocab/runtime";
2
+ export declare const toolsDoc: VocabDoc;
3
+ /** Invocation records; compose with toolDoc or an existing tool declaration. */ export declare const callDoc: VocabDoc;
4
+ export declare const toolDoc: VocabDoc;
5
+ /** What this package is: its manifest's description, the one place it is
6
+ * written, which a host stamps on each document here. */ export declare const description: string;
7
+ /** Every document this plugin declares. */ export declare const docs: VocabDoc[];
8
+ export { executionDerived as derived } from "./state.js";
9
+ //# sourceMappingURL=vocab.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vocab.d.ts","sources":["../vocab.ts"],"names":[],"mappings":"AAGA,SAAe,KAAK,QAAQ,mCAAwC;AAGpE,OAAO,cAAM,UAAU,SAAc;AACrC,8EAA8E,GAC9E,OAAO,cAAM,SAAS,SAGrB;AACD,OAAO,cAAM,SAAS,SAA8B;AAEpD;uDACuD,GACvD,OAAO,cAAM,aAAa,MAAM,CAAuB;AAEvD,yCAAyC,GACzC,OAAO,cAAM,MAAM,WAAuB;AAE1C,SAAS,oBAAoB,OAAO,qBAAoB"}
@@ -0,0 +1,28 @@
1
+ /** A reading tool's query, as its declaration writes it. */ export type Watch = readonly (string | readonly string[])[];
2
+ /**
3
+ * The query a tool that declares `watch` answers for `args`, or a sentence
4
+ * saying which argument it does not watch: one no part names would change the
5
+ * answer in a way the query cannot follow.
6
+ *
7
+ * ```ts
8
+ * import { assertEquals } from '@std/assert'
9
+ * import { watched } from './watch.ts'
10
+ *
11
+ * let tasks = ['.task', ['%{query}', '.task.status=open'], '.limit=%{limit}']
12
+ * assertEquals(watched(tasks, {}), { query: '.task&.task.status=open' })
13
+ * assertEquals(watched(tasks, { query: '.task.status=done', limit: 5 }), {
14
+ * query: '.task&.task.status=done&.limit=5',
15
+ * })
16
+ * assertEquals(watched(['%{q}', '%{filters}'], { q: '.a', filters: ['.b', '.c'] }), {
17
+ * query: '.a&.b&.c',
18
+ * })
19
+ * assertEquals(watched(['%{q}'], { q: '.a', branch: 2 }), {
20
+ * refused: 'branch',
21
+ * })
22
+ * ```
23
+ */ export declare let watched: (watch: Watch, args: Record<string, unknown>) => {
24
+ query: string;
25
+ } | {
26
+ refused: string;
27
+ };
28
+ //# sourceMappingURL=watch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"watch.d.ts","sources":["../watch.ts"],"names":[],"mappings":"AAaA,0DAA0D,GAC1D,YAAY,kBAAkB,MAAM,YAAY,MAAM;AAmBtD;;;;;;;;;;;;;;;;;;;;;CAqBC,GACD,OAAO,YAAI,UACT,OAAO,OACP,MAAM,OAAO,MAAM,EAAE,OAAO;EACzB,OAAO,MAAM;;EAAO,SAAS,MAAM;EAevC"}
package/access.js ADDED
@@ -0,0 +1,3 @@
1
+ // A declared command's caller floor, shared by the app page and its server.
2
+ export let mayCall = (floor, person, role)=>!floor || !!person && (floor == 'person' || role == 'owner' || floor == 'editor' && role == 'editor');
3
+ //# sourceMappingURL=access.js.map
package/access.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"access.js","sources":["./access.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAG5E,OAAO,IAAI,UAAU,CACnB,OACA,QACA,OAEA,CAAC,SACD,CAAC,CAAC,UAAU,CAAC,SAAS,YAClB,QAAQ,WAAW,SAAS,YAAY,QAAQ,QAAQ,EAAC"}
package/access.ts ADDED
@@ -0,0 +1,11 @@
1
+ // A declared command's caller floor, shared by the app page and its server.
2
+ export type Floor = 'person' | 'editor' | 'owner'
3
+
4
+ export let mayCall = (
5
+ floor: Floor | undefined,
6
+ person: string | null,
7
+ role: string | null,
8
+ ) =>
9
+ !floor ||
10
+ !!person && (floor == 'person' ||
11
+ role == 'owner' || floor == 'editor' && role == 'editor')
package/app-view.js ADDED
@@ -0,0 +1,26 @@
1
+ // What an MCP Apps view is served as: the type a host renders it under and
2
+ // the metadata saying which origins it may reach.
3
+ /**
4
+ * The type a view is served under: text/html with the profile the MCP Apps
5
+ * spec requires, which is how a host tells a page it renders from a page it
6
+ * merely reads.
7
+ */ export let VIEW_MIME = 'text/html;profile=mcp-app';
8
+ /**
9
+ * Resource metadata for both portable MCP Apps and ChatGPT, on resource
10
+ * listings and read contents. `ui.domain` is optional and host-specific:
11
+ * Claude expects a hashed hostname, while ChatGPT accepts a website origin,
12
+ * so the OpenAI value is never copied into the portable field. The CSP lists
13
+ * the network destinations; it does not set the sandbox origin.
14
+ * https://github.com/modelcontextprotocol/ext-apps/blob/main/specification/2026-01-26/apps.mdx
15
+ * https://developers.openai.com/plugins/reference
16
+ */ export let uiMeta = (domain, csp = {})=>({
17
+ ui: {
18
+ csp
19
+ },
20
+ 'openai/widgetDomain': domain,
21
+ 'openai/widgetCSP': {
22
+ connect_domains: csp.connectDomains ?? [],
23
+ resource_domains: csp.resourceDomains ?? []
24
+ }
25
+ });
26
+ //# sourceMappingURL=app-view.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app-view.js","sources":["./app-view.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,kDAAkD;AAElD;;;;CAIC,GACD,OAAO,IAAI,YAAY,4BAA2B;AAgBlD;;;;;;;;CAQC,GACD,OAAO,IAAI,SAAS,CAAC,QAAgB,MAAW,CAAC,CAAC,GAAK,CAAC;IACtD,IAAI;MAAE;IAAI;IACV,uBAAuB;IACvB,oBAAoB;MAClB,iBAAiB,IAAI,cAAc,IAAI,EAAE;MACzC,kBAAkB,IAAI,eAAe,IAAI,EAAE;IAC7C;EACF,CAAC,EAAC"}