@anhlp/alp-paseo 0.0.0-beta.2 → 0.0.1-beta.3
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 +16 -4
- package/client/library.tsx +22 -6
- package/package.json +14 -14
- package/paseo-plugin.json +1 -1
- package/server/dist/THIRD-PARTY-NOTICES.txt +2 -2
- package/server/dist/alpd.js +705 -326
- package/server/dist/index.js +686 -273
- package/server/dist/library.js +65 -9
- package/server/dist/main.js +284 -102
- package/server/dist/mapping.js +4 -2
- package/server/dist/panel/library.js +65 -9
- package/server/dist/panel/mapping.js +4 -2
- package/server/dist/panel/tasks.js +1 -1
- package/server/dist/panel/usage.js +3 -3
- package/server/dist/paseo/agents.js +62 -18
- package/server/dist/paseo/index.js +166 -68
- package/server/dist/paseo/plugins.js +84 -28
- package/server/dist/paseo/providers.js +44 -3
- package/server/dist/provider-core.js +14 -0
- package/server/dist/provider.js +574 -209
- package/server/dist/remote/index.js +34 -5
- package/server/dist/remote/link.js +1 -1
- package/server/dist/remote/panels.js +20 -5
- package/server/dist/remote/provider.js +15 -1
- package/server/dist/session-usage.js +15 -0
- package/server/dist/tasks.js +1 -1
- package/server/dist/usage.js +3 -3
- package/server/dist/web.js +1 -1
- package/shared/library.ts +2 -0
|
@@ -113,7 +113,7 @@ function ensureLibrary(home, options = {}) {
|
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
// packages/core/src/library-edit.js
|
|
116
|
-
import { mkdir as mkdir2, rename as rename2, rm as rm2, stat as stat2, writeFile as writeFile3 } from "node:fs/promises";
|
|
116
|
+
import { lstat as lstat2, mkdir as mkdir2, readdir as readdir5, rename as rename2, rm as rm2, stat as stat2, writeFile as writeFile3 } from "node:fs/promises";
|
|
117
117
|
import { createHash as createHash2, randomUUID as randomUUID2 } from "node:crypto";
|
|
118
118
|
import path7 from "node:path";
|
|
119
119
|
|
|
@@ -648,6 +648,42 @@ function base(scope, { root, library }, kind) {
|
|
|
648
648
|
return fail("INVALID_SCOPE", `Scope must be library or project, not '${scope}'`);
|
|
649
649
|
}
|
|
650
650
|
var revisionOf = (content) => content === void 0 ? null : createHash2("sha256").update(JSON.stringify(content)).digest("hex").slice(0, 16);
|
|
651
|
+
function assertProjectDataContent(kind, content) {
|
|
652
|
+
const deny = () => fail("UNSAFE_LIBRARY_WRITE", "Project-data writes allow only instruction entries and non-executable agent configuration");
|
|
653
|
+
if (!object4(content) || !["agents", "skills"].includes(kind)) deny();
|
|
654
|
+
const keys2 = kind === "skills" ? ["body"] : ["instructions", "config"];
|
|
655
|
+
if (Object.keys(content).some((key) => !keys2.includes(key))) deny();
|
|
656
|
+
const text = kind === "skills" ? content.body : content.instructions;
|
|
657
|
+
if (typeof text !== "string" || !text.trim()) deny();
|
|
658
|
+
if (content.config !== void 0) {
|
|
659
|
+
const config = content.config;
|
|
660
|
+
if (!object4(config)) deny();
|
|
661
|
+
const allowed = ["description", "model", "thinking", "context", "autocompact"];
|
|
662
|
+
if (Object.keys(config).some((key) => !allowed.includes(key))) deny();
|
|
663
|
+
for (const key of ["description", "thinking"]) if (config[key] !== void 0 && typeof config[key] !== "string") deny();
|
|
664
|
+
if (config.model !== void 0 && (typeof config.model !== "string" || !/^(codex|claude):[^\s/\\:]{1,240}$/.test(config.model))) deny();
|
|
665
|
+
for (const key of ["context", "autocompact"]) if (config[key] !== void 0 && !(typeof config[key] === "string" || typeof config[key] === "number" && Number.isFinite(config[key]))) deny();
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
async function projectDataEntry(kind, name, { scope, root, library, templates }) {
|
|
669
|
+
if (scope !== "project" || !root || !["agents", "skills"].includes(kind)) fail("UNSAFE_LIBRARY_WRITE", "Project-data writes require project scope and agents or skills");
|
|
670
|
+
nameOf(name);
|
|
671
|
+
const directory = base(scope, { root, library }, kind);
|
|
672
|
+
await safeEntryPaths(directory, kind, name);
|
|
673
|
+
const found = await layers(kind, name, { root, library, templates });
|
|
674
|
+
if (found.library !== void 0 || found.builtin !== void 0) fail("UNSAFE_LIBRARY_WRITE", "Project-data writes cannot shadow or reveal a library or built-in entry");
|
|
675
|
+
if (found.project !== void 0) assertProjectDataContent(kind, found.project);
|
|
676
|
+
const owned = path7.join(directory, kind, name);
|
|
677
|
+
const files = await readdir5(owned).catch((error) => {
|
|
678
|
+
if (error.code === "ENOENT") return [];
|
|
679
|
+
throw error;
|
|
680
|
+
});
|
|
681
|
+
const allowed = new Set(FILES[kind](name).map(([file]) => path7.basename(file)));
|
|
682
|
+
for (const file of files) {
|
|
683
|
+
const info = await lstat2(path7.join(owned, file));
|
|
684
|
+
if (!allowed.has(file) || !info.isFile() || info.isSymbolicLink() || info.nlink !== 1) fail("UNSAFE_LIBRARY_WRITE", "Project-data entries cannot contain sidecars, links or executable assets");
|
|
685
|
+
}
|
|
686
|
+
}
|
|
651
687
|
async function safeEntryPaths(directory, kind, name) {
|
|
652
688
|
for (const [file] of FILES[kind](name)) {
|
|
653
689
|
await assertNoSymlinks(directory, path7.join(kind, file));
|
|
@@ -825,9 +861,13 @@ async function writeAtomic(file, text) {
|
|
|
825
861
|
await writeFile3(temporary, text);
|
|
826
862
|
await moveFile(temporary, file);
|
|
827
863
|
}
|
|
828
|
-
async function saveEntry(kind, name, content, { scope, root, library, templates, revision } = {}) {
|
|
864
|
+
async function saveEntry(kind, name, content, { scope, root, library, templates, revision, policy } = {}) {
|
|
829
865
|
kindOf(kind);
|
|
830
866
|
nameOf(name);
|
|
867
|
+
if (policy === "project-data") {
|
|
868
|
+
assertProjectDataContent(kind, content);
|
|
869
|
+
await projectDataEntry(kind, name, { scope, root, library, templates });
|
|
870
|
+
}
|
|
831
871
|
const directory = base(scope, { root, library }, kind);
|
|
832
872
|
await safeEntryPaths(directory, kind, name);
|
|
833
873
|
await check(kind, name, content, { scope, root, library, templates });
|
|
@@ -849,9 +889,10 @@ async function saveEntry(kind, name, content, { scope, root, library, templates,
|
|
|
849
889
|
}
|
|
850
890
|
return { revision: revisionOf(await readLayer(kind, name, directory)) };
|
|
851
891
|
}
|
|
852
|
-
async function deleteEntry(kind, name, { scope, root, library, templates, revision } = {}) {
|
|
892
|
+
async function deleteEntry(kind, name, { scope, root, library, templates, revision, policy } = {}) {
|
|
853
893
|
kindOf(kind);
|
|
854
894
|
nameOf(name);
|
|
895
|
+
if (policy === "project-data") await projectDataEntry(kind, name, { scope, root, library, templates });
|
|
855
896
|
const directory = base(scope, { root, library }, kind);
|
|
856
897
|
const current = await readLayer(kind, name, directory);
|
|
857
898
|
if (current === void 0) fail("NOT_FOUND", `No ${kind} entry '${name}' in the ${scope}`);
|
|
@@ -59,6 +59,17 @@ function paseoDetail(detail) {
|
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
+
// integrations/paseo/server/session-usage.ts
|
|
63
|
+
var USAGE_FIELDS = ["inputTokens", "cachedInputTokens", "outputTokens", "totalCostUsd", "contextWindowMaxTokens", "contextWindowUsedTokens"];
|
|
64
|
+
function agentUsage(usage) {
|
|
65
|
+
const out = {};
|
|
66
|
+
for (const key of USAGE_FIELDS) {
|
|
67
|
+
const value = usage?.[key];
|
|
68
|
+
if (typeof value === "number" && Number.isFinite(value)) out[key] = value;
|
|
69
|
+
}
|
|
70
|
+
return out;
|
|
71
|
+
}
|
|
72
|
+
|
|
62
73
|
// integrations/paseo/server/provider-core.ts
|
|
63
74
|
var supported = [
|
|
64
75
|
"prompt.message",
|
|
@@ -215,6 +226,9 @@ function createAlpProvider(strategy) {
|
|
|
215
226
|
case "turn.ended":
|
|
216
227
|
emit({ type: "session.turn", sessionId, turnId: event.turnId, state: event.state, ...event.error ? { error: event.error } : {} });
|
|
217
228
|
return;
|
|
229
|
+
case "usage":
|
|
230
|
+
emit({ type: "session.usage", sessionId, usage: agentUsage(event.usage) });
|
|
231
|
+
return;
|
|
218
232
|
case "item":
|
|
219
233
|
if (event.item.kind === "todo") {
|
|
220
234
|
sessionTasks.set(sessionId, event.item.items.map((entry) => entry.id));
|