@banbolee/dsh-fish-shell 0.4.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/README.md +103 -0
- package/cordis.patch.yml +47 -0
- package/index.js +75 -0
- package/local.js +50 -0
- package/package.json +56 -0
- package/presets/fish/agent.cordis.yml +241 -0
- package/tool.js +337 -0
package/README.md
ADDED
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
# @banbolee/dsh-fish-shell
|
|
2
|
+
|
|
3
|
+
Fish shell executors and tool for DeepSeek Harness: run commands with
|
|
4
|
+
**fish** instead of bash. Distribution-ready and surface-agnostic: works in
|
|
5
|
+
any profile that mounts it — preset-roster based (dsh-tui, web) or
|
|
6
|
+
host-tool based (headless).
|
|
7
|
+
|
|
8
|
+
## What this bundle does
|
|
9
|
+
|
|
10
|
+
- **Executor, sandboxed** (`index.js`, default export): `FishSandboxExecutor`,
|
|
11
|
+
a `SandboxBashExecutor` subclass that confines `fish -c` commands instead
|
|
12
|
+
of `bash -c`. Mounted as `ctx.shell` in place of the base `bash-sandbox`
|
|
13
|
+
executor. The sandbox backend, denial classification, runner-failure
|
|
14
|
+
facts, and the `sandboxMode` capability fact (required by
|
|
15
|
+
`dsh-permission-presets`) are inherited. Both the confined and the
|
|
16
|
+
`danger-full-access` paths run fish (the base class's full-access branch
|
|
17
|
+
falls through to hardcoded bash, so it is overridden).
|
|
18
|
+
- **Executor, unconfined** (`local.js`, exported as `@banbolee/dsh-fish-shell/local`):
|
|
19
|
+
`FishLocalExecutor`, a `LocalBashExecutor` subclass running `fish -c`
|
|
20
|
+
without a sandbox. For custom compositions that deliberately run without a
|
|
21
|
+
sandbox; composing it with `dsh-permission-presets` fails loud at load.
|
|
22
|
+
- **Tool** (`tool.js`, exported as `@banbolee/dsh-fish-shell/tool`): a model-facing
|
|
23
|
+
`fish` tool mounted host-globally, executing through `ctx.shell`. It passes
|
|
24
|
+
the calling session's resolved sandbox policy (so `/permission` switches
|
|
25
|
+
and the session workspace root are honored), collects the managed `DSH_*`
|
|
26
|
+
environment from `ctx.shellEnv`, and renders the harness marker contract
|
|
27
|
+
(`[exit code: N]`, `[stderr]`, `[sandbox: file access denied under <mode>
|
|
28
|
+
mode]`, `[output truncated; full output: <path>]`). Its description teaches
|
|
29
|
+
the model fish syntax.
|
|
30
|
+
- **Agent preset** (bundled at `presets/fish/`): a copy of the shipped
|
|
31
|
+
`standard` preset with the shell section removed (the `fish` tool is
|
|
32
|
+
host-global, so the preset needs no shell row). The bundle patch adds the
|
|
33
|
+
package's `presets/` directory as a system preset root and switches the
|
|
34
|
+
preset-roster default to `fish` for both roster row ids (`agent-presets`
|
|
35
|
+
used by web, `dsh-tui-agent-presets` used by dsh-tui). The tool plugin also
|
|
36
|
+
installs the preset under `$DSH_HOME/.agent-presets/fish` create-only
|
|
37
|
+
(never overwrites an existing file, including a user-authored one; a failed
|
|
38
|
+
write is a warning) as a fallback for rosters whose row this bundle does
|
|
39
|
+
not patch.
|
|
40
|
+
|
|
41
|
+
## Install
|
|
42
|
+
|
|
43
|
+
```sh
|
|
44
|
+
# from this checkout, per profile:
|
|
45
|
+
dsh plugin --profile <name> add ./plugins/fish-shell
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
For a published npm package: `dsh plugin --profile <name> add @banbolee/dsh-fish-shell`.
|
|
49
|
+
|
|
50
|
+
Add it to every profile that should default to fish (dsh-tui, web, headless,
|
|
51
|
+
…). The bundle patch is a no-op (with a warning) for a roster row id that the
|
|
52
|
+
profile does not have, so one patch file is safe across surfaces.
|
|
53
|
+
|
|
54
|
+
### Deployed copy and the symlink chain
|
|
55
|
+
|
|
56
|
+
The executors subclass `@deepseek-ai/dsh-bash-local` /
|
|
57
|
+
`@deepseek-ai/dsh-bash-sandbox`. Those imports must resolve to the same
|
|
58
|
+
runtime instance the harness uses — the launcher-maintained
|
|
59
|
+
`profiles/node_modules/@deepseek-ai/*` symlink chain. A plain `link:` to this
|
|
60
|
+
checkout (outside the profile tree) would resolve no `@deepseek-ai` package,
|
|
61
|
+
so the deployed copy lives at `profiles/node_modules/@banbolee/dsh-fish-shell` (inside
|
|
62
|
+
the tree). `scripts/sync-to-profile.sh` copies the plugin there after edits
|
|
63
|
+
and checks the bundled fish preset for drift against the shipped `standard`
|
|
64
|
+
preset; a pnpm `file:` dependency points each profile at the deployed copy. A
|
|
65
|
+
package published to npm installs normally (its realpath already lies inside
|
|
66
|
+
the profile tree).
|
|
67
|
+
|
|
68
|
+
## Per-surface behavior
|
|
69
|
+
|
|
70
|
+
- **Preset-roster surfaces** (dsh-tui, web): agents compose tools from the
|
|
71
|
+
`fish` preset (default) — `standard` minus the shell rows — and see exactly
|
|
72
|
+
one shell tool, `fish`. **Upstream presets (`standard`, `code`) are not
|
|
73
|
+
fish-safe**: they register a `bash`-named tool that still executes through
|
|
74
|
+
the fish executor, so the name/description lie about the shell. Only the
|
|
75
|
+
bundled `fish` preset is fish-only. (`minimal` has no one-shot shell tool.)
|
|
76
|
+
- **Host-tool surfaces** (headless): the agent uses host-plane tools; the
|
|
77
|
+
disabled host `tool-bash` and the host-global `fish` tool make fish the
|
|
78
|
+
agent's only shell tool.
|
|
79
|
+
|
|
80
|
+
## Behavior
|
|
81
|
+
|
|
82
|
+
- Every shell call spawns a fresh non-login shell (under the configured
|
|
83
|
+
sandbox backend for `FishSandboxExecutor`); no state (cwd, variables,
|
|
84
|
+
functions, history) persists between calls.
|
|
85
|
+
- Output is bounded per stream by the executor's configured caps; timeouts
|
|
86
|
+
are clamped to the executor's cap; the model sees the harness marker
|
|
87
|
+
contract.
|
|
88
|
+
- Requires `fish` on PATH; the executors fail loud when it is missing.
|
|
89
|
+
|
|
90
|
+
## Known Limitations
|
|
91
|
+
|
|
92
|
+
- Models default to bash idioms; the `fish` tool description teaches fish
|
|
93
|
+
syntax, but a command written in bash dialect fails under fish. This is the
|
|
94
|
+
intended trade of swapping the shell.
|
|
95
|
+
- The `fish` tool has no `run_in_background` parameter and no sandbox
|
|
96
|
+
escalation (`sandbox_permissions`) parameters yet; long commands must
|
|
97
|
+
finish within the timeout, and a denied command cannot be re-run wider
|
|
98
|
+
(the executor's `start()` and the approval stack are available to
|
|
99
|
+
in-process consumers).
|
|
100
|
+
- Upstream presets (`standard`, `code`) are not fish-safe; see
|
|
101
|
+
Per-surface behavior.
|
|
102
|
+
- POSIX only: the `fish` binary and the underlying process-group semantics
|
|
103
|
+
are not available on Windows (the pwsh family covers Windows).
|
package/cordis.patch.yml
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# @banbolee/dsh-fish-shell bundle: make fish the default shell executor instead of bash.
|
|
2
|
+
#
|
|
3
|
+
# Works across every surface:
|
|
4
|
+
# - dsh-tui / web (agent-preset roster): disables the base bash executor
|
|
5
|
+
# (`bash-sandbox`) and the host bash tool (`tool-bash`), mounts the fish
|
|
6
|
+
# executor (ctx.shell) and a host-global `fish` tool, and points the
|
|
7
|
+
# roster default at the bundled `fish` agent preset (discovered through
|
|
8
|
+
# the package's own `presets/` directory, registered below as a system
|
|
9
|
+
# preset root).
|
|
10
|
+
# - headless (no preset roster; the agent uses host-plane tools): the
|
|
11
|
+
# host-global `fish` tool and the disabled `tool-bash` already make fish
|
|
12
|
+
# the agent's only shell tool.
|
|
13
|
+
#
|
|
14
|
+
# The model-facing `fish` tool is host-global so every surface sees it; the
|
|
15
|
+
# bundled `fish` preset (standard with the shell rows removed) keeps agents
|
|
16
|
+
# that select it free of a duplicate or bash shell tool.
|
|
17
|
+
- id: bash-sandbox
|
|
18
|
+
disabled: true
|
|
19
|
+
|
|
20
|
+
- id: tool-bash
|
|
21
|
+
disabled: true
|
|
22
|
+
|
|
23
|
+
- insert:
|
|
24
|
+
- id: fish-shell
|
|
25
|
+
name: '@banbolee/dsh-fish-shell'
|
|
26
|
+
|
|
27
|
+
- id: tool-fish
|
|
28
|
+
name: '@banbolee/dsh-fish-shell/tool'
|
|
29
|
+
|
|
30
|
+
- id: dsh-tui-agent-presets
|
|
31
|
+
config:
|
|
32
|
+
default: fish
|
|
33
|
+
roots: !!js >-
|
|
34
|
+
(() => {
|
|
35
|
+
const base = ctx.baseUrl
|
|
36
|
+
if (!base) return []
|
|
37
|
+
const resolvePath = (url) => {
|
|
38
|
+
const path = decodeURIComponent(url.pathname)
|
|
39
|
+
return /^\/[A-Za-z]:/.test(path) ? path.slice(1) : path
|
|
40
|
+
}
|
|
41
|
+
const system = new URL('../node_modules/@deepseek-ai/dsh/config/agent-presets/', base)
|
|
42
|
+
const own = new URL('./node_modules/@banbolee/dsh-fish-shell/presets/', base)
|
|
43
|
+
return [
|
|
44
|
+
{ path: resolvePath(system), trust: 'system' },
|
|
45
|
+
{ path: resolvePath(own), trust: 'system' },
|
|
46
|
+
]
|
|
47
|
+
})()
|
package/index.js
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fish sandbox executor for DeepSeek Harness: a `SandboxBashExecutor`
|
|
3
|
+
* subclass that confines `fish -c` commands instead of `bash -c`. Mounted as
|
|
4
|
+
* the `ctx.shell` provider in place of the base `bash-sandbox` executor.
|
|
5
|
+
*
|
|
6
|
+
* `SandboxBashExecutor.run`/`start` bypass `confine()` in
|
|
7
|
+
* `danger-full-access` mode and fall through to the hardcoded `bash -c`
|
|
8
|
+
* argv, so this subclass overrides both entry points: the full-access branch
|
|
9
|
+
* runs `fish -c` through `runArgv`/`startArgv`, while confined modes delegate
|
|
10
|
+
* to the base class (which calls the polymorphic `confine()`). The sandbox
|
|
11
|
+
* backend, denial classification, runner-failure facts, and the
|
|
12
|
+
* `sandboxMode` capability fact (which `dsh-permission-presets` requires of
|
|
13
|
+
* the mounted executor) are all inherited.
|
|
14
|
+
*
|
|
15
|
+
* `@deepseek-ai/dsh-bash-sandbox` resolves through the launcher-maintained
|
|
16
|
+
* `profiles/node_modules` symlink chain, so this subclass shares the exact
|
|
17
|
+
* runtime instance the harness runs — no duplicate Cordis or Service class
|
|
18
|
+
* copies.
|
|
19
|
+
*
|
|
20
|
+
* @module @banbolee/dsh-fish-shell
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
import { SandboxBashExecutor } from '@deepseek-ai/dsh-bash-sandbox'
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Local fish executor under the configured sandbox backend. Reuses every
|
|
27
|
+
* bash-sandbox mechanic with the public command's shell swapped from bash to
|
|
28
|
+
* fish.
|
|
29
|
+
*/
|
|
30
|
+
export class FishSandboxExecutor extends SandboxBashExecutor {
|
|
31
|
+
/**
|
|
32
|
+
* Run a command in the foreground. Full-access calls run `fish -c`
|
|
33
|
+
* unconfined (stamping the same sandbox fact the base class would); other
|
|
34
|
+
* modes delegate to the base class, which confines through
|
|
35
|
+
* {@link confine}.
|
|
36
|
+
* @param spec - a resolved spec from `resolve()`.
|
|
37
|
+
* @returns the settled foreground result.
|
|
38
|
+
*/
|
|
39
|
+
run(spec) {
|
|
40
|
+
const policy = spec.sandboxPolicy
|
|
41
|
+
if (policy?.mode === 'danger-full-access') {
|
|
42
|
+
return this.runArgv(spec, ['fish', '-c', spec.command]).then((result) => ({
|
|
43
|
+
...result,
|
|
44
|
+
sandbox: { mode: policy.mode, denied: false },
|
|
45
|
+
}))
|
|
46
|
+
}
|
|
47
|
+
return super.run(spec)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Start a background process. Full-access calls spawn `fish -c`
|
|
52
|
+
* unconfined; other modes delegate to the base class.
|
|
53
|
+
* @param spec - a resolved spec from `resolve()`.
|
|
54
|
+
* @returns the live background process handle.
|
|
55
|
+
*/
|
|
56
|
+
start(spec) {
|
|
57
|
+
const policy = spec.sandboxPolicy
|
|
58
|
+
if (policy?.mode === 'danger-full-access') {
|
|
59
|
+
return this.startArgv(spec, ['fish', '-c', spec.command])
|
|
60
|
+
}
|
|
61
|
+
return super.start(spec)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Confine a `fish -c <command>` argv through the configured sandbox backend.
|
|
66
|
+
* @param command - the fish command text.
|
|
67
|
+
* @param policy - the resolved execution policy for this call.
|
|
68
|
+
* @returns the provider's confined argv and settlement-classification facts.
|
|
69
|
+
*/
|
|
70
|
+
confine(command, policy) {
|
|
71
|
+
return this.ctx.sandbox.confine(['fish', '-c', command], policy)
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export default FishSandboxExecutor
|
package/local.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unconfined fish executor for DeepSeek Harness: a `LocalBashExecutor`
|
|
3
|
+
* subclass that runs every command through `fish -c` instead of `bash -c`,
|
|
4
|
+
* with NO sandbox wrapper.
|
|
5
|
+
*
|
|
6
|
+
* This is the `local` row of the fish executor family, mirroring
|
|
7
|
+
* `@deepseek-ai/dsh-bash-local`: it spawns a managed process group through
|
|
8
|
+
* `ctx.subprocess` and reuses all of bash-local's mechanics (resolve and
|
|
9
|
+
* defaulting, deadline and cause classification, the model-friendly terminal
|
|
10
|
+
* environment, bounded output with spill files, background process groups).
|
|
11
|
+
*
|
|
12
|
+
* Prefer {@link FishSandboxExecutor} (this package's default export) in any
|
|
13
|
+
* composition that mounts `dsh-permission-presets`, which requires the
|
|
14
|
+
* mounted `ctx.shell` executor to confine (`sandboxMode`). Mount this module
|
|
15
|
+
* (`@banbolee/dsh-fish-shell/local`) only in custom compositions that deliberately run
|
|
16
|
+
* without a sandbox.
|
|
17
|
+
*
|
|
18
|
+
* `@deepseek-ai/dsh-bash-local` resolves through the launcher-maintained
|
|
19
|
+
* `profiles/node_modules` symlink chain, so this subclass shares the exact
|
|
20
|
+
* runtime instance the harness runs.
|
|
21
|
+
*
|
|
22
|
+
* @module @banbolee/dsh-fish-shell/local
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
import { LocalBashExecutor } from '@deepseek-ai/dsh-bash-local'
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Local fish executor without sandbox confinement.
|
|
29
|
+
*/
|
|
30
|
+
export class FishLocalExecutor extends LocalBashExecutor {
|
|
31
|
+
/**
|
|
32
|
+
* Run a command in the foreground through `fish -c`.
|
|
33
|
+
* @param spec - a resolved spec from `resolve()`.
|
|
34
|
+
* @returns the settled foreground result.
|
|
35
|
+
*/
|
|
36
|
+
run(spec) {
|
|
37
|
+
return this.runArgv(spec, ['fish', '-c', spec.command])
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Start a background process through `fish -c`.
|
|
42
|
+
* @param spec - a resolved spec from `resolve()`.
|
|
43
|
+
* @returns the live background process handle.
|
|
44
|
+
*/
|
|
45
|
+
start(spec) {
|
|
46
|
+
return this.startArgv(spec, ['fish', '-c', spec.command])
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export default FishLocalExecutor
|
package/package.json
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@banbolee/dsh-fish-shell",
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"description": "Fish shell executors and tool for DeepSeek Harness: run commands with fish instead of bash.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "index.js",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": "./index.js",
|
|
9
|
+
"./local": "./local.js",
|
|
10
|
+
"./tool": "./tool.js",
|
|
11
|
+
"./package.json": "./package.json"
|
|
12
|
+
},
|
|
13
|
+
"files": [
|
|
14
|
+
"index.js",
|
|
15
|
+
"local.js",
|
|
16
|
+
"tool.js",
|
|
17
|
+
"cordis.patch.yml",
|
|
18
|
+
"presets/",
|
|
19
|
+
"README.md"
|
|
20
|
+
],
|
|
21
|
+
"dsh": {
|
|
22
|
+
"bundle": {
|
|
23
|
+
"patch": "./cordis.patch.yml"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"@deepseek-ai/cordis": "^4.0.2",
|
|
28
|
+
"@deepseek-ai/dsh-bash-local": "^0.1.5-rc.1",
|
|
29
|
+
"@deepseek-ai/dsh-bash-sandbox": "^0.1.5-rc.1",
|
|
30
|
+
"@deepseek-ai/dsh-home-paths": "^0.1.5-rc.1"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@deepseek-ai/cordis": "^4.0.2",
|
|
34
|
+
"@deepseek-ai/dsh-bash-local": "^0.1.5-rc.1",
|
|
35
|
+
"@deepseek-ai/dsh-bash-sandbox": "^0.1.5-rc.1",
|
|
36
|
+
"@deepseek-ai/dsh-home-paths": "^0.1.5-rc.1",
|
|
37
|
+
"@deepseek-ai/dsh-invariants": "^0.1.5-rc.1",
|
|
38
|
+
"@deepseek-ai/dsh-scope": "^0.1.5-rc.1",
|
|
39
|
+
"@deepseek-ai/dsh-shell": "^0.1.5-rc.1"
|
|
40
|
+
},
|
|
41
|
+
"keywords": [
|
|
42
|
+
"dsh",
|
|
43
|
+
"plugin",
|
|
44
|
+
"fish",
|
|
45
|
+
"shell",
|
|
46
|
+
"bundle"
|
|
47
|
+
],
|
|
48
|
+
"license": "MIT",
|
|
49
|
+
"publishConfig": {
|
|
50
|
+
"access": "public",
|
|
51
|
+
"registry": "https://registry.npmjs.org"
|
|
52
|
+
},
|
|
53
|
+
"engines": {
|
|
54
|
+
"node": ">=22"
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
# The `standard` agent preset: the full coding agent, mounted once per process.
|
|
2
|
+
#
|
|
3
|
+
# This file is an AGENT-PLANE composition. The roster mounts it ONCE under a
|
|
4
|
+
# standing scope; every session naming it joins by scope parentage, so the
|
|
5
|
+
# tools and prompt sections registered here cover each joined agent while a
|
|
6
|
+
# session's own state stays keyed per Session/Agent inside the plugins. The
|
|
7
|
+
# host composition (`base.cordis.yml` + `web.cordis.yml`) keeps everything a
|
|
8
|
+
# preset must not own: the registries themselves, the sandbox and approval
|
|
9
|
+
# stack, persistence, and the model route.
|
|
10
|
+
#
|
|
11
|
+
# A service row here MUST sit inside a group carrying an `isolate` realm.
|
|
12
|
+
# Without one it publishes into the root realm, where it is process-global —
|
|
13
|
+
# another preset publishing the same name collides, and a host reader would
|
|
14
|
+
# resolve one preset's instance for every session; `dsh-agent-presets` rejects
|
|
15
|
+
# that at mount. `true` means an entry-local realm: this standing mount's own
|
|
16
|
+
# private instance, apart from every other preset's. (A shared label does NOT
|
|
17
|
+
# pool instances — `provide()` throws on the second registration under the
|
|
18
|
+
# same realm symbol; labels join REALMS, and are not what this file needs.)
|
|
19
|
+
|
|
20
|
+
# ── identity ────────────────────────────────────────────────────────────────
|
|
21
|
+
|
|
22
|
+
# The preset's own persona, shadowing the deployment default for this agent.
|
|
23
|
+
# `{{model}}` and `{{cwd}}` resolve from the agent's own route and workspace.
|
|
24
|
+
- id: persona
|
|
25
|
+
name: '@deepseek-ai/dsh-persona'
|
|
26
|
+
config:
|
|
27
|
+
prefix: >-
|
|
28
|
+
You are a coding agent powered by the {{model}} model. Your working directory is {{cwd}}.
|
|
29
|
+
|
|
30
|
+
- id: agent-instructions
|
|
31
|
+
name: '@deepseek-ai/dsh-agent-instructions'
|
|
32
|
+
config:
|
|
33
|
+
maxBytes: 65536
|
|
34
|
+
|
|
35
|
+
# ── shell ───────────────────────────────────────────────────────────────────
|
|
36
|
+
|
|
37
|
+
# The @banbolee/dsh-fish-shell bundle mounts the model-facing `fish` tool on the HOST
|
|
38
|
+
# plane (global), so this preset carries no shell tool row — agents here see
|
|
39
|
+
# exactly one shell tool, `fish`, and no bash tool. The fish executor
|
|
40
|
+
# (FishSandboxExecutor) supplies ctx.shell on the host plane.
|
|
41
|
+
# ── filesystem ──────────────────────────────────────────────────────────────
|
|
42
|
+
|
|
43
|
+
# Both register into the host `tools` registry and provide nothing, so
|
|
44
|
+
# they need no realm. The `fs` service and its policy stay in the host.
|
|
45
|
+
- id: tool-fs
|
|
46
|
+
name: '@deepseek-ai/dsh-tool-fs'
|
|
47
|
+
|
|
48
|
+
- id: tool-fs-search
|
|
49
|
+
name: '@deepseek-ai/dsh-tool-fs-search'
|
|
50
|
+
config:
|
|
51
|
+
sampleOverCapGlobResults: false
|
|
52
|
+
|
|
53
|
+
# ── background jobs ────────────────────────────────────────────────────────
|
|
54
|
+
|
|
55
|
+
# Only the model-facing controls. The task REGISTRY stays on the host plane:
|
|
56
|
+
# its producers sit outside any realm this file could put it in — `tool-bash`
|
|
57
|
+
# above resolves it with `ctx.get`, and an entry-local realm here is invisible
|
|
58
|
+
# to every sibling row, so `run_in_background` would answer "background jobs
|
|
59
|
+
# unavailable" while these controls sat in the catalog. The registry is keyed by
|
|
60
|
+
# owning agent anyway, so one host instance serves every session. What a preset
|
|
61
|
+
# chooses is whether its agent can collect and stop background work at all.
|
|
62
|
+
- id: tool-jobs
|
|
63
|
+
name: '@deepseek-ai/dsh-tool-jobs'
|
|
64
|
+
|
|
65
|
+
# ── skills ──────────────────────────────────────────────────────────────────
|
|
66
|
+
|
|
67
|
+
# The skill REGISTRY lives in the host composition and is layered per scope:
|
|
68
|
+
# these rows register into THIS preset's layer of it, so they need no realm.
|
|
69
|
+
# `skill-filesystem` contributes local-root discovery for agents on this preset, and
|
|
70
|
+
# `tool-skill` gives them the catalog and loader; the merged catalog also
|
|
71
|
+
# carries whatever the deployment registered globally (repository plugins).
|
|
72
|
+
- id: skill-filesystem
|
|
73
|
+
name: '@deepseek-ai/dsh-skill-filesystem'
|
|
74
|
+
|
|
75
|
+
- id: tool-skill
|
|
76
|
+
name: '@deepseek-ai/dsh-tool-skill'
|
|
77
|
+
|
|
78
|
+
# ── goals ───────────────────────────────────────────────────────────────────
|
|
79
|
+
|
|
80
|
+
# Only the model-facing tool. The goal SERVICE, its session driver, and the
|
|
81
|
+
# `/goal` command stay on the host plane: the Gateway serves the goal domain as
|
|
82
|
+
# Remote endpoints whose receiver comes from a generated descriptor, so it
|
|
83
|
+
# resolves `goals` on the host and an entry-local realm here would hide it. The
|
|
84
|
+
# registry is keyed by session anyway, so one host instance serves every
|
|
85
|
+
# session. What a preset chooses is whether its agent can call the goal tool.
|
|
86
|
+
- id: tool-goal
|
|
87
|
+
name: '@deepseek-ai/dsh-tool-goal'
|
|
88
|
+
|
|
89
|
+
# ── plan mode ───────────────────────────────────────────────────────────────
|
|
90
|
+
|
|
91
|
+
# Plan state is per-agent by nature, so an entry-local realm is not a
|
|
92
|
+
# workaround here — it is the correct lifetime.
|
|
93
|
+
- id: planning
|
|
94
|
+
name: cordis:group
|
|
95
|
+
group: true
|
|
96
|
+
isolate:
|
|
97
|
+
planMode: true
|
|
98
|
+
config:
|
|
99
|
+
- id: plan-mode
|
|
100
|
+
name: '@deepseek-ai/dsh-plan-mode'
|
|
101
|
+
config:
|
|
102
|
+
section: |
|
|
103
|
+
You are in plan mode. Stay in plan mode until exit_plan_mode succeeds or the user switches the session mode. Imperative language to implement changes means plan the implementation, not execute it. A user's conversational agreement — including an answer confirming something you asked — approves nothing and does not end plan mode; fold the confirmed decision into the plan and submit it through exit_plan_mode.
|
|
104
|
+
|
|
105
|
+
Explore first. Use non-mutating reads, searches, static analysis, and checks to ground the plan in the actual repository. Do not edit or write files, change configuration, run formatters or code generation that rewrites tracked files, commit, or otherwise carry out the plan. Prefer existing functions and patterns over new machinery.
|
|
106
|
+
|
|
107
|
+
The tool catalog stays the same across modes for request-cache stability. These plan-mode rules override any later tool description or guidance that suggests using mutation tools; those tools remain listed to keep the tool catalog unchanged. Do not use todo_write to track this planning phase: it tracks implementation after an approved plan, while the plan itself belongs in exit_plan_mode.
|
|
108
|
+
|
|
109
|
+
Resolve discoverable facts by inspection. Use ask_user_question only for user-owned choices or material ambiguity that inspection cannot answer. Do not ask the user where code lives or how current behavior works when you can find out.
|
|
110
|
+
|
|
111
|
+
Make the plan decision-complete: state the goal and success criteria; group implementation changes by subsystem; identify public API, schema, and data-flow changes; cover edge cases, failure modes, tests, acceptance criteria, and explicit assumptions. Keep it concise enough to review but detailed enough that another engineer can implement it without making design decisions.
|
|
112
|
+
|
|
113
|
+
When ready, call exit_plan_mode with the complete plan markdown, starting with a # title. Make exit_plan_mode the only and final tool call in that assistant response: it presents the plan for approval, and implementation begins only in a later step after approval. Do not paste the final plan as a plain reply or ask "should I proceed?" through prose or ask_user_question. If review rejects it, incorporate the feedback and present again. If the review channel is unavailable or aborted, stay in plan mode and ask the user to switch modes manually; do not proceed with implementation.
|
|
114
|
+
|
|
115
|
+
# ── compaction ──────────────────────────────────────────────────────────────
|
|
116
|
+
|
|
117
|
+
# `compaction-basic` reads `toolResultPrune` through `ctx.get`, so the pruner must
|
|
118
|
+
# share this realm rather than sit outside it.
|
|
119
|
+
#
|
|
120
|
+
# `tokenMeter` is deliberately NOT in this realm: the meter stays on the HOST
|
|
121
|
+
# plane, and the rows here resolve that one instance. It takes no configuration,
|
|
122
|
+
# keys every fold by Session, and owns the context-meter projection units the
|
|
123
|
+
# browser reads for every session — behind a realm those units would come and go
|
|
124
|
+
# with whichever presets happen to be mounted. What a preset chooses is whether
|
|
125
|
+
# its agent compacts at all, which is `compaction-basic` below.
|
|
126
|
+
- id: compaction
|
|
127
|
+
name: cordis:group
|
|
128
|
+
group: true
|
|
129
|
+
isolate:
|
|
130
|
+
compaction: true
|
|
131
|
+
toolResultPruner: true
|
|
132
|
+
config:
|
|
133
|
+
- id: compaction-basic
|
|
134
|
+
name: '@deepseek-ai/dsh-compaction-basic'
|
|
135
|
+
|
|
136
|
+
- id: command-compact
|
|
137
|
+
name: '@deepseek-ai/dsh-command-compact'
|
|
138
|
+
|
|
139
|
+
- id: tool-result-pruner
|
|
140
|
+
name: '@deepseek-ai/dsh-compaction-tool-result-pruner'
|
|
141
|
+
config:
|
|
142
|
+
thresholdChars: 8192
|
|
143
|
+
headChars: 4096
|
|
144
|
+
tailChars: 1024
|
|
145
|
+
|
|
146
|
+
# ── delegation and workflows ────────────────────────────────────────────────
|
|
147
|
+
|
|
148
|
+
# The `subagents` registry and its spawn/fork backends live in the HOST
|
|
149
|
+
# composition: the registry is a process singleton whose cross-session queries
|
|
150
|
+
# the api-proxy serves to the browser, and a provider name may only be
|
|
151
|
+
# registered once. This preset contributes the delegation TOOLS, which resolve
|
|
152
|
+
# that host registry.
|
|
153
|
+
#
|
|
154
|
+
# `workflows` is different — nothing outside an agent reads it — so every row
|
|
155
|
+
# that reaches it shares one entry-local realm here, and a consumer left
|
|
156
|
+
# outside would resolve a host registry this preset does not populate.
|
|
157
|
+
#
|
|
158
|
+
# `tool-subagent-report` is host-plane for the same reason as the registry,
|
|
159
|
+
# not because a preset may not want it: it registers a CONTINUABLE SETUP on
|
|
160
|
+
# that singleton rather than a tool this agent calls, and the setup list is
|
|
161
|
+
# not scope-aware — one copy per mounted preset means every child gets
|
|
162
|
+
# `report` registered once per live session, which throws on the second.
|
|
163
|
+
- id: delegation
|
|
164
|
+
name: cordis:group
|
|
165
|
+
group: true
|
|
166
|
+
isolate:
|
|
167
|
+
workflowEngine: true
|
|
168
|
+
config:
|
|
169
|
+
- id: tool-subagent-control
|
|
170
|
+
name: '@deepseek-ai/dsh-tool-subagent-control'
|
|
171
|
+
|
|
172
|
+
- id: tool-subagent-list-agents
|
|
173
|
+
name: '@deepseek-ai/dsh-tool-subagent-control/list-agents'
|
|
174
|
+
|
|
175
|
+
- id: tool-subagent
|
|
176
|
+
name: '@deepseek-ai/dsh-tool-subagent'
|
|
177
|
+
config:
|
|
178
|
+
provider: spawn
|
|
179
|
+
toolName: subagent
|
|
180
|
+
backgroundMode: continuable
|
|
181
|
+
|
|
182
|
+
- id: tool-subagent-fork
|
|
183
|
+
name: '@deepseek-ai/dsh-tool-subagent'
|
|
184
|
+
config:
|
|
185
|
+
provider: fork
|
|
186
|
+
toolName: subagent_fork
|
|
187
|
+
backgroundMode: continuable
|
|
188
|
+
|
|
189
|
+
# Production dsh does not install these optional providers. Install the
|
|
190
|
+
# matching Bundle in this Profile and restart the Host, then copy this
|
|
191
|
+
# preset and remove `disabled` from the matching tool row. Host availability
|
|
192
|
+
# alone grants no tool.
|
|
193
|
+
- id: tool-subagent-codex
|
|
194
|
+
name: '@deepseek-ai/dsh-tool-subagent'
|
|
195
|
+
disabled: true
|
|
196
|
+
config:
|
|
197
|
+
provider: codex
|
|
198
|
+
toolName: subagent_codex
|
|
199
|
+
backgroundMode: one-shot
|
|
200
|
+
maxDepth: provider-managed
|
|
201
|
+
|
|
202
|
+
- id: tool-subagent-claude-code
|
|
203
|
+
name: '@deepseek-ai/dsh-tool-subagent'
|
|
204
|
+
disabled: true
|
|
205
|
+
config:
|
|
206
|
+
provider: claude-code
|
|
207
|
+
toolName: subagent_claude_code
|
|
208
|
+
backgroundMode: one-shot
|
|
209
|
+
maxDepth: provider-managed
|
|
210
|
+
|
|
211
|
+
- id: workflow-worker-thread
|
|
212
|
+
name: '@deepseek-ai/dsh-workflow-worker-thread'
|
|
213
|
+
config:
|
|
214
|
+
provider: spawn
|
|
215
|
+
|
|
216
|
+
- id: tool-workflow
|
|
217
|
+
name: '@deepseek-ai/dsh-tool-workflow'
|
|
218
|
+
|
|
219
|
+
- id: tool-ralph
|
|
220
|
+
name: '@deepseek-ai/dsh-tool-ralph'
|
|
221
|
+
config:
|
|
222
|
+
subagentProvider: spawn
|
|
223
|
+
maxRounds: 64
|
|
224
|
+
|
|
225
|
+
# ── remaining model-facing rows ─────────────────────────────────────────────
|
|
226
|
+
|
|
227
|
+
- id: tool-ask-user
|
|
228
|
+
name: '@deepseek-ai/dsh-tool-ask-user'
|
|
229
|
+
|
|
230
|
+
- id: tool-todo
|
|
231
|
+
name: '@deepseek-ai/dsh-tool-todo'
|
|
232
|
+
config:
|
|
233
|
+
allowParallelInProgress: true
|
|
234
|
+
|
|
235
|
+
# The `web` service and its search provider stay in the host composition; only
|
|
236
|
+
# the model-facing tool is per-session.
|
|
237
|
+
- id: tool-web
|
|
238
|
+
name: '@deepseek-ai/dsh-tool-web'
|
|
239
|
+
config:
|
|
240
|
+
fetch: false
|
|
241
|
+
searchTimeoutMs: 60000
|
package/tool.js
ADDED
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Model-facing `fish` tool for DeepSeek Harness.
|
|
3
|
+
*
|
|
4
|
+
* Registers a `fish` tool that executes commands through the harness `fish`
|
|
5
|
+
* executor (`ctx.shell`, the {@link FishSandboxExecutor} mounted by this
|
|
6
|
+
* bundle) instead of spawning its own subprocess. Going through `ctx.shell`
|
|
7
|
+
* means every call inherits the executor's sandbox confinement, credential
|
|
8
|
+
* scrub, bounded output collection, timeout clamping, and result facts —
|
|
9
|
+
* the standalone-spawn version this module used to carry was removed because
|
|
10
|
+
* it bypassed all of that.
|
|
11
|
+
*
|
|
12
|
+
* The tool description teaches fish syntax because models default to bash
|
|
13
|
+
* idioms; without it, every `export`/`$(...)`/`if then fi` would fail under
|
|
14
|
+
* fish.
|
|
15
|
+
*
|
|
16
|
+
* @module @banbolee/dsh-fish-shell/tool
|
|
17
|
+
*/
|
|
18
|
+
|
|
19
|
+
import { isAbsolute, resolve } from 'node:path'
|
|
20
|
+
import { mkdirSync, readFileSync, writeFileSync } from 'node:fs'
|
|
21
|
+
import { resolveDshHome } from '@deepseek-ai/dsh-home-paths'
|
|
22
|
+
|
|
23
|
+
export const name = 'fish-tool'
|
|
24
|
+
export const inject = ['tools', 'shell', 'shellEnv']
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Bundled fish agent preset: a copy of the shipped `standard` preset with
|
|
28
|
+
* the shell section removed (the `fish` tool is mounted host-globally by
|
|
29
|
+
* this plugin, so the preset needs no shell row).
|
|
30
|
+
*/
|
|
31
|
+
const BUNDLED_PRESET_URL = new URL('./presets/fish/agent.cordis.yml', import.meta.url)
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Install the bundled fish agent preset under the agent-presets user root,
|
|
35
|
+
* create-only: an existing target (even a user-edited one) is left alone,
|
|
36
|
+
* and a failed write is a warning, never a load failure.
|
|
37
|
+
*/
|
|
38
|
+
function installPreset() {
|
|
39
|
+
const home = resolveDshHome()
|
|
40
|
+
const targetDir = `${home}/.agent-presets/fish`
|
|
41
|
+
const target = `${targetDir}/agent.cordis.yml`
|
|
42
|
+
let exists = true
|
|
43
|
+
try {
|
|
44
|
+
readFileSync(target)
|
|
45
|
+
} catch {
|
|
46
|
+
exists = false
|
|
47
|
+
}
|
|
48
|
+
if (exists) return
|
|
49
|
+
try {
|
|
50
|
+
mkdirSync(targetDir, { recursive: true })
|
|
51
|
+
writeFileSync(target, readFileSync(BUNDLED_PRESET_URL, 'utf8'))
|
|
52
|
+
} catch (error) {
|
|
53
|
+
console.warn('@banbolee/dsh-fish-shell: could not install the fish agent preset:', String(error))
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* The model-facing tool description. Written from the model's perspective:
|
|
59
|
+
* the most important fact is that this is FISH, not bash, so the model must
|
|
60
|
+
* translate bash idioms before running them.
|
|
61
|
+
*/
|
|
62
|
+
const TOOL_DESCRIPTION = `Execute a fish shell command (\`fish -c\`) and return its stdout/stderr. Each call runs in a fresh non-login fish: no state (cwd, variables, functions, history) persists between calls — pass \`workdir\` instead of using \`cd\`. This tool uses the FISH shell, NOT bash; translate bash commands to fish syntax first:
|
|
63
|
+
- Variables: \`set -gx NAME value\` (not \`export NAME=value\`); read them as \`$NAME\`. Use \`env\` to see exported variables.
|
|
64
|
+
- Conditionals/loops: \`if ...; ...; end\`, \`for x in ...; ...; end\`, \`while ...; ...; end\`, \`switch\` instead of \`case\`.
|
|
65
|
+
- Chaining: \`a; and b\` / \`a; or b\` (fish 3 also accepts \`&&\` / \`||\`); background a job with \`cmd &\` and wait with \`wait\`.
|
|
66
|
+
- Command substitution: \`(cmd)\` (fish 3 also accepts \`$(cmd)\`); arithmetic: \`math '1 + 2'\`; string processing: \`string ...\`.
|
|
67
|
+
- Expansion: \`~\`, \`$VAR\`, and globs like \`*.md\` expand; an unmatched glob is an error, not a literal.
|
|
68
|
+
- Commands may run under a file sandbox; a blocked file operation is reported as \`[sandbox: file access denied under <mode> mode]\`.
|
|
69
|
+
- Non-zero exits are reported as \`[exit code: N]\`. Long output is truncated to its tail.
|
|
70
|
+
Bash idioms fish REJECTS with exit 127 — translate before running:
|
|
71
|
+
\`VAR=x\` / \`export VAR=x\` → \`set VAR x\` / \`set -gx VAR x\`
|
|
72
|
+
\`for i in ...; do ...; done\` → \`for i in ...; ...; end\`
|
|
73
|
+
\`if [ c ]; then ...; fi\` → \`if test c; ...; end\`
|
|
74
|
+
\`cmd <<'EOF' ... EOF\` (heredoc) → \`printf '...' | cmd\` (fish has no heredoc)
|
|
75
|
+
If fish rejects your command, retry with the fish form from the table — failed results carry a [fish syntax] hint naming the exact fix.`
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Targeted fish-syntax correction for a failed run. Models default to bash
|
|
79
|
+
* idioms; when fish rejects a command the stderr carries a diagnostic like
|
|
80
|
+
* "Unsupported use of '='. In fish, use 'set ...'". Instead of making the
|
|
81
|
+
* model guess, map the exact diagnostic to the fish form. Returns '' when
|
|
82
|
+
* there's nothing to correct.
|
|
83
|
+
*/
|
|
84
|
+
const FISH_SYNTAX_HINTS = [
|
|
85
|
+
{
|
|
86
|
+
pattern: /Unsupported use of '='\. In fish, please use 'set/i,
|
|
87
|
+
hint: 'bash assignment `VAR=x` → fish `set VAR x` (export: `set -gx VAR x`)',
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
pattern: /Expected a string, but found a redirection/i,
|
|
91
|
+
hint: 'bash heredoc `cmd <<EOF` has no fish equivalent — use `printf \'...\' | cmd` or `echo ... | cmd`',
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
pattern: /Missing end to balance this for loop/i,
|
|
95
|
+
hint: 'bash `for x in ...; do ...; done` → fish `for x in ...; ...; end`',
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
pattern: /Missing end to balance this if/i,
|
|
99
|
+
hint: 'bash `if [ c ]; then ...; fi` → fish `if test c; ...; end`',
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
pattern: /Unexpected end of string, quotes are not balanced/i,
|
|
103
|
+
hint: 'unbalanced quotes — fish strings must close (`"..."` or `\'...\'`); check escaping',
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
pattern: /No matches for wildcard/i,
|
|
107
|
+
hint: 'unmatched glob is an error in fish — quote the path or check the pattern (e.g. `"*.json"`)',
|
|
108
|
+
},
|
|
109
|
+
]
|
|
110
|
+
|
|
111
|
+
/** Find a fish syntax hint for one stderr text, or '' when none applies. */
|
|
112
|
+
function fishSyntaxHint(stderrText) {
|
|
113
|
+
for (const { pattern, hint } of FISH_SYNTAX_HINTS) {
|
|
114
|
+
if (pattern.test(stderrText)) return hint
|
|
115
|
+
}
|
|
116
|
+
return ''
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Shape one finished run into the text the model sees: stdout, then a marked
|
|
121
|
+
* stderr section, then sandbox/timeout/signal/exit markers — the same marker
|
|
122
|
+
* contract the harness bash tool uses, so the model reads both shells
|
|
123
|
+
* identically.
|
|
124
|
+
* @param {object} result - the settled foreground result from the executor.
|
|
125
|
+
* @returns {string} the model-facing text.
|
|
126
|
+
*/
|
|
127
|
+
function renderResult(result) {
|
|
128
|
+
const streamText = (stream) => {
|
|
129
|
+
if (!stream.truncated) return stream.text
|
|
130
|
+
return `${stream.text}\n[output truncated${stream.spillPath !== undefined
|
|
131
|
+
? `; full output: ${stream.spillPath}`
|
|
132
|
+
: '; full output: (unavailable)'}]`
|
|
133
|
+
}
|
|
134
|
+
const out = streamText(result.stdout)
|
|
135
|
+
const err = streamText(result.stderr)
|
|
136
|
+
|
|
137
|
+
let body = out
|
|
138
|
+
if (err.length > 0) {
|
|
139
|
+
if (body.length > 0 && !body.endsWith('\n')) body += '\n'
|
|
140
|
+
body += `[stderr]\n${err}`
|
|
141
|
+
}
|
|
142
|
+
if (body.length === 0) body = '(no output)'
|
|
143
|
+
|
|
144
|
+
// When the command failed and fish named a syntax problem, append the exact
|
|
145
|
+
// correction so the model retries in fish form instead of guessing. The exit
|
|
146
|
+
// marker alone ("[exit code: 127]") doesn't say how to fix it.
|
|
147
|
+
const syntaxHint = result.exitCode !== 0 ? fishSyntaxHint(err) : ''
|
|
148
|
+
if (syntaxHint.length > 0) {
|
|
149
|
+
if (!body.endsWith('\n')) body += '\n'
|
|
150
|
+
body += `[fish syntax] ${syntaxHint}`
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const markers = []
|
|
154
|
+
if (result.sandbox?.denied) {
|
|
155
|
+
markers.push(`[sandbox: file access denied under ${result.sandbox.mode} mode]`)
|
|
156
|
+
}
|
|
157
|
+
if (result.timedOut) markers.push(`[timed out after ${result.timeoutMs ?? 0}ms]`)
|
|
158
|
+
if (result.signal !== null) {
|
|
159
|
+
markers.push(`[killed by signal: ${result.signal}]`)
|
|
160
|
+
} else if (result.exitCode !== 0) {
|
|
161
|
+
markers.push(`[exit code: ${result.exitCode}]`)
|
|
162
|
+
}
|
|
163
|
+
if (markers.length === 0) return body
|
|
164
|
+
if (!body.endsWith('\n')) body += '\n'
|
|
165
|
+
return body + markers.join('\n')
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/** Object-root JSON Schema for the tool's parameters (raw-registered). */
|
|
169
|
+
const PARAMETERS = {
|
|
170
|
+
type: 'object',
|
|
171
|
+
additionalProperties: false,
|
|
172
|
+
required: ['command', 'description'],
|
|
173
|
+
properties: {
|
|
174
|
+
command: {
|
|
175
|
+
type: 'string',
|
|
176
|
+
description: 'The fish command to execute.',
|
|
177
|
+
},
|
|
178
|
+
description: {
|
|
179
|
+
type: 'string',
|
|
180
|
+
description: 'Clear, concise description of what this command does in active voice, '
|
|
181
|
+
+ '5-10 words (shown in the UI). Examples: "git status" → "Show working tree status".',
|
|
182
|
+
},
|
|
183
|
+
workdir: {
|
|
184
|
+
type: 'string',
|
|
185
|
+
description: 'Working directory for this command. Defaults to the session workspace; '
|
|
186
|
+
+ 'a relative path is resolved against it.',
|
|
187
|
+
},
|
|
188
|
+
timeoutMs: {
|
|
189
|
+
type: 'number',
|
|
190
|
+
description: 'Timeout in milliseconds (clamped to the executor\'s configured cap). '
|
|
191
|
+
+ 'The command is killed on expiry.',
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
const OUTPUT = {
|
|
197
|
+
schema: {
|
|
198
|
+
type: 'object',
|
|
199
|
+
additionalProperties: false,
|
|
200
|
+
required: ['kind', 'exitCode', 'signal', 'timedOut', 'aborted', 'timeoutMs', 'stdout', 'stderr'],
|
|
201
|
+
properties: {
|
|
202
|
+
kind: { type: 'string', const: 'foreground' },
|
|
203
|
+
exitCode: { oneOf: [{ type: 'integer' }, { type: 'null' }] },
|
|
204
|
+
signal: { oneOf: [{ type: 'string' }, { type: 'null' }] },
|
|
205
|
+
timedOut: { type: 'boolean' },
|
|
206
|
+
aborted: { type: 'boolean' },
|
|
207
|
+
timeoutMs: { type: 'number' },
|
|
208
|
+
stdout: {
|
|
209
|
+
type: 'object',
|
|
210
|
+
additionalProperties: false,
|
|
211
|
+
required: ['text', 'truncated'],
|
|
212
|
+
properties: {
|
|
213
|
+
text: { type: 'string' },
|
|
214
|
+
truncated: { type: 'boolean' },
|
|
215
|
+
spillPath: { type: 'string' },
|
|
216
|
+
},
|
|
217
|
+
},
|
|
218
|
+
stderr: {
|
|
219
|
+
type: 'object',
|
|
220
|
+
additionalProperties: false,
|
|
221
|
+
required: ['text', 'truncated'],
|
|
222
|
+
properties: {
|
|
223
|
+
text: { type: 'string' },
|
|
224
|
+
truncated: { type: 'boolean' },
|
|
225
|
+
spillPath: { type: 'string' },
|
|
226
|
+
},
|
|
227
|
+
},
|
|
228
|
+
sandbox: {
|
|
229
|
+
type: 'object',
|
|
230
|
+
additionalProperties: false,
|
|
231
|
+
required: ['mode', 'denied'],
|
|
232
|
+
properties: {
|
|
233
|
+
mode: { type: 'string' },
|
|
234
|
+
denied: { type: 'boolean' },
|
|
235
|
+
},
|
|
236
|
+
},
|
|
237
|
+
},
|
|
238
|
+
},
|
|
239
|
+
render: (_args, value) => [{ type: 'text', text: renderResult(value) }],
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
/** Resolve an explicit workdir: the sandbox policy's workspace root wins as
|
|
243
|
+
* the base, then the session cwd; a relative path resolves against it. */
|
|
244
|
+
function resolveWorkdir(modelWorkdir, exec, policyWorkspaceRoot) {
|
|
245
|
+
const sessionCwd = policyWorkspaceRoot ?? exec?.agent?.session?.header?.cwd
|
|
246
|
+
if (modelWorkdir === undefined) return sessionCwd
|
|
247
|
+
if (sessionCwd !== undefined && !isAbsolute(modelWorkdir)) {
|
|
248
|
+
return resolve(sessionCwd, modelWorkdir)
|
|
249
|
+
}
|
|
250
|
+
return modelWorkdir
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
/**
|
|
254
|
+
* Cordis plugin entry: install the bundled fish agent preset (an idempotent
|
|
255
|
+
* user-root fallback for surfaces whose roster row this bundle does not
|
|
256
|
+
* patch), then register the `fish` tool once the tool registry and the
|
|
257
|
+
* `fish` executor are up.
|
|
258
|
+
* @param {import('@deepseek-ai/cordis').Context} ctx - the harness context.
|
|
259
|
+
*/
|
|
260
|
+
export function apply(ctx) {
|
|
261
|
+
installPreset()
|
|
262
|
+
|
|
263
|
+
// Mirror dsh-tool-bash's policy path: when the mounted executor confines,
|
|
264
|
+
// resolve each call's standing policy against the calling session so
|
|
265
|
+
// /permission switches and the session workspace are honored, and fail loud
|
|
266
|
+
// at load when the policy owner is missing.
|
|
267
|
+
const defaultMode = ctx.shell.sandboxMode
|
|
268
|
+
const sandboxPolicy = defaultMode === undefined ? undefined : ctx.get('sandboxPolicy')
|
|
269
|
+
if (defaultMode !== undefined && sandboxPolicy === undefined) {
|
|
270
|
+
throw new Error('tool-fish: the mounted fish executor confines but ctx.sandboxPolicy is missing')
|
|
271
|
+
}
|
|
272
|
+
const resolveSandboxPolicy = (exec) => {
|
|
273
|
+
if (sandboxPolicy === undefined) return undefined
|
|
274
|
+
return sandboxPolicy.resolve(exec.agent === undefined ? {} : { session: exec.agent.session })
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
async function execute(args, exec) {
|
|
278
|
+
if (typeof args.command !== 'string' || args.command.trim().length === 0) {
|
|
279
|
+
throw new Error('invalid command: expected a non-empty string')
|
|
280
|
+
}
|
|
281
|
+
if (typeof args.description !== 'string' || args.description.trim().length === 0) {
|
|
282
|
+
throw new Error('invalid description: expected a non-empty string')
|
|
283
|
+
}
|
|
284
|
+
if (args.timeoutMs !== undefined && (!Number.isFinite(args.timeoutMs) || args.timeoutMs <= 0)) {
|
|
285
|
+
throw new Error(`invalid timeoutMs: expected a positive number, got ${JSON.stringify(args.timeoutMs)}`)
|
|
286
|
+
}
|
|
287
|
+
const standingPolicy = resolveSandboxPolicy(exec)
|
|
288
|
+
const workdir = resolveWorkdir(args.workdir, exec, standingPolicy?.workspaceRoot)
|
|
289
|
+
const request = {
|
|
290
|
+
command: args.command,
|
|
291
|
+
...workdir !== undefined ? { workdir } : {},
|
|
292
|
+
...args.timeoutMs !== undefined ? { timeoutMs: args.timeoutMs } : {},
|
|
293
|
+
dshEnv: ctx.shellEnv.collect(exec),
|
|
294
|
+
...standingPolicy !== undefined ? { sandboxPolicy: standingPolicy } : {},
|
|
295
|
+
}
|
|
296
|
+
const result = await ctx.shell.run(ctx.shell.resolve({
|
|
297
|
+
...request,
|
|
298
|
+
signal: exec?.signal,
|
|
299
|
+
}))
|
|
300
|
+
if (result.aborted) {
|
|
301
|
+
const error = new Error('tool call aborted')
|
|
302
|
+
error.name = 'AbortError'
|
|
303
|
+
throw error
|
|
304
|
+
}
|
|
305
|
+
const stream = (s) => ({
|
|
306
|
+
text: s.text,
|
|
307
|
+
truncated: s.truncated,
|
|
308
|
+
...s.spillPath !== undefined ? { spillPath: s.spillPath } : {},
|
|
309
|
+
})
|
|
310
|
+
return {
|
|
311
|
+
kind: 'foreground',
|
|
312
|
+
exitCode: result.exitCode,
|
|
313
|
+
signal: result.signal,
|
|
314
|
+
timedOut: result.timedOut,
|
|
315
|
+
aborted: result.aborted,
|
|
316
|
+
timeoutMs: result.timeoutMs,
|
|
317
|
+
stdout: stream(result.stdout),
|
|
318
|
+
stderr: stream(result.stderr),
|
|
319
|
+
...result.sandbox !== undefined
|
|
320
|
+
? { sandbox: { mode: result.sandbox.mode, denied: result.sandbox.denied } }
|
|
321
|
+
: {},
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
ctx.tools.register({
|
|
326
|
+
name: 'fish',
|
|
327
|
+
description: TOOL_DESCRIPTION,
|
|
328
|
+
parameters: PARAMETERS,
|
|
329
|
+
output: OUTPUT,
|
|
330
|
+
execute,
|
|
331
|
+
})
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// Deterministic test surface: the tool description and the result renderer are
|
|
335
|
+
// pure, so unit tests can assert the bash→fish guidance and the syntax-hint
|
|
336
|
+
// injection without booting a harness or running a live shell.
|
|
337
|
+
export { FISH_SYNTAX_HINTS, TOOL_DESCRIPTION, fishSyntaxHint, renderResult }
|