palmier 0.5.2 → 0.5.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.
- package/README.md +9 -9
- package/dist/agents/agent-instructions.md +7 -7
- package/dist/agents/shared-prompt.js +1 -1
- package/dist/client-store.d.ts +12 -0
- package/dist/client-store.js +57 -0
- package/dist/commands/clients.d.ts +4 -0
- package/dist/commands/clients.js +27 -0
- package/dist/commands/info.js +5 -5
- package/dist/commands/init.js +1 -1
- package/dist/commands/pair.js +4 -4
- package/dist/commands/run.js +9 -5
- package/dist/commands/serve.js +1 -1
- package/dist/events.js +1 -1
- package/dist/index.js +13 -13
- package/dist/platform/windows.d.ts +1 -1
- package/dist/platform/windows.js +33 -29
- package/dist/rpc-handler.js +7 -4
- package/dist/transports/http-transport.js +7 -7
- package/dist/transports/nats-transport.js +4 -4
- package/dist/types.d.ts +2 -2
- package/package.json +1 -1
- package/src/agents/agent-instructions.md +7 -7
- package/src/agents/shared-prompt.ts +1 -1
- package/src/client-store.ts +68 -0
- package/src/commands/clients.ts +29 -0
- package/src/commands/info.ts +5 -5
- package/src/commands/init.ts +1 -1
- package/src/commands/pair.ts +4 -4
- package/src/commands/run.ts +8 -5
- package/src/commands/serve.ts +1 -1
- package/src/events.ts +1 -1
- package/src/index.ts +13 -13
- package/src/platform/windows.ts +29 -29
- package/src/rpc-handler.ts +7 -4
- package/src/transports/http-transport.ts +7 -7
- package/src/transports/nats-transport.ts +4 -4
- package/src/types.ts +3 -3
- package/test/agent-instructions.test.ts +22 -5
- package/test/agent-output-parsing.test.ts +12 -0
- package/test/windows-xml.test.ts +2 -0
- package/dist/commands/sessions.d.ts +0 -4
- package/dist/commands/sessions.js +0 -27
- package/dist/session-store.d.ts +0 -12
- package/dist/session-store.js +0 -57
- package/src/commands/sessions.ts +0 -29
- package/src/session-store.ts +0 -68
|
@@ -38,6 +38,11 @@ describe("parseReportFiles", () => {
|
|
|
38
38
|
it("trims whitespace from file names", () => {
|
|
39
39
|
assert.deepEqual(parseReportFiles("[PALMIER_REPORT] report.md "), ["report.md"]);
|
|
40
40
|
});
|
|
41
|
+
|
|
42
|
+
it("ignores placeholder examples from echoed prompt", () => {
|
|
43
|
+
const output = "[PALMIER_REPORT] <filename>\n[PALMIER_REPORT] actual-report.md";
|
|
44
|
+
assert.deepEqual(parseReportFiles(output), ["actual-report.md"]);
|
|
45
|
+
});
|
|
41
46
|
});
|
|
42
47
|
|
|
43
48
|
describe("parsePermissions", () => {
|
|
@@ -57,5 +62,12 @@ describe("parsePermissions", () => {
|
|
|
57
62
|
it("returns empty array when no permissions", () => {
|
|
58
63
|
assert.deepEqual(parsePermissions("no permissions"), []);
|
|
59
64
|
});
|
|
65
|
+
|
|
66
|
+
it("ignores placeholder examples from echoed prompt", () => {
|
|
67
|
+
const output = "[PALMIER_PERMISSION] <tool_name> | <description>\n[PALMIER_PERMISSION] Read | Read files";
|
|
68
|
+
const perms = parsePermissions(output);
|
|
69
|
+
assert.equal(perms.length, 1);
|
|
70
|
+
assert.deepEqual(perms[0], { name: "Read", description: "Read files" });
|
|
71
|
+
});
|
|
60
72
|
});
|
|
61
73
|
|
package/test/windows-xml.test.ts
CHANGED
|
@@ -60,6 +60,8 @@ describe("buildTaskXml", () => {
|
|
|
60
60
|
const xml = buildTaskXml(tr, triggers);
|
|
61
61
|
|
|
62
62
|
assert.ok(xml.includes('<?xml version="1.0" encoding="UTF-16"?>'), "should have XML declaration");
|
|
63
|
+
assert.ok(xml.includes("<LogonType>S4U</LogonType>"), "should use S4U logon type");
|
|
64
|
+
assert.ok(xml.includes("<RunLevel>LeastPrivilege</RunLevel>"), "should use least privilege");
|
|
63
65
|
assert.ok(xml.includes("<MultipleInstancesPolicy>StopExisting</MultipleInstancesPolicy>"), "should set StopExisting");
|
|
64
66
|
assert.ok(xml.includes("<DisallowStartIfOnBatteries>false</DisallowStartIfOnBatteries>"), "should allow on battery");
|
|
65
67
|
assert.ok(xml.includes("<Command>C:\\Program Files\\nodejs\\node.exe</Command>"), "should extract command");
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { loadSessions, revokeSession, revokeAllSessions } from "../session-store.js";
|
|
2
|
-
export async function sessionsListCommand() {
|
|
3
|
-
const sessions = loadSessions();
|
|
4
|
-
if (sessions.length === 0) {
|
|
5
|
-
console.log("No active sessions.");
|
|
6
|
-
return;
|
|
7
|
-
}
|
|
8
|
-
console.log(`${sessions.length} active session(s):\n`);
|
|
9
|
-
for (const s of sessions) {
|
|
10
|
-
const label = s.label ? ` (${s.label})` : "";
|
|
11
|
-
console.log(` ${s.token}${label} created ${s.createdAt}`);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
export async function sessionsRevokeCommand(token) {
|
|
15
|
-
if (revokeSession(token)) {
|
|
16
|
-
console.log("Session revoked.");
|
|
17
|
-
}
|
|
18
|
-
else {
|
|
19
|
-
console.error("Session not found.");
|
|
20
|
-
process.exit(1);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
export async function sessionsRevokeAllCommand() {
|
|
24
|
-
const count = revokeAllSessions();
|
|
25
|
-
console.log(`Revoked ${count} session(s).`);
|
|
26
|
-
}
|
|
27
|
-
//# sourceMappingURL=sessions.js.map
|
package/dist/session-store.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
export interface SessionEntry {
|
|
2
|
-
token: string;
|
|
3
|
-
createdAt: string;
|
|
4
|
-
label?: string;
|
|
5
|
-
}
|
|
6
|
-
export declare function loadSessions(): SessionEntry[];
|
|
7
|
-
export declare function addSession(label?: string): SessionEntry;
|
|
8
|
-
export declare function revokeSession(token: string): boolean;
|
|
9
|
-
export declare function revokeAllSessions(): number;
|
|
10
|
-
export declare function validateSession(token: string): boolean;
|
|
11
|
-
export declare function hasSessions(): boolean;
|
|
12
|
-
//# sourceMappingURL=session-store.d.ts.map
|
package/dist/session-store.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import * as fs from "fs";
|
|
2
|
-
import * as path from "path";
|
|
3
|
-
import { randomBytes } from "crypto";
|
|
4
|
-
import { CONFIG_DIR } from "./config.js";
|
|
5
|
-
const SESSIONS_FILE = path.join(CONFIG_DIR, "sessions.json");
|
|
6
|
-
function readFile() {
|
|
7
|
-
try {
|
|
8
|
-
if (!fs.existsSync(SESSIONS_FILE))
|
|
9
|
-
return [];
|
|
10
|
-
const raw = fs.readFileSync(SESSIONS_FILE, "utf-8");
|
|
11
|
-
return JSON.parse(raw);
|
|
12
|
-
}
|
|
13
|
-
catch {
|
|
14
|
-
return [];
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
function writeFile(sessions) {
|
|
18
|
-
fs.mkdirSync(CONFIG_DIR, { recursive: true });
|
|
19
|
-
fs.writeFileSync(SESSIONS_FILE, JSON.stringify(sessions, null, 2), "utf-8");
|
|
20
|
-
}
|
|
21
|
-
export function loadSessions() {
|
|
22
|
-
return readFile();
|
|
23
|
-
}
|
|
24
|
-
export function addSession(label) {
|
|
25
|
-
const sessions = readFile();
|
|
26
|
-
const entry = {
|
|
27
|
-
token: randomBytes(32).toString("hex"),
|
|
28
|
-
createdAt: new Date().toISOString(),
|
|
29
|
-
...(label ? { label } : {}),
|
|
30
|
-
};
|
|
31
|
-
sessions.push(entry);
|
|
32
|
-
writeFile(sessions);
|
|
33
|
-
return entry;
|
|
34
|
-
}
|
|
35
|
-
export function revokeSession(token) {
|
|
36
|
-
const sessions = readFile();
|
|
37
|
-
const idx = sessions.findIndex((s) => s.token === token);
|
|
38
|
-
if (idx === -1)
|
|
39
|
-
return false;
|
|
40
|
-
sessions.splice(idx, 1);
|
|
41
|
-
writeFile(sessions);
|
|
42
|
-
return true;
|
|
43
|
-
}
|
|
44
|
-
export function revokeAllSessions() {
|
|
45
|
-
const sessions = readFile();
|
|
46
|
-
const count = sessions.length;
|
|
47
|
-
writeFile([]);
|
|
48
|
-
return count;
|
|
49
|
-
}
|
|
50
|
-
export function validateSession(token) {
|
|
51
|
-
const sessions = readFile();
|
|
52
|
-
return sessions.some((s) => s.token === token);
|
|
53
|
-
}
|
|
54
|
-
export function hasSessions() {
|
|
55
|
-
return readFile().length > 0;
|
|
56
|
-
}
|
|
57
|
-
//# sourceMappingURL=session-store.js.map
|
package/src/commands/sessions.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { loadSessions, revokeSession, revokeAllSessions } from "../session-store.js";
|
|
2
|
-
|
|
3
|
-
export async function sessionsListCommand(): Promise<void> {
|
|
4
|
-
const sessions = loadSessions();
|
|
5
|
-
if (sessions.length === 0) {
|
|
6
|
-
console.log("No active sessions.");
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
console.log(`${sessions.length} active session(s):\n`);
|
|
11
|
-
for (const s of sessions) {
|
|
12
|
-
const label = s.label ? ` (${s.label})` : "";
|
|
13
|
-
console.log(` ${s.token}${label} created ${s.createdAt}`);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export async function sessionsRevokeCommand(token: string): Promise<void> {
|
|
18
|
-
if (revokeSession(token)) {
|
|
19
|
-
console.log("Session revoked.");
|
|
20
|
-
} else {
|
|
21
|
-
console.error("Session not found.");
|
|
22
|
-
process.exit(1);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export async function sessionsRevokeAllCommand(): Promise<void> {
|
|
27
|
-
const count = revokeAllSessions();
|
|
28
|
-
console.log(`Revoked ${count} session(s).`);
|
|
29
|
-
}
|
package/src/session-store.ts
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import * as fs from "fs";
|
|
2
|
-
import * as path from "path";
|
|
3
|
-
import { randomBytes } from "crypto";
|
|
4
|
-
import { CONFIG_DIR } from "./config.js";
|
|
5
|
-
|
|
6
|
-
const SESSIONS_FILE = path.join(CONFIG_DIR, "sessions.json");
|
|
7
|
-
|
|
8
|
-
export interface SessionEntry {
|
|
9
|
-
token: string;
|
|
10
|
-
createdAt: string;
|
|
11
|
-
label?: string;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
function readFile(): SessionEntry[] {
|
|
15
|
-
try {
|
|
16
|
-
if (!fs.existsSync(SESSIONS_FILE)) return [];
|
|
17
|
-
const raw = fs.readFileSync(SESSIONS_FILE, "utf-8");
|
|
18
|
-
return JSON.parse(raw) as SessionEntry[];
|
|
19
|
-
} catch {
|
|
20
|
-
return [];
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
function writeFile(sessions: SessionEntry[]): void {
|
|
25
|
-
fs.mkdirSync(CONFIG_DIR, { recursive: true });
|
|
26
|
-
fs.writeFileSync(SESSIONS_FILE, JSON.stringify(sessions, null, 2), "utf-8");
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export function loadSessions(): SessionEntry[] {
|
|
30
|
-
return readFile();
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export function addSession(label?: string): SessionEntry {
|
|
34
|
-
const sessions = readFile();
|
|
35
|
-
const entry: SessionEntry = {
|
|
36
|
-
token: randomBytes(32).toString("hex"),
|
|
37
|
-
createdAt: new Date().toISOString(),
|
|
38
|
-
...(label ? { label } : {}),
|
|
39
|
-
};
|
|
40
|
-
sessions.push(entry);
|
|
41
|
-
writeFile(sessions);
|
|
42
|
-
return entry;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export function revokeSession(token: string): boolean {
|
|
46
|
-
const sessions = readFile();
|
|
47
|
-
const idx = sessions.findIndex((s) => s.token === token);
|
|
48
|
-
if (idx === -1) return false;
|
|
49
|
-
sessions.splice(idx, 1);
|
|
50
|
-
writeFile(sessions);
|
|
51
|
-
return true;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export function revokeAllSessions(): number {
|
|
55
|
-
const sessions = readFile();
|
|
56
|
-
const count = sessions.length;
|
|
57
|
-
writeFile([]);
|
|
58
|
-
return count;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export function validateSession(token: string): boolean {
|
|
62
|
-
const sessions = readFile();
|
|
63
|
-
return sessions.some((s) => s.token === token);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export function hasSessions(): boolean {
|
|
67
|
-
return readFile().length > 0;
|
|
68
|
-
}
|