dsh-mesh-host 0.0.1 → 0.0.3

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.
@@ -0,0 +1,4 @@
1
+ # dsh-mesh-host: install the DSH host bridge
2
+ - insert:
3
+ - id: dsh-mesh-host
4
+ name: dsh-mesh-host
package/lib/index.js CHANGED
@@ -7,6 +7,7 @@
7
7
  * remote peer can:
8
8
  * - create a fresh Session (`/host/sessions/create` → sessionController.create)
9
9
  * - prompt a Session without a web cookie (`/host/prompt`)
10
+ * - abort one Session's active turn (`/host/sessions/cancel` → sessionController.cancel)
10
11
  * - wake a live session (`/host/wake` → agent inbox + followup)
11
12
  * - list host sessions and their status (`/host/agents`, `/host/sessions`)
12
13
  * - list / call tools registered in *this* DSH instance (`/host/tools`,
@@ -37,7 +38,7 @@ export const name = 'dsh-mesh-host'
37
38
  /** Services this plugin needs before `apply` runs. */
38
39
  export const inject = ['tools', 'agents']
39
40
 
40
- export const PLUGIN_VERSION = '0.4.0'
41
+ export const PLUGIN_VERSION = '0.5.0'
41
42
  const MAX_BODY_BYTES = 256 * 1024
42
43
  const DEFAULT_TIMEOUT_MS = 120_000
43
44
 
@@ -541,6 +542,57 @@ export function apply(ctx) {
541
542
  }
542
543
  }
543
544
 
545
+ if (req.method === 'POST' && url.pathname === '/host/sessions/cancel') {
546
+ let payload
547
+ try {
548
+ payload = JSON.parse((await readBody(req)) || '{}')
549
+ } catch {
550
+ return json(res, 400, { ok: false, code: 'E_INVALID_ARG', message: 'body must be JSON' })
551
+ }
552
+ const sessionId = String(payload.sessionId || '').trim()
553
+ if (!sessionId) {
554
+ return json(res, 400, { ok: false, code: 'E_INVALID_ARG', message: 'sessionId is required' })
555
+ }
556
+ // The web UI's own stop button: sessionController.cancel aborts the active
557
+ // turn and keeps pending inbox work. Profiles that mount no such controller
558
+ // answer 501, so an old bridge (404 "unknown endpoint") stays distinguishable.
559
+ const controller = sessionController()
560
+ if (!controller || typeof controller.cancel !== 'function') {
561
+ return json(res, 501, {
562
+ ok: false,
563
+ code: 'E_HOST_NO_CONTROLLER',
564
+ message: 'this DSH profile mounts no sessionController service with cancel (session cancel unavailable)'
565
+ })
566
+ }
567
+ let agent
568
+ try {
569
+ agent = ctx.agents.get(sessionId)
570
+ } catch {
571
+ agent = undefined
572
+ }
573
+ // Agent.cancel() is a no-op on an idle agent: report whether a turn was really aborted.
574
+ const wasRunning = agent?.status === 'running'
575
+ try {
576
+ const value = await controller.cancel({ sessionId })
577
+ return json(res, 200, {
578
+ ok: true,
579
+ sessionId,
580
+ cancelled: true,
581
+ wasRunning,
582
+ accepted: value?.accepted !== false,
583
+ plugin: PLUGIN_VERSION
584
+ })
585
+ } catch (error) {
586
+ const message = error?.message || String(error)
587
+ const code = error?.code || ''
588
+ const missing = code === 'session/not-found' || /not found \(not attached\)/u.test(message)
589
+ if (missing) {
590
+ return json(res, 404, { ok: false, code: 'E_HOST_CANCEL', message })
591
+ }
592
+ return json(res, 200, { ok: false, code: code || 'E_HOST_CANCEL', message })
593
+ }
594
+ }
595
+
544
596
  if (req.method === 'POST' && url.pathname === '/host/sessions/archive') {
545
597
  let payload
546
598
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-mesh-host",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "DSH host-side bridge for dsh-mesh: exposes in-process sessions/agents/tools over loopback HTTP so a mesh server can create sessions, prompt, wake them and call host tools.",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -9,17 +9,21 @@
9
9
  "./package.json": "./package.json"
10
10
  },
11
11
  "engines": {
12
- "node": ">=22"
12
+ "node": ">=22",
13
+ "dsh": ">=0.2.0-rc.2 <0.3.0"
13
14
  },
14
15
  "dsh": {
15
- "compatibility": {
16
- "dshReleases": {
17
- "0.2.0-rc.2": "compatible"
18
- }
16
+ "manifestVersion": 1,
17
+ "bundle": {
18
+ "patch": "./cordis.patch.yml"
19
19
  }
20
20
  },
21
+ "peerDependencies": {
22
+ "@deepseek-ai/dsh": ">=0.2.0-rc.2 <0.3.0"
23
+ },
21
24
  "files": [
22
25
  "lib",
26
+ "cordis.patch.yml",
23
27
  "README.md",
24
28
  "LICENSE"
25
29
  ],