palmier 0.9.6 → 0.9.7
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 +28 -13
- package/dist/agents/agent.d.ts +0 -1
- package/dist/agents/agent.js +0 -1
- package/dist/agents/aider.d.ts +0 -1
- package/dist/agents/aider.js +0 -1
- package/dist/agents/claude.d.ts +0 -1
- package/dist/agents/claude.js +0 -1
- package/dist/agents/cline.d.ts +0 -1
- package/dist/agents/cline.js +0 -1
- package/dist/agents/codex.d.ts +0 -1
- package/dist/agents/codex.js +0 -1
- package/dist/agents/copilot.d.ts +0 -1
- package/dist/agents/copilot.js +0 -1
- package/dist/agents/cursor.d.ts +0 -1
- package/dist/agents/cursor.js +0 -1
- package/dist/agents/deepagents.d.ts +0 -1
- package/dist/agents/deepagents.js +0 -1
- package/dist/agents/droid.d.ts +0 -1
- package/dist/agents/droid.js +0 -1
- package/dist/agents/gemini.d.ts +0 -1
- package/dist/agents/gemini.js +0 -1
- package/dist/agents/goose.d.ts +0 -1
- package/dist/agents/goose.js +0 -1
- package/dist/agents/hermes.d.ts +0 -1
- package/dist/agents/hermes.js +0 -1
- package/dist/agents/kimi.d.ts +0 -1
- package/dist/agents/kimi.js +0 -1
- package/dist/agents/kiro.d.ts +0 -1
- package/dist/agents/kiro.js +0 -1
- package/dist/agents/openclaw.d.ts +0 -1
- package/dist/agents/openclaw.js +0 -1
- package/dist/agents/opencode.d.ts +0 -1
- package/dist/agents/opencode.js +0 -1
- package/dist/agents/qoder.d.ts +0 -1
- package/dist/agents/qoder.js +0 -1
- package/dist/agents/qwen.d.ts +0 -1
- package/dist/agents/qwen.js +0 -1
- package/dist/agents/shared-prompt.d.ts +0 -1
- package/dist/agents/shared-prompt.js +0 -1
- package/dist/client-store.d.ts +0 -1
- package/dist/client-store.js +0 -1
- package/dist/commands/clients.d.ts +0 -1
- package/dist/commands/clients.js +0 -1
- package/dist/commands/info.d.ts +0 -1
- package/dist/commands/info.js +0 -1
- package/dist/commands/init.d.ts +0 -1
- package/dist/commands/init.js +1 -2
- package/dist/commands/pair.d.ts +0 -1
- package/dist/commands/pair.js +0 -1
- package/dist/commands/restart.d.ts +0 -1
- package/dist/commands/restart.js +0 -1
- package/dist/commands/run.d.ts +0 -1
- package/dist/commands/run.js +0 -1
- package/dist/commands/serve.d.ts +0 -1
- package/dist/commands/serve.js +0 -1
- package/dist/commands/uninstall.d.ts +0 -1
- package/dist/commands/uninstall.js +0 -1
- package/dist/config.d.ts +0 -1
- package/dist/config.js +0 -1
- package/dist/event-queues.d.ts +0 -1
- package/dist/event-queues.js +0 -1
- package/dist/events.d.ts +0 -1
- package/dist/events.js +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/linked-device.d.ts +0 -1
- package/dist/linked-device.js +0 -1
- package/dist/mcp-handler.d.ts +0 -1
- package/dist/mcp-handler.js +0 -1
- package/dist/mcp-tools.d.ts +0 -1
- package/dist/mcp-tools.js +0 -1
- package/dist/nats-client.d.ts +0 -1
- package/dist/nats-client.js +0 -1
- package/dist/network.d.ts +0 -1
- package/dist/network.js +0 -1
- package/dist/notification-store.d.ts +0 -1
- package/dist/notification-store.js +0 -1
- package/dist/pending-requests.d.ts +0 -1
- package/dist/pending-requests.js +0 -1
- package/dist/platform/index.d.ts +0 -1
- package/dist/platform/index.js +0 -1
- package/dist/platform/linux.d.ts +0 -1
- package/dist/platform/linux.js +0 -1
- package/dist/platform/macos.d.ts +0 -1
- package/dist/platform/macos.js +0 -1
- package/dist/platform/platform.d.ts +0 -1
- package/dist/platform/platform.js +0 -1
- package/dist/platform/windows.d.ts +0 -1
- package/dist/platform/windows.js +0 -1
- package/dist/pwa/assets/{index-MLEFUP3r.js → index-DWvRAUiy.js} +31 -31
- package/dist/pwa/assets/{web-B1sKCc7e.js → web-C4iZbqTC.js} +1 -1
- package/dist/pwa/assets/{web-ETD-8ZHd.js → web-CBFqJGX6.js} +1 -1
- package/dist/pwa/assets/{web-B4xEa6WO.js → web-DL4uXOpS.js} +1 -1
- package/dist/pwa/index.html +2 -2
- package/dist/pwa/service-worker.js +1 -1
- package/dist/rpc-handler.d.ts +0 -1
- package/dist/rpc-handler.js +0 -1
- package/dist/sms-store.d.ts +0 -1
- package/dist/sms-store.js +0 -1
- package/dist/spawn-command.d.ts +0 -1
- package/dist/spawn-command.js +0 -1
- package/dist/task.d.ts +0 -1
- package/dist/task.js +0 -1
- package/dist/transports/http-transport.d.ts +0 -1
- package/dist/transports/http-transport.js +0 -1
- package/dist/transports/nats-transport.d.ts +0 -1
- package/dist/transports/nats-transport.js +0 -1
- package/dist/types.d.ts +0 -1
- package/dist/types.js +0 -1
- package/dist/update-checker.d.ts +0 -1
- package/dist/update-checker.js +0 -1
- package/package.json +5 -1
- package/.github/workflows/ci.yml +0 -16
- package/.github/workflows/publish.yml +0 -37
- package/CLAUDE.md +0 -22
- package/palmier-server/.github/workflows/ci.yml +0 -21
- package/palmier-server/.github/workflows/deploy.yml +0 -38
- package/palmier-server/CLAUDE.md +0 -17
- package/palmier-server/PRODUCTION.md +0 -358
- package/palmier-server/README.md +0 -231
- package/palmier-server/nats.conf +0 -19
- package/palmier-server/package.json +0 -15
- package/palmier-server/pnpm-lock.yaml +0 -7639
- package/palmier-server/pnpm-workspace.yaml +0 -3
- package/palmier-server/pwa/index.html +0 -16
- package/palmier-server/pwa/logo/logo_20260421.png +0 -0
- package/palmier-server/pwa/package.json +0 -34
- package/palmier-server/pwa/public/apple-touch-icon.png +0 -0
- package/palmier-server/pwa/public/favicon.ico +0 -0
- package/palmier-server/pwa/public/pwa-192x192.png +0 -0
- package/palmier-server/pwa/public/pwa-512x512.png +0 -0
- package/palmier-server/pwa/src/App.css +0 -3012
- package/palmier-server/pwa/src/App.tsx +0 -59
- package/palmier-server/pwa/src/agentLabels.ts +0 -11
- package/palmier-server/pwa/src/api.ts +0 -67
- package/palmier-server/pwa/src/components/CapabilityToggles.tsx +0 -170
- package/palmier-server/pwa/src/components/ConnectionStatusIcon.tsx +0 -113
- package/palmier-server/pwa/src/components/HostMenu.tsx +0 -429
- package/palmier-server/pwa/src/components/PermissionsDialog.tsx +0 -34
- package/palmier-server/pwa/src/components/PullToRefreshIndicator.tsx +0 -46
- package/palmier-server/pwa/src/components/RunDetailView.tsx +0 -343
- package/palmier-server/pwa/src/components/SessionComposer.tsx +0 -157
- package/palmier-server/pwa/src/components/SessionsView.tsx +0 -326
- package/palmier-server/pwa/src/components/SwipeToDeleteRow.tsx +0 -170
- package/palmier-server/pwa/src/components/TabBar.tsx +0 -40
- package/palmier-server/pwa/src/components/TaskCard.tsx +0 -255
- package/palmier-server/pwa/src/components/TaskForm.tsx +0 -766
- package/palmier-server/pwa/src/components/TasksView.tsx +0 -179
- package/palmier-server/pwa/src/constants.ts +0 -2
- package/palmier-server/pwa/src/contexts/HostConnectionContext.tsx +0 -432
- package/palmier-server/pwa/src/contexts/HostStoreContext.tsx +0 -124
- package/palmier-server/pwa/src/draftGuard.ts +0 -24
- package/palmier-server/pwa/src/formatTime.ts +0 -44
- package/palmier-server/pwa/src/hooks/useBackClose.ts +0 -75
- package/palmier-server/pwa/src/hooks/useMediaQuery.ts +0 -17
- package/palmier-server/pwa/src/hooks/usePullToRefresh.ts +0 -102
- package/palmier-server/pwa/src/hooks/usePushSubscription.ts +0 -77
- package/palmier-server/pwa/src/main.tsx +0 -14
- package/palmier-server/pwa/src/native/Device.ts +0 -49
- package/palmier-server/pwa/src/pages/Dashboard.tsx +0 -542
- package/palmier-server/pwa/src/pages/PairHost.tsx +0 -232
- package/palmier-server/pwa/src/pages/PairSetup.tsx +0 -134
- package/palmier-server/pwa/src/service-worker.ts +0 -142
- package/palmier-server/pwa/src/types.ts +0 -75
- package/palmier-server/pwa/src/vite-env.d.ts +0 -11
- package/palmier-server/pwa/tsconfig.json +0 -21
- package/palmier-server/pwa/tsconfig.node.json +0 -19
- package/palmier-server/pwa/vite.config.ts +0 -47
- package/palmier-server/server/.env.example +0 -20
- package/palmier-server/server/package.json +0 -36
- package/palmier-server/server/src/db.ts +0 -44
- package/palmier-server/server/src/fcm.ts +0 -74
- package/palmier-server/server/src/index.ts +0 -688
- package/palmier-server/server/src/nats-jwt.ts +0 -299
- package/palmier-server/server/src/nats-setup.ts +0 -48
- package/palmier-server/server/src/nats.ts +0 -33
- package/palmier-server/server/src/notify.ts +0 -34
- package/palmier-server/server/src/push.ts +0 -68
- package/palmier-server/server/src/routes/device.ts +0 -224
- package/palmier-server/server/src/routes/fcm.ts +0 -64
- package/palmier-server/server/src/routes/hosts.ts +0 -56
- package/palmier-server/server/src/routes/push.ts +0 -101
- package/palmier-server/server/tsconfig.json +0 -20
- package/palmier-server/spec.md +0 -533
- package/src/agents/agent-instructions.md +0 -28
- package/src/agents/agent.ts +0 -114
- package/src/agents/aider.ts +0 -35
- package/src/agents/claude.ts +0 -39
- package/src/agents/cline.ts +0 -35
- package/src/agents/codex.ts +0 -40
- package/src/agents/copilot.ts +0 -37
- package/src/agents/cursor.ts +0 -36
- package/src/agents/deepagents.ts +0 -36
- package/src/agents/droid.ts +0 -35
- package/src/agents/gemini.ts +0 -43
- package/src/agents/goose.ts +0 -33
- package/src/agents/hermes.ts +0 -36
- package/src/agents/kimi.ts +0 -35
- package/src/agents/kiro.ts +0 -36
- package/src/agents/openclaw.ts +0 -29
- package/src/agents/opencode.ts +0 -36
- package/src/agents/qoder.ts +0 -36
- package/src/agents/qwen.ts +0 -32
- package/src/agents/shared-prompt.ts +0 -30
- package/src/client-store.ts +0 -68
- package/src/commands/clients.ts +0 -29
- package/src/commands/info.ts +0 -29
- package/src/commands/init.ts +0 -165
- package/src/commands/pair.ts +0 -137
- package/src/commands/restart.ts +0 -6
- package/src/commands/run.ts +0 -608
- package/src/commands/serve.ts +0 -211
- package/src/commands/uninstall.ts +0 -9
- package/src/config.ts +0 -36
- package/src/cross-spawn.d.ts +0 -5
- package/src/event-queues.ts +0 -41
- package/src/events.ts +0 -29
- package/src/index.ts +0 -111
- package/src/linked-device.ts +0 -52
- package/src/mcp-handler.ts +0 -200
- package/src/mcp-tools.ts +0 -839
- package/src/nats-client.ts +0 -19
- package/src/network.ts +0 -96
- package/src/notification-store.ts +0 -30
- package/src/pending-requests.ts +0 -73
- package/src/platform/index.ts +0 -20
- package/src/platform/linux.ts +0 -296
- package/src/platform/macos.ts +0 -329
- package/src/platform/platform.ts +0 -31
- package/src/platform/windows.ts +0 -299
- package/src/rpc-handler.ts +0 -691
- package/src/sms-store.ts +0 -28
- package/src/spawn-command.ts +0 -123
- package/src/task.ts +0 -343
- package/src/transports/http-transport.ts +0 -478
- package/src/transports/nats-transport.ts +0 -76
- package/src/types.ts +0 -89
- package/src/update-checker.ts +0 -40
- package/test/agent-instructions.test.ts +0 -209
- package/test/agent-output-parsing.test.ts +0 -74
- package/test/linux-cron.test.ts +0 -41
- package/test/macos-plist.test.ts +0 -112
- package/test/notification-store.test.ts +0 -57
- package/test/pairing.test.ts +0 -35
- package/test/result-state.test.ts +0 -110
- package/test/task-parsing.test.ts +0 -82
- package/test/taskrun-messages.test.ts +0 -224
- package/test/tsconfig.json +0 -9
- package/test/windows-xml.test.ts +0 -89
- package/tsconfig.json +0 -19
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { Router, Request, Response } from "express";
|
|
2
|
-
import type { Router as RouterType } from "express";
|
|
3
|
-
import { pool } from "../db.js";
|
|
4
|
-
import { getNatsConnection } from "../nats.js";
|
|
5
|
-
import { StringCodec } from "nats";
|
|
6
|
-
|
|
7
|
-
const router: RouterType = Router();
|
|
8
|
-
|
|
9
|
-
// POST /api/fcm/register - Register or refresh an FCM token for a host
|
|
10
|
-
router.post("/register", async (req: Request, res: Response) => {
|
|
11
|
-
try {
|
|
12
|
-
const { hostId, fcmToken, deviceLabel } = req.body;
|
|
13
|
-
|
|
14
|
-
if (!hostId || !fcmToken) {
|
|
15
|
-
res.status(400).json({ error: "hostId and fcmToken are required" });
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
await pool.query(
|
|
20
|
-
`INSERT INTO fcm_tokens (host_id, fcm_token, device_label, updated_at)
|
|
21
|
-
VALUES ($1, $2, $3, NOW())
|
|
22
|
-
ON CONFLICT (host_id, fcm_token)
|
|
23
|
-
DO UPDATE SET device_label = EXCLUDED.device_label, updated_at = NOW()`,
|
|
24
|
-
[hostId, fcmToken, deviceLabel || null]
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
res.status(201).json({ message: "FCM token registered" });
|
|
28
|
-
} catch (err) {
|
|
29
|
-
console.error("FCM register error:", err);
|
|
30
|
-
res.status(500).json({ error: "Internal server error" });
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
// POST /api/fcm/geolocation-response - Receive location from Android device, forward via NATS
|
|
35
|
-
router.post("/geolocation-response", async (req: Request, res: Response) => {
|
|
36
|
-
try {
|
|
37
|
-
const { requestId, hostId, latitude, longitude, accuracy, timestamp, error } = req.body;
|
|
38
|
-
|
|
39
|
-
if (!requestId || !hostId) {
|
|
40
|
-
res.status(400).json({ error: "requestId and hostId are required" });
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const conn = await getNatsConnection();
|
|
45
|
-
const sc = StringCodec();
|
|
46
|
-
const subject = `host.${hostId}.geolocation.${requestId}`;
|
|
47
|
-
|
|
48
|
-
if (error) {
|
|
49
|
-
conn.publish(subject, sc.encode(JSON.stringify({ error })));
|
|
50
|
-
} else {
|
|
51
|
-
conn.publish(
|
|
52
|
-
subject,
|
|
53
|
-
sc.encode(JSON.stringify({ latitude, longitude, accuracy, timestamp }))
|
|
54
|
-
);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
res.json({ message: "Location forwarded" });
|
|
58
|
-
} catch (err) {
|
|
59
|
-
console.error("FCM geolocation-response error:", err);
|
|
60
|
-
res.status(500).json({ error: "Internal server error" });
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
export default router;
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import { Router, Request, Response } from "express";
|
|
2
|
-
import type { Router as RouterType } from "express";
|
|
3
|
-
import { pool } from "../db.js";
|
|
4
|
-
import { createHostCredentials } from "../nats-jwt.js";
|
|
5
|
-
|
|
6
|
-
const router: RouterType = Router();
|
|
7
|
-
|
|
8
|
-
// POST /api/hosts/register - Register a host (called by palmier init).
|
|
9
|
-
// If the request includes a hostId that already exists, the row is reused
|
|
10
|
-
// so re-initializing a host doesn't create a duplicate entry.
|
|
11
|
-
router.post("/register", async (req: Request, res: Response) => {
|
|
12
|
-
try {
|
|
13
|
-
const accountSeed = process.env.NATS_ACCOUNT_SEED;
|
|
14
|
-
if (!accountSeed) {
|
|
15
|
-
console.error("NATS_ACCOUNT_SEED not configured");
|
|
16
|
-
res.status(500).json({ error: "Server NATS auth not configured" });
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const requestedId: string | undefined = req.body?.hostId;
|
|
21
|
-
|
|
22
|
-
let hostId: string;
|
|
23
|
-
if (requestedId) {
|
|
24
|
-
// Reuse existing row or create one with the requested id.
|
|
25
|
-
await pool.query(
|
|
26
|
-
`INSERT INTO hosts (id) VALUES ($1) ON CONFLICT (id) DO NOTHING`,
|
|
27
|
-
[requestedId],
|
|
28
|
-
);
|
|
29
|
-
hostId = requestedId;
|
|
30
|
-
} else {
|
|
31
|
-
const result = await pool.query(
|
|
32
|
-
"INSERT INTO hosts DEFAULT VALUES RETURNING id"
|
|
33
|
-
);
|
|
34
|
-
hostId = result.rows[0].id;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// Generate per-host NATS credentials (scoped to this host's subjects)
|
|
38
|
-
const creds = createHostCredentials(accountSeed, hostId);
|
|
39
|
-
|
|
40
|
-
const natsUrl = process.env.NATS_HOST_URL || process.env.NATS_URL || "nats://localhost:4222";
|
|
41
|
-
const natsWsUrl = process.env.NATS_WS_URL || "";
|
|
42
|
-
|
|
43
|
-
res.status(201).json({
|
|
44
|
-
hostId,
|
|
45
|
-
natsUrl,
|
|
46
|
-
natsWsUrl,
|
|
47
|
-
natsJwt: creds.jwt,
|
|
48
|
-
natsNkeySeed: creds.nkeySeed,
|
|
49
|
-
});
|
|
50
|
-
} catch (err) {
|
|
51
|
-
console.error("Register host error:", err);
|
|
52
|
-
res.status(500).json({ error: "Internal server error" });
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
export default router;
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { Router, Request, Response } from "express";
|
|
2
|
-
import type { Router as RouterType } from "express";
|
|
3
|
-
import { pool } from "../db.js";
|
|
4
|
-
import { getNatsConnection } from "../nats.js";
|
|
5
|
-
import { StringCodec } from "nats";
|
|
6
|
-
|
|
7
|
-
const router: RouterType = Router();
|
|
8
|
-
|
|
9
|
-
// POST /api/push/subscribe - Upsert push subscription (keyed by hostId)
|
|
10
|
-
router.post("/subscribe", async (req: Request, res: Response) => {
|
|
11
|
-
try {
|
|
12
|
-
const { hostId, endpoint, keys } = req.body;
|
|
13
|
-
|
|
14
|
-
if (!hostId || !endpoint || !keys || !keys.p256dh || !keys.auth) {
|
|
15
|
-
res.status(400).json({
|
|
16
|
-
error: "hostId, endpoint, keys.p256dh, and keys.auth are required",
|
|
17
|
-
});
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
await pool.query(
|
|
22
|
-
`INSERT INTO push_subscriptions (host_id, endpoint, p256dh, auth)
|
|
23
|
-
VALUES ($1, $2, $3, $4)
|
|
24
|
-
ON CONFLICT (host_id, endpoint)
|
|
25
|
-
DO UPDATE SET p256dh = EXCLUDED.p256dh, auth = EXCLUDED.auth`,
|
|
26
|
-
[hostId, endpoint, keys.p256dh, keys.auth]
|
|
27
|
-
);
|
|
28
|
-
|
|
29
|
-
res.status(201).json({ message: "Push subscription saved" });
|
|
30
|
-
} catch (err) {
|
|
31
|
-
console.error("Push subscribe error:", err);
|
|
32
|
-
res.status(500).json({ error: "Internal server error" });
|
|
33
|
-
}
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
// DELETE /api/push/subscribe - Delete push subscription by endpoint
|
|
37
|
-
router.delete("/subscribe", async (req: Request, res: Response) => {
|
|
38
|
-
try {
|
|
39
|
-
const { hostId, endpoint } = req.body;
|
|
40
|
-
|
|
41
|
-
if (!hostId || !endpoint) {
|
|
42
|
-
res.status(400).json({ error: "hostId and endpoint are required" });
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const result = await pool.query(
|
|
47
|
-
"DELETE FROM push_subscriptions WHERE host_id = $1 AND endpoint = $2 RETURNING id",
|
|
48
|
-
[hostId, endpoint]
|
|
49
|
-
);
|
|
50
|
-
|
|
51
|
-
if (result.rows.length === 0) {
|
|
52
|
-
res.status(404).json({ error: "Subscription not found" });
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
res.json({ message: "Push subscription removed" });
|
|
57
|
-
} catch (err) {
|
|
58
|
-
console.error("Push unsubscribe error:", err);
|
|
59
|
-
res.status(500).json({ error: "Internal server error" });
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
// GET /api/push/vapid-key - Public endpoint
|
|
64
|
-
router.get("/vapid-key", (_req, res: Response) => {
|
|
65
|
-
const publicKey = process.env.VAPID_PUBLIC_KEY || "";
|
|
66
|
-
res.json({ publicKey });
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
// POST /api/push/respond - Respond to a pending request via NATS request-reply
|
|
70
|
-
router.post("/respond", async (req: Request, res: Response) => {
|
|
71
|
-
try {
|
|
72
|
-
const { task_id, session_id, host_id, response } = req.body;
|
|
73
|
-
const id = session_id || task_id;
|
|
74
|
-
|
|
75
|
-
if (!id || !host_id || !response) {
|
|
76
|
-
res.status(400).json({
|
|
77
|
-
error: "host_id, response, and session_id (or task_id for permissions) are required",
|
|
78
|
-
});
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const conn = await getNatsConnection();
|
|
83
|
-
const sc = StringCodec();
|
|
84
|
-
const subject = `host.${host_id}.rpc.task.user_input`;
|
|
85
|
-
const payload = sc.encode(JSON.stringify({ id, value: [response] }));
|
|
86
|
-
|
|
87
|
-
const reply = await conn.request(subject, payload, { timeout: 5000 });
|
|
88
|
-
const result = JSON.parse(sc.decode(reply.data));
|
|
89
|
-
|
|
90
|
-
res.json({ message: "Confirmation response recorded", ...result });
|
|
91
|
-
} catch (err: any) {
|
|
92
|
-
console.error("Push respond error:", err);
|
|
93
|
-
if (err.code === "503" || err.message?.includes("timeout")) {
|
|
94
|
-
res.status(504).json({ error: "Host did not respond" });
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
res.status(500).json({ error: "Internal server error" });
|
|
98
|
-
}
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
export default router;
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"target": "ES2023",
|
|
4
|
-
"module": "Node16",
|
|
5
|
-
"moduleResolution": "Node16",
|
|
6
|
-
"lib": ["ES2023"],
|
|
7
|
-
"outDir": "dist",
|
|
8
|
-
"rootDir": "src",
|
|
9
|
-
"strict": true,
|
|
10
|
-
"esModuleInterop": true,
|
|
11
|
-
"skipLibCheck": true,
|
|
12
|
-
"forceConsistentCasingInFileNames": true,
|
|
13
|
-
"resolveJsonModule": true,
|
|
14
|
-
"declaration": true,
|
|
15
|
-
"declarationMap": true,
|
|
16
|
-
"sourceMap": true
|
|
17
|
-
},
|
|
18
|
-
"include": ["src"],
|
|
19
|
-
"exclude": ["node_modules", "dist"]
|
|
20
|
-
}
|