Merge branch 'main' into feat/docker-self-upgrade

Resolve conflicts against the restart-coordinator rewrite and renumber
the manager-upgrade-jobs migration from 16 to 19 to avoid colliding
with main's 016-018 migrations. Includes review fixes: background the
docker pull, add a staleness guard for stuck recreating jobs, move
manager-upgrade types to @opencode-manager/shared, wire the
active-session pre-check dialog into the Upgrade Manager button, and
surface upgrade errors via FetchError-aware messaging.
This commit is contained in:
Chris Scott committed 2026-07-04 10:36:01 -04:00
commit 9effe53bdc
125 files changed
+3899 -975

No files matched your search

+1
View File
@@ -9,3 +9,4 @@ export * from './ssh'
export * from './schedule'
export * from './skills'
export * from './internal-assistant'
export * from './session-pins'
+60
View File
@@ -15,6 +15,62 @@ export const ScheduleSkillMetadataSchema = z.object({
})
export type ScheduleSkillMetadata = z.infer<typeof ScheduleSkillMetadataSchema>
/**
* Bash commands whose blast radius escapes the throwaway worktree: host-level
* commands that damage the machine regardless of cwd, plus force-pushes that can
* overwrite remote branches. File-mutating commands (`rm -rf`, `git reset --hard`,
* etc.) are intentionally omitted — they only affect the disposable worktree, which
* is never auto-pushed and is the real safety boundary.
*/
export const DEFAULT_DESTRUCTIVE_BASH_PATTERNS = [
'git push --force*', 'git push -f *',
'sudo *', 'dd *', 'mkfs*',
'shutdown*', 'reboot*', 'halt*',
'kill -9 *', 'killall *',
] as const
export const SchedulePermissionConfigSchema = z.object({
allowExternalDirectory: z.boolean().default(false),
bashDenyPatterns: z.array(z.string().min(1).max(200)).max(200)
.default([...DEFAULT_DESTRUCTIVE_BASH_PATTERNS]),
})
export type SchedulePermissionConfig = z.infer<typeof SchedulePermissionConfigSchema>
export type SchedulePermissionAction = 'allow' | 'deny' | 'ask'
export interface SchedulePermissionRuleset {
'*': SchedulePermissionAction
external_directory?: SchedulePermissionAction
bash?: Record<string, SchedulePermissionAction>
}
/**
* Builds an OpenCode permission config object for an unattended scheduled run.
*
* OpenCode's config/API permission format is keyed by tool, where each value is
* either a shorthand action or a glob-pattern -> action map (see
* https://opencode.ai/docs/permissions). A top-level `*` sets the baseline; the
* server merges tool entries after it and the last matching rule wins, so the
* `bash` deny patterns override the allow-all baseline for matching commands.
*/
export function buildSchedulePermissionRuleset(
config: SchedulePermissionConfig | null | undefined,
): SchedulePermissionRuleset {
const cfg = SchedulePermissionConfigSchema.parse(config ?? {})
const ruleset: SchedulePermissionRuleset = { '*': 'allow' }
if (!cfg.allowExternalDirectory) {
ruleset.external_directory = 'deny'
}
if (cfg.bashDenyPatterns.length > 0) {
const bash: Record<string, SchedulePermissionAction> = {}
for (const pattern of cfg.bashDenyPatterns) {
bash[pattern] = 'deny'
}
ruleset.bash = bash
}
return ruleset
}
export const ScheduleJobSchema = z.object({
id: z.number(),
repoId: z.number(),
@@ -29,6 +85,7 @@ export const ScheduleJobSchema = z.object({
prompt: z.string(),
model: z.string().nullable(),
skillMetadata: ScheduleSkillMetadataSchema.nullable(),
permissionConfig: SchedulePermissionConfigSchema.nullable(),
branch: z.string().nullable(),
createdAt: z.number(),
updatedAt: z.number(),
@@ -54,6 +111,7 @@ export const ScheduleRunSchema = z.object({
runBranch: z.string().nullable(),
commitHash: z.string().nullable(),
worktreePath: z.string().nullable(),
workspaceId: z.string().nullable(),
})
export type ScheduleRun = z.infer<typeof ScheduleRunSchema>
@@ -65,6 +123,7 @@ const ScheduleJobBaseRequestSchema = z.object({
prompt: z.string().min(1).max(20000),
model: z.string().min(1).max(200).optional(),
skillMetadata: ScheduleSkillMetadataSchema.nullable().optional(),
permissionConfig: SchedulePermissionConfigSchema.nullable().optional(),
branch: z.string().min(1).max(200).nullable().optional(),
})
@@ -93,6 +152,7 @@ export const UpdateScheduleJobRequestSchema = z.object({
prompt: z.string().min(1).max(20000).optional(),
model: z.string().min(1).max(200).nullable().optional(),
skillMetadata: ScheduleSkillMetadataSchema.nullable().optional(),
permissionConfig: SchedulePermissionConfigSchema.nullable().optional(),
branch: z.string().min(1).max(200).nullable().optional(),
})
export type UpdateScheduleJobRequest = z.infer<typeof UpdateScheduleJobRequestSchema>
+16
View File
@@ -0,0 +1,16 @@
import { z } from "zod";
export const SessionPinSchema = z.object({
sessionId: z.string(),
directory: z.string(),
pinnedAt: z.number(),
});
export const ToggleSessionPinRequestSchema = z.object({
sessionId: z.string().min(1),
directory: z.string().min(1),
pinned: z.boolean(),
});
export type SessionPin = z.infer<typeof SessionPinSchema>;
export type ToggleSessionPinRequest = z.infer<typeof ToggleSessionPinRequestSchema>;
+7
View File
@@ -100,6 +100,12 @@ export interface SuccessResponse {
success: boolean
}
export type {
ManagerUpgradeJobStatus,
ManagerUpgradeJob,
ManagerUpgradeStatusResponse,
} from './manager-upgrade'
export type { SSHHostKeyRequest, SSHHostKeyResponse, TrustedSSHHost } from '../schemas/ssh'
export type { GitCredential } from '../schemas/settings'
export type {
@@ -111,6 +117,7 @@ export type {
export type {
ScheduleMode,
SchedulePermissionConfig,
ScheduleRunTriggerSource,
ScheduleRunStatus,
ScheduleSkillMetadata,
+21
View File
@@ -0,0 +1,21 @@
export type ManagerUpgradeJobStatus = 'pending' | 'pulling' | 'recreating' | 'completed' | 'failed'
export interface ManagerUpgradeJob {
id: number
status: ManagerUpgradeJobStatus
fromVersion: string | null
toVersion: string | null
targetImage: string | null
error: string | null
startedAt: number
finishedAt: number | null
}
export interface ManagerUpgradeStatusResponse {
supported: boolean
inDocker: boolean
socketAvailable: boolean
enabled: boolean
currentVersion: string | null
job: ManagerUpgradeJob | null
}