@deepseek-ai/dsh-workflow-ptc 0.2.2-rc.4 → 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/src/runtime.ts CHANGED
@@ -7,7 +7,7 @@
7
7
 
8
8
  import * as vm from 'node:vm'
9
9
  import { brandString } from '@deepseek-ai/dsh-brand'
10
- import type { ContentBlock } from '@deepseek-ai/dsh-llm'
10
+ import { extractTextContent } from '@deepseek-ai/dsh-llm/message'
11
11
  import type { SessionId } from '@deepseek-ai/dsh-session'
12
12
  import { assertObjectJsonSchema, JsonSchemaError } from '@deepseek-ai/dsh-tools'
13
13
  import type { ObjectJsonSchema } from '@deepseek-ai/dsh-tools'
@@ -34,14 +34,6 @@ const SUPPORTED_AGENT_OPTIONS = new Set(['label', 'phase', 'schema', 'provider',
34
34
  /** Deferred Claude Code options we name explicitly in the rejection message. */
35
35
  const DEFERRED_AGENT_OPTIONS = new Set(['effort', 'isolation', 'agentType'])
36
36
 
37
- /** Flatten a child's final output blocks to text (the non-schema `agent()` result). */
38
- function outputText(blocks: ContentBlock[]): string {
39
- return blocks
40
- .filter((block): block is Extract<ContentBlock, { type: 'text' }> => block.type === 'text')
41
- .map(block => block.text)
42
- .join('')
43
- }
44
-
45
37
  /** A short display label derived from the prompt when the script passes none. */
46
38
  function defaultLabel(prompt: string): string {
47
39
  const newline = prompt.indexOf('\n')
@@ -109,7 +101,13 @@ export class WorkflowExecution {
109
101
  const value = raw === undefined ? null : this.materializeResult(raw)
110
102
  return { value, stopReason: 'completed', agentsStarted: this.started }
111
103
  } catch (error: unknown) {
112
- return { value: null, stopReason: 'error', error: renderThrown(error), agentsStarted: this.started }
104
+ return {
105
+ value: null,
106
+ stopReason: 'error',
107
+ error: renderThrown(error),
108
+ ...error instanceof WorkflowError ? { errorCode: error.code } : {},
109
+ agentsStarted: this.started,
110
+ }
113
111
  }
114
112
  }
115
113
 
@@ -216,7 +214,7 @@ export class WorkflowExecution {
216
214
  return result.structured
217
215
  }
218
216
  this.observer.agentEnd({ ...info, outcome: 'completed' })
219
- return outputText(result.output)
217
+ return extractTextContent(result.output)
220
218
  }
221
219
  this.observer.agentEnd({ ...info, outcome: 'failed' })
222
220
  return null