@rivus/agent 0.6.0 → 0.6.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.
- package/dist/agent-memory.js +114 -0
- package/dist/index.d.ts +13 -202
- package/dist/index.js +32 -246
- package/dist/pi-tool-proxy.d.ts +194 -0
- package/dist/pi.d.ts +10 -1
- package/dist/pi.js +111 -1
- package/dist/rivus-daemon-cli.js +5 -1
- package/dist/rivus-plugin-registry.js +2 -114
- package/dist/rivus-plugin-testkit.d.ts +2 -174
- package/dist/rivus-plugin-testkit.js +2 -1
- package/dist/rivus-plugin.d.ts +175 -0
- package/dist/tool-input-digest.js +126 -0
- package/examples/pi-feishu-deployment.bootstrap.ts +7 -4
- package/package.json +1 -1
package/dist/pi.js
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
+
import { d as requiresToolApproval } from "./agent-memory.js";
|
|
2
|
+
import { l as createPiSkillRuntime, o as createInvocationAuthority, r as createToolInputDigest } from "./tool-input-digest.js";
|
|
3
|
+
import { createHash } from "node:crypto";
|
|
1
4
|
import { isAbsolute, relative } from "node:path";
|
|
2
5
|
import { readFile, realpath, stat } from "node:fs/promises";
|
|
6
|
+
import { Unsafe } from "typebox";
|
|
3
7
|
import { createReadToolDefinition } from "@earendil-works/pi-coding-agent";
|
|
4
8
|
//#region src/infrastructure/pi/pi-project-skill-read-tool.ts
|
|
5
9
|
var ProjectSkillReadDenied = class extends Error {
|
|
@@ -30,4 +34,110 @@ async function authorize(path, sources) {
|
|
|
30
34
|
throw new ProjectSkillReadDenied("read is restricted to the bound Project Skill sources");
|
|
31
35
|
}
|
|
32
36
|
//#endregion
|
|
33
|
-
|
|
37
|
+
//#region src/infrastructure/pi/pi-tool-proxy.ts
|
|
38
|
+
function createPiToolProxyDefinitions(options) {
|
|
39
|
+
const names = /* @__PURE__ */ new Set();
|
|
40
|
+
return options.tools.map((tool) => {
|
|
41
|
+
const name = toPiToolName(tool.id);
|
|
42
|
+
if (names.has(name)) throw new Error(`Pi tool name collision: ${name}`);
|
|
43
|
+
names.add(name);
|
|
44
|
+
return {
|
|
45
|
+
description: tool.description,
|
|
46
|
+
execute: async (callId, input, signal) => {
|
|
47
|
+
const activeInput = options.getActiveInput();
|
|
48
|
+
const invocation = activeInput?.invocation;
|
|
49
|
+
if (!activeInput || !invocation) throw new Error(`tool ${tool.id} requires an active agent run with a trusted invocation`);
|
|
50
|
+
if (!invocation.tenantKey) throw new Error(`tool ${tool.id} requires a trusted tenant identity`);
|
|
51
|
+
throwIfAborted(signal ?? activeInput.abortSignal);
|
|
52
|
+
const inputDigest = createToolInputDigest(input);
|
|
53
|
+
const operationId = createBoundId("operation", {
|
|
54
|
+
agentId: options.agentId,
|
|
55
|
+
inputDigest,
|
|
56
|
+
instanceId: options.instanceId,
|
|
57
|
+
sourceMessageId: invocation.sourceMessageId,
|
|
58
|
+
toolId: tool.id,
|
|
59
|
+
toolVersion: tool.version
|
|
60
|
+
});
|
|
61
|
+
const approvalId = createBoundId("approval", {
|
|
62
|
+
callId,
|
|
63
|
+
operationId,
|
|
64
|
+
runId: activeInput.runId
|
|
65
|
+
});
|
|
66
|
+
if (requiresToolApproval(tool.risk)) {
|
|
67
|
+
if (invocation.allowedActorOpenIds.length === 0) throw new Error(`tool ${tool.id} requires at least one trusted approval actor`);
|
|
68
|
+
await options.approvals.requestApproval({
|
|
69
|
+
agentId: options.agentId,
|
|
70
|
+
allowedActorOpenIds: invocation.allowedActorOpenIds,
|
|
71
|
+
approvalId,
|
|
72
|
+
callId,
|
|
73
|
+
endpointId: invocation.endpointId,
|
|
74
|
+
inputDigest,
|
|
75
|
+
instanceId: options.instanceId,
|
|
76
|
+
operationId,
|
|
77
|
+
risk: tool.risk,
|
|
78
|
+
runId: activeInput.runId,
|
|
79
|
+
sessionKey: activeInput.sessionKey,
|
|
80
|
+
signal: signal ?? activeInput.abortSignal,
|
|
81
|
+
sourceMessageId: invocation.sourceMessageId,
|
|
82
|
+
tenantKey: invocation.tenantKey,
|
|
83
|
+
toolId: tool.id,
|
|
84
|
+
toolVersion: tool.version
|
|
85
|
+
});
|
|
86
|
+
throwIfAborted(signal ?? activeInput.abortSignal);
|
|
87
|
+
}
|
|
88
|
+
const result = await options.broker.execute({
|
|
89
|
+
authority: createInvocationAuthority({
|
|
90
|
+
agentId: options.agentId,
|
|
91
|
+
instanceId: options.instanceId,
|
|
92
|
+
...invocation.memory ? { memory: {
|
|
93
|
+
...invocation.memory,
|
|
94
|
+
scopes: options.memoryScopes ?? []
|
|
95
|
+
} } : {},
|
|
96
|
+
runId: activeInput.runId,
|
|
97
|
+
sessionKey: activeInput.sessionKey,
|
|
98
|
+
sourceMessageId: invocation.sourceMessageId,
|
|
99
|
+
tenantKey: invocation.tenantKey,
|
|
100
|
+
toolGrantSet: options.toolGrantSet
|
|
101
|
+
}),
|
|
102
|
+
callId,
|
|
103
|
+
input,
|
|
104
|
+
operationId,
|
|
105
|
+
...requiresToolApproval(tool.risk) ? { approvalId } : {},
|
|
106
|
+
toolId: tool.id,
|
|
107
|
+
version: tool.version
|
|
108
|
+
});
|
|
109
|
+
return {
|
|
110
|
+
content: [{
|
|
111
|
+
text: stringifyToolResult(result),
|
|
112
|
+
type: "text"
|
|
113
|
+
}],
|
|
114
|
+
details: result
|
|
115
|
+
};
|
|
116
|
+
},
|
|
117
|
+
executionMode: "sequential",
|
|
118
|
+
label: tool.id,
|
|
119
|
+
name,
|
|
120
|
+
parameters: Unsafe(tool.inputSchema),
|
|
121
|
+
promptSnippet: `${name}: ${tool.description}`
|
|
122
|
+
};
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
function createPiToolNameResolver(tools) {
|
|
126
|
+
const toolIdsByPiName = new Map(tools.map((tool) => [toPiToolName(tool.id), tool.id]));
|
|
127
|
+
return (toolName) => toolIdsByPiName.get(toolName) ?? toolName;
|
|
128
|
+
}
|
|
129
|
+
function toPiToolName(toolId) {
|
|
130
|
+
return `rivus_${toolId.replace(/[^a-zA-Z0-9_-]/g, "_")}`;
|
|
131
|
+
}
|
|
132
|
+
function createBoundId(kind, binding) {
|
|
133
|
+
return `${kind}:${createHash("sha256").update(JSON.stringify(binding)).digest("hex")}`;
|
|
134
|
+
}
|
|
135
|
+
function throwIfAborted(signal) {
|
|
136
|
+
if (signal.aborted) throw signal.reason ?? /* @__PURE__ */ new Error("tool execution was aborted");
|
|
137
|
+
}
|
|
138
|
+
function stringifyToolResult(result) {
|
|
139
|
+
if (typeof result === "string") return result;
|
|
140
|
+
return JSON.stringify(result ?? null);
|
|
141
|
+
}
|
|
142
|
+
//#endregion
|
|
143
|
+
export { ProjectSkillReadDenied, createPiProjectSkillReadTool, createPiSkillRuntime, createPiToolNameResolver, createPiToolProxyDefinitions };
|
package/dist/rivus-daemon-cli.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { t as MEMORY_SCOPES } from "./agent-memory.js";
|
|
2
|
+
import { n as resolveRivusAgentDefinition, r as deepFreeze, t as createRivusPluginCatalog } from "./rivus-plugin-registry.js";
|
|
2
3
|
import { createRequire } from "node:module";
|
|
3
4
|
import { Effect } from "effect";
|
|
4
5
|
import { createHash, randomUUID } from "node:crypto";
|
|
@@ -603,6 +604,9 @@ function createFeishuCardRollover(options) {
|
|
|
603
604
|
});
|
|
604
605
|
},
|
|
605
606
|
publish: (action) => exclusive(publishAction(action)),
|
|
607
|
+
releaseRun: (runId) => Effect.sync(() => {
|
|
608
|
+
liveRuns.delete(runId);
|
|
609
|
+
}),
|
|
606
610
|
recover: () => exclusive(Effect.gen(function* () {
|
|
607
611
|
const compensatedAt = yield* options.clock.now;
|
|
608
612
|
const compensated = yield* options.store.compensateInterruptedHandoffs(compensatedAt.toISOString());
|
|
@@ -1,117 +1,5 @@
|
|
|
1
|
+
import { c as InvalidRivusPlugin, o as createRivusMemoryToolContract, r as RIVUS_MEMORY_TOOL_PLUGIN_ID, t as MEMORY_SCOPES } from "./agent-memory.js";
|
|
1
2
|
import { createHash } from "node:crypto";
|
|
2
|
-
//#region src/domain/rivus-plugin.ts
|
|
3
|
-
const RIVUS_PLUGIN_API_VERSION = "1";
|
|
4
|
-
function requiresToolApproval(risk) {
|
|
5
|
-
return risk === "irreversible" || risk === "host-control";
|
|
6
|
-
}
|
|
7
|
-
var RivusToolInputRejected = class extends Error {
|
|
8
|
-
name = "RivusToolInputRejected";
|
|
9
|
-
};
|
|
10
|
-
var InvalidRivusPlugin = class extends Error {
|
|
11
|
-
name = "InvalidRivusPlugin";
|
|
12
|
-
};
|
|
13
|
-
//#endregion
|
|
14
|
-
//#region src/domain/agent-memory.ts
|
|
15
|
-
const MEMORY_SCOPES = [
|
|
16
|
-
"conversation",
|
|
17
|
-
"agent-private",
|
|
18
|
-
"project",
|
|
19
|
-
"shared-user-profile"
|
|
20
|
-
];
|
|
21
|
-
const RIVUS_MEMORY_TOOL_ID = "memory";
|
|
22
|
-
const RIVUS_MEMORY_TOOL_PLUGIN_ID = "rivus-core";
|
|
23
|
-
const RIVUS_MEMORY_TOOL_VERSION = "1.0.0";
|
|
24
|
-
function createMemoryNamespace(binding) {
|
|
25
|
-
const encode = (value) => encodeURIComponent(value);
|
|
26
|
-
switch (binding.scope) {
|
|
27
|
-
case "conversation": return [
|
|
28
|
-
binding.tenantId,
|
|
29
|
-
binding.agentId,
|
|
30
|
-
binding.subjectId,
|
|
31
|
-
binding.conversationId ?? "",
|
|
32
|
-
binding.scope
|
|
33
|
-
].map(encode).join("/");
|
|
34
|
-
case "agent-private": return [
|
|
35
|
-
binding.tenantId,
|
|
36
|
-
binding.agentId,
|
|
37
|
-
binding.subjectId,
|
|
38
|
-
binding.scope
|
|
39
|
-
].map(encode).join("/");
|
|
40
|
-
case "project": return [
|
|
41
|
-
binding.tenantId,
|
|
42
|
-
binding.agentId,
|
|
43
|
-
binding.projectId ?? "",
|
|
44
|
-
binding.scope
|
|
45
|
-
].map(encode).join("/");
|
|
46
|
-
case "shared-user-profile": return [
|
|
47
|
-
binding.tenantId,
|
|
48
|
-
binding.subjectId,
|
|
49
|
-
binding.scope
|
|
50
|
-
].map(encode).join("/");
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
function restrictMemoryScopesForAudience(scopes, audience) {
|
|
54
|
-
return audience === "group" ? scopes.filter((scope) => scope === "conversation" || scope === "project") : [...scopes];
|
|
55
|
-
}
|
|
56
|
-
function createRivusMemoryToolContract(scopes) {
|
|
57
|
-
return Object.freeze({
|
|
58
|
-
description: "Search and read Memory inside Host-bound scopes; propose or request forgetting only in writable private scopes.",
|
|
59
|
-
digest: "sha256:rivus-memory-v3",
|
|
60
|
-
id: RIVUS_MEMORY_TOOL_ID,
|
|
61
|
-
idempotency: "required",
|
|
62
|
-
inputSchema: Object.freeze({
|
|
63
|
-
additionalProperties: false,
|
|
64
|
-
properties: {
|
|
65
|
-
command: {
|
|
66
|
-
description: "One of search, read, propose, or forget_request.",
|
|
67
|
-
enum: [
|
|
68
|
-
"search",
|
|
69
|
-
"read",
|
|
70
|
-
"propose",
|
|
71
|
-
"forget_request"
|
|
72
|
-
],
|
|
73
|
-
type: "string"
|
|
74
|
-
},
|
|
75
|
-
id: {
|
|
76
|
-
description: "Required for read and forget_request.",
|
|
77
|
-
minLength: 1,
|
|
78
|
-
type: "string"
|
|
79
|
-
},
|
|
80
|
-
input: {
|
|
81
|
-
additionalProperties: false,
|
|
82
|
-
description: "Required for propose.",
|
|
83
|
-
properties: { content: {
|
|
84
|
-
minLength: 1,
|
|
85
|
-
type: "string"
|
|
86
|
-
} },
|
|
87
|
-
required: ["content"],
|
|
88
|
-
type: "object"
|
|
89
|
-
},
|
|
90
|
-
query: {
|
|
91
|
-
additionalProperties: false,
|
|
92
|
-
description: "Required for search.",
|
|
93
|
-
properties: { query: { type: "string" } },
|
|
94
|
-
required: ["query"],
|
|
95
|
-
type: "object"
|
|
96
|
-
},
|
|
97
|
-
reason: {
|
|
98
|
-
description: "Optional reason for forget_request.",
|
|
99
|
-
type: "string"
|
|
100
|
-
},
|
|
101
|
-
...scopes.length === 0 ? {} : { scope: {
|
|
102
|
-
description: "Optional Host-granted scope for search or propose. Confirmed Project and Shared User Profile Memory are read-only to the model.",
|
|
103
|
-
enum: [...scopes],
|
|
104
|
-
type: "string"
|
|
105
|
-
} }
|
|
106
|
-
},
|
|
107
|
-
required: ["command"],
|
|
108
|
-
type: "object"
|
|
109
|
-
}),
|
|
110
|
-
risk: "mutate",
|
|
111
|
-
version: RIVUS_MEMORY_TOOL_VERSION
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
//#endregion
|
|
115
3
|
//#region src/application/plugin/deep-freeze.ts
|
|
116
4
|
function deepFreeze(value) {
|
|
117
5
|
if (value !== null && typeof value === "object" && !Object.isFrozen(value)) {
|
|
@@ -321,4 +209,4 @@ function stableJson(value) {
|
|
|
321
209
|
return JSON.stringify(value);
|
|
322
210
|
}
|
|
323
211
|
//#endregion
|
|
324
|
-
export {
|
|
212
|
+
export { resolveRivusAgentDefinition as n, deepFreeze as r, createRivusPluginCatalog as t };
|
|
@@ -1,177 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { h as RivusPlugin, l as RivusAgentDeployment } from "./rivus-plugin.js";
|
|
2
2
|
|
|
3
|
-
//#region src/domain/rivus-plugin.d.ts
|
|
4
|
-
declare const RIVUS_PLUGIN_API_VERSION = "1";
|
|
5
|
-
type RivusToolRisk = "observe" | "mutate" | "irreversible" | "host-control";
|
|
6
|
-
type RivusToolIdempotency = "none" | "supported" | "required";
|
|
7
|
-
declare function requiresToolApproval(risk: RivusToolRisk): boolean;
|
|
8
|
-
declare class RivusToolInputRejected extends Error {
|
|
9
|
-
readonly name: string;
|
|
10
|
-
}
|
|
11
|
-
interface RivusPluginManifest {
|
|
12
|
-
readonly apiVersion: string;
|
|
13
|
-
readonly id: string;
|
|
14
|
-
readonly version: string;
|
|
15
|
-
}
|
|
16
|
-
interface RivusToolExecutor {
|
|
17
|
-
execute(input: unknown, context: RivusToolExecutionContext): unknown;
|
|
18
|
-
}
|
|
19
|
-
interface RivusToolExecutionContext {
|
|
20
|
-
readonly agentId: string;
|
|
21
|
-
readonly instanceId: string;
|
|
22
|
-
readonly memory?: AgentMemoryAuthority;
|
|
23
|
-
readonly runId: string;
|
|
24
|
-
readonly callId: string;
|
|
25
|
-
readonly operationId?: string;
|
|
26
|
-
readonly policyEpoch: number;
|
|
27
|
-
readonly toolId: string;
|
|
28
|
-
readonly toolVersion: string;
|
|
29
|
-
readonly sessionKey: string;
|
|
30
|
-
}
|
|
31
|
-
interface RivusToolFactoryContext {
|
|
32
|
-
readonly toolId: string;
|
|
33
|
-
readonly toolVersion: string;
|
|
34
|
-
}
|
|
35
|
-
interface RivusToolDescriptor {
|
|
36
|
-
readonly id: string;
|
|
37
|
-
readonly version: string;
|
|
38
|
-
readonly digest: string;
|
|
39
|
-
readonly description: string;
|
|
40
|
-
readonly inputSchema: unknown;
|
|
41
|
-
readonly risk: RivusToolRisk;
|
|
42
|
-
readonly idempotency: RivusToolIdempotency;
|
|
43
|
-
readonly createExecutor: (context: RivusToolFactoryContext) => RivusToolExecutor;
|
|
44
|
-
}
|
|
45
|
-
interface RivusHostToolDescriptor extends RivusToolDescriptor {
|
|
46
|
-
readonly replayCompleted?: (input: unknown, completedResult: unknown, context: RivusToolExecutionContext) => unknown;
|
|
47
|
-
}
|
|
48
|
-
interface RivusSkillDescriptor {
|
|
49
|
-
readonly id: string;
|
|
50
|
-
readonly version: string;
|
|
51
|
-
readonly digest: string;
|
|
52
|
-
readonly title: string;
|
|
53
|
-
readonly content: string;
|
|
54
|
-
}
|
|
55
|
-
interface RivusAutomationTemplate {
|
|
56
|
-
readonly id: string;
|
|
57
|
-
readonly profileId: string;
|
|
58
|
-
readonly requestedSkillIds: ReadonlyArray<string>;
|
|
59
|
-
readonly requestedToolIds: ReadonlyArray<string>;
|
|
60
|
-
readonly createInput: (tick: RivusAutomationTickContext) => RivusAutomationInput;
|
|
61
|
-
}
|
|
62
|
-
interface RivusAutomationTickContext {
|
|
63
|
-
readonly occurrence: string;
|
|
64
|
-
}
|
|
65
|
-
interface RivusAutomationInput {
|
|
66
|
-
readonly text: string;
|
|
67
|
-
}
|
|
68
|
-
interface RivusAgentProfile {
|
|
69
|
-
readonly id: string;
|
|
70
|
-
readonly displayName: string;
|
|
71
|
-
readonly systemPrompt: string;
|
|
72
|
-
readonly model: Readonly<Record<string, unknown>>;
|
|
73
|
-
readonly tools: {
|
|
74
|
-
readonly allow: ReadonlyArray<string>;
|
|
75
|
-
};
|
|
76
|
-
readonly skills: {
|
|
77
|
-
readonly allow: ReadonlyArray<string>;
|
|
78
|
-
};
|
|
79
|
-
readonly memory: {
|
|
80
|
-
readonly scopes: ReadonlyArray<MemoryScope>;
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
interface RivusPluginRegistry {
|
|
84
|
-
registerAgentProfile(profile: RivusAgentProfile): void;
|
|
85
|
-
registerTool(tool: RivusToolDescriptor): void;
|
|
86
|
-
registerSkill(skill: RivusSkillDescriptor): void;
|
|
87
|
-
registerAutomation(template: RivusAutomationTemplate): void;
|
|
88
|
-
}
|
|
89
|
-
interface RivusPlugin {
|
|
90
|
-
readonly manifest: RivusPluginManifest;
|
|
91
|
-
register(registry: RivusPluginRegistry): void;
|
|
92
|
-
}
|
|
93
|
-
interface RegisteredRivusPlugin extends RivusPluginManifest {}
|
|
94
|
-
interface RegisteredRivusTool extends RivusToolDescriptor {
|
|
95
|
-
readonly pluginId: string;
|
|
96
|
-
}
|
|
97
|
-
interface RegisteredRivusSkill extends RivusSkillDescriptor {
|
|
98
|
-
readonly pluginId: string;
|
|
99
|
-
}
|
|
100
|
-
interface RegisteredRivusAutomation extends RivusAutomationTemplate {
|
|
101
|
-
readonly pluginId: string;
|
|
102
|
-
}
|
|
103
|
-
interface RegisteredRivusAgentProfile extends RivusAgentProfile {
|
|
104
|
-
readonly pluginId: string;
|
|
105
|
-
}
|
|
106
|
-
interface RivusPluginCatalogSnapshot {
|
|
107
|
-
readonly plugins: ReadonlyArray<RegisteredRivusPlugin>;
|
|
108
|
-
readonly profiles: ReadonlyArray<RegisteredRivusAgentProfile>;
|
|
109
|
-
readonly tools: ReadonlyArray<RegisteredRivusTool>;
|
|
110
|
-
readonly skills: ReadonlyArray<RegisteredRivusSkill>;
|
|
111
|
-
readonly automations: ReadonlyArray<RegisteredRivusAutomation>;
|
|
112
|
-
}
|
|
113
|
-
interface RivusPluginCatalog {
|
|
114
|
-
registerPlugin(plugin: RivusPlugin): void;
|
|
115
|
-
snapshot(): RivusPluginCatalogSnapshot;
|
|
116
|
-
}
|
|
117
|
-
interface RivusAgentDeployment {
|
|
118
|
-
readonly agentId: string;
|
|
119
|
-
readonly pluginId: string;
|
|
120
|
-
readonly profileId: string;
|
|
121
|
-
readonly projectSpaceId?: string;
|
|
122
|
-
readonly endpointIds: ReadonlyArray<string>;
|
|
123
|
-
readonly memory?: {
|
|
124
|
-
readonly scopes: ReadonlyArray<MemoryScope>;
|
|
125
|
-
readonly tool: boolean;
|
|
126
|
-
};
|
|
127
|
-
readonly skills: {
|
|
128
|
-
readonly allow: ReadonlyArray<string>;
|
|
129
|
-
};
|
|
130
|
-
readonly tools: {
|
|
131
|
-
readonly allow: ReadonlyArray<string>;
|
|
132
|
-
};
|
|
133
|
-
}
|
|
134
|
-
interface RivusResolvedToolDescriptor {
|
|
135
|
-
readonly id: string;
|
|
136
|
-
readonly version: string;
|
|
137
|
-
readonly digest: string;
|
|
138
|
-
readonly description: string;
|
|
139
|
-
readonly inputSchema: unknown;
|
|
140
|
-
readonly risk: RivusToolRisk;
|
|
141
|
-
readonly idempotency: RivusToolIdempotency;
|
|
142
|
-
readonly pluginId: string;
|
|
143
|
-
}
|
|
144
|
-
interface RivusToolGrantSet {
|
|
145
|
-
readonly toolIds: ReadonlyArray<string>;
|
|
146
|
-
readonly revision: string;
|
|
147
|
-
}
|
|
148
|
-
interface RivusSkillGrantSet {
|
|
149
|
-
readonly skillIds: ReadonlyArray<string>;
|
|
150
|
-
readonly revision: string;
|
|
151
|
-
}
|
|
152
|
-
interface ResolvedRivusAgentDefinition {
|
|
153
|
-
readonly agentId: string;
|
|
154
|
-
readonly pluginId: string;
|
|
155
|
-
readonly profileId: string;
|
|
156
|
-
readonly projectSpaceId?: string;
|
|
157
|
-
readonly projectSpaceRevision?: string;
|
|
158
|
-
readonly endpointIds: ReadonlyArray<string>;
|
|
159
|
-
readonly profileRevision: string;
|
|
160
|
-
readonly systemPrompt: string;
|
|
161
|
-
readonly model: Readonly<Record<string, unknown>>;
|
|
162
|
-
readonly memory: {
|
|
163
|
-
readonly scopes: ReadonlyArray<MemoryScope>;
|
|
164
|
-
readonly tool: boolean;
|
|
165
|
-
};
|
|
166
|
-
readonly skillGrantSet: RivusSkillGrantSet;
|
|
167
|
-
readonly skills: ReadonlyArray<RegisteredRivusSkill>;
|
|
168
|
-
readonly tools: ReadonlyArray<RivusResolvedToolDescriptor>;
|
|
169
|
-
readonly toolGrantSet: RivusToolGrantSet;
|
|
170
|
-
}
|
|
171
|
-
declare class InvalidRivusPlugin extends Error {
|
|
172
|
-
readonly name = "InvalidRivusPlugin";
|
|
173
|
-
}
|
|
174
|
-
//#endregion
|
|
175
3
|
//#region src/testing/rivus-plugin-testkit.d.ts
|
|
176
4
|
interface RivusPluginLifecycleProbe {
|
|
177
5
|
activate(): Promise<{
|
|
@@ -196,4 +24,4 @@ declare class RivusPluginConformanceError extends Error {
|
|
|
196
24
|
declare function assertRivusPluginConforms(input: RivusPluginConformanceInput): Promise<RivusPluginConformanceReport>;
|
|
197
25
|
declare function createFakeRivusPlugin(): RivusPlugin;
|
|
198
26
|
//#endregion
|
|
199
|
-
export {
|
|
27
|
+
export { assertRivusPluginConforms as a, RivusPluginLifecycleProbe as i, RivusPluginConformanceInput as n, createFakeRivusPlugin as o, RivusPluginConformanceReport as r, RivusPluginConformanceError as t };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as RIVUS_MEMORY_TOOL_ID } from "./agent-memory.js";
|
|
2
|
+
import { n as resolveRivusAgentDefinition, t as createRivusPluginCatalog } from "./rivus-plugin-registry.js";
|
|
2
3
|
//#region src/testing/rivus-plugin-testkit.ts
|
|
3
4
|
var RivusPluginConformanceError = class extends Error {
|
|
4
5
|
name = "RivusPluginConformanceError";
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { c as MemoryScope, t as AgentMemoryAuthority } from "./agent-memory.js";
|
|
2
|
+
|
|
3
|
+
//#region src/domain/rivus-plugin.d.ts
|
|
4
|
+
declare const RIVUS_PLUGIN_API_VERSION = "1";
|
|
5
|
+
type RivusToolRisk = "observe" | "mutate" | "irreversible" | "host-control";
|
|
6
|
+
type RivusToolIdempotency = "none" | "supported" | "required";
|
|
7
|
+
declare function requiresToolApproval(risk: RivusToolRisk): boolean;
|
|
8
|
+
declare class RivusToolInputRejected extends Error {
|
|
9
|
+
readonly name: string;
|
|
10
|
+
}
|
|
11
|
+
interface RivusPluginManifest {
|
|
12
|
+
readonly apiVersion: string;
|
|
13
|
+
readonly id: string;
|
|
14
|
+
readonly version: string;
|
|
15
|
+
}
|
|
16
|
+
interface RivusToolExecutor {
|
|
17
|
+
execute(input: unknown, context: RivusToolExecutionContext): unknown;
|
|
18
|
+
}
|
|
19
|
+
interface RivusToolExecutionContext {
|
|
20
|
+
readonly agentId: string;
|
|
21
|
+
readonly instanceId: string;
|
|
22
|
+
readonly memory?: AgentMemoryAuthority;
|
|
23
|
+
readonly runId: string;
|
|
24
|
+
readonly callId: string;
|
|
25
|
+
readonly operationId?: string;
|
|
26
|
+
readonly policyEpoch: number;
|
|
27
|
+
readonly toolId: string;
|
|
28
|
+
readonly toolVersion: string;
|
|
29
|
+
readonly sessionKey: string;
|
|
30
|
+
}
|
|
31
|
+
interface RivusToolFactoryContext {
|
|
32
|
+
readonly toolId: string;
|
|
33
|
+
readonly toolVersion: string;
|
|
34
|
+
}
|
|
35
|
+
interface RivusToolDescriptor {
|
|
36
|
+
readonly id: string;
|
|
37
|
+
readonly version: string;
|
|
38
|
+
readonly digest: string;
|
|
39
|
+
readonly description: string;
|
|
40
|
+
readonly inputSchema: unknown;
|
|
41
|
+
readonly risk: RivusToolRisk;
|
|
42
|
+
readonly idempotency: RivusToolIdempotency;
|
|
43
|
+
readonly createExecutor: (context: RivusToolFactoryContext) => RivusToolExecutor;
|
|
44
|
+
}
|
|
45
|
+
interface RivusHostToolDescriptor extends RivusToolDescriptor {
|
|
46
|
+
readonly replayCompleted?: (input: unknown, completedResult: unknown, context: RivusToolExecutionContext) => unknown;
|
|
47
|
+
}
|
|
48
|
+
interface RivusSkillDescriptor {
|
|
49
|
+
readonly id: string;
|
|
50
|
+
readonly version: string;
|
|
51
|
+
readonly digest: string;
|
|
52
|
+
readonly title: string;
|
|
53
|
+
readonly content: string;
|
|
54
|
+
}
|
|
55
|
+
interface RivusAutomationTemplate {
|
|
56
|
+
readonly id: string;
|
|
57
|
+
readonly profileId: string;
|
|
58
|
+
readonly requestedSkillIds: ReadonlyArray<string>;
|
|
59
|
+
readonly requestedToolIds: ReadonlyArray<string>;
|
|
60
|
+
readonly createInput: (tick: RivusAutomationTickContext) => RivusAutomationInput;
|
|
61
|
+
}
|
|
62
|
+
interface RivusAutomationTickContext {
|
|
63
|
+
readonly occurrence: string;
|
|
64
|
+
}
|
|
65
|
+
interface RivusAutomationInput {
|
|
66
|
+
readonly text: string;
|
|
67
|
+
}
|
|
68
|
+
interface RivusAgentProfile {
|
|
69
|
+
readonly id: string;
|
|
70
|
+
readonly displayName: string;
|
|
71
|
+
readonly systemPrompt: string;
|
|
72
|
+
readonly model: Readonly<Record<string, unknown>>;
|
|
73
|
+
readonly tools: {
|
|
74
|
+
readonly allow: ReadonlyArray<string>;
|
|
75
|
+
};
|
|
76
|
+
readonly skills: {
|
|
77
|
+
readonly allow: ReadonlyArray<string>;
|
|
78
|
+
};
|
|
79
|
+
readonly memory: {
|
|
80
|
+
readonly scopes: ReadonlyArray<MemoryScope>;
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
interface RivusPluginRegistry {
|
|
84
|
+
registerAgentProfile(profile: RivusAgentProfile): void;
|
|
85
|
+
registerTool(tool: RivusToolDescriptor): void;
|
|
86
|
+
registerSkill(skill: RivusSkillDescriptor): void;
|
|
87
|
+
registerAutomation(template: RivusAutomationTemplate): void;
|
|
88
|
+
}
|
|
89
|
+
interface RivusPlugin {
|
|
90
|
+
readonly manifest: RivusPluginManifest;
|
|
91
|
+
register(registry: RivusPluginRegistry): void;
|
|
92
|
+
}
|
|
93
|
+
interface RegisteredRivusPlugin extends RivusPluginManifest {}
|
|
94
|
+
interface RegisteredRivusTool extends RivusToolDescriptor {
|
|
95
|
+
readonly pluginId: string;
|
|
96
|
+
}
|
|
97
|
+
interface RegisteredRivusSkill extends RivusSkillDescriptor {
|
|
98
|
+
readonly pluginId: string;
|
|
99
|
+
}
|
|
100
|
+
interface RegisteredRivusAutomation extends RivusAutomationTemplate {
|
|
101
|
+
readonly pluginId: string;
|
|
102
|
+
}
|
|
103
|
+
interface RegisteredRivusAgentProfile extends RivusAgentProfile {
|
|
104
|
+
readonly pluginId: string;
|
|
105
|
+
}
|
|
106
|
+
interface RivusPluginCatalogSnapshot {
|
|
107
|
+
readonly plugins: ReadonlyArray<RegisteredRivusPlugin>;
|
|
108
|
+
readonly profiles: ReadonlyArray<RegisteredRivusAgentProfile>;
|
|
109
|
+
readonly tools: ReadonlyArray<RegisteredRivusTool>;
|
|
110
|
+
readonly skills: ReadonlyArray<RegisteredRivusSkill>;
|
|
111
|
+
readonly automations: ReadonlyArray<RegisteredRivusAutomation>;
|
|
112
|
+
}
|
|
113
|
+
interface RivusPluginCatalog {
|
|
114
|
+
registerPlugin(plugin: RivusPlugin): void;
|
|
115
|
+
snapshot(): RivusPluginCatalogSnapshot;
|
|
116
|
+
}
|
|
117
|
+
interface RivusAgentDeployment {
|
|
118
|
+
readonly agentId: string;
|
|
119
|
+
readonly pluginId: string;
|
|
120
|
+
readonly profileId: string;
|
|
121
|
+
readonly projectSpaceId?: string;
|
|
122
|
+
readonly endpointIds: ReadonlyArray<string>;
|
|
123
|
+
readonly memory?: {
|
|
124
|
+
readonly scopes: ReadonlyArray<MemoryScope>;
|
|
125
|
+
readonly tool: boolean;
|
|
126
|
+
};
|
|
127
|
+
readonly skills: {
|
|
128
|
+
readonly allow: ReadonlyArray<string>;
|
|
129
|
+
};
|
|
130
|
+
readonly tools: {
|
|
131
|
+
readonly allow: ReadonlyArray<string>;
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
interface RivusResolvedToolDescriptor {
|
|
135
|
+
readonly id: string;
|
|
136
|
+
readonly version: string;
|
|
137
|
+
readonly digest: string;
|
|
138
|
+
readonly description: string;
|
|
139
|
+
readonly inputSchema: unknown;
|
|
140
|
+
readonly risk: RivusToolRisk;
|
|
141
|
+
readonly idempotency: RivusToolIdempotency;
|
|
142
|
+
readonly pluginId: string;
|
|
143
|
+
}
|
|
144
|
+
interface RivusToolGrantSet {
|
|
145
|
+
readonly toolIds: ReadonlyArray<string>;
|
|
146
|
+
readonly revision: string;
|
|
147
|
+
}
|
|
148
|
+
interface RivusSkillGrantSet {
|
|
149
|
+
readonly skillIds: ReadonlyArray<string>;
|
|
150
|
+
readonly revision: string;
|
|
151
|
+
}
|
|
152
|
+
interface ResolvedRivusAgentDefinition {
|
|
153
|
+
readonly agentId: string;
|
|
154
|
+
readonly pluginId: string;
|
|
155
|
+
readonly profileId: string;
|
|
156
|
+
readonly projectSpaceId?: string;
|
|
157
|
+
readonly projectSpaceRevision?: string;
|
|
158
|
+
readonly endpointIds: ReadonlyArray<string>;
|
|
159
|
+
readonly profileRevision: string;
|
|
160
|
+
readonly systemPrompt: string;
|
|
161
|
+
readonly model: Readonly<Record<string, unknown>>;
|
|
162
|
+
readonly memory: {
|
|
163
|
+
readonly scopes: ReadonlyArray<MemoryScope>;
|
|
164
|
+
readonly tool: boolean;
|
|
165
|
+
};
|
|
166
|
+
readonly skillGrantSet: RivusSkillGrantSet;
|
|
167
|
+
readonly skills: ReadonlyArray<RegisteredRivusSkill>;
|
|
168
|
+
readonly tools: ReadonlyArray<RivusResolvedToolDescriptor>;
|
|
169
|
+
readonly toolGrantSet: RivusToolGrantSet;
|
|
170
|
+
}
|
|
171
|
+
declare class InvalidRivusPlugin extends Error {
|
|
172
|
+
readonly name = "InvalidRivusPlugin";
|
|
173
|
+
}
|
|
174
|
+
//#endregion
|
|
175
|
+
export { RivusToolRisk as A, RivusToolDescriptor as C, RivusToolGrantSet as D, RivusToolFactoryContext as E, RivusToolIdempotency as O, RivusSkillGrantSet as S, RivusToolExecutor as T, RivusPluginCatalogSnapshot as _, RegisteredRivusPlugin as a, RivusResolvedToolDescriptor as b, ResolvedRivusAgentDefinition as c, RivusAutomationInput as d, RivusAutomationTemplate as f, RivusPluginCatalog as g, RivusPlugin as h, RegisteredRivusAutomation as i, requiresToolApproval as j, RivusToolInputRejected as k, RivusAgentDeployment as l, RivusHostToolDescriptor as m, RIVUS_PLUGIN_API_VERSION as n, RegisteredRivusSkill as o, RivusAutomationTickContext as p, RegisteredRivusAgentProfile as r, RegisteredRivusTool as s, InvalidRivusPlugin as t, RivusAgentProfile as u, RivusPluginManifest as v, RivusToolExecutionContext as w, RivusSkillDescriptor as x, RivusPluginRegistry as y };
|