pi-suite 0.3.7 → 0.3.8
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/package.json +1 -1
- package/src/agents/child.ts +9 -3
- package/src/agents/history.ts +3 -3
- package/src/agents/index.ts +22 -21
- package/src/agents/manager.ts +40 -12
- package/src/agents/records.ts +4 -2
- package/src/agents/runner.ts +12 -3
- package/src/agents/runtime.ts +1 -1
- package/src/agents/schedules/menu.ts +1 -1
- package/src/agents/types.ts +2 -1
- package/src/agents/ui/runs.ts +33 -13
- package/src/agents/viewer.ts +17 -11
- package/src/agents/workflow/index.ts +32 -9
- package/src/agents/workflow/manager.ts +18 -6
- package/src/agents/workflow/ui/menu.ts +2 -2
- package/src/jobs/index.ts +49 -36
- package/src/jobs/manager-record.ts +2 -2
- package/src/jobs/manager.ts +30 -12
- package/src/jobs/monitors/runtime.ts +41 -27
- package/src/jobs/store.ts +49 -10
- package/src/jobs/tools.ts +2 -2
- package/src/jobs/types.ts +2 -0
- package/src/jobs/viewer/metadata.ts +6 -0
- package/src/jobs/viewer.ts +30 -25
- package/src/runtime/branch.ts +14 -0
- package/src/runtime/cleanup/command.ts +116 -0
- package/src/runtime/cleanup/locations.ts +91 -0
- package/src/runtime/cleanup/occupancy.ts +117 -0
- package/src/runtime/cleanup/paths.ts +44 -0
- package/src/runtime/cleanup/quarantine.ts +162 -0
- package/src/runtime/cleanup/scan.ts +297 -0
- package/src/runtime/cleanup/session-use.ts +62 -0
- package/src/runtime/cleanup/sessions.ts +119 -0
- package/src/runtime/json-store.ts +6 -0
- package/src/runtime/owner.ts +1 -1
- package/src/runtime/settings/index.ts +9 -1
- package/src/runtime/suite.ts +43 -1
- package/src/tasks/store.ts +18 -1
- package/src/tasks/viewer.ts +14 -12
- package/src/ui/actions.ts +1 -1
- package/src/ui/browser.ts +95 -43
- package/src/ui/scroll.ts +5 -1
package/src/jobs/store.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
import { lstatSync, realpathSync, mkdirSync, writeFileSync, renameSync, unlinkSync, existsSync } from 'node:fs';
|
|
6
6
|
import { readdir, readFile, writeFile, rename, rm, stat, unlink, appendFile } from 'node:fs/promises';
|
|
7
7
|
import { join, relative, sep, isAbsolute } from 'node:path';
|
|
8
|
-
import { randomBytes, randomUUID } from 'node:crypto';
|
|
8
|
+
import { createHash, randomBytes, randomUUID } from 'node:crypto';
|
|
9
9
|
import { isTerminal } from './state.ts';
|
|
10
10
|
import { ToolError } from '../runtime/errors.ts';
|
|
11
11
|
import { SNAPSHOT_BYTES, SNAPSHOT_SCROLLBACK, type TerminalSnapshot } from './terminal/snapshot.ts';
|
|
@@ -43,9 +43,12 @@ export class JobStore {
|
|
|
43
43
|
}
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
|
|
46
|
+
private jobDirectory(job: Pick<JobSummary, 'id' | 'workspace'>): string {
|
|
47
47
|
if (!JOB_ID.test(job.id) || !HASH.test(job.workspace.hash)) throw new ToolError('UNSAFE_PATH', 'Invalid internal job identity');
|
|
48
|
-
|
|
48
|
+
return join(this.root, job.workspace.hash, job.id);
|
|
49
|
+
}
|
|
50
|
+
directory(job: Pick<JobSummary, 'id' | 'workspace'>): string {
|
|
51
|
+
const dir = this.jobDirectory(job);
|
|
49
52
|
this.secure(dir);
|
|
50
53
|
return dir;
|
|
51
54
|
}
|
|
@@ -145,24 +148,60 @@ export class JobStore {
|
|
|
145
148
|
let ids: string[];
|
|
146
149
|
try { ids = await readdir(root); }
|
|
147
150
|
catch (error) { if ((error as NodeJS.ErrnoException).code !== 'ENOENT') errors.push(String(error)); return { jobs, errors }; }
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
+
// Bound IO fan-out without changing the order of history or per-record diagnostics.
|
|
152
|
+
const batchSize = 16;
|
|
153
|
+
for (let offset = 0; offset < ids.length; offset += batchSize) {
|
|
154
|
+
const batch = await Promise.all(ids.slice(offset, offset + batchSize).map(async id => {
|
|
155
|
+
try { return await this.load(workspace, id); }
|
|
156
|
+
catch (error) { return `${id}: ${String(error)}`.slice(0, 512); }
|
|
157
|
+
}));
|
|
158
|
+
for (const result of batch) typeof result === 'string' ? errors.push(result) : jobs.push(result);
|
|
151
159
|
}
|
|
152
160
|
return { jobs, errors };
|
|
153
161
|
}
|
|
154
162
|
async load(workspace: Workspace, id: string): Promise<JobSummary> {
|
|
155
|
-
const path = join(this.
|
|
163
|
+
const path = join(this.jobDirectory({ id, workspace }), 'job.json'); this.secure(path);
|
|
164
|
+
const job = await this.readRecord(path, id, workspace.hash);
|
|
165
|
+
if (job.workspace.key !== workspace.key) throw new ToolError('CORRUPT_HISTORY', 'Mismatched job workspace', id);
|
|
166
|
+
return job;
|
|
167
|
+
}
|
|
168
|
+
private async readRecord(path: string, id: string, hash: string): Promise<JobSummary> {
|
|
156
169
|
const job = JSON.parse(await readFile(path, 'utf8')) as JobSummary;
|
|
157
|
-
if (job?.schemaVersion !== 1 || job.id !== id || job.workspace?.hash !==
|
|
170
|
+
if (job?.schemaVersion !== 1 || job.id !== id || job.workspace?.hash !== hash || typeof job.workspace.key !== 'string' ||
|
|
158
171
|
!STATES.includes(job.state) || !['pipe', 'pty'].includes(job.mode) || typeof job.command !== 'string' ||
|
|
159
172
|
typeof job.ownerSessionId !== 'string' || !CLEANUP.includes(job.cleanup?.state)) throw new ToolError('CORRUPT_HISTORY', 'Unsupported or mismatched job record', id);
|
|
160
173
|
return job;
|
|
161
174
|
}
|
|
175
|
+
async *maintenanceHistory(onRecordError: (path: string, error: unknown) => void): AsyncGenerator<JobSummary> {
|
|
176
|
+
this.secure(this.root);
|
|
177
|
+
const dirs = async (path: string) => readdir(path, {withFileTypes: true}).catch((error: NodeJS.ErrnoException) => {
|
|
178
|
+
if (error.code === 'ENOENT' && path === this.root) return []; throw error;
|
|
179
|
+
});
|
|
180
|
+
// Workspace queries cannot find every job owned by a session: cwd may differ.
|
|
181
|
+
for (const workspace of await dirs(this.root)) {
|
|
182
|
+
if (!HASH.test(workspace.name)) continue;
|
|
183
|
+
const root = join(this.root, workspace.name); this.secure(root);
|
|
184
|
+
if (!workspace.isDirectory()) throw new Error(`Invalid job workspace: ${root}`);
|
|
185
|
+
for (const entry of await dirs(root)) {
|
|
186
|
+
if (!JOB_ID.test(entry.name)) continue;
|
|
187
|
+
const path = join(root, entry.name, 'job.json');
|
|
188
|
+
let job: JobSummary;
|
|
189
|
+
try {
|
|
190
|
+
this.secure(path);
|
|
191
|
+
if (!entry.isDirectory()) throw new Error(`Invalid job directory: ${path}`);
|
|
192
|
+
job = await this.readRecord(path, entry.name, workspace.name);
|
|
193
|
+
if (createHash('sha256').update(job.workspace.key).digest('hex') !== workspace.name) throw new Error(`Invalid job workspace hash: ${path}`);
|
|
194
|
+
} catch (error) { onRecordError(path, error); continue; }
|
|
195
|
+
yield job;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
assertRemovable(job: JobSummary): void {
|
|
200
|
+
if (!isTerminal(job.state) || ['pending', 'unconfirmed'].includes(job.cleanup.state)) throw new ToolError('JOB_OCCUPIED', 'Cannot delete an active or unconfirmed job', job.id);
|
|
201
|
+
}
|
|
162
202
|
async remove(job: JobSummary): Promise<void> {
|
|
163
203
|
// Check disk state again; the caller's snapshot cannot authorize deleting live history.
|
|
164
|
-
|
|
165
|
-
if (!isTerminal(stored.state) || ['pending', 'unconfirmed'].includes(stored.cleanup.state)) throw new ToolError('JOB_OCCUPIED', 'Cannot delete an active or unconfirmed job', job.id);
|
|
204
|
+
this.assertRemovable(await this.load(job.workspace, job.id));
|
|
166
205
|
await rm(this.directory(job), { recursive: true });
|
|
167
206
|
}
|
|
168
207
|
}
|
package/src/jobs/tools.ts
CHANGED
|
@@ -27,7 +27,7 @@ const listSchema = Type.Object(listFields(['active', 'finished', 'all'] as const
|
|
|
27
27
|
const getSchema = Type.Object({ id, detail: Type.Optional(Type.Boolean()) }, { additionalProperties: false });
|
|
28
28
|
const queryHint = 'List: job_list({"state":"all"}); one job: job_get({"id":"job_3fa1c2d0"}).';
|
|
29
29
|
|
|
30
|
-
export function registerJobTools(pi: ExtensionAPI, jobs: JobsModule, viewer: ViewerDeps, launch: { config: () => SuiteConfig; tasks?: TasksModule; creator?: Creator }): void {
|
|
30
|
+
export function registerJobTools(pi: ExtensionAPI, jobs: JobsModule, viewer: ViewerDeps, launch: { config: () => SuiteConfig; tasks?: TasksModule; creator?: Creator; cleanupOwner?: string }): void {
|
|
31
31
|
registerBoundTool(pi, {
|
|
32
32
|
name: 'job_start', ...startRenderers, label: 'Start Job',
|
|
33
33
|
description: 'Start a command as a background job and return at once. mode=pipe (default) records stdout/stderr for builds, tests and batch work; mode=pty runs it in a terminal for REPLs and interactive programs. ' +
|
|
@@ -67,7 +67,7 @@ export function registerJobTools(pi: ExtensionAPI, jobs: JobsModule, viewer: Vie
|
|
|
67
67
|
}
|
|
68
68
|
const taskStore = params.taskId ? await launch.tasks!.executionTask(ctx, params.taskId, params.taskGeneration!) : undefined;
|
|
69
69
|
// Pi waits for piped stdin EOF before its initial prompt; PTY keeps interactive input.
|
|
70
|
-
const job = await manager.start({ ...request, command, cwd, ...owner, creator: launch.creator,
|
|
70
|
+
const job = await manager.start({ ...request, command, cwd, ...owner, creator: launch.creator, cleanupOwner: launch.cleanupOwner,
|
|
71
71
|
closeInput: agent?.preset === 'pi' && params.mode !== 'pty' }, shell, signal);
|
|
72
72
|
if (taskStore && params.taskId) {
|
|
73
73
|
try { await taskStore.link(params.taskId, { jobId: job.id }, params.taskGeneration!); }
|
package/src/jobs/types.ts
CHANGED
|
@@ -40,6 +40,8 @@ export type StartRequest = {
|
|
|
40
40
|
/** Omitted only for a file-watch monitor, which generates its own command. */
|
|
41
41
|
command?: string; name?: string; cwd: string; mode?: JobMode; timeoutMs?: number; taskId?: string; taskGeneration?: string;
|
|
42
42
|
ownerSessionId: string; anchorEntryId: string | null; creator?: Creator; cols?: number; rows?: number;
|
|
43
|
+
/** Root attribution for an active job owned by a child SDK session. */
|
|
44
|
+
cleanupOwner?: string;
|
|
43
45
|
monitor?: MonitorInput; handsFree?: HandsFreeInput;
|
|
44
46
|
/** Noninteractive pipe callers close stdin during launch, before a short command can exit. */
|
|
45
47
|
closeInput?: boolean;
|
|
@@ -3,6 +3,12 @@ import { executionRow } from '../../ui/dock/line.ts';
|
|
|
3
3
|
import { displayName, jobStatus, jobCompactStatus } from '../index.ts';
|
|
4
4
|
import type { JobSummary } from '../types.ts';
|
|
5
5
|
|
|
6
|
+
/** A paint tick advances elapsed time only; lifecycle data arrives via the owner subscription. */
|
|
7
|
+
export function timedJob(job: JobSummary, measuredAt: number): JobSummary {
|
|
8
|
+
return job.endedAt === undefined && job.elapsedMs !== undefined
|
|
9
|
+
? {...job, elapsedMs: job.elapsedMs + Math.round(performance.now() - measuredAt)} : job;
|
|
10
|
+
}
|
|
11
|
+
|
|
6
12
|
/** Lists and viewers protect the same domain-ordered state/time/cleanup metrics. */
|
|
7
13
|
export function jobRow(job: JobSummary, width: number, theme?: Theme): string {
|
|
8
14
|
return executionRow(displayName(job), jobStatus(job), jobCompactStatus(job), width, theme);
|
package/src/jobs/viewer.ts
CHANGED
|
@@ -4,18 +4,19 @@ import type { Dock } from '../ui/dock.ts';
|
|
|
4
4
|
import { showDetails } from '../ui/details.ts';
|
|
5
5
|
import { TerminalView, type TerminalExit, type TerminalKeys } from '../ui/terminal.ts';
|
|
6
6
|
import { ToolError } from '../runtime/errors.ts';
|
|
7
|
-
import { isActive } from './state.ts';
|
|
7
|
+
import { bucket, isActive } from './state.ts';
|
|
8
|
+
import { newestFirst } from '../runtime/tools.ts';
|
|
8
9
|
import { JOB_SCREEN, type JobScreenDetails } from './render.ts';
|
|
9
10
|
import { resolveWorkspace } from './workspace.ts';
|
|
10
|
-
import { JobsModule, displayName, summaryLine
|
|
11
|
-
import { jobViewerDetails, type ListScope } from './query.ts';
|
|
11
|
+
import { JobsModule, displayName, summaryLine } from './index.ts';
|
|
12
|
+
import { jobViewerDetails, type ListRow, type ListScope } from './query.ts';
|
|
12
13
|
import type { JobSummary } from './types.ts';
|
|
13
14
|
import { browse, browseState, compareActivity } from '../ui/browser.ts';
|
|
14
15
|
import { openReading } from '../ui/reading.ts';
|
|
15
16
|
import { ViewerNavigation } from '../ui/viewer/navigation.ts';
|
|
16
17
|
import { TerminalScreen } from './terminal/screen.ts';
|
|
17
18
|
import { JobView } from './viewer/component.ts';
|
|
18
|
-
import { jobRow } from './viewer/metadata.ts';
|
|
19
|
+
import { jobRow, timedJob } from './viewer/metadata.ts';
|
|
19
20
|
|
|
20
21
|
export interface ViewerDeps { jobs: JobsModule; dock: Dock; notifications: Notifications; keys: () => TerminalKeys }
|
|
21
22
|
|
|
@@ -66,41 +67,45 @@ async function pickJob(pi: ExtensionAPI, ctx: ExtensionCommandContext, deps: Vie
|
|
|
66
67
|
const workspace = await resolveWorkspace(ctx.cwd);
|
|
67
68
|
const viewState = browseState(), navigation = new ViewerNavigation();
|
|
68
69
|
while (!navigation.closed) {
|
|
69
|
-
const
|
|
70
|
+
const control = deps.jobs.control();
|
|
71
|
+
const { jobs, errors } = await control.list(workspace);
|
|
70
72
|
for (const error of errors) ctx.ui.notify(`history error: ${error}`, 'warning');
|
|
71
|
-
|
|
72
|
-
let
|
|
73
|
-
|
|
74
|
-
// of sorting/scanning the complete history again for each rendered name or suffix.
|
|
75
|
-
let displayed = new Map<string, JobSummary>();
|
|
73
|
+
let changed = false, ticking = false, total = 0, finished = 0;
|
|
74
|
+
let displayed = new Map<string, ListRow>(), measuredAt = 0;
|
|
75
|
+
const liveView = ({job, live}: ListRow) => live ? timedJob(job, measuredAt) : job;
|
|
76
76
|
const choice = await browse(ctx, deps.dock, { title: 'Jobs', state: viewState, navigation,
|
|
77
|
-
layout: {truncatePrimary: context =>
|
|
78
|
-
const job = displayed.get(context.item.value)!;
|
|
79
|
-
return jobRow(job, context.maxWidth, context.theme);
|
|
80
|
-
}},
|
|
77
|
+
layout: {truncatePrimary: context => jobRow(liveView(displayed.get(context.item.value)!), context.maxWidth, context.theme)},
|
|
81
78
|
controls: [
|
|
82
79
|
{key: 'w', label: 'Scope', selected: () => scope, items: () => [{value: 'session', label: 'This session'}, {value: 'workspace', label: 'Workspace'}],
|
|
83
80
|
select: (value, done) => {scope = value as ListScope; changed = true; done();}},
|
|
84
81
|
{key: 's', label: 'State', selected: () => state, items: () => STATES.map(value => ({value, label: value[0].toUpperCase() + value.slice(1),
|
|
85
|
-
description: String(
|
|
82
|
+
description: String(value === 'all' ? total : finished)})),
|
|
86
83
|
select: value => {state = value as BrowseJobState;}},
|
|
87
84
|
],
|
|
88
|
-
total: () =>
|
|
89
|
-
|
|
90
|
-
subscribe: refresh => deps.jobs.control().subscribe(refresh), ticking: () => current().some(row => isActive(row.job)),
|
|
85
|
+
total: () => total, selection: item => ({name: displayName(displayed.get(item.value)!.job)}),
|
|
86
|
+
subscribe: refresh => control.subscribe(refresh), ticking: () => ticking,
|
|
91
87
|
items: () => {
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
88
|
+
const rows = deps.jobs.browseRows(jobs, scope, ctx);
|
|
89
|
+
measuredAt = performance.now();
|
|
90
|
+
total = rows.length;
|
|
91
|
+
const settled = rows.filter(({job, live}) => bucket(job, live) === 'finished');
|
|
92
|
+
finished = settled.length;
|
|
93
|
+
const items = (state === 'finished' ? settled : rows)
|
|
94
|
+
.sort((a, b) => compareActivity(a.job, b.job, isActive) || newestFirst(a.job, b.job));
|
|
95
|
+
ticking = items.some(({job, live}) => live && isActive(job));
|
|
96
|
+
displayed = new Map(items.map(row => [row.job.id, row]));
|
|
97
|
+
return items.map(row => {
|
|
98
|
+
const {job} = row, label = displayName(job);
|
|
99
|
+
return { value: job.id, label,
|
|
100
|
+
search: `${job.id} ${label} ${job.state} ${job.command} ${job.cwd}`,
|
|
101
|
+
details: () => jobViewerDetails(liveView(row), row.live) };
|
|
102
|
+
});
|
|
98
103
|
},
|
|
99
104
|
});
|
|
100
105
|
if (navigation.closed) return;
|
|
101
106
|
if (changed) continue;
|
|
102
107
|
if (choice === undefined) return;
|
|
103
|
-
const job =
|
|
108
|
+
const job = displayed.get(choice)?.job;
|
|
104
109
|
if (job) await jobActions(pi, ctx, deps, job.id, false, job.cwd, navigation);
|
|
105
110
|
}
|
|
106
111
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ExtensionContext } from '@earendil-works/pi-coding-agent';
|
|
2
|
+
|
|
3
|
+
type SessionManager = ExtensionContext['sessionManager'];
|
|
4
|
+
|
|
5
|
+
const branches = new WeakMap<SessionManager, { sessionId: string; leaf: string | null; ids: ReadonlySet<string> }>();
|
|
6
|
+
|
|
7
|
+
/** Pi rebuilds a branch on every getBranch() call. Share membership across consumers of the same leaf. */
|
|
8
|
+
export function branchIds(session: SessionManager): ReadonlySet<string> {
|
|
9
|
+
const leaf = session.getLeafId(), sessionId = session.getSessionId(), cached = branches.get(session);
|
|
10
|
+
if (cached?.leaf === leaf && cached.sessionId === sessionId) return cached.ids;
|
|
11
|
+
const ids = new Set(session.getBranch().map(entry => entry.id));
|
|
12
|
+
branches.set(session, { sessionId, leaf, ids });
|
|
13
|
+
return ids;
|
|
14
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { realpath } from 'node:fs/promises';
|
|
2
|
+
import { join, resolve } from 'node:path';
|
|
3
|
+
import { formatSize, getAgentDir, SettingsManager, type ExtensionCommandContext } from '@earendil-works/pi-coding-agent';
|
|
4
|
+
import { AGENT_OWNER, WORKFLOW_OWNER } from '../../agents/registry.ts';
|
|
5
|
+
import { globals, key } from '../../jobs/registry.ts';
|
|
6
|
+
import { withJsonFileLock } from '../json-store.ts';
|
|
7
|
+
import { existingOwner, ownerBusy } from '../owner.ts';
|
|
8
|
+
import { sanitizeText } from '../text.ts';
|
|
9
|
+
import { maintenanceDir, rememberVerifiedHome } from './locations.ts';
|
|
10
|
+
import { inspect, matches, pathKey } from './paths.ts';
|
|
11
|
+
import { orphanCandidates } from './scan.ts';
|
|
12
|
+
import { batches, quarantine, quarantinedBytes, restore } from './quarantine.ts';
|
|
13
|
+
import { coordinated, enableCoordination, readOccupancy, withCoordination } from './occupancy.ts';
|
|
14
|
+
|
|
15
|
+
export async function cleanupCommand(args: string, ctx: ExtensionCommandContext): Promise<void> {
|
|
16
|
+
const [action, id, extra] = args.trim().split(/\s+/);
|
|
17
|
+
if (extra || action && !['restore', 'list', 'coordinate'].includes(action) || (action === 'restore') !== Boolean(id)) {
|
|
18
|
+
throw new Error('Usage: /suite cleanup [list | restore <batch-id> | coordinate]');
|
|
19
|
+
}
|
|
20
|
+
const configuredAgentDir = getAgentDir();
|
|
21
|
+
const agentDir = await realpath(configuredAgentDir);
|
|
22
|
+
if (action !== 'list' && (ctx.mode !== 'tui' || !ctx.isIdle())) {
|
|
23
|
+
throw new Error('Run this command from an idle Pi terminal.');
|
|
24
|
+
}
|
|
25
|
+
const occupied = (includeCurrent = true) => {
|
|
26
|
+
const ids = new Set<string>();
|
|
27
|
+
if (includeCurrent) ids.add(ctx.sessionManager.getSessionId());
|
|
28
|
+
for (const dir of new Set([configuredAgentDir, agentDir])) {
|
|
29
|
+
for (const key of [AGENT_OWNER, WORKFLOW_OWNER]) {
|
|
30
|
+
const owner = existingOwner(key, dir);
|
|
31
|
+
if (owner?.cleanupOwners) for (const id of owner.cleanupOwners()) ids.add(id);
|
|
32
|
+
else if (ownerBusy(key, dir)) throw new Error('An older execution runtime cannot identify its active sessions. Restart Pi before cleanup.');
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const jobs = globals[key];
|
|
36
|
+
if (jobs && (jobs.agentDir === agentDir || jobs.requestedAgentDir === configuredAgentDir)) {
|
|
37
|
+
if (jobs.manager.cleanupOwners) for (const id of jobs.manager.cleanupOwners()) ids.add(id);
|
|
38
|
+
else if (jobs.manager.hasOccupancy?.() !== false) throw new Error('An older Job runtime cannot identify its active sessions. Restart Pi before cleanup.');
|
|
39
|
+
}
|
|
40
|
+
return ids;
|
|
41
|
+
};
|
|
42
|
+
if (action === 'list') {
|
|
43
|
+
const ids = await batches(agentDir);
|
|
44
|
+
ctx.ui.notify(ids.length ? `Cleanup batches:\n${ids.join('\n')}` : 'No recoverable cleanup batches.', 'info');
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const root = maintenanceDir(agentDir);
|
|
48
|
+
await inspect(agentDir, root);
|
|
49
|
+
if (action === 'coordinate') {
|
|
50
|
+
if (occupied(false).size) throw new Error('Let background executions settle before enabling cleanup coordination.');
|
|
51
|
+
await withJsonFileLock(join(root, 'operation.lock'), 'CLEANUP', () => enableCoordination(agentDir));
|
|
52
|
+
ctx.ui.notify('Local cleanup coordination enabled. Reload Pi to register this session.', 'info');
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (!action) ctx.ui.notify('Starting cleanup: scanning for orphaned session data…', 'info');
|
|
56
|
+
const online = await coordinated(agentDir);
|
|
57
|
+
const custom = action === 'restore' ? undefined : process.env.PI_CODING_AGENT_SESSION_DIR || SettingsManager.create(ctx.cwd, agentDir,
|
|
58
|
+
{projectTrusted: ctx.isProjectTrusted()}).getSessionDir();
|
|
59
|
+
const scope = custom ? resolve(ctx.cwd, custom) : undefined;
|
|
60
|
+
// Discovery does not block session admission or reference publication. Only the
|
|
61
|
+
// authoritative rescan and filesystem moves share the coordination transaction.
|
|
62
|
+
const discovery = action === 'restore' ? undefined : await orphanCandidates(agentDir, scope, occupied());
|
|
63
|
+
const apply = async (remote?: ReturnType<typeof readOccupancy>) => {
|
|
64
|
+
if (remote && !remote.local.has(ctx.sessionManager.getSessionId())) throw new Error('This session is not registered for coordinated cleanup. Reload Pi and retry.');
|
|
65
|
+
const protectedIds = () => new Set([...occupied(), ...remote?.held ?? []]);
|
|
66
|
+
if (action === 'restore') {
|
|
67
|
+
const result = await restore(agentDir, id!, protectedIds);
|
|
68
|
+
report(ctx, `Restored ${result.restored} item(s)`, result.errors);
|
|
69
|
+
} else {
|
|
70
|
+
if (!discovery!.groups.length) return {ids: [], moved: [], errors: [], warnings: discovery!.warnings};
|
|
71
|
+
const verified = await orphanCandidates(agentDir, scope, protectedIds(), remote?.sources);
|
|
72
|
+
const candidates = new Map(discovery!.groups.map(group => [group.home.id, group]));
|
|
73
|
+
const ready = [];
|
|
74
|
+
const members = new Map<string, Set<string>>();
|
|
75
|
+
for (const group of verified.groups) {
|
|
76
|
+
const owner = group.home.id, first = candidates.get(owner);
|
|
77
|
+
if (!first) continue;
|
|
78
|
+
const prior = new Map(first.items.map(item => [pathKey(item.path), item]));
|
|
79
|
+
if (group.items.length !== prior.size || group.items.some(item => {
|
|
80
|
+
const expected = prior.get(pathKey(item.path));
|
|
81
|
+
return !expected || !matches(item.stamp, expected.stamp);
|
|
82
|
+
})) continue;
|
|
83
|
+
await rememberVerifiedHome(agentDir, group.home);
|
|
84
|
+
// Session files supply child ownership and creator proof for a later retry.
|
|
85
|
+
members.set(owner, group.sessionIds);
|
|
86
|
+
ready.push(...group.items.toSorted((a, b) => Number(a.kind === 'subagents') - Number(b.kind === 'subagents')));
|
|
87
|
+
}
|
|
88
|
+
const result = await quarantine(agentDir, ready, owner => {
|
|
89
|
+
const ids = protectedIds();
|
|
90
|
+
return [...members.get(owner)!].some(id => ids.has(id));
|
|
91
|
+
});
|
|
92
|
+
return {...result, warnings: verified.warnings};
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
const result = online ? await withCoordination(agentDir, db => apply(readOccupancy(db)))
|
|
96
|
+
: await withJsonFileLock(join(root, 'operation.lock'), 'CLEANUP', async () => {
|
|
97
|
+
if (await coordinated(agentDir)) throw new Error('Cleanup coordination was enabled. Reload Pi and retry.');
|
|
98
|
+
return apply();
|
|
99
|
+
});
|
|
100
|
+
if (!result) return;
|
|
101
|
+
// Size is for display only: don't hold the coordination lock while walking moved directories.
|
|
102
|
+
let size: string;
|
|
103
|
+
try { size = formatSize(await quarantinedBytes(result.moved)); }
|
|
104
|
+
catch (error) {
|
|
105
|
+
size = 'size unavailable';
|
|
106
|
+
result.warnings.push(`Could not measure quarantined data: ${String(error)}`);
|
|
107
|
+
}
|
|
108
|
+
const batch = result.ids.length ? ` · batch ${result.ids.join(', ')}` : '';
|
|
109
|
+
report(ctx, `Cleanup complete: Quarantined ${result.moved.length} item(s) · ${size}${batch}`, result.errors, result.warnings);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function report(ctx: ExtensionCommandContext, headline: string, errors: string[], warnings: string[] = []): void {
|
|
113
|
+
ctx.ui.notify(`${headline}.`, errors.length ? 'error' : 'info');
|
|
114
|
+
for (const warning of warnings) ctx.ui.notify(sanitizeText(warning), 'warning');
|
|
115
|
+
for (const error of errors) ctx.ui.notify(sanitizeText(error), 'error');
|
|
116
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { realpath } from 'node:fs/promises';
|
|
2
|
+
import { basename, dirname, isAbsolute, join } from 'node:path';
|
|
3
|
+
import type { ExtensionContext } from '@earendil-works/pi-coding-agent';
|
|
4
|
+
import { Type, type Static } from 'typebox';
|
|
5
|
+
import { Value } from 'typebox/value';
|
|
6
|
+
import { JsonStore } from '../json-store.ts';
|
|
7
|
+
import { inspect, pathKey, sameRoot } from './paths.ts';
|
|
8
|
+
|
|
9
|
+
export const SESSION_ID = /^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$/;
|
|
10
|
+
const directory = Type.Object({path: Type.String(), dev: Type.Number(), ino: Type.Number(), birthtimeMs: Type.Number()});
|
|
11
|
+
const location = Type.Object({id: Type.String({pattern: SESSION_ID.source}), file: Type.String(),
|
|
12
|
+
root: directory, workspace: directory});
|
|
13
|
+
const schema = Type.Object({version: Type.Literal(1), sessions: Type.Array(location), childRoots: Type.Array(directory)});
|
|
14
|
+
type Registry = Static<typeof schema>;
|
|
15
|
+
export type Home = Static<typeof location>;
|
|
16
|
+
export type Directory = Static<typeof directory>;
|
|
17
|
+
export const maintenanceDir = (agentDir: string) => join(agentDir, 'pi-suite', 'cleanup');
|
|
18
|
+
|
|
19
|
+
class LocationStore extends JsonStore<Registry> {
|
|
20
|
+
constructor(agentDir: string) {
|
|
21
|
+
const empty = (): Registry => ({version: 1, sessions: [], childRoots: []});
|
|
22
|
+
super(join(maintenanceDir(agentDir), 'locations.json'), empty(), value => {
|
|
23
|
+
if (!Value.Check(schema, value) || value.sessions.some(home => !isAbsolute(home.file) || !home.file.endsWith('.jsonl')
|
|
24
|
+
|| pathKey(dirname(home.file)) !== pathKey(home.root.path)) ||
|
|
25
|
+
[...value.childRoots, ...value.sessions.flatMap(home => [home.root, home.workspace])].some(dir => !isAbsolute(dir.path))) {
|
|
26
|
+
throw new Error('Invalid session location registry');
|
|
27
|
+
}
|
|
28
|
+
return value;
|
|
29
|
+
}, 'CLEANUP_LOCATIONS', {missing: empty, skipUnchanged: true});
|
|
30
|
+
}
|
|
31
|
+
remember(home: Home) {
|
|
32
|
+
return this.mutate(data => {
|
|
33
|
+
if (!data.sessions.some(other => other.id === home.id && pathKey(home.file) === pathKey(other.file)
|
|
34
|
+
&& sameRoot(home.root, other.root) && sameRoot(home.workspace, other.workspace))) data.sessions.push(home);
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
addChild(root: Directory) {
|
|
38
|
+
return this.mutate(data => {
|
|
39
|
+
if (!data.childRoots.some(other => pathKey(other.path) === pathKey(root.path) && sameRoot(root, other))) data.childRoots.push(root);
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
const stores = new Map<string, LocationStore>();
|
|
44
|
+
function store(agentDir: string): LocationStore {
|
|
45
|
+
const key = pathKey(agentDir);
|
|
46
|
+
let current = stores.get(key);
|
|
47
|
+
if (!current) { current = new LocationStore(agentDir); stores.set(key, current); }
|
|
48
|
+
return current;
|
|
49
|
+
}
|
|
50
|
+
export async function locations(agentDir: string): Promise<Registry> {
|
|
51
|
+
await inspect(agentDir, join(maintenanceDir(agentDir), 'locations.json'));
|
|
52
|
+
return store(agentDir).snapshot();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export async function identifyDirectory(path: string): Promise<Directory> {
|
|
56
|
+
const canonical = await realpath(path), info = await inspect(canonical, canonical);
|
|
57
|
+
return {path: canonical, dev: info!.dev, ino: info!.ino, birthtimeMs: info!.birthtimeMs};
|
|
58
|
+
}
|
|
59
|
+
export async function verifyDirectory(dir: Directory): Promise<void> {
|
|
60
|
+
const info = await inspect(dir.path, dir.path);
|
|
61
|
+
if (!info || !sameRoot(info, dir)) throw new Error(`Storage directory changed or is unavailable: ${dir.path}`);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export async function rememberVerifiedHome(agentDir: string, home: Home): Promise<void> {
|
|
65
|
+
await inspect(agentDir, join(maintenanceDir(agentDir), 'locations.json'));
|
|
66
|
+
await store(agentDir).remember(home);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Nothing in the registry claims a session that only exists in memory. */
|
|
70
|
+
export async function rememberSession(agentDir: string, session: ExtensionContext['sessionManager']): Promise<boolean> {
|
|
71
|
+
const file = session.getSessionFile(), header = session.getHeader();
|
|
72
|
+
if (!file || !header || !SESSION_ID.test(header.id)) return false;
|
|
73
|
+
const root = await identifyDirectory(dirname(file)), canonical = join(root.path, basename(file));
|
|
74
|
+
const info = await inspect(root.path, canonical);
|
|
75
|
+
if (!info) return false; // Pi writes new sessions only once they have a conversation.
|
|
76
|
+
if (!info.isFile()) throw new Error(`Session path is not a regular file: ${canonical}`);
|
|
77
|
+
const workspace = await identifyDirectory(header.cwd), base = await realpath(agentDir);
|
|
78
|
+
await rememberVerifiedHome(base, {id: header.id, file: canonical, root, workspace});
|
|
79
|
+
return true;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const childSeen = new Set<string>();
|
|
83
|
+
export async function rememberChildRoot(agentDir: string, directory: string): Promise<void> {
|
|
84
|
+
const root = await identifyDirectory(directory);
|
|
85
|
+
const key = JSON.stringify([agentDir, root.path, root.dev, root.ino, root.birthtimeMs]);
|
|
86
|
+
if (!childSeen.has(key)) {
|
|
87
|
+
const base = await realpath(agentDir);
|
|
88
|
+
await inspect(base, join(maintenanceDir(base), 'locations.json'));
|
|
89
|
+
await store(base).addChild(root); childSeen.add(key);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { randomUUID } from 'node:crypto';
|
|
2
|
+
import { mkdir, stat } from 'node:fs/promises';
|
|
3
|
+
import { hostname } from 'node:os';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
import type { DatabaseSync } from 'node:sqlite';
|
|
6
|
+
import { setTimeout as sleep } from 'node:timers/promises';
|
|
7
|
+
import { maintenanceDir, SESSION_ID } from './locations.ts';
|
|
8
|
+
import { inspect } from './paths.ts';
|
|
9
|
+
import { references, type References } from './sessions.ts';
|
|
10
|
+
|
|
11
|
+
const host = hostname();
|
|
12
|
+
const file = (root: string) => join(maintenanceDir(root), 'coordination.sqlite');
|
|
13
|
+
export async function coordinated(root: string): Promise<boolean> {
|
|
14
|
+
const info = await inspect(root, file(root));
|
|
15
|
+
if (info && !info.isFile()) throw new Error('Invalid cleanup coordination store.');
|
|
16
|
+
return Boolean(info);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** SQLite serializes publication and the final scan + move, and releases the gate on process death. */
|
|
20
|
+
export async function withCoordination<T>(root: string, run: (db: DatabaseSync) => Promise<T> | T, create = false): Promise<T> {
|
|
21
|
+
const { DatabaseSync } = await import('node:sqlite');
|
|
22
|
+
if (!await coordinated(root) && !create) throw new Error('Cleanup coordination store is missing.');
|
|
23
|
+
const db = new DatabaseSync(file(root));
|
|
24
|
+
try {
|
|
25
|
+
while (true) {
|
|
26
|
+
try { db.exec('BEGIN IMMEDIATE'); break; }
|
|
27
|
+
catch (error) {
|
|
28
|
+
if ((error as {errcode?: number}).errcode !== 5) throw error; // SQLITE_BUSY
|
|
29
|
+
await sleep(30);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
if (create) {
|
|
33
|
+
db.exec(`CREATE TABLE IF NOT EXISTS host (name TEXT PRIMARY KEY);
|
|
34
|
+
CREATE TABLE IF NOT EXISTS uses (token TEXT PRIMARY KEY, pid INTEGER NOT NULL,
|
|
35
|
+
owner TEXT NOT NULL, paths TEXT NOT NULL, ids TEXT NOT NULL)`);
|
|
36
|
+
if (!db.prepare('SELECT name FROM host').get()) db.prepare('INSERT INTO host VALUES (?)').run(host);
|
|
37
|
+
}
|
|
38
|
+
if (db.prepare('SELECT name FROM host').get()?.name !== host) throw new Error('Cleanup coordination requires storage local to this machine.');
|
|
39
|
+
const result = await run(db);
|
|
40
|
+
db.exec('COMMIT');
|
|
41
|
+
return result;
|
|
42
|
+
} finally { db.close(); }
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export async function enableCoordination(root: string): Promise<void> {
|
|
46
|
+
await coordinated(root);
|
|
47
|
+
await mkdir(maintenanceDir(root), {recursive: true, mode: 0o700});
|
|
48
|
+
await withCoordination(root, () => {}, true);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function readOccupancy(db: DatabaseSync): {held: Set<string>; local: Set<string>; sources: {owner: string; refs: References}[]} {
|
|
52
|
+
const held = new Set<string>(), local = new Set<string>(), sources: {owner: string; refs: References}[] = [];
|
|
53
|
+
const forget = db.prepare('DELETE FROM uses WHERE token = ?');
|
|
54
|
+
for (const row of db.prepare('SELECT * FROM uses').all()) {
|
|
55
|
+
const {token, pid, owner} = row;
|
|
56
|
+
const decode = (raw: unknown): string[] => {
|
|
57
|
+
const values: unknown = typeof raw === 'string' ? JSON.parse(raw) : undefined;
|
|
58
|
+
if (!Array.isArray(values) || values.some(item => typeof item !== 'string')) throw new Error('Invalid cleanup occupancy references.');
|
|
59
|
+
return values;
|
|
60
|
+
};
|
|
61
|
+
if (typeof token !== 'string' || typeof pid !== 'number' || !Number.isSafeInteger(pid) || pid <= 0
|
|
62
|
+
|| typeof owner !== 'string' || !SESSION_ID.test(owner)) throw new Error('Invalid cleanup occupancy record.');
|
|
63
|
+
try { process.kill(pid, 0); }
|
|
64
|
+
catch (error) {
|
|
65
|
+
const code = (error as NodeJS.ErrnoException).code;
|
|
66
|
+
if (code === 'ESRCH') { forget.run(token); continue; }
|
|
67
|
+
if (code !== 'EPERM') throw error; // An unsignalable process may still be alive.
|
|
68
|
+
}
|
|
69
|
+
held.add(owner);
|
|
70
|
+
if (pid === process.pid) local.add(owner);
|
|
71
|
+
sources.push({owner, refs: {paths: new Set(decode(row.paths)), ids: new Set(decode(row.ids))}});
|
|
72
|
+
}
|
|
73
|
+
return {held, local, sources};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
export class SessionUse {
|
|
77
|
+
private readonly token = randomUUID();
|
|
78
|
+
private refs = references();
|
|
79
|
+
private queue: Promise<void> = Promise.resolve();
|
|
80
|
+
private released = false;
|
|
81
|
+
private constructor(readonly root: string, readonly owner: string) {}
|
|
82
|
+
static async register(root: string, owner: string, prepare: (refs: References) => Promise<void>): Promise<SessionUse> {
|
|
83
|
+
const use = new SessionUse(root, owner);
|
|
84
|
+
await withCoordination(root, async db => {
|
|
85
|
+
await prepare(use.refs);
|
|
86
|
+
db.prepare('INSERT INTO uses VALUES (?, ?, ?, ?, ?)').run(use.token, process.pid, owner,
|
|
87
|
+
JSON.stringify([...use.refs.paths]), JSON.stringify([...use.refs.ids]));
|
|
88
|
+
});
|
|
89
|
+
return use;
|
|
90
|
+
}
|
|
91
|
+
async add(refs: References): Promise<void> {
|
|
92
|
+
const publish = this.queue.then(async () => {
|
|
93
|
+
if (this.released) throw new Error('Session occupancy ended before publishing references.');
|
|
94
|
+
if (![...refs.paths].some(path => !this.refs.paths.has(path)) && ![...refs.ids].some(id => !this.refs.ids.has(id))) return;
|
|
95
|
+
const next = {paths: new Set([...this.refs.paths, ...refs.paths]), ids: new Set([...this.refs.ids, ...refs.ids])};
|
|
96
|
+
await withCoordination(this.root, db => {
|
|
97
|
+
const updated = db.prepare('UPDATE uses SET paths = ?, ids = ? WHERE token = ?').run(JSON.stringify([...next.paths]), JSON.stringify([...next.ids]), this.token);
|
|
98
|
+
if (!updated.changes) throw new Error('Cleanup occupancy was lost before publishing references.');
|
|
99
|
+
});
|
|
100
|
+
this.refs = next;
|
|
101
|
+
});
|
|
102
|
+
this.queue = publish.catch(() => {}); // Keep the queue usable; the caller receives the failure.
|
|
103
|
+
return publish;
|
|
104
|
+
}
|
|
105
|
+
async release(): Promise<void> {
|
|
106
|
+
this.released = true;
|
|
107
|
+
await this.queue;
|
|
108
|
+
await withCoordination(this.root, db => { db.prepare('DELETE FROM uses WHERE token = ?').run(this.token); });
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export async function assertSessionAvailable(path: string, hadConversation: boolean): Promise<void> {
|
|
113
|
+
if (!hadConversation) return; // Pi intentionally defers creating new session files.
|
|
114
|
+
try { if ((await stat(path)).isFile()) return; }
|
|
115
|
+
catch (error) { if ((error as NodeJS.ErrnoException).code !== 'ENOENT') throw error; }
|
|
116
|
+
throw new Error('This session file disappeared before Suite could open its data. Restore the main session and retry.');
|
|
117
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { Stats } from 'node:fs';
|
|
2
|
+
import { lstat, realpath } from 'node:fs/promises';
|
|
3
|
+
import { basename, dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';
|
|
4
|
+
import { errnoCode } from '../../jobs/types.ts';
|
|
5
|
+
|
|
6
|
+
export type FileStamp = Pick<Stats, 'dev' | 'ino' | 'size' | 'mtimeMs' | 'birthtimeMs'>;
|
|
7
|
+
export const stamp = ({dev, ino, size, mtimeMs, birthtimeMs}: Stats): FileStamp => ({dev, ino, size, mtimeMs, birthtimeMs});
|
|
8
|
+
export const matches = (info: FileStamp | undefined, expected: FileStamp): boolean => !!info && sameRoot(info, expected)
|
|
9
|
+
&& info.size === expected.size && info.mtimeMs === expected.mtimeMs;
|
|
10
|
+
export const sameRoot = (info: Pick<Stats, 'dev' | 'ino' | 'birthtimeMs'>, expected: typeof info): boolean =>
|
|
11
|
+
info.dev === expected.dev && info.ino === expected.ino && info.birthtimeMs === expected.birthtimeMs;
|
|
12
|
+
export const pathKey = (path: string): string => process.platform === 'win32' ? resolve(path).toLowerCase() : resolve(path);
|
|
13
|
+
export function contains(base: string, path: string): boolean {
|
|
14
|
+
const rel = relative(base, path);
|
|
15
|
+
return rel !== '..' && !rel.startsWith(`..${sep}`) && !isAbsolute(rel);
|
|
16
|
+
}
|
|
17
|
+
export async function statIfPresent(path: string): Promise<Stats | undefined> {
|
|
18
|
+
try { return await lstat(path); } catch (error) { if (errnoCode(error) !== 'ENOENT') throw error; }
|
|
19
|
+
}
|
|
20
|
+
/** References can use Pi's workspace aliases even when moves use only canonical paths. */
|
|
21
|
+
export async function referenceKey(path: string): Promise<string> {
|
|
22
|
+
try { return pathKey(await realpath(path)); }
|
|
23
|
+
catch (error) {
|
|
24
|
+
if (errnoCode(error) !== 'ENOENT') throw error;
|
|
25
|
+
try { return pathKey(join(await realpath(dirname(path)), basename(path))); }
|
|
26
|
+
catch (parentError) { if (errnoCode(parentError) !== 'ENOENT') throw parentError; return pathKey(path); }
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Managed roots are canonical; never traverse a redirected component during a move. */
|
|
31
|
+
export async function inspect(base: string, path: string): Promise<Stats | undefined> {
|
|
32
|
+
if (!contains(base, path)) throw new Error(`Path leaves managed root: ${path}`);
|
|
33
|
+
let current = base;
|
|
34
|
+
let info = await lstat(base);
|
|
35
|
+
if (!info.isDirectory() || pathKey(await realpath(base)) !== pathKey(base)) throw new Error(`Invalid managed root: ${base}`);
|
|
36
|
+
for (const part of relative(base, path).split(sep).filter(Boolean)) {
|
|
37
|
+
current = join(current, part);
|
|
38
|
+
const child = await statIfPresent(current);
|
|
39
|
+
if (!child) return;
|
|
40
|
+
if (child.isSymbolicLink()) throw new Error(`Managed path is a link: ${current}`);
|
|
41
|
+
info = child;
|
|
42
|
+
}
|
|
43
|
+
return info;
|
|
44
|
+
}
|