@rivus/agent 0.15.0 → 0.15.1

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 !== 1) throw new Error("Model management supports exactly one Agent per Home.");
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({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rivus/agent",
3
- "version": "0.15.0",
3
+ "version": "0.15.1",
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",
@@ -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