palmier 1.0.10 → 1.0.11

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
@@ -55,8 +55,8 @@ Palmier exposes an [MCP](https://modelcontextprotocol.io) server at `http://loca
55
55
  | Tool | Description |
56
56
  |------|-------------|
57
57
  | `notify` | Send a push notification to the user's device |
58
- | `request-input` | Request input from the user (blocks until response) |
59
- | `request-confirmation` | Request confirmation from the user (blocks until response) |
58
+ | `request-input` | Request input from the user (blocks until response; aborting the prompt aborts the task) |
59
+ | `request-confirmation` | Request confirmation from the user (blocks until response; aborting aborts the task) |
60
60
  | `fill-password` | Fill a saved password or PIN into the active browser session and submit the form, prompting the user if unknown (the secret is never revealed to the agent) |
61
61
  | `device-geolocation` | Get GPS location of the user's mobile device |
62
62
  | `read-contacts` | Read the contact list from the user's device |
@@ -10,6 +10,7 @@ export interface ToolContext {
10
10
  publishEvent: (id: string, payload: Record<string, unknown>) => Promise<void>;
11
11
  sessionId: string;
12
12
  agentName?: string;
13
+ abortTask: (taskId: string) => Promise<void>;
13
14
  }
14
15
  export interface ToolDefinition {
15
16
  name: string;
package/dist/mcp-tools.js CHANGED
@@ -95,6 +95,7 @@ const requestInputTool = {
95
95
  event_type: "input-resolved", host_id: ctx.config.hostId,
96
96
  session_id: ctx.sessionId, status: "aborted",
97
97
  });
98
+ await abortSessionTask(ctx);
98
99
  return { aborted: true };
99
100
  }
100
101
  await ctx.publishEvent("_input", {
@@ -123,7 +124,7 @@ function recordUserInputToRun(ctx, questions, response, aborted) {
123
124
  if (!runId)
124
125
  return;
125
126
  const content = aborted
126
- ? "Cancel"
127
+ ? "Aborted"
127
128
  : questions.map((q, i) => `**${q}**\n\n${response[i] ?? ""}`).join("\n\n");
128
129
  try {
129
130
  spliceUserMessage(taskDir, runId, {
@@ -138,6 +139,13 @@ function recordUserInputToRun(ctx, questions, response, aborted) {
138
139
  // Run file missing or unwritable — best-effort, do not fail the tool call.
139
140
  }
140
141
  }
142
+ /** No-op for pure MCP-protocol sessions, whose sessionId is a random UUID rather than a task. */
143
+ async function abortSessionTask(ctx) {
144
+ const taskId = ctx.sessionId;
145
+ if (!taskId || !fs.existsSync(getTaskDir(ctx.config.projectRoot, taskId)))
146
+ return;
147
+ await ctx.abortTask(taskId);
148
+ }
141
149
  const requestConfirmationTool = {
142
150
  name: "request-confirmation",
143
151
  description: [
@@ -176,6 +184,8 @@ const requestConfirmationTool = {
176
184
  session_id: ctx.sessionId,
177
185
  status: confirmed ? "confirmed" : "aborted",
178
186
  });
187
+ if (!confirmed)
188
+ await abortSessionTask(ctx);
179
189
  return { confirmed };
180
190
  },
181
191
  };
@@ -231,8 +241,10 @@ const fillPasswordTool = {
231
241
  session_id: ctx.sessionId, status: aborted ? "aborted" : "provided",
232
242
  });
233
243
  // Never record the secret to the task run file (unlike request-input).
234
- if (aborted)
244
+ if (aborted) {
245
+ await abortSessionTask(ctx);
235
246
  return { aborted: true };
247
+ }
236
248
  password = response[0];
237
249
  // The PWA appends a "save"/"nosave" flag for password prompts; persist
238
250
  // unless the user opted out via the dialog's checkbox.