@deepseek-ai/dsh-subagent 0.2.2-rc.5 → 0.2.3-alpha.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/README.i18n.yaml +20 -8
- package/README.md +21 -5
- package/README.zh.md +21 -5
- package/lib/index.js +94 -42
- package/lib/typert.host.js +45 -7
- package/lib/typert.remote-client.d.ts.map +1 -1
- package/lib/typert.remote-client.js +2 -2
- package/lib/types/activation.d.ts +2 -0
- package/lib/types/activation.d.ts.map +1 -1
- package/lib/types/activation.js +4 -0
- package/lib/types/activation.js.map +1 -1
- package/lib/types/child-agent.d.ts +8 -4
- package/lib/types/child-agent.d.ts.map +1 -1
- package/lib/types/child-agent.js +14 -8
- package/lib/types/child-agent.js.map +1 -1
- package/lib/types/control-types.d.ts +1 -1
- package/lib/types/depth.d.ts +1 -1
- package/lib/types/depth.d.ts.map +1 -1
- package/lib/types/depth.js +3 -2
- package/lib/types/depth.js.map +1 -1
- package/lib/types/error.d.ts +83 -2
- package/lib/types/error.d.ts.map +1 -1
- package/lib/types/error.js +8 -1
- package/lib/types/error.js.map +1 -1
- package/lib/types/index.d.ts +11 -3
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/index.js +13 -1
- package/lib/types/index.js.map +1 -1
- package/lib/types/manager.d.ts +7 -1
- package/lib/types/manager.d.ts.map +1 -1
- package/lib/types/manager.js +30 -10
- package/lib/types/manager.js.map +1 -1
- package/lib/types/out-of-process.d.ts +1 -0
- package/lib/types/out-of-process.d.ts.map +1 -1
- package/lib/types/out-of-process.js +5 -3
- package/lib/types/out-of-process.js.map +1 -1
- package/lib/types/structured.d.ts.map +1 -1
- package/lib/types/structured.js +4 -2
- package/lib/types/structured.js.map +1 -1
- package/lib/types/types.d.ts +12 -4
- package/lib/types/types.d.ts.map +1 -1
- package/lib/types/types.js.map +1 -1
- package/package.json +49 -48
- package/src/activation.ts +5 -0
- package/src/child-agent.ts +14 -9
- package/src/control-types.ts +1 -1
- package/src/depth.ts +3 -2
- package/src/error.ts +86 -2
- package/src/index.ts +18 -2
- package/src/manager.ts +37 -11
- package/src/out-of-process.ts +5 -3
- package/src/structured.ts +4 -1
- package/src/types.ts +13 -4
package/src/out-of-process.ts
CHANGED
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
import { accessSync, constants, statSync } from 'node:fs'
|
|
14
14
|
import { isAbsolute } from 'node:path'
|
|
15
15
|
import type { ContentBlock } from '@deepseek-ai/dsh-llm'
|
|
16
|
+
import { SubagentError } from './error.ts'
|
|
16
17
|
import type { SubagentCapabilities, SubagentResult, SubagentRun, SubagentStopReason } from './types.ts'
|
|
17
18
|
|
|
18
19
|
/** Maximum UTF-8 size of {@link SubagentResult.diagnostic}. */
|
|
@@ -100,13 +101,14 @@ function isEnterableDirectory(path: string): boolean {
|
|
|
100
101
|
* @param label - which source supplied the value, for the diagnostic.
|
|
101
102
|
* @param cwd - the candidate working directory.
|
|
102
103
|
* @returns `cwd`, validated.
|
|
104
|
+
* @throws {SubagentError} `INVALID_CWD` when `cwd` is relative or not an enterable directory.
|
|
103
105
|
*/
|
|
104
106
|
export function assertUsableCwd(prefix: string, label: string, cwd: string): string {
|
|
105
107
|
if (!isAbsolute(cwd)) {
|
|
106
|
-
throw new
|
|
108
|
+
throw new SubagentError(`${prefix}: ${label} must be an absolute path: ${cwd}`, 'INVALID_CWD')
|
|
107
109
|
}
|
|
108
110
|
if (!isEnterableDirectory(cwd)) {
|
|
109
|
-
throw new
|
|
111
|
+
throw new SubagentError(`${prefix}: ${label} is not an accessible directory: ${cwd}`, 'INVALID_CWD')
|
|
110
112
|
}
|
|
111
113
|
return cwd
|
|
112
114
|
}
|
|
@@ -160,7 +162,7 @@ export async function settleRunResult(parts: RunResultSettlement): Promise<Subag
|
|
|
160
162
|
// Flatten post-publication transport failures while preserving diagnostics.
|
|
161
163
|
try {
|
|
162
164
|
parts.onError?.(toError(error), 'error')
|
|
163
|
-
} catch {
|
|
165
|
+
} catch (_diagnosticSinkFailed) {
|
|
164
166
|
// The diagnostic sink cannot reject the run result.
|
|
165
167
|
}
|
|
166
168
|
const collected = parts.collectDiagnostic?.()
|
package/src/structured.ts
CHANGED
|
@@ -14,6 +14,7 @@ import type { Context } from '@deepseek-ai/cordis'
|
|
|
14
14
|
import type { ToolSchema } from '@deepseek-ai/dsh-llm'
|
|
15
15
|
import type { ToolExecution, ToolRunContext } from '@deepseek-ai/dsh-tools'
|
|
16
16
|
import { ToolArgsError, validateJsonSchemaValue, type ObjectJsonSchema } from '@deepseek-ai/dsh-tools'
|
|
17
|
+
import { SubagentError } from './error.ts'
|
|
17
18
|
|
|
18
19
|
/** The model-facing tool name a structured child must call to finish. */
|
|
19
20
|
export const STRUCTURED_OUTPUT_TOOL = 'structured_output'
|
|
@@ -96,7 +97,9 @@ export function attachStructuredRuntime(
|
|
|
96
97
|
// ToolArgsError → isError result with INVALID_ARGS: the model retries
|
|
97
98
|
// within the same turn, exactly like a schema-validated defineTool call.
|
|
98
99
|
if (violations.length > 0) throw new ToolArgsError(violations)
|
|
99
|
-
if (!canComplete())
|
|
100
|
+
if (!canComplete()) {
|
|
101
|
+
throw new SubagentError('Process pending messages before submitting structured output.', 'STRUCTURED_OUTPUT_PENDING_INPUT')
|
|
102
|
+
}
|
|
100
103
|
// Two-phase commit, keyed by THIS execution: later transformable
|
|
101
104
|
// waterfalls may still turn the success into an error. ToolRuntime has
|
|
102
105
|
// already frozen model-bound arguments at the actual input boundary.
|
package/src/types.ts
CHANGED
|
@@ -13,6 +13,14 @@ import type { ContentBlock, MessageId } from '@deepseek-ai/dsh-llm'
|
|
|
13
13
|
import type { SessionEvent, SessionId } from '@deepseek-ai/dsh-session'
|
|
14
14
|
import type { ObjectJsonSchema } from '@deepseek-ai/dsh-tools'
|
|
15
15
|
|
|
16
|
+
/** Current concurrency capacity of one subagent tree; observing it reserves no slots. */
|
|
17
|
+
export interface SubagentCapacity {
|
|
18
|
+
/** Occupied slots, including starting, resident, and stopping children; excludes the root. */
|
|
19
|
+
readonly running: number
|
|
20
|
+
/** Configured maximum; running may exceed it after the limit is lowered. */
|
|
21
|
+
readonly limit: number
|
|
22
|
+
}
|
|
23
|
+
|
|
16
24
|
/** Identifies one subagent residency epoch across its lifecycle event pair. */
|
|
17
25
|
export type SubagentRunId = Branded<'SubagentRunId'>
|
|
18
26
|
|
|
@@ -152,7 +160,7 @@ export interface SubagentStartRequest {
|
|
|
152
160
|
readonly agentPreset?: string
|
|
153
161
|
/** Optional short display label persisted with a session-backed child. */
|
|
154
162
|
readonly label?: string
|
|
155
|
-
/**
|
|
163
|
+
/** Initial task; local continuable children record it as a message from the parent agent. */
|
|
156
164
|
readonly prompt: ContentBlock[]
|
|
157
165
|
/**
|
|
158
166
|
* The spawning agent. Its effective directory supplies the default cwd;
|
|
@@ -225,9 +233,10 @@ export interface ContinuableCreateRequest {
|
|
|
225
233
|
*/
|
|
226
234
|
export interface ContinuableCreateSpec {
|
|
227
235
|
/**
|
|
228
|
-
*
|
|
229
|
-
*
|
|
230
|
-
*
|
|
236
|
+
* Unmodified completed-turn prefix of the parent's log, contiguous from seq
|
|
237
|
+
* 0 with lossless JSON and balanced steps and turns; absent for a fresh child.
|
|
238
|
+
* The manager uses its length as the fork cut and stores the prefix as
|
|
239
|
+
* supplied, so a transformed prefix would diverge from the parent history.
|
|
231
240
|
*/
|
|
232
241
|
readonly seed?: readonly SessionEvent[]
|
|
233
242
|
}
|