@4fu/dsh-arbor-ui-workspace 0.0.0-stage → 2026.1110.0
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/LICENSE +21 -0
- package/README.md +234 -2
- package/client.js +294 -0
- package/index.d.ts +11 -0
- package/index.js +11 -0
- package/package.json +43 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 4fuu
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,235 @@
|
|
|
1
|
-
#
|
|
1
|
+
# dsh-arbor
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Run [arbor](https://github.com/4fuu/arbor) as the agent driver inside
|
|
4
|
+
[DeepSeek Harness](https://github.com/deepseek-ai/deepseek-harness) (DSH).
|
|
5
|
+
|
|
6
|
+
DSH gives a user a session, a transcript, approvals, plugins, skills and a model
|
|
7
|
+
picker. arbor gives an agent disposable context windows over one shared journal,
|
|
8
|
+
note store and workspace, instead of one long conversation. dsh-arbor connects
|
|
9
|
+
them: one arbor host runs inside the DSH process, each DSH session that selects
|
|
10
|
+
**Arbor** is served by that host, and the window's reply is written back to the
|
|
11
|
+
DSH session as an ordinary assistant message. A DSH session that does not select
|
|
12
|
+
Arbor keeps running on DSH's own embedded AgentLoop, in the same process.
|
|
13
|
+
|
|
14
|
+
> **Status.** This is a research-grade integration, not a DSH release. It is
|
|
15
|
+
> pinned to one DSH version and relies on DSH internals. Read
|
|
16
|
+
> [Versions and compatibility](docs/versions.md) before installing it on
|
|
17
|
+
> anything you care about. The packages are published under `@4fu` at
|
|
18
|
+
> `2026.1110.0`; the bundle and the font plugin install independently from npm.
|
|
19
|
+
|
|
20
|
+
## What an arbor session changes
|
|
21
|
+
|
|
22
|
+
Choosing **Arbor** in a DSH composer creates the session under the `arbor` agent
|
|
23
|
+
preset. That session then runs on arbor, and the following are true for it:
|
|
24
|
+
|
|
25
|
+
- **One window per turn, one chain per session.** A DSH session is one arbor
|
|
26
|
+
conversation: its first turn opens a window, a window that ends hands off to a
|
|
27
|
+
continuation, and the next turn drives the chain. The journal and note store
|
|
28
|
+
live under `$DSH_HOME/arbor/` and survive a restart.
|
|
29
|
+
- **arbor's workspace, not DSH's sandbox.** A window works in arbor's shared
|
|
30
|
+
folder (`$DSH_HOME/arbor/shared`). When the `ovnfs` binary is available a
|
|
31
|
+
window opens a copy-on-write checkout and merges back with `apply`; otherwise
|
|
32
|
+
arbor uses a plain directory. **There is no DSH sandbox for an arbor session:**
|
|
33
|
+
arbor's file tools and commands run on the host, and arbor's own secret scrub
|
|
34
|
+
is the only protection on what reaches the model.
|
|
35
|
+
- **arbor's projects.** The shared folder's project folders are the DSH project
|
|
36
|
+
list for arbor composers. A directory the user adds outside the shared folder
|
|
37
|
+
is recorded as an external pointer for that session and used in place.
|
|
38
|
+
- **arbor's prompt and tools.** DSH's official prompt sections are decided one by
|
|
39
|
+
one; the ones arbor replaces are absent, third-party sections go into a
|
|
40
|
+
`<dsh>` data block, and a trusted `<harness>` section says what remains true of
|
|
41
|
+
DSH. DSH tools are offered to the model as arbor external tools, and arbor's
|
|
42
|
+
own tools replace DSH tools with the same capability.
|
|
43
|
+
- **The Arbor page.** A permanent **Arbor** entry in DSH's left navigation opens
|
|
44
|
+
the whole-host overview and one tab per arbor session: windows, chains,
|
|
45
|
+
handoffs, projects, the board, notes, `/env`, schedules and arbor's search.
|
|
46
|
+
An arbor composer hides DSH's sandbox access-mode switch, because that switch
|
|
47
|
+
does not apply to it.
|
|
48
|
+
|
|
49
|
+
## What stays untouched in ordinary DSH sessions
|
|
50
|
+
|
|
51
|
+
A session that does not select Arbor is an ordinary DSH session. It keeps:
|
|
52
|
+
|
|
53
|
+
- DSH's embedded AgentLoop, session format, turn boundaries and streaming path;
|
|
54
|
+
- DSH's sandbox policy and its `ctx.fs` / `ctx.shell` file and command tools;
|
|
55
|
+
- DSH's project management, working directory and prompt assembly;
|
|
56
|
+
- its composer, sandbox access-mode switch, header and sidebar behavior.
|
|
57
|
+
|
|
58
|
+
It gets **no Arbor tab** and no arbor windows. The only shared surface is the
|
|
59
|
+
permanent Arbor entry in the left navigation, which simply does not list that
|
|
60
|
+
session. The routing registry replaces DSH's base `agent` row so it can send
|
|
61
|
+
`agentPreset: 'arbor'` sessions to arbor; every other session goes to the
|
|
62
|
+
official loop. Approvals still use DSH's approval path for both kinds of
|
|
63
|
+
session, and arbor's windows are registered so DSH's sidebar leaves them out.
|
|
64
|
+
|
|
65
|
+
## Screenshots
|
|
66
|
+
|
|
67
|
+
| Overview, light | Overview, dark |
|
|
68
|
+
| --- | --- |
|
|
69
|
+
|  |  |
|
|
70
|
+
| **Session tab, light** | **Session tab, dark** |
|
|
71
|
+
|  |  |
|
|
72
|
+
|
|
73
|
+
These are the web profile at 1440 px wide with the optional
|
|
74
|
+
[font plugin](https://github.com/4fuu/dsh-arbor-fonts) installed: ChillDIN
|
|
75
|
+
Gothic for labels and ChillDIN for numerals, while body text and code keep
|
|
76
|
+
DSH's fonts. The same overview without the plugin is
|
|
77
|
+
[here](docs/screenshots/overview-without-fonts.png).
|
|
78
|
+
|
|
79
|
+
## Install
|
|
80
|
+
|
|
81
|
+
Requirements: Node.js 24.9 or newer and DeepSeek Harness `dsh-v0.2.2-rc.1`.
|
|
82
|
+
The bundle is published with all packages it depends on; nothing has to be
|
|
83
|
+
built or linked.
|
|
84
|
+
|
|
85
|
+
```bash
|
|
86
|
+
npm install -g @deepseek-ai/dsh@0.2.2-rc.1
|
|
87
|
+
dsh plugin --profile web add @4fu/dsh-arbor-bundle@2026.1110.0
|
|
88
|
+
dsh web
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
`dsh plugin` adds the bundle to the profile's `dsh.profile.bundles` and installs
|
|
92
|
+
its packages into the profile. Pick **Arbor** in a composer and send a message.
|
|
93
|
+
The optional [font plugin](https://github.com/4fuu/dsh-arbor-fonts) installs the
|
|
94
|
+
same way:
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
dsh plugin --profile web add @4fu/dsh-arbor-fonts@2026.1110.0
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### From a checkout
|
|
101
|
+
|
|
102
|
+
The proofs and development use the TypeScript sources directly; that checkout is
|
|
103
|
+
what the scripts and the pin check run against.
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
git clone https://github.com/4fuu/dsh-arbor
|
|
107
|
+
cd dsh-arbor
|
|
108
|
+
pnpm install --frozen-lockfile
|
|
109
|
+
pnpm check # tsc --noEmit over every package and proof
|
|
110
|
+
pnpm proofs # 29 proofs against the scripted model
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
The first install may ask pnpm to approve dependency build scripts. Do not
|
|
114
|
+
approve them by hand: the repository's `pnpm-workspace.yaml` already denies the
|
|
115
|
+
six scripts it pulls in, each with the reason, and `pnpm install` finishes
|
|
116
|
+
cleanly with that policy.
|
|
117
|
+
|
|
118
|
+
### Hand the install to a model
|
|
119
|
+
|
|
120
|
+
[docs/install-for-agents.md](docs/install-for-agents.md) is a step-by-step guide
|
|
121
|
+
written for an AI agent: install from npm or a checkout, run the proofs, drive a
|
|
122
|
+
live turn with a restart, boot the web profile, and inspect what ran. Give a
|
|
123
|
+
model this prompt, editing the bracketed parts or dropping them:
|
|
124
|
+
|
|
125
|
+
```text copy Copy Install Prompt
|
|
126
|
+
Install dsh-arbor (https://github.com/4fuu/dsh-arbor) in this environment [in a
|
|
127
|
+
scratch DSH home under /tmp] and show me that it works: follow
|
|
128
|
+
docs/install-for-agents.md, install @4fu/dsh-arbor-bundle@2026.1110.0 into a DSH
|
|
129
|
+
web profile, pick Arbor for one session, and [also run the proof suite from a
|
|
130
|
+
checkout with pnpm install --frozen-lockfile, pnpm check and pnpm proofs]. Report
|
|
131
|
+
which checks passed, what the live session answered, and anything that did not
|
|
132
|
+
work. Fix only what is yours to fix and tell me what you changed.
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Use it in DSH
|
|
136
|
+
|
|
137
|
+
The npm install above adds the bundle to a DSH web profile. Pick **Arbor** in a
|
|
138
|
+
composer and send a message: the session is created under the preset, its window
|
|
139
|
+
and chain appear under the **Arbor** entry, and an ordinary session started
|
|
140
|
+
beside it keeps DSH's own composer and sandbox behavior. A checkout can also be
|
|
141
|
+
wired by hand; [section 7 of the install guide](docs/install-for-agents.md#7-wiring-the-bundle-into-a-real-dsh-installation)
|
|
142
|
+
shows the profile layout.
|
|
143
|
+
|
|
144
|
+
The one-shot `dsh <task>` runner cannot drive an arbor-preset session: DSH's
|
|
145
|
+
runner refuses to adopt a session that runs under a preset. Use the web client,
|
|
146
|
+
the SDK path the proofs use, or a remote `agent-preset/select` on a blank.
|
|
147
|
+
|
|
148
|
+
## Pinned DSH version
|
|
149
|
+
|
|
150
|
+
DSH is pinned to **`dsh-v0.2.2-rc.1`** (npm
|
|
151
|
+
`@deepseek-ai/dsh@0.2.2-rc.1`, commit `66491b05e3` of
|
|
152
|
+
`deepseek-ai/deepseek-harness`). Every `@deepseek-ai/dsh*` dependency is an
|
|
153
|
+
exact version, every package under `packages/` declares
|
|
154
|
+
`engines.dsh: 0.2.2-rc.1`, and `pnpm check:pin` checks both plus the prompt
|
|
155
|
+
bridge's `DSH_PINNED_VERSION`.
|
|
156
|
+
|
|
157
|
+
A different DSH version is unsupported. The bundle depends on DSH's row names,
|
|
158
|
+
its one-`AgentFactory` rule, its prompt-section registry, its client slot
|
|
159
|
+
registration and its exact Fetch registry; a move in any of them can fail the
|
|
160
|
+
boot, leave an official prompt section undecided, or stop the Arbor page from
|
|
161
|
+
registering. `proofs/12-official-sections.ts` and `proofs/18-picker-pin.ts`
|
|
162
|
+
are the behavioral checks. The canonical pin and the upgrade procedure are in
|
|
163
|
+
[Versions and compatibility](docs/versions.md).
|
|
164
|
+
|
|
165
|
+
## Optional: the font plugin
|
|
166
|
+
|
|
167
|
+
[dsh-arbor-fonts](https://github.com/4fuu/dsh-arbor-fonts) is a separate DSH
|
|
168
|
+
client plugin that changes only the typography of the Arbor page. It sets
|
|
169
|
+
ChillDIN Gothic for display labels and ChillDIN for numerals, leaves body text
|
|
170
|
+
and code on DSH's fonts, and does nothing on ordinary pages. It is optional and
|
|
171
|
+
installs into the same DSH profile:
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
dsh plugin --profile web add @4fu/dsh-arbor-fonts@2026.1110.0
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
The fonts are licensed under the SIL Open Font License 1.1; the plugin ships the
|
|
178
|
+
license text, per-file hashes and attribution.
|
|
179
|
+
|
|
180
|
+
## Limits worth knowing
|
|
181
|
+
|
|
182
|
+
- The judge is off: a model-based judge cannot run through the DSH backend yet.
|
|
183
|
+
- The 12 bundle packages are published together at one version; install and
|
|
184
|
+
upgrade the bundle as a unit, because its packages name each other exactly.
|
|
185
|
+
- `ovnfs` is optional. Without it arbor uses the plain-directory workspace, and a
|
|
186
|
+
window no longer gets a copy-on-write checkout.
|
|
187
|
+
- The web page's numbers and layout are read from arbor's journal and API; it is
|
|
188
|
+
not a generic DSH dashboard, and it deliberately shows only arbor sessions.
|
|
189
|
+
- The prompt bridge, the UI and the picker filter are pinned to DSH's internals,
|
|
190
|
+
not to a stable public API. See [Versions and compatibility](docs/versions.md).
|
|
191
|
+
|
|
192
|
+
## Documentation
|
|
193
|
+
|
|
194
|
+
- [Installing and inspecting dsh-arbor](docs/install-for-agents.md) — the
|
|
195
|
+
agent-facing install, proof, live-turn, web-profile and wiring guide.
|
|
196
|
+
- [Versions and compatibility](docs/versions.md) — the DSH and arbor pins, and
|
|
197
|
+
what breaks on another DSH version.
|
|
198
|
+
- [B0 findings](docs/b0-findings.md), [B3 findings](docs/b3-findings.md) and
|
|
199
|
+
[B3b projects and sandbox](docs/b3b-projects-and-sandbox.md) — historical
|
|
200
|
+
records of the integration's decisions, with the DSH source locations each
|
|
201
|
+
one rests on. They describe earlier stages; the install guide is the current
|
|
202
|
+
status.
|
|
203
|
+
- [Layout and proofs](#layout) below for a quick map of the packages.
|
|
204
|
+
|
|
205
|
+
## Layout
|
|
206
|
+
|
|
207
|
+
```text
|
|
208
|
+
packages/
|
|
209
|
+
arbor-host/ one Arbor host per process: SQLite journal and notes,
|
|
210
|
+
settings, window lifecycle, workspace and environment
|
|
211
|
+
arbor-driver/ the routing AgentRegistry, AgentFactory, session agent,
|
|
212
|
+
inbox and stream mirrors, and the journal relay
|
|
213
|
+
arbor-llm/ the arbor AgentBackend over DSH's ctx.llm and ctx.tools
|
|
214
|
+
arbor-prompt/ <harness>, the <dsh> data block, and the section table
|
|
215
|
+
arbor-tools/ DSH tools as arbor external tools, same-name replacement
|
|
216
|
+
arbor-workspace/ arbor's workspace over the shared folder (ovnfs or dir)
|
|
217
|
+
arbor-env/ /env, with DSH's skills and MCP servers mounted read-only
|
|
218
|
+
arbor-bundle/ the installable patch that mounts the rows and UI
|
|
219
|
+
arbor-facts/ the read face behind the Arbor page and its Fetch routes
|
|
220
|
+
arbor-ui/ the Arbor page, session tabs, copy and composer gate
|
|
221
|
+
arbor-ui-workspace/
|
|
222
|
+
the per-preset hero project picker
|
|
223
|
+
arbor-preset/ the agent-preset row that puts Arbor in the roster
|
|
224
|
+
arbor-testkit/ the boot harness, memory journal and scripted model
|
|
225
|
+
patches/ overlay layers a proof applies above the shipped profile
|
|
226
|
+
proofs/ one runnable proof per integration point
|
|
227
|
+
docs/ install, versions, screenshots and historical findings
|
|
228
|
+
scripts/ the DSH pin check, the release build and the publish dry run
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
## License
|
|
232
|
+
|
|
233
|
+
MIT. See [LICENSE](LICENSE). The optional font plugin vendors fonts under the
|
|
234
|
+
SIL Open Font License 1.1; its repository carries the license text and
|
|
235
|
+
attribution.
|
package/client.js
ADDED
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({
|
|
2
|
+
id: "@4fu/dsh-arbor-ui-workspace",
|
|
3
|
+
factory: (require) => {
|
|
4
|
+
var module = { exports: {} };
|
|
5
|
+
var exports = module.exports;
|
|
6
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
7
|
+
|
|
8
|
+
"use strict";
|
|
9
|
+
var __defProp = Object.defineProperty;
|
|
10
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
11
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
12
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
13
|
+
var __export = (target, all) => {
|
|
14
|
+
for (var name in all)
|
|
15
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
16
|
+
};
|
|
17
|
+
var __copyProps = (to, from, except, desc) => {
|
|
18
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
19
|
+
for (let key of __getOwnPropNames(from))
|
|
20
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
21
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
22
|
+
}
|
|
23
|
+
return to;
|
|
24
|
+
};
|
|
25
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
26
|
+
|
|
27
|
+
// src/client.ts
|
|
28
|
+
var client_exports = {};
|
|
29
|
+
__export(client_exports, {
|
|
30
|
+
apply: () => apply,
|
|
31
|
+
inject: () => inject
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(client_exports);
|
|
34
|
+
var import_react = require("react");
|
|
35
|
+
var PICKER_SLOT = "conversation.hero.workspace";
|
|
36
|
+
var HERO_SEAT_SLOT = "conversation.hero.agentPreset";
|
|
37
|
+
var SIDEBAR_SLOT = "sidebar.workspaces";
|
|
38
|
+
var ARBOR_PRESET = "arbor";
|
|
39
|
+
var PRESET_PROJECTION = "agentPreset";
|
|
40
|
+
var ARBOR_MARK = "\uFF08Arbor\uFF09";
|
|
41
|
+
var POLL_MS = 40;
|
|
42
|
+
var MAX_POLLS = 500;
|
|
43
|
+
var NAVIGATION_SERVICE = "uiWorkspace";
|
|
44
|
+
var CARRY_MS = 2e3;
|
|
45
|
+
var PRESET_WAIT_MS = 2e3;
|
|
46
|
+
var PRESET_POLL_MS = 25;
|
|
47
|
+
function useMainSessionId(props) {
|
|
48
|
+
const useSessions = props["useSessions"];
|
|
49
|
+
return useSessions?.((state) => {
|
|
50
|
+
for (const [id, row] of Object.entries(state.byId)) {
|
|
51
|
+
if ((row.retainedBy?.mainView ?? 0) > 0) return id;
|
|
52
|
+
}
|
|
53
|
+
return void 0;
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
function useProjectionOf(props) {
|
|
57
|
+
const useProjection = props["useProjection"];
|
|
58
|
+
return useProjection?.(PRESET_PROJECTION);
|
|
59
|
+
}
|
|
60
|
+
var inject = [
|
|
61
|
+
"contextMenus",
|
|
62
|
+
"slots",
|
|
63
|
+
"sessions",
|
|
64
|
+
"workspaces",
|
|
65
|
+
"locale",
|
|
66
|
+
"remote",
|
|
67
|
+
"remote.directoryPicker",
|
|
68
|
+
"layout",
|
|
69
|
+
"shortcuts",
|
|
70
|
+
"remoteAccess"
|
|
71
|
+
];
|
|
72
|
+
function isArborProject(path) {
|
|
73
|
+
const segments = path.split(/[\\/]/).filter((segment) => segment !== "");
|
|
74
|
+
for (let index = 0; index + 1 < segments.length; index++) {
|
|
75
|
+
if (segments[index] === "arbor" && segments[index + 1] === "shared") return true;
|
|
76
|
+
}
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
var EXTERNAL_MARK = "\uFF08\u5916\u90E8\uFF09";
|
|
80
|
+
function filterRows(rows, preset) {
|
|
81
|
+
if (preset === ARBOR_PRESET) {
|
|
82
|
+
return rows.map((row) => isArborProject(row.path) ? row : { ...row, title: `${row.title}${EXTERNAL_MARK}` });
|
|
83
|
+
}
|
|
84
|
+
return rows.filter((row) => !isArborProject(row.path));
|
|
85
|
+
}
|
|
86
|
+
var cached;
|
|
87
|
+
function filterState(state, preset) {
|
|
88
|
+
if (cached !== void 0 && cached.state === state && cached.preset === preset) return cached.result;
|
|
89
|
+
const result = { ...state, items: filterRows(state.items, preset) };
|
|
90
|
+
cached = { state, preset, result };
|
|
91
|
+
return result;
|
|
92
|
+
}
|
|
93
|
+
var markedCache;
|
|
94
|
+
function markState(state) {
|
|
95
|
+
if (markedCache !== void 0 && markedCache.state === state) return markedCache.result;
|
|
96
|
+
const result = {
|
|
97
|
+
...state,
|
|
98
|
+
items: state.items.map((row) => isArborProject(row.path) ? { ...row, title: `${row.title}${ARBOR_MARK}` } : row)
|
|
99
|
+
};
|
|
100
|
+
markedCache = { state, result };
|
|
101
|
+
return result;
|
|
102
|
+
}
|
|
103
|
+
function apply(ctx) {
|
|
104
|
+
const slots = ctx.slots;
|
|
105
|
+
let heroInject;
|
|
106
|
+
let unboundSeat;
|
|
107
|
+
const heroSeatFor = (sessionId) => {
|
|
108
|
+
if (heroInject === void 0) return void 0;
|
|
109
|
+
if (sessionId === void 0) {
|
|
110
|
+
unboundSeat ??= heroInject()?.hooks?.agentPresetSeat;
|
|
111
|
+
return unboundSeat;
|
|
112
|
+
}
|
|
113
|
+
return heroInject(sessionId)?.hooks?.agentPresetSeat;
|
|
114
|
+
};
|
|
115
|
+
let poll;
|
|
116
|
+
let attempts = 0;
|
|
117
|
+
let adoptWrapped = false;
|
|
118
|
+
let restoreWrapped = false;
|
|
119
|
+
const stop = () => {
|
|
120
|
+
if (poll !== void 0) {
|
|
121
|
+
clearInterval(poll);
|
|
122
|
+
poll = void 0;
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
const look = () => {
|
|
126
|
+
if (++attempts > MAX_POLLS) {
|
|
127
|
+
stop();
|
|
128
|
+
return;
|
|
129
|
+
}
|
|
130
|
+
if (heroInject === void 0) {
|
|
131
|
+
const face = slots.entriesOfSlot?.(HERO_SEAT_SLOT)[0]?.inject;
|
|
132
|
+
if (typeof face === "function") heroInject = face;
|
|
133
|
+
}
|
|
134
|
+
if (!adoptWrapped || !restoreWrapped) {
|
|
135
|
+
const navigation = ctx.get(NAVIGATION_SERVICE);
|
|
136
|
+
if (navigation !== void 0) {
|
|
137
|
+
if (!adoptWrapped) {
|
|
138
|
+
wrapAdopt();
|
|
139
|
+
adoptWrapped = true;
|
|
140
|
+
}
|
|
141
|
+
if (!restoreWrapped) {
|
|
142
|
+
wrapRestoreBlank();
|
|
143
|
+
restoreWrapped = true;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
if (heroInject !== void 0 && adoptWrapped && restoreWrapped) stop();
|
|
148
|
+
};
|
|
149
|
+
ctx.effect(() => () => {
|
|
150
|
+
stop();
|
|
151
|
+
}, "dsh-arbor-ui-workspace: stop the hero-seat poll");
|
|
152
|
+
poll = setInterval(look, POLL_MS);
|
|
153
|
+
function usePresetPick(sessionId, projected) {
|
|
154
|
+
const bound = heroSeatFor(sessionId);
|
|
155
|
+
const unbound = heroSeatFor(void 0);
|
|
156
|
+
return (0, import_react.useSyncExternalStore)(
|
|
157
|
+
(onChange) => {
|
|
158
|
+
const stops = [bound, unbound].map((store) => store?.subscribe(onChange));
|
|
159
|
+
return () => {
|
|
160
|
+
for (const halt of stops) halt?.();
|
|
161
|
+
};
|
|
162
|
+
},
|
|
163
|
+
() => {
|
|
164
|
+
const picks = [bound, unbound].map((store) => store?.getSnapshot().current);
|
|
165
|
+
return picks.find((pick) => pick === ARBOR_PRESET) ?? picks.find((pick) => pick !== void 0 && pick !== "") ?? (typeof projected === "string" ? projected : void 0);
|
|
166
|
+
}
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
const sessions = ctx.sessions;
|
|
170
|
+
const mainSession = () => {
|
|
171
|
+
const byId = sessions?.list.getSnapshot().byId ?? {};
|
|
172
|
+
for (const id of Object.keys(byId)) {
|
|
173
|
+
if ((byId[id]?.retainedBy?.mainView ?? 0) > 0) return byId[id];
|
|
174
|
+
}
|
|
175
|
+
return void 0;
|
|
176
|
+
};
|
|
177
|
+
const currentPick = () => {
|
|
178
|
+
const bound = heroSeatFor(mainSession()?.id);
|
|
179
|
+
const unbound = heroSeatFor(void 0);
|
|
180
|
+
const picks = [bound, unbound].map((store) => store?.getSnapshot().current);
|
|
181
|
+
return picks[0] !== void 0 && picks[0] !== "" ? picks[0] : picks.find((pick) => pick !== void 0 && pick !== "");
|
|
182
|
+
};
|
|
183
|
+
const heroFaceNow = (sessionId) => {
|
|
184
|
+
const face = slots.entriesOfSlot?.(HERO_SEAT_SLOT)[0]?.inject;
|
|
185
|
+
return typeof face === "function" ? face(sessionId) : void 0;
|
|
186
|
+
};
|
|
187
|
+
const workspaceRow = (workspaceId) => {
|
|
188
|
+
const items = ctx.get("workspaces");
|
|
189
|
+
return items?.list.getSnapshot().items.find((item) => item.workspaceId === workspaceId);
|
|
190
|
+
};
|
|
191
|
+
const reaskPick = (before) => {
|
|
192
|
+
const deadline = Date.now() + CARRY_MS;
|
|
193
|
+
const settle = () => {
|
|
194
|
+
const main = mainSession();
|
|
195
|
+
if (main === void 0 || main.blank !== true) return;
|
|
196
|
+
if (main.id === before && Date.now() < deadline) {
|
|
197
|
+
setTimeout(settle, POLL_MS);
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
if (main.projectionValues?.agentPreset !== ARBOR_PRESET) {
|
|
201
|
+
heroFaceNow(main.id)?.select?.(ARBOR_PRESET);
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
setTimeout(settle, POLL_MS);
|
|
205
|
+
};
|
|
206
|
+
const wrapAdopt = () => {
|
|
207
|
+
const navigation = ctx.get(NAVIGATION_SERVICE);
|
|
208
|
+
if (navigation === void 0 || typeof navigation.openWorkspace !== "function") return;
|
|
209
|
+
if (navigation.__arborAdopt === true) return;
|
|
210
|
+
const original2 = navigation.openWorkspace.bind(navigation);
|
|
211
|
+
navigation.openWorkspace = (workspaceId, beforeOpen, options) => {
|
|
212
|
+
const pick = currentPick();
|
|
213
|
+
const row = workspaceRow(workspaceId);
|
|
214
|
+
const createTakesIt = pick === ARBOR_PRESET && row !== void 0;
|
|
215
|
+
const before = mainSession()?.id;
|
|
216
|
+
const outcome = original2(workspaceId, beforeOpen, createTakesIt ? { agentPreset: pick } : options);
|
|
217
|
+
if (pick === ARBOR_PRESET && !createTakesIt) reaskPick(before);
|
|
218
|
+
return outcome;
|
|
219
|
+
};
|
|
220
|
+
Object.defineProperty(navigation, "__arborAdopt", { value: true, configurable: true });
|
|
221
|
+
ctx.effect(() => () => {
|
|
222
|
+
navigation.openWorkspace = original2;
|
|
223
|
+
delete navigation.__arborAdopt;
|
|
224
|
+
}, "dsh-arbor-ui-workspace: restore uiWorkspace.openWorkspace");
|
|
225
|
+
};
|
|
226
|
+
const presetInList = (sessionId) => {
|
|
227
|
+
const sessions2 = ctx.get("sessions");
|
|
228
|
+
const recorded = sessions2?.list.getSnapshot().byId[sessionId]?.projectionValues?.agentPreset;
|
|
229
|
+
return typeof recorded === "string" ? recorded : void 0;
|
|
230
|
+
};
|
|
231
|
+
const recordedPreset = async (sessionId) => {
|
|
232
|
+
const sessions2 = ctx.get("sessions");
|
|
233
|
+
if (sessions2 === void 0) return void 0;
|
|
234
|
+
const deadline = Date.now() + PRESET_WAIT_MS;
|
|
235
|
+
for (; ; ) {
|
|
236
|
+
const recorded = presetInList(sessionId);
|
|
237
|
+
if (recorded !== void 0) return recorded;
|
|
238
|
+
if (Date.now() >= deadline) return void 0;
|
|
239
|
+
await sessions2.refreshProjections(sessionId).catch(() => void 0);
|
|
240
|
+
const after = presetInList(sessionId);
|
|
241
|
+
if (after !== void 0) return after;
|
|
242
|
+
await new Promise((resolve) => setTimeout(resolve, PRESET_POLL_MS));
|
|
243
|
+
}
|
|
244
|
+
};
|
|
245
|
+
const wrapRestoreBlank = () => {
|
|
246
|
+
const navigation = ctx.get(NAVIGATION_SERVICE);
|
|
247
|
+
if (navigation === void 0 || typeof navigation.restoreBlank !== "function") return;
|
|
248
|
+
const original2 = navigation.restoreBlank.bind(navigation);
|
|
249
|
+
navigation.restoreBlank = async (workspaceId, sessionId) => {
|
|
250
|
+
await recordedPreset(sessionId);
|
|
251
|
+
return original2(workspaceId, sessionId);
|
|
252
|
+
};
|
|
253
|
+
ctx.effect(() => () => {
|
|
254
|
+
navigation.restoreBlank = original2;
|
|
255
|
+
}, "dsh-arbor-ui-workspace: restore uiWorkspace.restoreBlank");
|
|
256
|
+
};
|
|
257
|
+
const gate = (shipped) => (props) => {
|
|
258
|
+
const sessionId = useMainSessionId(props);
|
|
259
|
+
const preset = usePresetPick(sessionId, useProjectionOf(props));
|
|
260
|
+
const useWorkspaces = props["useWorkspaces"];
|
|
261
|
+
const filtered = (selector) => useWorkspaces === void 0 ? void 0 : selector(filterState(useWorkspaces((state) => state), preset));
|
|
262
|
+
return (0, import_react.createElement)(shipped, {
|
|
263
|
+
...props,
|
|
264
|
+
useWorkspaces: filtered
|
|
265
|
+
});
|
|
266
|
+
};
|
|
267
|
+
const marked = (shipped) => (props) => {
|
|
268
|
+
const useWorkspaces = props["useWorkspaces"];
|
|
269
|
+
const marking = (selector) => useWorkspaces === void 0 ? void 0 : selector(markState(useWorkspaces((state) => state)));
|
|
270
|
+
return (0, import_react.createElement)(shipped, {
|
|
271
|
+
...props,
|
|
272
|
+
useWorkspaces: marking
|
|
273
|
+
});
|
|
274
|
+
};
|
|
275
|
+
const original = slots.register.bind(slots);
|
|
276
|
+
const register = (options, component) => {
|
|
277
|
+
if (options.name === PICKER_SLOT) {
|
|
278
|
+
return original(options, gate(component));
|
|
279
|
+
}
|
|
280
|
+
if (options.name === SIDEBAR_SLOT) {
|
|
281
|
+
return original(options, marked(component));
|
|
282
|
+
}
|
|
283
|
+
return original(options, component);
|
|
284
|
+
};
|
|
285
|
+
Object.defineProperty(slots, "register", { value: register, configurable: true, writable: true });
|
|
286
|
+
ctx.effect(() => () => {
|
|
287
|
+
delete slots.register;
|
|
288
|
+
}, "dsh-arbor-ui-workspace: restore slots.register");
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
return module.exports;
|
|
292
|
+
}
|
|
293
|
+
});
|
|
294
|
+
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The dsh-arbor-ui-workspace node half.
|
|
3
|
+
*
|
|
4
|
+
* The empty host `apply` exists only so the plugin appears in the host
|
|
5
|
+
* cordis.yml / Loader: every behavior lives in the browser half
|
|
6
|
+
* (`exports["./client"]`), which the client module graph discovers from this
|
|
7
|
+
* package's `dsh.client` declaration. There is nothing to do on the host — the
|
|
8
|
+
* picker filter is a slot registration, which is browser state.
|
|
9
|
+
*/
|
|
10
|
+
/** Host plugin body — no host-side behavior for this surface plugin. */
|
|
11
|
+
export declare function apply(): void;
|
package/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The dsh-arbor-ui-workspace node half.
|
|
3
|
+
*
|
|
4
|
+
* The empty host `apply` exists only so the plugin appears in the host
|
|
5
|
+
* cordis.yml / Loader: every behavior lives in the browser half
|
|
6
|
+
* (`exports["./client"]`), which the client module graph discovers from this
|
|
7
|
+
* package's `dsh.client` declaration. There is nothing to do on the host — the
|
|
8
|
+
* picker filter is a slot registration, which is browser state.
|
|
9
|
+
*/
|
|
10
|
+
/** Host plugin body — no host-side behavior for this surface plugin. */
|
|
11
|
+
export function apply() { }
|
package/package.json
CHANGED
|
@@ -1,6 +1,45 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@4fu/dsh-arbor-ui-workspace",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
3
|
+
"version": "2026.1110.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "The dsh-arbor browser package for the project picker: arbor's shared-folder projects are listed for an arbor session only, and a directory outside them is marked external",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"types": "./index.d.ts",
|
|
9
|
+
"default": "./index.js"
|
|
10
|
+
},
|
|
11
|
+
"./client": "./client.js",
|
|
12
|
+
"./package.json": "./package.json"
|
|
13
|
+
},
|
|
14
|
+
"files": [
|
|
15
|
+
"client.js",
|
|
16
|
+
"index.d.ts",
|
|
17
|
+
"index.js"
|
|
18
|
+
],
|
|
19
|
+
"dsh": {
|
|
20
|
+
"client": {
|
|
21
|
+
"inject": [
|
|
22
|
+
"@deepseek-ai/dsh-client-ui-workspace"
|
|
23
|
+
],
|
|
24
|
+
"platform": "web"
|
|
25
|
+
}
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@deepseek-ai/cordis": "4.1.0"
|
|
29
|
+
},
|
|
30
|
+
"license": "MIT",
|
|
31
|
+
"repository": {
|
|
32
|
+
"type": "git",
|
|
33
|
+
"url": "git+https://github.com/4fuu/dsh-arbor.git",
|
|
34
|
+
"directory": "packages/arbor-ui-workspace"
|
|
35
|
+
},
|
|
36
|
+
"engines": {
|
|
37
|
+
"node": ">=24.9.0",
|
|
38
|
+
"dsh": "0.2.2-rc.1"
|
|
39
|
+
},
|
|
40
|
+
"publishConfig": {
|
|
41
|
+
"access": "public"
|
|
42
|
+
},
|
|
43
|
+
"types": "./index.d.ts",
|
|
44
|
+
"main": "./index.js"
|
|
45
|
+
}
|