@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.
- package/FRONTEND.md +170 -0
- package/LICENSE +202 -0
- package/MCPAuthPanel.js +166 -0
- package/MCPAuthPanel.js.map +1 -0
- package/MCPAuthPanel.ts +184 -0
- package/ModelPanel.js +124 -0
- package/ModelPanel.js.map +1 -0
- package/ModelPanel.ts +143 -0
- package/PersonaPanel.js +106 -0
- package/PersonaPanel.js.map +1 -0
- package/PersonaPanel.ts +110 -0
- package/README.md +1570 -2
- package/RuntimePanel.js +180 -0
- package/RuntimePanel.js.map +1 -0
- package/RuntimePanel.ts +205 -0
- package/STREAMING.md +101 -0
- package/WINDOWS.md +78 -0
- package/WORKER.md +221 -0
- package/_dist/agent.d.ts +197 -0
- package/_dist/agent.d.ts.map +1 -0
- package/_dist/cli.d.ts +10 -0
- package/_dist/cli.d.ts.map +1 -0
- package/_dist/conversations.d.ts +45 -0
- package/_dist/conversations.d.ts.map +1 -0
- package/_dist/default.d.ts +32 -0
- package/_dist/default.d.ts.map +1 -0
- package/_dist/detail.d.ts +16 -0
- package/_dist/detail.d.ts.map +1 -0
- package/_dist/diagnostics.d.ts +5 -0
- package/_dist/diagnostics.d.ts.map +1 -0
- package/_dist/effects.d.ts +35 -0
- package/_dist/effects.d.ts.map +1 -0
- package/_dist/http.d.ts +12 -0
- package/_dist/http.d.ts.map +1 -0
- package/_dist/isolated.d.ts +6 -0
- package/_dist/isolated.d.ts.map +1 -0
- package/_dist/local.d.ts +74 -0
- package/_dist/local.d.ts.map +1 -0
- package/_dist/machine.d.ts +3 -0
- package/_dist/machine.d.ts.map +1 -0
- package/_dist/mcp_auth.d.ts +8 -0
- package/_dist/mcp_auth.d.ts.map +1 -0
- package/_dist/mod.d.ts +43 -0
- package/_dist/mod.d.ts.map +1 -0
- package/_dist/model_selection.d.ts +8 -0
- package/_dist/model_selection.d.ts.map +1 -0
- package/_dist/routes.d.ts +11 -0
- package/_dist/routes.d.ts.map +1 -0
- package/_dist/runs.d.ts +7 -0
- package/_dist/runs.d.ts.map +1 -0
- package/_dist/runtime.d.ts +2 -0
- package/_dist/runtime.d.ts.map +1 -0
- package/_dist/session_machines.d.ts +18 -0
- package/_dist/session_machines.d.ts.map +1 -0
- package/_dist/skills.d.ts +11 -0
- package/_dist/skills.d.ts.map +1 -0
- package/_dist/store.d.ts +38 -0
- package/_dist/store.d.ts.map +1 -0
- package/_dist/tools.d.ts +28 -0
- package/_dist/tools.d.ts.map +1 -0
- package/_dist/view.d.ts +5 -0
- package/_dist/view.d.ts.map +1 -0
- package/_dist/vocab.d.ts +7 -0
- package/_dist/vocab.d.ts.map +1 -0
- package/_dist/worn.d.ts +52 -0
- package/_dist/worn.d.ts.map +1 -0
- package/agent.js +773 -0
- package/agent.js.map +1 -0
- package/agent.ts +959 -0
- package/app.js +811 -0
- package/app.js.map +1 -0
- package/app.ts +868 -0
- package/artifact_tools.js +186 -0
- package/artifact_tools.js.map +1 -0
- package/artifact_tools.ts +190 -0
- package/backend_worker.ts +286 -0
- package/cli.js +43 -0
- package/cli.js.map +1 -0
- package/cli.ts +48 -0
- package/conversations.js +526 -0
- package/conversations.js.map +1 -0
- package/conversations.ts +576 -0
- package/conversations_testing.ts +162 -0
- package/default.js +162 -0
- package/default.js.map +1 -0
- package/default.ts +168 -0
- package/deferred_model.ts +1 -0
- package/deno.json +1 -0
- package/detail.js +50 -0
- package/detail.js.map +1 -0
- package/detail.ts +75 -0
- package/diagnostics.js +132 -0
- package/diagnostics.js.map +1 -0
- package/diagnostics.ts +150 -0
- package/draft_vault.js +149 -0
- package/draft_vault.js.map +1 -0
- package/draft_vault.ts +176 -0
- package/effects.js +233 -0
- package/effects.js.map +1 -0
- package/effects.ts +250 -0
- package/frontend/vocab.json +376 -0
- package/frontend.js +511 -0
- package/frontend.js.map +1 -0
- package/frontend.ts +389 -0
- package/http.js +107 -0
- package/http.js.map +1 -0
- package/http.ts +105 -0
- package/input_text.js +91 -0
- package/input_text.js.map +1 -0
- package/input_text.ts +99 -0
- package/instructions.js +111 -0
- package/instructions.js.map +1 -0
- package/instructions.ts +145 -0
- package/isolated.js +512 -0
- package/isolated.js.map +1 -0
- package/isolated.ts +502 -0
- package/keyboard.js +544 -0
- package/keyboard.js.map +1 -0
- package/keyboard.ts +403 -0
- package/legacy_instructions.js +3 -0
- package/legacy_instructions.js.map +1 -0
- package/legacy_instructions.ts +13 -0
- package/local.js +181 -0
- package/local.js.map +1 -0
- package/local.ts +282 -0
- package/machine.js +3 -0
- package/machine.js.map +1 -0
- package/machine.ts +8 -0
- package/mcp.js +123 -0
- package/mcp.js.map +1 -0
- package/mcp.ts +141 -0
- package/mcp_auth.js +63 -0
- package/mcp_auth.js.map +1 -0
- package/mcp_auth.ts +91 -0
- package/mcp_authorize.js +17 -0
- package/mcp_authorize.js.map +1 -0
- package/mcp_authorize.ts +18 -0
- package/mcp_registry.js +178 -0
- package/mcp_registry.js.map +1 -0
- package/mcp_registry.ts +193 -0
- package/mod.js +43 -0
- package/mod.js.map +1 -0
- package/mod.ts +45 -0
- package/model_selection.js +72 -0
- package/model_selection.js.map +1 -0
- package/model_selection.ts +86 -0
- package/numbers.js +6 -0
- package/numbers.js.map +1 -0
- package/numbers.ts +8 -0
- package/package.json +106 -4
- package/panels.js +119 -0
- package/panels.js.map +1 -0
- package/panels.ts +259 -0
- package/patch.js +329 -0
- package/patch.js.map +1 -0
- package/patch.ts +325 -0
- package/perf.ts +65 -0
- package/providers.js +36 -0
- package/providers.js.map +1 -0
- package/providers.ts +53 -0
- package/remote.js +441 -0
- package/remote.js.map +1 -0
- package/remote.ts +446 -0
- package/results.js +49 -0
- package/results.js.map +1 -0
- package/results.ts +39 -0
- package/routes.js +64 -0
- package/routes.js.map +1 -0
- package/routes.ts +87 -0
- package/runs.js +478 -0
- package/runs.js.map +1 -0
- package/runs.ts +479 -0
- package/runtime/vocab.json +36 -0
- package/runtime.js +105 -0
- package/runtime.js.map +1 -0
- package/runtime.ts +112 -0
- package/session_machines.js +203 -0
- package/session_machines.js.map +1 -0
- package/session_machines.ts +216 -0
- package/sheet.js +55 -0
- package/sheet.js.map +1 -0
- package/sheet.ts +31 -0
- package/shutdown.js +7 -0
- package/shutdown.js.map +1 -0
- package/shutdown.ts +7 -0
- package/skills.js +116 -0
- package/skills.js.map +1 -0
- package/skills.ts +114 -0
- package/startup_bench.ts +140 -0
- package/status.js +82 -0
- package/status.js.map +1 -0
- package/status.ts +97 -0
- package/steps.baseline.json +28 -0
- package/steps_bench.ts +155 -0
- package/store.js +31 -0
- package/store.js.map +1 -0
- package/store.ts +82 -0
- package/streaming.js +3 -0
- package/streaming.js.map +1 -0
- package/streaming.ts +8 -0
- package/streaming_bench.ts +76 -0
- package/switch_bench.ts +97 -0
- package/testing.ts +177 -0
- package/tools.js +287 -0
- package/tools.js.map +1 -0
- package/tools.ts +313 -0
- package/transcript.js +149 -0
- package/transcript.js.map +1 -0
- package/transcript.ts +187 -0
- package/tree.js +97 -0
- package/tree.js.map +1 -0
- package/tree.ts +114 -0
- package/unfinished.js +186 -0
- package/unfinished.js.map +1 -0
- package/unfinished.ts +198 -0
- package/view.js +92 -0
- package/view.js.map +1 -0
- package/view.ts +102 -0
- package/vocab.js +23 -0
- package/vocab.js.map +1 -0
- package/vocab.json +494 -0
- package/vocab.ts +22 -0
- package/window_bench.ts +114 -0
- package/worker_bench.ts +72 -0
- package/workspace.js +21 -0
- package/workspace.js.map +1 -0
- package/workspace.ts +17 -0
- package/worn.js +194 -0
- package/worn.js.map +1 -0
- package/worn.ts +246 -0
package/WORKER.md
ADDED
|
@@ -0,0 +1,221 @@
|
|
|
1
|
+
# Web Worker runtime
|
|
2
|
+
|
|
3
|
+
The default TUI separates terminal rendering from the database and agent
|
|
4
|
+
runtime. The inline `local()` API remains available for diagnostics:
|
|
5
|
+
|
|
6
|
+
```sh
|
|
7
|
+
yak --config candidate.json session new '…' --tui
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
Use a config naming a separate candidate database. Changing working directory
|
|
11
|
+
does not isolate storage. The worker opens that config's database and runs
|
|
12
|
+
normal migrations.
|
|
13
|
+
|
|
14
|
+
## Ownership
|
|
15
|
+
|
|
16
|
+
The main thread owns terminal input, Preact, layout, Markdown rendering, VISUAL
|
|
17
|
+
selection, and the private ephemeral frontend graph. It also holds a separate
|
|
18
|
+
`@yaks/client` domain replica. The worker exclusively owns the authoritative
|
|
19
|
+
SQLite/blob graph, the runner, providers, and tools. Neither drafts nor
|
|
20
|
+
selection state are transmitted.
|
|
21
|
+
|
|
22
|
+
`@yaks/sync`'s `portLink` carries structured request/reply messages and existing
|
|
23
|
+
subscription frames over a MessagePort that `remote()` sends the worker; the
|
|
24
|
+
worker serves a backend on each port it is sent. The TUI starts a worker for its
|
|
25
|
+
one backend and ends it with it. A test process starts one and lends it to each
|
|
26
|
+
test's backend in turn (testing.ts `worker`), except where the test is about the
|
|
27
|
+
worker's own end, since a lent worker is never terminated: `force()` lets go of
|
|
28
|
+
its backend instead. `@yaks/api` supplies subscription membership and deltas;
|
|
29
|
+
`land` applies them to the replica. The worker exposes a fixed list of
|
|
30
|
+
operations rather than arbitrary function invocation. This pilot does not offer
|
|
31
|
+
optimistic graph mutations: send/start/archive/task admission are authoritative
|
|
32
|
+
commands with explicit responses.
|
|
33
|
+
|
|
34
|
+
Session and task entities are subscribed globally. Transcript subscriptions
|
|
35
|
+
cover only the selected session and its inherited fork prefix. Previous
|
|
36
|
+
transcript subscriptions are removed on selection changes. The UI now uses
|
|
37
|
+
bounded transcript pages; see [WINDOWS.md](WINDOWS.md) for window subscriptions,
|
|
38
|
+
retained rows, and entry-size limits. This worker is a thread in the same
|
|
39
|
+
process, not a sandbox or a separate fault-isolated process.
|
|
40
|
+
|
|
41
|
+
## What is incomplete
|
|
42
|
+
|
|
43
|
+
- Session titles and derived statuses still use the existing asynchronous
|
|
44
|
+
summary projections. Those RPC results are not yet live query projections.
|
|
45
|
+
`subscriptions` gained an explicit dependency invalidation callback: entry
|
|
46
|
+
commits refresh the session set. This is correct but coarse; it is not the
|
|
47
|
+
fully granular frontend architecture we want.
|
|
48
|
+
- Requests are bounded and timed out, but frames lack credit-based backpressure.
|
|
49
|
+
Large initial transcripts can still stall the main thread during structured
|
|
50
|
+
clone and replica application. Overlapping transcript queries are arranged as
|
|
51
|
+
disjoint session ranges; generic overlapping-subscription retention is not
|
|
52
|
+
solved by this pilot.
|
|
53
|
+
- The client working-set API applies received entities and owns bounded
|
|
54
|
+
retention. The worker adapter still tracks subscription membership/readiness.
|
|
55
|
+
A reusable client transport with subscription readiness, errors, and ownership
|
|
56
|
+
would remove this boilerplate.
|
|
57
|
+
- No transparent worker restart or mutation retry: a timeout does not prove a
|
|
58
|
+
write failed. Worker errors reject pending calls and surface in diagnostics.
|
|
59
|
+
- `Agent.close()` is idempotent and async: it stops admission and new steps,
|
|
60
|
+
then drains admitted operations and the step in flight, and leaves the effects
|
|
61
|
+
pool, before diagnostics and SQLite are closed. It does not mark sessions or
|
|
62
|
+
tasks stopped/completed. Inline callers must await it; a callback that never
|
|
63
|
+
returns keeps storage open.
|
|
64
|
+
- Interactive shutdown has two stages: the first Ctrl+C stops new commands and
|
|
65
|
+
model turns, then waits for admitted callbacks to finish. The UI shows a
|
|
66
|
+
shutdown message and accepts only another Ctrl+C. Frontend refresh loops stop
|
|
67
|
+
scheduling reads, and a read already awaiting another stage cannot overwrite
|
|
68
|
+
that message with an expected shutdown refusal. Other failures still enter
|
|
69
|
+
diagnostics. There is no automatic deadline. A second Ctrl+C ends the worker
|
|
70
|
+
where it stands, preserving the last durable checkpoints; independent
|
|
71
|
+
supervised processes remain running. OS SIGINT follows the same two-stage
|
|
72
|
+
path. Programmatic `remote.close()` retains its two-second default, kept, like
|
|
73
|
+
every request's deadline, by `remote()`'s `clock` option;
|
|
74
|
+
`close({timeout: null})` drains indefinitely, and `force()` releases that wait
|
|
75
|
+
explicitly. Terminal cleanup follows drain or explicit force. Queued children
|
|
76
|
+
remain queued for restart.
|
|
77
|
+
|
|
78
|
+
- Port close notifies its peer and rejects pending requests. Transport error and
|
|
79
|
+
messageerror events do likewise. A silent disappear without an event or close
|
|
80
|
+
packet can only be detected by request timeout; there is no heartbeat/restart.
|
|
81
|
+
- Native SQLite close never races callbacks in graceful shutdown. Deadline exit
|
|
82
|
+
terminates the worker rather than calling SQLite close beneath a live
|
|
83
|
+
callback. First the worker is asked to write its own ending (`end`): its pid
|
|
84
|
+
is the frontend's, which goes on, so only its `exit` in the graph says it is
|
|
85
|
+
over, and the next backend takes over what it held at once. A worker wedged
|
|
86
|
+
past answering within a second is terminated regardless, and what it held is
|
|
87
|
+
had once its leases lapse.
|
|
88
|
+
- No live-provider test or production-database experiment was performed.
|
|
89
|
+
|
|
90
|
+
## Measurements
|
|
91
|
+
|
|
92
|
+
Run `deno run -A packages/harness/worker_bench.ts`. It creates isolated
|
|
93
|
+
in-memory stores and a temporary working directory. It compares startup and a
|
|
94
|
+
burst of 11 100,000-character messages using an immediate fake model, while
|
|
95
|
+
sampling a 2ms main-thread timer. The final yield ensures blocked time is
|
|
96
|
+
observed. It reports message counts, not byte-accurate clone costs. Model
|
|
97
|
+
scheduling can coalesce asks differently between runs; this is not a controlled
|
|
98
|
+
throughput benchmark or an interactive latency guarantee.
|
|
99
|
+
|
|
100
|
+
An initial run measured inline startup 32ms / worker startup 255ms, burst 123ms
|
|
101
|
+
/ 169ms, maximum timer delay 112ms / 2ms. This suggests better event-loop
|
|
102
|
+
availability at the cost of startup and throughput overhead. Repeat on your
|
|
103
|
+
machine and workload; default promotion does not change these tradeoffs. There
|
|
104
|
+
are no claims yet for many concurrent children, p99 input latency, or streaming
|
|
105
|
+
backpressure.
|
|
106
|
+
|
|
107
|
+
Tests exercise a real worker with isolated SQLite, command errors, selected fork
|
|
108
|
+
replication, shutdown, and the existing App: typing a draft after the view is
|
|
109
|
+
ready sends zero messages to the backend. Generic UI tests continue to cover
|
|
110
|
+
visual selection, scroll anchors, mouse routing, and lazy rendering.
|
|
111
|
+
|
|
112
|
+
An isolated tmux smoke test started worker mode on a new temporary database,
|
|
113
|
+
rendered the sidebar and composer, accepted an unsent draft, and exited on
|
|
114
|
+
Ctrl+C. The test session was removed and no diagnostic journal was created. This
|
|
115
|
+
does not verify a live provider or sustained interactive streaming.
|
|
116
|
+
|
|
117
|
+
A later isolated run on this checkout measured inline startup 115ms / worker
|
|
118
|
+
693ms, burst 380ms / 613ms, max timer delay 331ms / 6ms (31 / 33 entries). This
|
|
119
|
+
is a noisy single run under concurrent development, not a p99 claim. Shutdown
|
|
120
|
+
tests cover an active held model, a never-returning worker model, burst writes,
|
|
121
|
+
duplicate close, peer disconnect, and a real worker crash. The diagnostic
|
|
122
|
+
journal confirmed the reported normal Ctrl+C failure was the old two-second
|
|
123
|
+
`Worker shutdown timeout` exception; that deadline now returns an expected
|
|
124
|
+
non-drained result instead.
|
|
125
|
+
|
|
126
|
+
A private-HOME tmux smoke test of the default TUI exited 0 on Ctrl+C, restored
|
|
127
|
+
identical `stty -g` settings, and produced no exception journal. The
|
|
128
|
+
stuck-worker test also reopens its private file-backed database, resumes, and
|
|
129
|
+
gets a reply. An admitted storage-callback test verifies an independently
|
|
130
|
+
spawned process is still alive after Agent close. This is not a
|
|
131
|
+
live-provider/subagent load test.
|
|
132
|
+
|
|
133
|
+
A private-HOME tmux smoke test of the default TUI exited 0 on Ctrl+C, restored
|
|
134
|
+
identical `stty -g` settings, and produced no exception journal. The
|
|
135
|
+
stuck-worker test also reopens its private file-backed database, resumes, and
|
|
136
|
+
gets a reply. An admitted storage-callback test verifies an independently
|
|
137
|
+
spawned process is still alive after Agent close. This is not a
|
|
138
|
+
live-provider/subagent load test.
|
|
139
|
+
|
|
140
|
+
## Session-switch measurements
|
|
141
|
+
|
|
142
|
+
`deno run -A packages/harness/switch_bench.ts 1000 1000` creates an isolated
|
|
143
|
+
SQLite database with 1,000 sessions, two 1,000-entry transcripts and ten entries
|
|
144
|
+
in each remaining session. Bodies contain about 1,000 characters. It mounts the
|
|
145
|
+
frontend at 120×32 cells and measures frontend selection through the first paint
|
|
146
|
+
containing the selected transcript. The first sample is cold; eleven subsequent
|
|
147
|
+
samples alternate between the two transcripts. No provider requests are made.
|
|
148
|
+
|
|
149
|
+
One before/after run on the same host measured:
|
|
150
|
+
|
|
151
|
+
| Measurement | Before | After |
|
|
152
|
+
| ------------------------------ | -------: | -----: |
|
|
153
|
+
| Cold selection to paint | 1,459 ms | 657 ms |
|
|
154
|
+
| Warm median | 1,036 ms | 152 ms |
|
|
155
|
+
| Warm p95 (11 samples; maximum) | 1,537 ms | 190 ms |
|
|
156
|
+
| Outbound worker messages | 88 | 40 |
|
|
157
|
+
| Maximum 2 ms timer delay | 97 ms | 185 ms |
|
|
158
|
+
|
|
159
|
+
The change bounds title reads to the first eligible local entry instead of
|
|
160
|
+
materializing every transcript. The remote adapter reuses asynchronous session
|
|
161
|
+
and task projection results until their authoritative subscription changes.
|
|
162
|
+
Initial transcript frames satisfy the waiting read without triggering a second
|
|
163
|
+
application refresh. Each concurrent transcript request returns its own selected
|
|
164
|
+
snapshot, not a later request's selection.
|
|
165
|
+
|
|
166
|
+
These are synthetic measurements, not production latency guarantees. The larger
|
|
167
|
+
maximum timer delay in this run remains a concern: initial replica application,
|
|
168
|
+
text extraction in the test terminal, and full transcript transfers still do
|
|
169
|
+
synchronous work. The change reduces elapsed switching latency, not every
|
|
170
|
+
main-thread stall. These measurements predate the bounded loading implementation
|
|
171
|
+
in [WINDOWS.md](WINDOWS.md). Under active writes, summary subscriptions still
|
|
172
|
+
invalidate broadly. First-class incremental summary projections and bounded
|
|
173
|
+
transfer/application remain follow-up work.
|
|
174
|
+
|
|
175
|
+
After integration with the independent input-publication fix, another run of the
|
|
176
|
+
same fixture measured 786 ms for the cold selection, 194 ms warm median, 284 ms
|
|
177
|
+
warm p95, and 142 ms maximum timer delay. Runs were taken on a shared host, not
|
|
178
|
+
under controlled load. Both elapsed time and main-thread stalls should continue
|
|
179
|
+
to be measured as the projection and transfer APIs change.
|
|
180
|
+
|
|
181
|
+
## Startup reconciliation
|
|
182
|
+
|
|
183
|
+
Startup previously woke every settled child to reconcile completion receipts.
|
|
184
|
+
For forks, this read each inherited transcript before checking whether the
|
|
185
|
+
receipt already existed. Finished pooled children could also enter scheduling
|
|
186
|
+
again. A large parent shared by many forks therefore caused repeated reads and
|
|
187
|
+
status evaluation ahead of the first sidebar response.
|
|
188
|
+
|
|
189
|
+
Resume now reconciles receipts directly rather than running the child again.
|
|
190
|
+
Reconciliation checks the child's latest local entry and existing receipt first.
|
|
191
|
+
Only missing receipts require the full inherited transcript. A child that
|
|
192
|
+
finishes during those reads uses the final snapshot for both receipt identity
|
|
193
|
+
and content.
|
|
194
|
+
|
|
195
|
+
An isolated benchmark is available:
|
|
196
|
+
|
|
197
|
+
```sh
|
|
198
|
+
deno run -A packages/harness/startup_bench.ts 150 4000
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
It creates a temporary database with 150 sessions, a 4,000-entry parent, and
|
|
202
|
+
settled forks with existing receipts. It never opens the configured database.
|
|
203
|
+
Three cached-module runs on a shared host measured:
|
|
204
|
+
|
|
205
|
+
| Stage | Before | After |
|
|
206
|
+
| ----------------------------------------------------- | ---------------- | ---------- |
|
|
207
|
+
| SQLite open | 10–23 ms | 15–16 ms |
|
|
208
|
+
| Worker initialization | 271–295 ms | 276–333 ms |
|
|
209
|
+
| Resume command response | 33–37 ms | 33–38 ms |
|
|
210
|
+
| First session summary, including queued recovery work | 12,204–12,468 ms | 287–309 ms |
|
|
211
|
+
| Selected transcript replication/read | 257–385 ms | 223–346 ms |
|
|
212
|
+
|
|
213
|
+
A separate process importing the application with cached modules took 310 ms
|
|
214
|
+
wall time (216 ms in dynamic imports). These results reproduce a roughly
|
|
215
|
+
12-second recovery stall; they do not prove every live startup has that cause.
|
|
216
|
+
The benchmark also reports mounted frontend paint after the initial read. That
|
|
217
|
+
stage used 14–41 ms in another three-run sample. Initial full-transcript
|
|
218
|
+
transfer and summary derivation are still required; this change is not
|
|
219
|
+
pagination. First installation downloads, module compilation, missing-receipt
|
|
220
|
+
delivery, and live provider recovery can have different costs. Timing results
|
|
221
|
+
are not latency guarantees, and the fixture uses a fake provider only.
|
package/_dist/agent.d.ts
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { type Bundle, type Comp, type Eid, type Graph } from "@yaks/graph";
|
|
2
|
+
import type { Effects } from "@yaks/effects";
|
|
3
|
+
import type { Vocab } from "@yaks/vocab";
|
|
4
|
+
import { type Model, type Request } from "@yaks/model";
|
|
5
|
+
import { type ChildLimits, type Deps, type Runner, type Step, type Tool, type TranscriptPage, type TranscriptWindow } from "@yaks/session";
|
|
6
|
+
import { type Snapshot } from "@yaks/context";
|
|
7
|
+
import { type ModelSelection } from "./model_selection.js";
|
|
8
|
+
import { type EntrySource, type SourceRequest } from "./detail.js";
|
|
9
|
+
import { type Wear } from "./worn.js";
|
|
10
|
+
import { type RuntimeAction } from "./runtime.js";
|
|
11
|
+
import type { Harness } from "./store.js";
|
|
12
|
+
/** The provider, model and tool rows a transcript is served from, as one
|
|
13
|
+
* idempotent batch with identities derived from each name, and the provider's
|
|
14
|
+
* offering of the model is a `serves` edge. */ export declare let seed: (o?: {
|
|
15
|
+
provider?: string;
|
|
16
|
+
model?: string;
|
|
17
|
+
tools?: Tool[];
|
|
18
|
+
}) => Bundle[];
|
|
19
|
+
/** What an agent runs over: a graph, the effects its commits raise, the
|
|
20
|
+
* vocabulary it reads them with, the process working it, which a run's lease
|
|
21
|
+
* names as its holder, and, where the host can tell, whether another holder is
|
|
22
|
+
* over, so a run it held is taken over now rather than at its expiry. */ export type Host = {
|
|
23
|
+
g: Graph;
|
|
24
|
+
fx: Effects;
|
|
25
|
+
vocab: Vocab;
|
|
26
|
+
me: Eid;
|
|
27
|
+
gone?: (holder: Eid) => boolean | Promise<boolean>;
|
|
28
|
+
report?: Harness['report'];
|
|
29
|
+
};
|
|
30
|
+
/** Where a defect happened: what was running, and in which transcript. */ export type Where = {
|
|
31
|
+
phase: string;
|
|
32
|
+
session?: Eid;
|
|
33
|
+
};
|
|
34
|
+
/** What a new session opens with: where it lives, the instruction files
|
|
35
|
+
* found there, each snapshotted into the transcript ahead of the first
|
|
36
|
+
* message, the persona it wears and the topic it is opened on (@yaks/topic's
|
|
37
|
+
* `session.topic`). */ export type Opening = {
|
|
38
|
+
home?: Comp;
|
|
39
|
+
files?: Snapshot[];
|
|
40
|
+
persona?: Eid;
|
|
41
|
+
topic?: Eid;
|
|
42
|
+
};
|
|
43
|
+
/** How an agent is started: the graph it runs over, what serves it, what it
|
|
44
|
+
* may do, and what its host lends it. */ export type Opts<H extends Host = Host> = ChildLimits & {
|
|
45
|
+
h: H;
|
|
46
|
+
/** one model for every provider (a test's, an embedder's) */ model?: Model;
|
|
47
|
+
/** implementations keyed by `provider.name` */ providers?: Record<string, Model>;
|
|
48
|
+
/** the model to ask for by name (otherwise `defaultUsing`'s) */ name?: string;
|
|
49
|
+
/** where the agent is lent no `name`, the `using{provider, model}` (eids)
|
|
50
|
+
* it asks, read again before every ask: by default the graph's own
|
|
51
|
+
* (./default.ts) */ defaultUsing?: () => Promise<Comp>;
|
|
52
|
+
/** When compaction must use the model selected for the session. */ compactWithCurrent?: Deps['compactWithCurrent'];
|
|
53
|
+
/** the provider to ask, by name, and the one `model` serves */ provider?: string;
|
|
54
|
+
/** what the agent may call */ tools?: Tool[];
|
|
55
|
+
/** tools served from elsewhere, offered afresh to every ask of the
|
|
56
|
+
* transcript named */ remote?: (session: Eid) => Promise<Tool[]>;
|
|
57
|
+
/** tools offered only to a transcript whose `sending.tools` names them
|
|
58
|
+
* (@yaks/session `Deps.named`) */ named?: () => Tool[];
|
|
59
|
+
streaming?: boolean;
|
|
60
|
+
checkpointMs?: number;
|
|
61
|
+
/** each piece of a streamed reply, once it is stored (@yaks/session
|
|
62
|
+
* `Deps.typed`) */ typed?: Runner['typed'];
|
|
63
|
+
/** The system prompt every ask carries, or what reads each transcript's:
|
|
64
|
+
* read again for every ask, so what it reads (a name, the apps in reach)
|
|
65
|
+
* is current in a transcript that runs for weeks. */ instructions?: string | ((session: Eid) => Promise<string>);
|
|
66
|
+
/** Changing this scope refreshes instructions even with a warm prefix cache. */ instructionScope?: Deps['instructionScope'];
|
|
67
|
+
/** Which of a transcript's lines a turn reads, for whom it acts. */ readable?: Deps['readable'];
|
|
68
|
+
/** The persona base shared by this application's transcripts. */ cachePrefix?: Omit<NonNullable<Request['cachePrefix']>, 'length'> & {
|
|
69
|
+
persona: Eid;
|
|
70
|
+
};
|
|
71
|
+
/** What every system prompt this agent composes opens with, ahead of the
|
|
72
|
+
* persona and `instructions`: the same for every transcript and every ask,
|
|
73
|
+
* so it stays in a provider's cached prefix (the box's kinds index, @yaks/vocab
|
|
74
|
+
* `kindsIndex`). */ opens?: string;
|
|
75
|
+
/** Wear each transcript's persona on every ask (`session.persona`, or that
|
|
76
|
+
* of the session that started it): its text (@yaks/persona `voice`) leads
|
|
77
|
+
* the system prompt and `instructions` follows it, both read again for
|
|
78
|
+
* every ask, so an edit to the persona reaches a transcript on its next
|
|
79
|
+
* turn. `bases` is where a persona's base (`persona.base`) is kept when this
|
|
80
|
+
* graph does not keep it, and `topic` says the tree of the topic the
|
|
81
|
+
* transcript is opened on (`session.topic`) after the persona. A transcript
|
|
82
|
+
* that wears nothing keeps the instructions it was given. `tools` offers
|
|
83
|
+
* each ask exactly the registered tools that persona contains, as it
|
|
84
|
+
* contains them then, where no line of the transcript selected its own
|
|
85
|
+
* (`sending.tools`); a persona containing none leaves the runner's set. */ wear?: Wear;
|
|
86
|
+
/** Maximum tool-result UTF-8 bytes before model-facing handle projection. */ outputLimit?: number;
|
|
87
|
+
/** A multi-user host supplies its scoped result storage at the same model boundary. */ resultText?: Deps['resultText'];
|
|
88
|
+
/** the share of its model's context window a transcript fills before it is
|
|
89
|
+
* compacted, for every model (@yaks/session `Deps.compactAt`) */ compactAt?: number;
|
|
90
|
+
compactShare?: Deps['compactShare'];
|
|
91
|
+
elideCold?: Deps['elideCold'];
|
|
92
|
+
background?: Deps['background'];
|
|
93
|
+
/** each step of every transcript, as it lands */ each?: (step: Step, session?: string) => void | Promise<void>;
|
|
94
|
+
opening?: (persona?: Eid, session?: Eid) => Promise<Opening>;
|
|
95
|
+
/** context an ask carries without storing its bytes in entries */ context?: Deps['contextItems'];
|
|
96
|
+
/** Dynamic context independent of source-bound image items. */ inputSource?: (entry: Bundle) => string | undefined;
|
|
97
|
+
/** Render host context around the words when the model reads the input. */ inputBody?: (entry: Bundle, body: string) => string;
|
|
98
|
+
requestItems?: Deps['requestItems'];
|
|
99
|
+
turnItems?: Deps['turnItems'];
|
|
100
|
+
/** defects, apart from refusals (default `console.error`) */ report?: (error: unknown, where: Where) => void;
|
|
101
|
+
/** each refusal a tool call met, apart from defects (@yaks/session
|
|
102
|
+
* `Deps.refused`) */ refused?: Deps['refused'];
|
|
103
|
+
/** what the host reconciles when the agent resumes */ resuming?: () => Promise<void>;
|
|
104
|
+
/** what the host lets go of once every admitted operation has drained */ release?: () => Promise<void> | void;
|
|
105
|
+
/** how long a transcript's lease stands between renewals, so how long a
|
|
106
|
+
* process that died running it holds it up (ms; default @yaks/effects') */ hold?: number;
|
|
107
|
+
/** how long a background call runs before the model may take a turn while
|
|
108
|
+
* it runs (ms; default @yaks/session `PATIENCE`) */ patience?: number;
|
|
109
|
+
};
|
|
110
|
+
/** A running agent. */ export type Agent<H extends Host = Host> = {
|
|
111
|
+
h: H;
|
|
112
|
+
tools: Tool[];
|
|
113
|
+
/** the model entity every new session is started under */ model: Eid;
|
|
114
|
+
/** what to call a model or tool entity, for the views: every model by its
|
|
115
|
+
* label once `naming` settles */ names: Record<string, string>;
|
|
116
|
+
naming: Promise<void>;
|
|
117
|
+
/** start a transcript with one instruction; the runner takes it from there.
|
|
118
|
+
* `by` is who wrote the instruction, where the caller knows. */ start: (prompt: string, o?: {
|
|
119
|
+
effort?: string;
|
|
120
|
+
model?: Eid;
|
|
121
|
+
persona?: Eid;
|
|
122
|
+
by?: Eid;
|
|
123
|
+
}) => Promise<Eid>;
|
|
124
|
+
/** personas this graph offers for a new session */ personas: () => Promise<Bundle[]>;
|
|
125
|
+
/** the configured models, and what this session asks for next */ models: (session?: Eid) => Promise<ModelSelection>;
|
|
126
|
+
/** record a passive model choice; the next request honours it */ selectModel: (session: Eid, model: Eid) => Promise<void>;
|
|
127
|
+
/** say something more to a transcript that is already going, as `by` where
|
|
128
|
+
* the caller knows who wrote it */ send: (session: Eid, text: string, by?: Eid) => Promise<Eid>;
|
|
129
|
+
/** mint and delegate unfiled work under an existing session */ taskEntry: (session: Eid, text: string) => Promise<{
|
|
130
|
+
task: Eid;
|
|
131
|
+
child: Eid;
|
|
132
|
+
}>;
|
|
133
|
+
archive: (session: Eid, archived: boolean) => Promise<void>;
|
|
134
|
+
/** selected session or a bounded, cursor-paged list */ sessions: (selected?: Eid, page?: ListPage) => Promise<Bundle[]>;
|
|
135
|
+
/** A bounded page of open/wip tasks, requested explicitly. */ tasks: (page?: ListPage) => Promise<Bundle[]>;
|
|
136
|
+
/** direct delegated sessions, including forks */ children: (session: Eid) => Promise<Bundle[]>;
|
|
137
|
+
/** one transcript's entries, in order */ transcript: (session: Eid) => Promise<Bundle[]>;
|
|
138
|
+
transcriptWindow: (session: Eid, request?: TranscriptWindow) => Promise<TranscriptPage>;
|
|
139
|
+
entrySource: (session: Eid, eid: Eid, request?: SourceRequest) => Promise<EntrySource>;
|
|
140
|
+
usage: (session: Eid) => Promise<Bundle[]>;
|
|
141
|
+
/** run every transcript left owed a turn that nothing wrote a run for, and
|
|
142
|
+
* answer which they were */ resume: () => Promise<Eid[]>;
|
|
143
|
+
/** wait for a transcript to run out of things to do */ idle: (session: Eid) => Promise<void>;
|
|
144
|
+
/** one bundle as a line of text, through @yaks/render's session views */ line: (b: Bundle, view?: string, ctx?: Record<string, unknown>) => string;
|
|
145
|
+
/** Explicit instruction admission; appends a snapshot, never a user turn. */ instruct: (session: Eid, text: string, source?: string) => Promise<Eid>;
|
|
146
|
+
runtime: (session: Eid) => Promise<Bundle[]>;
|
|
147
|
+
control: (session: Eid, action: RuntimeAction) => Promise<string>;
|
|
148
|
+
/** an operation the host adds, admitted like these: refused once the agent
|
|
149
|
+
* is closing, and drained before the host lets go of anything */ admitted: <A extends unknown[], T>(work: (...args: A) => Promise<T>) => (...args: A) => Promise<T>;
|
|
150
|
+
/** stop admitting, drain, and release; `reason` is what later calls get */ close: (reason?: Error) => Promise<void>;
|
|
151
|
+
};
|
|
152
|
+
/** A page of sidebar rows. A selected session only queries its direct children. */ export type ListPage = {
|
|
153
|
+
after?: string | number;
|
|
154
|
+
limit?: number;
|
|
155
|
+
};
|
|
156
|
+
export declare let LISTED: number;
|
|
157
|
+
export declare let through: (session: Eid, by?: Eid) => any;
|
|
158
|
+
/** A new transcript, as one write: the session and its instruction files,
|
|
159
|
+
* followed by a message that asks for a turn when one was given. An empty
|
|
160
|
+
* session holds its model choice until that first message arrives. The
|
|
161
|
+
* session and the message are whoever began it; the instruction files are the
|
|
162
|
+
* harness's own, put in front of the model, and never that person's words. */ export declare let begin: (g: Graph, prompt: string | undefined, o: Opening & {
|
|
163
|
+
using: Comp;
|
|
164
|
+
eid?: Eid;
|
|
165
|
+
by?: Eid;
|
|
166
|
+
via?: Eid;
|
|
167
|
+
project?: Eid;
|
|
168
|
+
work?: Eid;
|
|
169
|
+
title?: string;
|
|
170
|
+
}) => Promise<Eid>;
|
|
171
|
+
/**
|
|
172
|
+
* The runner an agent's options lend (@yaks/session `Runner`), over the
|
|
173
|
+
* provider, model and tool rows its first step seeds: what serves each
|
|
174
|
+
* provider, what a transcript may call, and how a step is taken. A host registers it with
|
|
175
|
+
* @yaks/session `running` wherever its effects are worked.
|
|
176
|
+
*
|
|
177
|
+
* ```ts
|
|
178
|
+
* import { lend } from '@yaks/harness'
|
|
179
|
+
* import { running } from '@yaks/session'
|
|
180
|
+
*
|
|
181
|
+
* // h.fx.handle(running(h.g, lend({ h, model })))
|
|
182
|
+
* ```
|
|
183
|
+
*/ export declare let lend: <H extends Host>(opts: Opts<H>) => Runner;
|
|
184
|
+
/**
|
|
185
|
+
* Lend a graph the runner and work its pool, seeded with what serves it.
|
|
186
|
+
*
|
|
187
|
+
* ```ts ignore
|
|
188
|
+
* import { agent } from '@yaks/harness'
|
|
189
|
+
*
|
|
190
|
+
* let a = agent({ h: { g, fx, vocab, me }, model: fake })
|
|
191
|
+
* let s = await a.start('reply with the word pong')
|
|
192
|
+
* await a.idle(s)
|
|
193
|
+
* ```
|
|
194
|
+
*/ export declare let agent: <H extends Host>(opts: Opts<H>) => Agent<H>;
|
|
195
|
+
/** Child assignment is explicit admission data; copied fork context is not its title. */ export declare let sessionTitle: (g: Graph, session: Bundle) => Promise<string>;
|
|
196
|
+
/** What a transcript is called in a listing: the first message sent to it. */ export declare let titleOf: (entries: Bundle[]) => string;
|
|
197
|
+
//# sourceMappingURL=agent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agent.d.ts","sources":["../agent.ts"],"names":[],"mappings":"AA4BA,SACE,KAAK,MAAM,EACX,KAAK,IAAI,EACT,KAAK,GAAG,EACR,KAAK,KAAK,2BAEmB;AAE/B,cAAc,OAAO,6BAAkC;AACvD,cAAc,KAAK,2BAAgC;AACnD,SAGE,KAAK,KAAK,EAGV,KAAK,OAAO,2BAEiB;AAI/B,SAME,KAAK,WAAW,EAIhB,KAAK,IAAI,EAOT,KAAK,MAAM,EAGX,KAAK,IAAI,EAET,KAAK,IAAI,EAET,KAAK,cAAc,EAEnB,KAAK,gBAAgB,6BAGU;AACjC,SAAkC,KAAK,QAAQ,6BAAkC;AAIjF,SACE,KAAK,cAAc,+BAIQ;AAC7B,SAAS,KAAK,WAAW,EAAe,KAAK,aAAa,sBAAqB;AAE/E,SAAoB,KAAK,IAAI,oBAAuC;AAEpE,SAAS,KAAK,aAAa,uBAAkD;AAE7E,cAAc,OAAO,qBAAoB;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;;;;;;;;;CAYC,GACD,OAAO,YAAI,OAAQ,UAAU,MAAM,MAAM,KAAK,OAAK,OAgNlD;AAED;;;;;;;;;;CAUC,GACD,OAAO,YAAI,QAAS,UAAU,MAAM,MAAM,KAAK,OAAK,MAAM,GA4PzD;AAED,uFAAuF,GACvF,OAAO,YAAI,eACT,GAAG,OACH,SAAS,WACR,QAAQ,MAAM,EAUhB;AAED,4EAA4E,GAC5E,OAAO,YAAI,UAAW,SAAS,aAAW,MAAM,CAShB"}
|
package/_dist/cli.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { CliCommand } from "@yaks/cli/host";
|
|
2
|
+
export declare let commands: CliCommand[];
|
|
3
|
+
/** The local command supplies its own filesystem context before the stored
|
|
4
|
+
* session_new call. A remote invocation never observes the server cwd. */ export declare let tools: {
|
|
5
|
+
readonly session_new: (args: Record<string, unknown>, context: {
|
|
6
|
+
config?: string;
|
|
7
|
+
duties: boolean;
|
|
8
|
+
}) => Promise<undefined>;
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=cli.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sources":["../cli.ts"],"names":[],"mappings":"AAKA,cAAc,UAAU,8BAAmC;AAC3D,OAAO,YAAI,UAAU,aAYpB;AAED;wEACwE,GACxE,OAAO,YAAI;WACT,cACE,MAAM,OAAO,MAAM,EAAE,OAAO,GAC5B;IAAW,SAAS,MAAM;IAAE,QAAQ,OAAO;QAC1C,QAAQ,SAAS;EAqBrB"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { Bundle, Graph } from "@yaks/graph";
|
|
2
|
+
import { type Built } from "@yaks/query";
|
|
3
|
+
import type { Runs } from "@yaks/graph/tools";
|
|
4
|
+
import type { Host } from "@yaks/host";
|
|
5
|
+
import { type Intake } from "@yaks/session";
|
|
6
|
+
/** Only the exact host process fallback may use config.person. This assumes
|
|
7
|
+
* an owner-only authenticated network perimeter; config.person is not OAuth
|
|
8
|
+
* subject mapping. No anonymous caller or agent transcript gets this fallback. */ export declare let conversationOwner: (call: Bundle, g: Graph, host?: Pick<Host, 'me' | 'config'>) => Promise<string>;
|
|
9
|
+
/** Lines from a task or conversation the caller has already authorized.
|
|
10
|
+
* Backward pages and incremental reads share the same transcript. */ export declare let conversationLines: (g: Graph, row: Bundle, _dts_1: never) => Promise<{
|
|
11
|
+
task?: Bundle;
|
|
12
|
+
comments?: Bundle[];
|
|
13
|
+
sessions?: Bundle[];
|
|
14
|
+
entries: Bundle[];
|
|
15
|
+
earlier?: {
|
|
16
|
+
count: number;
|
|
17
|
+
before: string;
|
|
18
|
+
};
|
|
19
|
+
}>;
|
|
20
|
+
/** What a host makes of a conversation, where it is not the box's: who a
|
|
21
|
+
* call speaks for (the box's authenticated person, else its process
|
|
22
|
+
* fallback), the words as it takes them and what it writes beside them (as
|
|
23
|
+
* given), and how a conversation begins for its first words, as given and
|
|
24
|
+
* as the owner said them, answering what to write beside them (the box's: a
|
|
25
|
+
* session with the project's context, titled by them). */ export type Conversing = Partial<Pick<Host, 'me' | 'config'>> & {
|
|
26
|
+
owner?: (call: Bundle, g: Graph) => Promise<string>;
|
|
27
|
+
/** What makes a conversation the owner's, where the host keeps whose each
|
|
28
|
+
* is: by default, that the owner's own words are in it. A host whose
|
|
29
|
+
* conversations an agent speaks in for its owner says so here, since the
|
|
30
|
+
* agent's words are its own (M-31958). */ theirs?: (owner: string) => Built;
|
|
31
|
+
/** The project a call talks in, in place of the active project it names. */ project?: (g: Graph, args: Record<string, unknown>) => Promise<Bundle>;
|
|
32
|
+
/** Whether `owner` may read `row`, a conversation or a task, in place of
|
|
33
|
+
* the box's rule (theirs, or working under theirs). */ reads?: (g: Graph, row: Bundle, owner: string, project: string) => Promise<boolean>;
|
|
34
|
+
given?: (g: Graph, words: Intake) => Promise<{
|
|
35
|
+
words: Intake;
|
|
36
|
+
beside?: Bundle[];
|
|
37
|
+
}>;
|
|
38
|
+
start?: (g: Graph, first: {
|
|
39
|
+
words: Intake;
|
|
40
|
+
said: string;
|
|
41
|
+
project: Bundle;
|
|
42
|
+
}) => Promise<Bundle[]>;
|
|
43
|
+
};
|
|
44
|
+
export declare let conversations: (host?: Conversing) => Runs;
|
|
45
|
+
//# sourceMappingURL=conversations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conversations.d.ts","sources":["../conversations.ts"],"names":[],"mappings":"AAEA,cAAqB,MAAM,EAAQ,KAAK,2BAAgC;AACxE,SAAS,KAAK,KAAK,2BAAmD;AAGtE,cAAc,IAAI,iCAAsC;AACxD,cAAc,IAAI,0BAA+B;AAIjD,SAEE,KAAK,MAAM,6BAKoB;AAgCjC;;gFAEgF,GAChF,OAAO,YAAI,oBACT,MAAM,QACN,GAAG,OACH,OAAO,KAAK,MAAM,OAAO,cACxB,QAAQ,MAAM,EAgBhB;AA4HD;mEACmE,GACnE,OAAO,YAAI,oBACT,GAAG,OACH,KAAK,QACL,kBAMC;EACD,OAAO;EACP,WAAW;EACX,WAAW;EACX,SAAS;EACT;IAAY,OAAO,MAAM;IAAE,QAAQ,MAAM;;GAiB1C;AA8JD;;;;;wDAKwD,GACxD,YAAY,aAAa,QAAQ,KAAK,MAAM,OAAO;EACjD,SAAS,MAAM,QAAQ,GAAG,UAAU,QAAQ,MAAM;EAClD;;;0CAGwC,GACxC,UAAU,OAAO,MAAM,KAAK;EAC5B,0EAA0E,GAC1E,WAAW,GAAG,OAAO,MAAM,OAAO,MAAM,EAAE,OAAO,MAAM,QAAQ;EAC/D;uDACqD,GACrD,SACE,GAAG,OACH,KAAK,QACL,OAAO,MAAM,EACb,SAAS,MAAM,KACZ,QAAQ,OAAO;EACpB,SACE,GAAG,OACH,OAAO,WACJ;IAAU,OAAO;IAAQ,SAAS;;EACvC,SACE,GAAG,OACH;IAAS,OAAO;IAAQ,MAAM,MAAM;IAAE,SAAS;QAC5C,QAAQ;;AAGf,OAAO,YAAI,gBAAiB,OAAM,eAAkB,KA0JnD"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { Comp, Eid, Graph } from "@yaks/graph";
|
|
2
|
+
import { type Route } from "@yaks/model/route";
|
|
3
|
+
/** The native harness's own entity, @yaks/code's row for this package: its
|
|
4
|
+
* eid is derived from the package's name, so every graph names it alike. */ export declare let HARNESS: string;
|
|
5
|
+
/** An offering a row routes, and the `routes` edge that routes it. */ export type Routing = Route & {
|
|
6
|
+
edge: Eid;
|
|
7
|
+
};
|
|
8
|
+
/** The offerings a row (otherwise {@link HARNESS}) routes: the `serves` edges
|
|
9
|
+
* its `routes` edges point at, each with the provider whose plan meters it, in
|
|
10
|
+
* the edges' order (`edge.ord`, then the earliest routed), so offerings that
|
|
11
|
+
* weigh alike keep one order. */ export declare let routing: (g: Graph, of?: Eid) => Promise<Routing[]>;
|
|
12
|
+
/** Where a session asking `using` goes on once that model's plan is spent:
|
|
13
|
+
* of the offerings {@link HARNESS} routes, one on another plan with room
|
|
14
|
+
* (@yaks/model `onward`), keeping the effort it asked with; nothing where the
|
|
15
|
+
* harness routes no other, or every other plan is spent too. */ export declare let movedOn: (g: Graph, using: Comp | undefined, options?: {
|
|
16
|
+
passed?: ReadonlySet<Eid>;
|
|
17
|
+
available?: ReadonlySet<Eid>;
|
|
18
|
+
}) => Promise<Comp | undefined>;
|
|
19
|
+
/** Pin what `of` (otherwise {@link HARNESS}) asks by default to the offering
|
|
20
|
+
* it routes of that model name, whatever the plans read, or with no name clear
|
|
21
|
+
* the pin so routing resumes. A pin is the `routes.pinned` mark on one `routes`
|
|
22
|
+
* edge, and the router reads it as it reads the rest. A name `of` does not
|
|
23
|
+
* route is refused, since only a routed offering can be pinned. */ export declare let pin: (g: Graph, name?: string, _dts_1: never) => Promise<void>;
|
|
24
|
+
/** What a native session asks when nothing names it: of the offerings
|
|
25
|
+
* {@link HARNESS} routes, the one the router chooses, with its reason
|
|
26
|
+
* (`using.why`); else the `using{provider, model}` on {@link HARNESS}. One
|
|
27
|
+
* write changes either and no release does. */ export declare let defaultUsing: (g: Graph) => Promise<Comp>;
|
|
28
|
+
/** What a session opened on a piece of work asks: what the project a task is
|
|
29
|
+
* filed in, or the project itself, routes or names (`using{provider, model}`),
|
|
30
|
+
* so the session runs as that project's other work does; {@link defaultUsing}
|
|
31
|
+
* where the project says neither. */ export declare let usingFor: (g: Graph, work: string) => Promise<Comp>;
|
|
32
|
+
//# sourceMappingURL=default.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default.d.ts","sources":["../default.ts"],"names":[],"mappings":"AASA,cAAsB,IAAI,EAAE,GAAG,EAAE,KAAK,2BAAgC;AAGtE,SAA+B,KAAK,KAAK,iCAA6C;AAGtF;0EAC0E,GAC1E,OAAO,YAAI,SAAS,MAAM,CAA4C;AAItE,oEAAoE,GACpE,YAAY,UAAU;EAAU,MAAM;;AAEtC;;;+BAG+B,GAC/B,OAAO,YAAI,UACT,GAAG,OACH,KAAI,QACH,QAAQ,WAmCV;AAaD;;;8DAG8D,GAC9D,OAAO,YAAI,UACT,GAAG,OACH,OAAO,OAAO,SAAS,EACvB;EAAW,SAAS,YAAY;EAAM,YAAY,YAAY;MAC7D,QAAQ,OAAO,SAAS,EAkB1B;AAED;;;;iEAIiE,GACjE,OAAO,YAAI,MACT,GAAG,OACH,OAAO,MAAM,EACb,kBACC,QAAQ,IAAI,EAkBd;AAED;;;6CAG6C,GAC7C,OAAO,YAAI,eAAsB,GAAG,UAAQ,QAAQ,MAYnD;AAED;;;mCAGmC,GACnC,OAAO,YAAI,WAAkB,GAAG,OAAO,MAAM,MAAM,KAAG,QAAQ,MAS7D"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type SourceRequest = {
|
|
2
|
+
start?: number;
|
|
3
|
+
revision?: string;
|
|
4
|
+
};
|
|
5
|
+
export type EntrySource = {
|
|
6
|
+
eid: string;
|
|
7
|
+
component: string;
|
|
8
|
+
property: string;
|
|
9
|
+
revision: string;
|
|
10
|
+
start: number;
|
|
11
|
+
end: number;
|
|
12
|
+
total: number;
|
|
13
|
+
next: number | null;
|
|
14
|
+
text: string;
|
|
15
|
+
};
|
|
16
|
+
//# sourceMappingURL=detail.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detail.d.ts","sources":["../detail.ts"],"names":[],"mappings":"AAOA,YAAY;EAAkB,QAAQ,MAAM;EAAE,WAAW,MAAM;;AAC/D,YAAY;EACV,KAAK,MAAM;EACX,WAAW,MAAM;EACjB,UAAU,MAAM;EAChB,UAAU,MAAM;EAChB,OAAO,MAAM;EACb,KAAK,MAAM;EACX,OAAO,MAAM;EACb,MAAM,MAAM,GAAG,IAAI;EACnB,MAAM,MAAM"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diagnostics.d.ts","sources":["../diagnostics.ts"],"names":[],"mappings":"AASA,YAAY;EAAmB,OAAO,MAAM;EAAE,UAAU,MAAM"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Handlers } from "@yaks/effects";
|
|
2
|
+
import type { Host } from "@yaks/host";
|
|
3
|
+
import { type Opts } from "./local.js";
|
|
4
|
+
import { type Setup } from "./isolated.js";
|
|
5
|
+
/** What config says an exposed session's sandbox is (./isolated.ts): a
|
|
6
|
+
* bubblewrap sandbox under `dir` with `limits`, the read-only `binds` and
|
|
7
|
+
* the command `env`, holding the committed HEAD of `source` over what `setup`
|
|
8
|
+
* made of it, shared read-only (kept under `dir`'s `.layers`); the host
|
|
9
|
+
* `tools` it is offered by name; and the tools its lander is offered
|
|
10
|
+
* (`landing`). */ export type IsolationConfig = {
|
|
11
|
+
dir?: string;
|
|
12
|
+
archive?: string;
|
|
13
|
+
limits?: {
|
|
14
|
+
cpuQuota: number;
|
|
15
|
+
memoryMax: number;
|
|
16
|
+
tasksMax: number;
|
|
17
|
+
};
|
|
18
|
+
binds?: string[];
|
|
19
|
+
env?: Record<string, string>;
|
|
20
|
+
source?: string;
|
|
21
|
+
setup?: Setup;
|
|
22
|
+
tools?: string[];
|
|
23
|
+
landing?: string[];
|
|
24
|
+
};
|
|
25
|
+
/** The runner, lent this machine, over the host's graph. The plugin's options
|
|
26
|
+
* may name `compactAt`, the share of its model's context window a transcript
|
|
27
|
+
* fills before it is compacted (half where absent), and `starts`, the most
|
|
28
|
+
* sessions started on comments at work at once (two where absent); the model
|
|
29
|
+
* a session asks by default is graph data (./default.ts `defaultUsing`), and
|
|
30
|
+
* so is the one a project's work runs on (`usingFor`). `isolation`
|
|
31
|
+
* ({@link IsolationConfig}) is what a session outside words started works
|
|
32
|
+
* with instead of the host's tools. */ export declare let effects: (host: Host, options?: Record<string, unknown> & Pick<Opts, 'env' | 'http'> & {
|
|
33
|
+
isolation?: IsolationConfig;
|
|
34
|
+
}) => Handlers;
|
|
35
|
+
//# sourceMappingURL=effects.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"effects.d.ts","sources":["../effects.ts"],"names":[],"mappings":"AAiBA,cAAc,QAAQ,6BAAkC;AACxD,cAAc,IAAI,0BAA+B;AAOjD,SAAe,KAAK,IAAI,qBAAoB;AAG5C,SAIE,KAAK,KAAK,wBAEU;AAEtB;;;;;gBAKgB,GAChB,YAAY;EACV,MAAM,MAAM;EACZ,UAAU,MAAM;EAChB;IAAW,UAAU,MAAM;IAAE,WAAW,MAAM;IAAE,UAAU,MAAM;;EAChE,QAAQ,MAAM;EACd,MAAM,OAAO,MAAM,EAAE,MAAM;EAC3B,SAAS,MAAM;EACf,QAAQ;EACR,QAAQ,MAAM;EACd,UAAU,MAAM;;AA6BlB;;;;;;;qCAOqC,GACrC,OAAO,YAAI,UACT,MAAM,MACN,UAAS,OAAO,MAAM,EAAE,OAAO,IAAI,KAAK,MAAM,QAAQ;EACpD,YAAY;MAEb,SA4JF"}
|
package/_dist/http.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
type Client = {
|
|
2
|
+
close: () => void;
|
|
3
|
+
fetch?: typeof fetch;
|
|
4
|
+
};
|
|
5
|
+
/** A host-owned fetch pool, with an injectable connection seam. */ export declare let pooledHttp: (options?: {
|
|
6
|
+
fetch?: typeof fetch;
|
|
7
|
+
client?: () => Client;
|
|
8
|
+
}) => {
|
|
9
|
+
fetch: typeof fetch;
|
|
10
|
+
close: () => void;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=http.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sources":["../http.ts"],"names":[],"mappings":"KAMK;EAAW,aAAa,IAAI;EAAE,eAAe;;AAGlD,iEAAiE,GACjE,OAAO,YAAI,aAAc;EACvB,eAAe;EACf,eAAe;;EACN,cAAc;EAAO,aAAa,IAAI;EA2FhD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isolated.d.ts","sources":["../isolated.ts"],"names":[],"mappings":"AAyIA;gDACgD,GAChD,YAAY,QAAQ,MAAM;EAAK,SAAS,MAAM;EAAE,MAAM,MAAM"}
|