@cuylabs/agent-runtime-dapr 0.10.0 → 0.12.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/dist/{chunk-YS2CWYBQ.js → chunk-2TBZCBXE.js} +20 -23
- package/dist/{chunk-YQQTUE6B.js → chunk-6BLY7B7U.js} +41 -31
- package/dist/{chunk-MJKJT3ZO.js → chunk-EJBODJQR.js} +395 -278
- package/dist/{chunk-MQJ4LZOX.js → chunk-HQLQRXU5.js} +6 -3
- package/dist/{chunk-5CJIC4YB.js → chunk-VKPTE4J6.js} +28 -10
- package/dist/dispatch/index.d.ts +2 -2
- package/dist/dispatch/index.js +2 -2
- package/dist/execution/index.js +2 -2
- package/dist/host/index.d.ts +2 -2
- package/dist/host/index.js +5 -5
- package/dist/{index-BmM58WZa.d.ts → index-BY0FipV1.d.ts} +3 -5
- package/dist/{index-BEOwKSPI.d.ts → index-UtePd9on.d.ts} +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +5 -5
- package/dist/{invoker-B1jvz9DG.d.ts → invoker-B6ikdYaz.d.ts} +2 -4
- package/dist/team/index.js +5 -5
- package/dist/workflow/index.js +2 -2
- package/package.json +4 -4
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DaprSidecarClient
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-HQLQRXU5.js";
|
|
4
4
|
|
|
5
5
|
// src/workflow/types.ts
|
|
6
6
|
var TERMINAL_DAPR_WORKFLOW_STATUSES = /* @__PURE__ */ new Set([
|
|
@@ -628,10 +628,7 @@ function extractHumanInputResponse(value) {
|
|
|
628
628
|
}
|
|
629
629
|
function createDeniedToolCallResult(plan, reason, updatedAt, feedback) {
|
|
630
630
|
const resultText = reason || formatApprovalDeniedReason(plan.toolCall.toolName);
|
|
631
|
-
const correction = createApprovalCorrection(
|
|
632
|
-
plan.toolCall.toolName,
|
|
633
|
-
feedback
|
|
634
|
-
);
|
|
631
|
+
const correction = createApprovalCorrection(plan.toolCall.toolName, feedback);
|
|
635
632
|
const toolResult = {
|
|
636
633
|
toolCallId: plan.toolCall.toolCallId,
|
|
637
634
|
toolName: plan.toolCall.toolName,
|
|
@@ -704,19 +701,19 @@ function normalizeSteerSnapshots(payload) {
|
|
|
704
701
|
if (typeof steer.id !== "string" || !steer.id.trim() || typeof steer.message !== "string" || !steer.message.trim() || typeof steer.createdAt !== "string" || !steer.createdAt.trim()) {
|
|
705
702
|
return [];
|
|
706
703
|
}
|
|
707
|
-
return [
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
704
|
+
return [
|
|
705
|
+
{
|
|
706
|
+
id: steer.id.trim(),
|
|
707
|
+
message: steer.message.trim(),
|
|
708
|
+
createdAt: steer.createdAt.trim()
|
|
709
|
+
}
|
|
710
|
+
];
|
|
712
711
|
});
|
|
713
712
|
}
|
|
714
713
|
var EXTERNAL_EVENT_TIMEOUT = /* @__PURE__ */ Symbol("EXTERNAL_EVENT_TIMEOUT");
|
|
715
714
|
function* waitForExternalEventWithTimeout(context, eventName, timeoutMs) {
|
|
716
715
|
if (!context.waitForExternalEvent) {
|
|
717
|
-
throw new Error(
|
|
718
|
-
"Workflow context does not support waitForExternalEvent"
|
|
719
|
-
);
|
|
716
|
+
throw new Error("Workflow context does not support waitForExternalEvent");
|
|
720
717
|
}
|
|
721
718
|
const eventTask = context.waitForExternalEvent(eventName);
|
|
722
719
|
if (timeoutMs && timeoutMs > 0 && context.createTimer && context.whenAny) {
|
|
@@ -758,15 +755,12 @@ function createDaprAgentTurnWorkflowDefinition(options) {
|
|
|
758
755
|
context.setCustomStatus?.(summarizeWorkflowState(state));
|
|
759
756
|
if (state.phase === "model-step" && steeringEnabled && activityNames.steerDrain && options.steerDrain) {
|
|
760
757
|
const controlEvents = normalizeSteerSnapshots(
|
|
761
|
-
yield context.callActivity(
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
maxItems: MAX_CONTROL_EVENTS_PER_BOUNDARY
|
|
768
|
-
}
|
|
769
|
-
)
|
|
758
|
+
yield context.callActivity(activityNames.steerDrain, {
|
|
759
|
+
workflowInstanceId: context.getWorkflowInstanceId?.() ?? "",
|
|
760
|
+
sessionId: state.sessionId,
|
|
761
|
+
step: state.step,
|
|
762
|
+
maxItems: MAX_CONTROL_EVENTS_PER_BOUNDARY
|
|
763
|
+
})
|
|
770
764
|
);
|
|
771
765
|
if (controlEvents.length > 0) {
|
|
772
766
|
state = applyWorkflowInterventions(state, controlEvents, now());
|
|
@@ -778,7 +772,10 @@ function createDaprAgentTurnWorkflowDefinition(options) {
|
|
|
778
772
|
message: steerEvent.message
|
|
779
773
|
});
|
|
780
774
|
}
|
|
781
|
-
await bridge?.notifyCheckpoint(
|
|
775
|
+
await bridge?.notifyCheckpoint(
|
|
776
|
+
"intervention-commit-finish",
|
|
777
|
+
state
|
|
778
|
+
);
|
|
782
779
|
}
|
|
783
780
|
}
|
|
784
781
|
}
|
|
@@ -1,14 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DaprSidecarClient,
|
|
3
3
|
isDaprConflictError
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-HQLQRXU5.js";
|
|
5
5
|
|
|
6
6
|
// src/dispatch/runtime.ts
|
|
7
|
-
import {
|
|
8
|
-
ensureNonEmpty as ensureNonEmpty2,
|
|
9
|
-
mergeInspection,
|
|
10
|
-
sleep
|
|
11
|
-
} from "@cuylabs/agent-core";
|
|
7
|
+
import { ensureNonEmpty as ensureNonEmpty2, mergeInspection, sleep } from "@cuylabs/agent-core";
|
|
12
8
|
|
|
13
9
|
// src/host/invoker.ts
|
|
14
10
|
var DEFAULT_DAPR_HTTP_ENDPOINT = "http://127.0.0.1:3500";
|
|
@@ -224,7 +220,13 @@ function createDaprDispatchRecordWriter(options) {
|
|
|
224
220
|
return { ids: [], etag: entry.etag, exists: true };
|
|
225
221
|
}
|
|
226
222
|
return {
|
|
227
|
-
ids: [
|
|
223
|
+
ids: [
|
|
224
|
+
...new Set(
|
|
225
|
+
entry.value.filter(
|
|
226
|
+
(item) => typeof item === "string"
|
|
227
|
+
)
|
|
228
|
+
)
|
|
229
|
+
],
|
|
228
230
|
etag: entry.etag,
|
|
229
231
|
exists: true
|
|
230
232
|
};
|
|
@@ -268,7 +270,10 @@ function createDaprDispatchRecordWriter(options) {
|
|
|
268
270
|
});
|
|
269
271
|
await addRecordToIndex(globalIndexKey(), record.id);
|
|
270
272
|
if (record.parentSessionId) {
|
|
271
|
-
await addRecordToIndex(
|
|
273
|
+
await addRecordToIndex(
|
|
274
|
+
sessionIndexKey(record.parentSessionId),
|
|
275
|
+
record.id
|
|
276
|
+
);
|
|
272
277
|
}
|
|
273
278
|
}
|
|
274
279
|
};
|
|
@@ -298,9 +303,7 @@ function createWorkflowDispatchTarget(options) {
|
|
|
298
303
|
}
|
|
299
304
|
);
|
|
300
305
|
if (options.waitForStart) {
|
|
301
|
-
await options.client.waitForWorkflowStart(
|
|
302
|
-
prepared.workflowInstanceId
|
|
303
|
-
);
|
|
306
|
+
await options.client.waitForWorkflowStart(prepared.workflowInstanceId);
|
|
304
307
|
}
|
|
305
308
|
return {
|
|
306
309
|
sessionId: prepared.sessionId,
|
|
@@ -316,7 +319,10 @@ function createWorkflowDispatchTarget(options) {
|
|
|
316
319
|
const executionId = input.record.executionId ?? ensureNonEmpty2(input.record.id, "record.id");
|
|
317
320
|
await options.host.steerTurn(options.client, {
|
|
318
321
|
workflowInstanceId: executionId,
|
|
319
|
-
sessionId: input.record.sessionId ?? ensureNonEmpty2(
|
|
322
|
+
sessionId: input.record.sessionId ?? ensureNonEmpty2(
|
|
323
|
+
input.record.parentSessionId ?? "",
|
|
324
|
+
"record.sessionId"
|
|
325
|
+
),
|
|
320
326
|
message: input.message
|
|
321
327
|
});
|
|
322
328
|
},
|
|
@@ -497,7 +503,10 @@ function createDaprDispatchRuntime(options) {
|
|
|
497
503
|
);
|
|
498
504
|
const now = options.now ?? (() => (/* @__PURE__ */ new Date()).toISOString());
|
|
499
505
|
const createId = options.createId ?? (() => crypto.randomUUID());
|
|
500
|
-
const pollIntervalMs = Math.max(
|
|
506
|
+
const pollIntervalMs = Math.max(
|
|
507
|
+
25,
|
|
508
|
+
Math.floor(options.pollIntervalMs ?? DEFAULT_POLL_INTERVAL_MS)
|
|
509
|
+
);
|
|
501
510
|
const targets = new Map(
|
|
502
511
|
options.targets.map((target) => [target.name, target])
|
|
503
512
|
);
|
|
@@ -532,7 +541,13 @@ function createDaprDispatchRuntime(options) {
|
|
|
532
541
|
return { ids: [], etag: entry.etag, exists: true };
|
|
533
542
|
}
|
|
534
543
|
return {
|
|
535
|
-
ids: [
|
|
544
|
+
ids: [
|
|
545
|
+
...new Set(
|
|
546
|
+
entry.value.filter(
|
|
547
|
+
(item) => typeof item === "string"
|
|
548
|
+
)
|
|
549
|
+
)
|
|
550
|
+
],
|
|
536
551
|
etag: entry.etag,
|
|
537
552
|
exists: true
|
|
538
553
|
};
|
|
@@ -694,7 +709,10 @@ function createDaprDispatchRuntime(options) {
|
|
|
694
709
|
await saveRecord(record);
|
|
695
710
|
await addRecordToIndex(globalIndexKey(), record.id);
|
|
696
711
|
if (record.parentSessionId) {
|
|
697
|
-
await addRecordToIndex(
|
|
712
|
+
await addRecordToIndex(
|
|
713
|
+
sessionIndexKey(record.parentSessionId),
|
|
714
|
+
record.id
|
|
715
|
+
);
|
|
698
716
|
}
|
|
699
717
|
return cloneRecord(record);
|
|
700
718
|
},
|
|
@@ -714,7 +732,9 @@ function createDaprDispatchRuntime(options) {
|
|
|
714
732
|
}
|
|
715
733
|
const target = targets.get(current.targetType);
|
|
716
734
|
if (!target) {
|
|
717
|
-
throw new Error(
|
|
735
|
+
throw new Error(
|
|
736
|
+
`No target registered for dispatch target "${current.targetType}".`
|
|
737
|
+
);
|
|
718
738
|
}
|
|
719
739
|
const nextMessage = ensureNonEmpty2(message, "message");
|
|
720
740
|
await target.redirect({
|
|
@@ -738,7 +758,9 @@ function createDaprDispatchRuntime(options) {
|
|
|
738
758
|
}
|
|
739
759
|
const target = targets.get(current.targetType);
|
|
740
760
|
if (!target) {
|
|
741
|
-
throw new Error(
|
|
761
|
+
throw new Error(
|
|
762
|
+
`No target registered for dispatch target "${current.targetType}".`
|
|
763
|
+
);
|
|
742
764
|
}
|
|
743
765
|
await target.cancel({
|
|
744
766
|
record: cloneRecord(current),
|
|
@@ -905,13 +927,7 @@ function createDaprWorkflowDispatchExecutor(options) {
|
|
|
905
927
|
targets,
|
|
906
928
|
timeoutMs: options.timeoutMs,
|
|
907
929
|
pollIntervalMs: options.pollIntervalMs,
|
|
908
|
-
createRecord: ({
|
|
909
|
-
taskInput,
|
|
910
|
-
target,
|
|
911
|
-
dispatchId,
|
|
912
|
-
startedAt,
|
|
913
|
-
startResult
|
|
914
|
-
}) => createDispatchRecord({
|
|
930
|
+
createRecord: ({ taskInput, target, dispatchId, startedAt, startResult }) => createDispatchRecord({
|
|
915
931
|
taskTitle: taskInput.task.title,
|
|
916
932
|
prompt: taskInput.prompt,
|
|
917
933
|
parentSessionId: taskInput.parentSessionId,
|
|
@@ -938,13 +954,7 @@ function createDaprAppDispatchExecutor(options) {
|
|
|
938
954
|
targets,
|
|
939
955
|
timeoutMs: options.timeoutMs,
|
|
940
956
|
pollIntervalMs: options.pollIntervalMs,
|
|
941
|
-
createRecord: ({
|
|
942
|
-
taskInput,
|
|
943
|
-
target,
|
|
944
|
-
dispatchId,
|
|
945
|
-
startedAt,
|
|
946
|
-
startResult
|
|
947
|
-
}) => createDispatchRecord({
|
|
957
|
+
createRecord: ({ taskInput, target, dispatchId, startedAt, startResult }) => createDispatchRecord({
|
|
948
958
|
taskTitle: taskInput.task.title,
|
|
949
959
|
prompt: taskInput.prompt,
|
|
950
960
|
parentSessionId: taskInput.parentSessionId,
|