@rivus/agent 0.14.2 → 0.14.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.
Files changed (37) hide show
  1. package/README.md +1 -1
  2. package/dist/acp.js +1 -2
  3. package/dist/bootstrap/pi-feishu.d.ts +1 -1
  4. package/dist/bootstrap/pi-feishu.js +4 -4
  5. package/dist/chunks/agent-loop.d.ts +55 -300
  6. package/dist/chunks/agent-loop.js +3 -1123
  7. package/dist/chunks/background-session-authority.js +230 -0
  8. package/dist/chunks/background-session-control-input.js +51 -0
  9. package/dist/chunks/background-session-service.d.ts +382 -0
  10. package/dist/chunks/index.d.ts +1201 -538
  11. package/dist/chunks/pi-tool-proxy.d.ts +22 -90
  12. package/dist/chunks/pi.js +5 -2
  13. package/dist/chunks/rivus-agent-definition-resolver.js +508 -0
  14. package/dist/chunks/rivus-daemon-cli.js +2776 -3244
  15. package/dist/chunks/rivus-plugin-testkit.d.ts +175 -2
  16. package/dist/chunks/rivus-plugin-testkit.js +11 -4
  17. package/dist/chunks/rivus-skill.d.ts +95 -0
  18. package/dist/chunks/sha256-digest.js +2 -7
  19. package/dist/chunks/src.js +11941 -7001
  20. package/dist/chunks/tool-input-digest.js +158 -0
  21. package/dist/cli.js +764 -712
  22. package/dist/index.d.ts +6 -7
  23. package/dist/index.js +7 -8
  24. package/dist/mcp.d.ts +48 -9
  25. package/dist/mcp.js +146 -20
  26. package/dist/pi.d.ts +3 -4
  27. package/dist/pi.js +1 -1
  28. package/package.json +5 -5
  29. package/dist/chunks/api.d.ts +0 -70
  30. package/dist/chunks/api.js +0 -471
  31. package/dist/chunks/api2.d.ts +0 -387
  32. package/dist/chunks/api2.js +0 -1331
  33. package/dist/chunks/api3.d.ts +0 -402
  34. package/dist/chunks/module.js +0 -267
  35. package/dist/chunks/pi-skill-tool.js +0 -460
  36. package/dist/chunks/spi.d.ts +0 -1
  37. package/dist/chunks/spi.js +0 -2
@@ -1,5 +1,178 @@
1
- import { J as RivusAgentDeployment, a as RivusPlugin } from "./api2.js";
1
+ import { a as RivusRuntimeToolId, d as RivusResolvedToolDescriptor, f as RivusToolDescriptor, g as RivusToolGrantSet, n as RivusSkillDescriptor, r as RivusSkillGrantSet, s as RegisteredRivusTool, t as RegisteredRivusSkill, u as RivusMemoryScope } from "./rivus-skill.js";
2
2
 
3
+ //#region src/core/application/agent-catalog/contracts/rivus-agent-definition.d.ts
4
+ interface RivusAgentProfile {
5
+ readonly id: string;
6
+ readonly displayName: string;
7
+ readonly systemPrompt: string;
8
+ readonly model: Readonly<Record<string, unknown>>;
9
+ readonly tools: {
10
+ readonly allow: ReadonlyArray<string>;
11
+ };
12
+ readonly skills: {
13
+ readonly allow: ReadonlyArray<string>;
14
+ };
15
+ readonly memory: {
16
+ readonly scopes: ReadonlyArray<RivusMemoryScope>;
17
+ };
18
+ readonly runtimeTools?: {
19
+ readonly allow: ReadonlyArray<RivusRuntimeToolId>;
20
+ };
21
+ }
22
+ interface RegisteredRivusAgentProfile extends RivusAgentProfile {
23
+ readonly pluginId: string;
24
+ }
25
+ interface RivusAgentDeployment {
26
+ readonly agentId: string;
27
+ readonly pluginId: string;
28
+ readonly profileId: string;
29
+ readonly projectSpaceId?: string;
30
+ readonly endpointIds: ReadonlyArray<string>;
31
+ readonly memory?: {
32
+ readonly scopes: ReadonlyArray<RivusMemoryScope>;
33
+ readonly tool: boolean;
34
+ };
35
+ readonly runtimeTools?: {
36
+ readonly allow: ReadonlyArray<RivusRuntimeToolId>;
37
+ };
38
+ readonly skills: {
39
+ readonly allow: ReadonlyArray<string>;
40
+ };
41
+ readonly tools: {
42
+ readonly allow: ReadonlyArray<string>;
43
+ };
44
+ }
45
+ interface ResolvedRivusAgentDefinition {
46
+ readonly agentId: string;
47
+ readonly pluginId: string;
48
+ readonly profileId: string;
49
+ readonly projectSpaceId?: string;
50
+ readonly projectSpaceRevision?: string;
51
+ readonly endpointIds: ReadonlyArray<string>;
52
+ readonly profileRevision: string;
53
+ readonly systemPrompt: string;
54
+ readonly model: Readonly<Record<string, unknown>>;
55
+ readonly memory: {
56
+ readonly scopes: ReadonlyArray<RivusMemoryScope>;
57
+ readonly tool: boolean;
58
+ };
59
+ readonly runtimeToolGrantSet: RivusRuntimeToolGrantSet;
60
+ readonly skillGrantSet: RivusSkillGrantSet;
61
+ readonly skills: ReadonlyArray<RegisteredRivusSkill>;
62
+ readonly tools: ReadonlyArray<RivusResolvedToolDescriptor>;
63
+ readonly toolGrantSet: RivusToolGrantSet;
64
+ }
65
+ interface RivusRuntimeToolGrantSet {
66
+ readonly revision: string;
67
+ readonly toolIds: ReadonlyArray<RivusRuntimeToolId>;
68
+ }
69
+ //#endregion
70
+ //#region src/core/application/agent-catalog/contracts/rivus-plugin.d.ts
71
+ declare const RIVUS_PLUGIN_API_VERSION = "1";
72
+ interface RivusPluginManifest {
73
+ readonly apiVersion: string;
74
+ readonly id: string;
75
+ readonly version: string;
76
+ }
77
+ interface RegisteredRivusPlugin extends RivusPluginManifest {}
78
+ declare class InvalidRivusPlugin extends Error {
79
+ readonly name = "InvalidRivusPlugin";
80
+ }
81
+ //#endregion
82
+ //#region src/core/application/automation/presentation/automation-presentation.d.ts
83
+ declare const AUTOMATION_PRESENTATION_SCHEMA_VERSION: 1;
84
+ type AutomationPresentationKind = "daily-ai" | "generic" | "industry" | "news" | "subscriptions";
85
+ interface AutomationPresentationSource {
86
+ readonly label: string;
87
+ readonly url: string;
88
+ }
89
+ interface AutomationPresentationItem {
90
+ readonly headline: string;
91
+ readonly note?: string;
92
+ readonly sources: ReadonlyArray<AutomationPresentationSource>;
93
+ }
94
+ interface AutomationPresentationSection {
95
+ readonly id: string;
96
+ readonly items: ReadonlyArray<AutomationPresentationItem>;
97
+ readonly title: string;
98
+ }
99
+ interface AutomationPresentation {
100
+ readonly footnote?: string;
101
+ readonly kind?: AutomationPresentationKind;
102
+ readonly meta: ReadonlyArray<string>;
103
+ readonly schemaVersion: typeof AUTOMATION_PRESENTATION_SCHEMA_VERSION;
104
+ readonly sections: ReadonlyArray<AutomationPresentationSection>;
105
+ readonly summary?: string;
106
+ readonly title: string;
107
+ }
108
+ interface AutomationPresentationInput {
109
+ readonly footnote?: string;
110
+ readonly kind?: AutomationPresentationKind;
111
+ readonly meta?: ReadonlyArray<string>;
112
+ readonly sections: ReadonlyArray<{
113
+ readonly id: string;
114
+ readonly items: ReadonlyArray<{
115
+ readonly headline: string;
116
+ readonly note?: string;
117
+ readonly sources?: ReadonlyArray<AutomationPresentationSource>;
118
+ }>;
119
+ readonly title: string;
120
+ }>;
121
+ readonly summary?: string;
122
+ readonly title: string;
123
+ }
124
+ declare class InvalidAutomationPresentation extends Error {
125
+ readonly name = "InvalidAutomationPresentation";
126
+ }
127
+ declare function createAutomationPresentation(input: AutomationPresentationInput): AutomationPresentation;
128
+ declare function readAutomationPresentation(value: unknown): AutomationPresentation;
129
+ //#endregion
130
+ //#region src/core/application/agent-catalog/contracts/rivus-automation-template.d.ts
131
+ interface RivusAutomationTemplate {
132
+ readonly id: string;
133
+ readonly profileId: string;
134
+ readonly requestedSkillIds: ReadonlyArray<string>;
135
+ readonly requestedToolIds: ReadonlyArray<string>;
136
+ readonly createInput: (tick: RivusAutomationTickContext) => RivusAutomationInput;
137
+ readonly createPresentation?: (output: RivusAutomationOutput) => AutomationPresentation;
138
+ }
139
+ interface RivusAutomationTickContext {
140
+ readonly occurrence: string;
141
+ }
142
+ interface RivusAutomationInput {
143
+ readonly text: string;
144
+ }
145
+ interface RivusAutomationOutput {
146
+ readonly occurrence: string;
147
+ readonly text: string;
148
+ }
149
+ interface RegisteredRivusAutomation extends RivusAutomationTemplate {
150
+ readonly pluginId: string;
151
+ }
152
+ //#endregion
153
+ //#region src/core/application/agent-catalog/contracts/rivus-plugin-contracts.d.ts
154
+ interface RivusPluginRegistry {
155
+ registerAgentProfile(profile: RivusAgentProfile): void;
156
+ registerTool(tool: RivusToolDescriptor): void;
157
+ registerSkill(skill: RivusSkillDescriptor): void;
158
+ registerAutomation(template: RivusAutomationTemplate): void;
159
+ }
160
+ interface RivusPlugin {
161
+ readonly manifest: RivusPluginManifest;
162
+ register(registry: RivusPluginRegistry): void;
163
+ }
164
+ interface RivusPluginCatalogSnapshot {
165
+ readonly plugins: ReadonlyArray<RegisteredRivusPlugin>;
166
+ readonly profiles: ReadonlyArray<RegisteredRivusAgentProfile>;
167
+ readonly tools: ReadonlyArray<RegisteredRivusTool>;
168
+ readonly skills: ReadonlyArray<RegisteredRivusSkill>;
169
+ readonly automations: ReadonlyArray<RegisteredRivusAutomation>;
170
+ }
171
+ interface RivusPluginCatalog {
172
+ registerPlugin(plugin: RivusPlugin): void;
173
+ snapshot(): RivusPluginCatalogSnapshot;
174
+ }
175
+ //#endregion
3
176
  //#region src/testing/rivus-plugin-testkit.d.ts
4
177
  interface RivusPluginLifecycleProbe {
5
178
  activate(): Promise<{
@@ -24,4 +197,4 @@ declare class RivusPluginConformanceError extends Error {
24
197
  declare function assertRivusPluginConforms(input: RivusPluginConformanceInput): Promise<RivusPluginConformanceReport>;
25
198
  declare function createFakeRivusPlugin(): RivusPlugin;
26
199
  //#endregion
27
- export { assertRivusPluginConforms as a, RivusPluginLifecycleProbe as i, RivusPluginConformanceInput as n, createFakeRivusPlugin as o, RivusPluginConformanceReport as r, RivusPluginConformanceError as t };
200
+ export { RegisteredRivusAgentProfile as A, InvalidAutomationPresentation as C, RIVUS_PLUGIN_API_VERSION as D, InvalidRivusPlugin as E, RivusAgentDeployment as M, RivusAgentProfile as N, RegisteredRivusPlugin as O, RivusRuntimeToolGrantSet as P, AutomationPresentationSource as S, readAutomationPresentation as T, AutomationPresentation as _, assertRivusPluginConforms as a, AutomationPresentationKind as b, RivusPluginCatalog as c, RegisteredRivusAutomation as d, RivusAutomationInput as f, AUTOMATION_PRESENTATION_SCHEMA_VERSION as g, RivusAutomationTickContext as h, RivusPluginLifecycleProbe as i, ResolvedRivusAgentDefinition as j, RivusPluginManifest as k, RivusPluginCatalogSnapshot as l, RivusAutomationTemplate as m, RivusPluginConformanceInput as n, createFakeRivusPlugin as o, RivusAutomationOutput as p, RivusPluginConformanceReport as r, RivusPlugin as s, RivusPluginConformanceError as t, RivusPluginRegistry as u, AutomationPresentationInput as v, createAutomationPresentation as w, AutomationPresentationSection as x, AutomationPresentationItem as y };
@@ -1,8 +1,15 @@
1
- import { i as createRivusPluginCatalog } from "./api.js";
2
- import { n as createRivusHostToolDescriptorProvider, r as RIVUS_MEMORY_TOOL_ID, t as createRivusAgentCatalog } from "./module.js";
1
+ import { o as createRivusHostToolDescriptorProvider, p as deepFreeze, r as createRivusPluginCatalog$1, s as RIVUS_MEMORY_TOOL_ID, t as createRivusAgentCatalog } from "./rivus-agent-definition-resolver.js";
2
+ import { t as createSha256Digest } from "./sha256-digest.js";
3
3
  //#region src/adapters/compatibility/agent-catalog/rivus-agent-catalog.ts
4
+ const runtime = Object.freeze({
5
+ digest: createSha256Digest,
6
+ deepFreeze
7
+ });
8
+ function createRivusPluginCatalog() {
9
+ return createRivusPluginCatalog$1(runtime);
10
+ }
4
11
  function createCompatibleRivusAgentCatalog(options = {}) {
5
- return createRivusAgentCatalog({ toolDescriptorProviders: [createRivusHostToolDescriptorProvider({ backgroundSessions: options.backgroundSessions === true })] });
12
+ return createRivusAgentCatalog([createRivusHostToolDescriptorProvider({ backgroundSessions: options.backgroundSessions === true })], runtime);
6
13
  }
7
14
  function resolveRivusAgentDefinition(catalog, deployment, options = {}) {
8
15
  return createCompatibleRivusAgentCatalog(options).resolve(catalog, deployment);
@@ -68,4 +75,4 @@ function createFakeRivusPlugin() {
68
75
  };
69
76
  }
70
77
  //#endregion
71
- export { resolveRivusAgentDefinition as a, createCompatibleRivusAgentCatalog as i, assertRivusPluginConforms as n, createFakeRivusPlugin as r, RivusPluginConformanceError as t };
78
+ export { createRivusPluginCatalog as a, createCompatibleRivusAgentCatalog as i, assertRivusPluginConforms as n, resolveRivusAgentDefinition as o, createFakeRivusPlugin as r, RivusPluginConformanceError as t };
@@ -0,0 +1,95 @@
1
+ //#region src/core/application/agent-catalog/contracts/rivus-tool.d.ts
2
+ type RivusMemoryScope = "conversation" | "agent-private" | "project" | "shared-user-profile";
3
+ type RivusToolRisk = "observe" | "mutate" | "irreversible" | "host-control";
4
+ type RivusToolIdempotency = "none" | "supported" | "required";
5
+ declare class RivusToolInputRejected extends Error {
6
+ readonly name: string;
7
+ }
8
+ interface RivusToolExecutor {
9
+ execute(input: unknown, context: RivusToolExecutionContext): unknown;
10
+ }
11
+ interface RivusToolExecutionOrigin {
12
+ readonly endpointId: string;
13
+ readonly tenantKey: string;
14
+ readonly conversationId?: string;
15
+ readonly allowedActorOpenIds: ReadonlyArray<string>;
16
+ }
17
+ interface RivusToolExecutionContext {
18
+ readonly agentId: string;
19
+ readonly instanceId: string;
20
+ readonly memory?: RivusMemoryAuthority;
21
+ readonly runId: string;
22
+ readonly callId: string;
23
+ readonly operationId?: string;
24
+ readonly policyEpoch: number;
25
+ readonly toolId: string;
26
+ readonly toolVersion: string;
27
+ readonly sessionKey: string;
28
+ readonly origin?: RivusToolExecutionOrigin;
29
+ readonly sourceMessageId?: string;
30
+ }
31
+ interface RivusMemoryAuthority {
32
+ readonly audience: "group" | "private";
33
+ readonly conversationId?: string;
34
+ readonly projectId?: string;
35
+ readonly scopes: ReadonlyArray<RivusMemoryScope>;
36
+ readonly subjectId: string;
37
+ readonly tenantId: string;
38
+ }
39
+ interface RivusToolFactoryContext {
40
+ readonly toolId: string;
41
+ readonly toolVersion: string;
42
+ }
43
+ interface RivusToolDescriptor {
44
+ readonly id: string;
45
+ readonly version: string;
46
+ readonly digest: string;
47
+ readonly description: string;
48
+ readonly inputSchema: unknown;
49
+ readonly risk: RivusToolRisk;
50
+ readonly idempotency: RivusToolIdempotency;
51
+ readonly createExecutor: (context: RivusToolFactoryContext) => RivusToolExecutor;
52
+ }
53
+ interface RivusHostToolDescriptor extends RivusToolDescriptor {
54
+ readonly replayCompleted?: (input: unknown, completedResult: unknown, context: RivusToolExecutionContext) => unknown;
55
+ }
56
+ interface RegisteredRivusTool extends RivusToolDescriptor {
57
+ readonly pluginId: string;
58
+ }
59
+ interface RivusResolvedToolDescriptor {
60
+ readonly id: string;
61
+ readonly version: string;
62
+ readonly digest: string;
63
+ readonly description: string;
64
+ readonly inputSchema: unknown;
65
+ readonly risk: RivusToolRisk;
66
+ readonly idempotency: RivusToolIdempotency;
67
+ readonly pluginId: string;
68
+ }
69
+ interface RivusToolGrantSet {
70
+ readonly toolIds: ReadonlyArray<string>;
71
+ readonly revision: string;
72
+ }
73
+ //#endregion
74
+ //#region src/core/application/agent-catalog/contracts/rivus-runtime-tool.d.ts
75
+ declare const RIVUS_RUNTIME_TOOL_IDS: readonly ["read", "bash", "edit", "write", "grep", "find", "ls"];
76
+ type RivusRuntimeToolId = (typeof RIVUS_RUNTIME_TOOL_IDS)[number];
77
+ declare function isRivusRuntimeToolId(value: string): value is RivusRuntimeToolId;
78
+ //#endregion
79
+ //#region src/core/application/agent-catalog/contracts/rivus-skill.d.ts
80
+ interface RivusSkillDescriptor {
81
+ readonly id: string;
82
+ readonly version: string;
83
+ readonly digest: string;
84
+ readonly title: string;
85
+ readonly content: string;
86
+ }
87
+ interface RegisteredRivusSkill extends RivusSkillDescriptor {
88
+ readonly pluginId: string;
89
+ }
90
+ interface RivusSkillGrantSet {
91
+ readonly skillIds: ReadonlyArray<string>;
92
+ readonly revision: string;
93
+ }
94
+ //#endregion
95
+ export { RivusToolIdempotency as _, RivusRuntimeToolId as a, RivusHostToolDescriptor as c, RivusResolvedToolDescriptor as d, RivusToolDescriptor as f, RivusToolGrantSet as g, RivusToolFactoryContext as h, RIVUS_RUNTIME_TOOL_IDS as i, RivusMemoryAuthority as l, RivusToolExecutor as m, RivusSkillDescriptor as n, isRivusRuntimeToolId as o, RivusToolExecutionContext as p, RivusSkillGrantSet as r, RegisteredRivusTool as s, RegisteredRivusSkill as t, RivusMemoryScope as u, RivusToolInputRejected as v, RivusToolRisk as y };
@@ -1,12 +1,7 @@
1
- import { createHash, randomUUID } from "node:crypto";
2
- //#region src/platform/identity/random-id.ts
3
- function createRandomId() {
4
- return randomUUID();
5
- }
6
- //#endregion
1
+ import { createHash } from "node:crypto";
7
2
  //#region src/platform/identity/sha256-digest.ts
8
3
  function createSha256Digest(value) {
9
4
  return `sha256:${createHash("sha256").update(value).digest("hex")}`;
10
5
  }
11
6
  //#endregion
12
- export { createRandomId as n, createSha256Digest as t };
7
+ export { createSha256Digest as t };