@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
@@ -0,0 +1,180 @@
1
+ import { useObserved, useWatch } from "@yaks/ux";
2
+ import { derivedEid } from "@yaks/graph/identity";
3
+ /** Optional runtime view. Application selection and feedback remain graph state. */ /* @ts-types="npm:@types/react@19.3.0" */ import { createElement as h, useLayoutEffect, useMemo } from "react";
4
+ import { signal } from "@preact/signals-core";
5
+ import { define } from "@yaks/render";
6
+ import { parse } from "@yaks/query";
7
+ import { render } from "@yaks/react";
8
+ import { loadVocab, pick } from "@yaks/vocab";
9
+ import { sessionDoc } from "@yaks/session/vocab";
10
+ import { kernelDoc } from "@yaks/kernel/vocab";
11
+ import { dispatchStatus } from "@yaks/session/admission";
12
+ import { toolsDoc } from "@yaks/tools/vocab";
13
+ import doc from './runtime/vocab.json' with {
14
+ type: 'json'
15
+ };
16
+ import { Scroll, useKeymap } from "@yaks/tui";
17
+ import { sessionLine } from "./panels.js";
18
+ export let runtimeVocab = loadVocab([
19
+ doc,
20
+ pick(toolsDoc, [
21
+ 'refusal'
22
+ ]),
23
+ pick(sessionDoc, [
24
+ 'dispatch'
25
+ ]),
26
+ pick(kernelDoc, [
27
+ 'admitted',
28
+ 'waiting',
29
+ 'interrupted',
30
+ 'failed'
31
+ ])
32
+ ]);
33
+ let label = (match, text, color)=>({
34
+ view: 'Runtime',
35
+ match: parse(match),
36
+ render: (_b, host)=>host('span', {
37
+ class: color
38
+ }, text)
39
+ });
40
+ export let runtimeViews = define([
41
+ label('.session&.dispatch.status=queued', 'queued', 'Key'),
42
+ label('.session&.attempt.by&!interrupted&.dispatch.status!=queued', 'generating', 'Key'),
43
+ label('.session&.interrupted', 'interrupted', 'Muted'),
44
+ label('.session.status=running&.call', 'waiting for tool', 'Key'),
45
+ label('.session.status=running', 'running', 'Key'),
46
+ label('.session.status=pending', 'pending', 'Key'),
47
+ label('.session.status=failed', 'failed', 'Bad'),
48
+ label('.session.status=stopped', 'stopped', 'Muted'),
49
+ label('.session', 'idle', 'Good')
50
+ ]);
51
+ // The matcher gives ladder marks priority over a carried status. Project the
52
+ // authoritative legacy value into that ladder too, without changing the row.
53
+ export let runtimeRow = (b)=>{
54
+ if (!b.dispatch) return b;
55
+ let status = dispatchStatus(b);
56
+ return {
57
+ ...b,
58
+ dispatch: {
59
+ ...b.dispatch,
60
+ status
61
+ },
62
+ admitted: status == 'active' ? {} : null,
63
+ waiting: status == 'waiting' ? {} : null
64
+ };
65
+ };
66
+ export let elapsed = (start, now)=>{
67
+ let at = typeof start == 'string' ? Date.parse(start) : NaN;
68
+ if (!Number.isFinite(at)) return '';
69
+ let seconds = Math.max(0, Math.floor((now - at) / 1000));
70
+ return seconds < 60 ? seconds + 's' : Math.floor(seconds / 60) + 'm ' + seconds % 60 + 's';
71
+ };
72
+ export let RuntimePanel = ({ ui, agent, session, subscribe })=>{
73
+ let state = useWatch(ui.keyboard)[0].keyboard;
74
+ let open = Boolean(state.runtime);
75
+ // Async read result is a projection; timer is presentation, neither is domain state.
76
+ let rows = useMemo(()=>signal([]), []);
77
+ let now = useMemo(()=>signal(Date.now()), []);
78
+ useLayoutEffect(()=>{
79
+ if (!open || !session || !agent.runtime) return;
80
+ let alive = true, busy = false, dirty = false;
81
+ rows.value = [];
82
+ let load = async ()=>{
83
+ if (busy) {
84
+ dirty = true;
85
+ return;
86
+ }
87
+ busy = true;
88
+ try {
89
+ let value = await agent.runtime(session);
90
+ if (alive) rows.value = value;
91
+ } catch (e) {
92
+ if (alive) ui.keys({
93
+ runtimeFeedback: String(e)
94
+ });
95
+ } finally{
96
+ busy = false;
97
+ // Domain notifications are coalesced by the presentation clock.
98
+ // Streaming deltas must not issue one projection query per token.
99
+ }
100
+ };
101
+ void load();
102
+ let off = subscribe(()=>{
103
+ dirty = true;
104
+ });
105
+ let timer = setInterval(()=>{
106
+ now.value = Date.now();
107
+ if (dirty && !busy) {
108
+ dirty = false;
109
+ void load();
110
+ }
111
+ }, 1000);
112
+ return ()=>{
113
+ alive = false;
114
+ off();
115
+ clearInterval(timer);
116
+ };
117
+ }, [
118
+ open,
119
+ session,
120
+ agent,
121
+ subscribe,
122
+ ui
123
+ ]);
124
+ useKeymap((key)=>{
125
+ let current = ui.client.ent(derivedEid('harness-frontend|keyboard')).keyboard;
126
+ if (!current.runtime || current.mode != 'NORMAL') return false;
127
+ if (key.ctrl && key.text == 'c') return false;
128
+ if (key.name == 'escape' || key.text == 'r') {
129
+ ui.keys({
130
+ runtime: false
131
+ });
132
+ return true;
133
+ }
134
+ let text = key.text;
135
+ let list = rows.value;
136
+ let index = Math.max(0, list.findIndex((b)=>b.entity.eid == current.runtimeSelected));
137
+ let selected = list[index];
138
+ if (text == 'j' || text == 'k') {
139
+ let next = list[Math.max(0, Math.min(list.length - 1, index + (text == 'j' ? 1 : -1)))];
140
+ if (next) ui.keys({
141
+ runtimeSelected: next.entity.eid
142
+ });
143
+ } else if ((text == 'x' || text == 'c') && selected && agent.control) {
144
+ let action = text == 'c' ? 'resume' : dispatchStatus(selected) == 'queued' ? 'cancel-queued' : 'interrupt';
145
+ ui.keys({
146
+ runtimeFeedback: 'Requesting ' + action + '…'
147
+ });
148
+ void agent.control(selected.entity.eid, action).then((message)=>ui.keys({
149
+ runtimeFeedback: message
150
+ }), (error)=>ui.keys({
151
+ runtimeFeedback: String(error)
152
+ }));
153
+ }
154
+ return true;
155
+ });
156
+ let readings = useObserved(rows);
157
+ let currentTime = useObserved(now);
158
+ if (!open) return null;
159
+ let index = Math.max(0, readings.findIndex((b)=>b.entity.eid == state.runtimeSelected));
160
+ return /*#__PURE__*/ h('div', {
161
+ border: 'Composer_Border',
162
+ height: '10',
163
+ col: '1'
164
+ }, /*#__PURE__*/ h('div', {
165
+ className: 'Panel_Title'
166
+ }, 'Runtime · j/k select · x interrupt/cancel queued · c continue · r close'), /*#__PURE__*/ h(Scroll, {
167
+ id: 'runtime',
168
+ grow: '1',
169
+ keyboard: false,
170
+ reveal: index
171
+ }, ...readings.map((b, i)=>/*#__PURE__*/ h('div', {
172
+ key: b.entity.eid,
173
+ fill: '1',
174
+ className: i == index ? 'Session_Selected' : ''
175
+ }, render(runtimeViews, runtimeRow(b), 'Runtime', runtimeVocab), ' ', elapsed(b.updated?.at ?? b.created?.at, currentTime), ' · ', sessionLine(b)))), !session ? /*#__PURE__*/ h('div', null, 'Select a session first.') : null, /*#__PURE__*/ h('div', {
176
+ wrap: '1',
177
+ className: 'Muted'
178
+ }, String(state.runtimeFeedback ?? 'Actions affect only the selected session, never independent processes or task completion.')));
179
+ };
180
+ //# sourceMappingURL=RuntimePanel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RuntimePanel.js","sources":["./RuntimePanel.ts"],"names":[],"mappings":"AAAA,SAAS,WAAW,EAAE,QAAQ,wBAA6B;AAC3D,SAAS,UAAU,oCAAyC;AAC5D,kFAAkF,GAClF,uCAAuC,GAAG,SAAS,iBAAiB,CAAC,EAAE,eAAe,EAAE,OAAO,gBAA0B;AACzH,SAAS,MAAM,+BAAyC;AAExD,SAAS,MAAM,4BAAgE;AAC/E,SAAS,KAAK,2BAAgC;AAC9C,SAAS,MAAM,2BAAgC;AAC/C,SAAS,SAAS,EAAE,IAAI,2BAAgC;AACxD,SAAS,UAAU,mCAAwC;AAC3D,SAAS,SAAS,kCAAuC;AACzD,SAAS,cAAc,uCAA4C;AACnE,SAAS,QAAQ,iCAAsC;AACvD,OAAO,SAAS,4BAA4B;EAAE,MAAM;AAAO,EAAC;AAC5D,SAAS,MAAM,EAAE,SAAS,yBAA8B;AAI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IAAI,MAAM,eAAe;EAEjE,qBAAO,EACL,OACA;IAAE,QAAQ;IAAmB,QAAQ;IAAM,KAAK;EAAI,iBACpD,EACE,OACA;IAAE,WAAW;EAAc,GAC3B,0FAEF,EACE,QACA;IAAE,IAAI;IAAW,MAAM;IAAK,UAAU;IAAO,QAAQ;EAAM,MACxD,SAAS,GAAG,CAAC,CAAC,GAAG,kBAClB,EACE,OACA;MACE,KAAK,EAAE,MAAM,CAAC,GAAG;MACjB,MAAM;MACN,WAAW,KAAK,QAAQ,qBAAqB;IAC/C,GACA,OAAO,cAAc,WAAW,IAAI,WAAW,eAC/C,KACA,QACE,AAAC,EAAE,OAAO,EAAuB,MAC9B,EAAE,OAAO,EAAuB,IACnC,cAEF,OACA,YAAY,OAIlB,CAAC,wBAAU,EAAE,OAAO,MAAM,6BAA6B,oBACvD,EACE,OACA;IAAE,MAAM;IAAK,WAAW;EAAQ,GAChC,OACE,MAAM,eAAe,IACnB;AAIV,EAAC"}
@@ -0,0 +1,205 @@
1
+ import { useObserved, useWatch } from '@yaks/ux'
2
+ import { derivedEid } from '@yaks/graph/identity'
3
+ /** Optional runtime view. Application selection and feedback remain graph state. */
4
+ /* @ts-types="npm:@types/react@19.3.0" */ import { createElement as h, useLayoutEffect, useMemo } from 'react'
5
+ import { signal } from '@preact/signals-core'
6
+ import { type Bundle, type Comp } from '@yaks/graph'
7
+ import { define, type Renderer, type Rendering } from '@yaks/render'
8
+ import { parse } from '@yaks/query'
9
+ import { render } from '@yaks/react'
10
+ import { loadVocab, pick } from '@yaks/vocab'
11
+ import { sessionDoc } from '@yaks/session/vocab'
12
+ import { kernelDoc } from '@yaks/kernel/vocab'
13
+ import { dispatchStatus } from '@yaks/session/admission'
14
+ import { toolsDoc } from '@yaks/tools/vocab'
15
+ import doc from './runtime/vocab.json' with { type: 'json' }
16
+ import { Scroll, useKeymap } from '@yaks/tui'
17
+ import type { RuntimeAction } from './runtime.ts'
18
+ import type { Frontend } from './frontend.ts'
19
+ import type { UIAgent } from './panels.js'
20
+ import { sessionLine } from './panels.js'
21
+
22
+ export let runtimeVocab = loadVocab([
23
+ doc,
24
+ pick(toolsDoc, ['refusal']),
25
+ pick(sessionDoc, ['dispatch']),
26
+ pick(kernelDoc, ['admitted', 'waiting', 'interrupted', 'failed']),
27
+ ])
28
+ let label = (
29
+ match: string,
30
+ text: string,
31
+ color: string,
32
+ ): Renderer & { render: Rendering } => ({
33
+ view: 'Runtime',
34
+ match: parse(match),
35
+ render: (_b, host) => host('span', { class: color }, text),
36
+ })
37
+ export let runtimeViews = define([
38
+ label('.session&.dispatch.status=queued', 'queued', 'Key'),
39
+ label(
40
+ '.session&.attempt.by&!interrupted&.dispatch.status!=queued',
41
+ 'generating',
42
+ 'Key',
43
+ ),
44
+ label('.session&.interrupted', 'interrupted', 'Muted'),
45
+ label('.session.status=running&.call', 'waiting for tool', 'Key'),
46
+ label('.session.status=running', 'running', 'Key'),
47
+ label('.session.status=pending', 'pending', 'Key'),
48
+ label('.session.status=failed', 'failed', 'Bad'),
49
+ label('.session.status=stopped', 'stopped', 'Muted'),
50
+ label('.session', 'idle', 'Good'),
51
+ ])
52
+ // The matcher gives ladder marks priority over a carried status. Project the
53
+ // authoritative legacy value into that ladder too, without changing the row.
54
+ export let runtimeRow = (b: Bundle): Bundle => {
55
+ if (!b.dispatch) return b
56
+ let status = dispatchStatus(b)
57
+ return {
58
+ ...b,
59
+ dispatch: { ...(b.dispatch as Comp), status },
60
+ admitted: status == 'active' ? {} : null,
61
+ waiting: status == 'waiting' ? {} : null,
62
+ }
63
+ }
64
+ export let elapsed = (start: unknown, now: number): string => {
65
+ let at = typeof start == 'string' ? Date.parse(start) : NaN
66
+ if (!Number.isFinite(at)) return ''
67
+ let seconds = Math.max(0, Math.floor((now - at) / 1000))
68
+ return seconds < 60
69
+ ? seconds + 's'
70
+ : Math.floor(seconds / 60) + 'm ' + seconds % 60 + 's'
71
+ }
72
+
73
+ export let RuntimePanel = ({ ui, agent, session, subscribe }: {
74
+ ui: Frontend
75
+ agent: UIAgent
76
+ session?: string
77
+ subscribe: (fn: () => void) => () => void
78
+ }) => {
79
+ let state = useWatch(ui.keyboard)[0].keyboard as Comp
80
+ let open = Boolean(state.runtime)
81
+ // Async read result is a projection; timer is presentation, neither is domain state.
82
+ let rows = useMemo(() => signal<Bundle[]>([]), [])
83
+ let now = useMemo(() => signal(Date.now()), [])
84
+ useLayoutEffect(() => {
85
+ if (!open || !session || !agent.runtime) return
86
+ let alive = true, busy = false, dirty = false
87
+ rows.value = []
88
+ let load = async () => {
89
+ if (busy) {
90
+ dirty = true
91
+ return
92
+ }
93
+ busy = true
94
+ try {
95
+ let value = await agent.runtime!(session)
96
+ if (alive) rows.value = value
97
+ } catch (e) {
98
+ if (alive) ui.keys({ runtimeFeedback: String(e) })
99
+ } finally {
100
+ busy = false
101
+ // Domain notifications are coalesced by the presentation clock.
102
+ // Streaming deltas must not issue one projection query per token.
103
+ }
104
+ }
105
+ void load()
106
+ let off = subscribe(() => {
107
+ dirty = true
108
+ })
109
+ let timer = setInterval(() => {
110
+ now.value = Date.now()
111
+ if (dirty && !busy) {
112
+ dirty = false
113
+ void load()
114
+ }
115
+ }, 1000)
116
+ return () => {
117
+ alive = false
118
+ off()
119
+ clearInterval(timer)
120
+ }
121
+ }, [open, session, agent, subscribe, ui])
122
+ useKeymap((key) => {
123
+ let current = ui.client.ent(derivedEid('harness-frontend|keyboard'))!
124
+ .keyboard as Comp
125
+ if (!current.runtime || current.mode != 'NORMAL') return false
126
+ if (key.ctrl && key.text == 'c') return false
127
+ if (key.name == 'escape' || key.text == 'r') {
128
+ ui.keys({ runtime: false })
129
+ return true
130
+ }
131
+ let text = key.text
132
+ let list = rows.value
133
+ let index = Math.max(
134
+ 0,
135
+ list.findIndex((b) => b.entity.eid == current.runtimeSelected),
136
+ )
137
+ let selected = list[index]
138
+ if (text == 'j' || text == 'k') {
139
+ let next = list[
140
+ Math.max(0, Math.min(list.length - 1, index + (text == 'j' ? 1 : -1)))
141
+ ]
142
+ if (next) ui.keys({ runtimeSelected: next.entity.eid })
143
+ } else if ((text == 'x' || text == 'c') && selected && agent.control) {
144
+ let action: RuntimeAction = text == 'c'
145
+ ? 'resume'
146
+ : dispatchStatus(selected) == 'queued'
147
+ ? 'cancel-queued'
148
+ : 'interrupt'
149
+ ui.keys({ runtimeFeedback: 'Requesting ' + action + '…' })
150
+ void agent.control(selected.entity.eid, action).then(
151
+ (message) => ui.keys({ runtimeFeedback: message }),
152
+ (error) => ui.keys({ runtimeFeedback: String(error) }),
153
+ )
154
+ }
155
+ return true
156
+ })
157
+ let readings = useObserved(rows)
158
+ let currentTime = useObserved(now)
159
+ if (!open) return null
160
+ let index = Math.max(
161
+ 0,
162
+ readings.findIndex((b) => b.entity.eid == state.runtimeSelected),
163
+ )
164
+ return h(
165
+ 'div',
166
+ { border: 'Composer_Border', height: '10', col: '1' },
167
+ h(
168
+ 'div',
169
+ { className: 'Panel_Title' },
170
+ 'Runtime · j/k select · x interrupt/cancel queued · c continue · r close',
171
+ ),
172
+ h(
173
+ Scroll,
174
+ { id: 'runtime', grow: '1', keyboard: false, reveal: index },
175
+ ...readings.map((b, i) =>
176
+ h(
177
+ 'div',
178
+ {
179
+ key: b.entity.eid,
180
+ fill: '1',
181
+ className: i == index ? 'Session_Selected' : '',
182
+ },
183
+ render(runtimeViews, runtimeRow(b), 'Runtime', runtimeVocab),
184
+ ' ',
185
+ elapsed(
186
+ (b.updated as Comp | undefined)?.at ??
187
+ (b.created as Comp | undefined)?.at,
188
+ currentTime,
189
+ ),
190
+ ' · ',
191
+ sessionLine(b),
192
+ )
193
+ ),
194
+ ),
195
+ !session ? h('div', null, 'Select a session first.') : null,
196
+ h(
197
+ 'div',
198
+ { wrap: '1', className: 'Muted' },
199
+ String(
200
+ state.runtimeFeedback ??
201
+ 'Actions affect only the selected session, never independent processes or task completion.',
202
+ ),
203
+ ),
204
+ )
205
+ }
package/STREAMING.md ADDED
@@ -0,0 +1,101 @@
1
+ # Streamed responses
2
+
3
+ Response streaming is enabled by default in both `agent` and the worker-backed
4
+ `remote` frontend. Disable it with `HARNESS_STREAM=0 yak session new …`, or pass
5
+ `streaming: false` (also accepted as `stream: false`) to `agent` / `remote`.
6
+ Explicit programmatic configuration overrides the environment; `streaming` wins
7
+ if both option names are supplied. `HARNESS_STREAM=1` remains supported.
8
+
9
+ Models that return only a final reply still work; they simply have no partial
10
+ text to display. Disabling streaming uses the older completed-response path: the
11
+ ask is recorded after the model returns, and existing non-streaming retry
12
+ behavior applies. Streaming attempts retain the interruption rules below.
13
+ Terminal graphics are configured separately and are not enabled by this change.
14
+
15
+ The worker receives each OpenAI public output-text delta, assigns the provider's
16
+ item ID to one response entry, and publishes ordered graph text projections.
17
+ Tool argument fragments and private reasoning are not published or executed.
18
+ Image payloads still go through artifact storage, not text projections. Final
19
+ output, calls, artifacts, and usage are committed when the reply completes.
20
+
21
+ Provider deltas are not necessarily individual tokens. Transient notifications
22
+ are microtask-batched by subscriptions, and terminal paints use the existing
23
+ renderer scheduling. The callback backlog is bounded at 4,096 deltas; overflow
24
+ fails the attempt instead of silently dropping text. The transport retries
25
+ transient failures until the first public text delta. An already-exposed partial
26
+ response is never replayed.
27
+
28
+ ## Ask lifecycle and failures
29
+
30
+ The ask is persisted **before calling the model**, with
31
+ `attempt.state=inflight`, its original `ask.through` boundary, and resolved
32
+ request configuration. Local context-image loading finishes first. A dispatch
33
+ crash after admission but before network send is indistinguishable from a crash
34
+ after send; either is treated as interrupted on restart. The resumed session
35
+ asks the model to continue from its saved transcript and inspect state before
36
+ repeating an action that may have completed.
37
+
38
+ Each text item starts with a durable identity and empty body. The body is live
39
+ until a checkpoint or finalization. A checkpoint stores what streamed within 250
40
+ ms of it arriving (`agent({checkpointMs})`), though the provider fall silent;
41
+ zero stores it only at the end. Checkpoints write complete current text through
42
+ existing blob storage; appends do not create blob versions. A host is told each
43
+ piece (`agent({typed})`) only once a checkpoint has stored it, so what a page
44
+ shows of a reply is what a crash or a deploy's reset leaves.
45
+
46
+ Success patches the original ask to `completed` and updates the same response
47
+ entries; it does not append duplicate final messages. Operational interruption
48
+ (abort or transport/provider error) preserves received/checkpointed text and
49
+ marks the attempt `interrupted`. Its `interrupted{code}` mark records that
50
+ outcome; a newer input can continue it. A worker restart instead adds a local
51
+ recovery instruction and continues the session on its own. It preserves partial
52
+ output and marks the prior attempt `interrupted`; repeated restarts do not
53
+ append additional records for that attempt.
54
+
55
+ Continuation uses the last completed response, never an interrupted attempt's
56
+ provider ID. Intervening user inputs and partial assistant text are included as
57
+ conversation history. Partial tool arguments are not admitted as executable
58
+ calls. This is not a guarantee of exactly-once execution for provider-native
59
+ side effects: an interrupted image or other native operation may have executed
60
+ remotely, so the resumed model is instructed to inspect before repeating it.
61
+
62
+ Unexpected adapter/programming exceptions and checkpoint/finalization failures
63
+ remain defects with exception records. Recognized operational errors bypass the
64
+ defect journal. This does not change nonstreaming request retry policy.
65
+
66
+ New messages arriving during a request remain outside its frozen boundary and
67
+ are served by a subsequent ask. Session status stays running while the request
68
+ is active. Tool calls execute only after final arguments are admitted. Forks
69
+ whose inherited prefix would include an in-flight attempt are rejected rather
70
+ than sharing a mutable response tail. Normal tool-created forks inherit the
71
+ completed request's original prefix, as before.
72
+
73
+ Shutdown lets the step in flight finish. A forced worker termination leaves the
74
+ ask in flight and the transcript's lease held until its take runs out; the next
75
+ run marks it interrupted and asks the model to continue from saved history. Old
76
+ inline readers must not be running against a streaming database.
77
+
78
+ ## Measurements and limitations
79
+
80
+ `deno run -A packages/harness/streaming_bench.ts` compares a RAM graph with an
81
+ API subscription receiving 2,000 ten-character deltas. One development-host run:
82
+
83
+ | Implementation | Durable writes | Serialized characters | Time |
84
+ | ----------------------------------- | -------------: | --------------------: | -----: |
85
+ | Growing-string write for each delta | 2,000 | 20,172,071 | 248 ms |
86
+ | Transient appends and final commit | 1 | 239,300 | 29 ms |
87
+
88
+ This is a protocol/storage-work comparison, **not** a terminal input-latency or
89
+ live-provider benchmark. The worker integration test verifies that the frontend
90
+ can read partial text before model completion. Existing Markdown rendering still
91
+ parses the visible item's growing text, and the harness still uses coarse
92
+ refresh notifications. Thus large visible outputs can incur repeated
93
+ layout/parse cost; this pilot does not promise constant-time rendering per
94
+ delta. Initial snapshots and checkpoints transfer complete strings. There is no
95
+ transport backpressure acknowledgment yet, only a bounded session ingestion
96
+ backlog.
97
+
98
+ The generic projection API and its deliberately durable query-membership rules
99
+ are documented in [TRANSIENT.md](../graph/TRANSIENT.md). Full transient
100
+ predicate indexes, generalized patch overlays, distributed writers, automatic
101
+ retry of ambiguous asks, and retained streaming replay logs are not implemented.
package/WINDOWS.md ADDED
@@ -0,0 +1,78 @@
1
+ # Bounded transcript loading
2
+
3
+ The transcript UI loads a page around the bottom or its saved entry anchor,
4
+ rather than subscribing to every entry in the selected session. The default page
5
+ contains at most 64 entry bodies. Navigating near an edge requests an
6
+ overlapping page. Start/end navigation requests the corresponding real edge. The
7
+ full `Agent.transcript()` API and model request history are unchanged.
8
+
9
+ ## Data flow
10
+
11
+ - `@yaks/session.transcriptPlan` walks fork ancestry and reads entry-position
12
+ projections. It returns ordinary sequence-range queries with entry limits.
13
+ - The worker opens those queries through the existing `@yaks/api` subscription
14
+ registry. Existing sync frames and transient text updates populate the
15
+ frontend's `@yaks/client` working set.
16
+ - A separate metadata-only newest-entry query per ancestor observes append
17
+ boundaries. New offscreen content is not replicated just to detect an append.
18
+ - The client owns loaded coverage and retains at most 256 inactive rows. Active
19
+ session/task subscriptions are outside that inactive budget. Moving away from
20
+ a page releases its subscription instead of marking its rows deleted.
21
+ - Viewport anchor, follow state, and pending range requests live in the private
22
+ frontend graph. The generic `VirtualList` only requests ranges and renders
23
+ supplied items. Loading a page cannot replace an anchor with a temporary empty
24
+ collection.
25
+ - The Context usage panel reads the latest fork-aware usage fields separately;
26
+ it no longer loads the entire transcript to find one ask.
27
+
28
+ No search/detail UI is introduced by this change. The entry-ID window API can
29
+ support a future reveal action without requiring every transcript ID locally.
30
+
31
+ ## Measured comparison
32
+
33
+ Run `deno task bench harness-window` to compare full-transcript and windowed
34
+ calls over a private SQLite fixture with 10,000 entries and 1,000-character
35
+ bodies. Each collection takes one first read and one warm read in each mode:
36
+ `full/first`, `full/warm`, `window/first` and `window/warm`. Paired rounds
37
+ provide repeated CPU observations. Fixture creation, worker opening and cleanup
38
+ have separate CPU diagnostics outside the transfer samples. No live database or
39
+ provider is used.
40
+
41
+ The table describes a separate 2,000-entry observation: three runs measuring
42
+ wall time on a shared host, not production guarantees or complete
43
+ launch-to-paint timings.
44
+
45
+ | Measurement | Full transcript | 64-entry window |
46
+ | ---------------------------- | --------------- | --------------- |
47
+ | Delivered entries | 2,000 | 64 |
48
+ | Serialized result characters | 2,409,570 | 77,113 |
49
+ | First read | 238–526 ms | 24–39 ms |
50
+ | Repeated read | 2–5 ms | 5–7 ms |
51
+ | Maximum 2 ms timer delay | 165–372 ms | 4–13 ms |
52
+
53
+ Serialized result size excludes frame envelopes, metadata frontier frames, and
54
+ initial session/task summaries. An additional SQLite regression seeds 10,000
55
+ 100,000-character bodies and reads only eight bodies. Its large source is
56
+ content-deduplicated by the blob store. The fixture does not imply a byte cap on
57
+ an individual page.
58
+
59
+ ## Remaining limits
60
+
61
+ - A page is bounded by entry count, not byte size. One enormous entry still
62
+ transfers and lays out its full text. Large-entry source slicing is separate
63
+ work.
64
+ - Ancestor discovery and edge planning scale with fork depth. Initial root
65
+ session/task summaries still load globally, and broad summary invalidation
66
+ remains independent work.
67
+ - The scrollbar estimates unknown ranges as additional pages; it does not show
68
+ an exact percentage of the complete transcript.
69
+ - Inactive retention is row-count bounded, not byte-count bounded. A retained
70
+ page can contain large entries. The renderer independently bounds its trees
71
+ and measured-line cache.
72
+ - Moving to a new page currently replaces its subscriptions. Cached rows avoid
73
+ unbounded memory retention but do not eliminate server revalidation/transfer.
74
+ - Concurrent edits to loaded entries are subscribed. Appended membership is
75
+ observed through frontier queries. Arbitrary historical deletion outside the
76
+ loaded page is learned when the affected range is next requested.
77
+ - The backend still assembles the complete required conversation for a model
78
+ request. This change limits UI reads, not model context.