@rivus/agent 0.7.0 → 0.8.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/README.md +1 -1
- package/dist/acp.d.ts +11 -0
- package/dist/acp.js +14 -1
- package/dist/background-session-authority.js +224 -0
- package/dist/background-session-input.js +45 -0
- package/dist/background-session-service.d.ts +291 -0
- package/dist/index.d.ts +1 -287
- package/dist/index.js +14 -31
- package/dist/mcp.d.ts +86 -0
- package/dist/mcp.js +416 -0
- package/dist/rivus-daemon-cli.js +2 -1
- package/dist/rivus-plugin-registry.js +2 -223
- package/package.json +5 -1
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { $ as createAgentTranscriptTurn, A as createAgentLoopModelExecutionStart
|
|
|
2
2
|
import { a as MemoryBinding, c as MemoryScope, d as RIVUS_MEMORY_TOOL_PLUGIN_ID, f as RIVUS_MEMORY_TOOL_VERSION, h as restrictMemoryScopesForAudience, i as MEMORY_SCOPES, l as MemoryState, m as createRivusMemoryToolContract, n as AgentMemoryIdentity, o as MemoryInvocationAudience, p as createMemoryNamespace, r as AgentMemorySnapshot, s as MemoryRecord, t as AgentMemoryAuthority, u as RIVUS_MEMORY_TOOL_ID } from "./agent-memory.js";
|
|
3
3
|
import { A as createRecoveryAction, C as ToolOperationReconciliation, D as createToolOperationLedger, E as ToolOperationState, O as InvalidRecoveryAction, S as ToolOperationLedger, T as ToolOperationRecord, _ as InvocationAuthorityRef, b as ToolOperationBinding, c as ToolApprovalRequest, d as ToolBrokerOptions, f as ToolExecutionRequest, g as InvocationAuthority, h as InvalidInvocationAuthority, k as RecoveryAction, l as ToolApprovalService, m as createToolBroker, o as AuthorizationPolicyProvider, p as ToolInvocationDenied, s as AuthorizationPolicyState, t as PiToolApprovalGateway, u as ToolBroker, v as createInvocationAuthority, w as ToolOperationReconciliationOutcome, x as ToolOperationInspectResult, y as ToolOperationBeginResult } from "./pi-tool-proxy.js";
|
|
4
4
|
import { A as RivusToolRisk, C as RivusToolDescriptor, D as RivusToolGrantSet, E as RivusToolFactoryContext, O as RivusToolIdempotency, S as RivusSkillGrantSet, T as RivusToolExecutor, _ as RivusPluginCatalogSnapshot, a as RegisteredRivusPlugin, b as RivusResolvedToolDescriptor, c as ResolvedRivusAgentDefinition, d as RivusAutomationInput, f as RivusAutomationTemplate, g as RivusPluginCatalog, h as RivusPlugin, i as RegisteredRivusAutomation, j as requiresToolApproval, k as RivusToolInputRejected, l as RivusAgentDeployment, m as RivusHostToolDescriptor, n as RIVUS_PLUGIN_API_VERSION, o as RegisteredRivusSkill, p as RivusAutomationTickContext, r as RegisteredRivusAgentProfile, s as RegisteredRivusTool, t as InvalidRivusPlugin, u as RivusAgentProfile, v as RivusPluginManifest, w as RivusToolExecutionContext, x as RivusSkillDescriptor, y as RivusPluginRegistry } from "./rivus-plugin.js";
|
|
5
|
+
import { $ as suspendBackgroundSession, A as BackgroundSessionCancellation, B as completeBackgroundSessionStep, C as BackgroundSessionDeliveryStore, D as BackgroundSessionRepositoryCorrupted, E as BackgroundSessionRepositoryConflict, F as BackgroundSessionState, G as isBackgroundSessionLeaseExpired, H as createBackgroundSession, I as BackgroundSessionTerminalResult, J as releaseBackgroundSessionLease, K as isBackgroundSessionTerminalPhase, L as BackgroundSessionTransitionDenied, M as BackgroundSessionLease, N as BackgroundSessionOrigin, O as createBackgroundSessionRepository, P as BackgroundSessionPhase, Q as resolveBackgroundSessionReconciliation, R as appendBackgroundSessionInput, S as BackgroundSessionDeliveryRecord, T as BackgroundSessionRepository, U as failBackgroundSessionStep, V as completeBackgroundSessionStop, W as isBackgroundSessionDue, X as requestBackgroundSessionStop, Y as renewBackgroundSessionLease, Z as requeueInterruptedBackgroundSessionStep, _ as createBackgroundSessionToolContracts, a as createBackgroundSessionService, b as narrowBackgroundSessionDefinition, c as terminalDeliveryId, d as BACKGROUND_SESSION_TOOL_IDS, f as BACKGROUND_SESSION_TOOL_PLUGIN_ID, g as createBackgroundSessionStepSourceMessageId, h as createBackgroundSessionKey, i as BackgroundSessionSummary, j as BackgroundSessionId, k as BackgroundSessionAuthority, l as BACKGROUND_SESSION_SESSION_KEY_PREFIX, m as backgroundSessionToolIds, n as BackgroundSessionDetail, o as progressDeliveryId, p as BACKGROUND_SESSION_TOOL_VERSION, q as parkBackgroundSessionForReconciliation, r as BackgroundSessionService, s as sessionIdFromSessionKey, t as BackgroundSessionCallerDenied, u as BACKGROUND_SESSION_START_TOOL_ID, v as extendBackgroundSessionDefinition, w as createBackgroundSessionDeliveryStore, x as BackgroundSessionDeliveryConflict, y as isBackgroundSessionToolId, z as claimBackgroundSession } from "./background-session-service.js";
|
|
5
6
|
import { a as assertRivusPluginConforms, i as RivusPluginLifecycleProbe, n as RivusPluginConformanceInput, o as createFakeRivusPlugin, r as RivusPluginConformanceReport, t as RivusPluginConformanceError } from "./rivus-plugin-testkit.js";
|
|
6
7
|
import { Effect, Stream } from "effect";
|
|
7
8
|
import { Tracer } from "@opentelemetry/api";
|
|
@@ -1780,206 +1781,6 @@ interface ScheduledAutomation {
|
|
|
1780
1781
|
}
|
|
1781
1782
|
declare function createScheduledAutomation(options: ScheduledAutomationOptions): ScheduledAutomation;
|
|
1782
1783
|
//#endregion
|
|
1783
|
-
//#region src/domain/background-agent-session.d.ts
|
|
1784
|
-
type BackgroundSessionId = string;
|
|
1785
|
-
type BackgroundSessionPhase = "queued" | "running" | "waiting" | "input-required" | "stopping" | "stopped" | "completed" | "failed" | "reconciliation-required";
|
|
1786
|
-
declare function isBackgroundSessionTerminalPhase(phase: BackgroundSessionPhase): boolean;
|
|
1787
|
-
interface BackgroundSessionLease {
|
|
1788
|
-
readonly owner: string;
|
|
1789
|
-
readonly epoch: number;
|
|
1790
|
-
readonly expiresAt: string;
|
|
1791
|
-
}
|
|
1792
|
-
interface BackgroundSessionOrigin {
|
|
1793
|
-
readonly endpointId: string;
|
|
1794
|
-
readonly tenantKey: string;
|
|
1795
|
-
readonly conversationId?: string;
|
|
1796
|
-
readonly allowedActorOpenIds: ReadonlyArray<string>;
|
|
1797
|
-
readonly memory?: AgentMemoryIdentity;
|
|
1798
|
-
}
|
|
1799
|
-
interface BackgroundSessionAuthority {
|
|
1800
|
-
readonly agentId: string;
|
|
1801
|
-
readonly profileRevision: string;
|
|
1802
|
-
readonly toolGrantRevision: string;
|
|
1803
|
-
readonly policyEpoch: number;
|
|
1804
|
-
readonly memoryScopes: ReadonlyArray<MemoryScope>;
|
|
1805
|
-
readonly projectSpaceId?: string;
|
|
1806
|
-
readonly sessionKey: string;
|
|
1807
|
-
}
|
|
1808
|
-
interface BackgroundSessionTerminalResult {
|
|
1809
|
-
readonly text: string;
|
|
1810
|
-
readonly stepRunId: string;
|
|
1811
|
-
readonly completedAt: string;
|
|
1812
|
-
}
|
|
1813
|
-
interface BackgroundSessionCancellation {
|
|
1814
|
-
readonly reason: string;
|
|
1815
|
-
readonly requestedAt: string;
|
|
1816
|
-
}
|
|
1817
|
-
interface BackgroundSessionState {
|
|
1818
|
-
readonly sessionId: BackgroundSessionId;
|
|
1819
|
-
readonly displayName: string;
|
|
1820
|
-
readonly phase: BackgroundSessionPhase;
|
|
1821
|
-
readonly revision: number;
|
|
1822
|
-
readonly parentRunId: string;
|
|
1823
|
-
readonly sourceMessageId: string;
|
|
1824
|
-
readonly origin: BackgroundSessionOrigin;
|
|
1825
|
-
readonly authority: BackgroundSessionAuthority;
|
|
1826
|
-
readonly prompt: string;
|
|
1827
|
-
readonly stepCount: number;
|
|
1828
|
-
readonly wakeCount: number;
|
|
1829
|
-
readonly currentStepRunId?: string;
|
|
1830
|
-
readonly lastWakeText?: string;
|
|
1831
|
-
readonly pendingInput: ReadonlyArray<string>;
|
|
1832
|
-
readonly wakeAt?: string;
|
|
1833
|
-
readonly lease?: BackgroundSessionLease;
|
|
1834
|
-
readonly cancellation?: BackgroundSessionCancellation;
|
|
1835
|
-
readonly consecutiveFailures: number;
|
|
1836
|
-
readonly result?: BackgroundSessionTerminalResult;
|
|
1837
|
-
readonly errorMessage?: string;
|
|
1838
|
-
readonly reconciliationNote?: string;
|
|
1839
|
-
readonly createdAt: string;
|
|
1840
|
-
readonly updatedAt: string;
|
|
1841
|
-
}
|
|
1842
|
-
declare class BackgroundSessionTransitionDenied extends Error {
|
|
1843
|
-
readonly sessionId: BackgroundSessionId;
|
|
1844
|
-
readonly name = "BackgroundSessionTransitionDenied";
|
|
1845
|
-
constructor(sessionId: BackgroundSessionId, message: string);
|
|
1846
|
-
}
|
|
1847
|
-
interface CreateBackgroundSessionInput {
|
|
1848
|
-
readonly sessionId: BackgroundSessionId;
|
|
1849
|
-
readonly displayName: string;
|
|
1850
|
-
readonly prompt: string;
|
|
1851
|
-
readonly parentRunId: string;
|
|
1852
|
-
readonly sourceMessageId: string;
|
|
1853
|
-
readonly origin: BackgroundSessionOrigin;
|
|
1854
|
-
readonly authority: BackgroundSessionAuthority;
|
|
1855
|
-
readonly now: string;
|
|
1856
|
-
}
|
|
1857
|
-
declare function createBackgroundSession(input: CreateBackgroundSessionInput): BackgroundSessionState;
|
|
1858
|
-
interface ClaimBackgroundSessionInput {
|
|
1859
|
-
readonly lease: BackgroundSessionLease;
|
|
1860
|
-
readonly stepRunId: string;
|
|
1861
|
-
readonly wakeText: string;
|
|
1862
|
-
readonly now: string;
|
|
1863
|
-
}
|
|
1864
|
-
declare function claimBackgroundSession(state: BackgroundSessionState, input: ClaimBackgroundSessionInput): BackgroundSessionState;
|
|
1865
|
-
declare function renewBackgroundSessionLease(state: BackgroundSessionState, lease: BackgroundSessionLease): BackgroundSessionState;
|
|
1866
|
-
declare function releaseBackgroundSessionLease(state: BackgroundSessionState): BackgroundSessionState;
|
|
1867
|
-
interface SuspendBackgroundSessionInput {
|
|
1868
|
-
readonly wakeAt?: string;
|
|
1869
|
-
readonly reason?: string;
|
|
1870
|
-
readonly now: string;
|
|
1871
|
-
}
|
|
1872
|
-
declare function suspendBackgroundSession(state: BackgroundSessionState, input: SuspendBackgroundSessionInput): BackgroundSessionState;
|
|
1873
|
-
declare function completeBackgroundSessionStep(state: BackgroundSessionState, input: {
|
|
1874
|
-
readonly text: string;
|
|
1875
|
-
readonly stepRunId: string;
|
|
1876
|
-
readonly now: string;
|
|
1877
|
-
}): BackgroundSessionState;
|
|
1878
|
-
declare function failBackgroundSessionStep(state: BackgroundSessionState, input: {
|
|
1879
|
-
readonly errorMessage: string;
|
|
1880
|
-
readonly now: string;
|
|
1881
|
-
readonly retryable: boolean;
|
|
1882
|
-
readonly wakeAt?: string;
|
|
1883
|
-
}): BackgroundSessionState;
|
|
1884
|
-
declare function requestBackgroundSessionStop(state: BackgroundSessionState, input: {
|
|
1885
|
-
readonly reason: string;
|
|
1886
|
-
readonly now: string;
|
|
1887
|
-
}): BackgroundSessionState;
|
|
1888
|
-
declare function completeBackgroundSessionStop(state: BackgroundSessionState, input: {
|
|
1889
|
-
readonly now: string;
|
|
1890
|
-
}): BackgroundSessionState;
|
|
1891
|
-
declare function parkBackgroundSessionForReconciliation(state: BackgroundSessionState, input: {
|
|
1892
|
-
readonly reason: string;
|
|
1893
|
-
readonly now: string;
|
|
1894
|
-
}): BackgroundSessionState;
|
|
1895
|
-
declare function resolveBackgroundSessionReconciliation(state: BackgroundSessionState, input: {
|
|
1896
|
-
readonly outcome: "continue" | "stop";
|
|
1897
|
-
readonly now: string;
|
|
1898
|
-
}): BackgroundSessionState;
|
|
1899
|
-
declare function appendBackgroundSessionInput(state: BackgroundSessionState, input: {
|
|
1900
|
-
readonly message: string;
|
|
1901
|
-
readonly now: string;
|
|
1902
|
-
}): BackgroundSessionState;
|
|
1903
|
-
declare function requeueInterruptedBackgroundSessionStep(state: BackgroundSessionState, input: {
|
|
1904
|
-
readonly wakeText: string;
|
|
1905
|
-
readonly now: string;
|
|
1906
|
-
}): BackgroundSessionState;
|
|
1907
|
-
declare function isBackgroundSessionLeaseExpired(state: BackgroundSessionState, now: string): boolean;
|
|
1908
|
-
declare function isBackgroundSessionDue(state: BackgroundSessionState, now: string): boolean;
|
|
1909
|
-
//#endregion
|
|
1910
|
-
//#region src/application/background-session/background-session-repository.d.ts
|
|
1911
|
-
interface BackgroundSessionLeasePrecondition {
|
|
1912
|
-
readonly kind: "absent";
|
|
1913
|
-
}
|
|
1914
|
-
interface BackgroundSessionLeaseRequirement {
|
|
1915
|
-
readonly kind: "held";
|
|
1916
|
-
readonly owner: string;
|
|
1917
|
-
readonly epoch: number;
|
|
1918
|
-
}
|
|
1919
|
-
interface BackgroundSessionLeaseStaleOrAbsent {
|
|
1920
|
-
readonly kind: "absent-or-stale";
|
|
1921
|
-
}
|
|
1922
|
-
interface BackgroundSessionRepository {
|
|
1923
|
-
create(state: BackgroundSessionState): Promise<BackgroundSessionState>;
|
|
1924
|
-
get(sessionId: string): Promise<BackgroundSessionState | undefined>;
|
|
1925
|
-
list(options?: {
|
|
1926
|
-
readonly phase?: BackgroundSessionPhase;
|
|
1927
|
-
readonly limit?: number;
|
|
1928
|
-
}): Promise<ReadonlyArray<BackgroundSessionState>>;
|
|
1929
|
-
update(input: {
|
|
1930
|
-
readonly sessionId: string;
|
|
1931
|
-
readonly expectedRevision: number;
|
|
1932
|
-
readonly expectedLease?: BackgroundSessionLeasePrecondition | BackgroundSessionLeaseRequirement | BackgroundSessionLeaseStaleOrAbsent;
|
|
1933
|
-
readonly now?: string;
|
|
1934
|
-
readonly build: (state: BackgroundSessionState) => BackgroundSessionState;
|
|
1935
|
-
}): Promise<BackgroundSessionState | undefined>;
|
|
1936
|
-
}
|
|
1937
|
-
declare class BackgroundSessionRepositoryConflict extends Error {
|
|
1938
|
-
readonly name = "BackgroundSessionRepositoryConflict";
|
|
1939
|
-
constructor(sessionId: string, message: string);
|
|
1940
|
-
}
|
|
1941
|
-
declare class BackgroundSessionRepositoryCorrupted extends Error {
|
|
1942
|
-
readonly name = "BackgroundSessionRepositoryCorrupted";
|
|
1943
|
-
}
|
|
1944
|
-
interface CreateBackgroundSessionRepositoryOptions {
|
|
1945
|
-
readonly initial?: ReadonlyArray<BackgroundSessionState>;
|
|
1946
|
-
readonly persist?: (state: BackgroundSessionState) => Promise<void>;
|
|
1947
|
-
}
|
|
1948
|
-
declare function createBackgroundSessionRepository(options?: CreateBackgroundSessionRepositoryOptions): BackgroundSessionRepository;
|
|
1949
|
-
//#endregion
|
|
1950
|
-
//#region src/application/background-session/background-session-delivery-store.d.ts
|
|
1951
|
-
type BackgroundSessionDeliveryKind = "progress" | "final" | "stopped" | "failed" | "reconciliation";
|
|
1952
|
-
interface BackgroundSessionDeliveryRecord {
|
|
1953
|
-
readonly deliveryId: string;
|
|
1954
|
-
readonly sessionId: string;
|
|
1955
|
-
readonly kind: BackgroundSessionDeliveryKind;
|
|
1956
|
-
readonly text: string;
|
|
1957
|
-
readonly state: "pending" | "delivered";
|
|
1958
|
-
readonly revision: number;
|
|
1959
|
-
readonly providerMessageId?: string;
|
|
1960
|
-
readonly createdAt: string;
|
|
1961
|
-
}
|
|
1962
|
-
interface BackgroundSessionDeliveryStore {
|
|
1963
|
-
enqueue(input: {
|
|
1964
|
-
readonly deliveryId: string;
|
|
1965
|
-
readonly sessionId: string;
|
|
1966
|
-
readonly kind: BackgroundSessionDeliveryKind;
|
|
1967
|
-
readonly text: string;
|
|
1968
|
-
readonly createdAt: string;
|
|
1969
|
-
}): Promise<BackgroundSessionDeliveryRecord>;
|
|
1970
|
-
pending(): Promise<ReadonlyArray<BackgroundSessionDeliveryRecord>>;
|
|
1971
|
-
markDelivered(deliveryId: string, providerMessageId: string): Promise<BackgroundSessionDeliveryRecord | undefined>;
|
|
1972
|
-
}
|
|
1973
|
-
declare class BackgroundSessionDeliveryConflict extends Error {
|
|
1974
|
-
readonly name = "BackgroundSessionDeliveryConflict";
|
|
1975
|
-
constructor(deliveryId: string, message: string);
|
|
1976
|
-
}
|
|
1977
|
-
interface CreateBackgroundSessionDeliveryStoreOptions {
|
|
1978
|
-
readonly initial?: ReadonlyArray<BackgroundSessionDeliveryRecord>;
|
|
1979
|
-
readonly persist?: (record: BackgroundSessionDeliveryRecord) => Promise<void>;
|
|
1980
|
-
}
|
|
1981
|
-
declare function createBackgroundSessionDeliveryStore(options?: CreateBackgroundSessionDeliveryStoreOptions): BackgroundSessionDeliveryStore;
|
|
1982
|
-
//#endregion
|
|
1983
1784
|
//#region src/application/background-session/background-session-supervisor.d.ts
|
|
1984
1785
|
interface BackgroundSessionLimits {
|
|
1985
1786
|
readonly intervalMs: number;
|
|
@@ -3050,93 +2851,6 @@ declare class AgentMemoryError extends Error {
|
|
|
3050
2851
|
}
|
|
3051
2852
|
declare function createAgentMemoryService(options?: AgentMemoryServiceOptions): AgentMemoryService;
|
|
3052
2853
|
//#endregion
|
|
3053
|
-
//#region src/application/background-session/background-session-authority.d.ts
|
|
3054
|
-
declare const BACKGROUND_SESSION_TOOL_IDS: readonly ["background.start", "background.wait", "background.list", "background.status", "background.send", "background.stop"];
|
|
3055
|
-
declare const BACKGROUND_SESSION_START_TOOL_ID = "background.start";
|
|
3056
|
-
declare const BACKGROUND_SESSION_TOOL_PLUGIN_ID = "rivus-core";
|
|
3057
|
-
declare const BACKGROUND_SESSION_TOOL_VERSION = "1.0.0";
|
|
3058
|
-
declare const BACKGROUND_SESSION_SESSION_KEY_PREFIX = "background";
|
|
3059
|
-
declare function createBackgroundSessionKey(sessionId: string): string;
|
|
3060
|
-
declare function createBackgroundSessionStepSourceMessageId(sessionId: string, stepCount: number): string;
|
|
3061
|
-
interface BackgroundSessionToolContract extends RivusResolvedToolDescriptor {}
|
|
3062
|
-
declare function createBackgroundSessionToolContracts(): ReadonlyArray<BackgroundSessionToolContract>;
|
|
3063
|
-
declare function backgroundSessionToolIds(): ReadonlyArray<string>;
|
|
3064
|
-
declare function isBackgroundSessionToolId(toolId: string): boolean;
|
|
3065
|
-
declare function extendBackgroundSessionDefinition(definition: ResolvedRivusAgentDefinition): ResolvedRivusAgentDefinition;
|
|
3066
|
-
declare function narrowBackgroundSessionDefinition(definition: ResolvedRivusAgentDefinition): ResolvedRivusAgentDefinition;
|
|
3067
|
-
//#endregion
|
|
3068
|
-
//#region src/application/background-session/background-session-service.d.ts
|
|
3069
|
-
interface BackgroundSessionSummary {
|
|
3070
|
-
readonly sessionId: string;
|
|
3071
|
-
readonly displayName: string;
|
|
3072
|
-
readonly phase: BackgroundSessionPhase;
|
|
3073
|
-
readonly stepCount: number;
|
|
3074
|
-
readonly wakeAt?: string;
|
|
3075
|
-
readonly createdAt: string;
|
|
3076
|
-
readonly updatedAt: string;
|
|
3077
|
-
}
|
|
3078
|
-
interface BackgroundSessionDetail extends BackgroundSessionSummary {
|
|
3079
|
-
readonly parentRunId: string;
|
|
3080
|
-
readonly pendingInput: ReadonlyArray<string>;
|
|
3081
|
-
readonly result?: BackgroundSessionState["result"];
|
|
3082
|
-
readonly errorMessage?: string;
|
|
3083
|
-
readonly cancellationReason?: string;
|
|
3084
|
-
readonly reconciliationNote?: string;
|
|
3085
|
-
}
|
|
3086
|
-
declare class BackgroundSessionCallerDenied extends Error {
|
|
3087
|
-
readonly name = "BackgroundSessionCallerDenied";
|
|
3088
|
-
constructor(message: string);
|
|
3089
|
-
}
|
|
3090
|
-
interface BackgroundSessionServiceOptions {
|
|
3091
|
-
readonly clock: {
|
|
3092
|
-
now(): string;
|
|
3093
|
-
};
|
|
3094
|
-
readonly deliveries: BackgroundSessionDeliveryStore;
|
|
3095
|
-
readonly repository: BackgroundSessionRepository;
|
|
3096
|
-
}
|
|
3097
|
-
interface BackgroundSessionService {
|
|
3098
|
-
list(input: {
|
|
3099
|
-
readonly context: RivusToolExecutionContext;
|
|
3100
|
-
readonly limit?: number;
|
|
3101
|
-
readonly phase?: BackgroundSessionPhase;
|
|
3102
|
-
}): Promise<ReadonlyArray<BackgroundSessionSummary>>;
|
|
3103
|
-
resolveReconciliation(input: {
|
|
3104
|
-
readonly outcome: "continue" | "stop";
|
|
3105
|
-
readonly sessionId: string;
|
|
3106
|
-
}): Promise<BackgroundSessionSummary>;
|
|
3107
|
-
send(input: {
|
|
3108
|
-
readonly context: RivusToolExecutionContext;
|
|
3109
|
-
readonly message: string;
|
|
3110
|
-
readonly sessionId: string;
|
|
3111
|
-
}): Promise<BackgroundSessionSummary>;
|
|
3112
|
-
start(input: {
|
|
3113
|
-
readonly authority: BackgroundSessionAuthority;
|
|
3114
|
-
readonly context: RivusToolExecutionContext;
|
|
3115
|
-
readonly displayName?: string;
|
|
3116
|
-
readonly prompt: string;
|
|
3117
|
-
readonly sessionId: string;
|
|
3118
|
-
}): Promise<BackgroundSessionSummary>;
|
|
3119
|
-
status(input: {
|
|
3120
|
-
readonly context: RivusToolExecutionContext;
|
|
3121
|
-
readonly sessionId: string;
|
|
3122
|
-
}): Promise<BackgroundSessionDetail>;
|
|
3123
|
-
stop(input: {
|
|
3124
|
-
readonly context: RivusToolExecutionContext;
|
|
3125
|
-
readonly reason?: string;
|
|
3126
|
-
readonly sessionId: string;
|
|
3127
|
-
}): Promise<BackgroundSessionSummary>;
|
|
3128
|
-
wait(input: {
|
|
3129
|
-
readonly context: RivusToolExecutionContext;
|
|
3130
|
-
readonly delayMs?: number;
|
|
3131
|
-
readonly reason?: string;
|
|
3132
|
-
readonly until?: string;
|
|
3133
|
-
}): Promise<BackgroundSessionSummary>;
|
|
3134
|
-
}
|
|
3135
|
-
declare function createBackgroundSessionService(options: BackgroundSessionServiceOptions): BackgroundSessionService;
|
|
3136
|
-
declare function sessionIdFromSessionKey(sessionKey: string): string | undefined;
|
|
3137
|
-
declare function terminalDeliveryId(sessionId: string, kind: BackgroundSessionDeliveryKind): string;
|
|
3138
|
-
declare function progressDeliveryId(sessionId: string, stepCount: number): string;
|
|
3139
|
-
//#endregion
|
|
3140
2854
|
//#region src/application/background-session/background-session-tools.d.ts
|
|
3141
2855
|
interface CreateBackgroundSessionHostToolsOptions {
|
|
3142
2856
|
readonly createSessionId: () => string;
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
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 createMemoryNamespace, c as InvalidRivusPlugin, d as requiresToolApproval, i as RIVUS_MEMORY_TOOL_VERSION, l as RIVUS_PLUGIN_API_VERSION, n as RIVUS_MEMORY_TOOL_ID, o as createRivusMemoryToolContract, r as RIVUS_MEMORY_TOOL_PLUGIN_ID, s as restrictMemoryScopesForAudience, t as MEMORY_SCOPES, u as RivusToolInputRejected } from "./agent-memory.js";
|
|
3
|
-
import { a as
|
|
3
|
+
import { a as BACKGROUND_SESSION_TOOL_VERSION, c as createBackgroundSessionStepSourceMessageId, d as isBackgroundSessionToolId, f as narrowBackgroundSessionDefinition, i as BACKGROUND_SESSION_TOOL_PLUGIN_ID, l as createBackgroundSessionToolContracts, n as BACKGROUND_SESSION_START_TOOL_ID, o as backgroundSessionToolIds, r as BACKGROUND_SESSION_TOOL_IDS, s as createBackgroundSessionKey, t as BACKGROUND_SESSION_SESSION_KEY_PREFIX, u as extendBackgroundSessionDefinition } from "./background-session-authority.js";
|
|
4
|
+
import { n as resolveRivusAgentDefinition, t as createRivusPluginCatalog } from "./rivus-plugin-registry.js";
|
|
4
5
|
import { $ as loadRivusDeployment, A as DEFAULT_BACKGROUND_SESSION_LIFETIME_MS, B as acceptsCardPresentationProgress, C as loadRivusDaemonConfig, D as loadRivusDeploymentManifest, E as RivusDeploymentManifestError, F as DEFAULT_BACKGROUND_SESSION_SUPERVISOR_INTERVAL_MS, G as createCardPresentationChain, H as beginCardPresentationHandoff, I as resolveBackgroundSessionSupervisorIntervalMs, J as markCardPresentationTerminal, K as failCardPresentationHandoff, L as DEFAULT_CARD_STREAM_LEASE_MS, M as DEFAULT_BACKGROUND_SESSION_MAX_CONSECUTIVE_FAILURES, N as DEFAULT_BACKGROUND_SESSION_RETRY_BACKOFF_MS, O as DEFAULT_BACKGROUND_SESSION_LEASE_MS, P as DEFAULT_BACKGROUND_SESSION_STEP_TIMEOUT_MS, Q as RivusPluginLoadError, R as createFeishuCardRollover, S as RivusDaemonConfigError, U as compensateCardPresentationHandoff, V as activeCardPresentation, W as completeCardPresentationHandoff, X as resolveFeishuEndpointCredentials, Y as FeishuEndpointCredentialError, _ as createStableId, a as InvalidRivusProjectSpace, b as createRivusEnvFromOpenClawConfig, c as RivusDeploymentReadinessError, d as createRivusAgentHost, et as validateRivusDeploymentManifest, f as AgentInstanceBusy, g as createAgentInstanceRegistry, h as AgentInstanceConflict, i as resolveRivusProjectSpace, j as DEFAULT_BACKGROUND_SESSION_MAX_CONCURRENT_SESSIONS, k as DEFAULT_BACKGROUND_SESSION_LEASE_RENEWAL_INTERVAL_MS, l as createRivusDeploymentDaemon, m as createAgentRuntimePool, n as createRivusDeploymentCliProcess, o as RivusDeploymentAutomationReadinessError, p as AgentRuntimeDisposed, q as isCardPresentationHandoffDue, 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 CardPresentationTransitionDenied } from "./rivus-daemon-cli.js";
|
|
5
6
|
import { a as InvalidInvocationAuthority, i as normalizeStableJson, n as InvalidToolInput, o as createInvocationAuthority, r as createToolInputDigest, s as resolveInvocationAuthority, t as InvalidStableJson } from "./tool-input-digest.js";
|
|
7
|
+
import { a as readBackgroundSessionWaitInput, i as readBackgroundSessionString, n as readBackgroundSessionObject, r as readBackgroundSessionPhase, t as readBackgroundSessionInteger } from "./background-session-input.js";
|
|
6
8
|
import { n as assertRivusPluginConforms, r as createFakeRivusPlugin, t as RivusPluginConformanceError } from "./rivus-plugin-testkit.js";
|
|
7
9
|
import { Cause, Deferred, Effect, Either, Exit, Fiber, Option, Stream } from "effect";
|
|
8
10
|
import { createHash, randomUUID } from "node:crypto";
|
|
@@ -6955,16 +6957,12 @@ function createExecutor(contract, options) {
|
|
|
6955
6957
|
});
|
|
6956
6958
|
};
|
|
6957
6959
|
case "background.wait": return (input, context) => {
|
|
6958
|
-
const { delayMs, reason, until } =
|
|
6959
|
-
"delayMs",
|
|
6960
|
-
"reason",
|
|
6961
|
-
"until"
|
|
6962
|
-
]);
|
|
6960
|
+
const { delayMs, reason, until } = readWaitInput(input);
|
|
6963
6961
|
return options.service.wait({
|
|
6964
6962
|
context,
|
|
6965
|
-
...delayMs === void 0 ? {} : { delayMs
|
|
6966
|
-
...reason === void 0 ? {} : { reason
|
|
6967
|
-
...until === void 0 ? {} : { until
|
|
6963
|
+
...delayMs === void 0 ? {} : { delayMs },
|
|
6964
|
+
...reason === void 0 ? {} : { reason },
|
|
6965
|
+
...until === void 0 ? {} : { until }
|
|
6968
6966
|
});
|
|
6969
6967
|
};
|
|
6970
6968
|
case "background.list": return async (input, context) => {
|
|
@@ -7048,39 +7046,24 @@ function buildAuthority(definition, context, sessionId) {
|
|
|
7048
7046
|
});
|
|
7049
7047
|
}
|
|
7050
7048
|
function readObject(input, allowed) {
|
|
7051
|
-
|
|
7052
|
-
const record = input;
|
|
7053
|
-
const unknown = Object.keys(record).find((key) => !allowed.includes(key));
|
|
7054
|
-
if (unknown) throw new BackgroundSessionCallerDenied(`field is not allowed: ${unknown}`);
|
|
7055
|
-
return record;
|
|
7049
|
+
return readBackgroundSessionObject(input, allowed, (message) => new BackgroundSessionCallerDenied(message));
|
|
7056
7050
|
}
|
|
7057
7051
|
function readString(value, name) {
|
|
7058
|
-
|
|
7059
|
-
return value;
|
|
7052
|
+
return readBackgroundSessionString(value, name, (message) => new BackgroundSessionCallerDenied(message));
|
|
7060
7053
|
}
|
|
7061
7054
|
function readInteger(value, name) {
|
|
7062
|
-
|
|
7063
|
-
return value;
|
|
7055
|
+
return readBackgroundSessionInteger(value, name, (message) => new BackgroundSessionCallerDenied(message));
|
|
7064
7056
|
}
|
|
7065
7057
|
function readPhase(value) {
|
|
7066
|
-
|
|
7067
|
-
"queued",
|
|
7068
|
-
"running",
|
|
7069
|
-
"waiting",
|
|
7070
|
-
"input-required",
|
|
7071
|
-
"stopping",
|
|
7072
|
-
"stopped",
|
|
7073
|
-
"completed",
|
|
7074
|
-
"failed",
|
|
7075
|
-
"reconciliation-required"
|
|
7076
|
-
];
|
|
7077
|
-
if (typeof value !== "string" || !phases.includes(value)) throw new BackgroundSessionCallerDenied(`phase must be one of ${phases.join(", ")}`);
|
|
7078
|
-
return value;
|
|
7058
|
+
return readBackgroundSessionPhase(value, (message) => new BackgroundSessionCallerDenied(message));
|
|
7079
7059
|
}
|
|
7080
7060
|
function readReplayedSessionId(value) {
|
|
7081
7061
|
if (value === null || typeof value !== "object" || Array.isArray(value)) throw new BackgroundSessionCallerDenied("replayed background tool result is invalid");
|
|
7082
7062
|
return readString(value.sessionId, "sessionId");
|
|
7083
7063
|
}
|
|
7064
|
+
function readWaitInput(input) {
|
|
7065
|
+
return readBackgroundSessionWaitInput(input, (message) => new BackgroundSessionCallerDenied(message));
|
|
7066
|
+
}
|
|
7084
7067
|
async function asToolInputRejection$1(operation) {
|
|
7085
7068
|
try {
|
|
7086
7069
|
return await operation();
|
package/dist/mcp.d.ts
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { k as BackgroundSessionAuthority, r as BackgroundSessionService } from "./background-session-service.js";
|
|
2
|
+
import { Readable, Writable } from "node:stream";
|
|
3
|
+
|
|
4
|
+
//#region src/application/background-session/background-session-control.d.ts
|
|
5
|
+
type BackgroundSessionControlCommand = "start" | "wait" | "list" | "status" | "send" | "stop";
|
|
6
|
+
interface BackgroundSessionControlOrigin {
|
|
7
|
+
readonly allowedActorOpenIds: ReadonlyArray<string>;
|
|
8
|
+
readonly conversationId?: string;
|
|
9
|
+
readonly endpointId: string;
|
|
10
|
+
readonly tenantKey: string;
|
|
11
|
+
}
|
|
12
|
+
interface BackgroundSessionControlContext {
|
|
13
|
+
readonly agentId: string;
|
|
14
|
+
readonly authority: BackgroundSessionAuthority;
|
|
15
|
+
readonly origin: BackgroundSessionControlOrigin;
|
|
16
|
+
readonly policyEpoch: number;
|
|
17
|
+
readonly runId: string;
|
|
18
|
+
readonly sessionKey: string;
|
|
19
|
+
readonly sourceMessageId: string;
|
|
20
|
+
}
|
|
21
|
+
interface BackgroundSessionControl {
|
|
22
|
+
handle(command: BackgroundSessionControlCommand, context: BackgroundSessionControlContext, input: unknown): Promise<unknown>;
|
|
23
|
+
}
|
|
24
|
+
declare function createBackgroundSessionControl(options: {
|
|
25
|
+
readonly service: BackgroundSessionService;
|
|
26
|
+
}): BackgroundSessionControl;
|
|
27
|
+
declare class BackgroundSessionControlError extends Error {
|
|
28
|
+
readonly name = "BackgroundSessionControlError";
|
|
29
|
+
}
|
|
30
|
+
declare function toControlContext(input: {
|
|
31
|
+
readonly agentId: string;
|
|
32
|
+
readonly authority: BackgroundSessionAuthority;
|
|
33
|
+
readonly origin: BackgroundSessionControlOrigin;
|
|
34
|
+
readonly policyEpoch: number;
|
|
35
|
+
readonly sessionKey: string;
|
|
36
|
+
readonly sourceMessageId?: string;
|
|
37
|
+
}): BackgroundSessionControlContext;
|
|
38
|
+
//#endregion
|
|
39
|
+
//#region src/infrastructure/mcp/background-session-mcp-server.d.ts
|
|
40
|
+
declare const BACKGROUND_SESSION_MCP_SERVER_NAME = "rivus-background-sessions";
|
|
41
|
+
declare const BACKGROUND_SESSION_MCP_SERVER_VERSION = "1.0.0";
|
|
42
|
+
interface BackgroundSessionMcpServerOptions {
|
|
43
|
+
readonly controlContext: BackgroundSessionControlContext;
|
|
44
|
+
readonly controlUrl: string;
|
|
45
|
+
readonly controlToken: string;
|
|
46
|
+
readonly enabledTools?: ReadonlyArray<BackgroundSessionControlCommand>;
|
|
47
|
+
readonly fetch?: typeof fetch;
|
|
48
|
+
readonly input?: Readable;
|
|
49
|
+
readonly output?: Writable;
|
|
50
|
+
readonly serverName?: string;
|
|
51
|
+
readonly serverVersion?: string;
|
|
52
|
+
}
|
|
53
|
+
interface BackgroundSessionMcpServer {
|
|
54
|
+
run(): Promise<void>;
|
|
55
|
+
}
|
|
56
|
+
declare class BackgroundSessionMcpError extends Error {
|
|
57
|
+
readonly name = "BackgroundSessionMcpError";
|
|
58
|
+
}
|
|
59
|
+
declare function createBackgroundSessionMcpServer(options: BackgroundSessionMcpServerOptions): BackgroundSessionMcpServer;
|
|
60
|
+
interface RunBackgroundSessionMcpServerEnv {
|
|
61
|
+
readonly fetch?: typeof fetch;
|
|
62
|
+
readonly input?: Readable;
|
|
63
|
+
readonly output?: Writable;
|
|
64
|
+
}
|
|
65
|
+
declare function runBackgroundSessionMcpServer(options?: RunBackgroundSessionMcpServerEnv): Promise<void>;
|
|
66
|
+
//#endregion
|
|
67
|
+
//#region src/infrastructure/http/background-session-control-http-server.d.ts
|
|
68
|
+
interface BackgroundSessionControlHttpServerOptions {
|
|
69
|
+
readonly control: BackgroundSessionControl;
|
|
70
|
+
readonly host?: string;
|
|
71
|
+
readonly port: number;
|
|
72
|
+
readonly token: string;
|
|
73
|
+
}
|
|
74
|
+
interface BackgroundSessionControlHttpServer {
|
|
75
|
+
port(): number;
|
|
76
|
+
close(): Promise<void>;
|
|
77
|
+
start(): Promise<void>;
|
|
78
|
+
}
|
|
79
|
+
declare class BackgroundSessionControlHttpError extends Error {
|
|
80
|
+
readonly statusCode: number;
|
|
81
|
+
readonly name = "BackgroundSessionControlHttpError";
|
|
82
|
+
constructor(statusCode: number, message: string);
|
|
83
|
+
}
|
|
84
|
+
declare function createBackgroundSessionControlHttpServer(options: BackgroundSessionControlHttpServerOptions): BackgroundSessionControlHttpServer;
|
|
85
|
+
//#endregion
|
|
86
|
+
export { BACKGROUND_SESSION_MCP_SERVER_NAME, BACKGROUND_SESSION_MCP_SERVER_VERSION, type BackgroundSessionControl, type BackgroundSessionControlCommand, type BackgroundSessionControlContext, BackgroundSessionControlError, BackgroundSessionControlHttpError, type BackgroundSessionControlHttpServer, type BackgroundSessionControlHttpServerOptions, type BackgroundSessionControlOrigin, BackgroundSessionMcpError, type BackgroundSessionMcpServer, type BackgroundSessionMcpServerOptions, createBackgroundSessionControl, createBackgroundSessionControlHttpServer, createBackgroundSessionMcpServer, runBackgroundSessionMcpServer, toControlContext };
|