@yaks/cli 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 (331) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +1059 -2
  3. package/_dist/account-forward.d.ts +12 -0
  4. package/_dist/account-forward.d.ts.map +1 -0
  5. package/_dist/accounts.d.ts +23 -0
  6. package/_dist/accounts.d.ts.map +1 -0
  7. package/_dist/answer.d.ts +88 -0
  8. package/_dist/answer.d.ts.map +1 -0
  9. package/_dist/apply.d.ts +17 -0
  10. package/_dist/apply.d.ts.map +1 -0
  11. package/_dist/args.d.ts +86 -0
  12. package/_dist/args.d.ts.map +1 -0
  13. package/_dist/commands.d.ts +15 -0
  14. package/_dist/commands.d.ts.map +1 -0
  15. package/_dist/complete.d.ts +15 -0
  16. package/_dist/complete.d.ts.map +1 -0
  17. package/_dist/config.d.ts +37 -0
  18. package/_dist/config.d.ts.map +1 -0
  19. package/_dist/dependencies.d.ts +6 -0
  20. package/_dist/dependencies.d.ts.map +1 -0
  21. package/_dist/facets.d.ts +71 -0
  22. package/_dist/facets.d.ts.map +1 -0
  23. package/_dist/grammar.d.ts +5 -0
  24. package/_dist/grammar.d.ts.map +1 -0
  25. package/_dist/host.d.ts +164 -0
  26. package/_dist/host.d.ts.map +1 -0
  27. package/_dist/install.d.ts +43 -0
  28. package/_dist/install.d.ts.map +1 -0
  29. package/_dist/main.d.ts +16 -0
  30. package/_dist/main.d.ts.map +1 -0
  31. package/_dist/memo.d.ts +60 -0
  32. package/_dist/memo.d.ts.map +1 -0
  33. package/_dist/mod.d.ts +46 -0
  34. package/_dist/mod.d.ts.map +1 -0
  35. package/_dist/page.d.ts +73 -0
  36. package/_dist/page.d.ts.map +1 -0
  37. package/_dist/platform.d.ts +27 -0
  38. package/_dist/platform.d.ts.map +1 -0
  39. package/_dist/reader.d.ts +10 -0
  40. package/_dist/reader.d.ts.map +1 -0
  41. package/_dist/release.d.ts +48 -0
  42. package/_dist/release.d.ts.map +1 -0
  43. package/_dist/remote.d.ts +13 -0
  44. package/_dist/remote.d.ts.map +1 -0
  45. package/_dist/reported.d.ts +11 -0
  46. package/_dist/reported.d.ts.map +1 -0
  47. package/_dist/roles.d.ts +2 -0
  48. package/_dist/roles.d.ts.map +1 -0
  49. package/_dist/roster.d.ts +41 -0
  50. package/_dist/roster.d.ts.map +1 -0
  51. package/_dist/rpc.d.ts +29 -0
  52. package/_dist/rpc.d.ts.map +1 -0
  53. package/_dist/run.d.ts +164 -0
  54. package/_dist/run.d.ts.map +1 -0
  55. package/_dist/runtime.d.ts +4 -0
  56. package/_dist/runtime.d.ts.map +1 -0
  57. package/_dist/searching.d.ts +7 -0
  58. package/_dist/searching.d.ts.map +1 -0
  59. package/_dist/show.d.ts +22 -0
  60. package/_dist/show.d.ts.map +1 -0
  61. package/_dist/store.d.ts +25 -0
  62. package/_dist/store.d.ts.map +1 -0
  63. package/_dist/terminal.d.ts +17 -0
  64. package/_dist/terminal.d.ts.map +1 -0
  65. package/_dist/tool.d.ts +55 -0
  66. package/_dist/tool.d.ts.map +1 -0
  67. package/_dist/tty.d.ts +3 -0
  68. package/_dist/tty.d.ts.map +1 -0
  69. package/_dist/vault.d.ts +9 -0
  70. package/_dist/vault.d.ts.map +1 -0
  71. package/_dist/words.d.ts +11 -0
  72. package/_dist/words.d.ts.map +1 -0
  73. package/_dist/yak.d.ts +10 -0
  74. package/_dist/yak.d.ts.map +1 -0
  75. package/account-forward.js +40 -0
  76. package/account-forward.js.map +1 -0
  77. package/account-forward.ts +50 -0
  78. package/accounts.js +162 -0
  79. package/accounts.js.map +1 -0
  80. package/accounts.ts +228 -0
  81. package/answer.js +394 -0
  82. package/answer.js.map +1 -0
  83. package/answer.ts +569 -0
  84. package/apply.js +49 -0
  85. package/apply.js.map +1 -0
  86. package/apply.ts +54 -0
  87. package/args.js +420 -0
  88. package/args.js.map +1 -0
  89. package/args.ts +494 -0
  90. package/code.js +209 -0
  91. package/code.js.map +1 -0
  92. package/code.ts +227 -0
  93. package/commands.js +131 -0
  94. package/commands.js.map +1 -0
  95. package/commands.ts +142 -0
  96. package/complete.js +104 -0
  97. package/complete.js.map +1 -0
  98. package/complete.ts +152 -0
  99. package/config.js +125 -0
  100. package/config.js.map +1 -0
  101. package/config.ts +180 -0
  102. package/declarations.js +67 -0
  103. package/declarations.js.map +1 -0
  104. package/declarations.ts +84 -0
  105. package/deno.json +1 -0
  106. package/dependencies.js +126 -0
  107. package/dependencies.js.map +1 -0
  108. package/dependencies.ts +141 -0
  109. package/derive.js +102 -0
  110. package/derive.js.map +1 -0
  111. package/derive.ts +125 -0
  112. package/drain.js +83 -0
  113. package/drain.js.map +1 -0
  114. package/drain.ts +115 -0
  115. package/duties.ts +17 -0
  116. package/exports.json +1486 -0
  117. package/external.js +373 -0
  118. package/external.js.map +1 -0
  119. package/external.ts +435 -0
  120. package/facets.js +214 -0
  121. package/facets.js.map +1 -0
  122. package/facets.ts +232 -0
  123. package/feedback.js +54 -0
  124. package/feedback.js.map +1 -0
  125. package/feedback.ts +57 -0
  126. package/files.js +84 -0
  127. package/files.js.map +1 -0
  128. package/files.ts +112 -0
  129. package/get_starts.js +31 -0
  130. package/get_starts.js.map +1 -0
  131. package/get_starts.ts +34 -0
  132. package/git-credential.js +79 -0
  133. package/git-credential.js.map +1 -0
  134. package/git-credential.ts +77 -0
  135. package/grammar.js +4 -0
  136. package/grammar.js.map +1 -0
  137. package/grammar.ts +5 -0
  138. package/held.js +51 -0
  139. package/held.js.map +1 -0
  140. package/held.ts +66 -0
  141. package/host.js +1174 -0
  142. package/host.js.map +1 -0
  143. package/host.ts +1343 -0
  144. package/init.js +138 -0
  145. package/init.js.map +1 -0
  146. package/init.ts +139 -0
  147. package/install.js +216 -0
  148. package/install.js.map +1 -0
  149. package/install.ts +223 -0
  150. package/lifetime.js +56 -0
  151. package/lifetime.js.map +1 -0
  152. package/lifetime.ts +66 -0
  153. package/local-page.ts +114 -0
  154. package/local.js +417 -0
  155. package/local.js.map +1 -0
  156. package/local.ts +537 -0
  157. package/lockfile.js +20 -0
  158. package/lockfile.js.map +1 -0
  159. package/lockfile.ts +32 -0
  160. package/machines.js +33 -0
  161. package/machines.js.map +1 -0
  162. package/machines.ts +51 -0
  163. package/made/4f855610bdabcd736100d34e4e467ea5.json +1 -0
  164. package/main.js +534 -0
  165. package/main.js.map +1 -0
  166. package/main.ts +547 -0
  167. package/mcp.js +108 -0
  168. package/mcp.js.map +1 -0
  169. package/mcp.ts +113 -0
  170. package/member.js +103 -0
  171. package/member.js.map +1 -0
  172. package/member.ts +133 -0
  173. package/memo.js +503 -0
  174. package/memo.js.map +1 -0
  175. package/memo.ts +634 -0
  176. package/mod.js +46 -0
  177. package/mod.js.map +1 -0
  178. package/mod.ts +99 -0
  179. package/operations.js +53 -0
  180. package/operations.js.map +1 -0
  181. package/operations.ts +68 -0
  182. package/package.json +115 -4
  183. package/page.js +211 -0
  184. package/page.js.map +1 -0
  185. package/page.ts +308 -0
  186. package/parser.js +45 -0
  187. package/parser.js.map +1 -0
  188. package/parser.ts +77 -0
  189. package/people-search.js +112 -0
  190. package/people-search.js.map +1 -0
  191. package/people-search.ts +162 -0
  192. package/platform.js +184 -0
  193. package/platform.js.map +1 -0
  194. package/platform.ts +224 -0
  195. package/platform_effects.js +5 -0
  196. package/platform_effects.js.map +1 -0
  197. package/platform_effects.ts +13 -0
  198. package/prepare.js +40 -0
  199. package/prepare.js.map +1 -0
  200. package/prepare.ts +46 -0
  201. package/read_activity.js +54 -0
  202. package/read_activity.js.map +1 -0
  203. package/read_activity.ts +61 -0
  204. package/read_thread.js +387 -0
  205. package/read_thread.js.map +1 -0
  206. package/read_thread.ts +506 -0
  207. package/read_worker.ts +164 -0
  208. package/reader.js +48 -0
  209. package/reader.js.map +1 -0
  210. package/reader.ts +57 -0
  211. package/release.js +82 -0
  212. package/release.js.map +1 -0
  213. package/release.json +127 -0
  214. package/release.ts +98 -0
  215. package/remote-page.ts +70 -0
  216. package/remote.js +96 -0
  217. package/remote.js.map +1 -0
  218. package/remote.ts +153 -0
  219. package/report.js +83 -0
  220. package/report.js.map +1 -0
  221. package/report.ts +101 -0
  222. package/reported.js +32 -0
  223. package/reported.js.map +1 -0
  224. package/reported.ts +38 -0
  225. package/restart.js +349 -0
  226. package/restart.js.map +1 -0
  227. package/restart.ts +478 -0
  228. package/restore.js +32 -0
  229. package/restore.js.map +1 -0
  230. package/restore.ts +38 -0
  231. package/roles.js +32 -0
  232. package/roles.js.map +1 -0
  233. package/roles.ts +49 -0
  234. package/roster.js +65 -0
  235. package/roster.js.map +1 -0
  236. package/roster.ts +84 -0
  237. package/rpc.js +113 -0
  238. package/rpc.js.map +1 -0
  239. package/rpc.ts +159 -0
  240. package/run.js +533 -0
  241. package/run.js.map +1 -0
  242. package/run.ts +741 -0
  243. package/runtime.js +381 -0
  244. package/runtime.js.map +1 -0
  245. package/runtime.ts +433 -0
  246. package/sandboxes.js +26 -0
  247. package/sandboxes.js.map +1 -0
  248. package/sandboxes.ts +30 -0
  249. package/searching.js +33 -0
  250. package/searching.js.map +1 -0
  251. package/searching.ts +50 -0
  252. package/show.js +109 -0
  253. package/show.js.map +1 -0
  254. package/show.ts +144 -0
  255. package/shown.js +13 -0
  256. package/shown.js.map +1 -0
  257. package/shown.ts +44 -0
  258. package/stall.js +90 -0
  259. package/stall.js.map +1 -0
  260. package/stall.ts +156 -0
  261. package/stall_profile.js +113 -0
  262. package/stall_profile.js.map +1 -0
  263. package/stall_profile.ts +142 -0
  264. package/stall_wait.js +183 -0
  265. package/stall_wait.js.map +1 -0
  266. package/stall_wait.ts +249 -0
  267. package/stall_wait_worker.ts +11 -0
  268. package/start.js +349 -0
  269. package/start.js.map +1 -0
  270. package/start.ts +343 -0
  271. package/starvation.js +147 -0
  272. package/starvation.js.map +1 -0
  273. package/starvation.ts +224 -0
  274. package/store.js +118 -0
  275. package/store.js.map +1 -0
  276. package/store.ts +193 -0
  277. package/subcommands.js +62 -0
  278. package/subcommands.js.map +1 -0
  279. package/subcommands.ts +77 -0
  280. package/terminal.js +93 -0
  281. package/terminal.js.map +1 -0
  282. package/terminal.ts +128 -0
  283. package/text.js +20 -0
  284. package/text.js.map +1 -0
  285. package/text.ts +37 -0
  286. package/tool.js +76 -0
  287. package/tool.js.map +1 -0
  288. package/tool.ts +157 -0
  289. package/trace_control.js +231 -0
  290. package/trace_control.js.map +1 -0
  291. package/trace_control.ts +233 -0
  292. package/traces.js +138 -0
  293. package/traces.js.map +1 -0
  294. package/traces.ts +160 -0
  295. package/tracker.js +22 -0
  296. package/tracker.js.map +1 -0
  297. package/tracker.ts +27 -0
  298. package/tty.js +82 -0
  299. package/tty.js.map +1 -0
  300. package/tty.ts +142 -0
  301. package/unit_failure.js +178 -0
  302. package/unit_failure.js.map +1 -0
  303. package/unit_failure.ts +191 -0
  304. package/upkeep_thread.js +32 -0
  305. package/upkeep_thread.js.map +1 -0
  306. package/upkeep_thread.ts +35 -0
  307. package/upkeep_worker.ts +27 -0
  308. package/vault.js +186 -0
  309. package/vault.js.map +1 -0
  310. package/vault.ts +220 -0
  311. package/vocab-ids.js +63 -0
  312. package/vocab-ids.js.map +1 -0
  313. package/vocab-ids.ts +62 -0
  314. package/vocab.json +35 -0
  315. package/warm.js +138 -0
  316. package/warm.js.map +1 -0
  317. package/warm.ts +171 -0
  318. package/watch_revision.js +25 -0
  319. package/watch_revision.js.map +1 -0
  320. package/watch_revision.ts +30 -0
  321. package/words.js +29 -0
  322. package/words.js.map +1 -0
  323. package/words.ts +41 -0
  324. package/workspaces.js +40 -0
  325. package/workspaces.js.map +1 -0
  326. package/workspaces.ts +58 -0
  327. package/yak-unit-failure.conf +6 -0
  328. package/yak-unit-handoff.conf +2 -0
  329. package/yak.js +123 -0
  330. package/yak.js.map +1 -0
  331. package/yak.ts +136 -0
package/_dist/run.d.ts ADDED
@@ -0,0 +1,164 @@
1
+ import type { Tool, ToolId } from "@yaks/graph";
2
+ import { type Grammar, type Reads } from "./args.js";
3
+ import { type Rpc } from "./rpc.js";
4
+ import type { Tty } from "./answer.js";
5
+ import { type Env } from "./store.js";
6
+ /** What a command is handed: where it runs, where to print, and the global
7
+ * flags. */ export type Ctx = {
8
+ /** The MCP server this command talks to, where it talks to one — and the
9
+ * name its bearer token is stored under either way. */ host: string;
10
+ /** Optional account name; absent uses the computed default. */ as?: string;
11
+ /** The config file naming the graph this command opens, in this process.
12
+ * Absent where the command named an MCP server instead ({@link aimed}). */ config?: string;
13
+ /** Whether this command may run duties if it explicitly starts them —
14
+ * false under `--no-duties`: no inline duties; web still restores external workers. */ duties: boolean;
15
+ json: boolean;
16
+ /** Whether an answer is held in the terminal (@yaks/tui) rather than
17
+ * printed — `--tui`. */ tui: boolean;
18
+ /** Where an answer is painted rather than printed: present when stdout is
19
+ * a terminal (and `NO_COLOR` is unset), with its width and a writer that
20
+ * keeps the painter's escapes — the painter strips content's own. */ tty?: Tty;
21
+ help: boolean;
22
+ /** The session this command line speaks for ({@link via}), named the same
23
+ * way to a host over HTTP and to a graph this process opened. */ via?: string;
24
+ /** The directory this machine keeps its token and tool lists in
25
+ * (./store.ts): its own, unless a test hands in a scratch one. */ state?: string;
26
+ ask: Rpc;
27
+ reads: Reads;
28
+ out: (line: string) => void;
29
+ note: (line: string) => void;
30
+ /** Every command this run can reach, including the ones that cost a
31
+ * composition or a round trip. Gathered once; a list that cannot be fetched
32
+ * is left out. */ all: () => Promise<Command[]>;
33
+ /** The usage page — every tool one line each, and why a list is missing. */ page: () => Promise<string>;
34
+ };
35
+ /**
36
+ * One command this program can run: a tool's declaration — its name, its
37
+ * schema, how it is written on a command line — with a run of its own.
38
+ *
39
+ * A graph tool is `run(call, graph) → bundles` and only @yaks/tools' runner
40
+ * calls one. A command is the other end: it takes the arguments parsed off the
41
+ * command line, prints, and returns an exit code. The same declaration, so a
42
+ * command is listed, helped and tab-completed from the one schema; a different
43
+ * run, because a command line is not a tool call. `yak <tool>` is a command
44
+ * wrapping a call — local.ts writes one against the graph this command opened,
45
+ * platform.ts sends one to the MCP server it named.
46
+ */ export type Command = Omit<Tool, 'run' | 'recover'> & {
47
+ /** Global flags explicitly bound to this command's input properties. */ globals?: readonly GlobalFlag[];
48
+ /** Whether the usage page lists it here: a command for something this
49
+ * line's graph does not have (a box's process plan) is still run when
50
+ * typed and still has its own page, but is not offered. */ offered?: (c: Ctx) => boolean;
51
+ run: (args: Record<string, unknown>, c: Ctx) => number | Promise<number>;
52
+ };
53
+ export type GlobalFlag = 'as' | 'host' | 'config' | 'duties' | 'json' | 'tui' | 'help' | 'timing';
54
+ /** What a program brings besides its tools. */ export type Opts = {
55
+ /** The words to read. Defaults to `system.args`. */ argv?: string[];
56
+ /** What the program calls itself, in its usage and its help pages. */ name?: string;
57
+ /** The line the usage page opens with. */ about?: string;
58
+ /** The release this program is, which `--version` prints. */ version?: string;
59
+ /** The notes it closes with. */ notes?: string;
60
+ /** Global flags reserved by the program; tool inputs use name=value. */ globalFlags?: readonly string[];
61
+ /** The MCP server a command talks to where it names neither a config nor a
62
+ * host. */ host?: string;
63
+ /** More commands, where gathering them costs a composition or a round
64
+ * trip. `fresh` asks past any cache the list is kept in. */ more?: (c: Ctx, o?: {
65
+ fresh?: boolean;
66
+ }) => Command[] | Promise<Command[]>;
67
+ /** What to say where a line named no place and this machine keeps no graph,
68
+ * and the host it fell to would not answer it (`aimed`'s `unplaced`). */ nowhere?: string;
69
+ /** A command for a first word nothing else claimed. */ stray?: (word: string, args: string[], c: Ctx) => Command | undefined | Promise<Command | undefined>;
70
+ /** How a JSON-RPC request is sent, where a program has a caller of its own
71
+ * — a test passes a function that records what it was asked. */ ask?: Rpc;
72
+ /** The session this command line speaks for. Defaults to {@link via}. */ via?: string;
73
+ /** Where the environment is read from: this process's by default. A test
74
+ * passes a function, so it never sets a variable every other test shares. */ env?: Env;
75
+ /** Where a value written `@path` or `-` is read from. */ reads?: Reads;
76
+ out?: (line: string) => void;
77
+ note?: (line: string) => void;
78
+ };
79
+ /**
80
+ * The tools, refused where two of them answer to one command line. A two-word
81
+ * tool is reachable in either order, so `session list` and `list session` are
82
+ * the same tool, and a second tool using either pair is a command line that
83
+ * means two things.
84
+ *
85
+ * `cli` does not apply this to the whole list, because shadowing is the point
86
+ * of the order: a program that carries its own `login` means it. A contributor
87
+ * runs this over its own list, where two tools of one name are a mistake.
88
+ */ export declare let unique: <T extends ToolId>(tools: readonly T[]) => readonly T[];
89
+ /**
90
+ * The tool a command line names, and the words left for its schema. A two-word
91
+ * tool takes the word after it in either order; a one-word tool takes none.
92
+ *
93
+ * ```ts
94
+ * commandFor([{noun: 'session', verb: 'list', description: '', run: () => 0}],
95
+ * ['list', 'session', '--all'])?.args // ['--all']
96
+ * ```
97
+ */ export { commandFor } from "./args.js";
98
+ type Listed = Grammar & {
99
+ title?: string;
100
+ description?: string;
101
+ globals?: Command['globals'];
102
+ };
103
+ /** Every tool, one line each, its verbs grouped under their noun. */ export declare let usage: (tools: readonly Listed[], opts?: Opts) => string;
104
+ /** The flags a program keeps for itself, lifted off the command line before a
105
+ * command ever sees it. `host` and `config` are what the command line gave and
106
+ * nothing else — where a command runs when it gives neither is
107
+ * {@link aimed}'s answer. */ export declare let globals: (argv: readonly string[], env?: Env) => {
108
+ host?: string;
109
+ config?: string;
110
+ as?: string;
111
+ duties: boolean;
112
+ json: boolean;
113
+ tui: boolean;
114
+ help: boolean;
115
+ version: boolean;
116
+ timing: boolean;
117
+ rest: string[];
118
+ };
119
+ /**
120
+ * Where this command runs what it was asked: the graph a config file names,
121
+ * which it opens in this process, or an MCP server it calls over `/mcp`.
122
+ *
123
+ * A config names A graph. `yak --config yak.json task list` reads that file,
124
+ * composes its plugins over the SQLite file it names, runs the tool here and
125
+ * exits — no server, and nothing to wait for. `--host` is for a graph this
126
+ * machine cannot open as a file; given together the two name two places, which
127
+ * is a command line that means two things.
128
+ *
129
+ * In order: `--config`, `--host`, `$YAKS_HOST`, `$YAK_CONFIG`, the config this
130
+ * machine keeps for its own graph (`~/.yak/yak.json`), and the platform this
131
+ * program came with. A host name comes back either way, because it is also the
132
+ * name a bearer token is stored under.
133
+ *
134
+ * A config the line named is the one place the line means. A config found in
135
+ * the environment or at home is only the first place in the order, so a word
136
+ * its graph lacks goes `onward`, to the host: `yak app_list` on a machine that
137
+ * keeps a graph of its own still reaches the platform.
138
+ *
139
+ * A line that said nothing, on a machine that keeps no graph, falls to the
140
+ * platform only by default: it is `unplaced`, and a platform that will not
141
+ * answer it is not what the person was asking about.
142
+ *
143
+ * ```ts
144
+ * aimed({ host: 'yaks.app' }) // { host: 'yaks.app' }
145
+ * aimed({}, 'yaks.app', () => undefined) // { host: 'yaks.app', unplaced: true }
146
+ * aimed({}, 'yaks.app', (n) => n == 'YAK_CONFIG' ? 'yak.json' : undefined)
147
+ * // { config: 'yak.json', host: 'yaks.app', onward: true }
148
+ * ```
149
+ */ export declare let aimed: (said: {
150
+ host?: string;
151
+ config?: string;
152
+ }, dflt?: string, env?: Env) => {
153
+ config?: string;
154
+ host: string;
155
+ onward?: boolean;
156
+ unplaced?: boolean;
157
+ };
158
+ /**
159
+ * Run one command line. Returns the exit code a script reads: 0 succeeded, 1
160
+ * the tool or the server refused, 2 the command line was wrong.
161
+ */ export declare let cli: (tools: readonly Command[], opts?: Opts) => Promise<number>;
162
+ /** The `help` command every program here carries: the whole usage page, or
163
+ * one subcommand's own. */ export declare let helpTool: (opts?: Opts) => Command;
164
+ //# sourceMappingURL=run.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"run.d.ts","sources":["../run.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,4 @@
1
+ /** The checkout a URL in this runtime's private tree was copied from, the
2
+ * inverse of {@link runtimePath}: what a plugin running git or a checkout's
3
+ * tools asks for, since the private tree has no `.git`. */ export declare let runtimeSource: (url: string, from?: string | undefined, to?: string | undefined) => string;
4
+ //# sourceMappingURL=runtime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime.d.ts","sources":["../runtime.ts"],"names":[],"mappings":"AA6UA;;yDAEyD,GACzD,OAAO,YAAI,gBACT,KAAK,MAAM,EACX,OAAM,MAAM,GAAG,SAAS,EAGxB,KAAI,MAAM,GAAG,SAAS,KAGrB,MAAM,CACmE"}
@@ -0,0 +1,7 @@
1
+ import type { Hit } from "@yaks/fts";
2
+ import type { MeaningHit } from "@yaks/host";
3
+ /** What the two halves found for some words. */ export type Found = {
4
+ words: Hit[];
5
+ meaning: MeaningHit[];
6
+ };
7
+ //# sourceMappingURL=searching.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"searching.d.ts","sources":["../searching.ts"],"names":[],"mappings":"AAQA,cAAc,GAAG,yBAA8B;AAE/C,cAAc,UAAU,0BAA+B;AAEvD,8CAA8C,GAC9C,YAAY;EAAU,OAAO;EAAO,SAAS"}
@@ -0,0 +1,22 @@
1
+ import { type Grammar } from "./args.js";
2
+ /** Text from a server, with every escape sequence a terminal could act on
3
+ * removed. */ export declare let safe: (text: string) => string;
4
+ /** Every tool, one per line, with the short label that says what it is. */ export declare let toolLines: (tools: (Grammar & {
5
+ title?: string;
6
+ description?: string;
7
+ })[]) => string;
8
+ /**
9
+ * The argument part of the command line to type: the positional arguments in
10
+ * order, then every other property as an option, in brackets where it is
11
+ * optional. The tool's own schema is the whole grammar, so this is the only
12
+ * place that decides how a tool is written on a command line.
13
+ */ export declare let sketch: (t: Grammar, omit?: readonly string[], reserved?: readonly string[]) => string;
14
+ /** The whole command line to type, without the program's own name. */ export declare let lineOf: (t: Grammar, omit?: readonly string[], reserved?: readonly string[]) => string;
15
+ /** One tool's help page: the command line to type, what it is for, and a row
16
+ * per argument with its type, whether it is required, and the description the
17
+ * schema gives it. */ export declare let toolHelp: (t: Grammar & {
18
+ description?: string;
19
+ }, program?: string, reserved?: readonly string[]) => string;
20
+ /** Wrap prose to a width, so a description written for a model is readable in
21
+ * a terminal. */ export declare let wrap: (text: string, width: number, lead?: string) => string;
22
+ //# sourceMappingURL=show.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"show.d.ts","sources":["../show.ts"],"names":[],"mappings":"AASA,SAAoB,KAAK,OAAO,oBAAmB;AAMnD;YACY,GACZ,OAAO,YAAI,OAAQ,MAAM,MAAM,KAAG,MAAM,CAC8B;AAItE,yEAAyE,GACzE,OAAO,YAAI,YACT,QAAQ;EAAY,QAAQ,MAAM;EAAE,cAAc,MAAM;SACvD,MAAM,CAKR;AAgBD;;;;;CAKC,GACD,OAAO,YAAI,SACT,GAAG,SACH,gBAAe,MAAM,IACrB,oBAAmB,MAAM,OACxB,MAAM,CAgBR;AAED,oEAAoE,GACpE,OAAO,YAAI,SACT,GAAG,SACH,gBAAe,MAAM,IACrB,oBAAmB,MAAM,OACxB,MAAM,CAA4D;AAErE;;oBAEoB,GACpB,OAAO,YAAI,WACT,GAAG;EAAY,cAAc,MAAM;GACnC,kBACA,oBAAmB,MAAM,OACxB,MAAM,CAqCR;AAED;eACe,GACf,OAAO,YAAI,OAAQ,MAAM,MAAM,EAAE,OAAO,MAAM,EAAE,kBAAY,MAAM,CAcjE"}
@@ -0,0 +1,25 @@
1
+ import type { VocabDoc } from "@yaks/vocab";
2
+ import type { Listed } from "./tool.js";
3
+ /** The tools a host served, and the version stamp of that list — and the
4
+ * vocabulary its answers are drawn with, once one needed drawing
5
+ * (platform.ts `vocabOf`), dropped with the list it came beside. */ export type Roster = {
6
+ version?: string;
7
+ protocol?: string;
8
+ tools: Listed[];
9
+ vocab?: VocabDoc;
10
+ };
11
+ /** Where a variable is read from: this process's environment by default, or
12
+ * a function a test passes so it never sets one every other test shares. */ export type Env = (name: string) => string | undefined;
13
+ /** Where this operating system keeps a program's configuration. */ export declare let configDir: (vars?: Env) => string;
14
+ /** This program's own directory under it. */ export declare let stateDir: (vars?: Env) => string;
15
+ /** A roster cache over a filesystem. Destinations survive a retried migration,
16
+ * and a forgotten host cannot return from the legacy combined file. */ /** Where each host's roster is kept between commands. */ export type Rosters = {
17
+ cached: (host: string, dir?: string) => Promise<Roster | null>;
18
+ remember: (host: string, roster: Roster, dir?: string) => Promise<void>;
19
+ forget: (host: string, dir?: string) => Promise<void>;
20
+ };
21
+ export { accountToken as tokenFor } from "./accounts.js";
22
+ export declare let cached: Rosters['cached'];
23
+ export declare let remember: Rosters['remember'];
24
+ export declare let forget: Rosters['forget'];
25
+ //# sourceMappingURL=store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store.d.ts","sources":["../store.ts"],"names":[],"mappings":"AAkBA,cAAc,QAAQ,2BAAgC;AAEtD,cAAc,MAAM,oBAAmB;AAEvC;;kEAEkE,GAClE,YAAY;EACV,UAAU,MAAM;EAChB,WAAW,MAAM;EACjB,OAAO;EACP,QAAQ;;AAGV;0EAC0E,GAC1E,YAAY,OAAO,MAAM,MAAM,KAAK,MAAM,GAAG,SAAS;AAUtD,iEAAiE,GACjE,OAAO,YAAI,YAAa,OAAM,QAAY,MAAM,CAO/C;AAED,2CAA2C,GAC3C,OAAO,YAAI,WAAY,OAAM,QAAY,MAAM,CACC;AAkBhD;qEACqE,GACrE,uDAAuD,GACvD,YAAY;EACV,SAAS,MAAM,MAAM,EAAE,MAAM,MAAM,KAAK,QAAQ,SAAS,IAAI;EAC7D,WAAW,MAAM,MAAM,EAAE,QAAQ,QAAQ,MAAM,MAAM,KAAK,QAAQ,IAAI;EACtE,SAAS,MAAM,MAAM,EAAE,MAAM,MAAM,KAAK,QAAQ,IAAI;;AA4GtD,SAAS,gBAAgB,QAAQ,wBAAuB;AAExD,OAAO,YAAI,QAAQ,QAAQ,UAAyB;AACpD,OAAO,YAAI,UAAU,QAAQ,YAA6B;AAC1D,OAAO,YAAI,QAAQ,QAAQ,UAAyB"}
@@ -0,0 +1,17 @@
1
+ import type { Bundle } from "@yaks/graph";
2
+ import { type Registry } from "@yaks/render";
3
+ import type { Vocab } from "@yaks/vocab/runtime";
4
+ import { type Drawn, type Held, type Near, type Source, type Tty } from "./answer.js";
5
+ /** A prepared answer, handed to the caller's presentation boundary. */ export type Presentation = (views: Registry, answer: Bundle[], named: Bundle[], page: Near | undefined, answers: ReadonlyMap<string, Bundle[]>) => void | Promise<void>;
6
+ /** Prepare an answer's views and the references and queries they read, then
7
+ * present it through `present`, or print its portable text. A tool that wrote
8
+ * draws its answer as it now stands, and a page draws a lone entity whole,
9
+ * beside the links and comments its page asks for. */ export declare let show: (c: {
10
+ tui: boolean;
11
+ tty?: Tty;
12
+ out: (line: string) => void;
13
+ }, views: Registry, vocab: Vocab, said: Bundle[], held?: {
14
+ views?: Held;
15
+ config?: string;
16
+ }, from?: Source, tool?: Drawn, present?: Presentation) => Promise<void>;
17
+ //# sourceMappingURL=terminal.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"terminal.d.ts","sources":["../terminal.ts"],"names":[],"mappings":"AAEA,cAAc,MAAM,2BAAgC;AAEpD,SAAmB,KAAK,QAAQ,4BAAgD;AAChF,cAAc,KAAK,mCAAwC;AAC3D,SACE,KAAK,KAAK,EACV,KAAK,IAAI,EACT,KAAK,IAAI,EAQT,KAAK,MAAM,EAEX,KAAK,GAAG,sBAEU;AAEpB,qEAAqE,GACrE,YAAY,gBACV,OAAO,UACP,QAAQ,UACR,OAAO,UACP,MAAM,OAAO,SAAS,EACtB,SAAS,YAAY,MAAM,EAAE,cAC1B,IAAI,GAAG,QAAQ,IAAI;AAIxB;;;oDAGoD,GACpD,OAAO,YAAI,OACT;EAAK,KAAK,OAAO;EAAE,MAAM;EAAK,MAAM,MAAM,MAAM,KAAK,IAAI;GACzD,OAAO,UACP,OAAO,OACP,MAAM,UACN;EAAQ,QAAQ;EAAM,SAAS,MAAM;GACrC,OAAM,QACN,OAAM,OACN,UAAU,iBACT,QAAQ,IAAI,EAgFd"}
@@ -0,0 +1,55 @@
1
+ /** One property of an input schema, as much of it as this client reads:
2
+ * enough to decide how the argument on the command line becomes a value. */ export type Prop = {
3
+ type?: string | string[];
4
+ short?: string;
5
+ description?: string;
6
+ enum?: unknown[];
7
+ items?: Prop;
8
+ default?: unknown;
9
+ /** standard JSON Schema, and what tab completion offers when nothing else
10
+ * narrows the argument (@yaks/vocab: a text property's examples are unioned
11
+ * with its own stored values) */ examples?: unknown[];
12
+ /** the component whose entities this argument names — where tab completion
13
+ * reads ids from */ ref?: string;
14
+ /** true = this text is full-text indexed, so tab completion asks the
15
+ * index */ search?: boolean;
16
+ };
17
+ /** A tool's input schema — an object schema, or nothing when it takes no
18
+ * arguments. */ export type Schema = {
19
+ type?: string;
20
+ properties?: Record<string, Prop>;
21
+ required?: string[];
22
+ };
23
+ /** A tool as an MCP server lists it. */ export type Listed = {
24
+ name: string;
25
+ title?: string;
26
+ description?: string;
27
+ inputSchema?: Schema;
28
+ outputSchema?: Schema;
29
+ annotations?: {
30
+ title?: string;
31
+ readOnlyHint?: boolean;
32
+ };
33
+ /** what MCP carries beside the schemas — where a tool's two words and its
34
+ * command-line argument layout are sent (see {@link spelling}) */ _meta?: Record<string, unknown>;
35
+ };
36
+ /** The short label a listing shows beside a tool's name: its title, or the
37
+ * first sentence of its description. */ export declare let titleOf: (t: {
38
+ title?: string;
39
+ description?: string;
40
+ annotations?: {
41
+ title?: string;
42
+ };
43
+ }) => string;
44
+ /** The type a value should be converted to, as one word. A schema naming
45
+ * several (`['string', 'null']`) is read as the first that is not `null`. */ export declare let typeOf: (p: Prop | undefined) => string;
46
+ /** What a person types to name a tool: its two words where it has them, the
47
+ * one word where it declared a noun or a verb alone, its name otherwise.
48
+ * `toolName` (@yaks/graph) answers the same question for MCP, which writes a
49
+ * pair as `noun_verb`; a command line can afford a space, and a single word is
50
+ * the same word in both places. */ export declare let commandOf: (t: {
51
+ name?: string;
52
+ noun?: string;
53
+ verb?: string;
54
+ }) => string;
55
+ //# sourceMappingURL=tool.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool.d.ts","sources":["../tool.ts"],"names":[],"mappings":"AASA;0EAC0E,GAC1E,YAAY;EACV,OAAO,MAAM,GAAG,MAAM;EACtB,QAAQ,MAAM;EACd,cAAc,MAAM;EACpB,OAAO,OAAO;EACd,QAAQ;EACR,UAAU,OAAO;EACjB;;iCAE+B,GAC/B,WAAW,OAAO;EAClB;oBACkB,GAClB,MAAM,MAAM;EACZ;WACS,GACT,SAAS,OAAO;;AAGlB;cACc,GACd,YAAY;EACV,OAAO,MAAM;EACb,aAAa,OAAO,MAAM,EAAE;EAC5B,WAAW,MAAM;;AAanB,sCAAsC,GACtC,YAAY;EACV,MAAM,MAAM;EACZ,QAAQ,MAAM;EACd,cAAc,MAAM;EACpB,cAAc;EACd,eAAe;EACf;IAAgB,QAAQ,MAAM;IAAE,eAAe,OAAO;;EACtD;kEACgE,GAChE,QAAQ,OAAO,MAAM,EAAE,OAAO;;AAuEhC;sCACsC,GACtC,OAAO,YAAI,UACT;EAAK,QAAQ,MAAM;EAAE,cAAc,MAAM;EAAE;IAAgB,QAAQ,MAAM;;MACxE,MAAM,CAKR;AAED;2EAC2E,GAC3E,OAAO,YAAI,SAAU,GAAG,OAAO,SAAS,KAAG,MAAM,CAIhD;AAED;;;;iCAIiC,GACjC,OAAO,YAAI,YACT;EAAK,OAAO,MAAM;EAAE,OAAO,MAAM;EAAE,OAAO,MAAM;MAC/C,MAAM,CACoE"}
package/_dist/tty.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import { show as present } from "./terminal.js";
2
+ /** Prepare and present an answer with the process-backed terminal painter. */ export declare let show: (...args: Parameters<typeof present>) => Promise<void>;
3
+ //# sourceMappingURL=tty.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tty.d.ts","sources":["../tty.ts"],"names":[],"mappings":"AAeA,SAAS,QAAQ,OAAO,wBAAuB;AAqF/C,4EAA4E,GAC5E,OAAO,YAAI,OACT,GAAG,MAAM,kBAAkB,aAC1B,QAAQ,IAAI,EAsCd"}
@@ -0,0 +1,9 @@
1
+ import { type Local } from "@yaks/secrets";
2
+ /** The vault in a directory: `<dir>/<eid>.json` per secret, and `<dir>/salt`,
3
+ * the key its sentinels are hashed under, made the first time one is asked
4
+ * for. */ export declare let fileVault: (dir: string) => Local;
5
+ /** The vault for the graph in the database at `db`: files in a `secrets`
6
+ * directory beside it, or memory for a graph in memory. Made once per graph
7
+ * and handed round, so the plugin sealing a value and the code reading it back
8
+ * hold the same vault — for a graph in memory, the only way they could. */ export declare let vaultOf: (db: string) => Local;
9
+ //# sourceMappingURL=vault.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vault.d.ts","sources":["../vault.ts"],"names":[],"mappings":"AAyBA,SACE,KAAK,KAAK,6BAKqB;AAyDjC;;QAEQ,GACR,OAAO,YAAI,YAAa,KAAK,MAAM,KAAG,MAsHrC;AAED;;;yEAGyE,GACzE,OAAO,YAAI,UAAW,IAAI,MAAM,KAAG,MAIlC"}
@@ -0,0 +1,11 @@
1
+ import { type Config } from "./config.js";
2
+ import type { Load } from "@yaks/host";
3
+ import { type Words } from "@yaks/host/words";
4
+ import type { CliFacet } from "./host.js";
5
+ export { type Declared, type Words } from "@yaks/host/words";
6
+ /** The box's loader, including its terminal commands. */ export declare let facet: Load<{
7
+ cli: CliFacet;
8
+ }>;
9
+ /** The words a config's plugins declare: each one's `./vocab`, and nothing
10
+ * else — no database opened, no rule or tool imported. */ export declare let words: (config: Config, load?: Load) => Promise<Words>;
11
+ //# sourceMappingURL=words.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"words.d.ts","sources":["../words.ts"],"names":[],"mappings":"AAQA,SAAS,KAAK,MAAM,sBAAqD;AAEzE,cAAsB,IAAI,0BAA+B;AACzD,SAAiB,KAAK,KAAK,gCAA8C;AACzE,cAAc,QAAQ,oBAAmB;AACzC,SAAS,KAAK,QAAQ,EAAE,KAAK,KAAK,gCAA8C;AAEhF,uDAAuD,GACvD,OAAO,YAAI,OAAO;EAAO,KAAK;GAI7B;AAED;wDACwD,GACxD,OAAO,YAAI,QACT,QAAQ,QACR,OAAM,SACL,QAAQ,OAaV"}
package/_dist/yak.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ /** The Git directory every worktree of the checkout at `root` shares, read as
2
+ * Git reads it: `.git` is that directory, or a file naming the worktree's
3
+ * own, whose `commondir` names the shared one. Undefined when `root` is no
4
+ * Git checkout. */ export declare let common: (root: string) => Promise<string | undefined>;
5
+ /** Wait until no landing writes the checkout at `root`, and keep the next
6
+ * from writing it until the returned release. Undefined when `root` is no Git
7
+ * checkout. */ export declare let steady: (root: string) => Promise<(() => void) | undefined>;
8
+ export declare let start: (argv: string[]) => Promise<void>;
9
+ /** The value a command line gives `--name`. */ export declare let flag: (argv: string[], name: string) => string | undefined;
10
+ //# sourceMappingURL=yak.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"yak.d.ts","sources":["../yak.ts"],"names":[],"mappings":"AAwBA;;;iBAGiB,GACjB,OAAO,YAAI,SAAgB,MAAM,MAAM,KAAG,QAAQ,MAAM,GAAG,SAAS,EAOnE;AAED;;aAEa,GACb,OAAO,YAAI,SACT,MAAM,MAAM,KACX,eAAe,IAAI,IAAI,SAAS,EAGlC;AAYD,OAAO,YAAI,QAAe,MAAM,MAAM,OAAK,QAAQ,IAAI,EAkEtD;AAKD,6CAA6C,GAC7C,OAAO,YAAI,OAAQ,MAAM,MAAM,IAAI,MAAM,MAAM,KAAG,MAAM,GAAG,SAAS,CAInE"}
@@ -0,0 +1,40 @@
1
+ // The shared box can route platform requests through its private admin sign-in.
2
+ // This address is a transport selector. It is never sent to the platform.
3
+ export let FORWARDED = 'yak_admin_forward:';
4
+ export let ADMIN_ACCOUNT = 'admin@bot.yak.sh';
5
+ export let CHECKS_ACCOUNT = 'checks@bot.yak.sh';
6
+ let forwarder = (config)=>{
7
+ let plugin = config.plugins?.find((p)=>typeof p != 'string' && p.use == '@yaks/admin');
8
+ let endpoint = typeof plugin == 'object' && plugin.with?.forward;
9
+ if (typeof endpoint == 'string') return endpoint;
10
+ };
11
+ /** The shared box keeps a dedicated connection for agents' checks. */ export let boxAccount = (config, as, agent = false)=>as ?? (agent && forwarder(config) ? CHECKS_ACCOUNT : undefined);
12
+ export let adminForward = (config, as)=>{
13
+ if (!as || ![
14
+ 'admin',
15
+ ADMIN_ACCOUNT
16
+ ].includes(as.toLowerCase())) return;
17
+ let endpoint = forwarder(config);
18
+ if (endpoint) return FORWARDED + endpoint;
19
+ };
20
+ export let forwarded = (url, credential, browser, init)=>{
21
+ if (!credential?.startsWith(FORWARDED)) return {
22
+ url,
23
+ init
24
+ };
25
+ let headers = new Headers(init.headers);
26
+ headers.delete('authorization');
27
+ headers.delete('cookie');
28
+ headers.set('x-yak-credential', browser ? 'session' : 'bearer');
29
+ let target = new URL(credential.slice(FORWARDED.length));
30
+ target.searchParams.set('url', url);
31
+ return {
32
+ url: target.href,
33
+ init: {
34
+ ...init,
35
+ headers,
36
+ redirect: 'manual'
37
+ }
38
+ };
39
+ };
40
+ //# sourceMappingURL=account-forward.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"account-forward.js","sources":["./account-forward.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,0EAA0E;AAG1E,OAAO,IAAI,YAAY,qBAAoB;AAC3C,OAAO,IAAI,gBAAgB,mBAAkB;AAC7C,OAAO,IAAI,iBAAiB,oBAAmB;AAI/C,IAAI,YAAY,CAAC;EACf,IAAI,SAAS,OAAO,OAAO,EAAE,KAAK,CAAC,IACjC,OAAO,KAAK,YAAY,EAAE,GAAG,IAAI;EAEnC,IAAI,WAAW,OAAO,UAAU,YAAY,OAAO,IAAI,EAAE;EACzD,IAAI,OAAO,YAAY,UAAU,OAAO;AAC1C;AAEA,oEAAoE,GACpE,OAAO,IAAI,aAAa,CACtB,QACA,IACA,QAAQ,KAAK,GAEb,MAAM,CAAC,SAAS,UAAU,UAAU,iBAAiB,SAAS,EAAC;AAEjE,OAAO,IAAI,eAAe,CACxB,QACA;EAEA,IAAI,CAAC,MAAM,CAAC;IAAC;IAAS;GAAc,CAAC,QAAQ,CAAC,GAAG,WAAW,KAAK;EACjE,IAAI,WAAW,UAAU;EACzB,IAAI,UAAU,OAAO,YAAY;AACnC,EAAC;AAED,OAAO,IAAI,YAAY,CACrB,KACA,YACA,SACA;EAEA,IAAI,CAAC,YAAY,WAAW,YAAY,OAAO;IAAE;IAAK;EAAK;EAC3D,IAAI,UAAU,IAAI,QAAQ,KAAK,OAAO;EACtC,QAAQ,MAAM,CAAC;EACf,QAAQ,MAAM,CAAC;EACf,QAAQ,GAAG,CAAC,oBAAoB,UAAU,YAAY;EACtD,IAAI,SAAS,IAAI,IAAI,WAAW,KAAK,CAAC,UAAU,MAAM;EACtD,OAAO,YAAY,CAAC,GAAG,CAAC,OAAO;EAC/B,OAAO;IAAE,KAAK,OAAO,IAAI;IAAE,MAAM;MAAE,GAAG,IAAI;MAAE;MAAS,UAAU;IAAS;EAAE;AAC5E,EAAC"}
@@ -0,0 +1,50 @@
1
+ // The shared box can route platform requests through its private admin sign-in.
2
+ // This address is a transport selector. It is never sent to the platform.
3
+ import type { Config } from 'jsr:@yaks/host@0.2.36'
4
+
5
+ export let FORWARDED = 'yak_admin_forward:'
6
+ export let ADMIN_ACCOUNT = 'admin@bot.yak.sh'
7
+ export let CHECKS_ACCOUNT = 'checks@bot.yak.sh'
8
+
9
+ type Plugins = Pick<Config, 'plugins'>
10
+
11
+ let forwarder = (config: Plugins): string | undefined => {
12
+ let plugin = config.plugins?.find((p) =>
13
+ typeof p != 'string' && p.use == '@yaks/admin'
14
+ )
15
+ let endpoint = typeof plugin == 'object' && plugin.with?.forward
16
+ if (typeof endpoint == 'string') return endpoint
17
+ }
18
+
19
+ /** The shared box keeps a dedicated connection for agents' checks. */
20
+ export let boxAccount = (
21
+ config: Plugins,
22
+ as?: string,
23
+ agent = false,
24
+ ): string | undefined =>
25
+ as ?? (agent && forwarder(config) ? CHECKS_ACCOUNT : undefined)
26
+
27
+ export let adminForward = (
28
+ config: Plugins,
29
+ as?: string,
30
+ ): string | undefined => {
31
+ if (!as || !['admin', ADMIN_ACCOUNT].includes(as.toLowerCase())) return
32
+ let endpoint = forwarder(config)
33
+ if (endpoint) return FORWARDED + endpoint
34
+ }
35
+
36
+ export let forwarded = (
37
+ url: string,
38
+ credential: string | null | undefined,
39
+ browser: boolean,
40
+ init: RequestInit,
41
+ ): { url: string; init: RequestInit } => {
42
+ if (!credential?.startsWith(FORWARDED)) return { url, init }
43
+ let headers = new Headers(init.headers)
44
+ headers.delete('authorization')
45
+ headers.delete('cookie')
46
+ headers.set('x-yak-credential', browser ? 'session' : 'bearer')
47
+ let target = new URL(credential.slice(FORWARDED.length))
48
+ target.searchParams.set('url', url)
49
+ return { url: target.href, init: { ...init, headers, redirect: 'manual' } }
50
+ }
package/accounts.js ADDED
@@ -0,0 +1,162 @@
1
+ import * as system from "@yaks/process/system";
2
+ import * as disk from "@yaks/file/io";
3
+ import { importing } from "@yaks/fp/imports";
4
+ import { line } from "@yaks/query";
5
+ import { configPath, dbOf, located, person, read, used } from "./config.js";
6
+ import { stateDir } from "./store.js";
7
+ import { adminForward, boxAccount } from "./account-forward.js";
8
+ export let personalPath = (state)=>`${state}/accounts.json`;
9
+ /** Make the personal graph only on explicit auth. Domain plugins are secrets
10
+ * and connections; core vocabulary, stamps and sealing effects are plumbing. */ export let personal = async (state = stateDir())=>{
11
+ let path = personalPath(state);
12
+ try {
13
+ await disk.stat(path);
14
+ return path;
15
+ } catch (e) {
16
+ if (!(e instanceof disk.errors.NotFound)) throw e;
17
+ }
18
+ await disk.mkdir(state, {
19
+ recursive: true,
20
+ mode: 0o700
21
+ });
22
+ let person = crypto.randomUUID();
23
+ await disk.writeTextFile(path, JSON.stringify({
24
+ db: `${state}/accounts.db`,
25
+ person,
26
+ plugins: [
27
+ '@yaks/kernel',
28
+ '@yaks/provenance',
29
+ '@yaks/edge',
30
+ '@yaks/doc',
31
+ '@yaks/effects',
32
+ '@yaks/secrets',
33
+ '@yaks/connections'
34
+ ]
35
+ }, null, 2) + '\n', {
36
+ createNew: true,
37
+ mode: 0o600
38
+ });
39
+ // Explicit auth creates its personal graph; opening it to write adds the
40
+ // schema. Ordinary token lookups only read this file.
41
+ let { compose } = await import("./host.js");
42
+ let { read } = await import("./config.js");
43
+ let host = await compose(read(path), [
44
+ 'graph'
45
+ ], undefined, {
46
+ process: false
47
+ });
48
+ await host.close();
49
+ return path;
50
+ };
51
+ export let accounts = (doors)=>{
52
+ let opened = new Map();
53
+ let readers = new Map();
54
+ let accountReader = (config, plugins)=>{
55
+ let key = JSON.stringify([
56
+ dbOf(config),
57
+ plugins
58
+ ]);
59
+ let held = readers.get(key);
60
+ if (!held) {
61
+ held = doors.reader(config, plugins);
62
+ readers.set(key, held);
63
+ held.catch(()=>readers.delete(key));
64
+ }
65
+ return held;
66
+ };
67
+ let host = (path)=>{
68
+ let held = opened.get(path);
69
+ if (!held) {
70
+ held = doors.host(path);
71
+ opened.set(path, held);
72
+ }
73
+ return held;
74
+ };
75
+ let close = async ()=>{
76
+ let held = [
77
+ ...opened.values()
78
+ ];
79
+ let read = [
80
+ ...readers.values()
81
+ ];
82
+ opened.clear();
83
+ readers.clear();
84
+ for (let r of read)(await r).close();
85
+ for (let h of held)await (await h).close();
86
+ };
87
+ let token = async (hostName, state = stateDir(), opts = {})=>{
88
+ let env = opts.env ?? ((name)=>system.env.get(name));
89
+ let explicit = env('YAKS_TOKEN');
90
+ if (explicit) return explicit;
91
+ let path = opts.config ?? configPath(undefined, env) ?? personalPath(state);
92
+ let config = await doors.config(path);
93
+ let url = new URL((await import("./rpc.js")).doorUrl(hostName));
94
+ let as = opts.as;
95
+ if (config && opts.agent !== undefined && url.origin == 'https://yaks.app') {
96
+ as = boxAccount(config, as, opts.agent);
97
+ let forwarded = adminForward(config, as);
98
+ if (forwarded) return forwarded;
99
+ }
100
+ if (!config?.person) return null;
101
+ let plugins = (config.plugins ?? []).map(used);
102
+ if (!plugins.includes('@yaks/connections')) return null;
103
+ let integration = url.hostname == 'yaks.app' ? 'yaks.app' : url.href;
104
+ let direct = /^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/i.test(config.person) || /^(?:[a-z]+-)?[0-9]+$/i.test(config.person);
105
+ if (!as && direct) {
106
+ let r = await accountReader(config, // A prefixed ID is checked against every kind its owner carries. Its
107
+ // defining vocabulary may belong to any configured plugin.
108
+ /^[a-z]+-[0-9]+$/i.test(config.person) ? plugins : plugins.filter((p)=>[
109
+ '@yaks/kernel',
110
+ '@yaks/provenance',
111
+ '@yaks/id',
112
+ '@yaks/connections'
113
+ ].includes(p)));
114
+ let owner = await person({
115
+ config,
116
+ graph: r.graph
117
+ });
118
+ if (!owner) return null;
119
+ let found = await r.graph.read(line`.connection.owner=${owner} .connection.integration=${integration} .fields=entity.eid .limit=1`);
120
+ if (!found.length) return null;
121
+ }
122
+ let h = await host(path);
123
+ let owner = await person(h);
124
+ if (!owner) return null;
125
+ return (await doors.credential({
126
+ graph: h.graph,
127
+ vault: h.vault
128
+ }, owner, integration, as))?.bearer ?? null;
129
+ };
130
+ return {
131
+ host,
132
+ close,
133
+ token
134
+ };
135
+ };
136
+ let command = accounts({
137
+ config: async (path)=>{
138
+ try {
139
+ await disk.stat(path);
140
+ } catch (e) {
141
+ if (e instanceof disk.errors.NotFound) return undefined;
142
+ throw e;
143
+ }
144
+ return read(path);
145
+ },
146
+ reader: (config, plugins)=>import("./reader.js").then(({ reader })=>reader(config, plugins)),
147
+ host: async (path)=>{
148
+ let { compose } = await import("./host.js");
149
+ return compose(read(path), [
150
+ 'graph'
151
+ ]);
152
+ },
153
+ credential: async (...args)=>{
154
+ let { accountCredential } = await importing(import.meta.resolve(located('@yaks/connections')));
155
+ return accountCredential(...args);
156
+ }
157
+ });
158
+ /** Account graphs are opened once per command and closed by the CLI's final
159
+ * boundary. Dynamic imports keep an environment-only sandbox off the graph. */ export let accountHost = command.host;
160
+ export let closeAccounts = command.close;
161
+ /** The selected yaks.app connection, or YAKS_TOKEN for a graphless sandbox. */ export let accountToken = command.token;
162
+ //# sourceMappingURL=accounts.js.map