@wjarka/cezarion 0.17.0-dev.5585 → 0.17.0-dev.5593
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/delegation/transport.d.ts +62 -62
- package/dist/server/activity-routes.d.ts +23 -23
- package/dist/server/open-in-targets.d.ts +7 -0
- package/dist/server/open-in-targets.js +18 -15
- package/dist/server/open-in-targets.js.map +1 -1
- package/dist/server/run-checkout.d.ts +1 -4
- package/dist/server/run-checkout.js +4 -4
- package/dist/server/run-checkout.js.map +1 -1
- package/dist/server/server.d.ts +1560 -1560
- package/dist/server/server.js +20 -19
- package/dist/server/server.js.map +1 -1
- package/package.json +3 -3
package/dist/server/server.js
CHANGED
|
@@ -158,7 +158,7 @@ import { GithubPrNotFoundError, GH_CHECKS_MAX, GH_REF_STATUS_MAX } from './forge
|
|
|
158
158
|
import { projectAdmissionRefusal, withProjectAdmission } from './cockpit-ownership.js';
|
|
159
159
|
import { closingSignal, prepareBeforeTicks, prepareProject, prepareProjects } from '../project-migration/auto.js';
|
|
160
160
|
import { RunStoreOpenError } from '../runs/store-open-error.js';
|
|
161
|
-
import { openRunApp, openRunCli, openRunDefaultApp } from './open-in-targets.js';
|
|
161
|
+
import { freshCliHandoff, openRunApp, openRunCli, openRunDefaultApp } from './open-in-targets.js';
|
|
162
162
|
import { agentCliRunner, detectOpenTargets } from './open-in-app.js';
|
|
163
163
|
import { ProviderRuntimeAuthObserver } from './provider-auth-runtime.js';
|
|
164
164
|
import { providerForExistingRun, providersRequiredByWorkflow, } from './provider-action-gate.js';
|
|
@@ -965,6 +965,16 @@ export function createApp(deps) {
|
|
|
965
965
|
return { error: `unknown ${provider} account: ${profileId}` };
|
|
966
966
|
return { profile: resolveStoredProfile(stored) };
|
|
967
967
|
};
|
|
968
|
+
const openHandoffCheckout = (c, suffix = '') => {
|
|
969
|
+
const checkout = runCheckout(c.get('project'), c.req.param('id'), 'open');
|
|
970
|
+
if ('status' in checkout)
|
|
971
|
+
return checkout;
|
|
972
|
+
// Hosted mode: there is no "my machine" to open a terminal on. The UI
|
|
973
|
+
// hides the button when localHandoff is false — this is defense in depth.
|
|
974
|
+
return !capabilities().localHandoff
|
|
975
|
+
? { status: 409, body: { error: `local handoff is disabled — this cockpit runs in hosted mode (CEZ_REMOTE)${suffix}` } }
|
|
976
|
+
: checkout;
|
|
977
|
+
};
|
|
968
978
|
/**
|
|
969
979
|
* The environment a terminal handoff must carry so the CLI lands on the right account.
|
|
970
980
|
*
|
|
@@ -3188,16 +3198,9 @@ export function createApp(deps) {
|
|
|
3188
3198
|
// in the task's worktree when it still exists (spec 006).
|
|
3189
3199
|
.post('/runs/:id/open-in-cli', async (c) => {
|
|
3190
3200
|
const project = c.get('project');
|
|
3191
|
-
const checkout =
|
|
3201
|
+
const checkout = openHandoffCheckout(c, '; resume the session from a machine that has the checkout');
|
|
3192
3202
|
if ('status' in checkout)
|
|
3193
3203
|
return c.json(checkout.body, checkout.status);
|
|
3194
|
-
// Hosted mode: there is no "my machine" to open a terminal on. The UI
|
|
3195
|
-
// hides the button when localHandoff is false — this is defense in depth.
|
|
3196
|
-
if (!capabilities().localHandoff) {
|
|
3197
|
-
return c.json({
|
|
3198
|
-
error: 'local handoff is disabled — this cockpit runs in hosted mode (CEZ_REMOTE); resume the session from a machine that has the checkout',
|
|
3199
|
-
}, 409);
|
|
3200
|
-
}
|
|
3201
3204
|
const sessionStep = [...checkout.run.steps].reverse().find((s) => s.sessionId);
|
|
3202
3205
|
const sessionId = sessionStep?.sessionId;
|
|
3203
3206
|
if (!sessionId)
|
|
@@ -3210,13 +3213,16 @@ export function createApp(deps) {
|
|
|
3210
3213
|
const refusal = fallbackProjectWriteError(cwd);
|
|
3211
3214
|
if (refusal)
|
|
3212
3215
|
return c.json({ error: refusal }, 409);
|
|
3213
|
-
const
|
|
3214
|
-
// Fails closed on an id we do not recognise — see resumeCommand (#431).
|
|
3215
|
-
if (
|
|
3216
|
+
const resume = checkout.resumeAllowed ? resumeCommand(backend, sessionId) : undefined;
|
|
3217
|
+
// Fails closed on an id we do not recognise — see resumeCommand (open-mercato/cezar#431).
|
|
3218
|
+
if (resume === null)
|
|
3216
3219
|
return c.json({ error: 'the recorded session id has an unexpected shape' }, 409);
|
|
3217
|
-
const account =
|
|
3220
|
+
const account = resume
|
|
3221
|
+
? { command: resume, ...await handoffEnv(backend, sessionStep?.profileId) }
|
|
3222
|
+
: await freshCliHandoff(backend, project.root, deps.home);
|
|
3218
3223
|
if ('error' in account)
|
|
3219
3224
|
return c.json({ error: account.error }, 409);
|
|
3225
|
+
const { command } = account;
|
|
3220
3226
|
const fallback = handoffFallbackCommand(cwd, command, account.env);
|
|
3221
3227
|
// Fail closed for the same reason as the session id: a terminal opened without the
|
|
3222
3228
|
// account's config dir resumes nothing and says nothing about why.
|
|
@@ -3232,14 +3238,9 @@ export function createApp(deps) {
|
|
|
3232
3238
|
// Open a run's worktree (or the repo root) in the chosen local app.
|
|
3233
3239
|
.post('/runs/:id/open-in', jsonZodValidator(openInSchema), async (c) => {
|
|
3234
3240
|
const project = c.get('project');
|
|
3235
|
-
const checkout =
|
|
3241
|
+
const checkout = openHandoffCheckout(c);
|
|
3236
3242
|
if ('status' in checkout)
|
|
3237
3243
|
return c.json(checkout.body, checkout.status);
|
|
3238
|
-
if (!capabilities().localHandoff) {
|
|
3239
|
-
return c.json({
|
|
3240
|
-
error: 'local handoff is disabled — this cockpit runs in hosted mode (CEZ_REMOTE)',
|
|
3241
|
-
}, 409);
|
|
3242
|
-
}
|
|
3243
3244
|
// Follows the safeParse convention (#429); the downstream allowlist match is the real
|
|
3244
3245
|
// injection guard, this just validates the shape.
|
|
3245
3246
|
const { target, path: relPath } = c.req.valid('json');
|