@adcp/sdk 16.0.0-beta.9 → 16.1.0
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 +54 -2
- package/bin/adcp-identity.js +3 -2
- package/dist/lib/client/core.d.mts +1 -1
- package/dist/lib/client/core.d.ts +1 -1
- package/dist/lib/core/AgentClient.d.mts +8 -1
- package/dist/lib/core/AgentClient.d.ts +8 -1
- package/dist/lib/core/AgentClient.js +10 -0
- package/dist/lib/core/AgentClient.mjs +10 -0
- package/dist/lib/core/AsyncHandler.d.mts +2 -0
- package/dist/lib/core/AsyncHandler.d.ts +2 -0
- package/dist/lib/core/AsyncHandler.js +1 -1
- package/dist/lib/core/AsyncHandler.mjs +1 -1
- package/dist/lib/core/ConversationTypes.d.mts +32 -0
- package/dist/lib/core/ConversationTypes.d.ts +32 -0
- package/dist/lib/core/SingleAgentClient.d.mts +11 -1
- package/dist/lib/core/SingleAgentClient.d.ts +11 -1
- package/dist/lib/core/SingleAgentClient.js +25 -6
- package/dist/lib/core/SingleAgentClient.mjs +26 -7
- package/dist/lib/core/TaskExecutor.d.mts +3 -1
- package/dist/lib/core/TaskExecutor.d.ts +3 -1
- package/dist/lib/core/TaskExecutor.js +127 -34
- package/dist/lib/core/TaskExecutor.mjs +127 -34
- package/dist/lib/core/task-deadline.d.mts +2 -0
- package/dist/lib/core/task-deadline.d.ts +2 -0
- package/dist/lib/core/task-deadline.js +20 -2
- package/dist/lib/core/task-deadline.mjs +19 -2
- package/dist/lib/identity-3.3/revocation.js +6 -7
- package/dist/lib/identity-3.3/revocation.mjs +6 -7
- package/dist/lib/identity-3.3/schemas.draft.js +1 -1
- package/dist/lib/identity-3.3/schemas.draft.mjs +1 -1
- package/dist/lib/identity-3.3/trust.d.mts +8 -0
- package/dist/lib/identity-3.3/trust.d.ts +8 -0
- package/dist/lib/identity-3.3/trust.js +41 -12
- package/dist/lib/identity-3.3/trust.mjs +40 -12
- package/dist/lib/index.d.mts +1 -1
- package/dist/lib/index.d.ts +1 -1
- package/dist/lib/server/account-sync-contract.js +4 -1
- package/dist/lib/server/account-sync-contract.mjs +4 -1
- package/dist/lib/server/create-adcp-server.js +1 -1
- package/dist/lib/server/create-adcp-server.mjs +1 -1
- package/dist/lib/server/decisioning/runtime/from-platform.js +22 -17
- package/dist/lib/server/decisioning/runtime/from-platform.mjs +22 -17
- package/dist/lib/signing/crypto.d.mts +1 -1
- package/dist/lib/signing/crypto.d.ts +1 -1
- package/dist/lib/signing/crypto.js +2 -45
- package/dist/lib/signing/crypto.mjs +2 -46
- package/dist/lib/signing/web-bot-auth.d.mts +18 -10
- package/dist/lib/signing/web-bot-auth.d.ts +18 -10
- package/dist/lib/signing/web-bot-auth.js +48 -28
- package/dist/lib/signing/web-bot-auth.mjs +49 -29
- package/dist/lib/testing/storyboard/validations.d.mts +1 -1
- package/dist/lib/testing/storyboard/validations.d.ts +1 -1
- package/dist/lib/v2/projection/catalog.d.mts +10 -0
- package/dist/lib/v2/projection/catalog.d.ts +10 -0
- package/dist/lib/v2/projection/catalog.js +5 -0
- package/dist/lib/v2/projection/catalog.mjs +4 -0
- package/dist/lib/v2/projection/creative-delivery.d.mts +15 -9
- package/dist/lib/v2/projection/creative-delivery.d.ts +15 -9
- package/dist/lib/v2/projection/creative-delivery.js +71 -10
- package/dist/lib/v2/projection/creative-delivery.mjs +71 -10
- package/dist/lib/v2/projection/v1-to-v2.js +3 -2
- package/dist/lib/v2/projection/v1-to-v2.mjs +4 -3
- package/dist/lib/version.d.mts +3 -3
- package/dist/lib/version.d.ts +3 -3
- package/dist/lib/version.js +3 -3
- package/dist/lib/version.mjs +3 -3
- package/docs/TYPE-SUMMARY.md +12 -2
- package/docs/guides/CREATIVE-DELIVERY.md +18 -1
- package/docs/guides/REPORTING-STABILITY.md +7 -7
- package/docs/llms.txt +3 -3
- package/docs/migration-14.x-rc-worksheet.md +4 -4
- package/docs/migration-agent-identity-3.3.md +56 -23
- package/docs/migration-reporting-storage-package.md +3 -3
- package/docs/releases/16.0.0.md +20 -0
- package/package.json +1 -1
|
@@ -2,7 +2,7 @@ import type { AgentConfig } from '../types';
|
|
|
2
2
|
import type { DeferredTaskStorage } from '../storage/interfaces';
|
|
3
3
|
import { type ValidationHookConfig } from '../validation/client-hooks';
|
|
4
4
|
import type { AdcpCapabilities } from '../utils/capabilities';
|
|
5
|
-
import type { Message, InputHandler, TaskOptions, TaskResult, TaskState, TaskStatus, TaskInfo, DirectPauseRecoveryRequest, WebhookUrlTemplate } from './ConversationTypes';
|
|
5
|
+
import type { Message, InputHandler, TaskOptions, TaskResult, TaskState, TaskStatus, TaskInfo, DirectPauseRecoveryRequest, TrackTaskRequest, TrackedTask, WebhookUrlTemplate } from './ConversationTypes';
|
|
6
6
|
import type { Activity } from './AsyncHandler';
|
|
7
7
|
import { GovernanceMiddleware } from './GovernanceMiddleware';
|
|
8
8
|
import type { GovernanceConfig } from './GovernanceTypes';
|
|
@@ -279,6 +279,8 @@ export declare class TaskExecutor {
|
|
|
279
279
|
* Set up submitted task with webhook
|
|
280
280
|
*/
|
|
281
281
|
private setupSubmittedTask;
|
|
282
|
+
/** Rebuild the polling continuation for seller work persisted by the caller. */
|
|
283
|
+
trackTask<T = unknown>(agent: AgentConfig, request: TrackTaskRequest): TrackedTask<T>;
|
|
282
284
|
/** Build polling closures around one authoritative seller work handle. */
|
|
283
285
|
private createSubmittedContinuation;
|
|
284
286
|
/**
|
|
@@ -636,6 +636,10 @@ class TaskExecutor {
|
|
|
636
636
|
* @internal
|
|
637
637
|
*/
|
|
638
638
|
async observeExternalTaskStatus(taskId, status, result, identity = {}) {
|
|
639
|
+
const task = this.activeTasks.get(taskId);
|
|
640
|
+
if (task && (identity.serverTaskId !== void 0 && task.serverTaskId !== void 0 && identity.serverTaskId !== task.serverTaskId || identity.taskType !== void 0 && identity.taskType !== task.taskName)) {
|
|
641
|
+
throw new import_errors2.ConfigurationError("The pushed task identity does not match the tracked operation.");
|
|
642
|
+
}
|
|
639
643
|
if (!["completed", "failed", "rejected", "canceled", "governance-denied", "aborted"].includes(status)) {
|
|
640
644
|
return { settled: false, result };
|
|
641
645
|
}
|
|
@@ -664,7 +668,9 @@ class TaskExecutor {
|
|
|
664
668
|
this.pendingExternalTaskObservations.set(taskId, pending);
|
|
665
669
|
return { settled: false, queued: true };
|
|
666
670
|
}
|
|
667
|
-
|
|
671
|
+
if (task && task.serverTaskId === void 0 && identity.serverTaskId !== void 0)
|
|
672
|
+
task.serverTaskId = identity.serverTaskId;
|
|
673
|
+
if (task && !TERMINAL_TASK_STATUSES.has(task.status)) this.updateTaskStatus(taskId, status, result);
|
|
668
674
|
return { settled: false, result };
|
|
669
675
|
}
|
|
670
676
|
/** Whether this process can safely settle or reject a durable callback for the operation. */
|
|
@@ -792,6 +798,9 @@ class TaskExecutor {
|
|
|
792
798
|
this.requireDeferredSettlementOperationRouting(this.config.deferredStorage, true);
|
|
793
799
|
}
|
|
794
800
|
const taskId = (0, import_task_deadline.getTaskOperationId)(options) ?? (0, import_crypto.randomUUID)();
|
|
801
|
+
if (this.activeTasks.has(taskId) || this.compactedTaskIds.has(taskId) || this.deferredTerminalPublicationTaskIds.has(taskId) || this.closedExternalTaskSettlementTaskIds.has(taskId) || this.externalTaskSettlementHandlers.has(taskId)) {
|
|
802
|
+
throw new import_errors2.ConfigurationError("operationId is already in use by this client; track the existing task instead.");
|
|
803
|
+
}
|
|
795
804
|
const startTime = Date.now();
|
|
796
805
|
const workingTimeout = this.config.workingTimeout || 12e4;
|
|
797
806
|
const wireAdcpVersion = options.wireAdcpVersion ?? this.config.wireAdcpVersion;
|
|
@@ -1067,12 +1076,14 @@ class TaskExecutor {
|
|
|
1067
1076
|
);
|
|
1068
1077
|
(0, import_abort.throwIfAborted)(postDispatchOptions.signal);
|
|
1069
1078
|
const respStatus = this.responseParser.getStatus(response);
|
|
1079
|
+
taskState.serverTaskId = this.responseParser.getTaskId(response);
|
|
1070
1080
|
await this.config.onActivity?.({
|
|
1071
1081
|
type: "protocol_response",
|
|
1072
1082
|
operation_id: taskId,
|
|
1073
1083
|
agent_id: agent.id,
|
|
1074
1084
|
context_id: options.contextId,
|
|
1075
1085
|
task_id: taskId,
|
|
1086
|
+
server_task_id: taskState.serverTaskId,
|
|
1076
1087
|
task_type: taskName,
|
|
1077
1088
|
status: respStatus,
|
|
1078
1089
|
payload: response,
|
|
@@ -1247,6 +1258,9 @@ class TaskExecutor {
|
|
|
1247
1258
|
}
|
|
1248
1259
|
async handleAsyncResponse(agent, taskId, taskName, params, response, messages, inputHandler, options = {}, debugLogs = [], startTime = Date.now(), deferTerminalTaskStatus = false, persistPausedContinuation = true, serverVersion = "v3", deferredClientContext, requireDeferredSettlementResumeAuthorization = false) {
|
|
1249
1260
|
const status = this.responseParser.getStatus(response);
|
|
1261
|
+
const serverTaskId = this.responseParser.getTaskId(response);
|
|
1262
|
+
const task = this.activeTasks.get(taskId);
|
|
1263
|
+
if (task && serverTaskId) task.serverTaskId = serverTaskId;
|
|
1250
1264
|
switch (status) {
|
|
1251
1265
|
case import_ProtocolResponseParser.ADCP_STATUS.COMPLETED:
|
|
1252
1266
|
const completedData = this.extractResponseData(response, debugLogs, taskName, serverVersion);
|
|
@@ -1602,8 +1616,70 @@ class TaskExecutor {
|
|
|
1602
1616
|
debug_logs: debugLogs
|
|
1603
1617
|
};
|
|
1604
1618
|
}
|
|
1619
|
+
/** Rebuild the polling continuation for seller work persisted by the caller. */
|
|
1620
|
+
trackTask(agent, request) {
|
|
1621
|
+
if (typeof request.taskId !== "string" || !request.taskId.trim()) {
|
|
1622
|
+
throw new TypeError("taskId must be a non-empty seller task id.");
|
|
1623
|
+
}
|
|
1624
|
+
if (typeof request.taskType !== "string" || !request.taskType.trim()) {
|
|
1625
|
+
throw new TypeError("taskType must be a non-empty tool name.");
|
|
1626
|
+
}
|
|
1627
|
+
const operationId = (0, import_task_deadline.getTaskOperationId)(request) ?? (0, import_crypto.randomUUID)();
|
|
1628
|
+
const existing = this.activeTasks.get(operationId);
|
|
1629
|
+
if (existing && (existing.serverTaskId !== request.taskId || existing.taskName !== request.taskType || existing.agent.id !== agent.id || existing.agent.protocol !== agent.protocol || existing.status === "pending")) {
|
|
1630
|
+
throw new import_errors2.ConfigurationError(
|
|
1631
|
+
"operationId is already tracked by this client for a different or dispatching task."
|
|
1632
|
+
);
|
|
1633
|
+
}
|
|
1634
|
+
if (this.deferredTerminalPublicationTaskIds.has(operationId) || this.closedExternalTaskSettlementTaskIds.has(operationId) || this.externalTaskSettlementHandlers.has(operationId)) {
|
|
1635
|
+
throw new import_errors2.ConfigurationError("This operation requires its original continuation or durable settlement recovery.");
|
|
1636
|
+
}
|
|
1637
|
+
const startTime = existing?.startTime ?? Date.now();
|
|
1638
|
+
if (!existing)
|
|
1639
|
+
this.activeTasks.set(operationId, {
|
|
1640
|
+
taskId: operationId,
|
|
1641
|
+
serverTaskId: request.taskId,
|
|
1642
|
+
taskName: request.taskType,
|
|
1643
|
+
status: "submitted",
|
|
1644
|
+
messages: [],
|
|
1645
|
+
startTime,
|
|
1646
|
+
attempt: 0,
|
|
1647
|
+
maxAttempts: 0,
|
|
1648
|
+
options: {},
|
|
1649
|
+
agent: { id: agent.id, name: agent.name, protocol: agent.protocol },
|
|
1650
|
+
serverVersion: "v3"
|
|
1651
|
+
});
|
|
1652
|
+
if (!existing) this.compactIntermediateTaskState(operationId, "submitted");
|
|
1653
|
+
const continuation = this.createSubmittedContinuation(
|
|
1654
|
+
agent,
|
|
1655
|
+
operationId,
|
|
1656
|
+
request.taskType,
|
|
1657
|
+
request.taskId,
|
|
1658
|
+
void 0,
|
|
1659
|
+
snapshotTransportOptions(request.transport ?? this.config.transport),
|
|
1660
|
+
{
|
|
1661
|
+
...this.buildMetadata({
|
|
1662
|
+
taskId: operationId,
|
|
1663
|
+
taskName: request.taskType,
|
|
1664
|
+
agent,
|
|
1665
|
+
startTime,
|
|
1666
|
+
status: "submitted"
|
|
1667
|
+
}),
|
|
1668
|
+
serverTaskId: request.taskId,
|
|
1669
|
+
a2aTaskId: request.cancelOnAbort === true ? request.a2aTaskId : void 0
|
|
1670
|
+
},
|
|
1671
|
+
false,
|
|
1672
|
+
"v3",
|
|
1673
|
+
this.config.wireAdcpVersion,
|
|
1674
|
+
this.config.versionEnvelope,
|
|
1675
|
+
request.signal
|
|
1676
|
+
);
|
|
1677
|
+
return { ...continuation, operationId };
|
|
1678
|
+
}
|
|
1605
1679
|
/** Build polling closures around one authoritative seller work handle. */
|
|
1606
|
-
createSubmittedContinuation(agent, taskId, taskName, serverTaskId, webhookUrl, pollingTransport, metadata, deferTerminalTaskStatus, serverVersion, wireAdcpVersion, versionEnvelope) {
|
|
1680
|
+
createSubmittedContinuation(agent, taskId, taskName, serverTaskId, webhookUrl, pollingTransport, metadata, deferTerminalTaskStatus, serverVersion, wireAdcpVersion, versionEnvelope, pollingSignal) {
|
|
1681
|
+
const registeredTask = this.activeTasks.get(taskId);
|
|
1682
|
+
const canPublish = (status) => registeredTask !== void 0 && this.activeTasks.get(taskId) === registeredTask && !TERMINAL_TASK_STATUSES.has(registeredTask.status) && registeredTask.status !== status;
|
|
1607
1683
|
return {
|
|
1608
1684
|
taskId: serverTaskId,
|
|
1609
1685
|
webhookUrl,
|
|
@@ -1613,25 +1689,27 @@ class TaskExecutor {
|
|
|
1613
1689
|
agent,
|
|
1614
1690
|
serverTaskId,
|
|
1615
1691
|
transportSnapshot,
|
|
1616
|
-
|
|
1692
|
+
pollingSignal,
|
|
1617
1693
|
taskName,
|
|
1618
1694
|
serverVersion,
|
|
1619
1695
|
wireAdcpVersion,
|
|
1620
|
-
versionEnvelope
|
|
1696
|
+
versionEnvelope,
|
|
1697
|
+
taskId
|
|
1621
1698
|
)).task;
|
|
1622
|
-
if (!deferTerminalTaskStatus && ["completed", "failed", "rejected", "canceled"].includes(task.status)) {
|
|
1699
|
+
if (!deferTerminalTaskStatus && ["completed", "failed", "rejected", "canceled"].includes(task.status) && canPublish(task.status)) {
|
|
1623
1700
|
this.updateTaskStatus(taskId, task.status, task.result, task.error);
|
|
1624
1701
|
}
|
|
1625
|
-
return task;
|
|
1702
|
+
return { ...task, operationId: taskId, serverTaskId };
|
|
1626
1703
|
},
|
|
1627
1704
|
waitForCompletion: async (pollInterval = 6e4, signal, requireExactTaskIdentity = false) => {
|
|
1628
1705
|
void requireExactTaskIdentity;
|
|
1706
|
+
const completionSignal = pollingSignal && signal ? AbortSignal.any([pollingSignal, signal]) : signal ?? pollingSignal;
|
|
1629
1707
|
const completed = await this.pollTaskCompletion(
|
|
1630
1708
|
agent,
|
|
1631
1709
|
serverTaskId,
|
|
1632
1710
|
pollInterval,
|
|
1633
1711
|
pollingTransport,
|
|
1634
|
-
|
|
1712
|
+
completionSignal,
|
|
1635
1713
|
metadata.a2aTaskId,
|
|
1636
1714
|
taskName,
|
|
1637
1715
|
taskId,
|
|
@@ -1639,7 +1717,9 @@ class TaskExecutor {
|
|
|
1639
1717
|
wireAdcpVersion,
|
|
1640
1718
|
versionEnvelope
|
|
1641
1719
|
);
|
|
1642
|
-
if (!deferTerminalTaskStatus || !TERMINAL_TASK_STATUSES.has(completed.status))
|
|
1720
|
+
if ((!deferTerminalTaskStatus || !TERMINAL_TASK_STATUSES.has(completed.status)) && // Cancellation, identity mismatches, missing tasks, and malformed
|
|
1721
|
+
// responses establish observation failure, not seller task failure.
|
|
1722
|
+
(!TERMINAL_TASK_STATUSES.has(completed.status) || isAuthoritativePolledTerminal(completed)) && canPublish(completed.status)) {
|
|
1643
1723
|
this.updateTaskStatus(taskId, completed.status, completed.data, completed.error);
|
|
1644
1724
|
}
|
|
1645
1725
|
return completed;
|
|
@@ -1652,7 +1732,9 @@ class TaskExecutor {
|
|
|
1652
1732
|
* local task publication only after those final wrappers return.
|
|
1653
1733
|
*/
|
|
1654
1734
|
attachSettledContinuationTaskStatus(taskId, result) {
|
|
1735
|
+
const registeredTask = this.activeTasks.get(taskId);
|
|
1655
1736
|
const publish = (status, data, error, identity) => {
|
|
1737
|
+
if (registeredTask === void 0 || this.activeTasks.get(taskId) !== registeredTask) return;
|
|
1656
1738
|
this.publishSettledTaskStatus(taskId, status, data, error, false, identity);
|
|
1657
1739
|
};
|
|
1658
1740
|
if (result.submitted) {
|
|
@@ -2283,7 +2365,7 @@ class TaskExecutor {
|
|
|
2283
2365
|
return [];
|
|
2284
2366
|
}
|
|
2285
2367
|
}
|
|
2286
|
-
async getTaskStatusWithRawResponse(agent, taskId, transport, signal, expectedTaskType, serverVersion, wireAdcpVersion, versionEnvelope) {
|
|
2368
|
+
async getTaskStatusWithRawResponse(agent, taskId, transport, signal, expectedTaskType, serverVersion, wireAdcpVersion, versionEnvelope, operationId) {
|
|
2287
2369
|
const toolName = agent.protocol === "mcp" ? "tasks_get" : "tasks/get";
|
|
2288
2370
|
const response = await import_protocols.ProtocolClient.callTool(
|
|
2289
2371
|
agent,
|
|
@@ -2302,7 +2384,8 @@ class TaskExecutor {
|
|
|
2302
2384
|
signal,
|
|
2303
2385
|
onTransportActivity: this.config.onTransportActivity,
|
|
2304
2386
|
transportActivityContext: {
|
|
2305
|
-
taskId
|
|
2387
|
+
taskId,
|
|
2388
|
+
...operationId !== void 0 && { operationId }
|
|
2306
2389
|
}
|
|
2307
2390
|
}
|
|
2308
2391
|
);
|
|
@@ -2334,12 +2417,13 @@ class TaskExecutor {
|
|
|
2334
2417
|
wireOptions?.versionEnvelope
|
|
2335
2418
|
)).task;
|
|
2336
2419
|
}
|
|
2337
|
-
async pollTaskCompletion(agent, taskId, pollInterval = 6e4, transport, signal, a2aCancellationTaskId, expectedTaskType, metadataTaskId
|
|
2420
|
+
async pollTaskCompletion(agent, taskId, pollInterval = 6e4, transport, signal, a2aCancellationTaskId, expectedTaskType, metadataTaskId, serverVersion, wireAdcpVersion, versionEnvelope) {
|
|
2338
2421
|
const transportSnapshot = snapshotTransportOptions(transport ?? this.config.transport);
|
|
2339
2422
|
if (!Number.isFinite(pollInterval) || pollInterval < 0 || pollInterval > MAX_TIMER_DELAY_MS) {
|
|
2340
2423
|
throw new RangeError(`pollInterval must be a finite non-negative number <= ${MAX_TIMER_DELAY_MS}`);
|
|
2341
2424
|
}
|
|
2342
2425
|
const pollStartTime = Date.now();
|
|
2426
|
+
const correlationId = metadataTaskId ?? taskId;
|
|
2343
2427
|
const withServerTaskId = (metadata) => ({
|
|
2344
2428
|
...metadata,
|
|
2345
2429
|
serverTaskId: taskId
|
|
@@ -2367,8 +2451,8 @@ class TaskExecutor {
|
|
|
2367
2451
|
error: `tasks/get polling was cancelled before a terminal state was observed: ${reason}`,
|
|
2368
2452
|
metadata: withServerTaskId(
|
|
2369
2453
|
this.buildMetadata({
|
|
2370
|
-
taskId:
|
|
2371
|
-
taskName: "unknown",
|
|
2454
|
+
taskId: correlationId,
|
|
2455
|
+
taskName: expectedTaskType ?? "unknown",
|
|
2372
2456
|
agent,
|
|
2373
2457
|
startTime: pollStartTime,
|
|
2374
2458
|
status: "failed"
|
|
@@ -2387,11 +2471,15 @@ class TaskExecutor {
|
|
|
2387
2471
|
expectedTaskType,
|
|
2388
2472
|
serverVersion,
|
|
2389
2473
|
wireAdcpVersion,
|
|
2390
|
-
versionEnvelope
|
|
2474
|
+
versionEnvelope,
|
|
2475
|
+
metadataTaskId
|
|
2391
2476
|
);
|
|
2392
2477
|
status = pollResult.task;
|
|
2393
2478
|
rawResponse = pollResult.rawResponse;
|
|
2394
2479
|
} catch (err) {
|
|
2480
|
+
if (signal?.aborted && agent.protocol === "a2a" && a2aCancellationTaskId && (0, import_abort.isAbortOrTimeoutError)(err)) {
|
|
2481
|
+
continue;
|
|
2482
|
+
}
|
|
2395
2483
|
if (err instanceof TaskBindingMismatchError) {
|
|
2396
2484
|
return (0, import_match.attachMatch)({
|
|
2397
2485
|
success: false,
|
|
@@ -2399,8 +2487,8 @@ class TaskExecutor {
|
|
|
2399
2487
|
error: err.message,
|
|
2400
2488
|
metadata: withServerTaskId(
|
|
2401
2489
|
this.buildMetadata({
|
|
2402
|
-
taskId:
|
|
2403
|
-
taskName: "unknown",
|
|
2490
|
+
taskId: correlationId,
|
|
2491
|
+
taskName: expectedTaskType ?? "unknown",
|
|
2404
2492
|
agent,
|
|
2405
2493
|
startTime: pollStartTime,
|
|
2406
2494
|
status: "failed",
|
|
@@ -2417,8 +2505,8 @@ class TaskExecutor {
|
|
|
2417
2505
|
error: `Task ${taskId} is no longer queryable \u2014 it may have been completed and evicted by the seller before this poll arrived. Consider using push notifications (reporting_webhook) instead of polling, or configuring a longer task retention TTL on the seller.`,
|
|
2418
2506
|
metadata: withServerTaskId(
|
|
2419
2507
|
this.buildMetadata({
|
|
2420
|
-
taskId:
|
|
2421
|
-
taskName: "unknown",
|
|
2508
|
+
taskId: correlationId,
|
|
2509
|
+
taskName: expectedTaskType ?? "unknown",
|
|
2422
2510
|
agent,
|
|
2423
2511
|
startTime: pollStartTime,
|
|
2424
2512
|
status: "failed"
|
|
@@ -2433,13 +2521,15 @@ class TaskExecutor {
|
|
|
2433
2521
|
success: false,
|
|
2434
2522
|
status: "failed",
|
|
2435
2523
|
error: "The seller returned a task outside the requested durable task identity.",
|
|
2436
|
-
metadata:
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
|
|
2442
|
-
|
|
2524
|
+
metadata: withServerTaskId(
|
|
2525
|
+
this.buildMetadata({
|
|
2526
|
+
taskId: correlationId,
|
|
2527
|
+
taskName: expectedTaskType ?? "unknown",
|
|
2528
|
+
agent,
|
|
2529
|
+
startTime: pollStartTime,
|
|
2530
|
+
status: "failed"
|
|
2531
|
+
})
|
|
2532
|
+
)
|
|
2443
2533
|
});
|
|
2444
2534
|
}
|
|
2445
2535
|
if (status.status === import_ProtocolResponseParser.ADCP_STATUS.COMPLETED) {
|
|
@@ -2452,7 +2542,7 @@ class TaskExecutor {
|
|
|
2452
2542
|
data: status.result,
|
|
2453
2543
|
metadata: withServerTaskId(
|
|
2454
2544
|
this.buildMetadata({
|
|
2455
|
-
taskId:
|
|
2545
|
+
taskId: correlationId,
|
|
2456
2546
|
taskName: status.taskType,
|
|
2457
2547
|
agent,
|
|
2458
2548
|
responseTimeMs: Date.now() - status.createdAt,
|
|
@@ -2471,11 +2561,11 @@ class TaskExecutor {
|
|
|
2471
2561
|
data: status.result,
|
|
2472
2562
|
error: this.extractOperationError(status.result),
|
|
2473
2563
|
adcpError: asyncResultErr,
|
|
2474
|
-
errorInstance: this.buildErrorInstance(
|
|
2564
|
+
errorInstance: this.buildErrorInstance(correlationId, asyncResultErr),
|
|
2475
2565
|
correlationId: (0, import_error_extraction.extractCorrelationId)(status.result),
|
|
2476
2566
|
metadata: withServerTaskId(
|
|
2477
2567
|
this.buildMetadata({
|
|
2478
|
-
taskId:
|
|
2568
|
+
taskId: correlationId,
|
|
2479
2569
|
taskName: status.taskType,
|
|
2480
2570
|
agent,
|
|
2481
2571
|
responseTimeMs: Date.now() - status.createdAt,
|
|
@@ -2495,11 +2585,11 @@ class TaskExecutor {
|
|
|
2495
2585
|
data: status.result,
|
|
2496
2586
|
error: status.error || status.message || `Task ${status.status}`,
|
|
2497
2587
|
adcpError: asyncFailedErr,
|
|
2498
|
-
errorInstance: this.buildErrorInstance(
|
|
2588
|
+
errorInstance: this.buildErrorInstance(correlationId, asyncFailedErr),
|
|
2499
2589
|
correlationId: (0, import_error_extraction.extractCorrelationId)(status.result),
|
|
2500
2590
|
metadata: withServerTaskId(
|
|
2501
2591
|
this.buildMetadata({
|
|
2502
|
-
taskId:
|
|
2592
|
+
taskId: correlationId,
|
|
2503
2593
|
taskName: status.taskType,
|
|
2504
2594
|
agent,
|
|
2505
2595
|
responseTimeMs: Date.now() - status.createdAt,
|
|
@@ -2517,7 +2607,7 @@ class TaskExecutor {
|
|
|
2517
2607
|
data: status.result,
|
|
2518
2608
|
metadata: withServerTaskId(
|
|
2519
2609
|
this.buildMetadata({
|
|
2520
|
-
taskId:
|
|
2610
|
+
taskId: correlationId,
|
|
2521
2611
|
taskName: status.taskType,
|
|
2522
2612
|
agent,
|
|
2523
2613
|
responseTimeMs: Date.now() - status.createdAt,
|
|
@@ -2534,8 +2624,8 @@ class TaskExecutor {
|
|
|
2534
2624
|
error: `tasks/get returned an unrecognizable response (parsed status: "unknown", taskId: "${status.taskId}"). The seller may not implement tasks/get as an AdCP skill, or its response did not match any supported envelope shape (flat AdCP, MCP structuredContent, or A2A DataPart artifact).`,
|
|
2535
2625
|
metadata: withServerTaskId(
|
|
2536
2626
|
this.buildMetadata({
|
|
2537
|
-
taskId:
|
|
2538
|
-
taskName: "unknown",
|
|
2627
|
+
taskId: correlationId,
|
|
2628
|
+
taskName: expectedTaskType ?? "unknown",
|
|
2539
2629
|
agent,
|
|
2540
2630
|
startTime: pollStartTime,
|
|
2541
2631
|
status: "failed",
|
|
@@ -4519,6 +4609,8 @@ class TaskExecutor {
|
|
|
4519
4609
|
task.status = status;
|
|
4520
4610
|
const taskInfo = {
|
|
4521
4611
|
taskId: task.taskId,
|
|
4612
|
+
operationId: task.taskId,
|
|
4613
|
+
serverTaskId: task.serverTaskId,
|
|
4522
4614
|
status,
|
|
4523
4615
|
taskType: task.taskName,
|
|
4524
4616
|
createdAt: task.startTime,
|
|
@@ -4533,6 +4625,7 @@ class TaskExecutor {
|
|
|
4533
4625
|
agent_id: task.agent.id,
|
|
4534
4626
|
context_id: void 0,
|
|
4535
4627
|
task_id: task.taskId,
|
|
4628
|
+
server_task_id: task.serverTaskId,
|
|
4536
4629
|
task_type: task.taskName,
|
|
4537
4630
|
status,
|
|
4538
4631
|
payload: result ?? (error ? { error } : void 0),
|
|
@@ -4547,7 +4640,7 @@ class TaskExecutor {
|
|
|
4547
4640
|
task.options = {};
|
|
4548
4641
|
delete task.pendingInput;
|
|
4549
4642
|
setTimeout(() => {
|
|
4550
|
-
this.cleanupTerminalTaskInspectionState(taskId);
|
|
4643
|
+
if (this.activeTasks.get(taskId) === task) this.cleanupTerminalTaskInspectionState(taskId);
|
|
4551
4644
|
}, 3e4).unref();
|
|
4552
4645
|
}
|
|
4553
4646
|
}
|