palmier 0.9.13 → 0.9.14
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/agents/agent.d.ts +5 -0
- package/dist/agents/gemini.d.ts +1 -0
- package/dist/agents/gemini.js +21 -2
- package/dist/commands/run.js +8 -3
- package/dist/pwa/assets/{index-DFSlSj5y.js → index-rt6aPV6d.js} +12 -12
- package/dist/pwa/assets/{web-BwfTkkzQ.js → web-B66LN9cT.js} +1 -1
- package/dist/pwa/assets/{web-BVkTlDTB.js → web-BUi47bZi.js} +1 -1
- package/dist/pwa/assets/{web-BKHSN2Uj.js → web-DQOof3g6.js} +1 -1
- package/dist/pwa/index.html +1 -1
- package/dist/rpc-handler.js +8 -1
- package/package.json +1 -1
package/dist/agents/agent.d.ts
CHANGED
|
@@ -6,6 +6,11 @@ export interface CommandLine {
|
|
|
6
6
|
stdin?: string;
|
|
7
7
|
/** Additional environment variables to set for the spawned process. */
|
|
8
8
|
env?: Record<string, string>;
|
|
9
|
+
/** Files to write into the spawned process's cwd before invocation. Path is relative to cwd. */
|
|
10
|
+
files?: Array<{
|
|
11
|
+
path: string;
|
|
12
|
+
content: string;
|
|
13
|
+
}>;
|
|
9
14
|
}
|
|
10
15
|
export interface AgentTool {
|
|
11
16
|
/** Return the command and args for a short, non-interactive prompt (e.g. generating a task name). */
|
package/dist/agents/gemini.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ParsedTask, RequiredPermission } from "../types.js";
|
|
2
2
|
import type { AgentTool, CommandLine } from "./agent.js";
|
|
3
|
+
export declare function renderPolicyToml(allowedTools: string[]): string;
|
|
3
4
|
export declare class GeminiAgent implements AgentTool {
|
|
4
5
|
supportsPermissions: boolean;
|
|
5
6
|
supportsYolo: boolean;
|
package/dist/agents/gemini.js
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
import { execSync } from "child_process";
|
|
2
2
|
import { getAgentInstructions } from "./shared-prompt.js";
|
|
3
3
|
import { SHELL } from "../platform/index.js";
|
|
4
|
+
export function renderPolicyToml(allowedTools) {
|
|
5
|
+
const list = allowedTools.map((t) => JSON.stringify(t)).join(", ");
|
|
6
|
+
return [
|
|
7
|
+
"# Generated by Palmier — do not edit.",
|
|
8
|
+
"[[rule]]",
|
|
9
|
+
`toolName = [${list}]`,
|
|
10
|
+
`decision = "allow"`,
|
|
11
|
+
"priority = 100",
|
|
12
|
+
"",
|
|
13
|
+
"[[rule]]",
|
|
14
|
+
`toolName = "*"`,
|
|
15
|
+
`decision = "deny"`,
|
|
16
|
+
"priority = 1",
|
|
17
|
+
"",
|
|
18
|
+
].join("\n");
|
|
19
|
+
}
|
|
4
20
|
export class GeminiAgent {
|
|
5
21
|
supportsPermissions = true;
|
|
6
22
|
supportsYolo = true;
|
|
@@ -11,20 +27,23 @@ export class GeminiAgent {
|
|
|
11
27
|
const yolo = extraPermissions === "yolo";
|
|
12
28
|
const prompt = followupPrompt ?? getAgentInstructions(task, yolo || !this.supportsPermissions);
|
|
13
29
|
const args = ["--approval-mode", yolo ? "yolo" : "auto_edit"];
|
|
30
|
+
const files = [];
|
|
14
31
|
if (!yolo) {
|
|
15
32
|
const tools = ["run_shell_command", "web_fetch"];
|
|
16
33
|
const allPerms = [...(task.frontmatter.permissions ?? []), ...(extraPermissions ?? [])];
|
|
17
34
|
for (const p of allPerms) {
|
|
18
35
|
tools.push(p.name);
|
|
19
36
|
}
|
|
20
|
-
|
|
37
|
+
const policyPath = "gemini-policy.toml";
|
|
38
|
+
files.push({ path: policyPath, content: renderPolicyToml(tools) });
|
|
39
|
+
args.push("--admin-policy", policyPath);
|
|
21
40
|
}
|
|
22
41
|
if (followupPrompt) {
|
|
23
42
|
args.push("--resume");
|
|
24
43
|
}
|
|
25
44
|
// Read prompt from stdin to avoid command-line length limits.
|
|
26
45
|
args.push("--prompt", "-");
|
|
27
|
-
return { command: "gemini", args, stdin: prompt };
|
|
46
|
+
return { command: "gemini", args, stdin: prompt, ...(files.length > 0 ? { files } : {}) };
|
|
28
47
|
}
|
|
29
48
|
async init() {
|
|
30
49
|
try {
|
package/dist/commands/run.js
CHANGED
|
@@ -63,10 +63,15 @@ async function invokeAgentWithRetries(ctx, invokeTask) {
|
|
|
63
63
|
ensureWriter(stream).write(filtered.join("\n") + "\n");
|
|
64
64
|
throttledNotify();
|
|
65
65
|
}
|
|
66
|
-
const { command, args, stdin, env: agentEnv } = ctx.agent.getTaskRunCommandLine(invokeTask, undefined, ctx.task.frontmatter.yolo_mode ? "yolo" : ctx.transientPermissions);
|
|
66
|
+
const { command, args, stdin, env: agentEnv, files } = ctx.agent.getTaskRunCommandLine(invokeTask, undefined, ctx.task.frontmatter.yolo_mode ? "yolo" : ctx.transientPermissions);
|
|
67
|
+
const runDir = getRunDir(ctx.taskDir, ctx.runId);
|
|
68
|
+
if (files) {
|
|
69
|
+
for (const f of files)
|
|
70
|
+
fs.writeFileSync(path.join(runDir, f.path), f.content, "utf-8");
|
|
71
|
+
}
|
|
67
72
|
const result = await spawnCommand(command, args, {
|
|
68
|
-
cwd:
|
|
69
|
-
env: { ...ctx.guiEnv, ...agentEnv, PALMIER_RUN_DIR:
|
|
73
|
+
cwd: runDir,
|
|
74
|
+
env: { ...ctx.guiEnv, ...agentEnv, PALMIER_RUN_DIR: runDir, PALMIER_HTTP_PORT: String(ctx.config.httpPort ?? 7256) },
|
|
70
75
|
echoStdout: true,
|
|
71
76
|
resolveOnFailure: true,
|
|
72
77
|
stdin,
|