gestalt-mobile 0.67.2 → 0.68.1
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/client/assets/index-BZ3ivopC.js +183 -0
- package/dist/client/assets/index-DRbCnCbk.css +1 -0
- package/dist/client/index.html +2 -2
- package/dist/server/server/composition.contracts.js +1113 -0
- package/dist/server/server/composition.js +330 -57
- package/dist/server/server/features/autopilot/application/service.js +26 -6
- package/dist/server/server/features/plans/application/org-plan-launch-store.js +6 -0
- package/dist/server/server/features/plans/application/prepare-org-plan-settings.js +66 -0
- package/dist/server/server/features/plans/application/prepare-org-plan-supervision.js +86 -0
- package/dist/server/server/features/plans/application/start-org-plan-supervision.js +323 -0
- package/dist/server/server/features/plans/execute-plan/endpoint.js +27 -0
- package/dist/server/server/features/plans/get-workspace-plan/endpoint.js +2 -1
- package/dist/server/server/features/plans/open-plan/endpoint.js +2 -1
- package/dist/server/server/features/plans/prepare-supervision/endpoint.js +52 -0
- package/dist/server/server/features/plans/register-routes.js +6 -0
- package/dist/server/server/features/sessions/application/resolve-session-skills.js +35 -0
- package/dist/server/server/features/sessions/application/start-settings.js +2 -1
- package/dist/server/server/features/sessions/register-routes.js +1 -0
- package/dist/server/server/features/sessions/start-session/endpoint.js +5 -0
- package/dist/server/server/features/sessions/start-session/use-case.js +7 -32
- package/dist/server/server/features/sessions/start-turn/endpoint.js +9 -167
- package/dist/server/server/features/sessions/start-turn/use-case.js +243 -0
- package/dist/server/server/features/skills/application/read-global-profiles.js +34 -0
- package/dist/server/server/features/skills/list-profiles/endpoint.js +9 -33
- package/dist/server/server/platform/catalog/filesystem-workspace-catalog.js +11 -0
- package/dist/server/server/platform/codex/session-runtime.js +20 -6
- package/dist/server/server/platform/persistence/migrate.js +12 -0
- package/dist/server/server/platform/persistence/sqlite-org-plan-launch-store.js +215 -0
- package/dist/server/server/platform/plans/filesystem-org-plan-context.js +99 -0
- package/dist/server/server/platform/plans/filesystem-workspace-plan-catalog.js +36 -3
- package/dist/server/shared/contracts/org-plan-execution.js +46 -0
- package/dist/server/shared/contracts/session-defaults.js +33 -3
- package/package.json +1 -1
- package/dist/client/assets/index-DcXYn8rY.js +0 -128
- package/dist/client/assets/index-DxsD-jG4.css +0 -1
|
@@ -0,0 +1,215 @@
|
|
|
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 class SqliteOrgPlanLaunchStore {
|
|
7
|
+
db;
|
|
8
|
+
#operations = new Map();
|
|
9
|
+
constructor(db) {
|
|
10
|
+
this.db = db;
|
|
11
|
+
}
|
|
12
|
+
find(launchId) {
|
|
13
|
+
return decode(this.db.prepare('SELECT record_json FROM org_plan_launches WHERE launch_id=?').get(launchId));
|
|
14
|
+
}
|
|
15
|
+
owner(canonicalPath) {
|
|
16
|
+
return decode(this.db
|
|
17
|
+
.prepare('SELECT record_json FROM org_plan_launches WHERE canonical_path=?')
|
|
18
|
+
.get(canonicalPath));
|
|
19
|
+
}
|
|
20
|
+
forSession(sessionId) {
|
|
21
|
+
return decode(this.db
|
|
22
|
+
.prepare('SELECT record_json FROM org_plan_launches WHERE session_id=?')
|
|
23
|
+
.get(sessionId));
|
|
24
|
+
}
|
|
25
|
+
reserve(record) {
|
|
26
|
+
const inserted = this.db
|
|
27
|
+
.prepare('INSERT OR IGNORE INTO org_plan_launches (launch_id,canonical_path,session_id,phase,record_json) VALUES (?,?,?,?,?)')
|
|
28
|
+
.run(record.launchId, record.canonicalPath, record.sessionId, record.phase, JSON.stringify(record));
|
|
29
|
+
if (inserted.changes === 1)
|
|
30
|
+
return { kind: 'reserved', record };
|
|
31
|
+
const existing = this.find(record.launchId);
|
|
32
|
+
if (existing)
|
|
33
|
+
return { kind: 'existing', record: existing };
|
|
34
|
+
const owner = this.owner(record.canonicalPath);
|
|
35
|
+
if (!owner)
|
|
36
|
+
throw new Error('ORG_PLAN_RESERVATION_CONFLICT');
|
|
37
|
+
return { kind: 'owned', record: owner };
|
|
38
|
+
}
|
|
39
|
+
save(record, expected) {
|
|
40
|
+
return (this.db
|
|
41
|
+
.prepare("UPDATE org_plan_launches SET phase=?,record_json=? WHERE launch_id=? AND session_id=? AND phase=? AND coalesce(json_extract(record_json,'$.publicationRevision'),0)=?")
|
|
42
|
+
.run(record.phase, JSON.stringify(record), record.launchId, record.sessionId, expected, record.publicationRevision ?? 0).changes === 1);
|
|
43
|
+
}
|
|
44
|
+
releaseOwner(record) {
|
|
45
|
+
this.db
|
|
46
|
+
.prepare('UPDATE org_plan_launches SET canonical_path=NULL WHERE launch_id=? AND session_id=? AND canonical_path=?')
|
|
47
|
+
.run(record.launchId, record.sessionId, record.canonicalPath);
|
|
48
|
+
}
|
|
49
|
+
acquireOwner(record) {
|
|
50
|
+
this.db
|
|
51
|
+
.prepare('UPDATE OR IGNORE org_plan_launches SET canonical_path=? WHERE launch_id=? AND session_id=? AND canonical_path IS NULL')
|
|
52
|
+
.run(record.canonicalPath, record.launchId, record.sessionId);
|
|
53
|
+
return this.owner(record.canonicalPath)?.launchId === record.launchId;
|
|
54
|
+
}
|
|
55
|
+
publishSession(record, candidate, sessions) {
|
|
56
|
+
this.db.exec('BEGIN IMMEDIATE');
|
|
57
|
+
try {
|
|
58
|
+
const current = this.find(record.launchId);
|
|
59
|
+
if (!current || current.sessionId !== candidate.id || record.sessionId !== candidate.id)
|
|
60
|
+
throw new Error('ORG_PLAN_PUBLICATION_FENCED');
|
|
61
|
+
const existing = sessions.find(record.sessionId);
|
|
62
|
+
if (existing) {
|
|
63
|
+
this.db.exec('COMMIT');
|
|
64
|
+
return { created: false, session: existing };
|
|
65
|
+
}
|
|
66
|
+
if (current.phase !== 'creating' ||
|
|
67
|
+
(current.publicationRevision ?? 0) !== (record.publicationRevision ?? 0) ||
|
|
68
|
+
this.owner(record.canonicalPath)?.launchId !== record.launchId)
|
|
69
|
+
throw new Error('ORG_PLAN_PUBLICATION_FENCED');
|
|
70
|
+
sessions.save(candidate);
|
|
71
|
+
this.db
|
|
72
|
+
.prepare("INSERT INTO org_plan_initial_activations (session_id,revision,phase) VALUES (?,0,'idle')")
|
|
73
|
+
.run(candidate.id);
|
|
74
|
+
if (!sessions.find(candidate.id) ||
|
|
75
|
+
!this.save({ ...current, phase: 'session', notPersisted: false }, 'creating'))
|
|
76
|
+
throw new Error('ORG_PLAN_PUBLICATION_FENCED');
|
|
77
|
+
this.db.exec('COMMIT');
|
|
78
|
+
return { created: true, session: candidate };
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
this.db.exec('ROLLBACK');
|
|
82
|
+
throw error;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
/** Only a tracked pre-request attempt can be superseded; null thread alone proves nothing. */
|
|
86
|
+
claimInitialActivation(sessionId, sessions) {
|
|
87
|
+
return this.activationTransaction(() => {
|
|
88
|
+
if (!this.initialSession(sessionId, sessions))
|
|
89
|
+
return null;
|
|
90
|
+
const prior = this.activation(sessionId);
|
|
91
|
+
if (!prior || !['idle', 'preparing', 'retryable'].includes(prior.phase))
|
|
92
|
+
return null;
|
|
93
|
+
const revision = prior.revision + 1;
|
|
94
|
+
this.db
|
|
95
|
+
.prepare('UPDATE org_plan_initial_activations SET revision=?,phase=? WHERE session_id=?')
|
|
96
|
+
.run(revision, 'preparing', sessionId);
|
|
97
|
+
return { sessionId, revision };
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
initialActivationCurrent(attempt, sessions) {
|
|
101
|
+
const current = this.activation(attempt.sessionId);
|
|
102
|
+
return Boolean(current &&
|
|
103
|
+
current.revision === attempt.revision &&
|
|
104
|
+
['preparing', 'requested'].includes(current.phase) &&
|
|
105
|
+
this.initialSession(attempt.sessionId, sessions));
|
|
106
|
+
}
|
|
107
|
+
requestInitialThread(attempt, sessions) {
|
|
108
|
+
return this.activationTransaction(() => {
|
|
109
|
+
if (!this.initialActivationCurrent(attempt, sessions))
|
|
110
|
+
return false;
|
|
111
|
+
this.db
|
|
112
|
+
.prepare("UPDATE org_plan_initial_activations SET phase='requested' WHERE session_id=?")
|
|
113
|
+
.run(attempt.sessionId);
|
|
114
|
+
return true;
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
completeInitialActivation(attempt, session, sessions) {
|
|
118
|
+
return this.activationTransaction(() => {
|
|
119
|
+
if (session.id !== attempt.sessionId ||
|
|
120
|
+
!session.threadId ||
|
|
121
|
+
this.activation(attempt.sessionId)?.phase !== 'requested' ||
|
|
122
|
+
!this.initialActivationCurrent(attempt, sessions))
|
|
123
|
+
return false;
|
|
124
|
+
sessions.save(session);
|
|
125
|
+
this.db
|
|
126
|
+
.prepare("UPDATE org_plan_initial_activations SET phase='completed' WHERE session_id=?")
|
|
127
|
+
.run(attempt.sessionId);
|
|
128
|
+
return true;
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
failInitialActivation(attempt) {
|
|
132
|
+
// A failed prepare has not requested any provider thread. Requested/unknown work stays fenced.
|
|
133
|
+
this.db
|
|
134
|
+
.prepare("UPDATE org_plan_initial_activations SET phase='retryable' WHERE session_id=? AND revision=? AND phase='preparing'")
|
|
135
|
+
.run(attempt.sessionId, attempt.revision);
|
|
136
|
+
}
|
|
137
|
+
activation(sessionId) {
|
|
138
|
+
return (this.db
|
|
139
|
+
.prepare('SELECT revision,phase FROM org_plan_initial_activations WHERE session_id=?')
|
|
140
|
+
.get(sessionId) ?? null);
|
|
141
|
+
}
|
|
142
|
+
initialSession(sessionId, sessions) {
|
|
143
|
+
const session = sessions.find(sessionId);
|
|
144
|
+
const launch = this.forSession(sessionId);
|
|
145
|
+
return Boolean(session &&
|
|
146
|
+
session.threadId === null &&
|
|
147
|
+
session.desiredState === 'active' &&
|
|
148
|
+
!['stopped', 'released'].includes(session.state) &&
|
|
149
|
+
launch?.phase === 'session' &&
|
|
150
|
+
this.owner(launch.canonicalPath)?.launchId === launch.launchId);
|
|
151
|
+
}
|
|
152
|
+
activationTransaction(operation) {
|
|
153
|
+
this.db.exec('BEGIN IMMEDIATE');
|
|
154
|
+
try {
|
|
155
|
+
const result = operation();
|
|
156
|
+
this.db.exec('COMMIT');
|
|
157
|
+
return result;
|
|
158
|
+
}
|
|
159
|
+
catch (error) {
|
|
160
|
+
this.db.exec('ROLLBACK');
|
|
161
|
+
throw error;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
revokePublication(record, sessions) {
|
|
165
|
+
this.db.exec('BEGIN IMMEDIATE');
|
|
166
|
+
try {
|
|
167
|
+
const current = this.find(record.launchId);
|
|
168
|
+
if (!current ||
|
|
169
|
+
current.sessionId !== record.sessionId ||
|
|
170
|
+
!['reserved', 'creating'].includes(current.phase) ||
|
|
171
|
+
(current.publicationRevision ?? 0) !== (record.publicationRevision ?? 0) ||
|
|
172
|
+
sessions.find(record.sessionId)) {
|
|
173
|
+
this.db.exec('COMMIT');
|
|
174
|
+
return false;
|
|
175
|
+
}
|
|
176
|
+
const revoked = {
|
|
177
|
+
...current,
|
|
178
|
+
phase: 'reserved',
|
|
179
|
+
notPersisted: true,
|
|
180
|
+
publicationRevision: (current.publicationRevision ?? 0) + 1,
|
|
181
|
+
};
|
|
182
|
+
const changed = this.db
|
|
183
|
+
.prepare("UPDATE org_plan_launches SET phase='reserved',canonical_path=NULL,record_json=? WHERE launch_id=? AND session_id=? AND phase=? AND coalesce(json_extract(record_json,'$.publicationRevision'),0)=?")
|
|
184
|
+
.run(JSON.stringify(revoked), record.launchId, record.sessionId, current.phase, current.publicationRevision ?? 0).changes === 1;
|
|
185
|
+
this.db.exec('COMMIT');
|
|
186
|
+
return changed;
|
|
187
|
+
}
|
|
188
|
+
catch (error) {
|
|
189
|
+
this.db.exec('ROLLBACK');
|
|
190
|
+
throw error;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
async run(launchId, operation) {
|
|
194
|
+
const prior = this.#operations.get(launchId) ?? Promise.resolve();
|
|
195
|
+
let release;
|
|
196
|
+
const current = new Promise((resolve) => {
|
|
197
|
+
release = resolve;
|
|
198
|
+
});
|
|
199
|
+
this.#operations.set(launchId, current);
|
|
200
|
+
await prior;
|
|
201
|
+
try {
|
|
202
|
+
return await operation();
|
|
203
|
+
}
|
|
204
|
+
finally {
|
|
205
|
+
release();
|
|
206
|
+
if (this.#operations.get(launchId) === current)
|
|
207
|
+
this.#operations.delete(launchId);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
function decode(row) {
|
|
212
|
+
return row
|
|
213
|
+
? JSON.parse(row.record_json)
|
|
214
|
+
: null;
|
|
215
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
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 { createHash } from 'node:crypto';
|
|
7
|
+
import { lstat, realpath, stat } from 'node:fs/promises';
|
|
8
|
+
import { basename, dirname, isAbsolute, relative, resolve, sep } from 'node:path';
|
|
9
|
+
/** Resolves only identities already permitted by the normal workspace catalog. */
|
|
10
|
+
export class FilesystemOrgPlanContext {
|
|
11
|
+
workspaces;
|
|
12
|
+
session;
|
|
13
|
+
constructor(workspaces, session) {
|
|
14
|
+
this.workspaces = workspaces;
|
|
15
|
+
this.session = session;
|
|
16
|
+
}
|
|
17
|
+
async resolveReference(reference) {
|
|
18
|
+
if (reference.kind === 'workspace') {
|
|
19
|
+
const workspace = await this.workspaces.resolve(reference.workspaceId);
|
|
20
|
+
return { workspacePath: workspace.realPath, planName: reference.planName };
|
|
21
|
+
}
|
|
22
|
+
const session = this.session(reference.sessionId);
|
|
23
|
+
if (!session)
|
|
24
|
+
return null;
|
|
25
|
+
const workspace = await this.workspaces.resolve(session.workspaceId);
|
|
26
|
+
if (workspace.realPath !== session.workspacePath)
|
|
27
|
+
return null;
|
|
28
|
+
if (reference.kind === 'session')
|
|
29
|
+
return { workspacePath: workspace.realPath, planName: reference.planName };
|
|
30
|
+
// Absolute file identity comes from durable server state, never a client path.
|
|
31
|
+
const retained = session.lastOrgPlan?.path;
|
|
32
|
+
const root = await this.root();
|
|
33
|
+
if (!retained || !root || !isAbsolute(retained) || !within(root.realPath, retained))
|
|
34
|
+
return null;
|
|
35
|
+
return {
|
|
36
|
+
workspacePath: root.realPath,
|
|
37
|
+
planName: relative(root.realPath, retained).split(sep).join('/'),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
async workspace(canonicalPath, fileRevision) {
|
|
41
|
+
const permitted = await this.workspaces.snapshot();
|
|
42
|
+
const containing = permitted.filter((workspace) => within(workspace.realPath, canonicalPath));
|
|
43
|
+
if (!containing.length)
|
|
44
|
+
return null;
|
|
45
|
+
containing.sort((a, b) => b.realPath.length - a.realPath.length);
|
|
46
|
+
const root = containing.reduce((a, b) => (a.realPath.length < b.realPath.length ? a : b));
|
|
47
|
+
if ((await realpath(canonicalPath)) !== canonicalPath)
|
|
48
|
+
return null;
|
|
49
|
+
let selected;
|
|
50
|
+
let owner;
|
|
51
|
+
let marker;
|
|
52
|
+
for (let directory = dirname(canonicalPath); within(root.realPath, directory); directory = dirname(directory)) {
|
|
53
|
+
if (basename(directory) === '.gestalt' && !owner)
|
|
54
|
+
owner = dirname(directory);
|
|
55
|
+
try {
|
|
56
|
+
const git = await lstat(resolve(directory, '.git'));
|
|
57
|
+
if (git.isSymbolicLink() || (!git.isDirectory() && !git.isFile()))
|
|
58
|
+
return null;
|
|
59
|
+
// Do not silently select an outer project for an unselectable nested repository.
|
|
60
|
+
selected = containing.find((workspace) => workspace.realPath === directory);
|
|
61
|
+
if (!selected)
|
|
62
|
+
return null;
|
|
63
|
+
marker = git;
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
catch (error) {
|
|
67
|
+
if (error.code !== 'ENOENT')
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
if (directory === root.realPath)
|
|
71
|
+
break;
|
|
72
|
+
}
|
|
73
|
+
selected ??= containing.find((workspace) => workspace.realPath === owner) ?? containing[0];
|
|
74
|
+
if (!selected || basename(selected.realPath) === '.gestalt')
|
|
75
|
+
return null;
|
|
76
|
+
const canonical = await realpath(selected.realPath);
|
|
77
|
+
const metadata = await stat(canonical);
|
|
78
|
+
if (canonical !== selected.realPath || !metadata.isDirectory())
|
|
79
|
+
return null;
|
|
80
|
+
const revision = createHash('sha256')
|
|
81
|
+
.update(JSON.stringify([
|
|
82
|
+
fileRevision,
|
|
83
|
+
selected.id,
|
|
84
|
+
canonical,
|
|
85
|
+
metadata.dev,
|
|
86
|
+
metadata.ino,
|
|
87
|
+
marker ? [marker.dev, marker.ino, marker.isFile()] : null,
|
|
88
|
+
]))
|
|
89
|
+
.digest('hex');
|
|
90
|
+
return { workspace: { id: selected.id, name: selected.name, path: canonical }, revision };
|
|
91
|
+
}
|
|
92
|
+
async root() {
|
|
93
|
+
return (await this.workspaces.snapshot())[0] ?? null;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
function within(root, path) {
|
|
97
|
+
const child = relative(root, path);
|
|
98
|
+
return child === '' || (!isAbsolute(child) && child !== '..' && !child.startsWith(`..${sep}`));
|
|
99
|
+
}
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
5
5
|
*/
|
|
6
6
|
import { lstat, readFile, realpath, stat } from 'node:fs/promises';
|
|
7
|
+
import { createHash } from 'node:crypto';
|
|
7
8
|
import { isAbsolute, relative, resolve, sep } from 'node:path';
|
|
8
9
|
import { parseSupervisedPlan } from '../../features/plans/application/parse-supervised-plan.js';
|
|
9
10
|
import { OrgPlanDiscovery } from './org-plan-discovery.js';
|
|
@@ -118,6 +119,25 @@ export class FilesystemWorkspacePlanCatalog {
|
|
|
118
119
|
return { kind: 'missing' };
|
|
119
120
|
return this.readFromWorkspace(workspace, planName);
|
|
120
121
|
}
|
|
122
|
+
/** Reuses the exact viewer reader without trusting its cached preview or sourcePath. */
|
|
123
|
+
async readExecution(workspacePath, planName) {
|
|
124
|
+
if (!isPlanPath(planName))
|
|
125
|
+
return { kind: 'missing' };
|
|
126
|
+
const workspace = await this.workspace(workspacePath);
|
|
127
|
+
if (!workspace)
|
|
128
|
+
return { kind: 'missing' };
|
|
129
|
+
const candidate = await this.readCandidate(workspace, planName);
|
|
130
|
+
if (candidate.kind !== 'readable')
|
|
131
|
+
return candidate;
|
|
132
|
+
const parsed = parseSupervisedPlan({
|
|
133
|
+
source: candidate.source,
|
|
134
|
+
planPath: candidate.canonicalPath,
|
|
135
|
+
workspacePath: workspace,
|
|
136
|
+
});
|
|
137
|
+
return parsed.kind === 'available'
|
|
138
|
+
? { ...parsed, canonicalPath: candidate.canonicalPath, revision: candidate.revision }
|
|
139
|
+
: { kind: 'invalid', reason: parsed.reason };
|
|
140
|
+
}
|
|
121
141
|
async workspace(workspacePath) {
|
|
122
142
|
if (!isAbsolute(workspacePath))
|
|
123
143
|
return null;
|
|
@@ -140,11 +160,12 @@ export class FilesystemWorkspacePlanCatalog {
|
|
|
140
160
|
workspacePath: workspace,
|
|
141
161
|
});
|
|
142
162
|
return parsed.kind === 'available'
|
|
143
|
-
? parsed
|
|
163
|
+
? { ...parsed, sourcePath: candidate.canonicalPath }
|
|
144
164
|
: {
|
|
145
165
|
kind: 'source',
|
|
146
166
|
title: fallbackTitle(planName, candidate.source),
|
|
147
167
|
source: candidate.source,
|
|
168
|
+
sourcePath: candidate.canonicalPath,
|
|
148
169
|
};
|
|
149
170
|
}
|
|
150
171
|
async readCandidate(workspace, planName) {
|
|
@@ -167,9 +188,21 @@ export class FilesystemWorkspacePlanCatalog {
|
|
|
167
188
|
after.size !== before.size ||
|
|
168
189
|
after.ino !== before.ino ||
|
|
169
190
|
after.dev !== before.dev ||
|
|
170
|
-
after.mtimeMs !== before.mtimeMs
|
|
191
|
+
after.mtimeMs !== before.mtimeMs ||
|
|
192
|
+
after.ctimeMs !== before.ctimeMs)
|
|
171
193
|
return { kind: 'unavailable' };
|
|
172
|
-
|
|
194
|
+
const revision = createHash('sha256')
|
|
195
|
+
.update(JSON.stringify([
|
|
196
|
+
canonical,
|
|
197
|
+
after.dev,
|
|
198
|
+
after.ino,
|
|
199
|
+
after.size,
|
|
200
|
+
after.mtimeMs,
|
|
201
|
+
after.ctimeMs,
|
|
202
|
+
source,
|
|
203
|
+
]))
|
|
204
|
+
.digest('hex');
|
|
205
|
+
return { kind: 'readable', source, canonicalPath: canonical, revision };
|
|
173
206
|
}
|
|
174
207
|
catch (error) {
|
|
175
208
|
return error.code === 'ENOENT'
|
|
@@ -0,0 +1,46 @@
|
|
|
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
|
+
const identity = z.string().min(1).max(1024);
|
|
8
|
+
export const orgPlanLaunchRequestSchema = z
|
|
9
|
+
.object({
|
|
10
|
+
reference: z.discriminatedUnion('kind', [
|
|
11
|
+
z
|
|
12
|
+
.object({ kind: z.literal('workspace'), workspaceId: identity, planName: identity })
|
|
13
|
+
.strict(),
|
|
14
|
+
z.object({ kind: z.literal('session'), sessionId: identity, planName: identity }).strict(),
|
|
15
|
+
z.object({ kind: z.literal('retained-session'), sessionId: identity }).strict(),
|
|
16
|
+
]),
|
|
17
|
+
expectedRevision: identity,
|
|
18
|
+
skillProfile: z.string().max(256).optional(),
|
|
19
|
+
launchId: z.string().min(1).max(256),
|
|
20
|
+
})
|
|
21
|
+
.strict();
|
|
22
|
+
/** Only these feature outcomes are returned as typed non-success HTTP receipts. */
|
|
23
|
+
export const orgPlanLaunchConflictSchema = z.discriminatedUnion('kind', [
|
|
24
|
+
z
|
|
25
|
+
.object({
|
|
26
|
+
kind: z.literal('blocked'),
|
|
27
|
+
code: z.enum(['CONTEXT_CHANGED', 'ACTIVE_SUPERVISION']),
|
|
28
|
+
reason: z.string().min(1),
|
|
29
|
+
existingSessionId: identity.optional(),
|
|
30
|
+
})
|
|
31
|
+
.strict(),
|
|
32
|
+
z
|
|
33
|
+
.object({
|
|
34
|
+
kind: z.literal('rejected'),
|
|
35
|
+
code: z.literal('LAUNCH_CONFLICT'),
|
|
36
|
+
reason: z.string().min(1),
|
|
37
|
+
})
|
|
38
|
+
.strict(),
|
|
39
|
+
]);
|
|
40
|
+
export const orgPlanLaunchInvalidRequestSchema = z
|
|
41
|
+
.object({
|
|
42
|
+
kind: z.literal('rejected'),
|
|
43
|
+
code: z.literal('INVALID_LAUNCH_REQUEST'),
|
|
44
|
+
reason: z.string().min(1),
|
|
45
|
+
})
|
|
46
|
+
.strict();
|
|
@@ -5,16 +5,46 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { z } from 'zod';
|
|
7
7
|
import { thinkingLevels } from './session-model-settings.js';
|
|
8
|
+
/** Normal New session defaults, shared by the form and server preparation. */
|
|
9
|
+
export const newSessionFallback = {
|
|
10
|
+
model: 'gpt-6.1-sol',
|
|
11
|
+
reasoningEffort: 'medium',
|
|
12
|
+
executorModel: 'gpt-5.6-terra',
|
|
13
|
+
executorReasoningEffort: 'high',
|
|
14
|
+
sandbox: 'workspace-git',
|
|
15
|
+
approvalPolicy: 'never',
|
|
16
|
+
};
|
|
17
|
+
export function defaultProviderModel(provider, models) {
|
|
18
|
+
return provider === 'codex' && models.includes(newSessionFallback.model)
|
|
19
|
+
? newSessionFallback.model
|
|
20
|
+
: (models[0] ?? (provider === 'codex' ? newSessionFallback.model : ''));
|
|
21
|
+
}
|
|
8
22
|
export const sessionDefaultsSchema = z
|
|
9
23
|
.object({
|
|
10
24
|
workspaceId: z.string().max(4096),
|
|
11
25
|
skillProfile: z.string().max(256),
|
|
12
26
|
provider: z.enum(['codex', 'kimi']),
|
|
13
27
|
model: z.string().min(1).max(256),
|
|
14
|
-
reasoningEffort: z.enum(thinkingLevels).default(
|
|
15
|
-
executorModel: z.string().trim().min(1).max(256).default(
|
|
16
|
-
executorReasoningEffort: z
|
|
28
|
+
reasoningEffort: z.enum(thinkingLevels).default(newSessionFallback.reasoningEffort),
|
|
29
|
+
executorModel: z.string().trim().min(1).max(256).default(newSessionFallback.executorModel),
|
|
30
|
+
executorReasoningEffort: z
|
|
31
|
+
.enum(thinkingLevels)
|
|
32
|
+
.default(newSessionFallback.executorReasoningEffort),
|
|
17
33
|
sandbox: z.enum(['workspace-git', 'workspace-write', 'read-only', 'danger-full-access']),
|
|
18
34
|
approvalPolicy: z.enum(['untrusted', 'on-request', 'never']),
|
|
19
35
|
})
|
|
20
36
|
.strict();
|
|
37
|
+
/** Saved provider-specific models never cross providers. Explicit saved models are not substituted. */
|
|
38
|
+
export function resolveNewSessionDefaults(saved, provider, models) {
|
|
39
|
+
return {
|
|
40
|
+
workspaceId: saved?.workspaceId ?? '',
|
|
41
|
+
skillProfile: saved?.skillProfile ?? '',
|
|
42
|
+
provider,
|
|
43
|
+
model: saved?.provider === provider ? saved.model : defaultProviderModel(provider, models),
|
|
44
|
+
reasoningEffort: saved?.reasoningEffort ?? newSessionFallback.reasoningEffort,
|
|
45
|
+
executorModel: saved?.executorModel ?? newSessionFallback.executorModel,
|
|
46
|
+
executorReasoningEffort: saved?.executorReasoningEffort ?? newSessionFallback.executorReasoningEffort,
|
|
47
|
+
sandbox: saved?.sandbox ?? newSessionFallback.sandbox,
|
|
48
|
+
approvalPolicy: saved?.approvalPolicy ?? newSessionFallback.approvalPolicy,
|
|
49
|
+
};
|
|
50
|
+
}
|