palmier 0.9.27 → 0.9.29
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/command-runners.d.ts +20 -0
- package/dist/command-runners.js +114 -0
- package/dist/commands/run.js +24 -185
- package/dist/commands/serve.js +6 -7
- package/dist/event-queues.d.ts +10 -2
- package/dist/event-queues.js +17 -2
- package/dist/pwa/assets/index-6T1kYgQ7.js +120 -0
- package/dist/pwa/assets/{web-CUvlxJZT.js → web-B_QZ1Xz7.js} +1 -1
- package/dist/pwa/assets/{web-DwDstsPq.js → web-C7WZtjWG.js} +1 -1
- package/dist/pwa/assets/{web-BKAJDrnk.js → web-CwAQf0-V.js} +1 -1
- package/dist/pwa/index.html +1 -1
- package/dist/rpc-handler.js +6 -0
- package/dist/trigger-dispatch.d.ts +14 -0
- package/dist/trigger-dispatch.js +51 -0
- package/package.json +1 -1
- package/dist/pwa/assets/index-D6UTaQKv.js +0 -120
|
@@ -1 +1 @@
|
|
|
1
|
-
import{W as t}from"./index-
|
|
1
|
+
import{W as t}from"./index-6T1kYgQ7.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 +1 @@
|
|
|
1
|
-
import{W as i}from"./index-
|
|
1
|
+
import{W as i}from"./index-6T1kYgQ7.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 p}from"./index-
|
|
1
|
+
import{W as p}from"./index-6T1kYgQ7.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};
|
package/dist/pwa/index.html
CHANGED
|
@@ -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="Run tasks from anywhere, approve actions on the go, and let your agents use your phone’s built-in capabilities when needed." />
|
|
11
|
-
<script type="module" crossorigin src="/assets/index-
|
|
11
|
+
<script type="module" crossorigin src="/assets/index-6T1kYgQ7.js"></script>
|
|
12
12
|
<link rel="stylesheet" crossorigin href="/assets/index-BpsVmTp9.css">
|
|
13
13
|
<link rel="manifest" href="/manifest.webmanifest"><script id="vite-plugin-pwa:register-sw" src="/registerSW.js"></script></head>
|
|
14
14
|
<body>
|
package/dist/rpc-handler.js
CHANGED
|
@@ -14,6 +14,7 @@ import { currentVersion, performUpdate, performAgentUpdate } from "./update-chec
|
|
|
14
14
|
import { saveConfig } from "./config.js";
|
|
15
15
|
import { parseReportFiles, parseTaskOutcome, stripPalmierMarkers } from "./commands/run.js";
|
|
16
16
|
import { clearTaskQueue } from "./event-queues.js";
|
|
17
|
+
import { reconcileCommandRunner, stopCommandRunner } from "./command-runners.js";
|
|
17
18
|
import { buildLanUrl } from "./network.js";
|
|
18
19
|
export function parseResultFrontmatter(raw) {
|
|
19
20
|
const fmMatch = raw.match(/^---\n([\s\S]*?)\n---\n([\s\S]*)$/);
|
|
@@ -232,6 +233,7 @@ export function createRpcHandler(config, nc) {
|
|
|
232
233
|
writeTaskFile(taskDir, task);
|
|
233
234
|
appendTaskList(config.projectRoot, id);
|
|
234
235
|
getPlatform().installTaskTimer(config, task);
|
|
236
|
+
reconcileCommandRunner(config, task);
|
|
235
237
|
return flattenTask(task);
|
|
236
238
|
}
|
|
237
239
|
case "task.update": {
|
|
@@ -291,11 +293,14 @@ export function createRpcHandler(config, nc) {
|
|
|
291
293
|
// installTaskTimer overwrites in-place (schtasks /f, systemd unit rewrite)
|
|
292
294
|
// without killing a running task process.
|
|
293
295
|
getPlatform().installTaskTimer(config, existing);
|
|
296
|
+
// Start/stop/restart the command process to match the new enabled state.
|
|
297
|
+
reconcileCommandRunner(config, existing);
|
|
294
298
|
return flattenTask(existing);
|
|
295
299
|
}
|
|
296
300
|
case "task.delete": {
|
|
297
301
|
const params = request.params;
|
|
298
302
|
getPlatform().removeTaskTimer(params.id);
|
|
303
|
+
stopCommandRunner(params.id);
|
|
299
304
|
clearTaskQueue(params.id);
|
|
300
305
|
removeFromTaskList(config.projectRoot, params.id);
|
|
301
306
|
return { ok: true, task_id: params.id };
|
|
@@ -629,6 +634,7 @@ export function createRpcHandler(config, nc) {
|
|
|
629
634
|
getPlatform().removeTaskTimer(params.task_id);
|
|
630
635
|
}
|
|
631
636
|
catch { /* best-effort */ }
|
|
637
|
+
stopCommandRunner(params.task_id);
|
|
632
638
|
clearTaskQueue(params.task_id);
|
|
633
639
|
try {
|
|
634
640
|
fs.rmSync(deleteTaskDir, { recursive: true, force: true });
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared entry point for trigger-driven tasks (on_new_* device events and
|
|
3
|
+
* command-output lines): enqueue the payload, launch a run on the idle→active
|
|
4
|
+
* edge, and run a self-healing watchdog.
|
|
5
|
+
*
|
|
6
|
+
* Why the watchdog: the per-task active flag is cleared on the empty pop while
|
|
7
|
+
* the previous run is still tearing down (its OS unit still "active"). A
|
|
8
|
+
* trigger landing in that window re-sets the flag but its `startTask` no-ops on
|
|
9
|
+
* the still-active unit, stranding the queued payload forever. The watchdog
|
|
10
|
+
* detects "work queued but no live run" shortly after triggers quiesce and
|
|
11
|
+
* relaunches. High-frequency sources (commands) would otherwise wedge fast.
|
|
12
|
+
*/
|
|
13
|
+
/** Enqueue a trigger payload and ensure a run is (or will be) draining it. */
|
|
14
|
+
export declare function dispatchTrigger(taskId: string, payload: string): void;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared entry point for trigger-driven tasks (on_new_* device events and
|
|
3
|
+
* command-output lines): enqueue the payload, launch a run on the idle→active
|
|
4
|
+
* edge, and run a self-healing watchdog.
|
|
5
|
+
*
|
|
6
|
+
* Why the watchdog: the per-task active flag is cleared on the empty pop while
|
|
7
|
+
* the previous run is still tearing down (its OS unit still "active"). A
|
|
8
|
+
* trigger landing in that window re-sets the flag but its `startTask` no-ops on
|
|
9
|
+
* the still-active unit, stranding the queued payload forever. The watchdog
|
|
10
|
+
* detects "work queued but no live run" shortly after triggers quiesce and
|
|
11
|
+
* relaunches. High-frequency sources (commands) would otherwise wedge fast.
|
|
12
|
+
*/
|
|
13
|
+
import { enqueueEvent, hasPendingEvents, resetActiveRun, markActiveRun } from "./event-queues.js";
|
|
14
|
+
import { getPlatform } from "./platform/index.js";
|
|
15
|
+
const WATCHDOG_MS = 3000;
|
|
16
|
+
const watchdogs = new Map();
|
|
17
|
+
function startRun(taskId) {
|
|
18
|
+
getPlatform().startTask(taskId).catch((err) => {
|
|
19
|
+
console.error(`[trigger] failed to start run for ${taskId}:`, err);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
function armWatchdog(taskId) {
|
|
23
|
+
const existing = watchdogs.get(taskId);
|
|
24
|
+
if (existing)
|
|
25
|
+
clearTimeout(existing);
|
|
26
|
+
watchdogs.set(taskId, setTimeout(() => watchdogTick(taskId), WATCHDOG_MS));
|
|
27
|
+
}
|
|
28
|
+
function watchdogTick(taskId) {
|
|
29
|
+
watchdogs.delete(taskId);
|
|
30
|
+
if (!hasPendingEvents(taskId))
|
|
31
|
+
return;
|
|
32
|
+
// A run is mid-flight and will drain the queue — check again later.
|
|
33
|
+
if (getPlatform().isTaskRunning(taskId)) {
|
|
34
|
+
armWatchdog(taskId);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
console.warn(`[trigger] ${taskId} has queued work but no running task; relaunching`);
|
|
38
|
+
resetActiveRun(taskId);
|
|
39
|
+
markActiveRun(taskId);
|
|
40
|
+
startRun(taskId);
|
|
41
|
+
// Keep watching: if this relaunch also fails to take (e.g. HTTP not yet up),
|
|
42
|
+
// the next tick retries until the queue actually drains.
|
|
43
|
+
armWatchdog(taskId);
|
|
44
|
+
}
|
|
45
|
+
/** Enqueue a trigger payload and ensure a run is (or will be) draining it. */
|
|
46
|
+
export function dispatchTrigger(taskId, payload) {
|
|
47
|
+
const { shouldStart } = enqueueEvent(taskId, payload);
|
|
48
|
+
if (shouldStart)
|
|
49
|
+
startRun(taskId);
|
|
50
|
+
armWatchdog(taskId);
|
|
51
|
+
}
|