@rivus/agent 0.15.0 → 0.16.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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { d as resolveInvocationAuthority, r as createPiSkillRuntime, s as createToolInputDigest, u as createInvocationAuthority } from "../chunks/rivus-tool.js";
|
|
2
|
-
import { $t as openJsonlRecoveryControl, A as createScheduledAutomation, An as createLangfuseAgentTelemetry, Bn as createFeishuTopicContextResolver, Dn as createPiAgentLoop, Dt as createBackgroundSessionHostTools, Ei as openJsonFeishuSessionStore, En as createPiSessionRegistry, Gi as readPersistenceFile, Ii as createFeishuCardDeliveryReconciler, In as createJsonlAgentEventLog, Ji as mergePiProviderModelDeclaration, Jt as createFeishuPresentationPreparation, K as createRivusMemoryToolDescriptor, Ki as isRecord$4, Lt as createBackgroundSessionService, Nt as openJsonlBackgroundSessionDeliveryStore, Oi as openJsonlFeishuInboxRepository, Ot as createBackgroundSessionSupervisor, Pi as openJsonlFeishuCardDeliveryLedger, Qr as createUuidRunIds, Si as createJsonFetchRequest, Ti as createSessionScheduler, Tn as readAutomationPresentation, Ui as createToolBroker, Un as createConfiguredFeishuTextReplySender, W as createProjectMemoryPromptPreparer, Wi as openJsonlToolOperationLedger, Wn as createConfiguredFeishuCardRolloverRuntime, Xt as createAgentHarnessPooledRuntime, Yi as writeAtomicTextFile, Yt as createFeishuDeploymentEndpoint, Zr as createSystemClock, an as createAgentsMdInstructionsProvider, bn as createJsonFileFeishuCardTargetRegistry, c as createConfiguredFeishuAutomationCardSender, d as createHumanInteractionToolApprovalGateway, en as openJsonlToolOperationLedger$1, f as createHumanInteractionEndpointRegistry, g as loadRivusDeploymentManifest, hr as createLazyFeishuWebSocketEventDispatcher, ht as resolveFeishuDeliveryChatId, ii as createAgentHarness, j as AUTOMATION_SUPPRESSION_PREFIX, jn as resolveLangfuseTelemetryConfig, jt as openJsonlBackgroundSessionRepository, k as openJsonAutomationTickRepository, l as createRoutedHumanInteractionToolApprovalService, mn as createFeishuCotPublisher, mt as createConfiguredFeishuBackgroundSessionDelivery, n as createConfiguredFeishuHumanInteractionPresenter, o as createJsonlHumanInteractionRepository, on as createWorkspaceRootHandle, qi as mergePiProviderBaseUrlOverride, t as createHumanInteractionService, tn as createToolBroker$1, tr as createConfiguredFeishuOpenApiClient, u as createHumanInteractionModelChangeApproval, wt as resolveBackgroundSessionSupervisorIntervalMs, z as openJsonlAgentMemoryService } from "../chunks/src.js";
|
|
2
|
+
import { $t as openJsonlRecoveryControl, A as createScheduledAutomation, An as createLangfuseAgentTelemetry, Bn as createFeishuTopicContextResolver, Dn as createPiAgentLoop, Dt as createBackgroundSessionHostTools, Ei as openJsonFeishuSessionStore, En as createPiSessionRegistry, Gi as readPersistenceFile, Hi as ToolInvocationDenied, Ii as createFeishuCardDeliveryReconciler, In as createJsonlAgentEventLog, Ji as mergePiProviderModelDeclaration, Jt as createFeishuPresentationPreparation, K as createRivusMemoryToolDescriptor, Ki as isRecord$4, Lt as createBackgroundSessionService, Nt as openJsonlBackgroundSessionDeliveryStore, Oi as openJsonlFeishuInboxRepository, Ot as createBackgroundSessionSupervisor, Pi as openJsonlFeishuCardDeliveryLedger, Qr as createUuidRunIds, Si as createJsonFetchRequest, Ti as createSessionScheduler, Tn as readAutomationPresentation, Ui as createToolBroker, Un as createConfiguredFeishuTextReplySender, W as createProjectMemoryPromptPreparer, Wi as openJsonlToolOperationLedger, Wn as createConfiguredFeishuCardRolloverRuntime, Xt as createAgentHarnessPooledRuntime, Yi as writeAtomicTextFile, Yt as createFeishuDeploymentEndpoint, Zr as createSystemClock, an as createAgentsMdInstructionsProvider, bn as createJsonFileFeishuCardTargetRegistry, c as createConfiguredFeishuAutomationCardSender, d as createHumanInteractionToolApprovalGateway, en as openJsonlToolOperationLedger$1, f as createHumanInteractionEndpointRegistry, g as loadRivusDeploymentManifest, hr as createLazyFeishuWebSocketEventDispatcher, ht as resolveFeishuDeliveryChatId, ii as createAgentHarness, j as AUTOMATION_SUPPRESSION_PREFIX, jn as resolveLangfuseTelemetryConfig, jt as openJsonlBackgroundSessionRepository, k as openJsonAutomationTickRepository, l as createRoutedHumanInteractionToolApprovalService, mn as createFeishuCotPublisher, mt as createConfiguredFeishuBackgroundSessionDelivery, n as createConfiguredFeishuHumanInteractionPresenter, o as createJsonlHumanInteractionRepository, on as createWorkspaceRootHandle, qi as mergePiProviderBaseUrlOverride, t as createHumanInteractionService, tn as createToolBroker$1, tr as createConfiguredFeishuOpenApiClient, u as createHumanInteractionModelChangeApproval, wt as resolveBackgroundSessionSupervisorIntervalMs, z as openJsonlAgentMemoryService } from "../chunks/src.js";
|
|
3
3
|
import { I as resolveFeishuEndpointCredentials, J as migrateRivusModelManagementConfig, K as installRivusModelManagementCliLauncher, U as runDeploymentProcessEffect, X as loadMergedLocalEnvFile, Y as parseRivusModelManagementHomeConfig, q as installRivusRuntimeManagementSkill } from "../chunks/rivus-daemon-cli.js";
|
|
4
4
|
import { t as createSha256Digest } from "../chunks/sha256-digest.js";
|
|
5
5
|
import { a as toRivusModelManagementSubmission, i as projectRivusModelCliResponse, r as parseRivusModelManagementWireRequest, t as createRivusModelManagementFailure } from "../chunks/rivus-model-management-wire.js";
|
|
@@ -1833,6 +1833,7 @@ const TOOL_ID = "rivus.model.change";
|
|
|
1833
1833
|
const TOOL_VERSION = "1";
|
|
1834
1834
|
/** Reuses Broker policy, exact approval binding and its durable operation ledger. */
|
|
1835
1835
|
function createModelChangeAuthorization(options) {
|
|
1836
|
+
if (typeof options.managementAgentId !== "string" || options.managementAgentId.trim() === "") throw new Error("managementAgentId must be a non-empty string");
|
|
1836
1837
|
const serial = Effect.unsafeMakeSemaphore(1);
|
|
1837
1838
|
const digest = (value) => createToolInputDigest(value, options.digest);
|
|
1838
1839
|
const admissions = /* @__PURE__ */ new Map();
|
|
@@ -1869,7 +1870,7 @@ function createModelChangeAuthorization(options) {
|
|
|
1869
1870
|
request
|
|
1870
1871
|
};
|
|
1871
1872
|
const approved = approvedAuthorization(grant, principal, authorizationId, deadlineAt, digest);
|
|
1872
|
-
const brokerAuthority = createModelChangeBrokerAuthority(run.authority, authorizationId);
|
|
1873
|
+
const brokerAuthority = createModelChangeBrokerAuthority(run.authority, authorizationId, options.managementAgentId);
|
|
1873
1874
|
const authority = resolveInvocationAuthority(brokerAuthority);
|
|
1874
1875
|
const approval = {
|
|
1875
1876
|
agentId: authority.agentId,
|
|
@@ -1912,6 +1913,7 @@ function createModelChangeAuthorization(options) {
|
|
|
1912
1913
|
if (input.homeId !== grant.homeId || authority.endpointId !== grant.endpointId || authority.tenantKey !== grant.tenantKey || !authority.allowedActorOpenIds?.includes(grant.ownerId) || authority.allowedActorOpenIds.length !== 1) return rejected("owner_mismatch", "The current conversation is outside the model management grant.");
|
|
1913
1914
|
if (!grant.operations.includes(input.request.operation)) return rejected("operation_not_granted", "This model operation is outside the configured grant.");
|
|
1914
1915
|
if (input.current.provider !== grant.provider || input.request.target && input.request.target.provider !== grant.provider || input.current.bindingRevision !== grant.bindingRevision) return rejected("binding_changed", "The model provider or binding is outside the current grant.");
|
|
1916
|
+
if (!authority.toolGrantSet.toolIds.includes(TOOL_ID)) return yield* Effect.fail(new ToolInvocationDenied(`tool is not granted for this run: ${TOOL_ID}`));
|
|
1915
1917
|
const principal = {
|
|
1916
1918
|
homeId: grant.homeId,
|
|
1917
1919
|
ownerId: grant.ownerId,
|
|
@@ -2010,11 +2012,12 @@ function authorizationIdentity(digest, grant, principal, request) {
|
|
|
2010
2012
|
request
|
|
2011
2013
|
});
|
|
2012
2014
|
}
|
|
2013
|
-
function createModelChangeBrokerAuthority(run, authorizationId) {
|
|
2015
|
+
function createModelChangeBrokerAuthority(run, authorizationId, managementAgentId) {
|
|
2014
2016
|
const authority = resolveInvocationAuthority(run);
|
|
2015
2017
|
const operationIdentity = `model-change:${authorizationId}`;
|
|
2016
2018
|
return createInvocationAuthority({
|
|
2017
2019
|
...authority,
|
|
2020
|
+
agentId: managementAgentId,
|
|
2018
2021
|
instanceId: operationIdentity,
|
|
2019
2022
|
runId: operationIdentity,
|
|
2020
2023
|
sessionKey: operationIdentity
|
|
@@ -3473,7 +3476,7 @@ async function openPiModelManagementDeployment(options) {
|
|
|
3473
3476
|
const statePath = join(managementDirectory, "model-state.json");
|
|
3474
3477
|
const markerPath = join(managementDirectory, "legacy-export.json");
|
|
3475
3478
|
if (!configuration.enabled && await readPersistenceFile(statePath) === void 0) return void 0;
|
|
3476
|
-
if (options.agentCount
|
|
3479
|
+
if (!Number.isSafeInteger(options.agentCount) || options.agentCount < 1) throw new Error("Model management requires a positive integer Agent count per Home.");
|
|
3477
3480
|
const homeId = createSha256Digest(await realpath(options.stateDirectory));
|
|
3478
3481
|
const runtimeVersion = options.runtimeVersion ?? JSON.parse(await readFile(new URL("../package.json", import.meta.resolve("@rivus/agent")), "utf8")).version;
|
|
3479
3482
|
const clock = { now: () => (/* @__PURE__ */ new Date()).toISOString() };
|
|
@@ -3587,6 +3590,7 @@ async function openPiModelManagementDeployment(options) {
|
|
|
3587
3590
|
try: () => readPiModelManagementGrant(options, homeId, state.current),
|
|
3588
3591
|
catch: (error) => error
|
|
3589
3592
|
}) },
|
|
3593
|
+
managementAgentId: options.agentId,
|
|
3590
3594
|
operations,
|
|
3591
3595
|
resolveWorkerRun: ({ grant: currentGrant, principal, request }) => Effect.sync(() => ({
|
|
3592
3596
|
authority: createInvocationAuthority({
|
|
@@ -79,6 +79,18 @@ declare class InvalidRivusPlugin extends Error {
|
|
|
79
79
|
readonly name = "InvalidRivusPlugin";
|
|
80
80
|
}
|
|
81
81
|
//#endregion
|
|
82
|
+
//#region src/core/application/automation/presentation/automation-line-chart.d.ts
|
|
83
|
+
interface AutomationLineChart {
|
|
84
|
+
readonly title: string;
|
|
85
|
+
readonly labels: ReadonlyArray<string>;
|
|
86
|
+
readonly unit: string;
|
|
87
|
+
readonly seriesLayout?: "overlay" | "separate";
|
|
88
|
+
readonly series: ReadonlyArray<{
|
|
89
|
+
readonly name: string;
|
|
90
|
+
readonly values: ReadonlyArray<number>;
|
|
91
|
+
}>;
|
|
92
|
+
}
|
|
93
|
+
//#endregion
|
|
82
94
|
//#region src/core/application/automation/presentation/automation-presentation.d.ts
|
|
83
95
|
declare const AUTOMATION_PRESENTATION_SCHEMA_VERSION: 1;
|
|
84
96
|
type AutomationPresentationKind = "daily-ai" | "generic" | "industry" | "news" | "subscriptions";
|
|
@@ -97,6 +109,7 @@ interface AutomationPresentationSection {
|
|
|
97
109
|
readonly title: string;
|
|
98
110
|
}
|
|
99
111
|
interface AutomationPresentation {
|
|
112
|
+
readonly lineChart?: AutomationLineChart;
|
|
100
113
|
readonly footnote?: string;
|
|
101
114
|
readonly kind?: AutomationPresentationKind;
|
|
102
115
|
readonly meta: ReadonlyArray<string>;
|
|
@@ -106,6 +119,7 @@ interface AutomationPresentation {
|
|
|
106
119
|
readonly title: string;
|
|
107
120
|
}
|
|
108
121
|
interface AutomationPresentationInput {
|
|
122
|
+
readonly lineChart?: AutomationLineChart;
|
|
109
123
|
readonly footnote?: string;
|
|
110
124
|
readonly kind?: AutomationPresentationKind;
|
|
111
125
|
readonly meta?: ReadonlyArray<string>;
|
package/dist/chunks/src.js
CHANGED
|
@@ -8079,6 +8079,42 @@ function createPiSessionRegistry(options) {
|
|
|
8079
8079
|
};
|
|
8080
8080
|
}
|
|
8081
8081
|
//#endregion
|
|
8082
|
+
//#region src/core/application/automation/presentation/automation-line-chart.ts
|
|
8083
|
+
function readAutomationLineChart(value) {
|
|
8084
|
+
if (!value || typeof value !== "object") throw new Error("Automation line chart must be an object");
|
|
8085
|
+
const chart = value;
|
|
8086
|
+
if (chart.seriesLayout !== void 0 && chart.seriesLayout !== "overlay" && chart.seriesLayout !== "separate") throw new Error("Automation line chart seriesLayout must be overlay or separate");
|
|
8087
|
+
const text = (value, limit) => {
|
|
8088
|
+
if (typeof value !== "string" || !value.trim() || value.length > limit) throw new Error("Automation line chart text is empty or exceeds its limit");
|
|
8089
|
+
return value.trim();
|
|
8090
|
+
};
|
|
8091
|
+
if (!Array.isArray(chart.labels) || chart.labels.length < 2 || chart.labels.length > 60) throw new Error("Automation line chart requires 2 to 60 labels");
|
|
8092
|
+
const labels = Array.from(chart.labels, (label) => text(label, 64));
|
|
8093
|
+
if (new Set(labels).size !== labels.length) throw new Error("Automation line chart labels must be unique");
|
|
8094
|
+
if (!Array.isArray(chart.series) || chart.series.length < 1 || chart.series.length > 6) throw new Error("Automation line chart requires 1 to 6 series");
|
|
8095
|
+
const series = Array.from(chart.series, (value) => {
|
|
8096
|
+
if (!value || typeof value !== "object") throw new Error("Automation line chart series must be an object");
|
|
8097
|
+
const row = value;
|
|
8098
|
+
if (!Array.isArray(row.values) || row.values.length !== labels.length) throw new Error("Automation line chart series must align with every label");
|
|
8099
|
+
const values = Array.from(row.values, (value) => {
|
|
8100
|
+
if (typeof value !== "number" || !Number.isFinite(value)) throw new Error("Automation line chart values must be finite numbers");
|
|
8101
|
+
return value;
|
|
8102
|
+
});
|
|
8103
|
+
return Object.freeze({
|
|
8104
|
+
name: text(row.name, 80),
|
|
8105
|
+
values: Object.freeze(values)
|
|
8106
|
+
});
|
|
8107
|
+
});
|
|
8108
|
+
if (new Set(series.map(({ name }) => name)).size !== series.length) throw new Error("Automation line chart series names must be unique");
|
|
8109
|
+
return Object.freeze({
|
|
8110
|
+
title: text(chart.title, 120),
|
|
8111
|
+
labels: Object.freeze(labels),
|
|
8112
|
+
unit: text(chart.unit, 80),
|
|
8113
|
+
...chart.seriesLayout === void 0 ? {} : { seriesLayout: chart.seriesLayout },
|
|
8114
|
+
series: Object.freeze(series)
|
|
8115
|
+
});
|
|
8116
|
+
}
|
|
8117
|
+
//#endregion
|
|
8082
8118
|
//#region src/core/application/automation/presentation/automation-presentation.ts
|
|
8083
8119
|
const AUTOMATION_PRESENTATION_SCHEMA_VERSION = 1;
|
|
8084
8120
|
var InvalidAutomationPresentation = class extends Error {
|
|
@@ -8107,6 +8143,7 @@ function createAutomationPresentation(input) {
|
|
|
8107
8143
|
});
|
|
8108
8144
|
});
|
|
8109
8145
|
return Object.freeze({
|
|
8146
|
+
...input.lineChart === void 0 ? {} : { lineChart: readAutomationLineChart(input.lineChart) },
|
|
8110
8147
|
...input.footnote ? { footnote: requiredText(input.footnote, "footnote", 240) } : {},
|
|
8111
8148
|
...input.kind === void 0 ? {} : { kind: input.kind },
|
|
8112
8149
|
meta: Object.freeze(meta),
|
|
@@ -8142,6 +8179,7 @@ function readAutomationPresentation(value) {
|
|
|
8142
8179
|
};
|
|
8143
8180
|
});
|
|
8144
8181
|
return createAutomationPresentation({
|
|
8182
|
+
...record.lineChart === void 0 ? {} : { lineChart: readAutomationLineChart(record.lineChart) },
|
|
8145
8183
|
...record.footnote === void 0 ? {} : { footnote: stringValue(record.footnote, "Automation presentation footnote") },
|
|
8146
8184
|
meta,
|
|
8147
8185
|
...record.kind === void 0 ? {} : { kind: automationPresentationKind(record.kind) },
|
|
@@ -14573,6 +14611,39 @@ function createRoutedHumanInteractionToolApprovalService(registry) {
|
|
|
14573
14611
|
} };
|
|
14574
14612
|
}
|
|
14575
14613
|
//#endregion
|
|
14614
|
+
//#region src/adapters/feishu/automation/automation-line-chart-renderer.ts
|
|
14615
|
+
function renderAutomationLineCharts(chart) {
|
|
14616
|
+
const separate = chart.seriesLayout === "separate";
|
|
14617
|
+
return (separate ? chart.series.map((series) => [series]) : [chart.series]).map((series) => ({
|
|
14618
|
+
tag: "chart",
|
|
14619
|
+
aspect_ratio: "4:3",
|
|
14620
|
+
color_theme: "complementary",
|
|
14621
|
+
chart_spec: {
|
|
14622
|
+
type: "line",
|
|
14623
|
+
title: {
|
|
14624
|
+
text: separate ? series[0].name : chart.title,
|
|
14625
|
+
subtext: separate ? `${chart.title} · ${chart.unit}` : chart.unit
|
|
14626
|
+
},
|
|
14627
|
+
data: { values: series.flatMap((row) => chart.labels.map((label, index) => ({
|
|
14628
|
+
date: label,
|
|
14629
|
+
value: row.values[index],
|
|
14630
|
+
series: row.name
|
|
14631
|
+
}))) },
|
|
14632
|
+
xField: "date",
|
|
14633
|
+
yField: "value",
|
|
14634
|
+
seriesField: "series",
|
|
14635
|
+
legends: {
|
|
14636
|
+
visible: !separate,
|
|
14637
|
+
orient: "bottom"
|
|
14638
|
+
},
|
|
14639
|
+
axes: [{
|
|
14640
|
+
orient: "left",
|
|
14641
|
+
zero: false
|
|
14642
|
+
}]
|
|
14643
|
+
}
|
|
14644
|
+
}));
|
|
14645
|
+
}
|
|
14646
|
+
//#endregion
|
|
14576
14647
|
//#region src/adapters/feishu/automation/automation-card-sender.ts
|
|
14577
14648
|
function createConfiguredFeishuAutomationCardSender(options) {
|
|
14578
14649
|
const baseUrl = options.config.feishu.baseUrl.replace(/\/$/, "");
|
|
@@ -14620,6 +14691,7 @@ function createStructuredAutomationCard(presentation) {
|
|
|
14620
14691
|
text_size: "normal"
|
|
14621
14692
|
});
|
|
14622
14693
|
}
|
|
14694
|
+
if (presentation.lineChart) elements.push(...renderAutomationLineCharts(presentation.lineChart));
|
|
14623
14695
|
presentation.sections.forEach((section, index) => {
|
|
14624
14696
|
if (presentation.summary || index > 0) elements.push({ tag: "hr" });
|
|
14625
14697
|
elements.push({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rivus/agent",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.16.0",
|
|
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",
|
|
@@ -93,10 +93,10 @@
|
|
|
93
93
|
"@earendil-works/pi-coding-agent": "0.84.4",
|
|
94
94
|
"@larksuiteoapi/node-sdk": "1.71.1",
|
|
95
95
|
"@opentelemetry/api": "^1.9.1",
|
|
96
|
-
"@opentelemetry/exporter-trace-otlp-proto": "^0.
|
|
97
|
-
"@opentelemetry/resources": "^2.
|
|
98
|
-
"@opentelemetry/sdk-trace-base": "^2.
|
|
99
|
-
"@opentelemetry/sdk-trace-node": "^2.
|
|
96
|
+
"@opentelemetry/exporter-trace-otlp-proto": "^0.222.0",
|
|
97
|
+
"@opentelemetry/resources": "^2.11.0",
|
|
98
|
+
"@opentelemetry/sdk-trace-base": "^2.11.0",
|
|
99
|
+
"@opentelemetry/sdk-trace-node": "^2.11.0",
|
|
100
100
|
"axios": "1.18.0",
|
|
101
101
|
"effect": "^3.21.4",
|
|
102
102
|
"typebox": "^1.1.38"
|
|
@@ -114,7 +114,7 @@
|
|
|
114
114
|
"@changesets/cli": "^2.31.1",
|
|
115
115
|
"@types/node": "24.13.3",
|
|
116
116
|
"@vitest/coverage-v8": "4.1.10",
|
|
117
|
-
"jscpd": "4.
|
|
117
|
+
"jscpd": "4.3.0",
|
|
118
118
|
"typescript": "6.0.3",
|
|
119
119
|
"vite": "npm:@voidzero-dev/vite-plus-core@0.2.4",
|
|
120
120
|
"vite-plus": "0.2.4"
|
|
@@ -29,6 +29,10 @@ rivus model status --request <request-id> --json
|
|
|
29
29
|
|
|
30
30
|
## Set a default model
|
|
31
31
|
|
|
32
|
+
The default is shared by every Agent in the current Home, including their background Sessions. Describe that scope when
|
|
33
|
+
submitting a change. If the user asks to change only one Agent, explain that per-Agent overrides are unsupported and
|
|
34
|
+
resolve the requested scope before submitting a Home-wide change.
|
|
35
|
+
|
|
32
36
|
Use the exact `provider/model` value confirmed by the Host. First obtain the current `revision`, then submit one request
|
|
33
37
|
with a fresh request id:
|
|
34
38
|
|