gestalt-mobile 0.42.1 → 0.44.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/README.md +64 -0
- package/dist/client/assets/index-7g7-CxvF.js +107 -0
- package/dist/client/assets/index-BKls66uM.css +1 -0
- package/dist/client/index.html +2 -2
- package/dist/server/server/app.js +2 -3
- package/dist/server/server/composition.contracts.js +107 -0
- package/dist/server/server/composition.js +45 -10
- package/dist/server/server/features/catalog/get-bootstrap/use-case.js +11 -0
- package/dist/server/server/features/catalog/register-routes.js +13 -0
- package/dist/server/server/features/catalog/session-defaults/endpoint.js +16 -0
- package/dist/server/server/features/files/check-references/endpoint.js +36 -0
- package/dist/server/server/features/files/read-entry/endpoint.js +28 -0
- package/dist/server/server/features/files/register-routes.js +4 -0
- package/dist/server/server/features/plans/application/parse-supervised-plan.js +11 -0
- package/dist/server/server/features/plans/archive-workspace-plan/endpoint.js +26 -0
- package/dist/server/server/features/plans/list-workspace-plans/endpoint.js +1 -1
- package/dist/server/server/features/plans/register-routes.js +6 -0
- package/dist/server/server/features/sessions/model/relay-session.js +2 -0
- package/dist/server/server/features/sessions/start-session/endpoint.js +6 -0
- package/dist/server/server/features/sessions/start-session/request.js +4 -0
- package/dist/server/server/features/sessions/start-session/use-case.js +12 -0
- package/dist/server/server/platform/catalog/filesystem-workspace-catalog.js +3 -0
- package/dist/server/server/platform/codex/recent-thread-lister.js +2 -1
- package/dist/server/server/platform/codex/session-model-config.js +104 -0
- package/dist/server/server/platform/codex/session-runtime.js +33 -13
- package/dist/server/server/platform/filesystem/filesystem-workspace-files.js +99 -0
- package/dist/server/server/platform/persistence/filesystem-session-defaults.js +42 -0
- package/dist/server/server/platform/persistence/migrate.js +2 -0
- package/dist/server/server/platform/persistence/sqlite-session-repository.js +7 -2
- package/dist/server/server/platform/plans/filesystem-plan-archiver.js +109 -0
- package/dist/server/server/platform/plans/filesystem-plan-status-source.js +42 -1
- package/dist/server/server/platform/plans/filesystem-workspace-plan-catalog.js +96 -68
- package/dist/server/server/platform/plans/org-plan-archive-tag.js +17 -0
- package/dist/server/server/platform/plans/org-plan-discovery.js +53 -0
- package/dist/server/shared/contracts/session-defaults.js +20 -0
- package/dist/server/shared/contracts/session-model-settings.js +6 -0
- package/package.json +3 -1
- package/dist/client/assets/index-BRly-q56.js +0 -38
- package/dist/client/assets/index-D57mr3B1.css +0 -1
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2026 Dyne.org foundation
|
|
3
|
+
* Designed by Denis Roio <jaromil@dyne.org>
|
|
4
|
+
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
5
|
+
*/
|
|
6
|
+
import { constants } from 'node:fs';
|
|
7
|
+
import { lstat, open, realpath, rename, rm, writeFile } from 'node:fs/promises';
|
|
8
|
+
import { randomUUID } from 'node:crypto';
|
|
9
|
+
import { basename, dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';
|
|
10
|
+
import { archiveOrgPlan } from './org-plan-archive-tag.js';
|
|
11
|
+
/** Adds a standard Org file tag without moving the plan or changing its tasks. */
|
|
12
|
+
export class FilesystemPlanArchiver {
|
|
13
|
+
beforePublish;
|
|
14
|
+
pending = new Map();
|
|
15
|
+
constructor(beforePublish = async () => { }) {
|
|
16
|
+
this.beforePublish = beforePublish;
|
|
17
|
+
}
|
|
18
|
+
async archive(workspacePath, planName) {
|
|
19
|
+
if (!isAbsolute(workspacePath) || !validPlanName(planName))
|
|
20
|
+
return { kind: 'missing' };
|
|
21
|
+
const key = `${workspacePath}\0${planName}`;
|
|
22
|
+
const active = this.pending.get(key);
|
|
23
|
+
if (active)
|
|
24
|
+
return active;
|
|
25
|
+
const request = this.write(workspacePath, planName).finally(() => this.pending.delete(key));
|
|
26
|
+
this.pending.set(key, request);
|
|
27
|
+
return request;
|
|
28
|
+
}
|
|
29
|
+
async write(workspacePath, planName) {
|
|
30
|
+
try {
|
|
31
|
+
const workspace = await realpath(workspacePath);
|
|
32
|
+
const path = resolve(workspace, ...planName.split('/'));
|
|
33
|
+
if ((await realpath(path)) !== path)
|
|
34
|
+
return { kind: 'unavailable' };
|
|
35
|
+
const parentPath = dirname(path);
|
|
36
|
+
const parent = await open(parentPath, constants.O_RDONLY | constants.O_DIRECTORY | constants.O_NOFOLLOW);
|
|
37
|
+
try {
|
|
38
|
+
// Anchor publishing to the checked directory, even if a parent is renamed.
|
|
39
|
+
const anchor = `/proc/self/fd/${parent.fd}`;
|
|
40
|
+
if ((await realpath(anchor)) !== parentPath)
|
|
41
|
+
return { kind: 'unavailable' };
|
|
42
|
+
const target = join(anchor, basename(path));
|
|
43
|
+
const file = await open(target, constants.O_RDONLY | constants.O_NOFOLLOW);
|
|
44
|
+
let metadata;
|
|
45
|
+
let source;
|
|
46
|
+
try {
|
|
47
|
+
metadata = await file.stat();
|
|
48
|
+
if (!metadata.isFile() || metadata.size > 1_048_576)
|
|
49
|
+
return { kind: 'unavailable' };
|
|
50
|
+
source = await file.readFile('utf8');
|
|
51
|
+
if (!sameFile(metadata, await file.stat()))
|
|
52
|
+
return { kind: 'conflict' };
|
|
53
|
+
}
|
|
54
|
+
finally {
|
|
55
|
+
await file.close();
|
|
56
|
+
}
|
|
57
|
+
const content = archiveOrgPlan(source);
|
|
58
|
+
if (content === source)
|
|
59
|
+
return { kind: 'archived' };
|
|
60
|
+
const temporary = join(anchor, `.${randomUUID()}.archive`);
|
|
61
|
+
try {
|
|
62
|
+
await writeFile(temporary, content, { flag: 'wx', mode: metadata.mode & 0o777 });
|
|
63
|
+
await this.beforePublish();
|
|
64
|
+
if ((await realpath(parentPath)) !== parentPath ||
|
|
65
|
+
(await realpath(anchor)) !== parentPath ||
|
|
66
|
+
!within(workspace, await realpath(anchor)))
|
|
67
|
+
return { kind: 'unavailable' };
|
|
68
|
+
if (!sameFile(metadata, await lstat(target)))
|
|
69
|
+
return { kind: 'conflict' };
|
|
70
|
+
await rename(temporary, target);
|
|
71
|
+
}
|
|
72
|
+
finally {
|
|
73
|
+
await rm(temporary, { force: true });
|
|
74
|
+
}
|
|
75
|
+
return { kind: 'archived' };
|
|
76
|
+
}
|
|
77
|
+
finally {
|
|
78
|
+
await parent.close();
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
return {
|
|
83
|
+
kind: error.code === 'ENOENT' ? 'missing' : 'unavailable',
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
function sameFile(before, after) {
|
|
89
|
+
return (after.isFile() &&
|
|
90
|
+
!after.isSymbolicLink() &&
|
|
91
|
+
before.dev === after.dev &&
|
|
92
|
+
before.ino === after.ino &&
|
|
93
|
+
before.size === after.size &&
|
|
94
|
+
before.mtimeMs === after.mtimeMs &&
|
|
95
|
+
before.ctimeMs === after.ctimeMs);
|
|
96
|
+
}
|
|
97
|
+
function within(root, path) {
|
|
98
|
+
const name = relative(root, path);
|
|
99
|
+
return name === '' || (!isAbsolute(name) && name !== '..' && !name.startsWith(`..${sep}`));
|
|
100
|
+
}
|
|
101
|
+
function validPlanName(name) {
|
|
102
|
+
const parts = name.split('/');
|
|
103
|
+
return (name.endsWith('.org') &&
|
|
104
|
+
!isAbsolute(name) &&
|
|
105
|
+
!name.includes('\\') &&
|
|
106
|
+
!name.includes('\0') &&
|
|
107
|
+
parts.slice(0, -1).includes('.gestalt') &&
|
|
108
|
+
parts.every((part) => part !== '' && part !== '.' && part !== '..' && part !== '.git'));
|
|
109
|
+
}
|
|
@@ -25,6 +25,8 @@ export class FilesystemPlanStatusSource {
|
|
|
25
25
|
}
|
|
26
26
|
async open(session, listener) {
|
|
27
27
|
this.leases.get(session.id)?.close();
|
|
28
|
+
if (!(await stat(session.workspacePath)).isDirectory())
|
|
29
|
+
throw new Error('WORKSPACE_NOT_DIRECTORY');
|
|
28
30
|
const statusDirectory = planStatusDirectoryPath(session.workspacePath, session.id);
|
|
29
31
|
await mkdir(this.dismissalDirectory, { recursive: true, mode: 0o700 });
|
|
30
32
|
await mkdir(statusDirectory, { recursive: true, mode: 0o700 });
|
|
@@ -39,6 +41,42 @@ export class FilesystemPlanStatusSource {
|
|
|
39
41
|
await lease.start();
|
|
40
42
|
return lease;
|
|
41
43
|
}
|
|
44
|
+
/** Explicit attachments use the same durable publication and watchers as helper updates. */
|
|
45
|
+
async attach(session, requestedPath, listener, reason = 'supervision-start') {
|
|
46
|
+
const [planPath, workspacePath] = await Promise.all([
|
|
47
|
+
this.planReadFilesystem.realpath(requestedPath),
|
|
48
|
+
this.planReadFilesystem.realpath(session.workspacePath),
|
|
49
|
+
]);
|
|
50
|
+
if (!isPlanPathWithinWorkspace(planPath, workspacePath))
|
|
51
|
+
throw new Error('PATH_OUTSIDE_WORKSPACE');
|
|
52
|
+
const parsed = parseSupervisedPlan({
|
|
53
|
+
source: await this.planReadFilesystem.readFile(planPath, 'utf8'),
|
|
54
|
+
planPath,
|
|
55
|
+
workspacePath,
|
|
56
|
+
});
|
|
57
|
+
if (parsed.kind !== 'available')
|
|
58
|
+
throw new Error('PLAN_UNAVAILABLE');
|
|
59
|
+
const directory = planStatusDirectoryPath(workspacePath, session.id);
|
|
60
|
+
await mkdir(directory, { recursive: true, mode: 0o700 });
|
|
61
|
+
const statusPath = planStatusFilePath(directory, planPath);
|
|
62
|
+
const candidate = join(directory, `.${randomUUID()}.status.tmp`);
|
|
63
|
+
try {
|
|
64
|
+
await writeFile(candidate, JSON.stringify({ schemaVersion: 1, planPath, reason, updatedAt: new Date().toISOString() }), { mode: 0o600 });
|
|
65
|
+
await rename(candidate, statusPath);
|
|
66
|
+
}
|
|
67
|
+
finally {
|
|
68
|
+
await rm(candidate, { force: true }).catch(() => { });
|
|
69
|
+
}
|
|
70
|
+
const identity = createHash('sha256').update(planPath).digest('hex');
|
|
71
|
+
const dismissed = new Set(await this.dismissed(session.id));
|
|
72
|
+
if (dismissed.delete(identity))
|
|
73
|
+
await this.saveDismissals(session.id, dismissed);
|
|
74
|
+
const lease = this.leases.get(session.id);
|
|
75
|
+
if (lease)
|
|
76
|
+
await lease.refreshLatest();
|
|
77
|
+
else
|
|
78
|
+
await this.open(session, listener);
|
|
79
|
+
}
|
|
42
80
|
closeAll() {
|
|
43
81
|
for (const lease of this.leases.values())
|
|
44
82
|
lease.close();
|
|
@@ -92,9 +130,12 @@ export class FilesystemPlanStatusSource {
|
|
|
92
130
|
}
|
|
93
131
|
}
|
|
94
132
|
async dismiss(sessionId, identity) {
|
|
95
|
-
const path = this.dismissalPath(sessionId);
|
|
96
133
|
const dismissed = await this.dismissed(sessionId);
|
|
97
134
|
const next = new Set(dismissed).add(identity);
|
|
135
|
+
await this.saveDismissals(sessionId, next);
|
|
136
|
+
}
|
|
137
|
+
async saveDismissals(sessionId, next) {
|
|
138
|
+
const path = this.dismissalPath(sessionId);
|
|
98
139
|
const candidate = join(this.dismissalDirectory, `.${randomUUID()}.dismissals.tmp`);
|
|
99
140
|
try {
|
|
100
141
|
await this.dismissalFilesystem.writeFile(candidate, JSON.stringify([...next]), {
|
|
@@ -3,44 +3,112 @@
|
|
|
3
3
|
* Designed by Denis Roio <jaromil@dyne.org>
|
|
4
4
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
5
5
|
*/
|
|
6
|
-
import { lstat,
|
|
7
|
-
import { isAbsolute,
|
|
6
|
+
import { lstat, readFile, realpath, stat } from 'node:fs/promises';
|
|
7
|
+
import { isAbsolute, relative, resolve, sep } from 'node:path';
|
|
8
8
|
import { parseSupervisedPlan } from '../../features/plans/application/parse-supervised-plan.js';
|
|
9
|
+
import { OrgPlanDiscovery } from './org-plan-discovery.js';
|
|
10
|
+
import { isArchivedOrgPlan } from './org-plan-archive-tag.js';
|
|
9
11
|
const maximumBytes = 1_048_576;
|
|
10
|
-
/**
|
|
11
|
-
* Passive access to every regular `.org` file below a workspace. Symlinks are
|
|
12
|
-
* never followed. Supported supervised plans include a browser preview; other
|
|
13
|
-
* Org files remain visible in the catalog without one.
|
|
14
|
-
*/
|
|
12
|
+
/** Cached `.gestalt` Org discovery, with bounded parallel metadata checks. */
|
|
15
13
|
export class FilesystemWorkspacePlanCatalog {
|
|
16
14
|
filesystem;
|
|
17
|
-
|
|
15
|
+
discovery;
|
|
16
|
+
now;
|
|
17
|
+
caches = new Map();
|
|
18
|
+
constructor(filesystem = { lstat, readFile, realpath, stat }, discovery = new OrgPlanDiscovery(), now = Date.now) {
|
|
18
19
|
this.filesystem = filesystem;
|
|
20
|
+
this.discovery = discovery;
|
|
21
|
+
this.now = now;
|
|
19
22
|
}
|
|
20
|
-
async list(workspacePath) {
|
|
23
|
+
async list(workspacePath, refresh = false) {
|
|
21
24
|
const workspace = await this.workspace(workspacePath);
|
|
22
25
|
if (!workspace)
|
|
23
26
|
return [];
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if (candidate.kind === 'missing')
|
|
29
|
-
continue;
|
|
30
|
-
if (candidate.kind === 'unavailable') {
|
|
31
|
-
entries.push(toFallbackEntry(planName));
|
|
32
|
-
continue;
|
|
33
|
-
}
|
|
34
|
-
const parsed = parseSupervisedPlan({
|
|
35
|
-
source: candidate.source,
|
|
36
|
-
planPath: candidate.canonicalPath,
|
|
37
|
-
workspacePath: workspace,
|
|
38
|
-
});
|
|
39
|
-
entries.push(parsed.kind === 'available'
|
|
40
|
-
? toEntry(planName, parsed.plan)
|
|
41
|
-
: toFallbackEntry(planName, candidate.source));
|
|
27
|
+
let cache = this.caches.get(workspace);
|
|
28
|
+
if (!cache) {
|
|
29
|
+
cache = { entries: null, files: new Map(), refreshedAt: 0, request: null };
|
|
30
|
+
this.caches.set(workspace, cache);
|
|
42
31
|
}
|
|
43
|
-
|
|
32
|
+
if (cache.request)
|
|
33
|
+
return cache.request;
|
|
34
|
+
if (!refresh && cache.entries && this.now() - cache.refreshedAt < 1_000)
|
|
35
|
+
return cache.entries;
|
|
36
|
+
const current = cache;
|
|
37
|
+
current.request = this.refresh(workspace, current).finally(() => {
|
|
38
|
+
current.request = null;
|
|
39
|
+
});
|
|
40
|
+
return current.request;
|
|
41
|
+
}
|
|
42
|
+
async refresh(workspace, cache) {
|
|
43
|
+
const planNames = [...new Set(await this.discovery.list(workspace))]
|
|
44
|
+
.filter((name) => isPlanPath(name) && name.split('/').slice(0, -1).includes('.gestalt'))
|
|
45
|
+
.sort((left, right) => left.localeCompare(right));
|
|
46
|
+
const entries = new Array(planNames.length).fill(null);
|
|
47
|
+
const files = new Map();
|
|
48
|
+
let next = 0;
|
|
49
|
+
await Promise.all(Array.from({ length: Math.min(8, planNames.length) }, async () => {
|
|
50
|
+
while (next < planNames.length) {
|
|
51
|
+
const index = next++;
|
|
52
|
+
const name = planNames[index];
|
|
53
|
+
let signature;
|
|
54
|
+
try {
|
|
55
|
+
const metadata = await this.filesystem.lstat(resolve(workspace, ...name.split('/')));
|
|
56
|
+
if (!metadata.isFile() || metadata.isSymbolicLink())
|
|
57
|
+
continue;
|
|
58
|
+
signature = [
|
|
59
|
+
metadata.dev,
|
|
60
|
+
metadata.ino,
|
|
61
|
+
metadata.size,
|
|
62
|
+
metadata.mtimeMs,
|
|
63
|
+
metadata.ctimeMs,
|
|
64
|
+
].join(':');
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
const previous = cache.files.get(name);
|
|
70
|
+
if (previous?.signature === signature) {
|
|
71
|
+
try {
|
|
72
|
+
const canonical = await this.filesystem.realpath(resolve(workspace, ...name.split('/')));
|
|
73
|
+
if (!isWithin(workspace, canonical) ||
|
|
74
|
+
toPlanName(relative(workspace, canonical)) !== name)
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
catch {
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
entries[index] = previous.entry;
|
|
81
|
+
files.set(name, previous);
|
|
82
|
+
continue;
|
|
83
|
+
}
|
|
84
|
+
const candidate = await this.readCandidate(workspace, name);
|
|
85
|
+
if (candidate.kind === 'missing')
|
|
86
|
+
continue;
|
|
87
|
+
let entry;
|
|
88
|
+
if (candidate.kind === 'unavailable') {
|
|
89
|
+
entry = toFallbackEntry(name);
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
const parsed = parseSupervisedPlan({
|
|
93
|
+
source: candidate.source,
|
|
94
|
+
planPath: candidate.canonicalPath,
|
|
95
|
+
workspacePath: workspace,
|
|
96
|
+
});
|
|
97
|
+
entry =
|
|
98
|
+
parsed.kind === 'available'
|
|
99
|
+
? toEntry(name, parsed.plan)
|
|
100
|
+
: toFallbackEntry(name, candidate.source);
|
|
101
|
+
if (isArchivedOrgPlan(candidate.source))
|
|
102
|
+
entry = { ...entry, archived: true };
|
|
103
|
+
files.set(name, { signature, entry });
|
|
104
|
+
}
|
|
105
|
+
entries[index] = entry;
|
|
106
|
+
}
|
|
107
|
+
}));
|
|
108
|
+
cache.files = files;
|
|
109
|
+
cache.entries = entries.filter((entry) => entry !== null);
|
|
110
|
+
cache.refreshedAt = this.now();
|
|
111
|
+
return cache.entries;
|
|
44
112
|
}
|
|
45
113
|
async read(workspacePath, planName) {
|
|
46
114
|
if (!isPlanPath(planName))
|
|
@@ -62,46 +130,6 @@ export class FilesystemWorkspacePlanCatalog {
|
|
|
62
130
|
return null;
|
|
63
131
|
}
|
|
64
132
|
}
|
|
65
|
-
async discover(workspace) {
|
|
66
|
-
const pending = [workspace];
|
|
67
|
-
const visited = new Set();
|
|
68
|
-
const plans = [];
|
|
69
|
-
while (pending.length > 0) {
|
|
70
|
-
const directory = pending.pop();
|
|
71
|
-
try {
|
|
72
|
-
const before = await this.filesystem.lstat(directory);
|
|
73
|
-
if (!before.isDirectory() || before.isSymbolicLink())
|
|
74
|
-
continue;
|
|
75
|
-
const canonical = await this.filesystem.realpath(directory);
|
|
76
|
-
if (!isWithin(workspace, canonical))
|
|
77
|
-
continue;
|
|
78
|
-
const metadata = await this.filesystem.stat(canonical);
|
|
79
|
-
if (!metadata.isDirectory() || visited.has(canonical))
|
|
80
|
-
continue;
|
|
81
|
-
visited.add(canonical);
|
|
82
|
-
const children = await this.filesystem.readdir(canonical, {
|
|
83
|
-
encoding: 'utf8',
|
|
84
|
-
withFileTypes: true,
|
|
85
|
-
});
|
|
86
|
-
for (const child of children) {
|
|
87
|
-
if (child.isSymbolicLink())
|
|
88
|
-
continue;
|
|
89
|
-
const childPath = join(canonical, child.name);
|
|
90
|
-
if (child.isDirectory())
|
|
91
|
-
pending.push(childPath);
|
|
92
|
-
else if (child.isFile() && isPlanFilename(child.name)) {
|
|
93
|
-
const planName = toPlanName(relative(workspace, childPath));
|
|
94
|
-
if (isPlanPath(planName))
|
|
95
|
-
plans.push(planName);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
catch {
|
|
100
|
-
// A disappearing or unreadable branch does not hide plans elsewhere.
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
return plans.sort((left, right) => left.localeCompare(right));
|
|
104
|
-
}
|
|
105
133
|
async readFromWorkspace(workspace, planName) {
|
|
106
134
|
const candidate = await this.readCandidate(workspace, planName);
|
|
107
135
|
if (candidate.kind !== 'readable')
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2026 Dyne.org foundation
|
|
3
|
+
* Designed by Denis Roio <jaromil@dyne.org>
|
|
4
|
+
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
5
|
+
*/
|
|
6
|
+
export function isArchivedOrgPlan(source) {
|
|
7
|
+
return [...source.matchAll(/^#\+FILETAGS:[ \t]*(.*)$/gim)].some((match) => match[1].split(/[:\s]+/).some((tag) => tag.toUpperCase() === 'ARCHIVE'));
|
|
8
|
+
}
|
|
9
|
+
export function archiveOrgPlan(source) {
|
|
10
|
+
if (isArchivedOrgPlan(source))
|
|
11
|
+
return source;
|
|
12
|
+
const existing = /^(#\+FILETAGS:[ \t]*)([^\r\n]*)(\r?)$/im;
|
|
13
|
+
if (existing.test(source))
|
|
14
|
+
return source.replace(existing, (_line, prefix, tags, carriage) => `${prefix}${tags.trimEnd()}${tags.trimEnd().endsWith(':') ? '' : ':'}ARCHIVE:${carriage}`);
|
|
15
|
+
const newline = source.includes('\r\n') ? '\r\n' : '\n';
|
|
16
|
+
return `#+FILETAGS: :ARCHIVE:${newline}${source}`;
|
|
17
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2026 Dyne.org foundation
|
|
3
|
+
* Designed by Denis Roio <jaromil@dyne.org>
|
|
4
|
+
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
5
|
+
*/
|
|
6
|
+
import { execFile } from 'node:child_process';
|
|
7
|
+
import { promisify } from 'node:util';
|
|
8
|
+
const execute = promisify(execFile);
|
|
9
|
+
async function run(command, args, cwd) {
|
|
10
|
+
try {
|
|
11
|
+
const result = await execute(command, [...args], {
|
|
12
|
+
cwd,
|
|
13
|
+
encoding: 'utf8',
|
|
14
|
+
maxBuffer: 64 * 1024 * 1024,
|
|
15
|
+
timeout: 30_000,
|
|
16
|
+
});
|
|
17
|
+
return result.stdout;
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
const failure = error;
|
|
21
|
+
// Permission errors in one branch must not hide readable plans elsewhere.
|
|
22
|
+
if (failure.code === 1 && !failure.killed && typeof failure.stdout === 'string')
|
|
23
|
+
return failure.stdout;
|
|
24
|
+
throw error;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
/** Native, NUL-delimited discovery; never invokes a shell or follows symlinks. */
|
|
28
|
+
export class OrgPlanDiscovery {
|
|
29
|
+
execute;
|
|
30
|
+
command = 'bfs';
|
|
31
|
+
constructor(execute = run) {
|
|
32
|
+
this.execute = execute;
|
|
33
|
+
}
|
|
34
|
+
async list(workspace) {
|
|
35
|
+
const args = ['.', '-type', 'f', '-name', '*.org', '-path', '*/.gestalt/*', '-print0'];
|
|
36
|
+
let output;
|
|
37
|
+
try {
|
|
38
|
+
output = await this.execute(this.command, args, workspace);
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
if (this.command !== 'bfs' || error.code !== 'ENOENT')
|
|
42
|
+
throw error;
|
|
43
|
+
this.command = 'find';
|
|
44
|
+
output = await this.execute('find', args, workspace);
|
|
45
|
+
}
|
|
46
|
+
return [
|
|
47
|
+
...new Set(output
|
|
48
|
+
.split('\0')
|
|
49
|
+
.filter(Boolean)
|
|
50
|
+
.map((path) => path.replace(/^\.\//, ''))),
|
|
51
|
+
];
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2026 Dyne.org foundation
|
|
3
|
+
* Designed by Denis Roio <jaromil@dyne.org>
|
|
4
|
+
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
5
|
+
*/
|
|
6
|
+
import { z } from 'zod';
|
|
7
|
+
import { thinkingLevels } from './session-model-settings.js';
|
|
8
|
+
export const sessionDefaultsSchema = z
|
|
9
|
+
.object({
|
|
10
|
+
workspaceId: z.string().max(4096),
|
|
11
|
+
skillProfile: z.string().max(256),
|
|
12
|
+
provider: z.enum(['codex', 'kimi']),
|
|
13
|
+
model: z.string().min(1).max(256),
|
|
14
|
+
reasoningEffort: z.enum(thinkingLevels).default('medium'),
|
|
15
|
+
executorModel: z.string().trim().min(1).max(256).default('gpt-5.6-terra'),
|
|
16
|
+
executorReasoningEffort: z.enum(thinkingLevels).default('high'),
|
|
17
|
+
sandbox: z.enum(['workspace-git', 'workspace-write', 'read-only', 'danger-full-access']),
|
|
18
|
+
approvalPolicy: z.enum(['untrusted', 'on-request', 'never']),
|
|
19
|
+
})
|
|
20
|
+
.strict();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gestalt-mobile",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.44.0",
|
|
4
4
|
"description": "Mobile-first web relay for durable Codex development sessions",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"codex",
|
|
@@ -72,7 +72,9 @@
|
|
|
72
72
|
"@fontsource/syne": "5.2.7",
|
|
73
73
|
"@simplewebauthn/browser": "13.3.0",
|
|
74
74
|
"@simplewebauthn/server": "13.3.2",
|
|
75
|
+
"dompurify": "^3.4.16",
|
|
75
76
|
"fastify": "^5.12.3",
|
|
77
|
+
"marked": "^18.0.14",
|
|
76
78
|
"qrcode": "^1.5.4",
|
|
77
79
|
"ws": "^8.21.0",
|
|
78
80
|
"yaml": "^2.9.0",
|