@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/FRONTEND.md ADDED
@@ -0,0 +1,170 @@
1
+ # Frontend graph pilot
2
+
3
+ Each mounted frontend owns a local-only `@yaks/client` over RAM. Most UI
4
+ components declare `sync: none, durable: connection`. Draft recovery records
5
+ declare `sync: none` and use the client vault. No URL or socket is configured.
6
+ Identical local entity IDs in two clients deliberately refer to different
7
+ frontend instances. `App` also accepts an application-owned `frontend` so other
8
+ controls/tests can read and mutate the same state.
9
+
10
+ - `frontend`: selected session, selection generation, show-settled.
11
+ - `composer`: message/task mode.
12
+ - `feedback`: visible error.
13
+ - `draft`: source text and cursor offset.
14
+ - `viewport`: per-transcript item identity/row offset and follow-end.
15
+
16
+ The generation distinguishes selecting _new_ again from the earlier pending
17
+ new-session request. Promises stay outside the graph; they are execution
18
+ machinery, not serializable state. A completed stale request cannot steal the
19
+ newer selection. Errors are graph data.
20
+
21
+ `@yaks/client` query watches use Preact signals. Draft, composer, feedback and
22
+ viewport have separate entity subscriptions, so typing/mode changes do not
23
+ render the application or read the transcript. The editor is selected by a
24
+ `.draft` renderer through `@yaks/render` and `@yaks/preact`. Reusable widgets
25
+ have no graph imports: Textarea takes `value`/`onEdit`, VirtualList takes
26
+ `value`/`onViewportChange`. Their uncontrolled APIs remain available to other
27
+ applications. Local refs coordinate event bursts and cache measurement; the
28
+ harness has no `useState` or refs mirroring selected mode/draft/filter state.
29
+
30
+ The domain graph remains authoritative. Existing asynchronous `UIAgent` methods
31
+ return read-only query projections; the frontend does **not** insert copies of
32
+ session/task/entry entities into its RAM graph. No transient state is inserted
33
+ into the durable harness graph.
34
+
35
+ ## Pilot findings / unfinished larger refactor
36
+
37
+ This is **not** the finished ideal graph frontend yet:
38
+
39
+ 1. Domain updates still use the existing coarse `changes` subscription and
40
+ asynchronous projection batch in App. A domain write may reread the full
41
+ transcript and all panels. Replacing that with per-panel incremental query
42
+ projections requires a shared async projection lifetime API and careful
43
+ handling of fork-inherited transcripts/derived session status. Merely copying
44
+ the results into another graph or renaming setters would hide the problem.
45
+ Typing and scrolling do not enter that path.
46
+ 2. `@yaks/preact`'s entity adapter wants synchronous entity reads; the SQLite
47
+ graph and `UIAgent` facade do not supply the same contract as a RAM client.
48
+ `@yaks/client.watch` already supports async first reads, but doesn't expose
49
+ readiness/error state. A reusable async adapter should make those facts
50
+ explicit before replacing every harness data projection.
51
+ 3. Query identity needs `entity.eid` declared in the frontend vocabulary even
52
+ though bundles always carry identity. This is boilerplate worth revisiting.
53
+ 4. Native renderer context is untyped `unknown` for caller-specific callbacks;
54
+ the editor boundary currently needs casts. Typed context composition would
55
+ improve ergonomics without teaching widgets about the graph.
56
+ 5. Layout publishes the logical viewport after measurement. Caches, renderer
57
+ trees, estimated heights and transient pending movement remain local to the
58
+ generic widget. Repeated unchanged publications are suppressed; huge single
59
+ entries still incur full parse/layout, as before.
60
+ 6. The active editor is an ephemeral projection of a per-session local draft.
61
+ Submission receipts retain unacknowledged text until the backend confirms
62
+ admission. These local records are never sent through domain synchronization.
63
+
64
+ A small shared-package fix accompanies the pilot: closing a client/watch before
65
+ its asynchronous initial read finishes can no longer resurrect that watch. Tests
66
+ cover both lifecycle races.
67
+
68
+ ## Performance contract
69
+
70
+ A deterministic test mounts 10,000 transcript entries, selects the session, then
71
+ types. It asserts fewer than 100 entries were rendered initially and **zero
72
+ additional entry renders or domain queries while typing**. Existing
73
+ virtualization/anchoring/mouse/scrollbar tests remain part of validation.
74
+
75
+ ## VISUAL source selection pilot
76
+
77
+ Selection mode, source snapshot, anchor/cursor and local yank live in a private
78
+ `visual` component. Only its indicator subscribes; generic TUI surface callbacks
79
+ read editor state or one virtual item. Keys update that component and request a
80
+ paint; they do not refresh domain projections. `useVisualController` is the host
81
+ adapter, not a graph dependency in TUI components.
82
+
83
+ This first slice uses a temporary plain **source view**, preserving
84
+ draft/Markdown bytes rather than attempting to reverse-map styled terminal
85
+ cells. It supports one item at a time (`[`/`]` choose neighbors), not cross-item
86
+ ranges. This exposes a remaining boundary between packages: rendered-cell
87
+ selection needs source-span metadata in portable Markdown renderers, plus
88
+ grapheme/display-column mapping. Do not infer source offsets from ANSI or
89
+ eagerly render history to paper over that gap.
90
+
91
+ ### Transcript publication and pending submissions
92
+
93
+ Transcript refreshes publish independently of asynchronous sidebar projections.
94
+ A new graph change schedules a follow-up read without discarding the current
95
+ valid read. Requiring a completely quiet graph before publishing can starve the
96
+ transcript while other sessions continuously produce events. Selection identity
97
+ and generation still reject results for a previously selected session.
98
+
99
+ Submitting a message must admit it to the graph without waiting for an active
100
+ provider request. Entry sequence allocation happens at transaction commit. A
101
+ reply acknowledges only the input boundary recorded on its ask; messages
102
+ admitted later remain pending and are included in the next request, including
103
+ when using a provider continuation anchor. This is authoritative graph state,
104
+ not an optimistic frontend copy. Rendering now also distinguishes ask entries
105
+ carrying `using` metadata from real user content; provider configuration is not
106
+ an author role.
107
+
108
+ The domain subscription remains coarse: all graph changes can trigger transcript
109
+ reads. This change removes the sidebar/quiet-period publication barrier, not the
110
+ need for dependency-aware projections. Worker startup and initial subscription
111
+ transfer latency still apply to the first selection.
112
+
113
+ ### Keyboard modes
114
+
115
+ The `keyboard` entity stores mode, focused region, help visibility, and pending
116
+ `g` in the private frontend graph. The draft view observes mode only to hide its
117
+ cursor outside INSERT; normal input still changes only the draft query.
118
+ `useKeymap` is a graph-free interception layer, and named `useKeys` targets let
119
+ NORMAL commands address the transcript without reordering the editor's focus. A
120
+ regression found during this work demonstrated why target registration and focus
121
+ registration must have separate lifetimes when the selected session changes.
122
+
123
+ NORMAL uses row scrolling (`j/k`) and page scrolling (`h/l`), not a persistent
124
+ rendered-text cursor. `v` selects the anchored item's source, so it retains the
125
+ same source-mapping and cross-item limits as the previous VISUAL implementation.
126
+ Sidebar focus uses sibling/parent/child navigation. Help is mounted only while
127
+ requested with `?`. Modified legacy actions remain aliases, not a second mode.
128
+
129
+ ## Local draft recovery
130
+
131
+ The terminal frontend opens a `@yaks/client` Vault before mounting the UI. Only
132
+ `savedDraft`, `pendingDraft`, and `recovery` enter it; domain replicas, prompt
133
+ context, visual selections, and credentials do not. `sync` and `durable` are
134
+ core vocabulary keywords, so a component that declares neither silently syncs to
135
+ the server and is kept forever.
136
+
137
+ Drafts include source text, cursor, and message/task mode for each session and
138
+ for the unsent new-session composer. The last selected session and local yank
139
+ also recover. Changing sessions selects its own draft. Submission clears the
140
+ editor immediately but retains a pending local record until admission succeeds;
141
+ a failure restores that text ahead of any newer edits. A restart restores
142
+ unacknowledged submissions as editable text, never automatically resends them.
143
+ Admission may already have succeeded remotely, so inspect the transcript before
144
+ resending recovered pending text. Checkpoint files are individually atomic, not
145
+ a transaction spanning every local record; a crash during acknowledgement can
146
+ recover text that was already sent rather than lose it.
147
+
148
+ `Ctrl+U` intentionally clears the draft and retains the yank. `Alt+p` inserts
149
+ the local yank at the current draft cursor, including after restart.
150
+
151
+ Default storage is `~/.yak/drafts/<profile>/`, with private directory/file
152
+ permissions (0700/0600). These are unencrypted JSON files: do not type secrets
153
+ unless that local-at-rest policy is acceptable. `HARNESS_DRAFT_DIR` relocates
154
+ the root. Profile identity combines the configured database path and
155
+ `HARNESS_FRONTEND`, falling back to the tmux pane or terminal device. Set a
156
+ stable `HARNESS_FRONTEND` to recover the same draft after replacing a terminal
157
+ window. Different profiles are isolated; an OS file lock rejects simultaneous
158
+ writers to one profile. Stop that frontend and remove its profile directory to
159
+ erase its recovery data. There is no automatic retention expiry. Programmatic
160
+ `frontend(false)` remains memory-only; `frontend(vault)` accepts browser
161
+ IndexedDB or another standard client vault. Await `ready` before mounting and
162
+ `flush` before closing. Host startup refuses malformed recovery records rather
163
+ than silently deleting drafts.
164
+
165
+ Writes run asynchronously in order, off the keyboard rendering path; shutdown
166
+ waits for them. An abrupt process kill can lose edits not yet written, and
167
+ writes are not fsynced for power-loss durability. Write failures appear in
168
+ feedback and make `flush` reject. The file adapter rewrites only changed local
169
+ entities, not the whole graph, but does not yet debounce repeated edits to a
170
+ very large draft.
package/LICENSE ADDED
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright 2026 Jeff Peterson
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.
@@ -0,0 +1,166 @@
1
+ import { useObserved, useWatch } from "@yaks/ux";
2
+ import { derivedEid } from "@yaks/graph/identity";
3
+ /** Authorization input is private component memory, deliberately outside draft/graph persistence. */ /* @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 { useKeymap } from "@yaks/tui";
6
+ export const MCPAuthPanel = ({ ui, agent })=>{
7
+ // Application mode/progress belongs to the private frontend graph. Sensitive
8
+ // URL/code/state material and async projection results never enter that graph.
9
+ const privateState = useMemo(()=>signal({
10
+ servers: [],
11
+ url: '',
12
+ redirect: '',
13
+ input: '',
14
+ generation: 0
15
+ }), []);
16
+ const state = {
17
+ get value () {
18
+ const keyboard = ui.keyboard.value[0]?.keyboard;
19
+ return {
20
+ ...privateState.value,
21
+ open: Boolean(keyboard?.mcpAuth),
22
+ index: Number(keyboard?.mcpAuthIndex ?? 0),
23
+ busy: Boolean(keyboard?.mcpAuthBusy),
24
+ feedback: String(keyboard?.mcpAuthFeedback ?? '')
25
+ };
26
+ }
27
+ };
28
+ const patch = (value)=>{
29
+ const { open, index, busy, feedback, ...privateFields } = value;
30
+ privateState.value = {
31
+ ...privateState.value,
32
+ ...privateFields
33
+ };
34
+ if (open !== undefined || index !== undefined || busy !== undefined || feedback !== undefined) {
35
+ ui.keys({
36
+ ...open !== undefined ? {
37
+ mcpAuth: open
38
+ } : {},
39
+ ...index !== undefined ? {
40
+ mcpAuthIndex: index
41
+ } : {},
42
+ ...busy !== undefined ? {
43
+ mcpAuthBusy: busy
44
+ } : {},
45
+ ...feedback !== undefined ? {
46
+ mcpAuthFeedback: feedback
47
+ } : {}
48
+ });
49
+ }
50
+ };
51
+ useLayoutEffect(()=>()=>{
52
+ const s = state.value;
53
+ if (s.open && agent.authorizeMCP) {
54
+ void agent.authorizeMCP('cancel', s.servers[s.index]).catch(()=>{});
55
+ }
56
+ privateState.value = {
57
+ servers: [],
58
+ url: '',
59
+ redirect: '',
60
+ input: '',
61
+ generation: privateState.value.generation + 1
62
+ };
63
+ }, []);
64
+ const run = (action, callback = '')=>{
65
+ const current = state.value;
66
+ const generation = current.generation;
67
+ patch({
68
+ busy: true,
69
+ input: '',
70
+ feedback: action === 'begin' ? 'Preparing authorization…' : 'Connecting…'
71
+ });
72
+ void agent.authorizeMCP(action, current.servers[current.index], callback).then((reply)=>{
73
+ if (!state.value.open || state.value.generation !== generation) return;
74
+ patch({
75
+ busy: false,
76
+ ...reply.servers ? {
77
+ servers: reply.servers,
78
+ index: 0
79
+ } : {},
80
+ url: reply.url ?? '',
81
+ redirect: reply.redirectUrl ?? '',
82
+ feedback: reply.message ?? (reply.url ? 'Open the link. After authorizing, copy the entire return URL and paste it here.' : 'Select a server and press Enter.')
83
+ });
84
+ }, (error)=>{
85
+ if (state.value.open && state.value.generation === generation) {
86
+ patch({
87
+ busy: false,
88
+ feedback: error instanceof Error ? error.message : 'Authorization failed. Begin again.'
89
+ });
90
+ }
91
+ });
92
+ };
93
+ useKeymap((key)=>{
94
+ const s = state.value;
95
+ if (!s.open) {
96
+ const mode = ui.client.ent(derivedEid('harness-frontend|keyboard'))?.keyboard?.mode;
97
+ if (mode !== 'NORMAL' || key.text !== 'A' || key.ctrl || key.alt || !agent.authorizeMCP) return false;
98
+ patch({
99
+ open: true,
100
+ generation: s.generation + 1
101
+ });
102
+ run('list');
103
+ return true;
104
+ }
105
+ if (key.ctrl && key.text === 'c') return false;
106
+ if (key.name === 'escape') {
107
+ patch({
108
+ open: false,
109
+ url: '',
110
+ input: '',
111
+ generation: s.generation + 1
112
+ });
113
+ void agent.authorizeMCP('cancel', s.servers[s.index]).catch(()=>{});
114
+ return true;
115
+ }
116
+ if (s.busy) return true;
117
+ if (!s.url) {
118
+ if (key.text === 'j' || key.name === 'down') {
119
+ patch({
120
+ index: Math.min(s.servers.length - 1, s.index + 1)
121
+ });
122
+ }
123
+ if (key.text === 'k' || key.name === 'up') {
124
+ patch({
125
+ index: Math.max(0, s.index - 1)
126
+ });
127
+ }
128
+ if (key.name === 'enter' && s.servers.length) run('begin');
129
+ } else if (key.name === 'enter') {
130
+ if (s.input) run('complete', s.input);
131
+ } else if (key.name === 'backspace') patch({
132
+ input: s.input.slice(0, -1)
133
+ });
134
+ else if ((key.name === 'paste' || key.name === 'char') && key.text && !key.ctrl && !key.alt) {
135
+ if (s.input.length + key.text.length <= 16384) {
136
+ patch({
137
+ input: s.input + key.text.replace(/[\r\n]/g, '')
138
+ });
139
+ } else patch({
140
+ feedback: 'Return URL is too long.'
141
+ });
142
+ }
143
+ return true;
144
+ });
145
+ useWatch(ui.keyboard);
146
+ useObserved(privateState);
147
+ const s = state.value;
148
+ if (!s.open) return null;
149
+ return /*#__PURE__*/ h('div', {
150
+ border: 'Composer_Border',
151
+ col: '1'
152
+ }, /*#__PURE__*/ h('div', {
153
+ className: 'Panel_Title'
154
+ }, 'Authorization · j/k connection · Enter select/submit · Esc cancel'), ...s.servers.map((name, i)=>/*#__PURE__*/ h('div', {
155
+ className: i === s.index ? 'Session_Selected' : ''
156
+ }, name)), !s.servers.length ? /*#__PURE__*/ h('div', null, 'No authorizable connections configured.') : null, s.url ? /*#__PURE__*/ h('div', {
157
+ wrap: '1'
158
+ }, /*#__PURE__*/ h('a', {
159
+ href: s.url
160
+ }, s.url)) : null, s.redirect ? /*#__PURE__*/ h('div', {
161
+ wrap: '1'
162
+ }, 'Return address: ' + s.redirect + ' (a browser connection error here is okay; copy its address bar)') : null, s.url ? /*#__PURE__*/ h('div', null, s.input ? 'Return URL received · Enter to submit' : 'Paste return URL here (hidden)') : null, /*#__PURE__*/ h('div', {
163
+ wrap: '1'
164
+ }, s.feedback));
165
+ };
166
+ //# sourceMappingURL=MCPAuthPanel.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MCPAuthPanel.js","sources":["./MCPAuthPanel.ts"],"names":[],"mappings":"AAAA,SAAS,WAAW,EAAE,QAAQ,wBAA6B;AAC3D,SAAS,UAAU,oCAAyC;AAC5D,mGAAmG,GACnG,uCAAuC,GAAG,SAAS,iBAAiB,CAAC,EAAE,eAAe,EAAE,OAAO,gBAA0B;AACzH,SAAS,MAAM,+BAAyC;AAIxD,SAAS,SAAS,yBAA8B;AAEhD,OAAO,MAAM,eAAe,CAC1B,EAAE,EAAE,EAAE,KAAK,EAAoC;EAE/C,6EAA6E;EAC7E,+EAA+E;EAC/E,MAAM,eAAe,QACnB,IACE,OAAO;MACL,SAAS,EAAE;MACX,KAAK;MACL,UAAU;MACV,OAAO;MACP,YAAY;IACd,IACF,EAAE;EAQJ,MAAM,QAAQ;IACZ,IAAI,SAAe;MACjB,MAAM,WAAW,GAAG,QAAQ,CAAC,KAAK,CAAC,EAAE,EAAE;MACvC,OAAO;QACL,GAAG,aAAa,KAAK;QACrB,MAAM,QAAQ,UAAU;QACxB,OAAO,OAAO,UAAU,gBAAgB;QACxC,MAAM,QAAQ,UAAU;QACxB,UAAU,OAAO,UAAU,mBAAmB;MAChD;IACF;EACF;EACA,MAAM,QAAQ,CAAC;IACb,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,eAAe,GAAG;IAC1D,aAAa,KAAK,GAAG;MAAE,GAAG,aAAa,KAAK;MAAE,GAAG,aAAa;IAAC;IAC/D,IACE,SAAS,aAAa,UAAU,aAAa,SAAS,aACtD,aAAa,WACb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