@rivus/agent 0.10.3 → 0.12.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/dist/acp.d.ts +6 -1
- package/dist/acp.js +121 -29
- package/dist/agent-loop.d.ts +8 -1
- package/dist/index.d.ts +186 -23
- package/dist/index.js +869 -250
- package/dist/rivus-daemon-cli.js +6 -0
- package/examples/pi-feishu-deployment.bootstrap.ts +19 -1
- package/package.json +2 -1
package/dist/rivus-daemon-cli.js
CHANGED
|
@@ -1317,6 +1317,10 @@ function createAgentRuntimePool(options) {
|
|
|
1317
1317
|
const runtime = runtimes.get(instance.instanceId);
|
|
1318
1318
|
return runtime ? (await runtime).cancel?.(input) ?? false : false;
|
|
1319
1319
|
},
|
|
1320
|
+
steer: async (instance, input) => {
|
|
1321
|
+
const runtime = runtimes.get(instance.instanceId);
|
|
1322
|
+
return runtime ? (await runtime).steer?.(input) ?? false : false;
|
|
1323
|
+
},
|
|
1320
1324
|
disposeAll: async () => {
|
|
1321
1325
|
const pendingRuntimes = [...runtimes.values()];
|
|
1322
1326
|
runtimes.clear();
|
|
@@ -1396,6 +1400,7 @@ function createRivusAgentHost(options) {
|
|
|
1396
1400
|
return {
|
|
1397
1401
|
cancelBackgroundSession: (agentId, input) => options.runtimePool.cancel(resolveBackgroundSession(agentId), input),
|
|
1398
1402
|
cancelEndpoint: (endpointId, input) => options.runtimePool.cancel(resolveEndpoint(endpointId), input),
|
|
1403
|
+
steerEndpoint: (endpointId, input) => options.runtimePool.steer(resolveEndpoint(endpointId), input),
|
|
1399
1404
|
handleAutomation: (automationId, input) => options.runtimePool.run(resolveAutomation(automationId), input),
|
|
1400
1405
|
handleBackgroundSession: (agentId, input) => options.runtimePool.run(resolveBackgroundSession(agentId), input),
|
|
1401
1406
|
handleEndpoint: (endpointId, input) => options.runtimePool.run(resolveEndpoint(endpointId), input),
|
|
@@ -1570,6 +1575,7 @@ async function createRivusDeploymentDaemon(options) {
|
|
|
1570
1575
|
endpointId: slot.definition.id,
|
|
1571
1576
|
handle: (input) => handleEndpoint(slot.definition.id, input),
|
|
1572
1577
|
instanceId: host.resolveEndpoint(slot.definition.id).instanceId,
|
|
1578
|
+
steer: (input) => host.steerEndpoint(slot.definition.id, input),
|
|
1573
1579
|
...definitions.get(slot.definition.agentId)?.projectSpaceId ? { projectSpaceId: definitions.get(slot.definition.agentId).projectSpaceId } : {}
|
|
1574
1580
|
}));
|
|
1575
1581
|
degraded ||= slotDegraded;
|
|
@@ -28,6 +28,7 @@ import {
|
|
|
28
28
|
createFeishuCotPublisher,
|
|
29
29
|
createFeishuDeploymentEndpoint,
|
|
30
30
|
createFeishuPresentationPreparation,
|
|
31
|
+
createFeishuTopicContextResolver,
|
|
31
32
|
createSystemClock,
|
|
32
33
|
createFeishuCardDeliveryReconciler,
|
|
33
34
|
createHumanInteractionEndpointRegistry,
|
|
@@ -55,6 +56,7 @@ import {
|
|
|
55
56
|
resolveFeishuDeliveryChatId,
|
|
56
57
|
openJsonlFeishuCardDeliveryLedger,
|
|
57
58
|
openJsonlFeishuInboxRepository,
|
|
59
|
+
openJsonFeishuSessionStore,
|
|
58
60
|
openJsonlAgentMemoryService,
|
|
59
61
|
openJsonAutomationTickRepository,
|
|
60
62
|
openJsonlToolOperationLedger,
|
|
@@ -329,6 +331,9 @@ export async function createRivusDeploymentAdapters(context: RivusDeploymentBoot
|
|
|
329
331
|
filePath: join(endpointState, "feishu-card-delivery.jsonl")
|
|
330
332
|
});
|
|
331
333
|
const inbox = await openJsonlFeishuInboxRepository({ filePath: join(endpointState, "feishu-inbox.jsonl") });
|
|
334
|
+
const sessionStore = await openJsonFeishuSessionStore({
|
|
335
|
+
filePath: join(endpointState, "feishu-session-store.json")
|
|
336
|
+
});
|
|
332
337
|
const config: RivusDaemonConfig = {
|
|
333
338
|
agentId: input.agentId,
|
|
334
339
|
feishu: {
|
|
@@ -340,6 +345,10 @@ export async function createRivusDeploymentAdapters(context: RivusDeploymentBoot
|
|
|
340
345
|
pi: {}
|
|
341
346
|
};
|
|
342
347
|
const openApiClient = createOpenApiClient(config);
|
|
348
|
+
const promptContext = createFeishuTopicContextResolver({
|
|
349
|
+
baseUrl: input.definition.baseUrl,
|
|
350
|
+
client: openApiClient
|
|
351
|
+
});
|
|
343
352
|
const cotPublisher = input.definition.experimental?.cotMessages
|
|
344
353
|
? createFeishuCotPublisher({
|
|
345
354
|
baseUrl: resolveExperimentalCotBaseUrl(context.env),
|
|
@@ -360,6 +369,9 @@ export async function createRivusDeploymentAdapters(context: RivusDeploymentBoot
|
|
|
360
369
|
const cardRollover = createConfiguredFeishuCardRolloverRuntime({
|
|
361
370
|
agentName: input.agentId,
|
|
362
371
|
cardTargets,
|
|
372
|
+
// The endpoint uses Feishu's long connection; callback buttons are
|
|
373
|
+
// not delivered on that transport.
|
|
374
|
+
cancelButton: false,
|
|
363
375
|
client: openApiClient,
|
|
364
376
|
clock: createSystemClock(),
|
|
365
377
|
config,
|
|
@@ -374,9 +386,10 @@ export async function createRivusDeploymentAdapters(context: RivusDeploymentBoot
|
|
|
374
386
|
const endpointEvents = createJsonlAgentEventLog({
|
|
375
387
|
filePath: join(STATE_DIR, "instances", input.instanceId, "agent-events.jsonl")
|
|
376
388
|
});
|
|
389
|
+
const endpointInitialEvents = await Effect.runPromise(endpointEvents.readAll());
|
|
377
390
|
await Effect.runPromise(
|
|
378
391
|
createFeishuCardDeliveryReconciler({
|
|
379
|
-
events:
|
|
392
|
+
events: endpointInitialEvents,
|
|
380
393
|
ledger: cardLedger,
|
|
381
394
|
publish: (action) => publisher.publish(action)
|
|
382
395
|
}).reconcile()
|
|
@@ -397,6 +410,7 @@ export async function createRivusDeploymentAdapters(context: RivusDeploymentBoot
|
|
|
397
410
|
groupPolicy: input.definition.groupPolicy,
|
|
398
411
|
handle: input.handle,
|
|
399
412
|
inboxRepository: inbox,
|
|
413
|
+
initialEvents: endpointInitialEvents,
|
|
400
414
|
interactions,
|
|
401
415
|
maxPendingMessages: 100,
|
|
402
416
|
memoryTenantId,
|
|
@@ -408,7 +422,11 @@ export async function createRivusDeploymentAdapters(context: RivusDeploymentBoot
|
|
|
408
422
|
prepareCardTarget,
|
|
409
423
|
reportCotError: (operation, error) => reportCotError(input.endpointId, operation, error)
|
|
410
424
|
}),
|
|
425
|
+
promptContext,
|
|
411
426
|
publish: (action) => publisher.publish(action),
|
|
427
|
+
reply: (messageId, text) => replies.reply(messageId, text),
|
|
428
|
+
sessionStore,
|
|
429
|
+
...(input.steer ? { steer: input.steer } : {}),
|
|
412
430
|
...(cotPublisher
|
|
413
431
|
? {
|
|
414
432
|
publishRunUpdate: (update) =>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rivus/agent",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.4",
|
|
4
4
|
"description": "A local agent daemon core built around a usable agent harness and domain events.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -72,6 +72,7 @@
|
|
|
72
72
|
"prepublishOnly": "npm run check",
|
|
73
73
|
"release:check": "node scripts/check-npm-release.mjs",
|
|
74
74
|
"test": "vp test",
|
|
75
|
+
"test:feishu:offline": "node scripts/run-feishu-offline-tests.mjs",
|
|
75
76
|
"test:coverage": "vp test --coverage",
|
|
76
77
|
"test:watch": "vp test watch",
|
|
77
78
|
"typecheck": "vp check --no-fmt --no-lint",
|