@agentfield/sdk 0.1.92-rc.19 → 0.1.92-rc.20
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/dist/index.d.ts +15 -0
- package/dist/index.js +52 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -274,6 +274,14 @@ interface ExecutionStatusUpdate {
|
|
|
274
274
|
progress?: number;
|
|
275
275
|
statusReason?: string;
|
|
276
276
|
}
|
|
277
|
+
interface RestartExecutionOptions {
|
|
278
|
+
scope?: 'workflow' | 'execution';
|
|
279
|
+
reuse?: 'succeeded-before' | 'all-succeeded' | 'none';
|
|
280
|
+
fork?: boolean;
|
|
281
|
+
reason?: string;
|
|
282
|
+
input?: Record<string, unknown>;
|
|
283
|
+
context?: Record<string, unknown>;
|
|
284
|
+
}
|
|
277
285
|
declare class AgentFieldClient {
|
|
278
286
|
private readonly http;
|
|
279
287
|
private readonly config;
|
|
@@ -295,7 +303,11 @@ declare class AgentFieldClient {
|
|
|
295
303
|
targetDid?: string;
|
|
296
304
|
agentNodeDid?: string;
|
|
297
305
|
agentNodeId?: string;
|
|
306
|
+
replaySourceRunId?: string;
|
|
307
|
+
replayBeforeExecutionId?: string;
|
|
308
|
+
replayMode?: string;
|
|
298
309
|
}): Promise<T>;
|
|
310
|
+
restartExecution(executionId: string, options?: RestartExecutionOptions): Promise<any>;
|
|
299
311
|
publishWorkflowEvent(event: {
|
|
300
312
|
executionId: string;
|
|
301
313
|
runId: string;
|
|
@@ -370,6 +382,9 @@ interface ExecutionMetadata {
|
|
|
370
382
|
callerDid?: string;
|
|
371
383
|
targetDid?: string;
|
|
372
384
|
agentNodeDid?: string;
|
|
385
|
+
replaySourceRunId?: string;
|
|
386
|
+
replayBeforeExecutionId?: string;
|
|
387
|
+
replayMode?: string;
|
|
373
388
|
}
|
|
374
389
|
declare class ExecutionContext {
|
|
375
390
|
readonly input: any;
|
package/dist/index.js
CHANGED
|
@@ -2330,6 +2330,9 @@ var AgentFieldClient = class {
|
|
|
2330
2330
|
if (metadata?.targetDid) headers["X-Target-DID"] = metadata.targetDid;
|
|
2331
2331
|
if (metadata?.agentNodeDid) headers["X-Agent-Node-DID"] = metadata.agentNodeDid;
|
|
2332
2332
|
if (metadata?.agentNodeId) headers["X-Agent-Node-ID"] = metadata.agentNodeId;
|
|
2333
|
+
if (metadata?.replaySourceRunId) headers["X-AgentField-Replay-Source-Run-ID"] = metadata.replaySourceRunId;
|
|
2334
|
+
if (metadata?.replayBeforeExecutionId) headers["X-AgentField-Replay-Before-Execution-ID"] = metadata.replayBeforeExecutionId;
|
|
2335
|
+
if (metadata?.replayMode) headers["X-AgentField-Replay-Mode"] = metadata.replayMode;
|
|
2333
2336
|
const bodyStr = JSON.stringify({ input });
|
|
2334
2337
|
const authHeaders = this.didAuthenticator.signRequest(Buffer.from(bodyStr));
|
|
2335
2338
|
try {
|
|
@@ -2356,6 +2359,44 @@ var AgentFieldClient = class {
|
|
|
2356
2359
|
throw err;
|
|
2357
2360
|
}
|
|
2358
2361
|
}
|
|
2362
|
+
async restartExecution(executionId, options = {}) {
|
|
2363
|
+
if (!executionId) {
|
|
2364
|
+
throw new Error("executionId is required");
|
|
2365
|
+
}
|
|
2366
|
+
const body = {
|
|
2367
|
+
scope: options.scope ?? "workflow",
|
|
2368
|
+
reuse: options.reuse ?? "succeeded-before",
|
|
2369
|
+
fork: options.fork,
|
|
2370
|
+
reason: options.reason,
|
|
2371
|
+
input: options.input,
|
|
2372
|
+
context: options.context
|
|
2373
|
+
};
|
|
2374
|
+
const bodyStr = JSON.stringify(body);
|
|
2375
|
+
const authHeaders = this.didAuthenticator.signRequest(Buffer.from(bodyStr));
|
|
2376
|
+
try {
|
|
2377
|
+
const res = await this.http.post(
|
|
2378
|
+
`/api/v1/executions/${encodeURIComponent(executionId)}/restart`,
|
|
2379
|
+
bodyStr,
|
|
2380
|
+
{ headers: this.mergeHeaders({ "Content-Type": "application/json", ...authHeaders }) }
|
|
2381
|
+
);
|
|
2382
|
+
return res.data;
|
|
2383
|
+
} catch (err) {
|
|
2384
|
+
const respData = err?.response?.data;
|
|
2385
|
+
if (respData) {
|
|
2386
|
+
const status = err.response.status;
|
|
2387
|
+
const msg = respData.message || respData.error || JSON.stringify(respData);
|
|
2388
|
+
const enriched = Object.assign(
|
|
2389
|
+
new Error(`restart execution ${executionId} failed (${status}): ${msg}`),
|
|
2390
|
+
{
|
|
2391
|
+
status,
|
|
2392
|
+
responseData: respData
|
|
2393
|
+
}
|
|
2394
|
+
);
|
|
2395
|
+
throw enriched;
|
|
2396
|
+
}
|
|
2397
|
+
throw err;
|
|
2398
|
+
}
|
|
2399
|
+
}
|
|
2359
2400
|
async publishWorkflowEvent(event) {
|
|
2360
2401
|
const payload = {
|
|
2361
2402
|
execution_id: event.executionId,
|
|
@@ -2552,6 +2593,9 @@ var AgentFieldClient = class {
|
|
|
2552
2593
|
if (metadata.targetDid) headers["x-target-did"] = metadata.targetDid;
|
|
2553
2594
|
if (metadata.agentNodeDid) headers["x-agent-node-did"] = metadata.agentNodeDid;
|
|
2554
2595
|
if (metadata.agentNodeId) headers["x-agent-node-id"] = metadata.agentNodeId;
|
|
2596
|
+
if (metadata.replaySourceRunId) headers["x-agentfield-replay-source-run-id"] = metadata.replaySourceRunId;
|
|
2597
|
+
if (metadata.replayBeforeExecutionId) headers["x-agentfield-replay-before-execution-id"] = metadata.replayBeforeExecutionId;
|
|
2598
|
+
if (metadata.replayMode) headers["x-agentfield-replay-mode"] = metadata.replayMode;
|
|
2555
2599
|
return headers;
|
|
2556
2600
|
}
|
|
2557
2601
|
setDIDCredentials(did, privateKeyJwk) {
|
|
@@ -4344,7 +4388,10 @@ var Agent = class {
|
|
|
4344
4388
|
callerDid: parentMetadata?.callerDid,
|
|
4345
4389
|
targetDid: parentMetadata?.targetDid,
|
|
4346
4390
|
agentNodeDid: parentMetadata?.agentNodeDid,
|
|
4347
|
-
agentNodeId: this.config.nodeId
|
|
4391
|
+
agentNodeId: this.config.nodeId,
|
|
4392
|
+
replaySourceRunId: parentMetadata?.replaySourceRunId,
|
|
4393
|
+
replayBeforeExecutionId: parentMetadata?.replayBeforeExecutionId,
|
|
4394
|
+
replayMode: parentMetadata?.replayMode
|
|
4348
4395
|
});
|
|
4349
4396
|
this.executionLogger.system("agent.call.completed", "Remote agent call completed", {
|
|
4350
4397
|
target,
|
|
@@ -4610,7 +4657,10 @@ var Agent = class {
|
|
|
4610
4657
|
reasonerId: overrides?.reasonerId ?? normalized["x-reasoner-id"],
|
|
4611
4658
|
callerDid: overrides?.callerDid ?? normalized["x-caller-did"],
|
|
4612
4659
|
targetDid: overrides?.targetDid ?? normalized["x-target-did"],
|
|
4613
|
-
agentNodeDid: overrides?.agentNodeDid ?? normalized["x-agent-node-did"] ?? normalized["x-agent-did"]
|
|
4660
|
+
agentNodeDid: overrides?.agentNodeDid ?? normalized["x-agent-node-did"] ?? normalized["x-agent-did"],
|
|
4661
|
+
replaySourceRunId: overrides?.replaySourceRunId ?? normalized["x-agentfield-replay-source-run-id"],
|
|
4662
|
+
replayBeforeExecutionId: overrides?.replayBeforeExecutionId ?? normalized["x-agentfield-replay-before-execution-id"],
|
|
4663
|
+
replayMode: overrides?.replayMode ?? normalized["x-agentfield-replay-mode"]
|
|
4614
4664
|
};
|
|
4615
4665
|
}
|
|
4616
4666
|
handleHttpRequest(req, res) {
|