@rivus/agent 0.16.0 → 0.16.2
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/bootstrap/pi-feishu.js +43 -32
- package/dist/chunks/agent-loop.d.ts +2 -1
- package/dist/chunks/agent-loop.js +8 -2
- package/dist/chunks/index.d.ts +7 -0
- package/dist/chunks/pi.js +39 -2
- package/dist/chunks/rivus-daemon-cli.js +1 -14
- package/dist/chunks/src.js +459 -263
- package/dist/pi.d.ts +22 -1
- package/dist/pi.js +2 -2
- package/examples/pi-feishu-deployment.bootstrap.ts +23 -11
- package/examples/pi-feishu.bootstrap.ts +1 -0
- package/package.json +1 -1
package/dist/pi.d.ts
CHANGED
|
@@ -66,6 +66,23 @@ interface PiNamedTool {
|
|
|
66
66
|
}
|
|
67
67
|
declare function resolvePiSessionToolNames(runtimeToolIds: ReadonlyArray<RivusRuntimeToolId>, customTools: ReadonlyArray<PiNamedTool>): ReadonlyArray<string>;
|
|
68
68
|
//#endregion
|
|
69
|
+
//#region src/adapters/pi/tool-execution/pi-bash-tool-options.d.ts
|
|
70
|
+
interface PiBashSpawnContext {
|
|
71
|
+
command: string;
|
|
72
|
+
cwd: string;
|
|
73
|
+
env: Record<string, string | undefined>;
|
|
74
|
+
}
|
|
75
|
+
/** Rivus's Bash configuration boundary, independent of provider UI/model types. */
|
|
76
|
+
interface PiBashToolOptions {
|
|
77
|
+
commandPrefix?: string;
|
|
78
|
+
shellPath?: string;
|
|
79
|
+
spawnHook?: (context: PiBashSpawnContext) => PiBashSpawnContext;
|
|
80
|
+
}
|
|
81
|
+
//#endregion
|
|
82
|
+
//#region src/adapters/pi/tool-execution/pi-bash-tool.d.ts
|
|
83
|
+
/** Keep Pi's native execution, rendering and abort cleanup with a bounded default. */
|
|
84
|
+
declare function createPiBashTool(cwd: string, options?: PiBashToolOptions): PiToolDefinition;
|
|
85
|
+
//#endregion
|
|
69
86
|
//#region src/adapters/pi/runtime/pi-session-resources.d.ts
|
|
70
87
|
interface CreatePiSessionResourcesOptions {
|
|
71
88
|
readonly agentDir: string;
|
|
@@ -77,6 +94,10 @@ interface CreatePiSessionResourcesOptions {
|
|
|
77
94
|
readonly systemPromptOverride?: (base: string | undefined) => string | undefined;
|
|
78
95
|
}
|
|
79
96
|
interface PiSessionResources {
|
|
97
|
+
readonly bashToolOptions?: {
|
|
98
|
+
readonly commandPrefix?: string;
|
|
99
|
+
readonly shellPath?: string;
|
|
100
|
+
};
|
|
80
101
|
readonly skillNames: ReadonlySet<string>;
|
|
81
102
|
readonly skillPaths: ReadonlyArray<string>;
|
|
82
103
|
readonly refresh: () => Promise<void>;
|
|
@@ -105,4 +126,4 @@ interface PiToolProxyOptions {
|
|
|
105
126
|
declare function createPiToolProxyDefinitions(options: PiToolProxyOptions): PiToolDefinition[];
|
|
106
127
|
declare function createPiToolNameResolver(tools: ReadonlyArray<Pick<RivusResolvedToolDescriptor, "id">>): (toolName: string) => string;
|
|
107
128
|
//#endregion
|
|
108
|
-
export { type CreatePiSessionResourcesOptions, InvalidPiSkillCatalog, InvalidPiSkillSource, type PiSessionResources, type PiSkillRuntime, type PiToolApprovalGateway, type PiToolApprovalRequest, type PiToolContent, type PiToolDefinition, type PiToolProxyOptions, type PiToolResult, ProjectSkillReadDenied, type ResolvePiSkillSourcesOptions, createPiProjectSkillReadTool, createPiSessionResources, createPiSkillReadTool, createPiSkillReadTools, createPiSkillRuntime, createPiToolNameResolver, createPiToolProxyDefinitions, resolvePiSessionToolNames, resolvePiSkillSources, validatePiSkillCatalog, validatePiSkillCommand };
|
|
129
|
+
export { type CreatePiSessionResourcesOptions, InvalidPiSkillCatalog, InvalidPiSkillSource, type PiBashToolOptions, type PiSessionResources, type PiSkillRuntime, type PiToolApprovalGateway, type PiToolApprovalRequest, type PiToolContent, type PiToolDefinition, type PiToolProxyOptions, type PiToolResult, ProjectSkillReadDenied, type ResolvePiSkillSourcesOptions, createPiBashTool, createPiProjectSkillReadTool, createPiSessionResources, createPiSkillReadTool, createPiSkillReadTools, createPiSkillRuntime, createPiToolNameResolver, createPiToolProxyDefinitions, resolvePiSessionToolNames, resolvePiSkillSources, validatePiSkillCatalog, validatePiSkillCommand };
|
package/dist/pi.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
+
import { a as InvalidPiSkillSource, c as validatePiSkillCatalog, d as createPiProjectSkillReadTool, f as createPiSkillReadTool, i as resolvePiSessionToolNames, l as validatePiSkillCommand, m as createPiBashTool, n as createPiToolProxyDefinitions, o as resolvePiSkillSources, p as createPiSkillReadTools, r as createPiSessionResources, s as InvalidPiSkillCatalog, t as createPiToolNameResolver, u as ProjectSkillReadDenied } from "./chunks/pi.js";
|
|
1
2
|
import { r as createPiSkillRuntime } from "./chunks/rivus-tool.js";
|
|
2
|
-
|
|
3
|
-
export { InvalidPiSkillCatalog, InvalidPiSkillSource, ProjectSkillReadDenied, createPiProjectSkillReadTool, createPiSessionResources, createPiSkillReadTool, createPiSkillReadTools, createPiSkillRuntime, createPiToolNameResolver, createPiToolProxyDefinitions, resolvePiSessionToolNames, resolvePiSkillSources, validatePiSkillCatalog, validatePiSkillCommand };
|
|
3
|
+
export { InvalidPiSkillCatalog, InvalidPiSkillSource, ProjectSkillReadDenied, createPiBashTool, createPiProjectSkillReadTool, createPiSessionResources, createPiSkillReadTool, createPiSkillReadTools, createPiSkillRuntime, createPiToolNameResolver, createPiToolProxyDefinitions, resolvePiSessionToolNames, resolvePiSkillSources, validatePiSkillCatalog, validatePiSkillCommand };
|
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
createConfiguredFeishuBackgroundSessionDelivery,
|
|
22
22
|
createConfiguredFeishuCardRolloverRuntime,
|
|
23
23
|
createConfiguredFeishuHumanInteractionPresenter,
|
|
24
|
+
createConfiguredFeishuMessageReactionSender,
|
|
24
25
|
createConfiguredFeishuOpenApiClient,
|
|
25
26
|
createConfiguredFeishuTextReplySender,
|
|
26
27
|
createFeishuCotPublisher,
|
|
@@ -81,6 +82,7 @@ import {
|
|
|
81
82
|
type RivusThinkingLevel
|
|
82
83
|
} from "@rivus/agent";
|
|
83
84
|
import {
|
|
85
|
+
createPiBashTool,
|
|
84
86
|
createPiSkillReadTools,
|
|
85
87
|
createPiSessionResources,
|
|
86
88
|
createPiSkillRuntime,
|
|
@@ -437,9 +439,14 @@ export async function createRivusDeploymentAdapters(context: RivusDeploymentBoot
|
|
|
437
439
|
client: openApiClient,
|
|
438
440
|
config
|
|
439
441
|
});
|
|
442
|
+
const reactions = createConfiguredFeishuMessageReactionSender({
|
|
443
|
+
client: openApiClient,
|
|
444
|
+
config
|
|
445
|
+
});
|
|
440
446
|
const prepareCardTarget = (run: FeishuAgentRunPreparation) => cardRollover.prepareRun(run);
|
|
441
447
|
const endpoint = createFeishuDeploymentEndpoint({
|
|
442
448
|
agentId: input.agentId,
|
|
449
|
+
acknowledgeSteering: (messageId) => reactions.add(messageId),
|
|
443
450
|
botOpenId,
|
|
444
451
|
cardRollover: cardRollover.transport,
|
|
445
452
|
finalizeRun: (runId) => cardRollover.rollover.releaseRun(runId),
|
|
@@ -532,9 +539,19 @@ export async function createRivusDeploymentAdapters(context: RivusDeploymentBoot
|
|
|
532
539
|
const sessionRegistry = createPiSessionRegistry({
|
|
533
540
|
createSession: async (firstInput) => {
|
|
534
541
|
let activeInput = firstInput;
|
|
542
|
+
const resources = await createPiSessionResources({
|
|
543
|
+
agentDir: PI_AGENT_DIR,
|
|
544
|
+
appendSystemPromptOverride: () =>
|
|
545
|
+
[workspaceInstructions.content, skillRuntime.prompt].filter((content) => content.length > 0),
|
|
546
|
+
cwd: workingDirectory,
|
|
547
|
+
homeDirectory: homedir(),
|
|
548
|
+
...(input.projectSpace ? { projectSkillPaths: input.projectSpace.skillPaths } : {}),
|
|
549
|
+
systemPromptOverride: () => input.definition.systemPrompt
|
|
550
|
+
});
|
|
535
551
|
const managedContext =
|
|
536
552
|
management?.enabled && runContexts && input.definition.runtimeToolGrantSet.toolIds.includes("bash")
|
|
537
553
|
? createPiManagedSessionContext({
|
|
554
|
+
...(resources.bashToolOptions ? { bashToolOptions: resources.bashToolOptions } : {}),
|
|
538
555
|
binDirectory: management.binDirectory,
|
|
539
556
|
contexts: runContexts.registry,
|
|
540
557
|
cwd: workingDirectory,
|
|
@@ -542,17 +559,11 @@ export async function createRivusDeploymentAdapters(context: RivusDeploymentBoot
|
|
|
542
559
|
socketPath: management.socketPath
|
|
543
560
|
})
|
|
544
561
|
: undefined;
|
|
545
|
-
const
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
[workspaceInstructions.content, skillRuntime.prompt].filter((content) => content.length > 0),
|
|
549
|
-
cwd: workingDirectory,
|
|
550
|
-
homeDirectory: homedir(),
|
|
551
|
-
...(input.projectSpace ? { projectSkillPaths: input.projectSpace.skillPaths } : {}),
|
|
552
|
-
systemPromptOverride: () => input.definition.systemPrompt
|
|
553
|
-
});
|
|
562
|
+
const bashTool = input.definition.runtimeToolGrantSet.toolIds.includes("bash")
|
|
563
|
+
? (managedContext?.tool ?? createPiBashTool(workingDirectory, resources.bashToolOptions))
|
|
564
|
+
: undefined;
|
|
554
565
|
const customTools = [
|
|
555
|
-
...(
|
|
566
|
+
...(bashTool ? [bashTool] : []),
|
|
556
567
|
...createPiSkillReadTools({
|
|
557
568
|
cwd: workingDirectory,
|
|
558
569
|
runtimeToolIds: input.definition.runtimeToolGrantSet.toolIds,
|
|
@@ -570,7 +581,7 @@ export async function createRivusDeploymentAdapters(context: RivusDeploymentBoot
|
|
|
570
581
|
}),
|
|
571
582
|
...(skillRuntime.tool ? [skillRuntime.tool] : [])
|
|
572
583
|
];
|
|
573
|
-
const nativeToolIds =
|
|
584
|
+
const nativeToolIds = bashTool
|
|
574
585
|
? input.definition.runtimeToolGrantSet.toolIds.filter((toolId) => toolId !== "bash")
|
|
575
586
|
: input.definition.runtimeToolGrantSet.toolIds;
|
|
576
587
|
const activeToolNames = resolvePiSessionToolNames(nativeToolIds, customTools);
|
|
@@ -605,6 +616,7 @@ export async function createRivusDeploymentAdapters(context: RivusDeploymentBoot
|
|
|
605
616
|
? management.runtime.registerSessionRegistry(sessionRegistry)
|
|
606
617
|
: undefined;
|
|
607
618
|
const loop = createPiAgentLoop({
|
|
619
|
+
supportsSteering: true,
|
|
608
620
|
disposeSessionAfterRun: false,
|
|
609
621
|
...(management?.enabled ? { runBoundary: management.boundary } : {}),
|
|
610
622
|
...(telemetry ? { modelContentObserver: telemetry.modelContentObserver } : {}),
|