@rivus/agent 0.5.2 → 0.6.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/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { a as createAgentLoopSkillExecutionStart, c as createAgentLoopToolExecutionEnd, d as createAsyncIterableAgentLoop, f as createEventAgentLoop, i as createAgentLoopSkillExecutionEnd, l as createAgentLoopToolExecutionStart, m as createTextAgentLoopFromCallback, n as createAgentLoopModelExecutionEnd, o as createAgentLoopTextDelta, p as createTextAgentLoop, r as createAgentLoopModelExecutionStart, s as createAgentLoopThinkingDelta, t as createAgentLoopFromCallback, u as createAgentLoopToolExecutionUpdate } from "./agent-loop.js";
2
2
  import { a as RIVUS_MEMORY_TOOL_ID, c as createMemoryNamespace, d as InvalidRivusPlugin, f as RIVUS_PLUGIN_API_VERSION, i as MEMORY_SCOPES, l as createRivusMemoryToolContract, m as requiresToolApproval, n as resolveRivusAgentDefinition, o as RIVUS_MEMORY_TOOL_PLUGIN_ID, p as RivusToolInputRejected, s as RIVUS_MEMORY_TOOL_VERSION, t as createRivusPluginCatalog, u as restrictMemoryScopesForAudience } from "./rivus-plugin-registry.js";
3
- import { C as loadRivusDaemonConfig, D as loadRivusDeploymentManifest, E as RivusDeploymentManifestError, M as loadRivusDeployment, N as validateRivusDeploymentManifest, O as FeishuEndpointCredentialError, S as RivusDaemonConfigError, _ as createStableId, a as InvalidRivusProjectSpace, b as createRivusEnvFromOpenClawConfig, c as RivusDeploymentReadinessError, d as createRivusAgentHost, f as AgentInstanceBusy, g as createAgentInstanceRegistry, h as AgentInstanceConflict, i as resolveRivusProjectSpace, j as RivusPluginLoadError, k as resolveFeishuEndpointCredentials, l as createRivusDeploymentDaemon, m as createAgentRuntimePool, n as createRivusDeploymentCliProcess, o as RivusDeploymentAutomationReadinessError, p as AgentRuntimeDisposed, r as createConfiguredRivusDeploymentDaemon, s as RivusDeploymentDaemonLifecycleError, t as runRivusDaemonCli, u as InvalidRivusEndpointBinding, v as createRivusDaemonShutdownController, w as loadNodeRivusPluginModule, x as formatRivusEnvFile, y as OpenClawEnvImportError } from "./rivus-daemon-cli.js";
3
+ import { A as CardPresentationTransitionDenied, B as FeishuEndpointCredentialError, C as loadRivusDaemonConfig, D as loadRivusDeploymentManifest, E as RivusDeploymentManifestError, F as completeCardPresentationHandoff, G as validateRivusDeploymentManifest, I as createCardPresentationChain, L as failCardPresentationHandoff, M as activeCardPresentation, N as beginCardPresentationHandoff, O as DEFAULT_CARD_STREAM_LEASE_MS, P as compensateCardPresentationHandoff, R as isCardPresentationHandoffDue, S as RivusDaemonConfigError, U as RivusPluginLoadError, V as resolveFeishuEndpointCredentials, W as loadRivusDeployment, _ as createStableId, a as InvalidRivusProjectSpace, b as createRivusEnvFromOpenClawConfig, c as RivusDeploymentReadinessError, d as createRivusAgentHost, f as AgentInstanceBusy, g as createAgentInstanceRegistry, h as AgentInstanceConflict, i as resolveRivusProjectSpace, j as acceptsCardPresentationProgress, k as createFeishuCardRollover, l as createRivusDeploymentDaemon, m as createAgentRuntimePool, n as createRivusDeploymentCliProcess, o as RivusDeploymentAutomationReadinessError, p as AgentRuntimeDisposed, r as createConfiguredRivusDeploymentDaemon, s as RivusDeploymentDaemonLifecycleError, t as runRivusDaemonCli, u as InvalidRivusEndpointBinding, v as createRivusDaemonShutdownController, w as loadNodeRivusPluginModule, x as formatRivusEnvFile, y as OpenClawEnvImportError, z as markCardPresentationTerminal } from "./rivus-daemon-cli.js";
4
4
  import { n as assertRivusPluginConforms, r as createFakeRivusPlugin, t as RivusPluginConformanceError } from "./rivus-plugin-testkit.js";
5
5
  import { Cause, Deferred, Effect, Exit, Fiber, Option, Stream } from "effect";
6
6
  import { createHash, randomUUID } from "node:crypto";
@@ -134,7 +134,7 @@ function createFeishuCardDeliveryReconciler(options) {
134
134
  return { reconcile: () => Effect.gen(function* () {
135
135
  const projector = createFeishuStreamProjector();
136
136
  const terminalByRun = /* @__PURE__ */ new Map();
137
- for (const event of options.events) for (const action of projector.apply(event)) if (action.type !== "update_text") terminalByRun.set(action.runId, action);
137
+ for (const event of options.events) for (const action of projector.apply(event)) if (action.type !== "update_text" && action.type !== "handoff") terminalByRun.set(action.runId, action);
138
138
  let repaired = 0;
139
139
  for (const [runId, action] of terminalByRun) {
140
140
  if (options.ledger.isTerminalPublished(runId)) continue;
@@ -2261,8 +2261,8 @@ function createFeishuMessageWorker(options) {
2261
2261
  }) };
2262
2262
  }
2263
2263
  //#endregion
2264
- //#region src/application/feishu/feishu-worker-loop.ts
2265
- function createFeishuWorkerLoop(options) {
2264
+ //#region src/application/support/periodic-effect-loop.ts
2265
+ function createPeriodicEffectLoop(options) {
2266
2266
  let running = false;
2267
2267
  let fiber;
2268
2268
  const reportError = (error) => {
@@ -2270,7 +2270,7 @@ function createFeishuWorkerLoop(options) {
2270
2270
  return reported instanceof Promise ? Effect.promise(() => reported) : Effect.void;
2271
2271
  };
2272
2272
  const continueAfterReporting = (effect) => effect.pipe(Effect.asVoid, Effect.catchAll((error) => reportError(error)));
2273
- const cycle = Effect.suspend(() => continueAfterReporting(options.drainAvailable()).pipe(Effect.flatMap(() => continueAfterReporting(options.sleep(options.intervalMs))), Effect.flatMap(() => cycle)));
2273
+ const cycle = Effect.suspend(() => continueAfterReporting(options.run()).pipe(Effect.flatMap(() => continueAfterReporting(options.sleep(options.intervalMs))), Effect.flatMap(() => cycle)));
2274
2274
  return {
2275
2275
  running: () => running,
2276
2276
  start: () => {
@@ -2287,6 +2287,16 @@ function createFeishuWorkerLoop(options) {
2287
2287
  };
2288
2288
  }
2289
2289
  //#endregion
2290
+ //#region src/application/feishu/feishu-worker-loop.ts
2291
+ function createFeishuWorkerLoop(options) {
2292
+ return createPeriodicEffectLoop({
2293
+ intervalMs: options.intervalMs,
2294
+ ...options.onError ? { onError: options.onError } : {},
2295
+ run: () => options.drainAvailable(),
2296
+ sleep: options.sleep
2297
+ });
2298
+ }
2299
+ //#endregion
2290
2300
  //#region src/application/daemon/rivus-daemon-process.ts
2291
2301
  function createRivusDaemonProcess(options) {
2292
2302
  let running = false;
@@ -2364,6 +2374,7 @@ function createRivusDaemonStatusReporter(options) {
2364
2374
  const activeSessionKey = availability?.busy ? availability.activeSessionKey : activeRun?.sessionKey;
2365
2375
  return {
2366
2376
  agentId: options.agentId,
2377
+ ...options.cardPresentations ? { cards: options.cardPresentations() } : {},
2367
2378
  harness: {
2368
2379
  ...activeRunId !== void 0 ? { activeRunId } : {},
2369
2380
  ...activeRunState !== void 0 ? { activeRunState } : {},
@@ -2764,14 +2775,41 @@ async function stopWebSocketClient(client) {
2764
2775
  else await client.disconnect?.();
2765
2776
  }
2766
2777
  //#endregion
2778
+ //#region src/application/feishu/feishu-card-rollover-supervisor.ts
2779
+ const DEFAULT_INTERVAL_MS = 1e3;
2780
+ function createFeishuCardRolloverSupervisor(options) {
2781
+ const intervalMs = options.intervalMs ?? DEFAULT_INTERVAL_MS;
2782
+ if (!Number.isSafeInteger(intervalMs) || intervalMs < 1) throw new Error("Feishu card rollover supervisor interval must be a positive integer");
2783
+ const tick = () => Effect.gen(function* () {
2784
+ const now = yield* options.clock.now;
2785
+ const results = [];
2786
+ for (const runId of options.rollover.dueRunIds(now)) results.push(yield* options.rollover.handoff(runId));
2787
+ return { results };
2788
+ });
2789
+ const loop = createPeriodicEffectLoop({
2790
+ intervalMs,
2791
+ ...options.onError ? { onError: options.onError } : {},
2792
+ run: tick,
2793
+ sleep: options.sleep
2794
+ });
2795
+ return {
2796
+ recover: () => options.rollover.recover().pipe(Effect.asVoid),
2797
+ running: () => loop.running(),
2798
+ start: () => loop.start(),
2799
+ stop: () => loop.stop(),
2800
+ tick
2801
+ };
2802
+ }
2803
+ //#endregion
2767
2804
  //#region src/infrastructure/feishu/feishu-agent-run-card.ts
2805
+ const FEISHU_AGENT_CARD_ELEMENT_ID = "rivus_agent_answer";
2768
2806
  function createFeishuAgentRunCard(input) {
2769
2807
  const presentation = resolveRunPresentation(input);
2770
2808
  return {
2771
2809
  body: { elements: [
2772
2810
  {
2773
2811
  content: presentation.content,
2774
- element_id: input.status === "running" ? input.elementId ?? "rivus_agent_answer" : "rivus_agent_answer",
2812
+ element_id: input.status === "running" ? input.elementId ?? "rivus_agent_answer" : FEISHU_AGENT_CARD_ELEMENT_ID,
2775
2813
  tag: "markdown"
2776
2814
  },
2777
2815
  {
@@ -2813,9 +2851,15 @@ function resolveRunPresentation(input) {
2813
2851
  switch (input.status) {
2814
2852
  case "running": return {
2815
2853
  content: input.text || "正在思考…",
2816
- note: "回答将实时更新",
2854
+ note: input.generation ? "接续上一条消息,回答将实时更新" : "回答将实时更新",
2817
2855
  template: "blue",
2818
- title: "正在处理"
2856
+ title: input.generation ? "正在处理(续)" : "正在处理"
2857
+ };
2858
+ case "handoff": return {
2859
+ content: "任务仍在后台处理,进度将继续显示在下一条消息。",
2860
+ note: "本卡片的流式窗口已交接",
2861
+ template: "blue",
2862
+ title: "已转到新消息"
2819
2863
  };
2820
2864
  case "completed": return {
2821
2865
  content: input.text || "已完成。",
@@ -2921,11 +2965,12 @@ function createFeishuCardKitOpenApiClient(options) {
2921
2965
  const agentName = options.agentName ?? "Rivus Agent";
2922
2966
  const streamingClosedCards = /* @__PURE__ */ new Set();
2923
2967
  const call = (request) => options.client.request(request).pipe(Effect.asVoid);
2924
- const updateTerminal = (request, status) => updateTerminalCard(baseUrl, agentName, request, status, call).pipe(Effect.tap(() => Effect.sync(() => streamingClosedCards.delete(request.cardId))));
2968
+ const updateTerminal = (request, status) => updateWholeCard(baseUrl, agentName, request, status, call).pipe(Effect.tap(() => Effect.sync(() => streamingClosedCards.delete(request.cardId))));
2925
2969
  return {
2926
2970
  cancel: (request) => updateTerminal(request, "cancelled"),
2927
2971
  fail: (request) => updateTerminal(request, "failed"),
2928
2972
  finish: (request) => updateTerminal(request, "completed"),
2973
+ handoff: (request) => Effect.sync(() => streamingClosedCards.add(request.cardId)).pipe(Effect.flatMap(() => updateWholeCard(baseUrl, agentName, request, "handoff", call))),
2929
2974
  updateText: (request) => {
2930
2975
  if (streamingClosedCards.has(request.cardId)) return Effect.void;
2931
2976
  return call({
@@ -2937,7 +2982,10 @@ function createFeishuCardKitOpenApiClient(options) {
2937
2982
  url: `${baseUrl}/open-apis/cardkit/v1/cards/${encodeURIComponent(request.cardId)}/elements/${encodeURIComponent(request.elementId)}/content`
2938
2983
  }).pipe(Effect.catchAll((error) => {
2939
2984
  if (!isStreamingClosed(error)) return Effect.fail(error);
2940
- return Effect.sync(() => streamingClosedCards.add(request.cardId));
2985
+ return Effect.sync(() => {
2986
+ streamingClosedCards.add(request.cardId);
2987
+ options.onStreamingClosed?.(request.cardId);
2988
+ });
2941
2989
  }));
2942
2990
  }
2943
2991
  };
@@ -2945,17 +2993,14 @@ function createFeishuCardKitOpenApiClient(options) {
2945
2993
  function isStreamingClosed(error) {
2946
2994
  return error instanceof FeishuOpenApiError && (error.code === 200850 || error.code === 300309);
2947
2995
  }
2948
- function updateTerminalCard(baseUrl, agentName, request, status, call) {
2949
- const card = status === "completed" && "text" in request ? createFeishuAgentRunCard({
2950
- agentName,
2951
- status: "completed",
2952
- text: request.text
2953
- }) : status === "cancelled" ? createFeishuAgentRunCard({
2996
+ function updateWholeCard(baseUrl, agentName, request, status, call) {
2997
+ const card = status === "completed" ? createFeishuAgentRunCard({
2954
2998
  agentName,
2955
- status: "cancelled"
2999
+ status,
3000
+ text: "text" in request ? request.text : ""
2956
3001
  }) : createFeishuAgentRunCard({
2957
3002
  agentName,
2958
- status: "failed"
3003
+ status
2959
3004
  });
2960
3005
  return call({
2961
3006
  body: {
@@ -2983,6 +3028,10 @@ function createFeishuCardKitPublisher(options) {
2983
3028
  elementId: target.elementId,
2984
3029
  sequence
2985
3030
  });
3031
+ case "handoff": return yield* options.client.handoff({
3032
+ cardId: target.cardId,
3033
+ sequence
3034
+ });
2986
3035
  case "finish":
2987
3036
  yield* options.client.finish({
2988
3037
  cardId: target.cardId,
@@ -3032,6 +3081,7 @@ function createCoalescingFeishuPublisher(options) {
3032
3081
  case "update_text": return Effect.sync(() => {
3033
3082
  pendingTextByRun.set(action.runId, action.text);
3034
3083
  });
3084
+ case "handoff": return options.publisher.publish(action);
3035
3085
  case "finish": return Effect.gen(function* () {
3036
3086
  pendingTextByRun.set(action.runId, action.text);
3037
3087
  yield* flushRun(action.runId);
@@ -3064,7 +3114,8 @@ function createConfiguredFeishuCardKitPublisher(options) {
3064
3114
  client: createFeishuCardKitOpenApiClient({
3065
3115
  ...options.agentName === void 0 ? {} : { agentName: options.agentName },
3066
3116
  baseUrl: options.config.feishu.baseUrl,
3067
- client: options.client
3117
+ client: options.client,
3118
+ ...options.onStreamingClosed === void 0 ? {} : { onStreamingClosed: options.onStreamingClosed }
3068
3119
  }),
3069
3120
  ...options.ledger ? { ledger: options.ledger } : {},
3070
3121
  resolveTarget: options.resolveTarget
@@ -3077,36 +3128,40 @@ function createConfiguredFeishuCardKitPublisher(options) {
3077
3128
  }
3078
3129
  //#endregion
3079
3130
  //#region src/infrastructure/feishu/feishu-cardkit-target-preparation.ts
3080
- const DEFAULT_ELEMENT_ID = "rivus_agent_answer";
3131
+ const DEFAULT_ELEMENT_ID = FEISHU_AGENT_CARD_ELEMENT_ID;
3081
3132
  function createFeishuCardTargetPreparation(options) {
3082
3133
  return (run) => Effect.gen(function* () {
3083
3134
  const target = yield* options.createTarget(run);
3084
- yield* options.registry.bind(run.runId, target);
3135
+ yield* options.presentations.bindRun(run, target);
3085
3136
  });
3086
3137
  }
3087
3138
  function createConfiguredFeishuCardKitTargetPreparation(options) {
3088
- const creator = createFeishuCardKitOpenApiTargetCreator({
3139
+ const creator = createConfiguredFeishuCardKitTargetCreator(options);
3140
+ return createFeishuCardTargetPreparation({
3141
+ createTarget: (run) => creator.createTarget(run),
3142
+ presentations: options.presentations
3143
+ });
3144
+ }
3145
+ function createConfiguredFeishuCardKitTargetCreator(options) {
3146
+ return createFeishuCardKitOpenApiTargetCreator({
3089
3147
  baseUrl: options.config.feishu.baseUrl,
3090
3148
  client: options.client,
3091
3149
  elementId: options.elementId ?? DEFAULT_ELEMENT_ID,
3092
3150
  ...options.initialContent === void 0 ? {} : { initialContent: options.initialContent },
3093
3151
  ...options.title === void 0 ? {} : { title: options.title }
3094
3152
  });
3095
- return createFeishuCardTargetPreparation({
3096
- createTarget: (run) => creator.createTarget(run),
3097
- registry: options.registry
3098
- });
3099
3153
  }
3100
3154
  function createFeishuCardKitOpenApiTargetCreator(options) {
3101
3155
  const baseUrl = (options.baseUrl ?? "https://open.feishu.cn").replace(/\/$/, "");
3102
3156
  const title = options.title ?? "Rivus Agent";
3103
3157
  const initialContent = options.initialContent ?? "";
3104
- return { createTarget: (run) => Effect.gen(function* () {
3158
+ return { createTarget: (run, createOptions) => Effect.gen(function* () {
3105
3159
  const cardId = yield* readStringData(yield* options.client.request({
3106
3160
  body: {
3107
3161
  data: JSON.stringify(createFeishuAgentRunCard({
3108
3162
  agentName: title,
3109
3163
  elementId: options.elementId,
3164
+ ...createOptions?.generation === void 0 ? {} : { generation: createOptions.generation },
3110
3165
  runId: run.runId,
3111
3166
  sessionKey: run.sessionKey,
3112
3167
  status: "running",
@@ -3143,6 +3198,68 @@ function isRecord$2(value) {
3143
3198
  return typeof value === "object" && value !== null && !Array.isArray(value);
3144
3199
  }
3145
3200
  //#endregion
3201
+ //#region src/composition/feishu-card-rollover-runtime.ts
3202
+ const MIN_SUPERVISOR_INTERVAL_MS = 200;
3203
+ const MAX_SUPERVISOR_INTERVAL_MS = 5e3;
3204
+ function createConfiguredFeishuCardRolloverRuntime(options) {
3205
+ const leaseMs = options.config.feishu.cardStreamLeaseMs;
3206
+ let rollover;
3207
+ const publisher = createConfiguredFeishuCardKitPublisher({
3208
+ ...options.agentName === void 0 ? {} : { agentName: options.agentName },
3209
+ client: options.client,
3210
+ config: options.config,
3211
+ ...options.ledger ? { ledger: options.ledger } : {},
3212
+ onStreamingClosed: (cardId) => rollover?.observeStreamClosed(cardId),
3213
+ resolveTarget: (runId) => options.cardTargets.resolveTarget(runId),
3214
+ sleep: options.sleep
3215
+ });
3216
+ const creator = createConfiguredFeishuCardKitTargetCreator({
3217
+ client: options.client,
3218
+ config: options.config,
3219
+ ...options.elementId === void 0 ? {} : { elementId: options.elementId },
3220
+ ...options.initialContent === void 0 ? {} : { initialContent: options.initialContent },
3221
+ ...options.title === void 0 ? {} : { title: options.title }
3222
+ });
3223
+ const cardRollover = createFeishuCardRollover({
3224
+ clock: options.clock,
3225
+ createSuccessor: ({ generation, run }) => creator.createTarget(run, { generation }),
3226
+ leaseMs,
3227
+ ...options.observe ? { observe: options.observe } : {},
3228
+ publisher,
3229
+ store: options.cardTargets
3230
+ });
3231
+ rollover = cardRollover;
3232
+ const supervisor = createFeishuCardRolloverSupervisor({
3233
+ clock: options.clock,
3234
+ intervalMs: options.supervisorIntervalMs ?? resolveSupervisorInterval(leaseMs),
3235
+ ...options.onError ? { onError: options.onError } : {},
3236
+ rollover: cardRollover,
3237
+ sleep: options.sleep
3238
+ });
3239
+ return {
3240
+ prepareRun: createFeishuCardTargetPreparation({
3241
+ createTarget: (run) => creator.createTarget(run),
3242
+ presentations: cardRollover
3243
+ }),
3244
+ rollover: cardRollover,
3245
+ supervisor,
3246
+ transport: {
3247
+ running: () => supervisor.running(),
3248
+ start: async () => {
3249
+ await Effect.runPromise(supervisor.recover().pipe(Effect.catchAll((error) => {
3250
+ const reported = options.onError?.(error);
3251
+ return reported instanceof Promise ? Effect.promise(() => reported) : Effect.void;
3252
+ })));
3253
+ supervisor.start();
3254
+ },
3255
+ stop: () => supervisor.stop()
3256
+ }
3257
+ };
3258
+ }
3259
+ function resolveSupervisorInterval(leaseMs) {
3260
+ return Math.max(MIN_SUPERVISOR_INTERVAL_MS, Math.min(MAX_SUPERVISOR_INTERVAL_MS, Math.floor(leaseMs / 10)));
3261
+ }
3262
+ //#endregion
3146
3263
  //#region src/composition/rivus-daemon-bootstrap.ts
3147
3264
  const DEFAULT_WORKER_INTERVAL_MS$1 = 250;
3148
3265
  const DEFAULT_RUN_TIMEOUT_MS = 900 * 1e3;
@@ -3157,17 +3274,19 @@ function createConfiguredRivusDaemonBootstrap(options) {
3157
3274
  config: options.config,
3158
3275
  request: options.request
3159
3276
  });
3160
- const prepareRun = createConfiguredFeishuCardKitTargetPreparation({
3161
- client: openApiClient,
3162
- config: options.config,
3163
- registry: options.cardTargets
3164
- });
3165
- const publisher = createConfiguredFeishuCardKitPublisher({
3277
+ const cardRollover = createConfiguredFeishuCardRolloverRuntime({
3278
+ cardTargets: options.cardTargets,
3166
3279
  client: openApiClient,
3280
+ clock: options.clock,
3167
3281
  config: options.config,
3168
- resolveTarget: (runId) => options.cardTargets.resolveTarget(runId),
3169
- sleep: options.sleep
3282
+ ...options.cardLedger ? { ledger: options.cardLedger } : {},
3283
+ ...options.observeCardRollover ? { observe: options.observeCardRollover } : {},
3284
+ ...options.onWorkerError ? { onError: options.onWorkerError } : {},
3285
+ sleep: options.sleep,
3286
+ ...options.cardRolloverIntervalMs === void 0 ? {} : { supervisorIntervalMs: options.cardRolloverIntervalMs }
3170
3287
  });
3288
+ const publisher = cardRollover.rollover;
3289
+ const prepareRun = (run) => cardRollover.prepareRun(run);
3171
3290
  const periodicFlush = createPeriodicFlush(options, publisher);
3172
3291
  const runtime = createFeishuAgentRuntime({
3173
3292
  agentId: options.config.agentId,
@@ -3197,25 +3316,31 @@ function createConfiguredRivusDaemonBootstrap(options) {
3197
3316
  });
3198
3317
  const restoreHistoryFromLog = () => restoreAgentHistory(options.eventLog);
3199
3318
  let processRef;
3200
- let transport = websocketTransport;
3319
+ let transport = createCompositeRivusDaemonTransport({ transports: [websocketTransport, cardRollover.transport] });
3201
3320
  const statusReporter = createRivusDaemonStatusReporter({
3202
3321
  agentId: options.config.agentId,
3203
3322
  availability: () => runtime.harness.getAvailability(),
3204
3323
  pending: () => runtime.pending(),
3205
3324
  processRunning: () => processRef?.running() ?? false,
3325
+ cardPresentations: () => cardRollover.rollover.status(),
3206
3326
  receiveStatus: () => runtime.receiveStatus(),
3207
3327
  restoreHistory: restoreHistoryFromLog,
3208
3328
  transportRunning: () => transport.running(),
3209
3329
  workerLoopRunning: () => workerLoop.running()
3210
3330
  });
3211
3331
  const statusTransport = options.createStatusTransport?.(statusReporter);
3212
- if (statusTransport) transport = createCompositeRivusDaemonTransport({ transports: [websocketTransport, statusTransport] });
3332
+ if (statusTransport) transport = createCompositeRivusDaemonTransport({ transports: [
3333
+ websocketTransport,
3334
+ cardRollover.transport,
3335
+ statusTransport
3336
+ ] });
3213
3337
  const process = createRivusDaemonProcess({
3214
3338
  transport,
3215
3339
  workerLoop
3216
3340
  });
3217
3341
  processRef = process;
3218
3342
  return {
3343
+ cardRollover,
3219
3344
  cardTargets: options.cardTargets,
3220
3345
  eventLog: options.eventLog,
3221
3346
  process,
@@ -4346,6 +4471,79 @@ function createPiSessionRegistry(options) {
4346
4471
  };
4347
4472
  }
4348
4473
  //#endregion
4474
+ //#region src/application/feishu/feishu-card-presentation-store.ts
4475
+ var FeishuCardPresentationNotFound = class {
4476
+ runId;
4477
+ _tag = "FeishuCardPresentationNotFound";
4478
+ constructor(runId) {
4479
+ this.runId = runId;
4480
+ }
4481
+ };
4482
+ function createFeishuCardPresentationStore(options = {}) {
4483
+ const chains = new Map(options.initial?.map((chain) => [chain.runId, structuredClone(chain)]) ?? []);
4484
+ const serial = createSerialExecutor();
4485
+ const save = async (next) => {
4486
+ for (const chain of next) chains.set(chain.runId, structuredClone(chain));
4487
+ await options.persist?.([...chains.values()]);
4488
+ };
4489
+ const mutate = (operation) => Effect.tryPromise({
4490
+ try: () => serial.run(operation),
4491
+ catch: (error) => error
4492
+ });
4493
+ const transition = (runId, apply) => mutate(async () => {
4494
+ const current = chains.get(runId);
4495
+ if (!current) throw new FeishuCardPresentationNotFound(runId);
4496
+ const next = apply(current);
4497
+ if (next !== current) await save([next]);
4498
+ return activeCardPresentation(next);
4499
+ });
4500
+ return {
4501
+ bind: (binding) => mutate(async () => {
4502
+ const current = chains.get(binding.runId);
4503
+ if (current && activeCardPresentation(current).cardId === binding.cardId) return activeCardPresentation(current);
4504
+ const created = createCardPresentationChain(binding);
4505
+ await save([created]);
4506
+ return activeCardPresentation(created);
4507
+ }),
4508
+ beginHandoff: ({ handoffAt, runId }) => mutate(async () => {
4509
+ const current = chains.get(runId);
4510
+ if (!current) throw new FeishuCardPresentationNotFound(runId);
4511
+ const next = beginCardPresentationHandoff(current, handoffAt);
4512
+ if (next === current) return {
4513
+ presentation: activeCardPresentation(current),
4514
+ started: false
4515
+ };
4516
+ await save([next]);
4517
+ return {
4518
+ presentation: activeCardPresentation(next),
4519
+ started: true
4520
+ };
4521
+ }),
4522
+ chain: (runId) => {
4523
+ const current = chains.get(runId);
4524
+ return current ? structuredClone(current) : void 0;
4525
+ },
4526
+ chains: () => [...chains.values()].map((chain) => structuredClone(chain)),
4527
+ compensateInterruptedHandoffs: (compensatedAt) => mutate(async () => {
4528
+ const compensated = [...chains.values()].map((chain) => ({
4529
+ chain,
4530
+ next: compensateCardPresentationHandoff(chain, compensatedAt)
4531
+ })).filter(({ chain, next }) => next !== chain).map(({ next }) => next);
4532
+ if (compensated.length > 0) await save(compensated);
4533
+ return compensated.map((chain) => structuredClone(chain));
4534
+ }),
4535
+ completeHandoff: ({ runId, successor }) => transition(runId, (chain) => completeCardPresentationHandoff(chain, successor)),
4536
+ failHandoff: ({ failedAt, runId }) => transition(runId, (chain) => failCardPresentationHandoff(chain, failedAt)).pipe(Effect.asVoid),
4537
+ markTerminal: ({ runId, terminalReceiptId }) => transition(runId, (chain) => markCardPresentationTerminal(chain, terminalReceiptId)).pipe(Effect.asVoid),
4538
+ release: (runId) => mutate(async () => {
4539
+ if (!chains.has(runId)) return;
4540
+ chains.delete(runId);
4541
+ await options.persist?.([...chains.values()]);
4542
+ }),
4543
+ size: () => chains.size
4544
+ };
4545
+ }
4546
+ //#endregion
4349
4547
  //#region src/infrastructure/feishu/feishu-card-target-registry.ts
4350
4548
  var FeishuCardTargetNotFound = class {
4351
4549
  runId;
@@ -4363,74 +4561,101 @@ var FeishuCardTargetRegistryStoreError = class {
4363
4561
  this.cause = cause;
4364
4562
  }
4365
4563
  };
4366
- function createInMemoryFeishuCardTargetRegistry() {
4367
- const targets = /* @__PURE__ */ new Map();
4368
- return {
4369
- bind: (runId, target) => Effect.sync(() => {
4370
- targets.set(runId, target);
4371
- }),
4372
- release: (runId) => Effect.sync(() => {
4373
- targets.delete(runId);
4374
- }),
4375
- resolveTarget: (runId) => Effect.sync(() => targets.get(runId)).pipe(Effect.flatMap((target) => target ? Effect.succeed(target) : Effect.fail(new FeishuCardTargetNotFound(runId)))),
4376
- size: () => targets.size
4377
- };
4564
+ const PRESENTATION_FILE_VERSION = 2;
4565
+ const LEGACY_PRESENTATION_TIMESTAMP = (/* @__PURE__ */ new Date(0)).toISOString();
4566
+ function createInMemoryFeishuCardTargetRegistry(initial = []) {
4567
+ const store = createFeishuCardPresentationStore({ initial });
4568
+ return withTargetResolution(store, () => Effect.succeed(store));
4378
4569
  }
4379
4570
  function createJsonFileFeishuCardTargetRegistry(options) {
4380
- let lastKnownSize = 0;
4381
- const loadTargets = Effect.tryPromise({
4382
- try: async () => {
4383
- try {
4384
- const raw = await readFile(options.filePath, "utf8");
4385
- const targets = parseTargets(JSON.parse(raw));
4386
- lastKnownSize = Object.keys(targets).length;
4387
- return targets;
4388
- } catch (error) {
4389
- if (isNodeErrorWithCode(error, "ENOENT")) {
4390
- lastKnownSize = 0;
4391
- return {};
4392
- }
4393
- throw error;
4394
- }
4395
- },
4396
- catch: (error) => new FeishuCardTargetRegistryStoreError("load", error)
4397
- });
4398
- const saveTargets = (targets) => Effect.tryPromise({
4399
- try: async () => {
4400
- await mkdir(dirname(options.filePath), { recursive: true });
4401
- await writeFile(options.filePath, `${JSON.stringify(targets, null, 2)}\n`, "utf8");
4402
- lastKnownSize = Object.keys(targets).length;
4403
- },
4404
- catch: (error) => new FeishuCardTargetRegistryStoreError("save", error)
4571
+ let opened;
4572
+ let loaded;
4573
+ const open = async () => {
4574
+ const store = createFeishuCardPresentationStore({
4575
+ initial: await loadChains(options.filePath),
4576
+ persist: (chains) => saveChains(options.filePath, chains)
4577
+ });
4578
+ loaded = store;
4579
+ return store;
4580
+ };
4581
+ const ready = () => Effect.tryPromise({
4582
+ try: () => opened ??= open(),
4583
+ catch: (error) => error instanceof FeishuCardTargetRegistryStoreError ? error : new FeishuCardTargetRegistryStoreError("load", error)
4405
4584
  });
4585
+ const use = (operation) => ready().pipe(Effect.flatMap(operation));
4586
+ return withTargetResolution({
4587
+ bind: (binding) => use((current) => current.bind(binding)),
4588
+ beginHandoff: (input) => use((current) => current.beginHandoff(input)),
4589
+ chain: (runId) => loaded?.chain(runId),
4590
+ chains: () => loaded?.chains() ?? [],
4591
+ compensateInterruptedHandoffs: (compensatedAt) => use((current) => current.compensateInterruptedHandoffs(compensatedAt)),
4592
+ completeHandoff: (input) => use((current) => current.completeHandoff(input)),
4593
+ failHandoff: (input) => use((current) => current.failHandoff(input)),
4594
+ markTerminal: (input) => use((current) => current.markTerminal(input)),
4595
+ release: (runId) => use((current) => current.release(runId)),
4596
+ size: () => loaded?.size() ?? 0
4597
+ }, ready);
4598
+ }
4599
+ function withTargetResolution(store, ready) {
4406
4600
  return {
4407
- bind: (runId, target) => loadTargets.pipe(Effect.flatMap((targets) => saveTargets({
4408
- ...targets,
4409
- [runId]: target
4410
- }))),
4411
- release: (runId) => loadTargets.pipe(Effect.flatMap((targets) => {
4412
- const nextTargets = { ...targets };
4413
- delete nextTargets[runId];
4414
- return saveTargets(nextTargets);
4415
- })),
4416
- resolveTarget: (runId) => loadTargets.pipe(Effect.flatMap((targets) => {
4417
- const target = targets[runId];
4418
- return target ? Effect.succeed(target) : Effect.fail(new FeishuCardTargetNotFound(runId));
4419
- })),
4420
- size: () => lastKnownSize
4601
+ ...store,
4602
+ resolveTarget: (runId) => ready().pipe(Effect.flatMap((current) => {
4603
+ const chain = current.chain(runId);
4604
+ return chain ? Effect.succeed(toTarget(activeCardPresentation(chain))) : Effect.fail(new FeishuCardTargetNotFound(runId));
4605
+ }))
4606
+ };
4607
+ }
4608
+ function toTarget(presentation) {
4609
+ return {
4610
+ cardId: presentation.cardId,
4611
+ elementId: presentation.elementId ?? "rivus_agent_answer"
4421
4612
  };
4422
4613
  }
4423
- function parseTargets(value) {
4424
- if (!isRecord$4(value)) throw new Error("Feishu card target registry file must contain a JSON object.");
4425
- const targets = {};
4426
- for (const [runId, target] of Object.entries(value)) {
4427
- if (!isFeishuCardTarget(target)) throw new Error(`Invalid Feishu card target entry for run '${runId}'.`);
4428
- targets[runId] = target;
4614
+ async function loadChains(filePath) {
4615
+ try {
4616
+ const raw = await readFile(filePath, "utf8");
4617
+ return parseChains(JSON.parse(raw));
4618
+ } catch (error) {
4619
+ if (isNodeErrorWithCode(error, "ENOENT")) return [];
4620
+ throw new FeishuCardTargetRegistryStoreError("load", error);
4429
4621
  }
4430
- return targets;
4431
4622
  }
4432
- function isFeishuCardTarget(value) {
4433
- return isRecord$4(value) && typeof value.cardId === "string" && typeof value.elementId === "string";
4623
+ async function saveChains(filePath, chains) {
4624
+ try {
4625
+ await mkdir(dirname(filePath), { recursive: true });
4626
+ const runs = Object.fromEntries(chains.map((chain) => [chain.runId, chain]));
4627
+ await writeFile(filePath, `${JSON.stringify({
4628
+ runs,
4629
+ version: PRESENTATION_FILE_VERSION
4630
+ }, null, 2)}\n`, "utf8");
4631
+ } catch (error) {
4632
+ throw new FeishuCardTargetRegistryStoreError("save", error);
4633
+ }
4634
+ }
4635
+ function parseChains(value) {
4636
+ if (!isRecord$4(value)) throw new Error("Feishu card presentation file must contain a JSON object.");
4637
+ if (value.version === void 0) return Object.entries(value).map(([runId, target]) => parseLegacyChain(runId, target));
4638
+ if (value.version !== PRESENTATION_FILE_VERSION || !isRecord$4(value.runs)) throw new Error(`Unsupported Feishu card presentation file version: ${JSON.stringify(value.version)}`);
4639
+ return Object.entries(value.runs).map(([runId, chain]) => parseChain(runId, chain));
4640
+ }
4641
+ function parseLegacyChain(runId, target) {
4642
+ if (!isRecord$4(target) || typeof target.cardId !== "string" || typeof target.elementId !== "string") throw new Error(`Invalid Feishu card target entry for run '${runId}'.`);
4643
+ return createCardPresentationChain({
4644
+ cardId: target.cardId,
4645
+ createdAt: LEGACY_PRESENTATION_TIMESTAMP,
4646
+ elementId: target.elementId,
4647
+ leaseDeadlineAt: LEGACY_PRESENTATION_TIMESTAMP,
4648
+ presentationId: `${runId}#0`,
4649
+ runId,
4650
+ sourceMessageId: ""
4651
+ });
4652
+ }
4653
+ function parseChain(runId, value) {
4654
+ if (!isRecord$4(value) || value.runId !== runId || !Number.isInteger(value.activeGeneration) || typeof value.activePresentationId !== "string" || !Number.isInteger(value.revision) || !Array.isArray(value.presentations) || value.presentations.length === 0) throw new Error(`Invalid Feishu card presentation chain for run '${runId}'.`);
4655
+ const chain = value;
4656
+ for (const presentation of chain.presentations) if (!isRecord$4(presentation) || typeof presentation.cardId !== "string" || typeof presentation.presentationId !== "string" || typeof presentation.status !== "string" || !Number.isInteger(presentation.generation)) throw new Error(`Invalid Feishu card presentation entry for run '${runId}'.`);
4657
+ activeCardPresentation(chain);
4658
+ return chain;
4434
4659
  }
4435
4660
  //#endregion
4436
4661
  //#region src/infrastructure/feishu/feishu-cot-tool-presenter.ts
@@ -5431,14 +5656,19 @@ function createFeishuDeploymentEndpoint(options) {
5431
5656
  })
5432
5657
  });
5433
5658
  return {
5434
- running: () => websocket.running() && workerLoop.running(),
5659
+ running: () => websocket.running() && workerLoop.running() && (options.cardRollover?.running() ?? true),
5435
5660
  start: async () => {
5436
5661
  execution.beginStart();
5437
5662
  try {
5663
+ await options.cardRollover?.start();
5438
5664
  await websocket.start();
5439
5665
  workerLoop.start();
5440
5666
  } catch (startError) {
5441
- const cleanupErrors = await settleCleanup([() => websocket.stop(), () => workerLoop.stop()]);
5667
+ const cleanupErrors = await settleCleanup([
5668
+ () => websocket.stop(),
5669
+ () => workerLoop.stop(),
5670
+ () => options.cardRollover?.stop()
5671
+ ]);
5442
5672
  if (cleanupErrors.length > 0) throw new AggregateError([startError, ...cleanupErrors], "Feishu endpoint startup and cleanup failed");
5443
5673
  throw startError;
5444
5674
  }
@@ -5449,7 +5679,8 @@ function createFeishuDeploymentEndpoint(options) {
5449
5679
  const cleanupErrors = await settleCleanup([
5450
5680
  () => websocketStop,
5451
5681
  () => execution.cancelActiveAndWait(),
5452
- () => workerStop
5682
+ () => workerStop,
5683
+ () => options.cardRollover?.stop()
5453
5684
  ]);
5454
5685
  if (cleanupErrors.length === 1) throw cleanupErrors[0];
5455
5686
  if (cleanupErrors.length > 1) throw new AggregateError(cleanupErrors, "Feishu endpoint cleanup failed");
@@ -7409,4 +7640,4 @@ function validateDecisionInput(input) {
7409
7640
  if (input.recommendedOptionId && !optionIds.includes(input.recommendedOptionId)) throw new Error("recommended user decision option must be available");
7410
7641
  }
7411
7642
  //#endregion
7412
- export { AgentContextBudgetExceeded, AgentEventHandlerFailed, AgentEventLogStoreError, AgentEventSinkFailed, AgentHarnessBusy, AgentInstanceBusy, AgentInstanceConflict, AgentLoopFailed, AgentMemoryError, AgentRunCancelled, AgentRuntimeDisposed, AutomationMandateError, CompactionError, DelegationDenied, DeliveryOutboxError, FeishuCardTargetNotFound, FeishuCardTargetRegistryStoreError, FeishuCotProtocolError, FeishuEndpointCredentialError, FeishuOpenApiError, FeishuTenantAccessTokenError, HumanInteractionRepositoryError, HumanInteractionTransitionDenied, InvalidFeishuCardAction, InvalidFeishuMessageContent, InvalidFeishuSessionReference, InvalidInvocationAuthority, InvalidProjectSkillCatalog, InvalidRecoveryAction, InvalidRivusEndpointBinding, InvalidRivusPlugin, InvalidRivusProjectSpace, InvalidStableJson, InvalidToolInput, InvalidWorkspaceRoot, LangfuseTelemetryConfigError, MEMORY_SCOPES, OpenClawEnvImportError, PluginStateConflict, RIVUS_MEMORY_TOOL_ID, RIVUS_MEMORY_TOOL_PLUGIN_ID, RIVUS_MEMORY_TOOL_VERSION, RIVUS_PLUGIN_API_VERSION, RivusDaemonConfigError, RivusDeploymentAutomationReadinessError, RivusDeploymentDaemonLifecycleError, RivusDeploymentManifestError, RivusDeploymentReadinessError, RivusPluginConformanceError, RivusPluginLoadError, RivusToolInputRejected, SessionSchedulerCapacityExceeded, SessionSchedulerDisposed, ToolInvocationDenied, UnsupportedFeishuCardAction, UnsupportedFeishuMessage, WorkspaceInstructionsSourceError, assembleAgentContext, assertRivusPluginConforms, commitAutomationOutcome, createAgentCommandFromFeishuCardAction, createAgentCommandFromFeishuMessage, createAgentConversationMessages, createAgentDomainEventHandler, createAgentDomainEventSink, createAgentDomainEventSinkFromCallback, createAgentHarness, createAgentHarnessClient, createAgentHarnessPooledRuntime, createAgentInstanceRegistry, createAgentLoopFromCallback, createAgentLoopModelExecutionEnd, createAgentLoopModelExecutionStart, createAgentLoopPromptTransformer, createAgentLoopSkillExecutionEnd, createAgentLoopSkillExecutionStart, createAgentLoopTextDelta, createAgentLoopThinkingDelta, createAgentLoopToolExecutionEnd, createAgentLoopToolExecutionStart, createAgentLoopToolExecutionUpdate, createAgentMemoryService, createAgentRunUpdateHandler, createAgentRuntime, createAgentRuntimePool, createAgentTranscriptMessages, createAgentTranscriptTurn, createAgentsMdInstructionsProvider, createAsyncIterableAgentLoop, createAutomationMandateStore, createCoalescingFeishuPublisher, createCompactionService, createCompositeRivusDaemonTransport, createConfiguredFeishuAutomationCardSender, createConfiguredFeishuCardKitPublisher, createConfiguredFeishuCardKitTargetPreparation, createConfiguredFeishuHumanInteractionPresenter, createConfiguredFeishuOpenApiClient, createConfiguredFeishuTextReplySender, createConfiguredRivusDaemonBootstrap, createConfiguredRivusDeploymentDaemon, createDailyAutomationSchedule, createDefaultAgentHarness, createDefaultAgentHarnessClient, createDefaultAgentHarnessClientFromCallback, createDefaultAgentHarnessClientFromTextCallback, createDefaultAgentHarnessFromCallback, createDefaultAgentHarnessFromTextCallback, createDefaultAgentRuntime, createDefaultAgentRuntimeFromCallback, createDefaultAgentRuntimeFromTextCallback, createDelegationService, createDeliveryOutbox, createEventAgentLoop, createFakeRivusPlugin, createFeishuAgentDaemon, createFeishuAgentRunCard, createFeishuAgentRuntime, createFeishuCardActionCallbackResponse, createFeishuCardActionErrorResponse, createFeishuCardDeliveryLedger, createFeishuCardDeliveryReconciler, createFeishuCardKitOpenApiClient, createFeishuCardKitOpenApiTargetCreator, createFeishuCardKitPublisher, createFeishuCardTargetPreparation, createFeishuConversationId, createFeishuCotPublisher, createFeishuDeploymentEndpoint, createFeishuEventHandlers, createFeishuHumanInteractionCard, createFeishuHumanInteractionPresenter, createFeishuInboxRepository, createFeishuMessageQueue, createFeishuMessageWorker, createFeishuOpenApiClient, createFeishuPeriodicFlush, createFeishuPresentationPreparation, createFeishuSessionKey, createFeishuStreamProjector, createFeishuTenantAccessTokenProvider, createFeishuWebSocketDaemon, createFeishuWorkerLoop, createFixedClock, createHumanInteractionEndpointRegistry, createHumanInteractionService, createHumanInteractionToolApprovalGateway, createInMemoryFeishuCardTargetRegistry, createInMemoryHumanInteractionRepository, createInvocationAuthority, createJsonFetchRequest, createJsonFileFeishuCardTargetRegistry, createJsonlAgentEventLog, createJsonlHumanInteractionRepository, createLangfuseAgentTelemetry, createLazyFeishuWebSocketEventDispatcher, createMemoryNamespace, createOpenTelemetryAgentEventSink, createOpenTelemetryAgentTelemetry, createPiAgentLoop, createPiSdkAgentLoop, createPiSessionRegistry, createPiSkillRuntime, createPiToolNameResolver, createPiToolProxyDefinitions, createPluginStateStore, createProjectMemoryPromptPreparer, createRateLimitedFeishuPublisher, createRecoveryAction, createRecoveryControl, createRivusAgentHost, createRivusDaemonProcess, createRivusDaemonShutdownController, createRivusDaemonStatusHttpServer, createRivusDaemonStatusReporter, createRivusDeploymentCliProcess, createRivusDeploymentDaemon, createRivusEnvFromOpenClawConfig, createRivusMemoryTool, createRivusMemoryToolContract, createRivusMemoryToolDescriptor, createRivusPluginCatalog, createRoutedHumanInteractionToolApprovalService, createScheduledAutomation, createSequenceRunIds, createSessionScheduler, createSubagentCoordinator, createSystemClock, createTelemetryContentRedactor, createTextAgentLoop, createTextAgentLoopFromCallback, createToolBroker, createToolInputDigest, createToolOperationLedger, createUuidRunIds, createWorkspaceRootHandle, describeFeishuMessageIntake, evolveAgentRun, formatRivusEnvFile, initialAgentRunState, intersectToolIds, isAgentToolExecutionEvent, isAssistantTextDeltaEvent, isAssistantThinkingDeltaEvent, isTerminalAgentDomainEvent, isTerminalAgentRunPhase, loadNodeRivusPluginModule, loadRivusDaemonConfig, loadRivusDeployment, loadRivusDeploymentManifest, normalizeStableJson, openJsonAutomationTickRepository, openJsonlAgentMemoryService, openJsonlFeishuCardDeliveryLedger, openJsonlFeishuInboxRepository, openJsonlRecoveryControl, openJsonlToolOperationLedger, replayAgentHistory, replayAgentTranscript, requiresToolApproval, resolveFeishuEndpointCredentials, resolveLangfuseTelemetryConfig, resolveRivusAgentDefinition, resolveRivusProjectSpace, restoreAgentHistory, restoreConfiguredRivusDaemonBootstrap, restrictMemoryScopesForAudience, runRivusDaemonCli, shouldAcceptFeishuEndpointMessage, transitionHumanInteraction, validateProjectSkillCatalog, validateProjectSkillCommand, validateRivusDeploymentManifest };
7643
+ export { AgentContextBudgetExceeded, AgentEventHandlerFailed, AgentEventLogStoreError, AgentEventSinkFailed, AgentHarnessBusy, AgentInstanceBusy, AgentInstanceConflict, AgentLoopFailed, AgentMemoryError, AgentRunCancelled, AgentRuntimeDisposed, AutomationMandateError, CardPresentationTransitionDenied, CompactionError, DEFAULT_CARD_STREAM_LEASE_MS, DelegationDenied, DeliveryOutboxError, FeishuCardPresentationNotFound, FeishuCardTargetNotFound, FeishuCardTargetRegistryStoreError, FeishuCotProtocolError, FeishuEndpointCredentialError, FeishuOpenApiError, FeishuTenantAccessTokenError, HumanInteractionRepositoryError, HumanInteractionTransitionDenied, InvalidFeishuCardAction, InvalidFeishuMessageContent, InvalidFeishuSessionReference, InvalidInvocationAuthority, InvalidProjectSkillCatalog, InvalidRecoveryAction, InvalidRivusEndpointBinding, InvalidRivusPlugin, InvalidRivusProjectSpace, InvalidStableJson, InvalidToolInput, InvalidWorkspaceRoot, LangfuseTelemetryConfigError, MEMORY_SCOPES, OpenClawEnvImportError, PluginStateConflict, RIVUS_MEMORY_TOOL_ID, RIVUS_MEMORY_TOOL_PLUGIN_ID, RIVUS_MEMORY_TOOL_VERSION, RIVUS_PLUGIN_API_VERSION, RivusDaemonConfigError, RivusDeploymentAutomationReadinessError, RivusDeploymentDaemonLifecycleError, RivusDeploymentManifestError, RivusDeploymentReadinessError, RivusPluginConformanceError, RivusPluginLoadError, RivusToolInputRejected, SessionSchedulerCapacityExceeded, SessionSchedulerDisposed, ToolInvocationDenied, UnsupportedFeishuCardAction, UnsupportedFeishuMessage, WorkspaceInstructionsSourceError, acceptsCardPresentationProgress, activeCardPresentation, assembleAgentContext, assertRivusPluginConforms, commitAutomationOutcome, createAgentCommandFromFeishuCardAction, createAgentCommandFromFeishuMessage, createAgentConversationMessages, createAgentDomainEventHandler, createAgentDomainEventSink, createAgentDomainEventSinkFromCallback, createAgentHarness, createAgentHarnessClient, createAgentHarnessPooledRuntime, createAgentInstanceRegistry, createAgentLoopFromCallback, createAgentLoopModelExecutionEnd, createAgentLoopModelExecutionStart, createAgentLoopPromptTransformer, createAgentLoopSkillExecutionEnd, createAgentLoopSkillExecutionStart, createAgentLoopTextDelta, createAgentLoopThinkingDelta, createAgentLoopToolExecutionEnd, createAgentLoopToolExecutionStart, createAgentLoopToolExecutionUpdate, createAgentMemoryService, createAgentRunUpdateHandler, createAgentRuntime, createAgentRuntimePool, createAgentTranscriptMessages, createAgentTranscriptTurn, createAgentsMdInstructionsProvider, createAsyncIterableAgentLoop, createAutomationMandateStore, createCoalescingFeishuPublisher, createCompactionService, createCompositeRivusDaemonTransport, createConfiguredFeishuAutomationCardSender, createConfiguredFeishuCardKitPublisher, createConfiguredFeishuCardKitTargetCreator, createConfiguredFeishuCardKitTargetPreparation, createConfiguredFeishuCardRolloverRuntime, createConfiguredFeishuHumanInteractionPresenter, createConfiguredFeishuOpenApiClient, createConfiguredFeishuTextReplySender, createConfiguredRivusDaemonBootstrap, createConfiguredRivusDeploymentDaemon, createDailyAutomationSchedule, createDefaultAgentHarness, createDefaultAgentHarnessClient, createDefaultAgentHarnessClientFromCallback, createDefaultAgentHarnessClientFromTextCallback, createDefaultAgentHarnessFromCallback, createDefaultAgentHarnessFromTextCallback, createDefaultAgentRuntime, createDefaultAgentRuntimeFromCallback, createDefaultAgentRuntimeFromTextCallback, createDelegationService, createDeliveryOutbox, createEventAgentLoop, createFakeRivusPlugin, createFeishuAgentDaemon, createFeishuAgentRunCard, createFeishuAgentRuntime, createFeishuCardActionCallbackResponse, createFeishuCardActionErrorResponse, createFeishuCardDeliveryLedger, createFeishuCardDeliveryReconciler, createFeishuCardKitOpenApiClient, createFeishuCardKitOpenApiTargetCreator, createFeishuCardKitPublisher, createFeishuCardPresentationStore, createFeishuCardRollover, createFeishuCardRolloverSupervisor, createFeishuCardTargetPreparation, createFeishuConversationId, createFeishuCotPublisher, createFeishuDeploymentEndpoint, createFeishuEventHandlers, createFeishuHumanInteractionCard, createFeishuHumanInteractionPresenter, createFeishuInboxRepository, createFeishuMessageQueue, createFeishuMessageWorker, createFeishuOpenApiClient, createFeishuPeriodicFlush, createFeishuPresentationPreparation, createFeishuSessionKey, createFeishuStreamProjector, createFeishuTenantAccessTokenProvider, createFeishuWebSocketDaemon, createFeishuWorkerLoop, createFixedClock, createHumanInteractionEndpointRegistry, createHumanInteractionService, createHumanInteractionToolApprovalGateway, createInMemoryFeishuCardTargetRegistry, createInMemoryHumanInteractionRepository, createInvocationAuthority, createJsonFetchRequest, createJsonFileFeishuCardTargetRegistry, createJsonlAgentEventLog, createJsonlHumanInteractionRepository, createLangfuseAgentTelemetry, createLazyFeishuWebSocketEventDispatcher, createMemoryNamespace, createOpenTelemetryAgentEventSink, createOpenTelemetryAgentTelemetry, createPiAgentLoop, createPiSdkAgentLoop, createPiSessionRegistry, createPiSkillRuntime, createPiToolNameResolver, createPiToolProxyDefinitions, createPluginStateStore, createProjectMemoryPromptPreparer, createRateLimitedFeishuPublisher, createRecoveryAction, createRecoveryControl, createRivusAgentHost, createRivusDaemonProcess, createRivusDaemonShutdownController, createRivusDaemonStatusHttpServer, createRivusDaemonStatusReporter, createRivusDeploymentCliProcess, createRivusDeploymentDaemon, createRivusEnvFromOpenClawConfig, createRivusMemoryTool, createRivusMemoryToolContract, createRivusMemoryToolDescriptor, createRivusPluginCatalog, createRoutedHumanInteractionToolApprovalService, createScheduledAutomation, createSequenceRunIds, createSessionScheduler, createSubagentCoordinator, createSystemClock, createTelemetryContentRedactor, createTextAgentLoop, createTextAgentLoopFromCallback, createToolBroker, createToolInputDigest, createToolOperationLedger, createUuidRunIds, createWorkspaceRootHandle, describeFeishuMessageIntake, evolveAgentRun, formatRivusEnvFile, initialAgentRunState, intersectToolIds, isAgentToolExecutionEvent, isAssistantTextDeltaEvent, isAssistantThinkingDeltaEvent, isCardPresentationHandoffDue, isTerminalAgentDomainEvent, isTerminalAgentRunPhase, loadNodeRivusPluginModule, loadRivusDaemonConfig, loadRivusDeployment, loadRivusDeploymentManifest, normalizeStableJson, openJsonAutomationTickRepository, openJsonlAgentMemoryService, openJsonlFeishuCardDeliveryLedger, openJsonlFeishuInboxRepository, openJsonlRecoveryControl, openJsonlToolOperationLedger, replayAgentHistory, replayAgentTranscript, requiresToolApproval, resolveFeishuEndpointCredentials, resolveLangfuseTelemetryConfig, resolveRivusAgentDefinition, resolveRivusProjectSpace, restoreAgentHistory, restoreConfiguredRivusDaemonBootstrap, restrictMemoryScopesForAudience, runRivusDaemonCli, shouldAcceptFeishuEndpointMessage, transitionHumanInteraction, validateProjectSkillCatalog, validateProjectSkillCommand, validateRivusDeploymentManifest };