@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/traces.ts ADDED
@@ -0,0 +1,160 @@
1
+ import * as system from '@yaks/process/system'
2
+ // Box telemetry observes the runtime channel, never the watched database.
3
+ // Selection happens after a root completes; all unselected trees die in memory.
4
+ //
5
+ // A tree is held until its root ends, and some roots never do: an effect that
6
+ // watches for the life of the process, a socket. Delivery keeps at most
7
+ // TRACE_MAX_SPANS of a tree, so a tree past a few times that is cut back to
8
+ // the spans worth holding (@yaks/timing `held`). Held whole, such a root kept
9
+ // every span it ever ran until the worker ran out of heap.
10
+ import type { Bundle } from 'jsr:@yaks/graph@0.2.36'
11
+ import { held, TRACE_MAX_SPANS } from '@yaks/timing/cap'
12
+ import {
13
+ type RequestState,
14
+ sampleRequest,
15
+ selectRequest,
16
+ } from '@yaks/timing/request'
17
+ import { channel, type Event } from '@yaks/trace'
18
+ import type { Sink } from 'jsr:@yaks/tracker@0.2.36/report'
19
+
20
+ export type Capture = { requested: boolean; rate: number }
21
+ export type Traces = { close: () => Promise<void> }
22
+
23
+ // The most spans one tree holds before it is cut back.
24
+ let HOLD = 4 * TRACE_MAX_SPANS
25
+
26
+ export let traces = (
27
+ graph: object,
28
+ options: {
29
+ process: string
30
+ getStart?: (event: Event) => boolean
31
+ reportGetStart?: (stack: string) => void
32
+ sink?: Sink
33
+ take: () => Promise<Capture>
34
+ origin?: number
35
+ now?: () => number
36
+ random?: () => number
37
+ },
38
+ ): Traces => {
39
+ let origin = options.origin ?? performance.timeOrigin
40
+ let now = options.now ?? Date.now
41
+ let random = options.random ?? Math.random
42
+ let quota: RequestState = new Map()
43
+ let roots = new Map<string, string>()
44
+ let trees = new Map<string, {
45
+ events: Map<string, Event>
46
+ capture: Promise<Capture | undefined>
47
+ }>()
48
+ let trim = (events: Map<string, Event>) => {
49
+ let keep = held([...events.values()])
50
+ for (let id of events.keys()) {
51
+ if (keep.has(id)) continue
52
+ events.delete(id)
53
+ roots.delete(id)
54
+ }
55
+ }
56
+ let pending = new Set<Promise<void>>()
57
+ // Selection can be waiting on another process's capture-control lock. It
58
+ // has delivered nothing yet and must not hold a closing server open.
59
+ let selections = new Set<() => void>()
60
+ let select = (): Promise<Capture | undefined> => {
61
+ let choice = Promise.withResolvers<Capture | undefined>()
62
+ let cancel = () => choice.resolve(undefined)
63
+ selections.add(cancel)
64
+ void options.take().then(
65
+ (value) => choice.resolve(value),
66
+ () => choice.resolve({ requested: false, rate: 0 }),
67
+ ).finally(() => selections.delete(cancel))
68
+ return choice.promise
69
+ }
70
+ let complete = async (
71
+ events: Event[],
72
+ capture: Promise<Capture | undefined>,
73
+ ) => {
74
+ let root = events[0]
75
+ if (!root) return
76
+ let armed = await capture
77
+ if (!armed) return
78
+ let rowsRead = root.counts?.rowsRead ?? 0
79
+ let rowsWritten = root.counts?.rowsWritten ?? 0
80
+ let selected = selectRequest({
81
+ op: root.kind,
82
+ name: root.name,
83
+ now: now(),
84
+ rowsRead,
85
+ rowsWritten,
86
+ ...armed,
87
+ random: random(),
88
+ }, quota)
89
+ quota = selected.state
90
+ if (!selected.reason || !options.sink) return
91
+ let rows = sampleRequest(events, {
92
+ origin,
93
+ eid: crypto.randomUUID(),
94
+ during: { process: options.process },
95
+ rowsRead,
96
+ rowsWritten,
97
+ requested: true,
98
+ repeats: selected.repeats,
99
+ })
100
+ if (rows) await options.sink(rows as Bundle[])
101
+ }
102
+ let stop = channel(graph).subscribe((event) => {
103
+ if (
104
+ ['get', 'sql'].includes(event.kind) && event.stage == 'start' &&
105
+ options.getStart?.(event)
106
+ ) {
107
+ let errors = Error as ErrorConstructor & { stackTraceLimit?: number }
108
+ let before = errors.stackTraceLimit
109
+ let stack: string
110
+ try {
111
+ errors.stackTraceLimit = 48
112
+ stack = (new Error('armed get start').stack ?? '').slice(0, 8192)
113
+ } finally {
114
+ errors.stackTraceLimit = before
115
+ }
116
+ if (options.reportGetStart) options.reportGetStart(stack)
117
+ else {console.error(
118
+ JSON.stringify({ diagnostic: 'get-start', pid: system.pid, stack }),
119
+ )}
120
+ }
121
+ let root = roots.get(event.id) ?? (event.parent && roots.get(event.parent))
122
+ if (!root && ['request', 'apply', 'effect'].includes(event.kind)) {
123
+ root = event.id
124
+ if (event.stage != 'start') return
125
+ trees.set(root, {
126
+ events: new Map(),
127
+ capture: select(),
128
+ })
129
+ }
130
+ if (!root) return
131
+ let tree = trees.get(root)
132
+ if (!tree) return
133
+ roots.set(event.id, root)
134
+ tree.events.set(event.id, event)
135
+ if (tree.events.size > HOLD) trim(tree.events)
136
+ if (event.id != root || event.stage == 'start') return
137
+ trees.delete(root)
138
+ for (let id of tree.events.keys()) roots.delete(id)
139
+ // No graph reads, writes or projection on the unselected path. Failures
140
+ // here must not recursively report into the same spool.
141
+ let work = complete([...tree.events.values()], tree.capture).catch(
142
+ (error) => {
143
+ console.error('trace delivery failed —', error)
144
+ },
145
+ ).finally(() => pending.delete(work))
146
+ pending.add(work)
147
+ }, { history: false })
148
+ return {
149
+ close: async () => {
150
+ stop()
151
+ // A selection already resolved has priority over cancellation.
152
+ await Promise.resolve()
153
+ selections.forEach((cancel) => cancel())
154
+ selections.clear()
155
+ trees.clear()
156
+ roots.clear()
157
+ await Promise.all(pending)
158
+ },
159
+ }
160
+ }
package/tracker.js ADDED
@@ -0,0 +1,22 @@
1
+ // A local tracker's configured checkout becomes capabilities lent to its
2
+ // portable effects and tools; neither needs to know the filesystem or Git.
3
+ import { sourceFrames } from "@yaks/code/source";
4
+ import { commitsOf } from "@yaks/git/source";
5
+ import { enrichFrames } from "@yaks/tracker";
6
+ export let trackerOptions = (options, sources = sourceFrames, commits = commitsOf)=>{
7
+ let code = options.code;
8
+ if (!code) return options;
9
+ let capabilities = {
10
+ ...code.url && options.enrich == null ? {
11
+ enrich: enrichFrames(sources(code))
12
+ } : {},
13
+ ...options.commits == null ? {
14
+ commits: (sha)=>commits(code.cwd, sha)
15
+ } : {}
16
+ };
17
+ return Object.defineProperties({}, {
18
+ ...Object.getOwnPropertyDescriptors(options),
19
+ ...Object.getOwnPropertyDescriptors(capabilities)
20
+ });
21
+ };
22
+ //# sourceMappingURL=tracker.js.map
package/tracker.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tracker.js","sources":["./tracker.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,2EAA2E;AAC3E,SAAS,YAAY,iCAA0D;AAC/E,SAAS,SAAS,gCAAqC;AAEvD,SAAS,YAAY,6BAAkC;AAEvD,OAAO,IAAI,iBAAiB,CAC1B,SACA,UAA+B,YAAY,EAC3C,UAA4B,SAAS;EAErC,IAAI,OAAO,QAAQ,IAAI;EACvB,IAAI,CAAC,MAAM,OAAO;EAClB,IAAI,eAAe;IACjB,GAAG,KAAK,GAAG,IAAI,QAAQ,MAAM,IAAI,OAC7B;MAAE,QAAQ,aAAa,QAAQ;IAAO,IACtC,CAAC,CAAC;IACN,GAAG,QAAQ,OAAO,IAAI,OAClB;MAAE,SAAS,CAAC,MAAgB,QAAQ,KAAK,GAAG,EAAE;IAAK,IACnD,CAAC,CAAC;EACR;EACA,OAAO,OAAO,gBAAgB,CAAC,CAAC,GAAG;IACjC,GAAG,OAAO,yBAAyB,CAAC,QAAQ;IAC5C,GAAG,OAAO,yBAAyB,CAAC,aAAa;EACnD;AACF,EAAC"}
package/tracker.ts ADDED
@@ -0,0 +1,27 @@
1
+ // A local tracker's configured checkout becomes capabilities lent to its
2
+ // portable effects and tools; neither needs to know the filesystem or Git.
3
+ import { sourceFrames, type SourceOptions } from '@yaks/code/source'
4
+ import { commitsOf } from '@yaks/git/source'
5
+ import type { Options } from 'jsr:@yaks/host@0.2.36/config'
6
+ import { enrichFrames } from '@yaks/tracker'
7
+
8
+ export let trackerOptions = (
9
+ options: Options,
10
+ sources: typeof sourceFrames = sourceFrames,
11
+ commits: typeof commitsOf = commitsOf,
12
+ ): Options => {
13
+ let code = options.code as SourceOptions | undefined
14
+ if (!code) return options
15
+ let capabilities = {
16
+ ...code.url && options.enrich == null
17
+ ? { enrich: enrichFrames(sources(code)) }
18
+ : {},
19
+ ...options.commits == null
20
+ ? { commits: (sha: string) => commits(code.cwd, sha) }
21
+ : {},
22
+ }
23
+ return Object.defineProperties({}, {
24
+ ...Object.getOwnPropertyDescriptors(options),
25
+ ...Object.getOwnPropertyDescriptors(capabilities),
26
+ })
27
+ }
package/tty.js ADDED
@@ -0,0 +1,82 @@
1
+ // Process-backed presentation of the portable answers prepared by terminal.ts.
2
+ import { resolve } from "@yaks/render";
3
+ import { sheet } from "@yaks/render/views";
4
+ import { drawn, freshness, joined, nothing } from "./answer.js";
5
+ import { show as present } from "./terminal.js";
6
+ // What an answer wears in a terminal: @yaks/ui's components and these views'
7
+ // own classes, in its default theme. Loaded with the painter, so a printed
8
+ // answer never pays for it.
9
+ let dressed = async ()=>{
10
+ let { composition, sheet: kit } = await import("@yaks/ui");
11
+ return {
12
+ ...kit(composition),
13
+ ...sheet(composition.theme.colors)
14
+ };
15
+ };
16
+ /** The same answer painted for a terminal `columns` wide: the same views,
17
+ * mounted in @yaks/tui's document and laid out, styled and colored by its
18
+ * painter, once. Loaded only for a terminal, so a printed answer never pays
19
+ * for the painter. */ export let painted = async (views, vocab, answer, named, columns, page, answers)=>{
20
+ let [{ render: mount }, { print }, dress] = await Promise.all([
21
+ import("@yaks/react"),
22
+ import("@yaks/tui/print"),
23
+ dressed()
24
+ ]);
25
+ let groups = drawn(vocab, answer, named, page, (b, v, c)=>mount(views, b, v, vocab, {
26
+ ...c,
27
+ readOnly: true
28
+ }), {
29
+ answers
30
+ });
31
+ return joined([
32
+ ...groups.map((g)=>g.map((n)=>print(n, columns, dress))),
33
+ [
34
+ freshness(answer, page)
35
+ ]
36
+ ]);
37
+ };
38
+ /** An answer held in the terminal (@yaks/tui) until Ctrl-C, drawn as a
39
+ * printout draws it ({@link painted}). Loaded only when asked for, so a
40
+ * printed answer never pays for a terminal app. `config` is the config file
41
+ * naming the graph the answer came from, for a view that keeps reading it. A
42
+ * lone answer whose page is a component of its own (a plugin's `./tui`) is an
43
+ * app, and has the whole terminal, whether or not the answer was drawn as a
44
+ * `page`; anything else scrolls. */ export let hold = async (views, vocab, answer, config, named = [], page, answers)=>{
45
+ let [{ createElement: h }, { render: mount }, { run, Scroll }, dress] = await Promise.all([
46
+ import("react"),
47
+ import("@yaks/react"),
48
+ import("@yaks/tui"),
49
+ dressed()
50
+ ]);
51
+ let [lone] = answer;
52
+ let app = answer.length == 1 && 'Render' in (resolve(views, lone, 'Page', vocab, {
53
+ config
54
+ }) ?? {});
55
+ await run(()=>{
56
+ let nodes = drawn(vocab, answer, named, app ? page ?? nothing : page, (b, v, c)=>mount(views, b, v, vocab, {
57
+ ...c,
58
+ config
59
+ }), {
60
+ answers
61
+ }).flat();
62
+ return app ? nodes[0] : h(Scroll, {
63
+ id: 'answer',
64
+ grow: '1'
65
+ }, nodes.map((n)=>h('div', null, n)));
66
+ }, {
67
+ sheet: dress
68
+ });
69
+ };
70
+ /** Prepare and present an answer with the process-backed terminal painter. */ export let show = async (...args)=>{
71
+ let [c, views, vocab, said, held = {}, from, tool] = args;
72
+ return await present(c, views, vocab, said, held, from, tool, c.tui || c.tty ? async (prepared, answer, named, page, answers)=>{
73
+ if (c.tui) {
74
+ return await hold(held.views ?? prepared, vocab, answer, held.config, named, page, answers);
75
+ }
76
+ if (c.tty) {
77
+ let text = await painted(held.views ?? prepared, vocab, answer, named, c.tty.columns, page, answers);
78
+ if (text) c.tty.write(text);
79
+ }
80
+ } : undefined);
81
+ };
82
+ //# sourceMappingURL=tty.js.map
package/tty.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tty.js","sources":["./tty.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAE/E,SAAS,OAAO,4BAAiC;AAIjD,SAAS,KAAK,kCAAuC;AACrD,SACE,KAAK,EACL,SAAS,EAET,MAAM,EAEN,OAAO,sBACW;AACpB,SAAS,QAAQ,OAAO,wBAAuB;AAE/C,6EAA6E;AAC7E,2EAA2E;AAC3E,4BAA4B;AAC5B,IAAI,UAAU;EACZ,IAAI,EAAE,WAAW,EAAE,OAAO,GAAG,EAAE,GAAG,MAAM,MAAM,CAAC;EAC/C,OAAO;IAAE,GAAG,IAAI,YAAY;IAAE,GAAG,MA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N,OAAO,MAAM,KAAK,CAAC,EAAE,GAAG,EACtB,QACA;MAAE,IAAI;MAAU,MAAM;IAAI,GAC1B,MAAM,GAAG,CAAC,CAAC,IAAM,EAAE,OAAO,MAAM;EAEpC,GAAG;IAAE,OAAO;EAAM;AACpB,EAAC;AAED,4EAA4E,GAC5E,OAAO,IAAI,OAAO,OAChB,GAAG;EAEH,IAAI,CAAC,GAAG,OAAO,OAAO,MAAM,OAAO,CAAC,CAAC,EAAE,MAAM,KAAK,GAAG;EACrD,OAAO,MAAM,QACX,GACA,OACA,OACA,MACA,MACA,MACA,MACA,EAAE,GAAG,IAAI,EAAE,GAAG,GACV,OAAO,UAAU,QAAQ,OAAO,MAAM;IACtC,IAAI,EAAE,GAAG,EAAE;MACT,OAAO,MAAM,KACX,KAAK,KAAK,IAAI,UACd,OACA,QACA,KAAK,MAAM,EACX,OACA,MACA;IAEJ;IACA,IAAI,EAAE,GAAG,EAAE;MACT,IAAI,OAAO,MAAM,QACf,KAAK,KAAK,IAAI,UACd,OACA,QACA,OACA,EAAE,GAAG,CAAC,OAAO,EACb,MACA;MAEF,IAAI,MAAM,EAAE,GAAG,CAAC,KAAK,CAAC;IACxB;EACF,IACE;AAER,EAAC"}
package/tty.ts ADDED
@@ -0,0 +1,142 @@
1
+ // Process-backed presentation of the portable answers prepared by terminal.ts.
2
+ import type { Bundle } from 'jsr:@yaks/graph@0.2.36'
3
+ import { resolve } from '@yaks/render'
4
+ import type { Vocab } from 'jsr:@yaks/vocab@0.2.36/runtime'
5
+ /* @ts-types="npm:@types/react@19.3.0" */ import type { ReactNode } from 'react'
6
+ import type { Sheet } from 'jsr:@yaks/ui@0.2.36/sheet'
7
+ import { sheet } from '@yaks/render/views'
8
+ import {
9
+ drawn,
10
+ freshness,
11
+ type Held,
12
+ joined,
13
+ type Near,
14
+ nothing,
15
+ } from './answer.js'
16
+ import { show as present } from './terminal.js'
17
+
18
+ // What an answer wears in a terminal: @yaks/ui's components and these views'
19
+ // own classes, in its default theme. Loaded with the painter, so a printed
20
+ // answer never pays for it.
21
+ let dressed = async (): Promise<Sheet> => {
22
+ let { composition, sheet: kit } = await import('@yaks/ui')
23
+ return { ...kit(composition), ...sheet(composition.theme.colors) }
24
+ }
25
+
26
+ /** The same answer painted for a terminal `columns` wide: the same views,
27
+ * mounted in @yaks/tui's document and laid out, styled and colored by its
28
+ * painter, once. Loaded only for a terminal, so a printed answer never pays
29
+ * for the painter. */
30
+ export let painted = async (
31
+ views: Held,
32
+ vocab: Vocab,
33
+ answer: Bundle[],
34
+ named: Bundle[],
35
+ columns: number,
36
+ page?: Near,
37
+ answers?: ReadonlyMap<string, Bundle[]>,
38
+ ): Promise<string> => {
39
+ let [{ render: mount }, { print }, dress] = await Promise.all([
40
+ import('@yaks/react'),
41
+ import('@yaks/tui/print'),
42
+ dressed(),
43
+ ])
44
+ let groups = drawn<ReactNode>(
45
+ vocab,
46
+ answer,
47
+ named,
48
+ page,
49
+ (b, v, c) => mount(views, b, v, vocab, { ...c, readOnly: true }),
50
+ { answers },
51
+ )
52
+ return joined([
53
+ ...groups.map((g) => g.map((n) => print(n, columns, dress))),
54
+ [freshness(answer, page)],
55
+ ])
56
+ }
57
+
58
+ /** An answer held in the terminal (@yaks/tui) until Ctrl-C, drawn as a
59
+ * printout draws it ({@link painted}). Loaded only when asked for, so a
60
+ * printed answer never pays for a terminal app. `config` is the config file
61
+ * naming the graph the answer came from, for a view that keeps reading it. A
62
+ * lone answer whose page is a component of its own (a plugin's `./tui`) is an
63
+ * app, and has the whole terminal, whether or not the answer was drawn as a
64
+ * `page`; anything else scrolls. */
65
+ export let hold = async (
66
+ views: Held,
67
+ vocab: Vocab,
68
+ answer: Bundle[],
69
+ config?: string,
70
+ named: Bundle[] = [],
71
+ page?: Near,
72
+ answers?: ReadonlyMap<string, Bundle[]>,
73
+ ): Promise<void> => {
74
+ let [{ createElement: h }, { render: mount }, { run, Scroll }, dress] =
75
+ await Promise.all([
76
+ import('react'),
77
+ import('@yaks/react'),
78
+ import('@yaks/tui'),
79
+ dressed(),
80
+ ])
81
+ let [lone] = answer
82
+ let app = answer.length == 1 && 'Render' in
83
+ (resolve(views, lone, 'Page', vocab, { config }) ?? {})
84
+ await run(() => {
85
+ let nodes = drawn<ReactNode>(
86
+ vocab,
87
+ answer,
88
+ named,
89
+ app ? page ?? nothing : page,
90
+ (b, v, c) => mount(views, b, v, vocab, { ...c, config }),
91
+ { answers },
92
+ ).flat()
93
+ return app ? nodes[0] : h(
94
+ Scroll,
95
+ { id: 'answer', grow: '1' },
96
+ nodes.map((n) => h('div', null, n)),
97
+ )
98
+ }, { sheet: dress })
99
+ }
100
+
101
+ /** Prepare and present an answer with the process-backed terminal painter. */
102
+ export let show = async (
103
+ ...args: Parameters<typeof present>
104
+ ): Promise<void> => {
105
+ let [c, views, vocab, said, held = {}, from, tool] = args
106
+ return await present(
107
+ c,
108
+ views,
109
+ vocab,
110
+ said,
111
+ held,
112
+ from,
113
+ tool,
114
+ c.tui || c.tty
115
+ ? async (prepared, answer, named, page, answers) => {
116
+ if (c.tui) {
117
+ return await hold(
118
+ held.views ?? prepared,
119
+ vocab,
120
+ answer,
121
+ held.config,
122
+ named,
123
+ page,
124
+ answers,
125
+ )
126
+ }
127
+ if (c.tty) {
128
+ let text = await painted(
129
+ held.views ?? prepared,
130
+ vocab,
131
+ answer,
132
+ named,
133
+ c.tty.columns,
134
+ page,
135
+ answers,
136
+ )
137
+ if (text) c.tty.write(text)
138
+ }
139
+ }
140
+ : undefined,
141
+ )
142
+ }
@@ -0,0 +1,178 @@
1
+ import * as system from "@yaks/process/system";
2
+ import { command as launchCommand } from "@yaks/process/command";
3
+ import { names, read } from "./config.js";
4
+ import { reporter } from "./report.js";
5
+ import { instanceOf, others } from "./restart.js";
6
+ export let unitFailure = (exit)=>{
7
+ if (exit.result == 'success' && exit.others === 0) {
8
+ return Object.assign(new Error(`systemd unit ${exit.unit} stopped with no other ${instanceOf(exit.unit)?.[0]}@ ready, so nothing serves it until one starts; ` + '`yak restart` hands over ready-first'), {
9
+ name: 'SystemdUnitAlone'
10
+ });
11
+ }
12
+ if (!exit.result || exit.result == 'success') return;
13
+ return Object.assign(new Error(`systemd unit ${exit.unit} failed: ${exit.result} (${exit.code ?? 'unknown'} ${exit.status ?? 'unknown'})`), {
14
+ name: 'SystemdUnitFailure'
15
+ });
16
+ };
17
+ // Keep failures of the same unit together only when their termination and
18
+ // known diagnostic agree. The reporter's normal message key drops numbers,
19
+ // which would give every numeric exit code the same bug.
20
+ let diagnostics = [
21
+ [
22
+ 'heap-exhausted',
23
+ /Fatal JavaScript out of memory/i
24
+ ],
25
+ [
26
+ 'runtime-panic',
27
+ /Deno has panicked/i
28
+ ],
29
+ [
30
+ 'shutdown-deadline',
31
+ /yak work shutdown did not drain/i
32
+ ],
33
+ [
34
+ 'inspector-address-in-use',
35
+ /Failed to start inspector server/i
36
+ ],
37
+ [
38
+ 'dependency-resolution',
39
+ /Deno expects the node_modules\/ directory/i
40
+ ],
41
+ [
42
+ 'duplicate-component',
43
+ /component '.+' is declared twice, by /i
44
+ ]
45
+ ];
46
+ let failureKey = (exit, stderr)=>{
47
+ let unit = instanceOf(exit.unit)?.[0] ?? exit.unit;
48
+ let diagnosis = diagnostics.find(([, message])=>message.test(stderr))?.[0];
49
+ return JSON.stringify([
50
+ 'systemd',
51
+ unit,
52
+ exit.result,
53
+ exit.code,
54
+ exit.status,
55
+ diagnosis
56
+ ]);
57
+ };
58
+ let execute = async (command, args)=>{
59
+ let output = await launchCommand(command, {
60
+ args,
61
+ stdout: 'piped',
62
+ stderr: 'null',
63
+ stdin: 'null'
64
+ }).output();
65
+ return {
66
+ code: output.code,
67
+ stdout: new TextDecoder().decode(output.stdout)
68
+ };
69
+ };
70
+ /** Read only this invocation, never a previous restart's output. Journald
71
+ * merges stdout and stderr for these units, so retain both. A host whose
72
+ * runtime journal is root-only may allow a noninteractive privileged read. */ export let unitOutput = async (exit, run = execute)=>{
73
+ if (!exit.invocation || !/^[a-f0-9]{32}$/i.test(exit.invocation)) return '';
74
+ let args = [
75
+ '--quiet',
76
+ '--no-pager',
77
+ '--output=cat',
78
+ '--lines=40',
79
+ `_SYSTEMD_USER_UNIT=${exit.unit}`,
80
+ `_SYSTEMD_INVOCATION_ID=${exit.invocation}`,
81
+ `_UID=${system.uid()}`,
82
+ '_TRANSPORT=stdout'
83
+ ];
84
+ for (let [command, prefix] of [
85
+ [
86
+ 'journalctl',
87
+ []
88
+ ],
89
+ [
90
+ 'sudo',
91
+ [
92
+ '-n',
93
+ 'journalctl'
94
+ ]
95
+ ]
96
+ ]){
97
+ try {
98
+ let output = await run(command, [
99
+ ...prefix,
100
+ ...args
101
+ ]);
102
+ if (output.code == 0 && output.stdout.trim()) {
103
+ // deno-lint-ignore no-control-regex -- remove journald's ANSI styling
104
+ return output.stdout.replace(/\x1b\[[0-?]*[ -/]*[@-~]/g, '').slice(-8192).trim();
105
+ }
106
+ } catch {}
107
+ }
108
+ return '';
109
+ };
110
+ export let reportUnit = async (exit, report, output = unitOutput)=>{
111
+ let error = unitFailure(exit);
112
+ if (!error) return;
113
+ let stderr = await output(exit);
114
+ if (exit.result != 'success') {
115
+ Object.assign(error, {
116
+ fault: failureKey(exit, stderr)
117
+ });
118
+ }
119
+ await report(error, {
120
+ ...Object.fromEntries(Object.entries(exit).filter(([, value])=>value != null).map(([key, value])=>[
121
+ key,
122
+ String(value)
123
+ ])),
124
+ ...stderr ? {
125
+ stderr
126
+ } : {}
127
+ });
128
+ };
129
+ export let unitFailureCommand = {
130
+ name: 'unit_failure',
131
+ noun: 'unit',
132
+ verb: 'failure',
133
+ description: 'Report a systemd unit that failed, or stopped with no other instance of its template ready, from ExecStopPost to the configured tracker spool',
134
+ positional: [
135
+ 'unit'
136
+ ],
137
+ offered: (c)=>names(c.config, 'tracker'),
138
+ inputSchema: {
139
+ type: 'object',
140
+ additionalProperties: false,
141
+ required: [
142
+ 'unit'
143
+ ],
144
+ properties: {
145
+ unit: {
146
+ type: 'string',
147
+ description: 'the unit that ended (%n)'
148
+ }
149
+ }
150
+ },
151
+ run: async (args, context)=>{
152
+ let exit = {
153
+ unit: String(args.unit),
154
+ result: system.env.get('SERVICE_RESULT'),
155
+ code: system.env.get('EXIT_CODE'),
156
+ status: system.env.get('EXIT_STATUS'),
157
+ invocation: system.env.get('INVOCATION_ID')
158
+ };
159
+ let runtimeDir = system.env.get('XDG_RUNTIME_DIR');
160
+ if (exit.result == 'success' && runtimeDir) {
161
+ exit.others = await others(exit.unit, runtimeDir);
162
+ }
163
+ if (!unitFailure(exit)) return 0;
164
+ if (!context.config) throw new Error('unit failure needs --config');
165
+ let config = read(context.config);
166
+ if (!config.tracker) throw new Error('unit failure needs a tracker spool');
167
+ let report = reporter(config, undefined, undefined, {
168
+ command: 'systemd unit',
169
+ source: 'systemd'
170
+ });
171
+ await reportUnit(exit, (error, tags)=>report(error, {
172
+ tags
173
+ }));
174
+ await report.close();
175
+ return 0;
176
+ }
177
+ };
178
+ //# sourceMappingURL=unit_failure.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unit_failure.js","sources":["./unit_failure.ts"],"names":[],"mappings":"AAAA,YAAY,wCAA6C;AACzD,SAAS,WAAW,aAAa,qCAA0C;AAY3E,SAAS,KAAK,EAAE,IAAI,sBAAqB;AACzC,SAAS,QAAQ,sBAAqB;AACtC,SAAS,UAAU,EAAE,MAAM,uBAAsB;AAajD,OAAO,IAAI,cAAc,CAAC;EACxB,IAAI,KAAK,MAAM,IAAI,aAAa,KAAK,MAAM,KAAK,GAAG;IACjD,OAAO,OAAO,MAAM,CAClB,IAAI,MACF,CAAC,aAAa,EAAE,KAAK,IAAI,CAAC,uBAAuB,EAC/C,WAAW,KAAK,IAAI,GAAG,CAAC,EAAE,CAC3B,gDAAgD,CAAC,GAChD,yCAEJ;MAAE,MAAM;IAAmB;EAE/B;EACA,IAAI,CAAC,KAAK,MAAM,IAAI,KAAK,MAAM,IAAI,WAAW;EAC9C,OAAO,OAAO,MAAM,CAClB,I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