palmier 1.0.7 → 1.0.10

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/README.md CHANGED
@@ -79,6 +79,10 @@ Resources support MCP subscriptions — clients can subscribe via `resources/sub
79
79
 
80
80
  All device tools work while the Palmier Android app is in the background — they communicate via FCM data messages which wake the app's service even when it's not in the foreground. Each host has one **linked device**: the phone the host uses for SMS, contacts, location, and other device capabilities. Choose it at pair time (the "Link the host to this device" checkbox) or later from the drawer. Each capability must be enabled and its Android permission granted via toggles in the linked device's drawer.
81
81
 
82
+ ### Files in Agent Output
83
+
84
+ Agents run with the task's run directory (`~/palmier/tasks/<task-id>/<run-id>/`) as their working directory and are instructed to link any file they produce with a relative markdown link, e.g. `[View report](report.md)` or `![Chart](chart.png)`. The app opens these links over whichever transport is in use (local, relay, or auto-LAN). It fetches the file through the `task.file` RPC in 512 KiB chunks, so large files fit within the relay's message size. Markdown files render in-app, with their own relative links and images resolved from the file's location. Text and images are previewed, and other file types are offered as a browser download. The host only serves files whose real path (after resolving symlinks) is inside that task's directory, up to 25 MB. A run whose output links an existing file triggers a "report ready" push notification.
85
+
82
86
  ### Architecture
83
87
 
84
88
  ```
@@ -158,7 +162,7 @@ Revoking the linked device also clears the host's linked-device record; device c
158
162
 
159
163
  Palmier can store website passwords and PINs like a browser's password manager so agents can sign in to sites without ever seeing the credentials. When an agent driving a browser (via the `playwright-cli` skill) reaches a login or PIN field, it calls the `fill-password` tool with the page URL, the username, and the field's element ref. Palmier matches the saved secret by **origin**, fills it directly into the live browser session, and presses Enter to submit the form in the same step — so the plaintext secret sits on the page for as little time as possible and never enters the agent's context. If nothing is saved for that `(origin, username)`, Palmier prompts you in the app with a masked dialog. The dialog has a "Save for next time" checkbox (on by default): leave it checked to store the secret for reuse, or uncheck it to fill it just this once without saving. Either way it is filled into the page. The plaintext secret is never returned to the agent and is never written to task history.
160
164
 
161
- Saved passwords and PINs are encrypted at rest with AES-256-GCM under a host-local key, both stored in `~/.config/palmier/` (`passwords.enc` and `password-key`). Manage them from the host:
165
+ Saved passwords and PINs are encrypted at rest with AES-256-GCM under a host-local key, both stored in `~/.config/palmier/` (`passwords.enc` and `password-key`). Manage them from the app via **Manage saved passwords** in the side panel (lists origin and username only, with per-entry delete), or from the host CLI:
162
166
 
163
167
  ```bash
164
168
  # List saved passwords (origin and username only — never the password)
@@ -2,10 +2,14 @@ You are an AI agent executing a task on behalf of the user. Follow these instruc
2
2
 
3
3
  All `[PALMIER_*]` markers below are control signals parsed by the host. They MUST be written to **stdout** (not stderr). Markers on stderr are ignored.
4
4
 
5
- ## Reporting Output
6
-
7
- If you generate report or output files, print each file path on its own line to stdout using this exact format:
8
- [PALMIER_REPORT] <filename>
5
+ ## Linking Files
6
+
7
+ The user reads your output on a different device and can only open files you link. When you refer to a file you created (report, image, data export, etc.):
8
+ - Save it inside the current working directory (subdirectories are fine). Files anywhere else cannot be opened — copy them in first.
9
+ - Link it with a markdown link whose target is a path relative to the current working directory, e.g. `[View report](report.md)` or `[Raw data](exports/results.csv)`. Never use absolute paths or `file://` URLs.
10
+ - Embed images inline with `![description](chart.png)`.
11
+ - Avoid spaces in file names; if unavoidable, percent-encode them (`my%20report.md`).
12
+ - Inside markdown files you write, link other files relative to that markdown file.
9
13
 
10
14
  ## Completion
11
15
 
@@ -2,5 +2,4 @@ import type { ParsedTask } from "../types.js";
2
2
  export declare function getAgentInstructions(task: ParsedTask): string;
3
3
  export declare const TASK_SUCCESS_MARKER = "[PALMIER_TASK_SUCCESS]";
4
4
  export declare const TASK_FAILURE_MARKER = "[PALMIER_TASK_FAILURE]";
5
- export declare const TASK_REPORT_PREFIX = "[PALMIER_REPORT]";
6
5
  export declare const TASK_PERMISSION_PREFIX = "[PALMIER_PERMISSION]";
@@ -20,5 +20,4 @@ export function getAgentInstructions(task) {
20
20
  }
21
21
  export const TASK_SUCCESS_MARKER = "[PALMIER_TASK_SUCCESS]";
22
22
  export const TASK_FAILURE_MARKER = "[PALMIER_TASK_FAILURE]";
23
- export const TASK_REPORT_PREFIX = "[PALMIER_REPORT]";
24
23
  export const TASK_PERMISSION_PREFIX = "[PALMIER_PERMISSION]";
@@ -1,7 +1,8 @@
1
1
  import type { TaskRunningState, RequiredPermission } from "../types.js";
2
2
  export declare function stripPalmierMarkers(output: string): string;
3
3
  export declare function runCommand(taskId: string): Promise<void>;
4
- export declare function parseReportFiles(output: string): string[];
4
+ /** Only links to files that exist count, so example links echoed from the prompt are ignored. */
5
+ export declare function listLinkedTaskFiles(taskDir: string, runId: string, output: string): string[];
5
6
  export declare function parsePermissions(output: string): RequiredPermission[];
6
7
  /** Falls back to "finished" if no success/failure marker is found. */
7
8
  export declare function parseTaskOutcome(output: string): TaskRunningState;
@@ -6,7 +6,8 @@ import { connectNats } from "../nats-client.js";
6
6
  import { parseTaskFile, getTaskDir, writeTaskFile, writeTaskStatus, readTaskStatus, appendHistory, createRunDir, appendRunMessage, readRunMessages, getRunDir, beginStreamingMessage } from "../task.js";
7
7
  import { getAgent } from "../agents/agent.js";
8
8
  import { getPlatform } from "../platform/index.js";
9
- import { TASK_SUCCESS_MARKER, TASK_FAILURE_MARKER, TASK_REPORT_PREFIX, TASK_PERMISSION_PREFIX } from "../agents/shared-prompt.js";
9
+ import { TASK_SUCCESS_MARKER, TASK_FAILURE_MARKER, TASK_PERMISSION_PREFIX } from "../agents/shared-prompt.js";
10
+ import { extractFileLinks, resolveTaskFile } from "../task-files.js";
10
11
  import { publishHostEvent } from "../events.js";
11
12
  /**
12
13
  * Invoke the agent CLI in a continuation loop to handle permission requests.
@@ -68,7 +69,7 @@ async function invokeAgentWithRetries(ctx, invokeTask) {
68
69
  if (notifyTimer)
69
70
  clearTimeout(notifyTimer);
70
71
  const outcome = result.exitCode !== 0 ? "failed" : parseTaskOutcome(result.output);
71
- const reportFiles = parseReportFiles(result.output);
72
+ const linkedFiles = listLinkedTaskFiles(ctx.taskDir, ctx.runId, result.output);
72
73
  const requiredPermissions = parsePermissions(result.output);
73
74
  for (const stream of ["stdout", "stderr"]) {
74
75
  const trailing = lineBufs[stream];
@@ -80,19 +81,14 @@ async function invokeAgentWithRetries(ctx, invokeTask) {
80
81
  const permLines = requiredPermissions.map((p) => `- **${p.name}** ${p.description}`).join("\n");
81
82
  ensureWriter("stdout").write(`\n\n**Permissions requested:**\n${permLines}\n`);
82
83
  }
83
- if (reportFiles.length > 0) {
84
- ensureWriter("stdout").end(reportFiles);
85
- }
86
- else if (writer) {
87
- writer.end();
88
- }
84
+ writer?.end();
89
85
  await publishHostEvent(ctx.nc, ctx.config.hostId, ctx.taskId, { event_type: "result-updated", run_id: ctx.runId });
90
- if (reportFiles.length > 0) {
86
+ if (linkedFiles.length > 0) {
91
87
  await publishHostEvent(ctx.nc, ctx.config.hostId, ctx.taskId, {
92
88
  event_type: "report-generated",
93
89
  run_id: ctx.runId,
94
90
  name: ctx.task.frontmatter.name,
95
- report_files: reportFiles,
91
+ report_files: linkedFiles,
96
92
  });
97
93
  }
98
94
  if (requiredPermissions.length > 0) {
@@ -357,22 +353,17 @@ async function requestConfirmation(config, task, taskDir) {
357
353
  });
358
354
  return confirmed;
359
355
  }
360
- const ALLOWED_REPORT_EXT = [".md", ".txt", ".png", ".jpg", ".jpeg", ".gif", ".svg", ".webp"];
361
- export function parseReportFiles(output) {
362
- const regex = new RegExp(`^\\${TASK_REPORT_PREFIX}\\s+(.+)$`, "gm");
363
- const files = [];
364
- let match;
365
- while ((match = regex.exec(output)) !== null) {
366
- const name = match[1].trim();
367
- // Skip placeholder examples echoed from the prompt (e.g. "<filename>").
368
- if (!name || name.startsWith("<"))
369
- continue;
370
- const ext = name.lastIndexOf(".") >= 0 ? name.slice(name.lastIndexOf(".")).toLowerCase() : "";
371
- if (!ALLOWED_REPORT_EXT.includes(ext))
372
- continue;
373
- files.push(name);
374
- }
375
- return files;
356
+ /** Only links to files that exist count, so example links echoed from the prompt are ignored. */
357
+ export function listLinkedTaskFiles(taskDir, runId, output) {
358
+ return extractFileLinks(output).filter((file) => {
359
+ try {
360
+ resolveTaskFile(taskDir, runId, file);
361
+ return true;
362
+ }
363
+ catch {
364
+ return false;
365
+ }
366
+ });
376
367
  }
377
368
  export function parsePermissions(output) {
378
369
  const regex = new RegExp(`^\\${TASK_PERMISSION_PREFIX}\\s+(.+)$`, "gm");