@parall/cli 1.83.0 → 1.84.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/dist/commands/apps-scaffold.d.ts +4 -4
- package/dist/commands/apps-scaffold.d.ts.map +1 -1
- package/dist/commands/apps-scaffold.js +24 -16
- package/dist/commands/apps-template-catalog.d.ts +46 -72
- package/dist/commands/apps-template-catalog.d.ts.map +1 -1
- package/dist/commands/apps-template-catalog.js +107 -22
- package/dist/commands/apps-template-download.d.ts +7 -0
- package/dist/commands/apps-template-download.d.ts.map +1 -0
- package/dist/commands/apps-template-download.js +116 -0
- package/dist/commands/apps-template-init.d.ts +22 -25
- package/dist/commands/apps-template-init.d.ts.map +1 -1
- package/dist/commands/apps-template-init.js +16 -60
- package/dist/commands/apps-template.d.ts +3 -2
- package/dist/commands/apps-template.d.ts.map +1 -1
- package/dist/commands/apps-template.js +4 -1
- package/dist/commands/triggers.d.ts.map +1 -1
- package/dist/commands/triggers.js +11 -45
- package/dist/commands/wiki-changesets.d.ts.map +1 -1
- package/dist/commands/wiki-changesets.js +10 -2
- package/dist/commands/wiki-edit.d.ts +7 -0
- package/dist/commands/wiki-edit.d.ts.map +1 -0
- package/dist/commands/wiki-edit.js +50 -0
- package/dist/commands/wiki.d.ts.map +1 -1
- package/dist/commands/wiki.js +2 -0
- package/dist/lib/output.d.ts +7 -0
- package/dist/lib/output.d.ts.map +1 -1
- package/dist/lib/output.js +14 -0
- package/dist/lib/trigger-arguments.d.ts +47 -0
- package/dist/lib/trigger-arguments.d.ts.map +1 -0
- package/dist/lib/trigger-arguments.js +126 -0
- package/dist/lib/wiki-copies.d.ts +18 -0
- package/dist/lib/wiki-copies.d.ts.map +1 -0
- package/dist/lib/wiki-copies.js +88 -0
- package/dist/lib/wiki-edit.d.ts +22 -0
- package/dist/lib/wiki-edit.d.ts.map +1 -0
- package/dist/lib/wiki-edit.js +74 -0
- package/dist/lib/wiki-service-error.d.ts +10 -0
- package/dist/lib/wiki-service-error.d.ts.map +1 -0
- package/dist/lib/wiki-service-error.js +23 -0
- package/dist/lib/wiki-shared.d.ts.map +1 -1
- package/dist/lib/wiki-shared.js +2 -1
- package/dist/lib/wiki-stale-mounts.d.ts +2 -0
- package/dist/lib/wiki-stale-mounts.d.ts.map +1 -0
- package/dist/lib/wiki-stale-mounts.js +59 -0
- package/dist/lib/wiki-sync.d.ts.map +1 -1
- package/dist/lib/wiki-sync.js +4 -59
- package/package.json +5 -5
- package/dist/commands/apps-template-catalog.gen.d.ts +0 -3
- package/dist/commands/apps-template-catalog.gen.d.ts.map +0 -1
- package/dist/commands/apps-template-catalog.gen.js +0 -242
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type ParallContext } from './wiki-shared.js';
|
|
2
|
+
import { WikiServiceError } from './wiki-service-error.js';
|
|
3
|
+
/** A whole-library read wiki-service refused to an agent held to its callers. */
|
|
4
|
+
export declare function isWholeWikiRefusal(error: unknown): error is WikiServiceError;
|
|
5
|
+
/** Thrown after the local copies were removed. */
|
|
6
|
+
export declare class WikiCopiesRetiredError extends Error {
|
|
7
|
+
readonly removed: string[];
|
|
8
|
+
constructor(removed: string[]);
|
|
9
|
+
}
|
|
10
|
+
/** Where the agent's wiki copies live, when it keeps them under one root. */
|
|
11
|
+
export declare function wikiMountRoot(ctx: ParallContext): string | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* Runs `work` (a sync, or a propose from a copy). When wiki-service refuses
|
|
14
|
+
* the whole-library read, removes every wiki copy under `root`, or the one
|
|
15
|
+
* `copy` when there is no root, and throws WikiCopiesRetiredError instead.
|
|
16
|
+
*/
|
|
17
|
+
export declare function retireCopiesOnRefusal<T>(work: () => Promise<T>, root: string | undefined, copy?: string): Promise<T>;
|
|
18
|
+
//# sourceMappingURL=wiki-copies.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wiki-copies.d.ts","sourceRoot":"","sources":["../../src/lib/wiki-copies.ts"],"names":[],"mappings":"AAUA,OAAO,EAAsC,KAAK,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC1F,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAI3D,iFAAiF;AACjF,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,gBAAgB,CAE5E;AAED,kDAAkD;AAClD,qBAAa,sBAAuB,SAAQ,KAAK;IAC/C,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,CAAC;gBAEf,OAAO,EAAE,MAAM,EAAE;CAU9B;AAED,6EAA6E;AAC7E,wBAAgB,aAAa,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,GAAG,SAAS,CAEpE;AAED;;;;GAIG;AACH,wBAAsB,qBAAqB,CAAC,CAAC,EAC3C,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACtB,IAAI,EAAE,MAAM,GAAG,SAAS,EACxB,IAAI,CAAC,EAAE,MAAM,GACZ,OAAO,CAAC,CAAC,CAAC,CAaZ"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// Whole-library wiki copies while an organization keeps agents within what
|
|
2
|
+
// the people they work for can see (agent-caller-scope-design.md §4.5):
|
|
3
|
+
// wiki-service closes the manifest and bulk download to its agents, because a
|
|
4
|
+
// copy on disk outlives the turn it was read in. When a sync or a propose
|
|
5
|
+
// from a copy meets that refusal, the CLI removes the copies it made and
|
|
6
|
+
// points at the online commands. This only tidies up: a copy may have been
|
|
7
|
+
// moved elsewhere already.
|
|
8
|
+
import { promises as fs } from 'node:fs';
|
|
9
|
+
import path from 'node:path';
|
|
10
|
+
import { LOCAL_MANIFEST_FILE, PRLL_WIKI_DIR } from './wiki-shared.js';
|
|
11
|
+
import { WikiServiceError } from './wiki-service-error.js';
|
|
12
|
+
const ROUTE_CLOSED = 'AGENT_ROUTE_CLOSED';
|
|
13
|
+
/** A whole-library read wiki-service refused to an agent held to its callers. */
|
|
14
|
+
export function isWholeWikiRefusal(error) {
|
|
15
|
+
return error instanceof WikiServiceError && error.status === 403 && error.code === ROUTE_CLOSED;
|
|
16
|
+
}
|
|
17
|
+
/** Thrown after the local copies were removed. */
|
|
18
|
+
export class WikiCopiesRetiredError extends Error {
|
|
19
|
+
removed;
|
|
20
|
+
constructor(removed) {
|
|
21
|
+
const where = removed.length > 0 ? ` Removed the local copies: ${removed.join(', ')}.` : '';
|
|
22
|
+
super('This organization keeps agents within what the people they work for can see, so whole-wiki copies are not allowed.' +
|
|
23
|
+
`${where} Read a page with \`parall wiki cat <path> [wiki] --remote\` and change one with ` +
|
|
24
|
+
'`parall wiki edit <path> [wiki] --file <file>`.');
|
|
25
|
+
this.name = 'WikiCopiesRetiredError';
|
|
26
|
+
this.removed = removed;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/** Where the agent's wiki copies live, when it keeps them under one root. */
|
|
30
|
+
export function wikiMountRoot(ctx) {
|
|
31
|
+
return ctx.mountRoot?.trim() || process.env.PRLL_WIKI_MOUNT_ROOT?.trim() || undefined;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Runs `work` (a sync, or a propose from a copy). When wiki-service refuses
|
|
35
|
+
* the whole-library read, removes every wiki copy under `root`, or the one
|
|
36
|
+
* `copy` when there is no root, and throws WikiCopiesRetiredError instead.
|
|
37
|
+
*/
|
|
38
|
+
export async function retireCopiesOnRefusal(work, root, copy) {
|
|
39
|
+
try {
|
|
40
|
+
return await work();
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
if (!isWholeWikiRefusal(error))
|
|
44
|
+
throw error;
|
|
45
|
+
let removed = [];
|
|
46
|
+
if (root?.trim()) {
|
|
47
|
+
removed = await removeCopiesUnder(path.resolve(root));
|
|
48
|
+
}
|
|
49
|
+
else if (copy?.trim()) {
|
|
50
|
+
removed = await removeCopy(path.resolve(copy));
|
|
51
|
+
}
|
|
52
|
+
throw new WikiCopiesRetiredError(removed);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
async function removeCopy(dir) {
|
|
56
|
+
if (!(await isCopy(dir)))
|
|
57
|
+
return [];
|
|
58
|
+
await fs.rm(dir, { recursive: true, force: true });
|
|
59
|
+
return [dir];
|
|
60
|
+
}
|
|
61
|
+
// Copies beneath `dir`, never `dir` itself: the CLI never makes a copy at the
|
|
62
|
+
// mount root (resolveMountPath refuses it), so a root holding a manifest is
|
|
63
|
+
// not one to delete.
|
|
64
|
+
async function removeCopiesUnder(dir) {
|
|
65
|
+
let names;
|
|
66
|
+
try {
|
|
67
|
+
names = await fs.readdir(dir);
|
|
68
|
+
}
|
|
69
|
+
catch {
|
|
70
|
+
return [];
|
|
71
|
+
}
|
|
72
|
+
const removed = [];
|
|
73
|
+
for (const name of names) {
|
|
74
|
+
const full = path.join(dir, name);
|
|
75
|
+
const stat = await fs.lstat(full).catch(() => null);
|
|
76
|
+
if (!stat?.isDirectory() || stat.isSymbolicLink())
|
|
77
|
+
continue;
|
|
78
|
+
const copy = await removeCopy(full);
|
|
79
|
+
removed.push(...(copy.length > 0 ? copy : await removeCopiesUnder(full)));
|
|
80
|
+
}
|
|
81
|
+
return removed;
|
|
82
|
+
}
|
|
83
|
+
async function isCopy(dir) {
|
|
84
|
+
return fs
|
|
85
|
+
.stat(path.join(dir, PRLL_WIKI_DIR, LOCAL_MANIFEST_FILE))
|
|
86
|
+
.then((s) => s.isFile())
|
|
87
|
+
.catch(() => false);
|
|
88
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { type WikiChangeset } from '@parall/sdk';
|
|
2
|
+
import { type ParallContext } from './wiki-shared.js';
|
|
3
|
+
export interface WikiEditOptions {
|
|
4
|
+
title?: string;
|
|
5
|
+
message?: string;
|
|
6
|
+
sourceChatId?: string;
|
|
7
|
+
sourceMessageId?: string;
|
|
8
|
+
sourceRunId?: string;
|
|
9
|
+
}
|
|
10
|
+
export interface WikiEditResult {
|
|
11
|
+
wiki_id: string;
|
|
12
|
+
wiki_slug: string;
|
|
13
|
+
path: string;
|
|
14
|
+
action: 'create' | 'update';
|
|
15
|
+
changeset: WikiChangeset;
|
|
16
|
+
status: WikiChangeset['status'];
|
|
17
|
+
auto_merged: boolean;
|
|
18
|
+
next_action: string;
|
|
19
|
+
source: 'online';
|
|
20
|
+
}
|
|
21
|
+
export declare function editWikiFileOnline(ctx: ParallContext, wikiRef: string | undefined, filePath: string, content: Buffer, options: WikiEditOptions): Promise<WikiEditResult>;
|
|
22
|
+
//# sourceMappingURL=wiki-edit.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wiki-edit.d.ts","sourceRoot":"","sources":["../../src/lib/wiki-edit.ts"],"names":[],"mappings":"AAOA,OAAO,EAAY,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EACL,KAAK,aAAa,EAMnB,MAAM,kBAAkB,CAAC;AAE1B,MAAM,WAAW,eAAe;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC5B,SAAS,EAAE,aAAa,CAAC;IACzB,MAAM,EAAE,aAAa,CAAC,QAAQ,CAAC,CAAC;IAChC,WAAW,EAAE,OAAO,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE,QAAQ,CAAC;CAClB;AAED,wBAAsB,kBAAkB,CACtC,GAAG,EAAE,aAAa,EAClB,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,eAAe,GACvB,OAAO,CAAC,cAAc,CAAC,CAmCzB"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// Online wiki edit: change one page without a local copy. The page is read
|
|
2
|
+
// from the server for its current version, and the whole new content goes in
|
|
3
|
+
// a changeset guarded by that version (base_sha), so a concurrent edit is
|
|
4
|
+
// refused instead of rolled back. The agent path while its organization keeps
|
|
5
|
+
// agents within their callers (agent-caller-scope-design.md §4.5), and usable
|
|
6
|
+
// by anyone.
|
|
7
|
+
import { ApiError } from '@parall/sdk';
|
|
8
|
+
import { TEXT_MAX_BYTES, looksBinary, normalizeOptionalString, normalizeRequiredWikiPath, resolveWikiRef, } from './wiki-shared.js';
|
|
9
|
+
export async function editWikiFileOnline(ctx, wikiRef, filePath, content, options) {
|
|
10
|
+
const wiki = await resolveWikiRef(ctx, wikiRef);
|
|
11
|
+
const pagePath = normalizeRequiredWikiPath(filePath);
|
|
12
|
+
if (content.length > TEXT_MAX_BYTES || looksBinary(content)) {
|
|
13
|
+
throw new Error(`${pagePath}: \`parall wiki edit\` changes text pages only; upload files with \`parall wiki file upload\``);
|
|
14
|
+
}
|
|
15
|
+
const baseSha = await currentVersion(ctx, wiki.id, pagePath);
|
|
16
|
+
const changeset = await ctx.client.createWikiChangeset(ctx.orgId, wiki.id, {
|
|
17
|
+
title: normalizeOptionalString(options.title) ?? `Edit ${pagePath}`,
|
|
18
|
+
message: normalizeOptionalString(options.message),
|
|
19
|
+
file_changes: [
|
|
20
|
+
{
|
|
21
|
+
path: pagePath,
|
|
22
|
+
action: baseSha ? 'update' : 'create',
|
|
23
|
+
content_base64: content.toString('base64'),
|
|
24
|
+
...(baseSha ? { base_sha: baseSha } : {}),
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
source_chat_id: normalizeOptionalString(options.sourceChatId),
|
|
28
|
+
source_message_id: normalizeOptionalString(options.sourceMessageId),
|
|
29
|
+
source_run_id: normalizeOptionalString(options.sourceRunId),
|
|
30
|
+
});
|
|
31
|
+
return {
|
|
32
|
+
wiki_id: wiki.id,
|
|
33
|
+
wiki_slug: wiki.slug,
|
|
34
|
+
path: pagePath,
|
|
35
|
+
action: baseSha ? 'update' : 'create',
|
|
36
|
+
changeset,
|
|
37
|
+
status: changeset.status,
|
|
38
|
+
auto_merged: changeset.status === 'merged',
|
|
39
|
+
next_action: describeOnlineEditNextAction(changeset),
|
|
40
|
+
source: 'online',
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/** The page's current blob SHA, or undefined when it does not exist yet. */
|
|
44
|
+
async function currentVersion(ctx, wikiId, pagePath) {
|
|
45
|
+
try {
|
|
46
|
+
const blob = await ctx.client.getWikiBlob(ctx.orgId, wikiId, { path: pagePath });
|
|
47
|
+
// A binary comes back as a signed URL, or inline base64 when no link can
|
|
48
|
+
// be signed (an agent held to its callers gets none).
|
|
49
|
+
if (blob.encoding !== 'utf-8' || !blob.sha) {
|
|
50
|
+
throw new Error(`${pagePath} is a binary file: \`parall wiki edit\` changes text pages only; upload files with \`parall wiki file upload\``);
|
|
51
|
+
}
|
|
52
|
+
return blob.sha;
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
if (error instanceof ApiError && error.status === 404 && error.code === 'FILE_NOT_FOUND') {
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
throw error;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
function describeOnlineEditNextAction(changeset) {
|
|
62
|
+
switch (changeset.status) {
|
|
63
|
+
case 'merged':
|
|
64
|
+
return 'Merged: the page is live.';
|
|
65
|
+
case 'conflict':
|
|
66
|
+
return 'The page changed while you edited it. Read it again with `parall wiki cat <path> --remote`, redo the edit and run `parall wiki edit` again.';
|
|
67
|
+
case 'proposed':
|
|
68
|
+
case 'approval_pending':
|
|
69
|
+
case 'approved':
|
|
70
|
+
return 'Awaiting review: the change touches a protected path or auto-merge was skipped.';
|
|
71
|
+
default:
|
|
72
|
+
return `Changeset is ${changeset.status}.`;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A non-2xx answer from wiki-service. The message keeps the shape callers
|
|
3
|
+
* have always printed; `status` and `code` let them tell refusals apart.
|
|
4
|
+
*/
|
|
5
|
+
export declare class WikiServiceError extends Error {
|
|
6
|
+
readonly status: number;
|
|
7
|
+
readonly code?: string;
|
|
8
|
+
constructor(method: string, url: string, status: number, statusText: string, body: string);
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=wiki-service-error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wiki-service-error.d.ts","sourceRoot":"","sources":["../../src/lib/wiki-service-error.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;gBAEX,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;CAM1F"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A non-2xx answer from wiki-service. The message keeps the shape callers
|
|
3
|
+
* have always printed; `status` and `code` let them tell refusals apart.
|
|
4
|
+
*/
|
|
5
|
+
export class WikiServiceError extends Error {
|
|
6
|
+
status;
|
|
7
|
+
code;
|
|
8
|
+
constructor(method, url, status, statusText, body) {
|
|
9
|
+
super(`wiki-service ${method} ${url}: ${status} ${statusText}${body ? ` — ${body}` : ''}`);
|
|
10
|
+
this.name = 'WikiServiceError';
|
|
11
|
+
this.status = status;
|
|
12
|
+
this.code = parseErrorCode(body);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function parseErrorCode(body) {
|
|
16
|
+
try {
|
|
17
|
+
const code = JSON.parse(body).error?.code;
|
|
18
|
+
return typeof code === 'string' ? code : undefined;
|
|
19
|
+
}
|
|
20
|
+
catch {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wiki-shared.d.ts","sourceRoot":"","sources":["../../src/lib/wiki-shared.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"wiki-shared.d.ts","sourceRoot":"","sources":["../../src/lib/wiki-shared.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,IAAI,EAAE,KAAK,QAAQ,EAAE,KAAK,YAAY,EAAE,MAAM,aAAa,CAAC;AAK7F,MAAM,MAAM,aAAa,GAAG;IAC1B,MAAM,EAAE,YAAY,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,yFAAyF;IACzF,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kFAAkF;IAClF,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EA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EAAE,MAAM,GAAG,OAAO,CAGxD;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAEvD;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAQpE;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE7C;AAED,wBAAgB,uBAAuB,CAAC,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,MAAM,GAAG,SAAS,CAGjF;AAED,wBAAsB,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAOjE;AAED,wBAAgB,cAAc,CAAC,GAAG,EAAE,aAAa,GAAG,MAAM,CAMzD"}
|
package/dist/lib/wiki-shared.js
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// wiki resolution, wiki-service REST helpers, blob hashing and path utilities.
|
|
3
3
|
// Entry point for consumers is ./wiki.ts, which re-exports the public surface.
|
|
4
4
|
import { createHash } from 'node:crypto';
|
|
5
|
+
import { WikiServiceError } from './wiki-service-error.js';
|
|
5
6
|
import { promises as fs } from 'node:fs';
|
|
6
7
|
import path from 'node:path';
|
|
7
8
|
// ---------------------------------------------------------------------------
|
|
@@ -104,7 +105,7 @@ export async function wikiServiceFetch(url, token, options = {}) {
|
|
|
104
105
|
});
|
|
105
106
|
if (!response.ok) {
|
|
106
107
|
const text = await response.text().catch(() => '');
|
|
107
|
-
throw new
|
|
108
|
+
throw new WikiServiceError(method, url, response.status, response.statusText, text);
|
|
108
109
|
}
|
|
109
110
|
return response.json();
|
|
110
111
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wiki-stale-mounts.d.ts","sourceRoot":"","sources":["../../src/lib/wiki-stale-mounts.ts"],"names":[],"mappings":"AAOA,wBAAsB,gBAAgB,CACpC,SAAS,EAAE,MAAM,GAAG,SAAS,EAC7B,WAAW,EAAE,GAAG,CAAC,MAAM,CAAC,GACvB,OAAO,CAAC,IAAI,CAAC,CAyBf"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// Stale mount cleanup for `parall wiki sync`: report copies that no longer
|
|
2
|
+
// map to a visible library (never delete them).
|
|
3
|
+
import { promises as fs } from 'node:fs';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { LOCAL_MANIFEST_FILE, PRLL_WIKI_DIR, pathExists } from './wiki-shared.js';
|
|
6
|
+
export async function pruneStaleMounts(mountRoot, activePaths) {
|
|
7
|
+
const root = mountRoot?.trim();
|
|
8
|
+
if (!root)
|
|
9
|
+
return;
|
|
10
|
+
const absRoot = path.resolve(root);
|
|
11
|
+
if (!(await pathExists(absRoot)))
|
|
12
|
+
return;
|
|
13
|
+
const stat = await fs.stat(absRoot);
|
|
14
|
+
if (!stat.isDirectory()) {
|
|
15
|
+
throw new Error(`mount root "${absRoot}" is not a directory`);
|
|
16
|
+
}
|
|
17
|
+
const activeArr = Array.from(activePaths);
|
|
18
|
+
const staleDirs = [];
|
|
19
|
+
await findStaleMountDirs(absRoot, absRoot, activePaths, activeArr, staleDirs);
|
|
20
|
+
// NEVER delete: since existence filtering landed, "absent from the list"
|
|
21
|
+
// no longer implies "deleted" — a library switched to private disappears
|
|
22
|
+
// from the list entirely (by design, indistinguishable from absent), and
|
|
23
|
+
// recursively removing its mount would destroy uncommitted local edits.
|
|
24
|
+
// Retain and report; reclaiming is a deliberate manual act until a
|
|
25
|
+
// positive deletion signal exists.
|
|
26
|
+
for (const staleDir of staleDirs) {
|
|
27
|
+
console.warn(`[wiki sync] mount "${staleDir}" no longer maps to a visible library — retained (delete manually if the library was removed)`);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
async function findStaleMountDirs(absRoot, dir, activePaths, activeArr, staleDirs) {
|
|
31
|
+
let names;
|
|
32
|
+
try {
|
|
33
|
+
names = await fs.readdir(dir);
|
|
34
|
+
}
|
|
35
|
+
catch {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
for (const name of names) {
|
|
39
|
+
const fullPath = path.join(dir, name);
|
|
40
|
+
const stat = await fs.lstat(fullPath).catch(() => null);
|
|
41
|
+
if (!stat?.isDirectory() || stat.isSymbolicLink())
|
|
42
|
+
continue;
|
|
43
|
+
if (name === PRLL_WIKI_DIR) {
|
|
44
|
+
const mountDir = path.dirname(fullPath);
|
|
45
|
+
if (mountDir === absRoot)
|
|
46
|
+
continue;
|
|
47
|
+
if (activePaths.has(mountDir))
|
|
48
|
+
continue;
|
|
49
|
+
const prefix = mountDir + path.sep;
|
|
50
|
+
if (activeArr.some((ap) => ap.startsWith(prefix)))
|
|
51
|
+
continue;
|
|
52
|
+
if (await pathExists(path.join(fullPath, LOCAL_MANIFEST_FILE))) {
|
|
53
|
+
staleDirs.push(mountDir);
|
|
54
|
+
}
|
|
55
|
+
continue;
|
|
56
|
+
}
|
|
57
|
+
await findStaleMountDirs(absRoot, fullPath, activePaths, activeArr, staleDirs);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wiki-sync.d.ts","sourceRoot":"","sources":["../../src/lib/wiki-sync.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"wiki-sync.d.ts","sourceRoot":"","sources":["../../src/lib/wiki-sync.ts"],"names":[],"mappings":"AAUA,OAAO,EAIL,KAAK,aAAa,EAElB,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,eAAe,EAcrB,MAAM,kBAAkB,CAAC;AAqB1B,2FAA2F;AAK3F,MAAM,MAAM,UAAU,GAAG;IACvB;;;kDAG8C;IAC9C,EAAE,EAAE,OAAO,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE;QACN,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,EAAE,MAAM,CAAC;QAChB,aAAa,EAAE,MAAM,CAAC;QACtB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AE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAE/D;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,KAAK,EAAE;IACrC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;IACxB,OAAO,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAC;IACzC,QAAQ,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,MAAM,GAAG,IAAI,CAAC;IAC1C,MAAM,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;CAChE,GAAG,UAAU,EAAE,CA8Cf;AAED,wBAAsB,cAAc,CAClC,GAAG,EAAE,aAAa,EAClB,IAAI,EAAE,OAAO,aAAa,EAAE,IAAI,EAChC,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,eAAe,CAAC,CA2c1B;AAED;;;;GAIG;AACH,wBAAsB,mBAAmB,CACvC,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,MAAM,GACd,OAAO,CAAC,MAAM,CAAC,CAYjB;AAED;;;;;;;;;;GAUG;AACH,wBAAsB,uBAAuB,CAC3C,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,IAAI,CAAC,CAkBf"}
|
package/dist/lib/wiki-sync.js
CHANGED
|
@@ -3,8 +3,10 @@
|
|
|
3
3
|
// Entry point for consumers is ./wiki.ts, which re-exports the public surface.
|
|
4
4
|
import { promises as fs } from 'node:fs';
|
|
5
5
|
import path from 'node:path';
|
|
6
|
+
import { retireCopiesOnRefusal } from './wiki-copies.js';
|
|
7
|
+
import { pruneStaleMounts } from './wiki-stale-mounts.js';
|
|
6
8
|
import { hasDelimiterLine, mergeTextThreeWay } from './wiki-merge.js';
|
|
7
|
-
import {
|
|
9
|
+
import { PRLL_WIKI_DIR, bulkDownloadFiles, computeGitBlobSHA, isReadableWiki, isWikiTextContent, removeEmptyParents, requireAgentId, resolveApiToken, resolveMountPath, resolvePathInsideRoot, resolveWikiRef, resolveWikiServiceBaseUrl, walkLocalFiles, wikiServiceFetch, } from './wiki-shared.js';
|
|
8
10
|
import { ensureBaselineObjects, gcBaselineObjects, probeLocalGitBlob, readBaselineObject, readLocalManifest, writeLocalManifest, } from './wiki-workspace.js';
|
|
9
11
|
const CONFLICTS_DIR = 'conflicts';
|
|
10
12
|
const REMOTE_CONFLICT_SUFFIX = '.remote';
|
|
@@ -34,7 +36,7 @@ export async function syncAllMounts(ctx, wikiRef) {
|
|
|
34
36
|
for (const wiki of wikis) {
|
|
35
37
|
const mountPath = resolveMountPath(wiki.slug, mountRoot);
|
|
36
38
|
activeMountPaths.add(mountPath);
|
|
37
|
-
const outcome = await syncSingleWiki(ctx, wiki, mountPath);
|
|
39
|
+
const outcome = await retireCopiesOnRefusal(() => syncSingleWiki(ctx, wiki, mountPath), mountRoot, mountPath);
|
|
38
40
|
synced.push({
|
|
39
41
|
slug: wiki.slug,
|
|
40
42
|
path: mountPath,
|
|
@@ -578,60 +580,3 @@ export async function removeConflictArtifacts(mountRoot, sourcePath) {
|
|
|
578
580
|
await removeEmptyParents(conflictsRoot, parent);
|
|
579
581
|
}
|
|
580
582
|
}
|
|
581
|
-
// ---------------------------------------------------------------------------
|
|
582
|
-
// Stale mount cleanup
|
|
583
|
-
// ---------------------------------------------------------------------------
|
|
584
|
-
async function pruneStaleMounts(mountRoot, activePaths) {
|
|
585
|
-
const root = mountRoot?.trim();
|
|
586
|
-
if (!root)
|
|
587
|
-
return;
|
|
588
|
-
const absRoot = path.resolve(root);
|
|
589
|
-
if (!(await pathExists(absRoot)))
|
|
590
|
-
return;
|
|
591
|
-
const stat = await fs.stat(absRoot);
|
|
592
|
-
if (!stat.isDirectory()) {
|
|
593
|
-
throw new Error(`mount root "${absRoot}" is not a directory`);
|
|
594
|
-
}
|
|
595
|
-
const activeArr = Array.from(activePaths);
|
|
596
|
-
const staleDirs = [];
|
|
597
|
-
await findStaleMountDirs(absRoot, absRoot, activePaths, activeArr, staleDirs);
|
|
598
|
-
// NEVER delete: since existence filtering landed, "absent from the list"
|
|
599
|
-
// no longer implies "deleted" — a library switched to private disappears
|
|
600
|
-
// from the list entirely (by design, indistinguishable from absent), and
|
|
601
|
-
// recursively removing its mount would destroy uncommitted local edits.
|
|
602
|
-
// Retain and report; reclaiming is a deliberate manual act until a
|
|
603
|
-
// positive deletion signal exists.
|
|
604
|
-
for (const staleDir of staleDirs) {
|
|
605
|
-
console.warn(`[wiki sync] mount "${staleDir}" no longer maps to a visible library — retained (delete manually if the library was removed)`);
|
|
606
|
-
}
|
|
607
|
-
}
|
|
608
|
-
async function findStaleMountDirs(absRoot, dir, activePaths, activeArr, staleDirs) {
|
|
609
|
-
let names;
|
|
610
|
-
try {
|
|
611
|
-
names = await fs.readdir(dir);
|
|
612
|
-
}
|
|
613
|
-
catch {
|
|
614
|
-
return;
|
|
615
|
-
}
|
|
616
|
-
for (const name of names) {
|
|
617
|
-
const fullPath = path.join(dir, name);
|
|
618
|
-
const stat = await fs.lstat(fullPath).catch(() => null);
|
|
619
|
-
if (!stat?.isDirectory() || stat.isSymbolicLink())
|
|
620
|
-
continue;
|
|
621
|
-
if (name === PRLL_WIKI_DIR) {
|
|
622
|
-
const mountDir = path.dirname(fullPath);
|
|
623
|
-
if (mountDir === absRoot)
|
|
624
|
-
continue;
|
|
625
|
-
if (activePaths.has(mountDir))
|
|
626
|
-
continue;
|
|
627
|
-
const prefix = mountDir + path.sep;
|
|
628
|
-
if (activeArr.some((ap) => ap.startsWith(prefix)))
|
|
629
|
-
continue;
|
|
630
|
-
if (await pathExists(path.join(fullPath, LOCAL_MANIFEST_FILE))) {
|
|
631
|
-
staleDirs.push(mountDir);
|
|
632
|
-
}
|
|
633
|
-
continue;
|
|
634
|
-
}
|
|
635
|
-
await findStaleMountDirs(absRoot, fullPath, activePaths, activeArr, staleDirs);
|
|
636
|
-
}
|
|
637
|
-
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@parall/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.84.0",
|
|
4
4
|
"description": "CLI client for Parall — universal agent & human access to Parall API",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
"node-diff3": "3.2.1",
|
|
43
43
|
"tar-stream": "^3.2.1",
|
|
44
44
|
"zod": "^4.3.6",
|
|
45
|
-
"@parall/agent-core": "1.
|
|
46
|
-
"@parall/sdk": "1.
|
|
45
|
+
"@parall/agent-core": "1.84.0",
|
|
46
|
+
"@parall/sdk": "1.84.0"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@dnd-kit/core": "6.3.1",
|
|
@@ -71,10 +71,10 @@
|
|
|
71
71
|
"tw-animate-css": "1.4.0",
|
|
72
72
|
"typescript": "^5.7.0",
|
|
73
73
|
"vite": "6.4.1",
|
|
74
|
-
"@parall/agent-core": "1.
|
|
74
|
+
"@parall/agent-core": "1.84.0"
|
|
75
75
|
},
|
|
76
76
|
"scripts": {
|
|
77
|
-
"build": "node scripts/generate-miniapp-sdk.mjs --check && node scripts/generate-local-runner.mjs --check && node scripts/generate-app-templates.mjs --check &&
|
|
77
|
+
"build": "node scripts/generate-miniapp-sdk.mjs --check && node scripts/generate-local-runner.mjs --check && node scripts/generate-app-templates.mjs --check && tsc",
|
|
78
78
|
"dev": "tsc --watch",
|
|
79
79
|
"test": "pnpm run build && node --test test/*.test.mjs",
|
|
80
80
|
"bundle": "node scripts/bundle.mjs"
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"apps-template-catalog.gen.d.ts","sourceRoot":"","sources":["../../src/commands/apps-template-catalog.gen.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAE9D,eAAO,MAAM,aAAa,EAAE,SAAS,WAAW,EAiP/C,CAAC"}
|