dsh-agent-plugins-market 0.12.0 → 0.12.1
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/lib/packages/market-bundle/src/application/catalog.js +12 -3
- package/lib/packages/market-bundle/src/index.js +29 -19
- package/lib/packages/market-runtime/src/runtime/core/source-auto-update.js +27 -9
- package/lib/packages/market-runtime/src/runtime/host/extension-session-state.js +36 -5
- package/lib/packages/market-translation/src/application/translation/localizer.js +10 -1
- package/lib/packages/market-translation/src/application/translation/service.js +6 -2
- package/lib/types/packages/market-bundle/src/application/catalog.d.ts +11 -2
- package/lib/types/packages/market-runtime/src/runtime/core/source-auto-update.d.ts +17 -3
- package/lib/types/packages/market-runtime/src/runtime/host/extension-session-state.d.ts +18 -2
- package/lib/types/packages/market-translation/src/application/translation/localizer.d.ts +10 -1
- package/lib/types/packages/market-translation/src/application/translation/service.d.ts +6 -2
- package/package.json +1 -4
|
@@ -122,10 +122,19 @@ export class Catalog {
|
|
|
122
122
|
// answers from cache instead of re-asking a provider.
|
|
123
123
|
await this.translation.load();
|
|
124
124
|
}
|
|
125
|
-
/**
|
|
126
|
-
|
|
127
|
-
|
|
125
|
+
/**
|
|
126
|
+
* Release the localizer's and the snapshot cache's timers; in-flight work still persists.
|
|
127
|
+
*
|
|
128
|
+
* Both timer sets are cancelled synchronously. The returned promise is the
|
|
129
|
+
* translation cache write the localizer's disposal starts, a file under the
|
|
130
|
+
* plugin data root, so the owner that disposes this catalog awaits it before
|
|
131
|
+
* removing that root or reporting its own teardown complete.
|
|
132
|
+
*
|
|
133
|
+
* @returns fulfillment once the pending translation cache write landed.
|
|
134
|
+
*/
|
|
135
|
+
async dispose() {
|
|
128
136
|
this.snapshots.dispose();
|
|
137
|
+
await this.translation.dispose();
|
|
129
138
|
}
|
|
130
139
|
/**
|
|
131
140
|
* Drop every cached translation, in memory and on disk.
|
|
@@ -371,28 +371,38 @@ export async function apply(ctx, config = {
|
|
|
371
371
|
};
|
|
372
372
|
}, 'dsh-agent-plugins-market: http routes');
|
|
373
373
|
});
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
// profile reload, delete a tree this fiber was still writing to and
|
|
386
|
-
// emptying. The runtime goes first so its own stop flag makes a queued
|
|
387
|
-
// pass bail before the schedule join below waits for it.
|
|
374
|
+
/**
|
|
375
|
+
* Await one teardown, reporting its failure instead of failing the unload.
|
|
376
|
+
*
|
|
377
|
+
* Cordis awaits an async disposer, so this fiber reports unloaded only after
|
|
378
|
+
* every writer below finished. Each of them writes under the plugin data
|
|
379
|
+
* root or the user root — a translation cache, a source checkout, an MCP
|
|
380
|
+
* mount's plugin data — and returning before them let a caller that removes
|
|
381
|
+
* one of those roots, a test teardown, an uninstall or a profile reload,
|
|
382
|
+
* delete a tree this fiber was still writing to and emptying.
|
|
383
|
+
*/
|
|
384
|
+
const drain = async (label, work) => {
|
|
388
385
|
try {
|
|
389
|
-
await
|
|
386
|
+
await work();
|
|
390
387
|
}
|
|
391
388
|
catch (error) {
|
|
392
|
-
ctx.logger.warn(
|
|
389
|
+
ctx.logger.warn(`${label}: ` + String(error));
|
|
393
390
|
}
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
391
|
+
};
|
|
392
|
+
ctx.effect(() => async () => {
|
|
393
|
+
disposed = true;
|
|
394
|
+
const scheduleStopped = scheduler.dispose();
|
|
395
|
+
// Stopping the interval is synchronous; the promise joins a pass that was
|
|
396
|
+
// already refreshing sources under the user root.
|
|
397
|
+
const updateStopped = autoUpdate.dispose();
|
|
398
|
+
settings.dispose();
|
|
399
|
+
// The runtime goes first so its own stop flag makes a queued reconcile
|
|
400
|
+
// bail instead of making the scheduler join below wait for it.
|
|
401
|
+
await drain('runtime disposal', () => runtime.dispose());
|
|
402
|
+
// The catalog write is a cache file under the plugin data root; the
|
|
403
|
+
// scheduler join and the source-update join are work already in flight.
|
|
404
|
+
await drain('translation cache disposal', () => catalog.dispose());
|
|
405
|
+
await drain('reconcile disposal', () => scheduleStopped);
|
|
406
|
+
await drain('source update disposal', () => updateStopped);
|
|
397
407
|
}, 'dsh-agent-plugins-market: lifecycle');
|
|
398
408
|
}
|
|
@@ -18,7 +18,8 @@ export class SourceAutoUpdater {
|
|
|
18
18
|
refresh;
|
|
19
19
|
intervalMs;
|
|
20
20
|
stop;
|
|
21
|
-
|
|
21
|
+
/** The pass in flight, or undefined. Disposal joins it, so no write outlives the fiber. */
|
|
22
|
+
pass;
|
|
22
23
|
constructor(ctx, refresh, intervalMs = AUTO_UPDATE_INTERVAL_MS) {
|
|
23
24
|
this.ctx = ctx;
|
|
24
25
|
this.refresh = refresh;
|
|
@@ -38,20 +39,40 @@ export class SourceAutoUpdater {
|
|
|
38
39
|
this.ctx.logger?.info?.('[dsh-agent-plugins-market] background source updates off');
|
|
39
40
|
return;
|
|
40
41
|
}
|
|
41
|
-
this.stop = repeat(this.ctx, () => void this.
|
|
42
|
+
this.stop = repeat(this.ctx, () => void this.start(), this.intervalMs);
|
|
42
43
|
this.ctx.logger?.info?.(`[dsh-agent-plugins-market] background source updates on: every ${Math.round(this.intervalMs / 60_000)} minutes`);
|
|
43
44
|
}
|
|
44
|
-
/**
|
|
45
|
+
/**
|
|
46
|
+
* Disarm the interval, and join a pass that is already running.
|
|
47
|
+
*
|
|
48
|
+
* The disarm is synchronous: no further tick starts after this returns. The
|
|
49
|
+
* returned promise is the pass that was in flight, because that pass
|
|
50
|
+
* refreshes sources — cloning checkouts and committing state under the user
|
|
51
|
+
* root — so an owner that disposes this updater must await it before removing
|
|
52
|
+
* that root or reporting its own teardown complete. A failure inside the pass
|
|
53
|
+
* is reported through the logger and does not reject this promise.
|
|
54
|
+
*
|
|
55
|
+
* @returns fulfillment once no pass is running.
|
|
56
|
+
*/
|
|
45
57
|
dispose() {
|
|
46
58
|
this.stop?.();
|
|
47
59
|
this.stop = undefined;
|
|
60
|
+
return this.pass ?? Promise.resolve();
|
|
48
61
|
}
|
|
49
|
-
|
|
50
|
-
|
|
62
|
+
/** Start one pass unless the previous one is still running. */
|
|
63
|
+
start() {
|
|
64
|
+
if (this.pass !== undefined) {
|
|
51
65
|
this.ctx.logger?.warn?.('[dsh-agent-plugins-market] background source update skipped: the previous pass is still running');
|
|
52
66
|
return;
|
|
53
67
|
}
|
|
54
|
-
|
|
68
|
+
const pass = this.run();
|
|
69
|
+
this.pass = pass;
|
|
70
|
+
void pass.finally(() => {
|
|
71
|
+
if (this.pass === pass)
|
|
72
|
+
this.pass = undefined;
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
async run() {
|
|
55
76
|
try {
|
|
56
77
|
await this.refresh();
|
|
57
78
|
this.ctx.logger?.info?.('[dsh-agent-plugins-market] background source update finished');
|
|
@@ -59,8 +80,5 @@ export class SourceAutoUpdater {
|
|
|
59
80
|
catch (error) {
|
|
60
81
|
this.ctx.logger?.warn?.(`[dsh-agent-plugins-market] background source update failed: ${error instanceof Error ? error.message : String(error)}`);
|
|
61
82
|
}
|
|
62
|
-
finally {
|
|
63
|
-
this.inFlight = false;
|
|
64
|
-
}
|
|
65
83
|
}
|
|
66
84
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createUserMessage } from '@deepseek-ai/dsh-llm';
|
|
2
|
-
import '@deepseek-ai/dsh-session-query';
|
|
3
2
|
import { z } from 'zod';
|
|
3
|
+
import { optionalService } from '../core/context.js';
|
|
4
4
|
import { parseExtensionIds } from '../../../../market-contracts/src/contracts/extension-presets.js';
|
|
5
5
|
export const EXTENSION_SESSION_SOURCE = 'market-extension-selection';
|
|
6
6
|
const selectionSchema = z
|
|
@@ -227,8 +227,29 @@ export class ExtensionSessionState {
|
|
|
227
227
|
return false;
|
|
228
228
|
return error !== 'extension-session-busy' && error !== 'extension-session-corrupt';
|
|
229
229
|
}
|
|
230
|
-
/**
|
|
230
|
+
/**
|
|
231
|
+
* The host's session-query service, read off the optional seam.
|
|
232
|
+
*
|
|
233
|
+
* The host owns the instance and this plugin only reads it, so the package is an
|
|
234
|
+
* optional peer and this is the one place that answers for it. A profile that
|
|
235
|
+
* provides no service gets `undefined`, never a throw.
|
|
236
|
+
* @returns the host service, or `undefined` when the profile provides none.
|
|
237
|
+
*/
|
|
238
|
+
query() {
|
|
239
|
+
return optionalService(this.ctx, 'sessionQuery');
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Whether this service governs one agent at all.
|
|
243
|
+
*
|
|
244
|
+
* A profile with no session-query service governs nobody: no durable selection can be
|
|
245
|
+
* replayed, so every hook passes through untouched, every managed resource stays
|
|
246
|
+
* denied, and no turn is parked waiting for a state this host can never publish.
|
|
247
|
+
* @param agent - the agent to decide.
|
|
248
|
+
* @returns whether the port accepts it and the service it reads is present.
|
|
249
|
+
*/
|
|
231
250
|
governs(agent) {
|
|
251
|
+
if (this.query() === undefined)
|
|
252
|
+
return false;
|
|
232
253
|
if (this.ports.eligible === undefined)
|
|
233
254
|
return true;
|
|
234
255
|
try {
|
|
@@ -281,8 +302,11 @@ export class ExtensionSessionState {
|
|
|
281
302
|
status(agent) {
|
|
282
303
|
// An ungoverned agent reports why it has no session state at all, so a route
|
|
283
304
|
// or panel can name the reason instead of reading a permanent "not ready".
|
|
284
|
-
|
|
285
|
-
|
|
305
|
+
// A profile with no session-query service names that capability, which is a
|
|
306
|
+
// different answer from an agent this service deliberately does not govern.
|
|
307
|
+
if (!this.governs(agent)) {
|
|
308
|
+
return { ready: false, revision: 0, recoverable: false, error: this.query() === undefined ? 'extension-session-query-unavailable' : 'extension-session-ineligible' };
|
|
309
|
+
}
|
|
286
310
|
const ready = !this.disposed && !this.unavailable.has(agent) && this.states.has(agent);
|
|
287
311
|
const checkpoint = this.checkpoints.get(agent);
|
|
288
312
|
const error = this.errors.get(agent);
|
|
@@ -314,6 +338,8 @@ export class ExtensionSessionState {
|
|
|
314
338
|
initialize(agent, source, signal) {
|
|
315
339
|
if (this.disposed)
|
|
316
340
|
return Promise.reject(failure('extension-session-not-ready'));
|
|
341
|
+
if (this.query() === undefined)
|
|
342
|
+
return Promise.reject(failure('extension-session-query-unavailable'));
|
|
317
343
|
if (!this.governs(agent))
|
|
318
344
|
return Promise.reject(failure('extension-session-ineligible'));
|
|
319
345
|
const pending = this.initializing.get(agent);
|
|
@@ -339,7 +365,12 @@ export class ExtensionSessionState {
|
|
|
339
365
|
return operation;
|
|
340
366
|
}
|
|
341
367
|
async replay(agent) {
|
|
342
|
-
|
|
368
|
+
// The read site for the optional service: a profile without it gets this code
|
|
369
|
+
// through status and the record {@link fail} writes, never a TypeError.
|
|
370
|
+
const query = this.query();
|
|
371
|
+
if (query === undefined)
|
|
372
|
+
throw failure('extension-session-query-unavailable');
|
|
373
|
+
const observation = await query.observeSession(agent.id, { projectionMode: 'none' });
|
|
343
374
|
const checkpoint = {};
|
|
344
375
|
const seen = new Map();
|
|
345
376
|
try {
|
|
@@ -622,6 +622,15 @@ export class TranslationLocalizer {
|
|
|
622
622
|
* returning. Dropping them costs nothing durable: translation is lazy, the
|
|
623
623
|
* cache is the only state that has to survive, and the next activation's
|
|
624
624
|
* first read queues whatever is still missing.
|
|
625
|
+
*
|
|
626
|
+
* The timers are cancelled synchronously and the returned promise is the
|
|
627
|
+
* cache write this disposal starts: {@link flush} writes the entries a
|
|
628
|
+
* completed call recorded, which is a file under the plugin data root, so an
|
|
629
|
+
* owner that disposes this instance must await the result before removing
|
|
630
|
+
* that root or reporting its own teardown complete. Every owner on the way
|
|
631
|
+
* out awaits it — `TranslationService.dispose`, the catalog, the plugin fiber.
|
|
632
|
+
*
|
|
633
|
+
* @returns fulfillment once the pending cache write landed.
|
|
625
634
|
*/
|
|
626
635
|
dispose() {
|
|
627
636
|
this.disposed = true;
|
|
@@ -637,6 +646,6 @@ export class TranslationLocalizer {
|
|
|
637
646
|
// Ownership goes with the queue: no later read can be answered from a job
|
|
638
647
|
// this instance will never run. In-flight calls still land and are written.
|
|
639
648
|
this.owners.clear();
|
|
640
|
-
|
|
649
|
+
return this.flush();
|
|
641
650
|
}
|
|
642
651
|
}
|
|
@@ -10,9 +10,13 @@ export class TranslationService {
|
|
|
10
10
|
load() {
|
|
11
11
|
return this.localizer.load();
|
|
12
12
|
}
|
|
13
|
-
/**
|
|
13
|
+
/**
|
|
14
|
+
* Cancel timers and drop queued work; in-flight calls finish and are persisted.
|
|
15
|
+
*
|
|
16
|
+
* @returns fulfillment once the localizer's pending cache write landed.
|
|
17
|
+
*/
|
|
14
18
|
dispose() {
|
|
15
|
-
this.localizer.dispose();
|
|
19
|
+
return this.localizer.dispose();
|
|
16
20
|
}
|
|
17
21
|
/** Drop every cached translation, in memory and on disk. */
|
|
18
22
|
clear() {
|
|
@@ -57,8 +57,17 @@ export declare class Catalog implements MarketService {
|
|
|
57
57
|
setScanProjectLayouts(enabled: boolean): Promise<void>;
|
|
58
58
|
/** Load persisted user state once at plugin activation. */
|
|
59
59
|
load(): Promise<void>;
|
|
60
|
-
/**
|
|
61
|
-
|
|
60
|
+
/**
|
|
61
|
+
* Release the localizer's and the snapshot cache's timers; in-flight work still persists.
|
|
62
|
+
*
|
|
63
|
+
* Both timer sets are cancelled synchronously. The returned promise is the
|
|
64
|
+
* translation cache write the localizer's disposal starts, a file under the
|
|
65
|
+
* plugin data root, so the owner that disposes this catalog awaits it before
|
|
66
|
+
* removing that root or reporting its own teardown complete.
|
|
67
|
+
*
|
|
68
|
+
* @returns fulfillment once the pending translation cache write landed.
|
|
69
|
+
*/
|
|
70
|
+
dispose(): Promise<void>;
|
|
62
71
|
/**
|
|
63
72
|
* Drop every cached translation, in memory and on disk.
|
|
64
73
|
*
|
|
@@ -20,13 +20,27 @@ export declare class SourceAutoUpdater {
|
|
|
20
20
|
private readonly refresh;
|
|
21
21
|
private readonly intervalMs;
|
|
22
22
|
private stop;
|
|
23
|
-
|
|
23
|
+
/** The pass in flight, or undefined. Disposal joins it, so no write outlives the fiber. */
|
|
24
|
+
private pass;
|
|
24
25
|
constructor(ctx: Context, refresh: SourceRefresh, intervalMs?: number);
|
|
25
26
|
/** Whether a refresh timer is currently armed. */
|
|
26
27
|
get enabled(): boolean;
|
|
27
28
|
/** Arm or disarm the interval; repeated calls with the same state do nothing. */
|
|
28
29
|
setEnabled(enabled: boolean): void;
|
|
29
|
-
/**
|
|
30
|
-
|
|
30
|
+
/**
|
|
31
|
+
* Disarm the interval, and join a pass that is already running.
|
|
32
|
+
*
|
|
33
|
+
* The disarm is synchronous: no further tick starts after this returns. The
|
|
34
|
+
* returned promise is the pass that was in flight, because that pass
|
|
35
|
+
* refreshes sources — cloning checkouts and committing state under the user
|
|
36
|
+
* root — so an owner that disposes this updater must await it before removing
|
|
37
|
+
* that root or reporting its own teardown complete. A failure inside the pass
|
|
38
|
+
* is reported through the logger and does not reject this promise.
|
|
39
|
+
*
|
|
40
|
+
* @returns fulfillment once no pass is running.
|
|
41
|
+
*/
|
|
42
|
+
dispose(): Promise<void>;
|
|
43
|
+
/** Start one pass unless the previous one is still running. */
|
|
44
|
+
private start;
|
|
31
45
|
private run;
|
|
32
46
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { Context } from '@deepseek-ai/cordis';
|
|
2
2
|
import type { Agent } from '@deepseek-ai/dsh-agent';
|
|
3
|
-
import '@deepseek-ai/dsh-session-query';
|
|
4
3
|
import { z } from 'zod';
|
|
5
4
|
import { type ExtensionSelection } from '../../../../market-contracts/src/contracts/extension-presets.js';
|
|
6
5
|
export declare const EXTENSION_SESSION_SOURCE = "market-extension-selection";
|
|
@@ -167,7 +166,24 @@ export declare class ExtensionSessionState {
|
|
|
167
166
|
* resources stay denied.
|
|
168
167
|
*/
|
|
169
168
|
private terminalFailure;
|
|
170
|
-
/**
|
|
169
|
+
/**
|
|
170
|
+
* The host's session-query service, read off the optional seam.
|
|
171
|
+
*
|
|
172
|
+
* The host owns the instance and this plugin only reads it, so the package is an
|
|
173
|
+
* optional peer and this is the one place that answers for it. A profile that
|
|
174
|
+
* provides no service gets `undefined`, never a throw.
|
|
175
|
+
* @returns the host service, or `undefined` when the profile provides none.
|
|
176
|
+
*/
|
|
177
|
+
private query;
|
|
178
|
+
/**
|
|
179
|
+
* Whether this service governs one agent at all.
|
|
180
|
+
*
|
|
181
|
+
* A profile with no session-query service governs nobody: no durable selection can be
|
|
182
|
+
* replayed, so every hook passes through untouched, every managed resource stays
|
|
183
|
+
* denied, and no turn is parked waiting for a state this host can never publish.
|
|
184
|
+
* @param agent - the agent to decide.
|
|
185
|
+
* @returns whether the port accepts it and the service it reads is present.
|
|
186
|
+
*/
|
|
171
187
|
private governs;
|
|
172
188
|
/** Attach idle agents independently; busy agents remain denied until their current activity ends. */
|
|
173
189
|
start(): Promise<void>;
|
|
@@ -320,6 +320,15 @@ export declare class TranslationLocalizer {
|
|
|
320
320
|
* returning. Dropping them costs nothing durable: translation is lazy, the
|
|
321
321
|
* cache is the only state that has to survive, and the next activation's
|
|
322
322
|
* first read queues whatever is still missing.
|
|
323
|
+
*
|
|
324
|
+
* The timers are cancelled synchronously and the returned promise is the
|
|
325
|
+
* cache write this disposal starts: {@link flush} writes the entries a
|
|
326
|
+
* completed call recorded, which is a file under the plugin data root, so an
|
|
327
|
+
* owner that disposes this instance must await the result before removing
|
|
328
|
+
* that root or reporting its own teardown complete. Every owner on the way
|
|
329
|
+
* out awaits it — `TranslationService.dispose`, the catalog, the plugin fiber.
|
|
330
|
+
*
|
|
331
|
+
* @returns fulfillment once the pending cache write landed.
|
|
323
332
|
*/
|
|
324
|
-
dispose(): void
|
|
333
|
+
dispose(): Promise<void>;
|
|
325
334
|
}
|
|
@@ -19,8 +19,12 @@ export declare class TranslationService {
|
|
|
19
19
|
constructor(options: LocalizerOptions);
|
|
20
20
|
/** Read the persisted cache once, before the first {@link translateFields} read. */
|
|
21
21
|
load(): Promise<void>;
|
|
22
|
-
/**
|
|
23
|
-
|
|
22
|
+
/**
|
|
23
|
+
* Cancel timers and drop queued work; in-flight calls finish and are persisted.
|
|
24
|
+
*
|
|
25
|
+
* @returns fulfillment once the localizer's pending cache write landed.
|
|
26
|
+
*/
|
|
27
|
+
dispose(): Promise<void>;
|
|
24
28
|
/** Drop every cached translation, in memory and on disk. */
|
|
25
29
|
clear(): Promise<void>;
|
|
26
30
|
/** Apply a live display-preference change: off cancels unfinished work, on forgets failures. */
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "dsh-agent-plugins-market",
|
|
3
3
|
"icon": "./assets/dsh-agent-plugins.png",
|
|
4
4
|
"description": "One-stop skills, subagent, MCP and LSP manager inside DeepSeek Harness (DSH), compatible with Claude Code, Codex, Cursor, Kimi and other agent plugin layouts.",
|
|
5
|
-
"version": "0.12.
|
|
5
|
+
"version": "0.12.1",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "lib/index.js",
|
|
8
8
|
"types": "lib/types/index.d.ts",
|
|
@@ -116,9 +116,6 @@
|
|
|
116
116
|
},
|
|
117
117
|
"@deepseek-ai/dsh-session-query": {
|
|
118
118
|
"optional": true
|
|
119
|
-
},
|
|
120
|
-
"@deepseek-ai/dsh-tools": {
|
|
121
|
-
"optional": true
|
|
122
119
|
}
|
|
123
120
|
},
|
|
124
121
|
"dependencies": {
|