paseo-dsh-direct 0.2.3 → 0.2.4
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/OVERVIEW.md +1 -0
- package/README.md +1 -0
- package/README.zh.md +1 -0
- package/dsh.png +0 -0
- package/dsh.svg +2 -10
- package/package.json +1 -1
- package/scripts/build.mjs +2 -1
- package/server/dsh/host.ts +20 -0
- package/server/dsh/service.ts +83 -0
- package/server/provider.ts +9 -0
- package/shared/bridge-protocol.ts +19 -0
package/OVERVIEW.md
CHANGED
|
@@ -12,6 +12,7 @@ Runs DeepSeek Harness (`dsh`) as a native Paseo agent provider. Paseo clients (d
|
|
|
12
12
|
- Streaming assistant text and reasoning ("thinking") as Paseo timeline items.
|
|
13
13
|
- Tool calls with Paseo approval prompts, and `dsh` user questions answered from the Paseo UI.
|
|
14
14
|
- Create, resume, cancel and close sessions; model list and mode switching from the Paseo UI.
|
|
15
|
+
- Token usage and context-window fill in Paseo's usage meter.
|
|
15
16
|
- DSH branding (name and icon) in the provider list.
|
|
16
17
|
|
|
17
18
|
## Processes and environment
|
package/README.md
CHANGED
|
@@ -25,6 +25,7 @@ Most dsh integrations go through ACP, a generic protocol that every agent can sp
|
|
|
25
25
|
- Tool approvals and dsh's questions to you appear as Paseo's own approval and question cards.
|
|
26
26
|
- Your existing dsh sessions can be imported and resumed in Paseo.
|
|
27
27
|
- dsh's slash commands (`/compact`, `/plan`, ...) appear in Paseo's `/` menu.
|
|
28
|
+
- Paseo's usage meter shows dsh's token counts and how full the context window is.
|
|
28
29
|
|
|
29
30
|
## Versioning
|
|
30
31
|
|
package/README.zh.md
CHANGED
package/dsh.png
CHANGED
|
Binary file
|
package/dsh.svg
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0
|
|
2
|
-
<
|
|
3
|
-
<linearGradient id="wave" x1="8" y1="10" x2="56" y2="54" gradientUnits="userSpaceOnUse">
|
|
4
|
-
<stop stop-color="#6A8DFF"/>
|
|
5
|
-
<stop offset="1" stop-color="#3158E6"/>
|
|
6
|
-
</linearGradient>
|
|
7
|
-
</defs>
|
|
8
|
-
<path fill="url(#wave)" d="M8 34c7-13 18-20 33-20 6 0 11 1 15 4-2 13-8 23-18 29-8 5-17 6-27 3 7-2 12-6 15-11-7 2-13 0-18-5Z"/>
|
|
9
|
-
<circle cx="43" cy="25" r="3" fill="#fff"/>
|
|
10
|
-
<path d="M13 42c8 4 17 3 25-2" fill="none" stroke="#fff" stroke-width="3" stroke-linecap="round" opacity=".9"/>
|
|
1
|
+
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 50 50" fill="currentColor" role="img" aria-label="DeepSeek Harness">
|
|
2
|
+
<path fill-rule="nonzero" d="M48.8354 10.0479C48.3232 9.79199 48.1025 10.2798 47.8032 10.5278C47.7007 10.6079 47.6143 10.7119 47.5273 10.8076C46.7793 11.624 45.9048 12.1597 44.7622 12.0957C43.0923 12 41.666 12.5356 40.4058 13.8398C40.1377 12.2319 39.2476 11.272 37.8926 10.6558C37.1836 10.3359 36.4668 10.0156 35.9702 9.31982C35.6235 8.82373 35.5293 8.27197 35.356 7.72754C35.2456 7.3999 35.1353 7.06396 34.7651 7.00781C34.3633 6.94385 34.2056 7.2876 34.0479 7.57568C33.418 8.75195 33.1733 10.0479 33.1973 11.3599C33.2524 14.312 34.4736 16.6641 36.8999 18.3359C37.1758 18.5278 37.2466 18.7197 37.1597 19C36.9946 19.5757 36.7974 20.1357 36.624 20.7119C36.5137 21.0801 36.3486 21.1597 35.9624 21C34.6309 20.4321 33.481 19.5918 32.4644 18.5757C30.7393 16.8721 29.1792 14.9917 27.2334 13.52C26.7764 13.1758 26.3193 12.856 25.8467 12.5518C23.8618 10.584 26.1069 8.96777 26.627 8.77588C27.1704 8.57568 26.8159 7.8877 25.0591 7.896C23.3022 7.90381 21.6953 8.50391 19.647 9.30371C19.3477 9.42383 19.0322 9.51172 18.7095 9.58398C16.8501 9.22363 14.9199 9.14355 12.9033 9.37598C9.10596 9.80762 6.07275 11.6396 3.84326 14.7681C1.16455 18.5278 0.53418 22.7998 1.30664 27.2559C2.11768 31.9521 4.46582 35.8398 8.07373 38.8799C11.8159 42.0322 16.1255 43.5762 21.041 43.2803C24.0269 43.104 27.3516 42.6963 31.1016 39.4561C32.0469 39.936 33.0396 40.1279 34.686 40.272C35.9546 40.3921 37.1758 40.208 38.1211 40.0078C39.6021 39.688 39.4995 38.2881 38.9639 38.0322C34.623 35.9678 35.5762 36.8081 34.71 36.1279C36.9155 33.4639 40.2402 30.6958 41.54 21.728C41.6426 21.0161 41.5557 20.5679 41.54 19.9917C41.5322 19.6396 41.6108 19.5039 42.0049 19.4639C43.0923 19.3359 44.1479 19.0317 45.1167 18.4878C47.9292 16.9199 49.064 14.3438 49.3315 11.2559C49.3711 10.7837 49.3237 10.2959 48.8354 10.0479ZM24.3262 37.8398C20.1196 34.4639 18.0791 33.3521 17.2358 33.3999C16.4482 33.4482 16.5898 34.3682 16.7632 34.9678C16.9443 35.5601 17.1812 35.9683 17.5117 36.4878C17.7402 36.832 17.8979 37.3442 17.2832 37.728C15.9282 38.584 13.5728 37.4399 13.4624 37.3838C10.7207 35.7358 8.42822 33.5601 6.81348 30.584C5.25342 27.7197 4.34766 24.6479 4.19775 21.3677C4.1582 20.5757 4.38672 20.2959 5.15869 20.1519C6.17529 19.96 7.22314 19.9199 8.23926 20.0718C12.5327 20.7119 16.1885 22.6719 19.2529 25.7759C21.002 27.5439 22.3252 29.6558 23.6885 31.7202C25.1377 33.9121 26.6978 36 28.6831 37.7119C29.3843 38.312 29.9434 38.7681 30.479 39.104C28.8643 39.2881 26.1699 39.3281 24.3262 37.8398ZM26.3433 24.6001C26.3433 24.248 26.6191 23.9678 26.9658 23.9678C27.0444 23.9678 27.1152 23.9839 27.1782 24.0078C27.2651 24.04 27.3438 24.0879 27.4067 24.1602C27.5171 24.272 27.5801 24.4321 27.5801 24.6001C27.5801 24.9521 27.3042 25.2319 26.9575 25.2319C26.6108 25.2319 26.3433 24.9521 26.3433 24.6001ZM32.6064 27.8799C32.2046 28.0479 31.8027 28.1919 31.4165 28.208C30.8179 28.2397 30.1641 27.9922 29.8096 27.688C29.2583 27.2158 28.8643 26.9521 28.6987 26.1279C28.6279 25.7759 28.6675 25.2319 28.7305 24.9199C28.8721 24.248 28.7144 23.8159 28.2495 23.4238C27.8716 23.104 27.3911 23.0161 26.8633 23.0161C26.666 23.0161 26.4849 22.9277 26.3511 22.856C26.1304 22.7441 25.9492 22.4639 26.1226 22.1201C26.1777 22.0078 26.4458 21.7358 26.5088 21.688C27.2256 21.272 28.0527 21.4077 28.8169 21.7197C29.5259 22.0161 30.0615 22.5601 30.834 23.3281C31.6216 24.2559 31.7632 24.5117 32.2124 25.208C32.5669 25.752 32.8901 26.312 33.1104 26.9521C33.2446 27.3521 33.0713 27.6802 32.6064 27.8799Z"/>
|
|
11
3
|
</svg>
|
package/package.json
CHANGED
package/scripts/build.mjs
CHANGED
|
@@ -13,7 +13,8 @@ const result = await build({
|
|
|
13
13
|
write: false,
|
|
14
14
|
})
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
// esbuild reports output paths with the platform separator (backslashes on Windows).
|
|
17
|
+
const bridge = result.outputFiles.find(file => file.path.replace(/\\/g, '/').endsWith('/dsh-bridge.mjs'))
|
|
17
18
|
if (!bridge) throw new Error('esbuild did not produce dist/dsh-bridge.mjs')
|
|
18
19
|
await mkdir('dist', { recursive: true })
|
|
19
20
|
await writeFile('dist/dsh-bridge.mjs', bridge.contents)
|
package/server/dsh/host.ts
CHANGED
|
@@ -125,6 +125,26 @@ export interface HostServices {
|
|
|
125
125
|
}>;
|
|
126
126
|
};
|
|
127
127
|
agentDefaultModel: { currentSelection(): ModelSelection } | undefined;
|
|
128
|
+
/**
|
|
129
|
+
* Projection registry read cut. The `tokenUsage` and `contextPressure` units
|
|
130
|
+
* carry the figures Paseo renders as session usage; absent when the profile
|
|
131
|
+
* mounts no projection registry.
|
|
132
|
+
*/
|
|
133
|
+
sessionProjections?: {
|
|
134
|
+
snapshot(
|
|
135
|
+
session: HostSession,
|
|
136
|
+
keys?: readonly string[],
|
|
137
|
+
): { values: Partial<Record<string, unknown>> };
|
|
138
|
+
/** Change feed: fires once per client-visible unit whose raw view changed. */
|
|
139
|
+
onChanged(
|
|
140
|
+
listener: (
|
|
141
|
+
session: HostSession,
|
|
142
|
+
key: string,
|
|
143
|
+
value: unknown,
|
|
144
|
+
seq: number,
|
|
145
|
+
) => void,
|
|
146
|
+
): () => void;
|
|
147
|
+
};
|
|
128
148
|
sessionTitle:
|
|
129
149
|
{ rename(session: HostSession, title: string): void } | undefined;
|
|
130
150
|
approval: object | undefined;
|
package/server/dsh/service.ts
CHANGED
|
@@ -6,6 +6,7 @@ import type {
|
|
|
6
6
|
BridgeInitializeResult,
|
|
7
7
|
BridgeMethods,
|
|
8
8
|
BridgeNotifications,
|
|
9
|
+
BridgeUsage,
|
|
9
10
|
DshSessionEvent,
|
|
10
11
|
InteractionRequest,
|
|
11
12
|
ModelSelection,
|
|
@@ -25,6 +26,7 @@ import type {
|
|
|
25
26
|
HostHandle,
|
|
26
27
|
HostHelpers,
|
|
27
28
|
HostServices,
|
|
29
|
+
HostSession,
|
|
28
30
|
ModelSelectionRef,
|
|
29
31
|
} from "./host.js";
|
|
30
32
|
|
|
@@ -136,6 +138,8 @@ export class BridgeService {
|
|
|
136
138
|
private readonly preapproved = new Map<string, ReadonlySet<string>>();
|
|
137
139
|
private readonly interactions = new Map<string, PendingInteraction>();
|
|
138
140
|
private readonly subscriptions: Array<() => void> = [];
|
|
141
|
+
/** Last usage payload sent per session, so an unchanged fold is not re-sent. */
|
|
142
|
+
private readonly lastUsage = new Map<string, string>();
|
|
139
143
|
private stopping = false;
|
|
140
144
|
private stopTask?: Promise<{}>;
|
|
141
145
|
|
|
@@ -172,6 +176,19 @@ export class BridgeService {
|
|
|
172
176
|
notify("session.status", { sessionId: String(agent.id), status });
|
|
173
177
|
}),
|
|
174
178
|
);
|
|
179
|
+
// Usage rides the projection change feed rather than the session event
|
|
180
|
+
// stream: it fires exactly when the harness's token fold moves, so no
|
|
181
|
+
// session-event name has to be guessed and an idle session costs nothing.
|
|
182
|
+
const projections = ctx.get("sessionProjections");
|
|
183
|
+
if (projections) {
|
|
184
|
+
this.subscriptions.push(
|
|
185
|
+
projections.onChanged((session, key) => {
|
|
186
|
+
if (key === "tokenUsage" || key === "contextPressure") {
|
|
187
|
+
this.publishUsage(session);
|
|
188
|
+
}
|
|
189
|
+
}),
|
|
190
|
+
);
|
|
191
|
+
}
|
|
175
192
|
this.subscriptions.push(
|
|
176
193
|
ctx.on("approval/request", (request, next) => {
|
|
177
194
|
const sessionId = this.rootFor(request.agent);
|
|
@@ -216,6 +233,70 @@ export class BridgeService {
|
|
|
216
233
|
);
|
|
217
234
|
}
|
|
218
235
|
|
|
236
|
+
/**
|
|
237
|
+
* Fold the harness's token projections into Paseo's usage vocabulary.
|
|
238
|
+
*
|
|
239
|
+
* `tokenUsage` totals and `contextPressure` carry every figure Paseo can
|
|
240
|
+
* render, and both are plain numbers, so no live harness object crosses the
|
|
241
|
+
* wire. Returns undefined when no projection registry is mounted or neither
|
|
242
|
+
* unit is registered: a profile without them degrades to no usage rather
|
|
243
|
+
* than failing the turn.
|
|
244
|
+
*/
|
|
245
|
+
private readUsage(session: HostSession): BridgeUsage | undefined {
|
|
246
|
+
const projections = this.ctx.get("sessionProjections");
|
|
247
|
+
if (!projections) return undefined;
|
|
248
|
+
let values: Partial<Record<string, unknown>>;
|
|
249
|
+
try {
|
|
250
|
+
values = projections.snapshot(session, [
|
|
251
|
+
"tokenUsage",
|
|
252
|
+
"contextPressure",
|
|
253
|
+
]).values;
|
|
254
|
+
} catch {
|
|
255
|
+
return undefined;
|
|
256
|
+
}
|
|
257
|
+
const tokens = values.tokenUsage as
|
|
258
|
+
| {
|
|
259
|
+
uncachedInputTokens?: number;
|
|
260
|
+
outputTokens?: number;
|
|
261
|
+
cacheReadTokens?: number;
|
|
262
|
+
}
|
|
263
|
+
| undefined;
|
|
264
|
+
const pressure = values.contextPressure as
|
|
265
|
+
| { contextWindow?: number; pressureTokens?: number }
|
|
266
|
+
| undefined;
|
|
267
|
+
const usage: BridgeUsage = {};
|
|
268
|
+
if (typeof tokens?.uncachedInputTokens === "number")
|
|
269
|
+
usage.inputTokens = tokens.uncachedInputTokens;
|
|
270
|
+
if (typeof tokens?.cacheReadTokens === "number")
|
|
271
|
+
usage.cachedInputTokens = tokens.cacheReadTokens;
|
|
272
|
+
if (typeof tokens?.outputTokens === "number")
|
|
273
|
+
usage.outputTokens = tokens.outputTokens;
|
|
274
|
+
if (typeof pressure?.pressureTokens === "number")
|
|
275
|
+
usage.contextWindowUsedTokens = pressure.pressureTokens;
|
|
276
|
+
if (typeof pressure?.contextWindow === "number")
|
|
277
|
+
usage.contextWindowMaxTokens = pressure.contextWindow;
|
|
278
|
+
// The units materialize at zero before any provider usage lands, so a
|
|
279
|
+
// payload carrying no measured token is warm-up noise, not a reading.
|
|
280
|
+
const measured =
|
|
281
|
+
(usage.inputTokens ?? 0) > 0 ||
|
|
282
|
+
(usage.cachedInputTokens ?? 0) > 0 ||
|
|
283
|
+
(usage.outputTokens ?? 0) > 0 ||
|
|
284
|
+
(usage.contextWindowUsedTokens ?? 0) > 0;
|
|
285
|
+
return measured ? usage : undefined;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/** Publish one tracked session's usage, skipping an unchanged fold. */
|
|
289
|
+
private publishUsage(session: HostSession): void {
|
|
290
|
+
const sessionId = String(session.id);
|
|
291
|
+
if (!this.tracked.has(sessionId)) return;
|
|
292
|
+
const usage = this.readUsage(session);
|
|
293
|
+
if (!usage) return;
|
|
294
|
+
const signature = JSON.stringify(usage);
|
|
295
|
+
if (this.lastUsage.get(sessionId) === signature) return;
|
|
296
|
+
this.lastUsage.set(sessionId, signature);
|
|
297
|
+
this.notify("session.usage", { sessionId, usage });
|
|
298
|
+
}
|
|
299
|
+
|
|
219
300
|
private rootFor(agent: HostAgent | undefined): string | undefined {
|
|
220
301
|
let id = agent?.id && String(agent.id);
|
|
221
302
|
const seen = new Set<string>();
|
|
@@ -652,6 +733,7 @@ export class BridgeService {
|
|
|
652
733
|
this.opening.delete(id);
|
|
653
734
|
this.tracked.delete(id);
|
|
654
735
|
this.preapproved.delete(id);
|
|
736
|
+
this.lastUsage.delete(id);
|
|
655
737
|
},
|
|
656
738
|
);
|
|
657
739
|
return task;
|
|
@@ -800,6 +882,7 @@ export class BridgeService {
|
|
|
800
882
|
this.owned.delete(id);
|
|
801
883
|
this.tracked.delete(id);
|
|
802
884
|
this.preapproved.delete(id);
|
|
885
|
+
this.lastUsage.delete(id);
|
|
803
886
|
})();
|
|
804
887
|
this.closing.set(id, task);
|
|
805
888
|
void task.finally(() => this.closing.delete(id)).catch(() => undefined);
|
package/server/provider.ts
CHANGED
|
@@ -275,6 +275,15 @@ function listenToSessionBridge(
|
|
|
275
275
|
session.dispatch.deferred = terminal;
|
|
276
276
|
}
|
|
277
277
|
}),
|
|
278
|
+
session.bridge.on("session.usage", ({ sessionId, usage }) => {
|
|
279
|
+
if (!isCurrentSession(sessionId)) return;
|
|
280
|
+
emit({
|
|
281
|
+
type: "session.usage",
|
|
282
|
+
sessionId: session.paseoId,
|
|
283
|
+
...(session.activeTurnId ? { turnId: session.activeTurnId } : {}),
|
|
284
|
+
usage,
|
|
285
|
+
});
|
|
286
|
+
}),
|
|
278
287
|
session.bridge.on("interaction.request", (interaction) => {
|
|
279
288
|
if (!isCurrentSession(interaction.sessionId)) return;
|
|
280
289
|
session.pendingInteractions.set(interaction.requestId, interaction);
|
|
@@ -208,11 +208,30 @@ export interface BridgeMethods {
|
|
|
208
208
|
};
|
|
209
209
|
"bridge.shutdown": { params: {}; result: {} };
|
|
210
210
|
}
|
|
211
|
+
/**
|
|
212
|
+
* One session's token and context figures, in Paseo's usage vocabulary.
|
|
213
|
+
*
|
|
214
|
+
* Field names match `ProviderUsage` so the provider forwards this straight
|
|
215
|
+
* onto `session.usage` without a second translation table.
|
|
216
|
+
*/
|
|
217
|
+
export interface BridgeUsage {
|
|
218
|
+
/** Uncached prompt tokens reported by the provider. */
|
|
219
|
+
inputTokens?: number;
|
|
220
|
+
/** Prompt tokens served from the provider's cache. */
|
|
221
|
+
cachedInputTokens?: number;
|
|
222
|
+
/** Completion tokens produced by the model. */
|
|
223
|
+
outputTokens?: number;
|
|
224
|
+
/** Provider-reported prompt size of the newest request. */
|
|
225
|
+
contextWindowUsedTokens?: number;
|
|
226
|
+
/** Route context capacity paired with that pressure. */
|
|
227
|
+
contextWindowMaxTokens?: number;
|
|
228
|
+
}
|
|
211
229
|
export interface BridgeNotifications {
|
|
212
230
|
"bridge.ready": { protocolVersion: 1 };
|
|
213
231
|
"session.event": { sessionId: string; event: DshSessionEvent };
|
|
214
232
|
"session.stream": { sessionId: string; frame: DshStreamFrame };
|
|
215
233
|
"session.status": { sessionId: string; status: "idle" | "running" };
|
|
234
|
+
"session.usage": { sessionId: string; usage: BridgeUsage };
|
|
216
235
|
"interaction.request": InteractionRequest;
|
|
217
236
|
"interaction.closed": { requestId: string; sessionId: string };
|
|
218
237
|
}
|