polpo-ai 0.6.20 → 0.6.22
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.
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { SkillStore, SkillRecord } from "@polpo-ai/core";
|
|
2
|
+
/**
|
|
3
|
+
* File-backed SkillStore.
|
|
4
|
+
*
|
|
5
|
+
* Persists the full catalog to `${polpoDir}/skills-index.json` as a
|
|
6
|
+
* JSON object keyed by skill name. Writes are atomic (tmp + rename).
|
|
7
|
+
*
|
|
8
|
+
* Legacy compatibility: the old `skills-index.json` format contained
|
|
9
|
+
* only `{ tags?, category? }` per skill. This store reads those files
|
|
10
|
+
* transparently (treating them as partial records) and the caller —
|
|
11
|
+
* typically the upsert triggered by skills/add — fills in the full
|
|
12
|
+
* record on next write.
|
|
13
|
+
*/
|
|
14
|
+
export declare class FileSkillStore implements SkillStore {
|
|
15
|
+
private readonly filePath;
|
|
16
|
+
constructor(polpoDir: string);
|
|
17
|
+
list(): Promise<SkillRecord[]>;
|
|
18
|
+
get(name: string): Promise<SkillRecord | undefined>;
|
|
19
|
+
upsert(record: SkillRecord): Promise<void>;
|
|
20
|
+
remove(name: string): Promise<boolean>;
|
|
21
|
+
/** Read the JSON file, normalising legacy shapes. */
|
|
22
|
+
private readAll;
|
|
23
|
+
/** Write the full catalog atomically (tmp + rename). */
|
|
24
|
+
private writeAll;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=file-skill-store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-skill-store.d.ts","sourceRoot":"","sources":["../../src/stores/file-skill-store.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE9D;;;;;;;;;;;GAWG;AACH,qBAAa,cAAe,YAAW,UAAU;IAC/C,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;gBAEtB,QAAQ,EAAE,MAAM;IAItB,IAAI,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;IAK9B,GAAG,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC;IAKnD,MAAM,CAAC,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAM1C,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAQ5C,qDAAqD;IACrD,OAAO,CAAC,OAAO;IAqCf,wDAAwD;IACxD,OAAO,CAAC,QAAQ;CAOjB"}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { existsSync, readFileSync, writeFileSync, mkdirSync, renameSync, } from "node:fs";
|
|
2
|
+
import { join, dirname } from "node:path";
|
|
3
|
+
/**
|
|
4
|
+
* File-backed SkillStore.
|
|
5
|
+
*
|
|
6
|
+
* Persists the full catalog to `${polpoDir}/skills-index.json` as a
|
|
7
|
+
* JSON object keyed by skill name. Writes are atomic (tmp + rename).
|
|
8
|
+
*
|
|
9
|
+
* Legacy compatibility: the old `skills-index.json` format contained
|
|
10
|
+
* only `{ tags?, category? }` per skill. This store reads those files
|
|
11
|
+
* transparently (treating them as partial records) and the caller —
|
|
12
|
+
* typically the upsert triggered by skills/add — fills in the full
|
|
13
|
+
* record on next write.
|
|
14
|
+
*/
|
|
15
|
+
export class FileSkillStore {
|
|
16
|
+
filePath;
|
|
17
|
+
constructor(polpoDir) {
|
|
18
|
+
this.filePath = join(polpoDir, "skills-index.json");
|
|
19
|
+
}
|
|
20
|
+
async list() {
|
|
21
|
+
const all = this.readAll();
|
|
22
|
+
return Object.values(all);
|
|
23
|
+
}
|
|
24
|
+
async get(name) {
|
|
25
|
+
const all = this.readAll();
|
|
26
|
+
return all[name];
|
|
27
|
+
}
|
|
28
|
+
async upsert(record) {
|
|
29
|
+
const all = this.readAll();
|
|
30
|
+
all[record.name] = record;
|
|
31
|
+
this.writeAll(all);
|
|
32
|
+
}
|
|
33
|
+
async remove(name) {
|
|
34
|
+
const all = this.readAll();
|
|
35
|
+
if (!(name in all))
|
|
36
|
+
return false;
|
|
37
|
+
delete all[name];
|
|
38
|
+
this.writeAll(all);
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
/** Read the JSON file, normalising legacy shapes. */
|
|
42
|
+
readAll() {
|
|
43
|
+
if (!existsSync(this.filePath))
|
|
44
|
+
return {};
|
|
45
|
+
let raw;
|
|
46
|
+
try {
|
|
47
|
+
raw = readFileSync(this.filePath, "utf-8");
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
return {};
|
|
51
|
+
}
|
|
52
|
+
if (!raw.trim())
|
|
53
|
+
return {};
|
|
54
|
+
let parsed;
|
|
55
|
+
try {
|
|
56
|
+
parsed = JSON.parse(raw);
|
|
57
|
+
}
|
|
58
|
+
catch {
|
|
59
|
+
return {};
|
|
60
|
+
}
|
|
61
|
+
if (!parsed || typeof parsed !== "object")
|
|
62
|
+
return {};
|
|
63
|
+
const out = {};
|
|
64
|
+
for (const [name, value] of Object.entries(parsed)) {
|
|
65
|
+
if (!value || typeof value !== "object")
|
|
66
|
+
continue;
|
|
67
|
+
const v = value;
|
|
68
|
+
out[name] = {
|
|
69
|
+
name,
|
|
70
|
+
description: typeof v.description === "string" ? v.description : "",
|
|
71
|
+
source: typeof v.source === "string" ? v.source : undefined,
|
|
72
|
+
installedAt: typeof v.installedAt === "string"
|
|
73
|
+
? v.installedAt
|
|
74
|
+
: new Date(0).toISOString(),
|
|
75
|
+
allowedTools: Array.isArray(v.allowedTools) ? v.allowedTools : undefined,
|
|
76
|
+
tags: Array.isArray(v.tags) ? v.tags : undefined,
|
|
77
|
+
category: typeof v.category === "string" ? v.category : undefined,
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
return out;
|
|
81
|
+
}
|
|
82
|
+
/** Write the full catalog atomically (tmp + rename). */
|
|
83
|
+
writeAll(all) {
|
|
84
|
+
const dir = dirname(this.filePath);
|
|
85
|
+
if (!existsSync(dir))
|
|
86
|
+
mkdirSync(dir, { recursive: true });
|
|
87
|
+
const tmp = this.filePath + ".tmp";
|
|
88
|
+
writeFileSync(tmp, JSON.stringify(all, null, 2) + "\n", "utf-8");
|
|
89
|
+
renameSync(tmp, this.filePath);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
//# sourceMappingURL=file-skill-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-skill-store.js","sourceRoot":"","sources":["../../src/stores/file-skill-store.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,YAAY,EACZ,aAAa,EACb,SAAS,EACT,UAAU,GACX,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAG1C;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,cAAc;IACR,QAAQ,CAAS;IAElC,YAAY,QAAgB;QAC1B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,EAAE,mBAAmB,CAAC,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,IAAI;QACR,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;QAC3B,OAAO,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,IAAY;QACpB,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;QAC3B,OAAO,GAAG,CAAC,IAAI,CAAC,CAAC;IACnB,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,MAAmB;QAC9B,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;QAC3B,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC;QAC1B,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IACrB,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,IAAY;Q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F"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "polpo-ai",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.22",
|
|
4
4
|
"description": "The open backend for AI agents",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -66,10 +66,10 @@
|
|
|
66
66
|
"nanoid": "^5.1.2",
|
|
67
67
|
"yaml": "^2.7.0",
|
|
68
68
|
"zod": "^4.3.6",
|
|
69
|
-
"@polpo-ai/
|
|
70
|
-
"@polpo-ai/
|
|
71
|
-
"@polpo-ai/
|
|
72
|
-
"@polpo-ai/
|
|
69
|
+
"@polpo-ai/llm": "0.6.22",
|
|
70
|
+
"@polpo-ai/server": "0.6.22",
|
|
71
|
+
"@polpo-ai/vault-crypto": "0.6.22",
|
|
72
|
+
"@polpo-ai/core": "0.6.22"
|
|
73
73
|
},
|
|
74
74
|
"optionalDependencies": {
|
|
75
75
|
"better-sqlite3": "^12.6.2",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"nodemailer": "^8.0.1",
|
|
78
78
|
"playwright-core": "^1.52.0",
|
|
79
79
|
"postgres": "^3.4.0",
|
|
80
|
-
"@polpo-ai/drizzle": "0.6.
|
|
80
|
+
"@polpo-ai/drizzle": "0.6.22"
|
|
81
81
|
},
|
|
82
82
|
"devDependencies": {
|
|
83
83
|
"@types/better-sqlite3": "^7.6.13",
|