forked from claude-code-best/claude-code
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhostHandle.ts
More file actions
42 lines (38 loc) · 1.29 KB
/
Copy pathhostHandle.ts
File metadata and controls
42 lines (38 loc) · 1.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import {
createHostHandle,
unwrapHostHandle,
type HostHandle,
} from '@claude-code-best/workflow-engine'
import type { CanUseToolFn } from '../hooks/useCanUseTool.js'
import type { AssistantMessage } from '../types/message.js'
import type { AgentId } from '../types/ids.js'
import type { ToolUseContext } from '../Tool.js'
/** Opaque bundle held inside HostHandle (unpacked on the core side). */
export type WorkflowHostBundle = {
toolUseContext: ToolUseContext
canUseTool: CanUseToolFn
parentMessage?: AssistantMessage
agentId?: AgentId
}
/**
* Shared: builds the host bundle from toolUseContext/canUseTool.
* parentMessage is optional (absent on the panel launch path — claudeCodeBackend never reads it).
*/
export function buildHostBundle(
toolUseContext: WorkflowHostBundle['toolUseContext'],
canUseTool: WorkflowHostBundle['canUseTool'],
parentMessage?: AssistantMessage,
): WorkflowHostBundle {
return {
toolUseContext,
canUseTool,
...(parentMessage !== undefined ? { parentMessage } : {}),
agentId: toolUseContext.agentId,
}
}
export function makeHostHandle(bundle: WorkflowHostBundle): HostHandle {
return createHostHandle(bundle)
}
export function readHostBundle(handle: HostHandle): WorkflowHostBundle {
return unwrapHostHandle(handle) as WorkflowHostBundle
}