@wjarka/cezarion 0.17.0-dev.5581 → 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/routes.d.ts +11 -11
- package/dist/delegation/transport.d.ts +73 -73
- package/dist/git-command.d.ts +7 -0
- package/dist/git-command.js +8 -0
- package/dist/git-command.js.map +1 -0
- package/dist/git-private-index.d.ts +11 -0
- package/dist/git-private-index.js +51 -0
- package/dist/git-private-index.js.map +1 -0
- package/dist/git-worktree.d.ts +3 -12
- package/dist/git-worktree.js +8 -56
- package/dist/git-worktree.js.map +1 -1
- package/dist/server/activity-routes.d.ts +23 -23
- package/dist/server/git-changes.d.ts +2 -0
- package/dist/server/git-changes.js +5 -2
- package/dist/server/git-changes.js.map +1 -1
- 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 +5 -5
- package/dist/server/run-checkout.js +16 -8
- package/dist/server/run-checkout.js.map +1 -1
- package/dist/server/server.d.ts +1589 -1589
- package/dist/server/server.js +32 -29
- package/dist/server/server.js.map +1 -1
- package/dist/server/workspace-live-routes.d.ts +6 -6
- 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');
|
|
@@ -3300,21 +3301,23 @@ export function createApp(deps) {
|
|
|
3300
3301
|
})
|
|
3301
3302
|
// Task diff (spec 006): what this run changed — its worktree vs its base.
|
|
3302
3303
|
.get('/runs/:id/diff', async (c) => {
|
|
3303
|
-
const checkout = runCheckout(c.get('project'), c.req.param('id'), 'read', {
|
|
3304
|
+
const checkout = runCheckout(c.get('project'), c.req.param('id'), 'read', { directory: 'existing-worktree' });
|
|
3304
3305
|
if ('body' in checkout)
|
|
3305
3306
|
return c.json(checkout.body, checkout.status);
|
|
3306
|
-
|
|
3307
|
-
if (!workingDirectory) {
|
|
3307
|
+
if (!checkout.directory)
|
|
3308
3308
|
return c.text('(no worktree — this task ran directly in the repo working tree)');
|
|
3309
|
-
|
|
3310
|
-
|
|
3309
|
+
const result = await worktreeDiff(checkout.directory, checkout.run.baseBranch ?? 'HEAD', undefined, checkout.beforeLiveIndex);
|
|
3310
|
+
if (typeof result !== 'string')
|
|
3311
|
+
return c.json({ error: result.error }, 409);
|
|
3312
|
+
return c.text(result);
|
|
3311
3313
|
})
|
|
3312
3314
|
.get('/runs/:id/changes', async (c) => {
|
|
3313
|
-
const checkout = runCheckout(c.get('project'), c.req.param('id'), 'read', {
|
|
3315
|
+
const checkout = runCheckout(c.get('project'), c.req.param('id'), 'read', { directory: 'working-directory' });
|
|
3314
3316
|
if ('body' in checkout)
|
|
3315
3317
|
return c.json(checkout.body, checkout.status);
|
|
3316
3318
|
const { run, directory: workingDirectory } = checkout;
|
|
3317
3319
|
const result = await collectChanges(workingDirectory, run.baseBranch ?? 'HEAD', {
|
|
3320
|
+
beforeLiveIndex: checkout.beforeLiveIndex,
|
|
3318
3321
|
taskBranch: run.branch,
|
|
3319
3322
|
// Anchors a repointed worktree at the branch as this run found it (#751).
|
|
3320
3323
|
runStartedAt: run.startedAt,
|
|
@@ -3327,7 +3330,7 @@ export function createApp(deps) {
|
|
|
3327
3330
|
})
|
|
3328
3331
|
// The run's own commits (<base>..HEAD on the worktree branch) — the Commits tab.
|
|
3329
3332
|
.get('/runs/:id/commits', async (c) => {
|
|
3330
|
-
const checkout = runCheckout(c.get('project'), c.req.param('id'), 'read', {
|
|
3333
|
+
const checkout = runCheckout(c.get('project'), c.req.param('id'), 'read', { directory: 'working-directory' });
|
|
3331
3334
|
if ('body' in checkout)
|
|
3332
3335
|
return c.json(checkout.body, checkout.status);
|
|
3333
3336
|
const { run, directory: workingDirectory } = checkout;
|
|
@@ -3338,7 +3341,7 @@ export function createApp(deps) {
|
|
|
3338
3341
|
})
|
|
3339
3342
|
// One of the run's commits, structured like the Changes tab (reuses collectCommitChanges).
|
|
3340
3343
|
.get('/runs/:id/commit/:sha', async (c) => {
|
|
3341
|
-
const checkout = runCheckout(c.get('project'), c.req.param('id'), 'read', {
|
|
3344
|
+
const checkout = runCheckout(c.get('project'), c.req.param('id'), 'read', { directory: 'working-directory' });
|
|
3342
3345
|
if ('body' in checkout)
|
|
3343
3346
|
return c.json(checkout.body, checkout.status);
|
|
3344
3347
|
const { directory: workingDirectory } = checkout;
|
|
@@ -3349,7 +3352,7 @@ export function createApp(deps) {
|
|
|
3349
3352
|
})
|
|
3350
3353
|
.get('/runs/:id/file-link', paramZodValidator(artifactParamsSchema.omit({ artifactId: true })), queryZodValidator(fileLinkQuerySchema), async (c) => {
|
|
3351
3354
|
const { root, store } = c.get('project');
|
|
3352
|
-
const checkout = runCheckout(c.get('project'), c.req.valid('param').id, 'read', {
|
|
3355
|
+
const checkout = runCheckout(c.get('project'), c.req.valid('param').id, 'read', { directory: 'recorded-path-or-root' });
|
|
3353
3356
|
if ('body' in checkout)
|
|
3354
3357
|
return c.json(checkout.body, checkout.status);
|
|
3355
3358
|
const { run, directory: workingDirectory } = checkout;
|
|
@@ -3438,7 +3441,7 @@ export function createApp(deps) {
|
|
|
3438
3441
|
const wantsRaw = query.raw !== undefined
|
|
3439
3442
|
? query.raw === '1'
|
|
3440
3443
|
: negotiate(c.req.header('accept'), FILE_FORMATS) === 'image/*';
|
|
3441
|
-
const checkout = runCheckout(c.get('project'), c.req.param('id'), 'read', {
|
|
3444
|
+
const checkout = runCheckout(c.get('project'), c.req.param('id'), 'read', { directory: 'working-directory' });
|
|
3442
3445
|
if ('body' in checkout)
|
|
3443
3446
|
return c.json(checkout.body, checkout.status);
|
|
3444
3447
|
const { directory: workingDirectory } = checkout;
|