@zumikua/dsh-junie-subagent 0.1.0 → 0.1.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/helpers.js +94 -0
- package/index.js +5 -17
- package/package.json +2 -6
package/helpers.js
ADDED
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Provider-side helpers for out-of-process subagent backends.
|
|
3
|
+
*
|
|
4
|
+
* These mirror the contracts of the `@deepseek-ai/dsh-subagent/out-of-process`
|
|
5
|
+
* vocabulary, but live here on purpose: a published bundle installs into a
|
|
6
|
+
* profile whose module resolution cannot see the Host's own packages, so the
|
|
7
|
+
* plugin must not import `@deepseek-ai/*` at runtime.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
import { existsSync } from 'node:fs'
|
|
11
|
+
import { isAbsolute } from 'node:path'
|
|
12
|
+
|
|
13
|
+
/** A child in another process cannot honour parent-enforced start features. */
|
|
14
|
+
export const NO_START_CAPABILITIES = Object.freeze({
|
|
15
|
+
agentOptions: false,
|
|
16
|
+
agentPreset: false,
|
|
17
|
+
outputSchema: false,
|
|
18
|
+
depthLimit: false,
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Reject a timing value the seam would refuse anyway, with the plugin's name in
|
|
23
|
+
* the message.
|
|
24
|
+
* @param prefix - the reporting plugin's diagnostic prefix.
|
|
25
|
+
* @param name - the configuration key being validated.
|
|
26
|
+
* @param value - the value to check.
|
|
27
|
+
*/
|
|
28
|
+
export function assertPositiveFinite(prefix, name, value) {
|
|
29
|
+
if (typeof value !== 'number' || !Number.isFinite(value) || value <= 0) {
|
|
30
|
+
throw new Error(`${prefix}: ${name} must be a positive finite number, received ${String(value)}`)
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Reject a working directory the child process could not enter.
|
|
36
|
+
* @param prefix - the reporting plugin's diagnostic prefix.
|
|
37
|
+
* @param label - describes the source of the value, for the message.
|
|
38
|
+
* @param value - the candidate directory.
|
|
39
|
+
* @returns the same value, for chaining.
|
|
40
|
+
*/
|
|
41
|
+
export function assertUsableCwd(prefix, label, value) {
|
|
42
|
+
if (typeof value !== 'string' || value.length === 0 || !isAbsolute(value)) {
|
|
43
|
+
throw new Error(`${prefix}: ${label} must be an absolute path, received ${String(value)}`)
|
|
44
|
+
}
|
|
45
|
+
if (!existsSync(value)) throw new Error(`${prefix}: ${label} does not exist: ${value}`)
|
|
46
|
+
return value
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Settle one run under the seam contract: `result` never rejects, and the
|
|
51
|
+
* abort listener the caller registered is removed on every path.
|
|
52
|
+
* @param parts - the attempt, the partial-output readers, and the abort wiring.
|
|
53
|
+
* @returns the settled result.
|
|
54
|
+
*/
|
|
55
|
+
export async function settleRunResult(parts) {
|
|
56
|
+
const { attempt, collectOutput, collectDiagnostic, cancelled, signal, onAbort } = parts
|
|
57
|
+
try {
|
|
58
|
+
return await attempt()
|
|
59
|
+
} catch (error) {
|
|
60
|
+
const diagnostic = collectDiagnostic()
|
|
61
|
+
return {
|
|
62
|
+
output: collectOutput(),
|
|
63
|
+
stopReason: cancelled() ? 'aborted' : 'error',
|
|
64
|
+
...(diagnostic === undefined || diagnostic === '' ? {} : { diagnostic }),
|
|
65
|
+
}
|
|
66
|
+
} finally {
|
|
67
|
+
signal?.removeEventListener('abort', onAbort)
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Publish the seam run handle for an out-of-process child. `dispose()` is
|
|
73
|
+
* idempotent: it removes the abort listener, requests cancellation without
|
|
74
|
+
* assuming the child cooperates, then awaits the backend teardown.
|
|
75
|
+
* @param parts - run identity, the settled result, cancellation, and teardown.
|
|
76
|
+
* @returns the external run handle.
|
|
77
|
+
*/
|
|
78
|
+
export function subprocessRunHandle(parts) {
|
|
79
|
+
const { id, result, signal, onAbort, requestCancel, teardown } = parts
|
|
80
|
+
let disposal
|
|
81
|
+
const dispose = () => {
|
|
82
|
+
disposal ??= (async () => {
|
|
83
|
+
signal?.removeEventListener('abort', onAbort)
|
|
84
|
+
try {
|
|
85
|
+
requestCancel()
|
|
86
|
+
} catch {
|
|
87
|
+
// Cancellation is best effort; teardown still owns the escalation.
|
|
88
|
+
}
|
|
89
|
+
await teardown()
|
|
90
|
+
})()
|
|
91
|
+
return disposal
|
|
92
|
+
}
|
|
93
|
+
return { id, result, dispose }
|
|
94
|
+
}
|
package/index.js
CHANGED
|
@@ -20,8 +20,7 @@ import {
|
|
|
20
20
|
assertUsableCwd,
|
|
21
21
|
settleRunResult,
|
|
22
22
|
subprocessRunHandle,
|
|
23
|
-
} from '
|
|
24
|
-
import Schema from '@deepseek-ai/schemastery'
|
|
23
|
+
} from './helpers.js'
|
|
25
24
|
|
|
26
25
|
export const name = 'junie-subagent'
|
|
27
26
|
|
|
@@ -298,22 +297,11 @@ function configRouteHandler(ctx, cfg) {
|
|
|
298
297
|
}
|
|
299
298
|
|
|
300
299
|
/**
|
|
301
|
-
*
|
|
302
|
-
*
|
|
300
|
+
* Note: this bundle deliberately exports no `Config` schema. A schemastery
|
|
301
|
+
* schema would need `@deepseek-ai/schemastery`, which is not resolvable from a
|
|
302
|
+
* profile-installed bundle; the row defaults are applied by `normalize()`
|
|
303
|
+
* instead, and the settings page is the supported way to change them.
|
|
303
304
|
*/
|
|
304
|
-
export const Config = Schema.object({
|
|
305
|
-
providerName: Schema.string().default('junie'),
|
|
306
|
-
command: Schema.string().default(''),
|
|
307
|
-
args: Schema.array(Schema.string()).default([]),
|
|
308
|
-
model: Schema.string().default('mix.normal'),
|
|
309
|
-
effort: Schema.string().default('high'),
|
|
310
|
-
braveMode: Schema.string().default('brave-auto'),
|
|
311
|
-
permission: Schema.string().default('reject'),
|
|
312
|
-
timeoutMs: Schema.number().default(900000),
|
|
313
|
-
graceMs: Schema.number().default(3000),
|
|
314
|
-
})
|
|
315
|
-
|
|
316
|
-
|
|
317
305
|
|
|
318
306
|
/** ACP terminal reasons mapped onto the seam's stop-reason vocabulary. */
|
|
319
307
|
const STOP_REASONS = new Map([
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zumikua/dsh-junie-subagent",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
},
|
|
35
35
|
"files": [
|
|
36
36
|
"index.js",
|
|
37
|
+
"helpers.js",
|
|
37
38
|
"client.js",
|
|
38
39
|
"cordis.patch.yml",
|
|
39
40
|
"locale/*.json",
|
|
@@ -45,11 +46,6 @@
|
|
|
45
46
|
"engines": {
|
|
46
47
|
"dsh": ">=0.2.1-rc.2"
|
|
47
48
|
},
|
|
48
|
-
"peerDependencies": {
|
|
49
|
-
"@deepseek-ai/cordis": "^4.0.4",
|
|
50
|
-
"@deepseek-ai/dsh-subagent": "0.2.1-rc.2",
|
|
51
|
-
"@deepseek-ai/schemastery": "^3.0.0"
|
|
52
|
-
},
|
|
53
49
|
"dsh": {
|
|
54
50
|
"bundle": {
|
|
55
51
|
"patch": "./cordis.patch.yml"
|