arisa 4.0.22 → 4.1.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/AGENTS.md +33 -58
- package/README.md +6 -4
- package/package.json +1 -1
- package/src/core/agent/agent-manager.js +69 -12
- package/src/core/agent/core-tools.js +139 -0
- package/src/core/agent/runtime-context.js +14 -3
- package/src/core/agent/system-shell-tool.js +207 -0
- package/src/index.js +44 -10
- package/src/runtime/bootstrap.js +412 -36
- package/src/runtime/create-app.js +52 -9
- package/src/transport/telegram/bot.js +4 -3
- package/test/agent-tool-policy.test.js +91 -0
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { mkdtemp, realpath } from "node:fs/promises";
|
|
3
|
+
import os from "node:os";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import test from "node:test";
|
|
6
|
+
import { buildPiToolPolicy } from "../src/core/agent/core-tools.js";
|
|
7
|
+
import { createSystemShellTool } from "../src/core/agent/system-shell-tool.js";
|
|
8
|
+
import { applyRuntimeOverrides } from "../src/runtime/create-app.js";
|
|
9
|
+
import { arisaHomeDir } from "../src/runtime/paths.js";
|
|
10
|
+
|
|
11
|
+
test("builds default Pi tool policy for the Arisa home workspace", () => {
|
|
12
|
+
const policy = buildPiToolPolicy({ config: { pi: {} } });
|
|
13
|
+
|
|
14
|
+
assert.equal(policy.workspaceDir, path.resolve(arisaHomeDir));
|
|
15
|
+
assert.equal(policy.tools, undefined);
|
|
16
|
+
assert.equal(policy.excludeTools, undefined);
|
|
17
|
+
assert.deepEqual(
|
|
18
|
+
policy.coreTools.filter((tool) => tool.enabled).map((tool) => tool.name),
|
|
19
|
+
["read", "bash", "edit", "write"]
|
|
20
|
+
);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test("keeps Arisa custom tools available when pi.tools is configured", () => {
|
|
24
|
+
const policy = buildPiToolPolicy({
|
|
25
|
+
config: {
|
|
26
|
+
pi: {
|
|
27
|
+
tools: "read,bash",
|
|
28
|
+
excludeTools: "bash",
|
|
29
|
+
workspaceDir: "~/arisa-workspace",
|
|
30
|
+
shellTimeoutMs: "120000"
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
customToolNames: ["run_tool", "system_shell"]
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
assert.deepEqual(policy.tools, ["read", "bash", "run_tool", "system_shell"]);
|
|
37
|
+
assert.deepEqual(policy.excludeTools, ["bash"]);
|
|
38
|
+
assert.equal(policy.shell.timeoutMs, 120000);
|
|
39
|
+
assert.equal(policy.workspaceDir, path.join(os.homedir(), "arisa-workspace"));
|
|
40
|
+
assert.deepEqual(
|
|
41
|
+
policy.coreTools.filter((tool) => tool.enabled).map((tool) => tool.name),
|
|
42
|
+
["read"]
|
|
43
|
+
);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
test("applies runtime overrides without dropping persisted Pi config", () => {
|
|
47
|
+
const config = {
|
|
48
|
+
telegram: { token: "token" },
|
|
49
|
+
pi: {
|
|
50
|
+
provider: "openai-codex",
|
|
51
|
+
model: "gpt-5.5",
|
|
52
|
+
apiKey: "persisted"
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const next = applyRuntimeOverrides(config, {
|
|
57
|
+
pi: {
|
|
58
|
+
model: "anthropic/claude-opus-4-5",
|
|
59
|
+
workspaceDir: "/tmp/arisa",
|
|
60
|
+
tools: "read,bash",
|
|
61
|
+
excludeTools: "write",
|
|
62
|
+
shellTimeoutMs: "90000"
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
assert.equal(next.pi.provider, "anthropic");
|
|
67
|
+
assert.equal(next.pi.model, "claude-opus-4-5");
|
|
68
|
+
assert.equal(next.pi.apiKey, "persisted");
|
|
69
|
+
assert.equal(next.pi.workspaceDir, "/tmp/arisa");
|
|
70
|
+
assert.deepEqual(next.pi.tools, ["read", "bash"]);
|
|
71
|
+
assert.deepEqual(next.pi.excludeTools, ["write"]);
|
|
72
|
+
assert.equal(next.pi.shellTimeoutMs, 90000);
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
test("system_shell runs commands from the configured workspace", async () => {
|
|
76
|
+
const workspaceDir = await mkdtemp(path.join(os.tmpdir(), "arisa-shell-"));
|
|
77
|
+
const tool = createSystemShellTool({
|
|
78
|
+
workspaceDir,
|
|
79
|
+
shell: { timeoutMs: 10_000 }
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
const result = await tool.execute("call-1", {
|
|
83
|
+
command: "node -e \"process.stdout.write(process.cwd())\""
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
const realWorkspaceDir = await realpath(workspaceDir);
|
|
87
|
+
assert.equal(result.isError, false);
|
|
88
|
+
assert.equal(result.details.cwd, workspaceDir);
|
|
89
|
+
assert.equal(result.details.exitCode, 0);
|
|
90
|
+
assert.equal(result.details.stdout, realWorkspaceDir);
|
|
91
|
+
});
|