MCPcopy Create free account
hub / github.com/chekusu/wanman / createLocalRuntimeClient

Function createLocalRuntimeClient

packages/cli/src/runtime-client.ts:131–170  ·  view source on GitHub ↗
(port: number)

Source from the content-addressed store, hash-verified

129}
130
131export function createLocalRuntimeClient(port: number): RuntimeClient {
132 const getHealth = async (): Promise<RuntimeHealth> => {
133 const response = await fetch(`http://127.0.0.1:${port}/health`)
134 if (!response.ok) throw new Error(`Health failed with status ${response.status}`)
135 return await response.json() as RuntimeHealth
136 }
137
138 return {
139 waitForHealth: timeoutMs => waitForHealthWith(getHealth, timeoutMs),
140 getHealth,
141 listTasks: async () => {
142 const result = await localRpc<{ tasks: TaskInfo[] }>(port, 'task.list', {})
143 return result.tasks
144 },
145 listInitiatives: async () => {
146 const result = await localRpc<{ initiatives: RuntimeInitiative[] }>(port, 'initiative.list', {})
147 return result.initiatives
148 },
149 listCapsules: async () => {
150 const result = await localRpc<{ capsules: RuntimeCapsule[] }>(port, 'capsule.list', {})
151 return result.capsules
152 },
153 listArtifacts: async () => {
154 const result = await localRpc<{ artifacts: RuntimeArtifactRecord[] }>(port, 'artifact.list', {})
155 return summarizeArtifacts(result.artifacts)
156 },
157 createInitiative: async input => {
158 await localRpc(port, 'initiative.create', input)
159 },
160 sendMessage: async input => {
161 await localRpc(port, 'agent.send', input)
162 },
163 spawnAgent: async (template, name) => {
164 await localRpc(port, 'agent.spawn', { template, name })
165 },
166 updateTask: async input => {
167 await localRpc(port, 'task.update', input)
168 },
169 }
170}

Callers 2

startLocalSupervisorFunction · 0.85

Calls 3

waitForHealthWithFunction · 0.85
summarizeArtifactsFunction · 0.85
localRpcFunction · 0.85

Tested by

no test coverage detected