palmier 0.4.2 → 0.4.4

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.
Files changed (45) hide show
  1. package/README.md +18 -30
  2. package/dist/agents/agent-instructions.md +40 -0
  3. package/dist/agents/claude.js +2 -8
  4. package/dist/agents/codex.js +0 -6
  5. package/dist/agents/copilot.js +0 -20
  6. package/dist/agents/gemini.js +0 -6
  7. package/dist/agents/shared-prompt.d.ts +1 -2
  8. package/dist/agents/shared-prompt.js +5 -18
  9. package/dist/commands/notify.d.ts +9 -0
  10. package/dist/commands/notify.js +43 -0
  11. package/dist/commands/request-input.d.ts +10 -0
  12. package/dist/commands/request-input.js +49 -0
  13. package/dist/commands/run.d.ts +4 -5
  14. package/dist/commands/run.js +90 -105
  15. package/dist/commands/serve.js +31 -28
  16. package/dist/index.js +15 -5
  17. package/dist/platform/linux.js +16 -6
  18. package/dist/platform/windows.js +54 -14
  19. package/dist/rpc-handler.js +217 -54
  20. package/dist/spawn-command.d.ts +1 -1
  21. package/dist/spawn-command.js +13 -1
  22. package/dist/task.d.ts +18 -7
  23. package/dist/task.js +70 -27
  24. package/dist/types.d.ts +10 -1
  25. package/package.json +2 -3
  26. package/src/agents/agent-instructions.md +40 -0
  27. package/src/agents/claude.ts +2 -7
  28. package/src/agents/codex.ts +0 -5
  29. package/src/agents/copilot.ts +0 -19
  30. package/src/agents/gemini.ts +0 -5
  31. package/src/agents/shared-prompt.ts +10 -18
  32. package/src/commands/notify.ts +44 -0
  33. package/src/commands/request-input.ts +51 -0
  34. package/src/commands/run.ts +98 -129
  35. package/src/commands/serve.ts +34 -36
  36. package/src/index.ts +16 -5
  37. package/src/platform/linux.ts +17 -7
  38. package/src/platform/windows.ts +53 -15
  39. package/src/rpc-handler.ts +244 -57
  40. package/src/spawn-command.ts +13 -2
  41. package/src/task.ts +79 -29
  42. package/src/types.ts +11 -1
  43. package/dist/commands/mcpserver.d.ts +0 -2
  44. package/dist/commands/mcpserver.js +0 -93
  45. package/src/commands/mcpserver.ts +0 -113
@@ -1,93 +0,0 @@
1
- import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
- import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
3
- import { z } from "zod";
4
- import { StringCodec } from "nats";
5
- import { loadConfig } from "../config.js";
6
- import { connectNats } from "../nats-client.js";
7
- import { getTaskDir, parseTaskFile } from "../task.js";
8
- import { requestUserInput, publishInputResolved } from "../user-input.js";
9
- export async function mcpserverCommand() {
10
- const config = loadConfig();
11
- const nc = await connectNats(config);
12
- const sc = StringCodec();
13
- const server = new McpServer({ name: "palmier", version: "1.0.0" }, { capabilities: { tools: {} } });
14
- // send-push-notification requires NATS — only register when server mode is enabled
15
- if (nc) {
16
- server.registerTool("send-push-notification", {
17
- description: "Send a push notification to the user",
18
- inputSchema: {
19
- title: z.string().describe("Notification title"),
20
- body: z.string().describe("Notification body text"),
21
- },
22
- }, async (args) => {
23
- const payload = {
24
- hostId: config.hostId,
25
- title: args.title,
26
- body: args.body,
27
- };
28
- try {
29
- const subject = `host.${config.hostId}.push.send`;
30
- const reply = await nc.request(subject, sc.encode(JSON.stringify(payload)), {
31
- timeout: 15_000,
32
- });
33
- const result = JSON.parse(sc.decode(reply.data));
34
- if (result.ok) {
35
- return {
36
- content: [{ type: "text", text: "Push notification sent successfully" }],
37
- };
38
- }
39
- else {
40
- return {
41
- content: [{ type: "text", text: `Failed to send push notification: ${result.error}` }],
42
- isError: true,
43
- };
44
- }
45
- }
46
- catch (err) {
47
- return {
48
- content: [{ type: "text", text: `Error sending push notification: ${err}` }],
49
- isError: true,
50
- };
51
- }
52
- });
53
- }
54
- const taskId = process.env.PALMIER_TASK_ID;
55
- if (taskId) {
56
- const taskDir = getTaskDir(config.projectRoot, taskId);
57
- const task = parseTaskFile(taskDir);
58
- server.registerTool("request-user-input", {
59
- description: "Request input from the user. The user will see the descriptions and can provide values or abort.",
60
- inputSchema: {
61
- descriptions: z.array(z.string()).describe("List of input descriptions to show the user"),
62
- },
63
- }, async (args) => {
64
- try {
65
- const response = await requestUserInput(nc, config, taskId, task.frontmatter.name, taskDir, args.descriptions);
66
- await publishInputResolved(nc, config, taskId, response === "aborted" ? "aborted" : "provided");
67
- if (response === "aborted") {
68
- return {
69
- content: [{ type: "text", text: "User aborted the input request." }],
70
- };
71
- }
72
- const lines = args.descriptions.map((desc, i) => `${desc}: ${response[i]}`).join("\n");
73
- return {
74
- content: [{ type: "text", text: lines }],
75
- };
76
- }
77
- catch (err) {
78
- return {
79
- content: [{ type: "text", text: `Error requesting user input: ${err}` }],
80
- isError: true,
81
- };
82
- }
83
- });
84
- }
85
- const transport = new StdioServerTransport();
86
- await server.connect(transport);
87
- // Graceful shutdown
88
- transport.onclose = async () => {
89
- if (nc)
90
- await nc.drain();
91
- };
92
- }
93
- //# sourceMappingURL=mcpserver.js.map
@@ -1,113 +0,0 @@
1
- import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
2
- import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
3
- import { z } from "zod";
4
- import { StringCodec } from "nats";
5
- import { loadConfig } from "../config.js";
6
- import { connectNats } from "../nats-client.js";
7
- import { getTaskDir, parseTaskFile } from "../task.js";
8
- import { requestUserInput, publishInputResolved } from "../user-input.js";
9
- export async function mcpserverCommand(): Promise<void> {
10
- const config = loadConfig();
11
- const nc = await connectNats(config);
12
-
13
- const sc = StringCodec();
14
-
15
- const server = new McpServer(
16
- { name: "palmier", version: "1.0.0" },
17
- { capabilities: { tools: {} } }
18
- );
19
-
20
- // send-push-notification requires NATS — only register when server mode is enabled
21
- if (nc) {
22
- server.registerTool(
23
- "send-push-notification",
24
- {
25
- description: "Send a push notification to the user",
26
- inputSchema: {
27
- title: z.string().describe("Notification title"),
28
- body: z.string().describe("Notification body text"),
29
- },
30
- },
31
- async (args) => {
32
- const payload = {
33
- hostId: config.hostId,
34
- title: args.title,
35
- body: args.body,
36
- };
37
-
38
- try {
39
- const subject = `host.${config.hostId}.push.send`;
40
- const reply = await nc!.request(subject, sc.encode(JSON.stringify(payload)), {
41
- timeout: 15_000,
42
- });
43
- const result = JSON.parse(sc.decode(reply.data)) as {
44
- ok?: boolean;
45
- error?: string;
46
- };
47
-
48
- if (result.ok) {
49
- return {
50
- content: [{ type: "text" as const, text: "Push notification sent successfully" }],
51
- };
52
- } else {
53
- return {
54
- content: [{ type: "text" as const, text: `Failed to send push notification: ${result.error}` }],
55
- isError: true,
56
- };
57
- }
58
- } catch (err) {
59
- return {
60
- content: [{ type: "text" as const, text: `Error sending push notification: ${err}` }],
61
- isError: true,
62
- };
63
- }
64
- }
65
- );
66
- }
67
-
68
- const taskId = process.env.PALMIER_TASK_ID;
69
- if (taskId) {
70
- const taskDir = getTaskDir(config.projectRoot, taskId);
71
- const task = parseTaskFile(taskDir);
72
-
73
- server.registerTool(
74
- "request-user-input",
75
- {
76
- description: "Request input from the user. The user will see the descriptions and can provide values or abort.",
77
- inputSchema: {
78
- descriptions: z.array(z.string()).describe("List of input descriptions to show the user"),
79
- },
80
- },
81
- async (args) => {
82
- try {
83
- const response = await requestUserInput(nc, config, taskId, task.frontmatter.name, taskDir, args.descriptions);
84
- await publishInputResolved(nc, config, taskId, response === "aborted" ? "aborted" : "provided");
85
-
86
- if (response === "aborted") {
87
- return {
88
- content: [{ type: "text" as const, text: "User aborted the input request." }],
89
- };
90
- }
91
-
92
- const lines = args.descriptions.map((desc: string, i: number) => `${desc}: ${response[i]}`).join("\n");
93
- return {
94
- content: [{ type: "text" as const, text: lines }],
95
- };
96
- } catch (err) {
97
- return {
98
- content: [{ type: "text" as const, text: `Error requesting user input: ${err}` }],
99
- isError: true,
100
- };
101
- }
102
- }
103
- );
104
- }
105
-
106
- const transport = new StdioServerTransport();
107
- await server.connect(transport);
108
-
109
- // Graceful shutdown
110
- transport.onclose = async () => {
111
- if (nc) await nc.drain();
112
- };
113
- }