palmier 1.1.19 → 1.1.21

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.
@@ -1 +1 @@
1
- import{W as p}from"./index-DztP_wQC.js";class f extends p{constructor(){super(...arguments),this.group="CapacitorStorage"}async configure({group:e}){typeof e=="string"&&(this.group=e)}async get(e){return{value:this.impl.getItem(this.applyPrefix(e.key))}}async set(e){this.impl.setItem(this.applyPrefix(e.key),e.value)}async remove(e){this.impl.removeItem(this.applyPrefix(e.key))}async keys(){return{keys:this.rawKeys().map(t=>t.substring(this.prefix.length))}}async clear(){for(const e of this.rawKeys())this.impl.removeItem(e)}async migrate(){var e;const t=[],s=[],n="_cap_",o=Object.keys(this.impl).filter(i=>i.indexOf(n)===0);for(const i of o){const r=i.substring(n.length),a=(e=this.impl.getItem(i))!==null&&e!==void 0?e:"",{value:l}=await this.get({key:r});typeof l=="string"?s.push(r):(await this.set({key:r,value:a}),t.push(r))}return{migrated:t,existing:s}}async removeOld(){const e="_cap_",t=Object.keys(this.impl).filter(s=>s.indexOf(e)===0);for(const s of t)this.impl.removeItem(s)}get impl(){return window.localStorage}get prefix(){return this.group==="NativeStorage"?"":`${this.group}.`}rawKeys(){return Object.keys(this.impl).filter(e=>e.indexOf(this.prefix)===0)}applyPrefix(e){return this.prefix+e}}export{f as PreferencesWeb};
1
+ import{W as p}from"./index-rqAuAC0q.js";class f extends p{constructor(){super(...arguments),this.group="CapacitorStorage"}async configure({group:e}){typeof e=="string"&&(this.group=e)}async get(e){return{value:this.impl.getItem(this.applyPrefix(e.key))}}async set(e){this.impl.setItem(this.applyPrefix(e.key),e.value)}async remove(e){this.impl.removeItem(this.applyPrefix(e.key))}async keys(){return{keys:this.rawKeys().map(t=>t.substring(this.prefix.length))}}async clear(){for(const e of this.rawKeys())this.impl.removeItem(e)}async migrate(){var e;const t=[],s=[],n="_cap_",o=Object.keys(this.impl).filter(i=>i.indexOf(n)===0);for(const i of o){const r=i.substring(n.length),a=(e=this.impl.getItem(i))!==null&&e!==void 0?e:"",{value:l}=await this.get({key:r});typeof l=="string"?s.push(r):(await this.set({key:r,value:a}),t.push(r))}return{migrated:t,existing:s}}async removeOld(){const e="_cap_",t=Object.keys(this.impl).filter(s=>s.indexOf(e)===0);for(const s of t)this.impl.removeItem(s)}get impl(){return window.localStorage}get prefix(){return this.group==="NativeStorage"?"":`${this.group}.`}rawKeys(){return Object.keys(this.impl).filter(e=>e.indexOf(this.prefix)===0)}applyPrefix(e){return this.prefix+e}}export{f as PreferencesWeb};
@@ -1 +1 @@
1
- import{W as i}from"./index-DztP_wQC.js";function o(){const t=window.navigator.connection||window.navigator.mozConnection||window.navigator.webkitConnection;let n="unknown";const e=t?t.type||t.effectiveType:null;if(e&&typeof e=="string")switch(e){case"bluetooth":case"cellular":n="cellular";break;case"none":n="none";break;case"ethernet":case"wifi":case"wimax":n="wifi";break;case"other":case"unknown":n="unknown";break;case"slow-2g":case"2g":case"3g":n="cellular";break;case"4g":n="wifi";break}return n}class s extends i{constructor(){super(),this.handleOnline=()=>{const e={connected:!0,connectionType:o()};this.notifyListeners("networkStatusChange",e)},this.handleOffline=()=>{const n={connected:!1,connectionType:"none"};this.notifyListeners("networkStatusChange",n)},typeof window<"u"&&(window.addEventListener("online",this.handleOnline),window.addEventListener("offline",this.handleOffline))}async getStatus(){if(!window.navigator)throw this.unavailable("Browser does not support the Network Information API");const n=window.navigator.onLine,e=o();return{connected:n,connectionType:n?e:"none"}}}const r=new s;export{r as Network,s as NetworkWeb};
1
+ import{W as i}from"./index-rqAuAC0q.js";function o(){const t=window.navigator.connection||window.navigator.mozConnection||window.navigator.webkitConnection;let n="unknown";const e=t?t.type||t.effectiveType:null;if(e&&typeof e=="string")switch(e){case"bluetooth":case"cellular":n="cellular";break;case"none":n="none";break;case"ethernet":case"wifi":case"wimax":n="wifi";break;case"other":case"unknown":n="unknown";break;case"slow-2g":case"2g":case"3g":n="cellular";break;case"4g":n="wifi";break}return n}class s extends i{constructor(){super(),this.handleOnline=()=>{const e={connected:!0,connectionType:o()};this.notifyListeners("networkStatusChange",e)},this.handleOffline=()=>{const n={connected:!1,connectionType:"none"};this.notifyListeners("networkStatusChange",n)},typeof window<"u"&&(window.addEventListener("online",this.handleOnline),window.addEventListener("offline",this.handleOffline))}async getStatus(){if(!window.navigator)throw this.unavailable("Browser does not support the Network Information API");const n=window.navigator.onLine,e=o();return{connected:n,connectionType:n?e:"none"}}}const r=new s;export{r as Network,s as NetworkWeb};
@@ -1 +1 @@
1
- import{W as t}from"./index-DztP_wQC.js";class s extends t{constructor(){super(),this.handleVisibilityChange=()=>{const e={isActive:document.hidden!==!0};this.notifyListeners("appStateChange",e),document.hidden?this.notifyListeners("pause",null):this.notifyListeners("resume",null)},document.addEventListener("visibilitychange",this.handleVisibilityChange,!1)}exitApp(){throw this.unimplemented("Not implemented on web.")}async getInfo(){throw this.unimplemented("Not implemented on web.")}async getLaunchUrl(){return{url:""}}async getState(){return{isActive:document.hidden!==!0}}async minimizeApp(){throw this.unimplemented("Not implemented on web.")}async toggleBackButtonHandler(){throw this.unimplemented("Not implemented on web.")}async getAppLanguage(){return{value:navigator.language.split("-")[0].toLowerCase()}}}export{s as AppWeb};
1
+ import{W as t}from"./index-rqAuAC0q.js";class s extends t{constructor(){super(),this.handleVisibilityChange=()=>{const e={isActive:document.hidden!==!0};this.notifyListeners("appStateChange",e),document.hidden?this.notifyListeners("pause",null):this.notifyListeners("resume",null)},document.addEventListener("visibilitychange",this.handleVisibilityChange,!1)}exitApp(){throw this.unimplemented("Not implemented on web.")}async getInfo(){throw this.unimplemented("Not implemented on web.")}async getLaunchUrl(){return{url:""}}async getState(){return{isActive:document.hidden!==!0}}async minimizeApp(){throw this.unimplemented("Not implemented on web.")}async toggleBackButtonHandler(){throw this.unimplemented("Not implemented on web.")}async getAppLanguage(){return{value:navigator.language.split("-")[0].toLowerCase()}}}export{s as AppWeb};
@@ -8,7 +8,7 @@
8
8
  <link rel="apple-touch-icon" href="/apple-touch-icon.png" />
9
9
  <title>Palmier</title>
10
10
  <meta name="description" content="Your personal AI agent runs on your own computer, with local data and credential storage. Use your existing AI subscription and connect your calendar, contacts, notifications, and more." />
11
- <script type="module" crossorigin src="/assets/index-DztP_wQC.js"></script>
11
+ <script type="module" crossorigin src="/assets/index-rqAuAC0q.js"></script>
12
12
  <link rel="stylesheet" crossorigin href="/assets/index-ByB7B0d2.css">
13
13
  <link rel="manifest" href="/manifest.webmanifest"><script id="vite-plugin-pwa:register-sw" src="/registerSW.js"></script></head>
14
14
  <body>
@@ -1,4 +1,3 @@
1
- import { type NatsConnection } from "nats";
2
1
  import type { HostConfig, RpcMessage } from "./types.js";
3
2
  export declare function parseResultFrontmatter(raw: string): Record<string, unknown>;
4
- export declare function createRpcHandler(config: HostConfig, nc?: NatsConnection): (request: RpcMessage) => Promise<unknown>;
3
+ export declare function createRpcHandler(config: HostConfig): (request: RpcMessage) => Promise<unknown>;
@@ -184,15 +184,13 @@ async function killActiveFollowup(projectRoot, taskId, runId) {
184
184
  * The run process never started, so write a `started` + `failed` status pair
185
185
  * directly to TASKRUN.md (run.ts normally does this) and notify clients.
186
186
  */
187
- async function recordStartFailure(taskDir, taskId, runId, detail, ctx) {
187
+ async function recordStartFailure(taskDir, taskId, runId, detail) {
188
188
  const now = Date.now();
189
189
  appendRunMessage(taskDir, runId, { role: "status", time: now, content: "", type: "started" });
190
190
  appendRunMessage(taskDir, runId, { role: "status", time: now, content: detail, type: "failed" });
191
- if (ctx?.nc) {
192
- await publishHostEvent(ctx.nc, ctx.hostId, taskId, { event_type: "result-updated", run_id: runId });
193
- }
191
+ await publishHostEvent(taskId, { event_type: "result-updated", run_id: runId });
194
192
  }
195
- export function createRpcHandler(config, nc) {
193
+ export function createRpcHandler(config) {
196
194
  function flattenTask(task) {
197
195
  const taskDir = getTaskDir(config.projectRoot, task.frontmatter.id);
198
196
  const status = readTaskStatus(taskDir);
@@ -376,7 +374,7 @@ export function createRpcHandler(config, nc) {
376
374
  catch (err) {
377
375
  const e = err;
378
376
  const detail = (e.stderr || e.message || String(err)).trim();
379
- await recordStartFailure(taskDir, id, runId, detail, { nc, hostId: config.hostId });
377
+ await recordStartFailure(taskDir, id, runId, detail);
380
378
  return { error: `Failed to start task: ${detail}` };
381
379
  }
382
380
  return { ok: true, task_id: id, run_id: runId };
@@ -403,7 +401,7 @@ export function createRpcHandler(config, nc) {
403
401
  const detail = (e.stderr || e.message || String(err)).trim();
404
402
  console.error(`task.run failed for ${params.id}: ${detail}`);
405
403
  if (taskRunId)
406
- await recordStartFailure(runTaskDir, params.id, taskRunId, detail, { nc, hostId: config.hostId });
404
+ await recordStartFailure(runTaskDir, params.id, taskRunId, detail);
407
405
  return { error: `Failed to start task: ${detail}` };
408
406
  }
409
407
  }
@@ -431,8 +429,8 @@ export function createRpcHandler(config, nc) {
431
429
  type: "started",
432
430
  });
433
431
  writeTaskStatus(followupTaskDir, { running_state: "started", time_stamp: Date.now() });
434
- await publishHostEvent(nc, config.hostId, params.id, { event_type: "result-updated", run_id: params.run_id });
435
- await publishHostEvent(nc, config.hostId, params.id, {
432
+ await publishHostEvent(params.id, { event_type: "result-updated", run_id: params.run_id });
433
+ await publishHostEvent(params.id, {
436
434
  event_type: "running-state", running_state: "started",
437
435
  name: taskDisplayName(followupTask.frontmatter), run_id: params.run_id,
438
436
  });
@@ -484,8 +482,8 @@ export function createRpcHandler(config, nc) {
484
482
  type: outcome,
485
483
  });
486
484
  writeTaskStatus(followupTaskDir, { running_state: outcome, time_stamp: Date.now() });
487
- await publishHostEvent(nc, config.hostId, params.id, { event_type: "result-updated", run_id: params.run_id });
488
- await publishHostEvent(nc, config.hostId, params.id, {
485
+ await publishHostEvent(params.id, { event_type: "result-updated", run_id: params.run_id });
486
+ await publishHostEvent(params.id, {
489
487
  event_type: "running-state", running_state: outcome,
490
488
  name: taskDisplayName(followupTask.frontmatter), run_id: params.run_id,
491
489
  });
@@ -501,8 +499,8 @@ export function createRpcHandler(config, nc) {
501
499
  type: "failed",
502
500
  });
503
501
  writeTaskStatus(followupTaskDir, { running_state: "failed", time_stamp: Date.now() });
504
- await publishHostEvent(nc, config.hostId, params.id, { event_type: "result-updated", run_id: params.run_id });
505
- await publishHostEvent(nc, config.hostId, params.id, {
502
+ await publishHostEvent(params.id, { event_type: "result-updated", run_id: params.run_id });
503
+ await publishHostEvent(params.id, {
506
504
  event_type: "running-state", running_state: "failed",
507
505
  name: taskDisplayName(followupTask.frontmatter), run_id: params.run_id,
508
506
  });
@@ -571,7 +569,7 @@ export function createRpcHandler(config, nc) {
571
569
  }
572
570
  catch { /* best-effort cleanup */ }
573
571
  const abortPayload = { event_type: "running-state", running_state: "aborted" };
574
- await publishHostEvent(nc, config.hostId, params.id, abortPayload);
572
+ await publishHostEvent(params.id, abortPayload);
575
573
  return { ok: true, task_id: params.id };
576
574
  }
577
575
  case "task.status": {
@@ -1,3 +1,3 @@
1
1
  import { type NatsConnection } from "nats";
2
2
  import type { HostConfig, RpcMessage } from "../types.js";
3
- export declare function startHttpTransport(config: HostConfig, handleRpc: (req: RpcMessage) => Promise<unknown>, port: number, nc: NatsConnection | undefined, pairingCode?: string, onReady?: () => void): Promise<void>;
3
+ export declare function startHttpTransport(config: HostConfig, handleRpc: (req: RpcMessage) => Promise<unknown>, port: number, getNc: () => NatsConnection | undefined, pairingCode?: string, onReady?: () => void): Promise<void>;
@@ -61,7 +61,7 @@ async function persistDefaultInterface(config) {
61
61
  saveConfig(config);
62
62
  }
63
63
  }
64
- export async function startHttpTransport(config, handleRpc, port, nc, pairingCode, onReady) {
64
+ export async function startHttpTransport(config, handleRpc, port, getNc, pairingCode, onReady) {
65
65
  const sseClients = new Set();
66
66
  // Always bind 0.0.0.0 so other devices on the LAN can reach /rpc and /health.
67
67
  // The web UI, /pair, and /events are individually gated to loopback.
@@ -108,14 +108,12 @@ export async function startHttpTransport(config, handleRpc, port, nc, pairingCod
108
108
  async function publishEvent(taskId, payload) {
109
109
  const sc = StringCodec();
110
110
  const subject = `host-event.${config.hostId}.${taskId}`;
111
- if (nc) {
112
- nc.publish(subject, sc.encode(JSON.stringify(payload)));
113
- }
111
+ getNc()?.publish(subject, sc.encode(JSON.stringify(payload)));
114
112
  broadcastSseEvent({ task_id: taskId, ...payload });
115
113
  }
116
114
  function makeToolContext(taskId) {
117
115
  return {
118
- config, nc, publishEvent, taskId,
116
+ config, nc: getNc(), publishEvent, taskId,
119
117
  abortTask: async () => { await handleRpc({ method: "task.abort", params: { id: taskId }, localhost: true }); },
120
118
  };
121
119
  }
@@ -205,8 +203,8 @@ export async function startHttpTransport(config, handleRpc, port, nc, pairingCod
205
203
  }
206
204
  try {
207
205
  const body = await readBody(req);
208
- const event = JSON.parse(body);
209
- broadcastSseEvent(event);
206
+ const { task_id: taskId, ...payload } = JSON.parse(body);
207
+ await publishEvent(taskId, payload);
210
208
  sendJson(res, 200, { ok: true });
211
209
  }
212
210
  catch {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "palmier",
3
- "version": "1.1.19",
3
+ "version": "1.1.21",
4
4
  "description": "Palmier host CLI - provisions, executes tasks, and serves NATS RPC",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Hongxu Cai",