@yaks/harness 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 (230) hide show
  1. package/FRONTEND.md +170 -0
  2. package/LICENSE +202 -0
  3. package/MCPAuthPanel.js +166 -0
  4. package/MCPAuthPanel.js.map +1 -0
  5. package/MCPAuthPanel.ts +184 -0
  6. package/ModelPanel.js +124 -0
  7. package/ModelPanel.js.map +1 -0
  8. package/ModelPanel.ts +143 -0
  9. package/PersonaPanel.js +106 -0
  10. package/PersonaPanel.js.map +1 -0
  11. package/PersonaPanel.ts +110 -0
  12. package/README.md +1570 -2
  13. package/RuntimePanel.js +180 -0
  14. package/RuntimePanel.js.map +1 -0
  15. package/RuntimePanel.ts +205 -0
  16. package/STREAMING.md +101 -0
  17. package/WINDOWS.md +78 -0
  18. package/WORKER.md +221 -0
  19. package/_dist/agent.d.ts +197 -0
  20. package/_dist/agent.d.ts.map +1 -0
  21. package/_dist/cli.d.ts +10 -0
  22. package/_dist/cli.d.ts.map +1 -0
  23. package/_dist/conversations.d.ts +45 -0
  24. package/_dist/conversations.d.ts.map +1 -0
  25. package/_dist/default.d.ts +32 -0
  26. package/_dist/default.d.ts.map +1 -0
  27. package/_dist/detail.d.ts +16 -0
  28. package/_dist/detail.d.ts.map +1 -0
  29. package/_dist/diagnostics.d.ts +5 -0
  30. package/_dist/diagnostics.d.ts.map +1 -0
  31. package/_dist/effects.d.ts +35 -0
  32. package/_dist/effects.d.ts.map +1 -0
  33. package/_dist/http.d.ts +12 -0
  34. package/_dist/http.d.ts.map +1 -0
  35. package/_dist/isolated.d.ts +6 -0
  36. package/_dist/isolated.d.ts.map +1 -0
  37. package/_dist/local.d.ts +74 -0
  38. package/_dist/local.d.ts.map +1 -0
  39. package/_dist/machine.d.ts +3 -0
  40. package/_dist/machine.d.ts.map +1 -0
  41. package/_dist/mcp_auth.d.ts +8 -0
  42. package/_dist/mcp_auth.d.ts.map +1 -0
  43. package/_dist/mod.d.ts +43 -0
  44. package/_dist/mod.d.ts.map +1 -0
  45. package/_dist/model_selection.d.ts +8 -0
  46. package/_dist/model_selection.d.ts.map +1 -0
  47. package/_dist/routes.d.ts +11 -0
  48. package/_dist/routes.d.ts.map +1 -0
  49. package/_dist/runs.d.ts +7 -0
  50. package/_dist/runs.d.ts.map +1 -0
  51. package/_dist/runtime.d.ts +2 -0
  52. package/_dist/runtime.d.ts.map +1 -0
  53. package/_dist/session_machines.d.ts +18 -0
  54. package/_dist/session_machines.d.ts.map +1 -0
  55. package/_dist/skills.d.ts +11 -0
  56. package/_dist/skills.d.ts.map +1 -0
  57. package/_dist/store.d.ts +38 -0
  58. package/_dist/store.d.ts.map +1 -0
  59. package/_dist/tools.d.ts +28 -0
  60. package/_dist/tools.d.ts.map +1 -0
  61. package/_dist/view.d.ts +5 -0
  62. package/_dist/view.d.ts.map +1 -0
  63. package/_dist/vocab.d.ts +7 -0
  64. package/_dist/vocab.d.ts.map +1 -0
  65. package/_dist/worn.d.ts +52 -0
  66. package/_dist/worn.d.ts.map +1 -0
  67. package/agent.js +773 -0
  68. package/agent.js.map +1 -0
  69. package/agent.ts +959 -0
  70. package/app.js +811 -0
  71. package/app.js.map +1 -0
  72. package/app.ts +868 -0
  73. package/artifact_tools.js +186 -0
  74. package/artifact_tools.js.map +1 -0
  75. package/artifact_tools.ts +190 -0
  76. package/backend_worker.ts +286 -0
  77. package/cli.js +43 -0
  78. package/cli.js.map +1 -0
  79. package/cli.ts +48 -0
  80. package/conversations.js +526 -0
  81. package/conversations.js.map +1 -0
  82. package/conversations.ts +576 -0
  83. package/conversations_testing.ts +162 -0
  84. package/default.js +162 -0
  85. package/default.js.map +1 -0
  86. package/default.ts +168 -0
  87. package/deferred_model.ts +1 -0
  88. package/deno.json +1 -0
  89. package/detail.js +50 -0
  90. package/detail.js.map +1 -0
  91. package/detail.ts +75 -0
  92. package/diagnostics.js +132 -0
  93. package/diagnostics.js.map +1 -0
  94. package/diagnostics.ts +150 -0
  95. package/draft_vault.js +149 -0
  96. package/draft_vault.js.map +1 -0
  97. package/draft_vault.ts +176 -0
  98. package/effects.js +233 -0
  99. package/effects.js.map +1 -0
  100. package/effects.ts +250 -0
  101. package/frontend/vocab.json +376 -0
  102. package/frontend.js +511 -0
  103. package/frontend.js.map +1 -0
  104. package/frontend.ts +389 -0
  105. package/http.js +107 -0
  106. package/http.js.map +1 -0
  107. package/http.ts +105 -0
  108. package/input_text.js +91 -0
  109. package/input_text.js.map +1 -0
  110. package/input_text.ts +99 -0
  111. package/instructions.js +111 -0
  112. package/instructions.js.map +1 -0
  113. package/instructions.ts +145 -0
  114. package/isolated.js +512 -0
  115. package/isolated.js.map +1 -0
  116. package/isolated.ts +502 -0
  117. package/keyboard.js +544 -0
  118. package/keyboard.js.map +1 -0
  119. package/keyboard.ts +403 -0
  120. package/legacy_instructions.js +3 -0
  121. package/legacy_instructions.js.map +1 -0
  122. package/legacy_instructions.ts +13 -0
  123. package/local.js +181 -0
  124. package/local.js.map +1 -0
  125. package/local.ts +282 -0
  126. package/machine.js +3 -0
  127. package/machine.js.map +1 -0
  128. package/machine.ts +8 -0
  129. package/mcp.js +123 -0
  130. package/mcp.js.map +1 -0
  131. package/mcp.ts +141 -0
  132. package/mcp_auth.js +63 -0
  133. package/mcp_auth.js.map +1 -0
  134. package/mcp_auth.ts +91 -0
  135. package/mcp_authorize.js +17 -0
  136. package/mcp_authorize.js.map +1 -0
  137. package/mcp_authorize.ts +18 -0
  138. package/mcp_registry.js +178 -0
  139. package/mcp_registry.js.map +1 -0
  140. package/mcp_registry.ts +193 -0
  141. package/mod.js +43 -0
  142. package/mod.js.map +1 -0
  143. package/mod.ts +45 -0
  144. package/model_selection.js +72 -0
  145. package/model_selection.js.map +1 -0
  146. package/model_selection.ts +86 -0
  147. package/numbers.js +6 -0
  148. package/numbers.js.map +1 -0
  149. package/numbers.ts +8 -0
  150. package/package.json +106 -4
  151. package/panels.js +119 -0
  152. package/panels.js.map +1 -0
  153. package/panels.ts +259 -0
  154. package/patch.js +329 -0
  155. package/patch.js.map +1 -0
  156. package/patch.ts +325 -0
  157. package/perf.ts +65 -0
  158. package/providers.js +36 -0
  159. package/providers.js.map +1 -0
  160. package/providers.ts +53 -0
  161. package/remote.js +441 -0
  162. package/remote.js.map +1 -0
  163. package/remote.ts +446 -0
  164. package/results.js +49 -0
  165. package/results.js.map +1 -0
  166. package/results.ts +39 -0
  167. package/routes.js +64 -0
  168. package/routes.js.map +1 -0
  169. package/routes.ts +87 -0
  170. package/runs.js +478 -0
  171. package/runs.js.map +1 -0
  172. package/runs.ts +479 -0
  173. package/runtime/vocab.json +36 -0
  174. package/runtime.js +105 -0
  175. package/runtime.js.map +1 -0
  176. package/runtime.ts +112 -0
  177. package/session_machines.js +203 -0
  178. package/session_machines.js.map +1 -0
  179. package/session_machines.ts +216 -0
  180. package/sheet.js +55 -0
  181. package/sheet.js.map +1 -0
  182. package/sheet.ts +31 -0
  183. package/shutdown.js +7 -0
  184. package/shutdown.js.map +1 -0
  185. package/shutdown.ts +7 -0
  186. package/skills.js +116 -0
  187. package/skills.js.map +1 -0
  188. package/skills.ts +114 -0
  189. package/startup_bench.ts +140 -0
  190. package/status.js +82 -0
  191. package/status.js.map +1 -0
  192. package/status.ts +97 -0
  193. package/steps.baseline.json +28 -0
  194. package/steps_bench.ts +155 -0
  195. package/store.js +31 -0
  196. package/store.js.map +1 -0
  197. package/store.ts +82 -0
  198. package/streaming.js +3 -0
  199. package/streaming.js.map +1 -0
  200. package/streaming.ts +8 -0
  201. package/streaming_bench.ts +76 -0
  202. package/switch_bench.ts +97 -0
  203. package/testing.ts +177 -0
  204. package/tools.js +287 -0
  205. package/tools.js.map +1 -0
  206. package/tools.ts +313 -0
  207. package/transcript.js +149 -0
  208. package/transcript.js.map +1 -0
  209. package/transcript.ts +187 -0
  210. package/tree.js +97 -0
  211. package/tree.js.map +1 -0
  212. package/tree.ts +114 -0
  213. package/unfinished.js +186 -0
  214. package/unfinished.js.map +1 -0
  215. package/unfinished.ts +198 -0
  216. package/view.js +92 -0
  217. package/view.js.map +1 -0
  218. package/view.ts +102 -0
  219. package/vocab.js +23 -0
  220. package/vocab.js.map +1 -0
  221. package/vocab.json +494 -0
  222. package/vocab.ts +22 -0
  223. package/window_bench.ts +114 -0
  224. package/worker_bench.ts +72 -0
  225. package/workspace.js +21 -0
  226. package/workspace.js.map +1 -0
  227. package/workspace.ts +17 -0
  228. package/worn.js +194 -0
  229. package/worn.js.map +1 -0
  230. package/worn.ts +246 -0
package/skills.js ADDED
@@ -0,0 +1,116 @@
1
+ // Native skill discovery and instruction loading read the graph. Repository
2
+ // files are mirrors, never a model-request dependency or a machine lease.
3
+ //
4
+ // One rule for every host: a session working in a repository is offered that
5
+ // repository's skills, and one with none, as every session on yaks.app, is
6
+ // offered every skill its store keeps. This module reads only the graph, so
7
+ // the box (./local.ts) and a space's Operator (workers/yak) both load it.
8
+ import { argsOf, who } from "@yaks/graph/call";
9
+ import { Refused } from "@yaks/graph/errors";
10
+ import { lineage } from "@yaks/project";
11
+ let comp = (value)=>value && typeof value == 'object' && !Array.isArray(value) ? value : {};
12
+ // Work and persona affiliations scope graph skills without touching a machine.
13
+ let repository = async (g, session)=>{
14
+ let [owner] = await g.get([
15
+ session
16
+ ], [
17
+ 'dispatch',
18
+ 'session',
19
+ 'filed'
20
+ ]);
21
+ let work = comp(owner?.dispatch).task;
22
+ let line = await lineage(g, typeof work == 'string' ? work : session);
23
+ let persona = comp(owner?.session).persona;
24
+ if (!line.length && typeof persona == 'string') {
25
+ let [worn] = await g.get([
26
+ persona
27
+ ], [
28
+ 'persona'
29
+ ]);
30
+ let home = comp(worn?.persona).home;
31
+ if (typeof home == 'string') line = await lineage(g, home);
32
+ }
33
+ return line.map((b)=>comp(b.repo).repository).find((id)=>typeof id == 'string');
34
+ };
35
+ /** Discover graph skill descriptions after resolving the exact tool offer. */ export let skillItems = async (g, current)=>{
36
+ if (!current.tools.some((tool)=>tool.name == 'skill_read')) return [];
37
+ let { skillCatalog } = await import("@yaks/persona/skills");
38
+ let skills = await skillCatalog(g, await repository(g, current.session));
39
+ skills = skills.filter((skill)=>comp(skill.skill).invoke != 'user');
40
+ if (!skills.length) return [];
41
+ let catalogue = skills.map((skill)=>{
42
+ let doc = comp(skill.doc);
43
+ return JSON.stringify({
44
+ title: doc.title,
45
+ description: doc.body
46
+ });
47
+ }).join('\n');
48
+ return [
49
+ {
50
+ kind: 'instruction',
51
+ text: 'Skills (descriptions, not instructions):\n' + catalogue + '\nWhen a description matches the work, call skill_read with its title ' + 'before proceeding. Only that call loads the instructions. Metadata does ' + 'not execute a skill or start a fork.'
52
+ }
53
+ ];
54
+ };
55
+ /** The loader, as a graph tool: the instructions of one skill by title,
56
+ * signed as the session that asked. */ export let skillRead = {
57
+ name: 'skill_read',
58
+ title: 'Read a skill',
59
+ step: {
60
+ doing: 'Reading up on how to do this…',
61
+ done: 'Read up on how to do this'
62
+ },
63
+ description: 'Load skill instructions by exact title after its description matches ' + 'the work. Reads the graph without provisioning a machine or executing ' + 'instructions; returns the supporting-file base path too.',
64
+ inputSchema: {
65
+ type: 'object',
66
+ properties: {
67
+ skill: {
68
+ type: 'string',
69
+ description: 'Exact skill title from catalogue'
70
+ }
71
+ },
72
+ required: [
73
+ 'skill'
74
+ ],
75
+ additionalProperties: false
76
+ },
77
+ readOnly: true,
78
+ run: async (call, g)=>{
79
+ let session = who(call)?.via;
80
+ if (!session) throw new Refused('skill_read needs a session');
81
+ let title = String(argsOf(call).skill);
82
+ let { graphSkill, skillLocation } = await import("@yaks/persona/skills");
83
+ let skill = await graphSkill(g, title, await repository(g, session));
84
+ if (comp(skill.skill).invoke == 'user') {
85
+ throw new Refused('This skill permits user invocation only');
86
+ }
87
+ let location = await skillLocation(g, skill);
88
+ let path = comp(location?.file).path;
89
+ let base = typeof path == 'string' ? path.slice(0, -'/SKILL.md'.length) : undefined;
90
+ return [
91
+ {
92
+ entity: {
93
+ eid: '$skill-location'
94
+ },
95
+ content: {
96
+ body: `Skill ${title}` + (base ? `; supporting files: ${base}` : '') + '\nMetadata: ' + JSON.stringify(comp(skill.skill))
97
+ },
98
+ output: {
99
+ source: call.entity.eid
100
+ }
101
+ },
102
+ {
103
+ entity: {
104
+ eid: '$skill-instructions'
105
+ },
106
+ content: {
107
+ body: String(comp(skill.content).body)
108
+ },
109
+ output: {
110
+ source: call.entity.eid
111
+ }
112
+ }
113
+ ];
114
+ }
115
+ };
116
+ //# sourceMappingURL=skills.js.map
package/skills.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skills.js","sources":["./skills.ts"],"names":[],"mappings":"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"}
package/skills.ts ADDED
@@ -0,0 +1,114 @@
1
+ // Native skill discovery and instruction loading read the graph. Repository
2
+ // files are mirrors, never a model-request dependency or a machine lease.
3
+ //
4
+ // One rule for every host: a session working in a repository is offered that
5
+ // repository's skills, and one with none, as every session on yaks.app, is
6
+ // offered every skill its store keeps. This module reads only the graph, so
7
+ // the box (./local.ts) and a space's Operator (workers/yak) both load it.
8
+ import type { Comp, Eid, Graph, NamedTool } from 'jsr:@yaks/graph@0.2.36'
9
+ import { argsOf, who } from '@yaks/graph/call'
10
+ import { Refused } from '@yaks/graph/errors'
11
+ import type { Item } from 'jsr:@yaks/model@0.2.36'
12
+ import { lineage } from '@yaks/project'
13
+
14
+ let comp = (value: unknown): Comp =>
15
+ value && typeof value == 'object' && !Array.isArray(value)
16
+ ? value as Comp
17
+ : {}
18
+
19
+ // Work and persona affiliations scope graph skills without touching a machine.
20
+ let repository = async (
21
+ g: Graph,
22
+ session: Eid,
23
+ ): Promise<string | undefined> => {
24
+ let [owner] = await g.get([session], ['dispatch', 'session', 'filed'])
25
+ let work = comp(owner?.dispatch).task
26
+ let line = await lineage(g, typeof work == 'string' ? work : session)
27
+ let persona = comp(owner?.session).persona
28
+ if (!line.length && typeof persona == 'string') {
29
+ let [worn] = await g.get([persona], ['persona'])
30
+ let home = comp(worn?.persona).home
31
+ if (typeof home == 'string') line = await lineage(g, home)
32
+ }
33
+ return line.map((b) => comp(b.repo).repository)
34
+ .find((id): id is string => typeof id == 'string')
35
+ }
36
+
37
+ /** Discover graph skill descriptions after resolving the exact tool offer. */
38
+ export let skillItems = async (
39
+ g: Graph,
40
+ current: { session: Eid; tools: readonly { name: string }[] },
41
+ ): Promise<Item[]> => {
42
+ if (!current.tools.some((tool) => tool.name == 'skill_read')) return []
43
+ let { skillCatalog } = await import('@yaks/persona/skills')
44
+ let skills = await skillCatalog(g, await repository(g, current.session))
45
+ skills = skills.filter((skill) => comp(skill.skill).invoke != 'user')
46
+ if (!skills.length) return []
47
+ let catalogue = skills.map((skill) => {
48
+ let doc = comp(skill.doc)
49
+ return JSON.stringify({ title: doc.title, description: doc.body })
50
+ }).join('\n')
51
+ return [{
52
+ kind: 'instruction',
53
+ text: 'Skills (descriptions, not instructions):\n' + catalogue +
54
+ '\nWhen a description matches the work, call skill_read with its title ' +
55
+ 'before proceeding. Only that call loads the instructions. Metadata does ' +
56
+ 'not execute a skill or start a fork.',
57
+ }]
58
+ }
59
+
60
+ /** The loader, as a graph tool: the instructions of one skill by title,
61
+ * signed as the session that asked. */
62
+ export let skillRead: NamedTool = {
63
+ name: 'skill_read',
64
+ title: 'Read a skill',
65
+ step: {
66
+ doing: 'Reading up on how to do this…',
67
+ done: 'Read up on how to do this',
68
+ },
69
+ description:
70
+ 'Load skill instructions by exact title after its description matches ' +
71
+ 'the work. Reads the graph without provisioning a machine or executing ' +
72
+ 'instructions; returns the supporting-file base path too.',
73
+ inputSchema: {
74
+ type: 'object',
75
+ properties: {
76
+ skill: {
77
+ type: 'string',
78
+ description: 'Exact skill title from catalogue',
79
+ },
80
+ },
81
+ required: ['skill'],
82
+ additionalProperties: false,
83
+ },
84
+ readOnly: true,
85
+ run: async (call, g) => {
86
+ let session = who(call)?.via
87
+ if (!session) throw new Refused('skill_read needs a session')
88
+ let title = String(argsOf(call).skill)
89
+ let { graphSkill, skillLocation } = await import('@yaks/persona/skills')
90
+ let skill = await graphSkill(g, title, await repository(g, session))
91
+ if (comp(skill.skill).invoke == 'user') {
92
+ throw new Refused('This skill permits user invocation only')
93
+ }
94
+ let location = await skillLocation(g, skill)
95
+ let path = comp(location?.file).path
96
+ let base = typeof path == 'string'
97
+ ? path.slice(0, -'/SKILL.md'.length)
98
+ : undefined
99
+ return [{
100
+ entity: { eid: '$skill-location' },
101
+ content: {
102
+ body: `Skill ${title}` +
103
+ (base ? `; supporting files: ${base}` : '') +
104
+ '\nMetadata: ' +
105
+ JSON.stringify(comp(skill.skill)),
106
+ },
107
+ output: { source: call.entity.eid },
108
+ }, {
109
+ entity: { eid: '$skill-instructions' },
110
+ content: { body: String(comp(skill.content).body) },
111
+ output: { source: call.entity.eid },
112
+ }]
113
+ },
114
+ }
@@ -0,0 +1,140 @@
1
+ /** Isolated startup benchmark. Does not open the configured harness database. */
2
+
3
+ import * as fs from 'jsr:@yaks/file@0.2.36/io'
4
+ import { local } from './local.ts'
5
+ import { remote } from './remote.ts'
6
+ import type { Bundle } from 'jsr:@yaks/graph@0.2.36'
7
+ /* @ts-types="npm:@types/react@19.3.0" */ import { createElement as node } from 'npm:react@19.3.0'
8
+ import { App } from './app.ts'
9
+ import { frontend } from './frontend.ts'
10
+ import { at, harness, mount } from './testing.ts'
11
+ import { type Sample, type Samples, stopwatch } from 'jsr:@yaks/benchmark@0.2.36'
12
+ import { standaloneMain } from '../../bench/standalone-main.ts'
13
+ import { fixture } from '../../bench/fixture.ts'
14
+
15
+ export let corpus = (count: number, depth: number): Bundle[] => {
16
+ let rows: Bundle[] = []
17
+ for (let i = 0; i < count; i++) {
18
+ rows.push({
19
+ entity: { eid: 's' + i },
20
+ session: { id: 's' + i },
21
+ ...i
22
+ ? { spawned: { parent: 's0' }, fork: { from: 's0-e' + (depth - 1) } }
23
+ : {},
24
+ })
25
+ for (let j = 0; j < (i ? 10 : depth); j++) {
26
+ rows.push({
27
+ entity: { eid: 's' + i + '-e' + j },
28
+ entry: { session: 's' + i },
29
+ content: { body: 'message ' + 'x'.repeat(1000) },
30
+ ...(j ? { output: { source: 's' + i + '-e0' } } : {}),
31
+ })
32
+ }
33
+ if (i) {
34
+ rows.push({
35
+ entity: { eid: 'delivery:s' + i + ':s' + i + '-e9' },
36
+ entry: { session: 's0' },
37
+ content: { body: 'delivered' },
38
+ output: { source: 's0-e0' },
39
+ })
40
+ }
41
+ }
42
+ return rows
43
+ }
44
+
45
+ let seeded = fixture(async (path: string, count: number, depth: number) => {
46
+ let seed = await harness(path)
47
+ try {
48
+ // The measurement reads stored transcript state, not its setup transactions.
49
+ await seed.g.apply(corpus(count, depth))
50
+ } finally {
51
+ await seed.close()
52
+ }
53
+ })
54
+
55
+ export async function measure(
56
+ args: string[] = [],
57
+ ): Promise<Record<string, Samples>> {
58
+ let samples: Record<string, Samples> = {}
59
+
60
+ let directory = await fs.makeTempDir({ prefix: 'harness-startup-' })
61
+ let count = Number(args[0] ?? 300)
62
+ let depth = Number(args[1] ?? 4000)
63
+ let path = directory + '/bench.db'
64
+ await seeded(path, count, depth)
65
+ try {
66
+ for (let run = 0; run < 3; run++) {
67
+ let times: Record<string, Sample> = {}
68
+ let took = stopwatch()
69
+ let mark = (name: string) => {
70
+ times[name] = took()
71
+ took = stopwatch()
72
+ }
73
+ let h = await harness(path)
74
+ mark('open')
75
+ let a = await local({
76
+ h,
77
+ model: () => Promise.resolve({ id: 'fake', model: 'fake', items: [] }),
78
+ name: 'fake',
79
+ cwd: directory,
80
+ })
81
+ mark('agent')
82
+ await a.sessions()
83
+ mark('sessions')
84
+ await a.transcript('s0')
85
+ mark('transcriptRead')
86
+ await a.close()
87
+ mark('close')
88
+ let r = await remote({ config: at(path), cwd: directory, fake: true })
89
+ mark('remoteReady')
90
+ await r.resume()
91
+ mark('resume')
92
+ await r.agent.sessions()
93
+ mark('remoteSessions')
94
+ await r.agent.transcript('s0')
95
+ mark('remoteTranscript')
96
+ let ui = frontend()
97
+ ui.patch({ selected: 's0' })
98
+ let screen = await mount(
99
+ () =>
100
+ node(App, {
101
+ agent: r.agent,
102
+ subscribe: r.subscribe,
103
+ frontend: ui,
104
+ }),
105
+ 120,
106
+ 32,
107
+ )
108
+ mark('mount')
109
+ let begin = performance.now()
110
+ try {
111
+ while (!screen.text().includes('message')) {
112
+ if (performance.now() - begin > 30000) {
113
+ throw new Error('Initial transcript did not paint')
114
+ }
115
+ await new Promise((resolve) => setTimeout(resolve, 1))
116
+ }
117
+ mark('selectedPaintAfterRead')
118
+ } finally {
119
+ screen.free()
120
+ ui.close()
121
+ }
122
+
123
+ await r.close()
124
+ mark('remoteClose')
125
+ for (let [name, sample] of Object.entries(times)) {
126
+ let collected = (samples[name] ??= []) as Sample[]
127
+ collected.push({
128
+ ...sample,
129
+ source: 'phase',
130
+ counts: { sessions: count, depth },
131
+ })
132
+ }
133
+ }
134
+ } finally {
135
+ await fs.remove(directory, { recursive: true })
136
+ }
137
+ return samples
138
+ }
139
+
140
+ if (import.meta.main) await standaloneMain('harness-startup')
package/status.js ADDED
@@ -0,0 +1,82 @@
1
+ /** Sidebar indicators choose a component to show by how specific its query
2
+ * is. */ import { parse } from "@yaks/query";
3
+ import { define } from "@yaks/render";
4
+ import { render } from "@yaks/react";
5
+ import { loadVocab } from "@yaks/vocab";
6
+ // These are already evaluated read-model properties, not storage declarations.
7
+ // The match host reads the supplied status rather than recomputing a
8
+ // transcript.
9
+ export let statusVocab = loadVocab([
10
+ {
11
+ title: 'sidebar status projection',
12
+ '$defs': {
13
+ task: {
14
+ component: true,
15
+ type: 'object',
16
+ properties: {
17
+ status: {
18
+ type: 'string'
19
+ }
20
+ }
21
+ },
22
+ session: {
23
+ component: true,
24
+ type: 'object',
25
+ properties: {
26
+ status: {
27
+ type: 'string'
28
+ }
29
+ }
30
+ },
31
+ claim: {
32
+ component: true,
33
+ type: 'object',
34
+ properties: {
35
+ session: {
36
+ type: 'string'
37
+ }
38
+ }
39
+ }
40
+ }
41
+ }
42
+ ]);
43
+ let dot = (query, glyph, color, label)=>({
44
+ view: 'Indicator',
45
+ match: parse(query),
46
+ render: (_b, h)=>h('span', {
47
+ class: color,
48
+ title: label,
49
+ 'aria-label': label
50
+ }, glyph)
51
+ });
52
+ export let statusViews = define([
53
+ dot('.task.status=wip&.claim&.session.status=failed', '●', 'Bad', 'Claimed worker crashed'),
54
+ dot('.task.status=wip&.claim&.session.status=settled', '◐', 'Key', 'Claimed worker settled; task unfinished'),
55
+ dot('.task.status=wip&.claim&.session.status=stopped', '◐', 'Muted', 'Claimed worker stopped; task unfinished'),
56
+ dot('.task.status=wip&.claim&.session.status=pending,running', '●', 'Key', 'Active work'),
57
+ dot('.task.status=wip&.claim&.session.status=queued', '◷', 'Muted', 'Worker queued'),
58
+ dot('.task.status=done', '●', 'Good', 'Completed'),
59
+ dot('.task.status=cancelled', '○', 'Muted', 'Cancelled'),
60
+ dot('.task.status=wip', '◐', 'Muted', 'Claimed; worker state unknown'),
61
+ dot('.task.status=open', '○', 'Accent', 'Open'),
62
+ dot('.task', '○', 'Accent', 'Open'),
63
+ dot('.session.status=failed', '●', 'Bad', 'Crashed'),
64
+ dot('.session.status=queued', '◷', 'Muted', 'Queued'),
65
+ dot('.session.status=settled', '●', 'Good', 'Settled'),
66
+ dot('.session.status=pending,running', '●', 'Key', 'Active'),
67
+ dot('.session.status=stopped', '○', 'Muted', 'Stopped'),
68
+ dot('.session', '○', 'Accent', 'Open')
69
+ ]);
70
+ /** Read-only join: the owning session is a rendering projection, never stored. */ export let statusBundle = (bundle, sessions = [])=>{
71
+ if (!bundle.task) return bundle;
72
+ let owner = bundle.claim?.session;
73
+ let session = sessions.find((b)=>b.entity.eid == owner)?.session;
74
+ return {
75
+ ...bundle,
76
+ ...session ? {
77
+ session
78
+ } : {}
79
+ };
80
+ };
81
+ export let indicator = (bundle, sessions)=>render(statusViews, statusBundle(bundle, sessions), 'Indicator', statusVocab);
82
+ //# sourceMappingURL=status.js.map
package/status.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"status.js","sources":["./status.ts"],"names":[],"mappings":"AAAA;OACO,GAEP,SAAS,KAAK,2BAAgC;AAC9C,SAAS,MAAM,4BAAgE;AAC/E,SAAS,MAAM,2BAAgC;AAC/C,SAAS,SAAS,2BAAgC;AAElD,+EAA+E;AAC/E,qEAAqE;AACrE,cAAc;AACd,OAAO,IAAI,cAAc,UAAU;EAAC;IAClC,OAAO;IACP,SAAS;MACP,MAAM;QACJ,WAAW;QACX,MAAM;QACN,YAAY;UAAE,QAAQ;YAAE,MAAM;UAAS;QAAE;MAC3C;MACA,SAAS;QACP,WAAW;QACX,MAAM;QACN,YAAY;UAAE,QAAQ;YAAE,MAAM;UAAS;QAAE;MAC3C;MACA,OAAO;QACL,WAAW;QACX,MAAM;QACN,YAAY;UAAE,SAAS;YAAE,MAAM;UAAS;QAAE;MAC5C;IACF;EACF;CAAE,EAAC;AAEH,IAAI,MAAM,CACR,OACA,OACA,OACA,QACqC,CAAC;IACtC,MAAM;IACN,OAAO,MAAM;IACb,QAAQ,CAAC,IAAI,IACX,EAAE,QAAQ;QAAE,OAAO;QAAO,OAAO;QAAO,cAAc;MAAM,GAAG;EACnE,CAAC;AAED,OAAO,IAAI,cAAc,OAAO;EAC9B,IACE,kDACA,KACA,OACA;EAEF,IACE,mDACA,KACA,OACA;EAEF,IACE,mDACA,KACA,SACA;EAEF,IACE,2DACA,KACA,OACA;EAEF,IACE,kDACA,KACA,SACA;EAEF,IAAI,qBAAqB,KAAK,QAAQ;EACtC,IAAI,0BAA0B,KAAK,SAAS;EAC5C,IAAI,oBAAoB,KAAK,SAAS;EACtC,IAAI,qBAAqB,KAAK,UAAU;EACxC,IAAI,SAAS,KAAK,UAAU;EAC5B,IAAI,0BAA0B,KAAK,OAAO;EAC1C,IAAI,0BAA0B,KAAK,SAAS;EAC5C,IAAI,2BAA2B,KAAK,QAAQ;EAC5C,IAAI,mCAAmC,KAAK,OAAO;EACnD,IAAI,2BAA2B,KAAK,SAAS;EAC7C,IAAI,YAAY,KAAK,UAAU;CAChC,EAAC;AAEF,gFAAgF,GAChF,OAAO,IAAI,eAAe,CAAC,QAAgB,WAAqB,EAAE;EAChE,IAAI,CAAC,OAAO,IAAI,EAAE,OAAO;EACzB,IAAI,QAAS,OAAO,KAAK,EAAuB;EAChD,IAAI,UAAU,SAAS,IAAI,CAAC,CAAC,IAAM,EAAE,MAAM,CAAC,GAAG,IAAI,QAAQ;EAC3D,OAAO;IAAE,GAAG,MAAM;IAAE,GAAI,UAAU;MAAE;IAAQ,IAAI,CAAC,CAAC;EAAE;AACtD,EAAC;AACD,OAAO,IAAI,YAAY,CAAC,QAAgB,WACtC,OAAO,aAAa,aAAa,QAAQ,WAAW,aAAa,aAAY"}
package/status.ts ADDED
@@ -0,0 +1,97 @@
1
+ /** Sidebar indicators choose a component to show by how specific its query
2
+ * is. */
3
+ import type { Bundle, Comp } from 'jsr:@yaks/graph@0.2.36'
4
+ import { parse } from '@yaks/query'
5
+ import { define, type Renderer, type Rendering } from '@yaks/render'
6
+ import { render } from '@yaks/react'
7
+ import { loadVocab } from '@yaks/vocab'
8
+
9
+ // These are already evaluated read-model properties, not storage declarations.
10
+ // The match host reads the supplied status rather than recomputing a
11
+ // transcript.
12
+ export let statusVocab = loadVocab([{
13
+ title: 'sidebar status projection',
14
+ '$defs': {
15
+ task: {
16
+ component: true,
17
+ type: 'object',
18
+ properties: { status: { type: 'string' } },
19
+ },
20
+ session: {
21
+ component: true,
22
+ type: 'object',
23
+ properties: { status: { type: 'string' } },
24
+ },
25
+ claim: {
26
+ component: true,
27
+ type: 'object',
28
+ properties: { session: { type: 'string' } },
29
+ },
30
+ },
31
+ }])
32
+
33
+ let dot = (
34
+ query: string,
35
+ glyph: string,
36
+ color: string,
37
+ label: string,
38
+ ): Renderer & { render: Rendering } => ({
39
+ view: 'Indicator',
40
+ match: parse(query),
41
+ render: (_b, h) =>
42
+ h('span', { class: color, title: label, 'aria-label': label }, glyph),
43
+ })
44
+
45
+ export let statusViews = define([
46
+ dot(
47
+ '.task.status=wip&.claim&.session.status=failed',
48
+ '●',
49
+ 'Bad',
50
+ 'Claimed worker crashed',
51
+ ),
52
+ dot(
53
+ '.task.status=wip&.claim&.session.status=settled',
54
+ '◐',
55
+ 'Key',
56
+ 'Claimed worker settled; task unfinished',
57
+ ),
58
+ dot(
59
+ '.task.status=wip&.claim&.session.status=stopped',
60
+ '◐',
61
+ 'Muted',
62
+ 'Claimed worker stopped; task unfinished',
63
+ ),
64
+ dot(
65
+ '.task.status=wip&.claim&.session.status=pending,running',
66
+ '●',
67
+ 'Key',
68
+ 'Active work',
69
+ ),
70
+ dot(
71
+ '.task.status=wip&.claim&.session.status=queued',
72
+ '◷',
73
+ 'Muted',
74
+ 'Worker queued',
75
+ ),
76
+ dot('.task.status=done', '●', 'Good', 'Completed'),
77
+ dot('.task.status=cancelled', '○', 'Muted', 'Cancelled'),
78
+ dot('.task.status=wip', '◐', 'Muted', 'Claimed; worker state unknown'),
79
+ dot('.task.status=open', '○', 'Accent', 'Open'),
80
+ dot('.task', '○', 'Accent', 'Open'),
81
+ dot('.session.status=failed', '●', 'Bad', 'Crashed'),
82
+ dot('.session.status=queued', '◷', 'Muted', 'Queued'),
83
+ dot('.session.status=settled', '●', 'Good', 'Settled'),
84
+ dot('.session.status=pending,running', '●', 'Key', 'Active'),
85
+ dot('.session.status=stopped', '○', 'Muted', 'Stopped'),
86
+ dot('.session', '○', 'Accent', 'Open'),
87
+ ])
88
+
89
+ /** Read-only join: the owning session is a rendering projection, never stored. */
90
+ export let statusBundle = (bundle: Bundle, sessions: Bundle[] = []): Bundle => {
91
+ if (!bundle.task) return bundle
92
+ let owner = (bundle.claim as Comp | undefined)?.session
93
+ let session = sessions.find((b) => b.entity.eid == owner)?.session
94
+ return { ...bundle, ...(session ? { session } : {}) }
95
+ }
96
+ export let indicator = (bundle: Bundle, sessions?: Bundle[]) =>
97
+ render(statusViews, statusBundle(bundle, sessions), 'Indicator', statusVocab)
@@ -0,0 +1,28 @@
1
+ {
2
+ "version": 1,
3
+ "suite": "harness-steps",
4
+ "metric": "median-of-round-medians/cpu",
5
+ "workload": 1,
6
+ "runtime": "deno/2.9.1 x64-linux",
7
+ "cpu": "Intel(R) Core(TM) i7-8700K CPU @ 3.70GHz",
8
+ "tolerance": 0,
9
+ "benches": [
10
+ {
11
+ "name": "no-tools",
12
+ "unit": "ms",
13
+ "better": "lower",
14
+ "median": 77.95649999999932,
15
+ "reference": "01f3ab27db00022cafadc271e18db1d894c6727e",
16
+ "tolerance": 0.95
17
+ },
18
+ {
19
+ "name": "tool-step",
20
+ "unit": "ms",
21
+ "better": "lower",
22
+ "median": 62.216416666666646,
23
+ "reference": "01f3ab27db00022cafadc271e18db1d894c6727e",
24
+ "tolerance": 0.783
25
+ }
26
+ ],
27
+ "reference": "01f3ab27db00022cafadc271e18db1d894c6727e"
28
+ }