elasticdash-sdk 0.2.6 → 0.2.7-beta
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.md +119 -18
- package/dist/dashboard-server.d.ts.map +1 -1
- package/dist/dashboard-server.js +76 -3
- package/dist/dashboard-server.js.map +1 -1
- package/dist/execution/tool-runner.d.ts.map +1 -1
- package/dist/execution/tool-runner.js +66 -5
- package/dist/execution/tool-runner.js.map +1 -1
- package/dist/index.cjs +57 -6
- package/dist/tool-runner-worker.js +27 -2
- package/dist/tool-runner-worker.js.map +1 -1
- package/dist/trigger-executor.d.ts.map +1 -1
- package/dist/trigger-executor.js +3 -1
- package/dist/trigger-executor.js.map +1 -1
- package/dist/workflow-runner-worker.js +24 -0
- package/dist/workflow-runner-worker.js.map +1 -1
- package/docs/agent-coding-instructions.md +8 -5
- package/docs/agent-integration-guide.md +130 -10
- package/package.json +1 -1
- package/src/dashboard-server.ts +71 -3
- package/src/execution/tool-runner.ts +62 -5
- package/src/tool-runner-worker.ts +22 -2
- package/src/trigger-executor.ts +3 -1
- package/src/workflow-runner-worker.ts +23 -0
|
@@ -43,6 +43,13 @@ async function readStdin(): Promise<string> {
|
|
|
43
43
|
|
|
44
44
|
const RESULT_PREFIX = '__ELASTICDASH_RESULT__:'
|
|
45
45
|
|
|
46
|
+
const WORKER_START_MS = Date.now()
|
|
47
|
+
function stage(name: string, extra?: Record<string, unknown>): void {
|
|
48
|
+
if (process.env.ELASTICDASH_DEBUG !== '1') return
|
|
49
|
+
const tail = extra ? ' ' + Object.entries(extra).map(([k, v]) => `${k}=${typeof v === 'string' ? v : JSON.stringify(v)}`).join(' ') : ''
|
|
50
|
+
process.stderr.write(`[elasticdash-worker workflow] stage=${name} pid=${process.pid} elapsedMs=${Date.now() - WORKER_START_MS}${tail}\n`)
|
|
51
|
+
}
|
|
52
|
+
|
|
46
53
|
const IS_DENO = typeof (globalThis as any).Deno !== 'undefined'
|
|
47
54
|
|
|
48
55
|
/** Write the result JSON to fd3 pipe (Node.js) or a prefixed stdout line (Deno).
|
|
@@ -215,10 +222,12 @@ async function loadAndWrapTools(
|
|
|
215
222
|
}
|
|
216
223
|
|
|
217
224
|
async function main() {
|
|
225
|
+
stage('boot')
|
|
218
226
|
// Keep a reference to the real process.exit so we can call it after flushing stdout.
|
|
219
227
|
const originalExit = process.exit.bind(process)
|
|
220
228
|
|
|
221
229
|
const raw = await readStdin()
|
|
230
|
+
stage('stdin-eof', { bytes: raw.length })
|
|
222
231
|
|
|
223
232
|
let payload: {
|
|
224
233
|
workflowsModulePath: string
|
|
@@ -249,6 +258,7 @@ async function main() {
|
|
|
249
258
|
originalExit(1)
|
|
250
259
|
return
|
|
251
260
|
}
|
|
261
|
+
stage('payload-parsed')
|
|
252
262
|
|
|
253
263
|
const { workflowsModulePath, toolsModulePath, workflowName, args, input, replayMode = false, checkpoint = 0, history = [], agentState, toolMockConfig, aiMockConfig, promptMockConfig, userPromptMockConfig, strict } = payload
|
|
254
264
|
|
|
@@ -273,6 +283,9 @@ async function main() {
|
|
|
273
283
|
originalValues[name] = globals[name]
|
|
274
284
|
globals[name] = fn
|
|
275
285
|
}
|
|
286
|
+
stage('tools-wrapped', { count: Object.keys(wrappedTools).length })
|
|
287
|
+
} else {
|
|
288
|
+
stage('tools-wrapped-skipped')
|
|
276
289
|
}
|
|
277
290
|
|
|
278
291
|
// Intercept process.exit() so that workflows that call it internally (e.g. agent
|
|
@@ -305,20 +318,25 @@ async function main() {
|
|
|
305
318
|
interceptFetch()
|
|
306
319
|
interceptRandom()
|
|
307
320
|
interceptDateNow()
|
|
321
|
+
stage('interceptors-installed')
|
|
308
322
|
|
|
309
323
|
try {
|
|
310
324
|
if (agentState) {
|
|
311
325
|
// Agent mid-trace resumption path: load ed_agents and resume from saved state
|
|
312
326
|
const agentsModulePath = workflowsModulePath.replace(/ed_workflows(\.[^.]+)?$/, 'ed_agents$1')
|
|
313
327
|
const agentsMod = await import(pathToFileURL(agentsModulePath).href)
|
|
328
|
+
stage('agents-module-imported')
|
|
314
329
|
if (typeof agentsMod.resumeAgentFromTrace !== 'function') {
|
|
315
330
|
throw new Error(`"resumeAgentFromTrace" is not an exported function in ${agentsModulePath}`)
|
|
316
331
|
}
|
|
332
|
+
stage('workflow-call-start', { mode: 'agent-resume' })
|
|
317
333
|
currentOutput = await (agentsMod.resumeAgentFromTrace as (s: AgentState) => Promise<unknown>)(agentState)
|
|
334
|
+
stage('workflow-call-end', { mode: 'agent-resume' })
|
|
318
335
|
console.error('[worker] resumeAgentFromTrace resolved, currentOutput:', currentOutput)
|
|
319
336
|
} else {
|
|
320
337
|
// Standard workflow path
|
|
321
338
|
const workflowsMod = await import(pathToFileURL(workflowsModulePath).href)
|
|
339
|
+
stage('workflow-module-imported')
|
|
322
340
|
const workflowFn = workflowsMod[workflowName]
|
|
323
341
|
if (typeof workflowFn !== 'function') {
|
|
324
342
|
;(process as NodeJS.Process).exit = originalExit
|
|
@@ -328,7 +346,9 @@ async function main() {
|
|
|
328
346
|
}
|
|
329
347
|
// Standardize workflow argument resolution: always pass [input] if args is empty
|
|
330
348
|
const callArgs = args.length ? args : [input]
|
|
349
|
+
stage('workflow-call-start', { workflow: workflowName })
|
|
331
350
|
currentOutput = await (workflowFn as (...a: unknown[]) => unknown)(...callArgs)
|
|
351
|
+
stage('workflow-call-end', { workflow: workflowName })
|
|
332
352
|
console.error('[worker] workflowFn resolved, currentOutput:', currentOutput) // stderr so it's visible
|
|
333
353
|
}
|
|
334
354
|
} finally {
|
|
@@ -369,6 +389,7 @@ async function main() {
|
|
|
369
389
|
}
|
|
370
390
|
|
|
371
391
|
await recorder.flush()
|
|
392
|
+
stage('recorder-flushed')
|
|
372
393
|
|
|
373
394
|
const traceData = {
|
|
374
395
|
steps: context.trace.getSteps(),
|
|
@@ -380,9 +401,11 @@ async function main() {
|
|
|
380
401
|
|
|
381
402
|
if (workflowError) {
|
|
382
403
|
await writeResult({ ok: false, error: workflowError.message ?? String(workflowError), ...traceData })
|
|
404
|
+
stage('result-written', { ok: false })
|
|
383
405
|
originalExit(pendingExitCode ?? 1)
|
|
384
406
|
} else {
|
|
385
407
|
await writeResult({ ok: true, currentOutput, ...traceData })
|
|
408
|
+
stage('result-written', { ok: true })
|
|
386
409
|
originalExit(pendingExitCode ?? 0)
|
|
387
410
|
}
|
|
388
411
|
}
|