@cuylabs/agent-runtime-dapr 4.9.0 → 5.0.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.
@@ -5,18 +5,18 @@ import {
5
5
  createWorkflowDispatchTarget,
6
6
  invokeRemoteAgentRun,
7
7
  readWorkflowCompletion
8
- } from "./chunk-6BLY7B7U.js";
8
+ } from "./chunk-BQLQLDWZ.js";
9
9
  import {
10
10
  DaprExecutionStore,
11
11
  createDaprExecutionObserver,
12
12
  createDaprLoggingObserver,
13
13
  createWorkflowObserverBridge
14
- } from "./chunk-J3IJLF6U.js";
14
+ } from "./chunk-POIJYTT6.js";
15
15
  import {
16
16
  DaprWorkflowClient,
17
17
  createDaprAgentTurnWorkflowKit,
18
18
  isTerminalDaprWorkflowStatus
19
- } from "./chunk-2TBZCBXE.js";
19
+ } from "./chunk-L6SWGYZC.js";
20
20
  import {
21
21
  DaprSidecarClient,
22
22
  __export,
@@ -5299,13 +5299,13 @@ function createDaprWorkflowFollowUpRuntime(options) {
5299
5299
  }
5300
5300
 
5301
5301
  // src/host/workflow/workflow-host.ts
5302
- import { randomUUID } from "crypto";
5303
5302
  import process2 from "process";
5304
5303
  import {
5304
+ commitAgentContextCompaction,
5305
5305
  MiddlewareRunner,
5306
- SessionManager,
5307
5306
  isApprovalMiddleware as isApprovalMiddleware2,
5308
5307
  createAgentWorkflowTurnState,
5308
+ restoreAgentWorkflowMessages,
5309
5309
  snapshotAgentWorkflowMessage,
5310
5310
  snapshotAgentWorkflowMessages
5311
5311
  } from "@cuylabs/agent-core";
@@ -8200,24 +8200,72 @@ function createDaprTeamRunner(options) {
8200
8200
  };
8201
8201
  }
8202
8202
 
8203
- // src/host/workflow/workflow-host.ts
8204
- function buildToolRecord(agent) {
8205
- return Object.fromEntries(
8206
- agent.getTools().map((tool) => [tool.id, tool])
8207
- );
8203
+ // src/host/workflow/control-requests.ts
8204
+ import { randomUUID } from "crypto";
8205
+ function validateControlRequestInput(input) {
8206
+ if (!input.workflowInstanceId.trim()) {
8207
+ throw new Error(
8208
+ '"workflowInstanceId" is required and must be a non-empty string.'
8209
+ );
8210
+ }
8211
+ const sessionId = input.sessionId.trim();
8212
+ if (!sessionId) {
8213
+ throw new Error('"sessionId" is required and must be a non-empty string.');
8214
+ }
8215
+ const message = input.message.trim();
8216
+ if (!message) {
8217
+ throw new Error('"message" is required and must be a non-empty string.');
8218
+ }
8219
+ return {
8220
+ sessionId,
8221
+ message,
8222
+ timestamp: input.timestamp ?? Date.now()
8223
+ };
8208
8224
  }
8209
- function createWorkflowToolMiddlewareRunner(agent) {
8210
- const inherited = agent.getMiddlewareRunner().getMiddleware();
8211
- return new MiddlewareRunner(
8212
- inherited.filter((mw) => !isApprovalMiddleware2(mw))
8213
- );
8225
+ function createSteeringRequest(input) {
8226
+ const { sessionId, message, timestamp } = validateControlRequestInput(input);
8227
+ return {
8228
+ id: input.id?.trim() || randomUUID(),
8229
+ sessionId,
8230
+ message,
8231
+ timestamp
8232
+ };
8233
+ }
8234
+ function createFollowUpRequest(input) {
8235
+ const { sessionId, message, timestamp } = validateControlRequestInput(input);
8236
+ return {
8237
+ id: input.id?.trim() || randomUUID(),
8238
+ sessionId,
8239
+ message,
8240
+ timestamp
8241
+ };
8242
+ }
8243
+
8244
+ // src/host/workflow/session.ts
8245
+ import { randomUUID as randomUUID2 } from "crypto";
8246
+ import { SessionManager } from "@cuylabs/agent-core";
8247
+ function createWorkflowSessionId(sessionId) {
8248
+ const normalized = sessionId?.trim();
8249
+ return normalized && normalized.length > 0 ? normalized : `workflow_${randomUUID2().slice(0, 8)}`;
8250
+ }
8251
+ function normalizeWorkflowInstanceId(explicitInstanceId, sessionId) {
8252
+ const normalized = explicitInstanceId?.trim();
8253
+ return normalized && normalized.length > 0 ? normalized : `turn_${sessionId}_${randomUUID2().slice(0, 8)}`;
8254
+ }
8255
+ function createWorkflowUserMessage(message, createdAt) {
8256
+ return {
8257
+ id: randomUUID2(),
8258
+ role: "user",
8259
+ content: message,
8260
+ createdAt: new Date(createdAt)
8261
+ };
8214
8262
  }
8215
8263
  function createScopedSessionManager(agent) {
8216
- return new SessionManager(agent.getSessionManager().getStorage());
8264
+ return new SessionManager(agent.getSessionManager().getStore());
8217
8265
  }
8218
- async function ensureSessionLoaded(agent, sessionId, options) {
8266
+ async function ensureWorkflowSessionLoaded(agent, sessionId, options) {
8219
8267
  const sessions = createScopedSessionManager(agent);
8220
- const storage = sessions.getStorage();
8268
+ const storage = sessions.getStore();
8221
8269
  let existingEntries;
8222
8270
  try {
8223
8271
  existingEntries = await storage.read(sessionId);
@@ -8240,61 +8288,18 @@ async function ensureSessionLoaded(agent, sessionId, options) {
8240
8288
  await sessions.load(sessionId);
8241
8289
  return sessions;
8242
8290
  }
8243
- function createUserMessage(message, createdAt) {
8244
- return {
8245
- id: randomUUID(),
8246
- role: "user",
8247
- content: message,
8248
- createdAt: new Date(createdAt)
8249
- };
8250
- }
8251
- function normalizeWorkflowInstanceId(explicitInstanceId, sessionId) {
8252
- const normalized = explicitInstanceId?.trim();
8253
- return normalized && normalized.length > 0 ? normalized : `turn_${sessionId}_${randomUUID().slice(0, 8)}`;
8254
- }
8255
- function createSteeringRequest(input) {
8256
- if (!input.workflowInstanceId.trim()) {
8257
- throw new Error(
8258
- '"workflowInstanceId" is required and must be a non-empty string.'
8259
- );
8260
- }
8261
- const sessionId = input.sessionId.trim();
8262
- if (!sessionId) {
8263
- throw new Error('"sessionId" is required and must be a non-empty string.');
8264
- }
8265
- const message = input.message.trim();
8266
- if (!message) {
8267
- throw new Error('"message" is required and must be a non-empty string.');
8268
- }
8269
- const timestamp = input.timestamp ?? Date.now();
8270
- return {
8271
- id: input.id?.trim() || randomUUID(),
8272
- sessionId,
8273
- message,
8274
- timestamp
8275
- };
8291
+
8292
+ // src/host/workflow/workflow-host.ts
8293
+ function buildToolRecord(agent) {
8294
+ return Object.fromEntries(
8295
+ agent.getTools().map((tool) => [tool.id, tool])
8296
+ );
8276
8297
  }
8277
- function createFollowUpRequest(input) {
8278
- if (!input.workflowInstanceId.trim()) {
8279
- throw new Error(
8280
- '"workflowInstanceId" is required and must be a non-empty string.'
8281
- );
8282
- }
8283
- const sessionId = input.sessionId.trim();
8284
- if (!sessionId) {
8285
- throw new Error('"sessionId" is required and must be a non-empty string.');
8286
- }
8287
- const message = input.message.trim();
8288
- if (!message) {
8289
- throw new Error('"message" is required and must be a non-empty string.');
8290
- }
8291
- const timestamp = input.timestamp ?? Date.now();
8292
- return {
8293
- id: input.id?.trim() || randomUUID(),
8294
- sessionId,
8295
- message,
8296
- timestamp
8297
- };
8298
+ function createWorkflowToolMiddlewareRunner(agent) {
8299
+ const inherited = agent.getMiddlewareRunner().getMiddleware();
8300
+ return new MiddlewareRunner(
8301
+ inherited.filter((mw) => !isApprovalMiddleware2(mw))
8302
+ );
8298
8303
  }
8299
8304
  function createDaprAgentWorkflowHost(options) {
8300
8305
  const now = options.now ?? (() => (/* @__PURE__ */ new Date()).toISOString());
@@ -8411,6 +8416,62 @@ function createDaprAgentWorkflowHost(options) {
8411
8416
  ...onEvent ? { onEvent } : {},
8412
8417
  now
8413
8418
  },
8419
+ contextCompactionActivity: {
8420
+ compact: async (input) => {
8421
+ const sessions = await ensureWorkflowSessionLoaded(
8422
+ options.agent,
8423
+ input.sessionId
8424
+ );
8425
+ const result = await options.agent.compactMessages(
8426
+ restoreAgentWorkflowMessages(input.messages),
8427
+ {
8428
+ force: input.force,
8429
+ sessionId: input.sessionId,
8430
+ ...input.turnId ? { turnId: input.turnId } : {},
8431
+ cwd: options.agent.cwd,
8432
+ phase: input.force ? "recovery" : "pre-step",
8433
+ trigger: input.force ? "recovery" : "auto",
8434
+ reason: input.force ? "provider-overflow" : "context-limit"
8435
+ }
8436
+ );
8437
+ if (!result.compacted) {
8438
+ return {
8439
+ compacted: false,
8440
+ messages: input.messages.map((message) => structuredClone(message)),
8441
+ inputTokens: result.tokensBefore,
8442
+ limit: result.limit,
8443
+ decision: result.decision,
8444
+ effectiveness: result.effectiveness,
8445
+ removedCount: 0,
8446
+ tokensRemoved: 0,
8447
+ summarized: false
8448
+ };
8449
+ }
8450
+ await commitAgentContextCompaction({
8451
+ sessions,
8452
+ result,
8453
+ middlewareRunner: options.agent.getMiddlewareRunner(),
8454
+ sessionId: input.sessionId,
8455
+ ...input.turnId ? { turnId: input.turnId } : {},
8456
+ cwd: options.agent.cwd,
8457
+ phase: input.force ? "recovery" : "pre-step"
8458
+ });
8459
+ return {
8460
+ compacted: true,
8461
+ messages: snapshotAgentWorkflowMessages(sessions.getMessages()),
8462
+ inputTokens: result.tokensBefore,
8463
+ limit: result.limit,
8464
+ decision: result.decision,
8465
+ effectiveness: result.effectiveness,
8466
+ removedCount: result.removedCount,
8467
+ tokensRemoved: result.tokensRemoved,
8468
+ summarized: result.summarized,
8469
+ ...result.summary ? { summary: result.summary } : {},
8470
+ ...result.cutIndex !== void 0 ? { cutIndex: result.cutIndex } : {},
8471
+ ...result.cutReason ? { cutReason: result.cutReason } : {}
8472
+ };
8473
+ }
8474
+ },
8414
8475
  ...options.humanInputRuntime?.hasHumanInputTools ? {
8415
8476
  humanInputCheckActivity: {
8416
8477
  check: async (input) => {
@@ -8460,7 +8521,10 @@ function createDaprAgentWorkflowHost(options) {
8460
8521
  },
8461
8522
  commitActivity: {
8462
8523
  persistMessages: async (sessionId, messages) => {
8463
- const sessions = await ensureSessionLoaded(options.agent, sessionId);
8524
+ const sessions = await ensureWorkflowSessionLoaded(
8525
+ options.agent,
8526
+ sessionId
8527
+ );
8464
8528
  await sessions.addMessages(messages);
8465
8529
  },
8466
8530
  now
@@ -8486,6 +8550,12 @@ function createDaprAgentWorkflowHost(options) {
8486
8550
  workflowKit.activities.steerDrain.handler
8487
8551
  );
8488
8552
  }
8553
+ if (workflowKit.activities.contextCompaction) {
8554
+ registered.registerActivityWithName(
8555
+ workflowKit.activities.contextCompaction.name,
8556
+ workflowKit.activities.contextCompaction.handler
8557
+ );
8558
+ }
8489
8559
  registered.registerActivityWithName(
8490
8560
  workflowKit.activities.modelStep.name,
8491
8561
  workflowKit.activities.modelStep.handler
@@ -8517,23 +8587,35 @@ function createDaprAgentWorkflowHost(options) {
8517
8587
  );
8518
8588
  },
8519
8589
  async createInitialState(request) {
8520
- const sessionId = request.sessionId?.trim() || `workflow_${randomUUID().slice(0, 8)}`;
8590
+ const sessionId = createWorkflowSessionId(request.sessionId);
8591
+ const workflowInstanceId = normalizeWorkflowInstanceId(
8592
+ request.workflowInstanceId,
8593
+ sessionId
8594
+ );
8521
8595
  const startedAt = now();
8522
- const sessions = await ensureSessionLoaded(options.agent, sessionId, {
8523
- title: request.title,
8524
- parentSessionId: request.parentSessionId
8525
- });
8596
+ const sessions = await ensureWorkflowSessionLoaded(
8597
+ options.agent,
8598
+ sessionId,
8599
+ {
8600
+ title: request.title,
8601
+ parentSessionId: request.parentSessionId
8602
+ }
8603
+ );
8526
8604
  const seedableFollowUps = options.followUpsEnabled === false ? [] : await options.followUpRuntime?.listSeedable(sessionId) ?? [];
8527
8605
  if (seedableFollowUps.length > 0) {
8528
8606
  await sessions.addMessages(
8529
8607
  seedableFollowUps.map(
8530
- (followUp) => createUserMessage(followUp.message, followUp.createdAt)
8608
+ (followUp) => createWorkflowUserMessage(followUp.message, followUp.createdAt)
8531
8609
  )
8532
8610
  );
8533
8611
  }
8534
- const inputMessage = createUserMessage(request.message, startedAt);
8612
+ const inputMessage = createWorkflowUserMessage(
8613
+ request.message,
8614
+ startedAt
8615
+ );
8535
8616
  const initialState = createAgentWorkflowTurnState({
8536
8617
  sessionId,
8618
+ turnId: workflowInstanceId,
8537
8619
  startedAt,
8538
8620
  maxSteps: request.maxSteps ?? options.agent.getTurnRuntimeConfig().maxSteps,
8539
8621
  systemPrompts: await options.agent.buildSystemPrompts(
@@ -8545,16 +8627,14 @@ function createDaprAgentWorkflowHost(options) {
8545
8627
  });
8546
8628
  return {
8547
8629
  sessionId,
8548
- workflowInstanceId: normalizeWorkflowInstanceId(
8549
- request.workflowInstanceId,
8550
- sessionId
8551
- ),
8630
+ turnId: workflowInstanceId,
8631
+ workflowInstanceId,
8552
8632
  initialState,
8553
8633
  seededFollowUpIds: seedableFollowUps.map((followUp) => followUp.id)
8554
8634
  };
8555
8635
  },
8556
8636
  async startTurn(client, request) {
8557
- const sessionId = request.sessionId?.trim() || `workflow_${randomUUID().slice(0, 8)}`;
8637
+ const sessionId = createWorkflowSessionId(request.sessionId);
8558
8638
  const releaseSessionLock = await options.agent.acquireSessionTurnLock(sessionId);
8559
8639
  let prepared;
8560
8640
  try {
@@ -8615,6 +8695,10 @@ function createDaprAgentWorkflowHost(options) {
8615
8695
  await activeTurn.bridge.notifyTaskError(
8616
8696
  prepared?.initialState ?? createAgentWorkflowTurnState({
8617
8697
  sessionId,
8698
+ turnId: prepared?.workflowInstanceId ?? normalizeWorkflowInstanceId(
8699
+ request.workflowInstanceId,
8700
+ sessionId
8701
+ ),
8618
8702
  startedAt: now(),
8619
8703
  maxSteps: request.maxSteps ?? options.agent.getTurnRuntimeConfig().maxSteps
8620
8704
  }),
@@ -9992,49 +10076,10 @@ async function startDaprHostHttpServer(options) {
9992
10076
  }
9993
10077
 
9994
10078
  // src/host/workflow/agent-server.ts
9995
- import { randomUUID as randomUUID2 } from "crypto";
9996
- import { ensureSessionLoaded as ensureSessionLoaded2 } from "@cuylabs/agent-core";
9997
- function mergeCapabilities(base, patch) {
9998
- if (!patch) {
9999
- return structuredClone(base);
10000
- }
10001
- const merged = structuredClone(base);
10002
- for (const [key, value] of Object.entries(patch)) {
10003
- const current = merged[key];
10004
- if (current && typeof current === "object" && !Array.isArray(current) && value && typeof value === "object" && !Array.isArray(value)) {
10005
- merged[key] = mergeCapabilities(
10006
- current,
10007
- value
10008
- );
10009
- continue;
10010
- }
10011
- merged[key] = value;
10012
- }
10013
- return merged;
10014
- }
10015
- function normalizePluginCommandToken(token) {
10016
- return token.trim().replace(/^\//, "").toLowerCase();
10017
- }
10018
- function extractModelId(model) {
10019
- const candidate = model;
10020
- if (typeof candidate.modelId === "string" && candidate.modelId.trim()) {
10021
- return candidate.modelId;
10022
- }
10023
- if (typeof candidate.id === "string" && candidate.id.trim()) {
10024
- return candidate.id;
10025
- }
10026
- return "server-managed";
10027
- }
10028
- function extractProvider(model) {
10029
- const candidate = model;
10030
- if (typeof candidate.provider === "string" && candidate.provider.trim()) {
10031
- return candidate.provider;
10032
- }
10033
- if (typeof candidate.specificationVersion === "string" && candidate.specificationVersion.trim()) {
10034
- return candidate.specificationVersion;
10035
- }
10036
- return void 0;
10037
- }
10079
+ import { randomUUID as randomUUID3 } from "crypto";
10080
+ import { ensureSessionLoaded } from "@cuylabs/agent-core";
10081
+
10082
+ // src/host/workflow/agent-server-events.ts
10038
10083
  function parseJsonProperty(value) {
10039
10084
  if (!value) {
10040
10085
  return void 0;
@@ -10148,6 +10193,51 @@ function isSyntheticTerminalEvent(event) {
10148
10193
  }
10149
10194
  return typeof event.error.message === "string";
10150
10195
  }
10196
+
10197
+ // src/host/workflow/agent-server-support.ts
10198
+ function mergeCapabilities(base, patch) {
10199
+ if (!patch) {
10200
+ return structuredClone(base);
10201
+ }
10202
+ const merged = structuredClone(base);
10203
+ for (const [key, value] of Object.entries(patch)) {
10204
+ const current = merged[key];
10205
+ if (current && typeof current === "object" && !Array.isArray(current) && value && typeof value === "object" && !Array.isArray(value)) {
10206
+ merged[key] = mergeCapabilities(
10207
+ current,
10208
+ value
10209
+ );
10210
+ continue;
10211
+ }
10212
+ merged[key] = value;
10213
+ }
10214
+ return merged;
10215
+ }
10216
+ function normalizePluginCommandToken(token) {
10217
+ return token.trim().replace(/^\//, "").toLowerCase();
10218
+ }
10219
+ function extractModelId(model) {
10220
+ const candidate = model;
10221
+ if (typeof candidate.modelId === "string" && candidate.modelId.trim()) {
10222
+ return candidate.modelId;
10223
+ }
10224
+ if (typeof candidate.id === "string" && candidate.id.trim()) {
10225
+ return candidate.id;
10226
+ }
10227
+ return "server-managed";
10228
+ }
10229
+ function extractProvider(model) {
10230
+ const candidate = model;
10231
+ if (typeof candidate.provider === "string" && candidate.provider.trim()) {
10232
+ return candidate.provider;
10233
+ }
10234
+ if (typeof candidate.specificationVersion === "string" && candidate.specificationVersion.trim()) {
10235
+ return candidate.specificationVersion;
10236
+ }
10237
+ return void 0;
10238
+ }
10239
+
10240
+ // src/host/workflow/agent-server.ts
10151
10241
  function createDaprAgentServerAdapter(runner, options = {}) {
10152
10242
  const agent = runner.agent;
10153
10243
  const pluginCommands = options.pluginCommands ?? [];
@@ -10186,7 +10276,7 @@ function createDaprAgentServerAdapter(runner, options = {}) {
10186
10276
  (left, right) => left.name.localeCompare(right.name)
10187
10277
  ) : void 0;
10188
10278
  async function ensureActionSessionLoaded(sessionId) {
10189
- await ensureSessionLoaded2({
10279
+ await ensureSessionLoaded({
10190
10280
  sessionId,
10191
10281
  sessions: agent.getSessionManager(),
10192
10282
  cwd: agent.cwd
@@ -10353,7 +10443,7 @@ function createDaprAgentServerAdapter(runner, options = {}) {
10353
10443
  if (!active || !runner.workflowHost.steerTurn) {
10354
10444
  return { id: "", accepted: false };
10355
10445
  }
10356
- const id = randomUUID2();
10446
+ const id = randomUUID3();
10357
10447
  void runner.workflowHost.steerTurn(runner.workflowClient, {
10358
10448
  workflowInstanceId: active.workflowInstanceId,
10359
10449
  sessionId,
@@ -10368,7 +10458,7 @@ function createDaprAgentServerAdapter(runner, options = {}) {
10368
10458
  if (!active || !runner.workflowHost.followUpTurn) {
10369
10459
  return { id: "", accepted: false };
10370
10460
  }
10371
- const id = randomUUID2();
10461
+ const id = randomUUID3();
10372
10462
  void runner.workflowHost.followUpTurn(runner.workflowClient, {
10373
10463
  workflowInstanceId: active.workflowInstanceId,
10374
10464
  sessionId,
@@ -10441,7 +10531,7 @@ function createDaprAgentServerAdapter(runner, options = {}) {
10441
10531
  },
10442
10532
  listSessions: () => agent.listSessions(),
10443
10533
  deleteSession: (sessionId) => agent.deleteSession(sessionId),
10444
- getSessionStorage: () => agent.getSessionManager().getStorage(),
10534
+ getSessionStore: () => agent.getSessionManager().getStore(),
10445
10535
  listPluginCommands: () => pluginCommandInfos,
10446
10536
  executePluginCommand: async (name, args) => {
10447
10537
  const command = pluginCommandTokens.get(
@@ -1,4 +1,4 @@
1
- import { AgentWorkflowModelStepPlan, AgentWorkflowModelStepResult, AgentWorkflowInterventionSnapshot, AgentWorkflowToolCallPlan, AgentWorkflowToolCallResult, HumanInputRequest, ApprovalRequest, AgentWorkflowInputCommitPlan, AgentWorkflowStepCommitPlan, AgentWorkflowCommitResult, AgentWorkflowOutputCommitPlan, AgentEvent, AgentTurnStepRuntimeConfig, Tool, convertAgentMessagesToModelMessages, PrepareModelStepOptions, ToolHost, TurnTrackerContext, MiddlewareRunner, ReasoningLevel, Message, AgentWorkflowTurnState } from '@cuylabs/agent-core';
1
+ import { AgentWorkflowModelStepPlan, AgentWorkflowModelStepResult, AgentWorkflowInterventionSnapshot, AgentWorkflowTurnState, AgentWorkflowContextCompactionResult, AgentWorkflowToolCallPlan, AgentWorkflowToolCallResult, HumanInputRequest, ApprovalRequest, AgentWorkflowInputCommitPlan, AgentWorkflowStepCommitPlan, AgentWorkflowCommitResult, AgentWorkflowOutputCommitPlan, AgentEvent, AgentTurnStepRuntimeConfig, Tool, convertAgentMessagesToModelMessages, PrepareModelStepOptions, ToolHost, TurnTrackerContext, MiddlewareRunner, ReasoningLevel, Message } from '@cuylabs/agent-core';
2
2
  import { d as DaprSidecarClientOptions, f as DaprWorkflowObserverBridge } from './workflow-bridge-BcicHH1Y.js';
3
3
 
4
4
  type DaprWorkflowApiVersion = "v1.0" | "v1.0-beta1" | "v1.0-alpha1";
@@ -70,6 +70,7 @@ declare function hasStartedDaprWorkflow(status: DaprWorkflowRuntimeStatus): bool
70
70
 
71
71
  interface DaprAgentTurnWorkflowActivityNames {
72
72
  steerDrain?: string;
73
+ contextCompaction?: string;
73
74
  modelStep: string;
74
75
  humanInputCheck?: string;
75
76
  approvalCheck?: string;
@@ -134,6 +135,14 @@ interface DaprAgentTurnSteerDrainInput {
134
135
  step: number;
135
136
  maxItems: number;
136
137
  }
138
+ interface DaprAgentTurnContextCompactionInput {
139
+ workflowInstanceId: string;
140
+ sessionId: string;
141
+ turnId?: string;
142
+ step: number;
143
+ messages: AgentWorkflowTurnState["messages"];
144
+ force?: boolean;
145
+ }
137
146
  interface DaprAgentTurnWorkflowRegistration {
138
147
  workflowName: string;
139
148
  activityNames: DaprAgentTurnWorkflowActivityNames;
@@ -231,6 +240,9 @@ interface DaprAgentTurnHumanInputCheckActivityOptions {
231
240
  interface DaprAgentTurnSteerDrainActivityOptions {
232
241
  drain: (input: DaprAgentTurnSteerDrainInput) => Promise<AgentWorkflowInterventionSnapshot[]> | AgentWorkflowInterventionSnapshot[];
233
242
  }
243
+ interface DaprAgentTurnContextCompactionActivityOptions {
244
+ compact: (input: DaprAgentTurnContextCompactionInput) => Promise<AgentWorkflowContextCompactionResult> | AgentWorkflowContextCompactionResult;
245
+ }
234
246
  interface DaprAgentTurnCommitActivityOptions {
235
247
  persistMessages: (sessionId: string, messages: Message[]) => Promise<void>;
236
248
  now?: () => string;
@@ -238,6 +250,7 @@ interface DaprAgentTurnCommitActivityOptions {
238
250
  interface CreateDaprAgentTurnWorkflowDefinitionOptions extends CreateDaprAgentTurnWorkflowRegistrationOptions {
239
251
  modelStep: (input: AgentWorkflowModelStepPlan) => Promise<AgentWorkflowModelStepResult> | AgentWorkflowModelStepResult;
240
252
  steerDrain?: (input: DaprAgentTurnSteerDrainInput) => Promise<AgentWorkflowInterventionSnapshot[]> | AgentWorkflowInterventionSnapshot[];
253
+ contextCompaction?: (input: DaprAgentTurnContextCompactionInput) => Promise<AgentWorkflowContextCompactionResult> | AgentWorkflowContextCompactionResult;
241
254
  toolCall: (input: AgentWorkflowToolCallPlan) => Promise<AgentWorkflowToolCallResult> | AgentWorkflowToolCallResult;
242
255
  humanInputCheck?: (input: DaprAgentTurnHumanInputCheckInput) => Promise<DaprAgentTurnHumanInputCheckResult> | DaprAgentTurnHumanInputCheckResult;
243
256
  approvalCheck?: (input: DaprAgentTurnApprovalCheckInput) => Promise<DaprAgentTurnApprovalCheckResult> | DaprAgentTurnApprovalCheckResult;
@@ -262,6 +275,7 @@ interface CreateDaprAgentTurnWorkflowDefinitionOptions extends CreateDaprAgentTu
262
275
  interface CreateDaprAgentTurnWorkflowKitOptions extends CreateDaprAgentTurnWorkflowRegistrationOptions {
263
276
  modelStepActivity: DaprAgentTurnModelStepActivityOptions;
264
277
  steerDrainActivity?: DaprAgentTurnSteerDrainActivityOptions;
278
+ contextCompactionActivity?: DaprAgentTurnContextCompactionActivityOptions;
265
279
  humanInputCheckActivity?: DaprAgentTurnHumanInputCheckActivityOptions;
266
280
  approvalCheckActivity?: DaprAgentTurnApprovalCheckActivityOptions;
267
281
  toolCallActivity: DaprAgentTurnToolCallActivityOptions;
@@ -282,6 +296,7 @@ type DaprAgentTurnWorkflowToolHandler = (input: DaprAgentTurnWorkflowToolHandler
282
296
  interface DaprAgentTurnWorkflowKit extends DaprAgentTurnWorkflowRegistration {
283
297
  activities: {
284
298
  steerDrain?: DaprAgentTurnActivityRegistration<DaprAgentTurnSteerDrainInput, AgentWorkflowInterventionSnapshot[]>;
299
+ contextCompaction?: DaprAgentTurnActivityRegistration<DaprAgentTurnContextCompactionInput, AgentWorkflowContextCompactionResult>;
285
300
  modelStep: DaprAgentTurnActivityRegistration<AgentWorkflowModelStepPlan, AgentWorkflowModelStepResult>;
286
301
  humanInputCheck?: DaprAgentTurnActivityRegistration<DaprAgentTurnHumanInputCheckInput, DaprAgentTurnHumanInputCheckResult>;
287
302
  approvalCheck?: DaprAgentTurnActivityRegistration<DaprAgentTurnApprovalCheckInput, DaprAgentTurnApprovalCheckResult>;
@@ -1,9 +1,9 @@
1
- export { b as DaprAppDispatchExecutorOptions, c as DaprDispatchRecord, D as DaprDispatchRuntimeOptions, d as DaprDispatchTarget, e as DaprDispatchTargetInspection, f as DaprWorkflowDispatchExecutorOptions, R as RemoteAgentDispatchTargetOptions, W as WorkflowDispatchTargetOptions, g as createDaprAppDispatchExecutor, h as createDaprCompositeDispatchExecutor, i as createDaprDispatchRuntime, j as createDaprWorkflowDispatchExecutor, k as createRemoteAgentDispatchTarget, l as createWorkflowDispatchTarget } from '../index-UtePd9on.js';
1
+ export { b as DaprAppDispatchExecutorOptions, c as DaprDispatchRecord, D as DaprDispatchRuntimeOptions, d as DaprDispatchTarget, e as DaprDispatchTargetInspection, f as DaprWorkflowDispatchExecutorOptions, R as RemoteAgentDispatchTargetOptions, W as WorkflowDispatchTargetOptions, g as createDaprAppDispatchExecutor, h as createDaprCompositeDispatchExecutor, i as createDaprDispatchRuntime, j as createDaprWorkflowDispatchExecutor, k as createRemoteAgentDispatchTarget, l as createWorkflowDispatchTarget } from '../index-DgexJdIL.js';
2
2
  import '@cuylabs/agent-core';
3
3
  import '../workflow-bridge-BcicHH1Y.js';
4
- import '../client-UsEIzDF6.js';
5
- import '../workflow-host-D6W6fXoL.js';
6
- import '@cuylabs/agent-core/events';
7
4
  import '../invoker-B6ikdYaz.js';
5
+ import '../workflow-host-DHibEPOQ.js';
6
+ import '../client-Dk8N3lMW.js';
7
+ import '@cuylabs/agent-core/events';
8
8
  import '../store-BXBIDz40.js';
9
9
  import '@cuylabs/agent-runtime';
@@ -5,7 +5,7 @@ import {
5
5
  createDaprWorkflowDispatchExecutor,
6
6
  createRemoteAgentDispatchTarget,
7
7
  createWorkflowDispatchTarget
8
- } from "../chunk-6BLY7B7U.js";
8
+ } from "../chunk-BQLQLDWZ.js";
9
9
  import "../chunk-HQLQRXU5.js";
10
10
  export {
11
11
  createDaprAppDispatchExecutor,
@@ -5,7 +5,7 @@ import {
5
5
  createDaprLoggingObserver,
6
6
  createOtelObserver,
7
7
  createWorkflowObserverBridge
8
- } from "../chunk-J3IJLF6U.js";
8
+ } from "../chunk-POIJYTT6.js";
9
9
  import "../chunk-HQLQRXU5.js";
10
10
  export {
11
11
  DaprExecutionObserver,
@@ -1,11 +1,11 @@
1
- export { C as CreateDaprAgentServerAdapterOptions, a as CreateRemoteAgentToolOptions, D as DaprAgentDurableRunOptions, b as DaprAgentDurableRunResult, N as DaprAgentHttpHandlerOptions, O as DaprAgentHttpRoute, c as DaprAgentRunner, d as DaprAgentRunnerOptions, e as DaprAgentRuntimeBundle, f as DaprAgentRuntimeOptions, g as DaprAgentServeOptions, h as DaprAgentTaskErrorContext, i as DaprAgentTaskResultContext, j as DaprHostApp, P as DaprHostHttpHandler, k as DaprHostHttpHandlerOptions, l as DaprHostHttpServer, m as DaprHostHttpServerOptions, n as DaprHostReadinessCheck, o as DaprHostReadinessStatus, p as DaprHostRemoteRunRequest, q as DaprHostedAgentInfo, Q as DaprHttpServerOptions, u as DaprMultiAgentRunner, v as DaprMultiAgentRunnerAgentConfig, w as DaprMultiAgentRunnerOptions, y as DaprWorkloadErrorContext, z as DaprWorkloadResultContext, A as DaprWorkloadRuntimeBundle, B as DaprWorkloadRuntimeOptions, E as createDaprAgentRunner, F as createDaprAgentRuntime, G as createDaprAgentServerAdapter, H as createDaprHostHttpHandler, J as createDaprMultiAgentRunner, K as createDaprWorkloadRuntime, L as createRemoteAgentTool, M as startDaprHostHttpServer, R as startDaprHttpServer } from '../index-BY0FipV1.js';
1
+ export { C as CreateDaprAgentServerAdapterOptions, a as CreateRemoteAgentToolOptions, D as DaprAgentDurableRunOptions, b as DaprAgentDurableRunResult, N as DaprAgentHttpHandlerOptions, O as DaprAgentHttpRoute, c as DaprAgentRunner, d as DaprAgentRunnerOptions, e as DaprAgentRuntimeBundle, f as DaprAgentRuntimeOptions, g as DaprAgentServeOptions, h as DaprAgentTaskErrorContext, i as DaprAgentTaskResultContext, j as DaprHostApp, P as DaprHostHttpHandler, k as DaprHostHttpHandlerOptions, l as DaprHostHttpServer, m as DaprHostHttpServerOptions, n as DaprHostReadinessCheck, o as DaprHostReadinessStatus, p as DaprHostRemoteRunRequest, q as DaprHostedAgentInfo, Q as DaprHttpServerOptions, u as DaprMultiAgentRunner, v as DaprMultiAgentRunnerAgentConfig, w as DaprMultiAgentRunnerOptions, y as DaprWorkloadErrorContext, z as DaprWorkloadResultContext, A as DaprWorkloadRuntimeBundle, B as DaprWorkloadRuntimeOptions, E as createDaprAgentRunner, F as createDaprAgentRuntime, G as createDaprAgentServerAdapter, H as createDaprHostHttpHandler, J as createDaprMultiAgentRunner, K as createDaprWorkloadRuntime, L as createRemoteAgentTool, M as startDaprHostHttpServer, R as startDaprHttpServer } from '../index-BA2PeEUf.js';
2
2
  export { D as DaprInvokeMethodOptions, a as DaprInvokeMethodResult, b as DaprServiceInvoker, c as DaprServiceInvokerOptions, R as RemoteAgentRunRequest, d as RemoteAgentRunResponse, i as invokeRemoteAgentRun } from '../invoker-B6ikdYaz.js';
3
- export { b as DaprAgentWorkflowFollowUpRequest, a as DaprAgentWorkflowHost, c as DaprAgentWorkflowHostOptions, d as DaprAgentWorkflowRunRequest, e as DaprAgentWorkflowRunResult, f as DaprAgentWorkflowSteerRequest, g as DaprApprovalDecision, h as DaprApprovalRequestListOptions, i as DaprApprovalRequestRecord, j as DaprApprovalRequestStatus, k as DaprApprovalResolution, l as DaprFollowUpListOptions, m as DaprFollowUpRecord, n as DaprHumanInputRequestListOptions, o as DaprHumanInputRequestRecord, p as DaprHumanInputRequestStatus, q as DaprPubSubEventBridge, r as DaprPubSubEventBridgeOptions, s as DaprSteerRecord, t as DaprWorkflowApprovalCheckInput, u as DaprWorkflowApprovalCheckResult, v as DaprWorkflowApprovalRuntime, w as DaprWorkflowApprovalRuntimeOptions, x as DaprWorkflowEventRaiserLike, y as DaprWorkflowFollowUpRuntime, z as DaprWorkflowFollowUpRuntimeOptions, A as DaprWorkflowHumanInputCheckInput, B as DaprWorkflowHumanInputCheckResult, C as DaprWorkflowHumanInputRuntime, E as DaprWorkflowHumanInputRuntimeOptions, D as DaprWorkflowRuntimeRegistrar, F as DaprWorkflowStarterLike, G as DaprWorkflowSteerRuntime, H as DaprWorkflowSteerRuntimeOptions, I as createDaprAgentWorkflowHost, J as createDaprPubSubEventBridge, K as createDaprWorkflowApprovalRuntime, L as createDaprWorkflowFollowUpRuntime, M as createDaprWorkflowHumanInputRuntime, N as createDaprWorkflowSteerRuntime, O as startDaprAgentWorkflowTurn } from '../workflow-host-D6W6fXoL.js';
4
- export { D as DaprWorkflowWorker, a as DaprWorkflowWorkerAgentDefinition, b as DaprWorkflowWorkerLogger, c as DaprWorkflowWorkerOptions, d as DaprWorkflowWorkerRuntime, e as createDaprWorkflowWorker } from '../worker-CXq0IFGX.js';
3
+ export { b as DaprAgentWorkflowFollowUpRequest, a as DaprAgentWorkflowHost, c as DaprAgentWorkflowHostOptions, d as DaprAgentWorkflowRunRequest, e as DaprAgentWorkflowRunResult, f as DaprAgentWorkflowSteerRequest, g as DaprApprovalDecision, h as DaprApprovalRequestListOptions, i as DaprApprovalRequestRecord, j as DaprApprovalRequestStatus, k as DaprApprovalResolution, l as DaprFollowUpListOptions, m as DaprFollowUpRecord, n as DaprHumanInputRequestListOptions, o as DaprHumanInputRequestRecord, p as DaprHumanInputRequestStatus, q as DaprPubSubEventBridge, r as DaprPubSubEventBridgeOptions, s as DaprSteerRecord, t as DaprWorkflowApprovalCheckInput, u as DaprWorkflowApprovalCheckResult, v as DaprWorkflowApprovalRuntime, w as DaprWorkflowApprovalRuntimeOptions, x as DaprWorkflowEventRaiserLike, y as DaprWorkflowFollowUpRuntime, z as DaprWorkflowFollowUpRuntimeOptions, A as DaprWorkflowHumanInputCheckInput, B as DaprWorkflowHumanInputCheckResult, C as DaprWorkflowHumanInputRuntime, E as DaprWorkflowHumanInputRuntimeOptions, D as DaprWorkflowRuntimeRegistrar, F as DaprWorkflowStarterLike, G as DaprWorkflowSteerRuntime, H as DaprWorkflowSteerRuntimeOptions, I as createDaprAgentWorkflowHost, J as createDaprPubSubEventBridge, K as createDaprWorkflowApprovalRuntime, L as createDaprWorkflowFollowUpRuntime, M as createDaprWorkflowHumanInputRuntime, N as createDaprWorkflowSteerRuntime, O as startDaprAgentWorkflowTurn } from '../workflow-host-DHibEPOQ.js';
4
+ export { D as DaprWorkflowWorker, a as DaprWorkflowWorkerAgentDefinition, b as DaprWorkflowWorkerLogger, c as DaprWorkflowWorkerOptions, d as DaprWorkflowWorkerRuntime, e as createDaprWorkflowWorker } from '../worker-DE8t7tcI.js';
5
5
  export { EventBus, EventBusMessage, EventBusOptions, EventBusSubscribeOptions, EventBusSubscription, createEventBus } from '@cuylabs/agent-core/events';
6
6
  import '@cuylabs/agent-core';
7
7
  import '../store-BXBIDz40.js';
8
8
  import '@cuylabs/agent-runtime';
9
9
  import '../workflow-bridge-BcicHH1Y.js';
10
- import '../client-UsEIzDF6.js';
10
+ import '../client-Dk8N3lMW.js';
11
11
  import 'node:http';
@@ -17,13 +17,13 @@ import {
17
17
  startDaprAgentWorkflowTurn,
18
18
  startDaprHostHttpServer,
19
19
  startDaprHttpServer
20
- } from "../chunk-26RCP3L3.js";
20
+ } from "../chunk-WYU7JOJ7.js";
21
21
  import {
22
22
  DaprServiceInvoker,
23
23
  invokeRemoteAgentRun
24
- } from "../chunk-6BLY7B7U.js";
25
- import "../chunk-J3IJLF6U.js";
26
- import "../chunk-2TBZCBXE.js";
24
+ } from "../chunk-BQLQLDWZ.js";
25
+ import "../chunk-POIJYTT6.js";
26
+ import "../chunk-L6SWGYZC.js";
27
27
  import "../chunk-HQLQRXU5.js";
28
28
  export {
29
29
  DaprServiceInvoker,