@byte5ai/palaia 1.8.1 → 2.0.0

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/src/runner.ts CHANGED
@@ -164,11 +164,24 @@ export async function run(
164
164
  cmdArgs = [...args];
165
165
  }
166
166
 
167
- const result = await execCommand(cmd, cmdArgs, {
167
+ let result = await execCommand(cmd, cmdArgs, {
168
168
  timeoutMs,
169
169
  cwd: opts.workspace,
170
170
  });
171
171
 
172
+ // Retry once on lock/timeout errors (L-5: concurrent CLI write safety)
173
+ if (result.exitCode !== 0) {
174
+ const errMsg = result.stderr.trim() || result.stdout.trim();
175
+ const errLower = errMsg.toLowerCase();
176
+ if (errLower.includes("lock") || errLower.includes("timeout")) {
177
+ await new Promise((r) => setTimeout(r, 500));
178
+ result = await execCommand(cmd, cmdArgs, {
179
+ timeoutMs,
180
+ cwd: opts.workspace,
181
+ });
182
+ }
183
+ }
184
+
172
185
  if (result.exitCode !== 0) {
173
186
  const errMsg = result.stderr.trim() || result.stdout.trim();
174
187
  throw new Error(`Palaia CLI error (exit ${result.exitCode}): ${errMsg}`);
package/src/tools.ts CHANGED
@@ -9,6 +9,7 @@
9
9
  import { Type } from "@sinclair/typebox";
10
10
  import { runJson, type RunnerOpts } from "./runner.js";
11
11
  import type { PalaiaPluginConfig } from "./config.js";
12
+ import { sanitizeScope, isValidScope } from "./hooks.js";
12
13
 
13
14
  /** Shape returned by `palaia query --json` */
14
15
  interface QueryResult {
@@ -84,6 +85,11 @@ export function registerTools(api: any, config: PalaiaPluginConfig): void {
84
85
  description: "Filter by scope: private|team|shared:X|public",
85
86
  })
86
87
  ),
88
+ type: Type.Optional(
89
+ Type.String({
90
+ description: "Filter by entry type: memory|process|task",
91
+ })
92
+ ),
87
93
  }),
88
94
  async execute(
89
95
  _id: string,
@@ -92,6 +98,7 @@ export function registerTools(api: any, config: PalaiaPluginConfig): void {
92
98
  maxResults?: number;
93
99
  tier?: string;
94
100
  scope?: string;
101
+ type?: string;
95
102
  }
96
103
  ) {
97
104
  const limit = params.maxResults || config.maxResults || 5;
@@ -102,6 +109,11 @@ export function registerTools(api: any, config: PalaiaPluginConfig): void {
102
109
  args.push("--all");
103
110
  }
104
111
 
112
+ // Type filter (Issue #82)
113
+ if (params.type) {
114
+ args.push("--type", params.type);
115
+ }
116
+
105
117
  const result = await runJson<QueryResult>(args, opts);
106
118
 
107
119
  // Format as memory_search compatible output
@@ -190,18 +202,59 @@ export function registerTools(api: any, config: PalaiaPluginConfig): void {
190
202
  description: "Tags for categorization",
191
203
  })
192
204
  ),
205
+ type: Type.Optional(
206
+ Type.String({
207
+ description: "Entry type: memory|process|task (default: memory)",
208
+ })
209
+ ),
210
+ project: Type.Optional(
211
+ Type.String({
212
+ description: "Project name to associate this entry with",
213
+ })
214
+ ),
215
+ title: Type.Optional(
216
+ Type.String({
217
+ description: "Title for the entry",
218
+ })
219
+ ),
193
220
  }),
194
221
  async execute(
195
222
  _id: string,
196
- params: { content: string; scope?: string; tags?: string[] }
223
+ params: {
224
+ content: string;
225
+ scope?: string;
226
+ tags?: string[];
227
+ type?: string;
228
+ project?: string;
229
+ title?: string;
230
+ }
197
231
  ) {
198
232
  const args: string[] = ["write", params.content];
199
233
  if (params.scope) {
200
- args.push("--scope", params.scope);
234
+ if (!isValidScope(params.scope)) {
235
+ return {
236
+ content: [
237
+ {
238
+ type: "text" as const,
239
+ text: `Invalid scope "${params.scope}". Valid scopes: private, team, public, shared:<name>`,
240
+ },
241
+ ],
242
+ };
243
+ }
244
+ args.push("--scope", sanitizeScope(params.scope));
201
245
  }
202
246
  if (params.tags && params.tags.length > 0) {
203
247
  args.push("--tags", params.tags.join(","));
204
248
  }
249
+ if (params.type) {
250
+ args.push("--type", params.type);
251
+ }
252
+ if (params.project) {
253
+ args.push("--project", params.project);
254
+ }
255
+ if (params.title) {
256
+ args.push("--title", params.title);
257
+ }
205
258
 
206
259
  const result = await runJson<WriteResult>(args, opts);
207
260