feat: agent and CLI control plane for sessions, worktrees, and scheduled tasks (#2408)
Add a shared OpenChamber control service with two thin adapters — a native `openchamber` tool injected into managed OpenCode, and new CLI commands — so users can manage parallel sessions, worktrees, and scheduled tasks conversationally through agents or from the terminal. Control plane: - New openchamber-control service owning a fixed action contract: projects.list, models.list, session list/create/send/fork/status/messages, and schedule list/create/run/delete/toggle. Session and worktree deletion and project registration are deliberately not exposed. - New openchamber-sessions module owning create/worktree/prompt orchestration, Goal Mode dispatch, wait semantics (initial idle never counts as completion; timeout and cancellation are failures), and explicit partial-failure results. - Scheduled-task logic extracted into a service shared by routes, CLI, and the agent tool. Agent tool: - Managed OpenCode gets a materialized plugin registering one typed tool with a loopback-only callback, per-child ephemeral bearer (timing-safe, never persisted or logged), and abort propagation into the service. - The ~1.5k-token schema applies progressive disclosure: short descriptions, server-side validation returning actionable usage errors, and intent guardrails — created sessions/tasks are user-facing work (not age self-delegation); worktree/goal/agent/variant/wait are omit-by-default; dispatches produce no completion notification, and later result r to session.messages, which now returns the authoritative sessionStatus. - session.create without a user-named model picks from favorites/re send/fork omit the selection and the service reuses the target session's last user-message model, agent, and variant before falling back t - An "Agent control tool" setting (default on, Save + Reload to apply) disables plugin injection entirely. CLI: - New `openchamber session`, `schedule`, `projects`, and `models` commands with automatic instance targeting, --wait/--timeout/--last-assist worktree flags, and Goal Mode, preserving interactive, non-TTY, --quiet, and --json contracts. The control HTTP timeout derives from the w instead of the 4-second default. UI: - New built-in "Schedule a Task" starter (/schedule-task) running a dialogue that defines a task and offers to create it via the tool after explicit confirmation; Craft a Goal and Feature Planning gain the handoff offer, and guided starters reserve the question tool for concrete option choices. Localized in all 10 locales, migrated into custom starter lists, hidden on VS Code. - Sidebar shows CLI/agent-created sessions live via the control eve - openchamber tool calls render with per-action titles and metadata.
This commit is contained in:
committed by
GitHub
parent
484fe8bc18
commit
e908db637b
@@ -63,10 +63,12 @@ function parseArgs(argv = process.argv.slice(2)) {
|
||||
all: false,
|
||||
follow: true,
|
||||
lines: DEFAULT_TAIL_LINES,
|
||||
limit: undefined,
|
||||
provider: undefined,
|
||||
mode: undefined,
|
||||
profile: undefined,
|
||||
name: undefined,
|
||||
title: undefined,
|
||||
configPath: undefined,
|
||||
token: undefined,
|
||||
tokenFile: undefined,
|
||||
@@ -88,6 +90,30 @@ function parseArgs(argv = process.argv.slice(2)) {
|
||||
foreground: false,
|
||||
lan: false,
|
||||
apiOnly: false,
|
||||
project: undefined,
|
||||
task: undefined,
|
||||
session: undefined,
|
||||
message: undefined,
|
||||
prompt: undefined,
|
||||
model: undefined,
|
||||
daily: undefined,
|
||||
weekly: undefined,
|
||||
once: undefined,
|
||||
time: undefined,
|
||||
cron: undefined,
|
||||
timezone: undefined,
|
||||
agent: undefined,
|
||||
variant: undefined,
|
||||
disabled: false,
|
||||
goal: false,
|
||||
goalTokenBudget: undefined,
|
||||
directory: undefined,
|
||||
role: undefined,
|
||||
last: false,
|
||||
wait: false,
|
||||
timeout: undefined,
|
||||
lastAssistant: false,
|
||||
withStatus: false,
|
||||
};
|
||||
|
||||
const removedFlagErrors = [];
|
||||
@@ -194,6 +220,140 @@ function parseArgs(argv = process.argv.slice(2)) {
|
||||
options.name = typeof value === 'string' ? value : options.name;
|
||||
break;
|
||||
}
|
||||
case 'title': {
|
||||
const { value, nextIndex } = consumeValue(i, inlineValue);
|
||||
i = nextIndex;
|
||||
options.title = typeof value === 'string' ? value : options.title;
|
||||
break;
|
||||
}
|
||||
case 'worktree': {
|
||||
const { value, nextIndex } = consumeValue(i, inlineValue);
|
||||
i = nextIndex;
|
||||
options.worktree = typeof value === 'string' ? value : options.worktree;
|
||||
break;
|
||||
}
|
||||
case 'branch': {
|
||||
const { value, nextIndex } = consumeValue(i, inlineValue);
|
||||
i = nextIndex;
|
||||
options.branch = typeof value === 'string' ? value : options.branch;
|
||||
break;
|
||||
}
|
||||
case 'start-ref':
|
||||
case 'base': {
|
||||
const { value, nextIndex } = consumeValue(i, inlineValue);
|
||||
i = nextIndex;
|
||||
options.startRef = typeof value === 'string' ? value : options.startRef;
|
||||
break;
|
||||
}
|
||||
case 'upstream':
|
||||
options.setUpstream = true;
|
||||
break;
|
||||
case 'no-upstream':
|
||||
options.setUpstream = false;
|
||||
break;
|
||||
case 'project': {
|
||||
const { value, nextIndex } = consumeValue(i, inlineValue);
|
||||
i = nextIndex;
|
||||
options.project = typeof value === 'string' ? value : options.project;
|
||||
break;
|
||||
}
|
||||
case 'dir':
|
||||
case 'directory': {
|
||||
const { value, nextIndex } = consumeValue(i, inlineValue);
|
||||
i = nextIndex;
|
||||
options.directory = typeof value === 'string' ? value : options.directory;
|
||||
break;
|
||||
}
|
||||
case 'task': {
|
||||
const { value, nextIndex } = consumeValue(i, inlineValue);
|
||||
i = nextIndex;
|
||||
options.task = typeof value === 'string' ? value : options.task;
|
||||
break;
|
||||
}
|
||||
case 'session': {
|
||||
const { value, nextIndex } = consumeValue(i, inlineValue);
|
||||
i = nextIndex;
|
||||
options.session = typeof value === 'string' ? value : options.session;
|
||||
break;
|
||||
}
|
||||
case 'message': {
|
||||
const { value, nextIndex } = consumeValue(i, inlineValue);
|
||||
i = nextIndex;
|
||||
options.message = typeof value === 'string' ? value : options.message;
|
||||
break;
|
||||
}
|
||||
case 'prompt': {
|
||||
const { value, nextIndex } = consumeValue(i, inlineValue);
|
||||
i = nextIndex;
|
||||
options.prompt = typeof value === 'string' ? value : options.prompt;
|
||||
break;
|
||||
}
|
||||
case 'model': {
|
||||
const { value, nextIndex } = consumeValue(i, inlineValue);
|
||||
i = nextIndex;
|
||||
options.model = typeof value === 'string' ? value : options.model;
|
||||
break;
|
||||
}
|
||||
case 'daily': {
|
||||
const { value, nextIndex } = consumeValue(i, inlineValue);
|
||||
i = nextIndex;
|
||||
options.daily = typeof value === 'string' ? value : options.daily;
|
||||
break;
|
||||
}
|
||||
case 'weekly': {
|
||||
const { value, nextIndex } = consumeValue(i, inlineValue);
|
||||
i = nextIndex;
|
||||
options.weekly = typeof value === 'string' ? value : options.weekly;
|
||||
break;
|
||||
}
|
||||
case 'once': {
|
||||
const { value, nextIndex } = consumeValue(i, inlineValue);
|
||||
i = nextIndex;
|
||||
options.once = typeof value === 'string' ? value : options.once;
|
||||
break;
|
||||
}
|
||||
case 'time': {
|
||||
const { value, nextIndex } = consumeValue(i, inlineValue);
|
||||
i = nextIndex;
|
||||
options.time = typeof value === 'string' ? value : options.time;
|
||||
break;
|
||||
}
|
||||
case 'cron': {
|
||||
const { value, nextIndex } = consumeValue(i, inlineValue);
|
||||
i = nextIndex;
|
||||
options.cron = typeof value === 'string' ? value : options.cron;
|
||||
break;
|
||||
}
|
||||
case 'timezone': {
|
||||
const { value, nextIndex } = consumeValue(i, inlineValue);
|
||||
i = nextIndex;
|
||||
options.timezone = typeof value === 'string' ? value : options.timezone;
|
||||
break;
|
||||
}
|
||||
case 'agent': {
|
||||
const { value, nextIndex } = consumeValue(i, inlineValue);
|
||||
i = nextIndex;
|
||||
options.agent = typeof value === 'string' ? value : options.agent;
|
||||
break;
|
||||
}
|
||||
case 'variant': {
|
||||
const { value, nextIndex } = consumeValue(i, inlineValue);
|
||||
i = nextIndex;
|
||||
options.variant = typeof value === 'string' ? value : options.variant;
|
||||
break;
|
||||
}
|
||||
case 'disabled':
|
||||
options.disabled = true;
|
||||
break;
|
||||
case 'goal':
|
||||
options.goal = true;
|
||||
break;
|
||||
case 'goal-token-budget': {
|
||||
const { value, nextIndex } = consumeValue(i, inlineValue);
|
||||
i = nextIndex;
|
||||
options.goalTokenBudget = value;
|
||||
break;
|
||||
}
|
||||
case 'config': {
|
||||
const { value, nextIndex } = consumeValue(i, inlineValue);
|
||||
i = nextIndex;
|
||||
@@ -249,6 +409,30 @@ function parseArgs(argv = process.argv.slice(2)) {
|
||||
case 'all':
|
||||
options.all = true;
|
||||
break;
|
||||
case 'last':
|
||||
options.last = true;
|
||||
break;
|
||||
case 'last-assistant':
|
||||
options.lastAssistant = true;
|
||||
break;
|
||||
case 'wait':
|
||||
options.wait = true;
|
||||
break;
|
||||
case 'timeout': {
|
||||
const { value, nextIndex } = consumeValue(i, inlineValue);
|
||||
i = nextIndex;
|
||||
options.timeout = typeof value === 'string' ? value : options.timeout;
|
||||
break;
|
||||
}
|
||||
case 'with-status':
|
||||
options.withStatus = true;
|
||||
break;
|
||||
case 'role': {
|
||||
const { value, nextIndex } = consumeValue(i, inlineValue);
|
||||
i = nextIndex;
|
||||
options.role = typeof value === 'string' ? value : options.role;
|
||||
break;
|
||||
}
|
||||
case 'no-follow':
|
||||
options.follow = false;
|
||||
break;
|
||||
@@ -264,6 +448,16 @@ function parseArgs(argv = process.argv.slice(2)) {
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 'limit': {
|
||||
const { value, nextIndex } = consumeValue(i, inlineValue);
|
||||
i = nextIndex;
|
||||
const parsed = parseInt(value ?? '', 10);
|
||||
if (!Number.isFinite(parsed) || parsed < 1) {
|
||||
throw new TunnelCliError('Invalid limit value. Provide a positive integer.', EXIT_CODE.USAGE_ERROR);
|
||||
}
|
||||
options.limit = parsed;
|
||||
break;
|
||||
}
|
||||
case 'relay':
|
||||
options.relay = true;
|
||||
break;
|
||||
@@ -342,6 +536,9 @@ function parseArgs(argv = process.argv.slice(2)) {
|
||||
const subcommand = command === 'tunnel' ? (positional[1] || 'help') : null;
|
||||
const tunnelAction = command === 'tunnel' ? (positional[2] || null) : null;
|
||||
const startupAction = command === 'startup' ? (positional[1] || 'status') : null;
|
||||
const scheduleAction = command === 'schedule' ? (positional[1] || 'help') : null;
|
||||
const sessionAction = command === 'session' ? (positional[1] || 'help') : null;
|
||||
const controlAction = command === 'control' ? (positional[1] || 'help') : null;
|
||||
|
||||
if (options.lan && typeof options.host !== 'string') {
|
||||
options.host = '0.0.0.0';
|
||||
@@ -356,6 +553,9 @@ function parseArgs(argv = process.argv.slice(2)) {
|
||||
subcommand,
|
||||
tunnelAction,
|
||||
startupAction,
|
||||
scheduleAction,
|
||||
sessionAction,
|
||||
controlAction,
|
||||
options,
|
||||
removedFlagErrors,
|
||||
helpRequested,
|
||||
@@ -375,6 +575,11 @@ COMMANDS:
|
||||
stop Stop running instance(s)
|
||||
restart Stop and start the server
|
||||
status Show server status
|
||||
schedule Manage scheduled tasks
|
||||
session Create, inspect, and read OpenChamber sessions
|
||||
models Show default and favorite models
|
||||
projects Show configured projects and IDs
|
||||
control Show OpenChamber control-plane commands
|
||||
tunnel Tunnel lifecycle commands
|
||||
startup Manage launch at system startup
|
||||
logs Tail OpenChamber logs
|
||||
@@ -412,12 +617,52 @@ EXAMPLES:
|
||||
openchamber serve --foreground # Start in foreground (for systemd Type=simple)
|
||||
openchamber connect-url --port 3000 --qr
|
||||
openchamber connect-url --server https://openchamber.example.com
|
||||
openchamber control # Show control-plane commands for agents/scripts
|
||||
openchamber startup enable # Start OpenChamber at user login
|
||||
openchamber tunnel help # Show tunnel lifecycle help
|
||||
openchamber logs # Follow logs for latest running instance
|
||||
`);
|
||||
}
|
||||
|
||||
function showControlHelp() {
|
||||
console.log(`
|
||||
OpenChamber Control Commands
|
||||
|
||||
USAGE:
|
||||
openchamber <COMMAND> [OPTIONS]
|
||||
|
||||
COMMANDS:
|
||||
status Show running OpenChamber runtimes
|
||||
session Create, inspect, and read sessions
|
||||
models Show default and favorite models
|
||||
projects Show configured projects and IDs
|
||||
schedule Manage scheduled tasks
|
||||
tunnel Inspect tunnel status/readiness
|
||||
logs Tail logs for CLI-managed runtimes
|
||||
|
||||
DETAILED HELP:
|
||||
openchamber session --help Show session creation, status, and message options
|
||||
openchamber models --help Show model defaults and favorites help
|
||||
openchamber projects --help Show project list help
|
||||
openchamber schedule --help Show scheduled task actions and schedule options
|
||||
openchamber tunnel help Show tunnel lifecycle/status commands
|
||||
openchamber status --help Show runtime status options
|
||||
|
||||
COMMON OPTIONS:
|
||||
--json Output machine-readable JSON
|
||||
-q, --quiet Print minimal output
|
||||
-p, --port <port> Target a specific OpenChamber runtime
|
||||
--ui-password <password> Authenticate to a password-protected runtime
|
||||
|
||||
EXAMPLES:
|
||||
openchamber status
|
||||
openchamber models
|
||||
openchamber projects
|
||||
openchamber session --help
|
||||
openchamber schedule --help
|
||||
`);
|
||||
}
|
||||
|
||||
function showStartupHelp() {
|
||||
console.log(`
|
||||
OpenChamber Startup Commands
|
||||
@@ -579,7 +824,7 @@ _openchamber_tunnel() {
|
||||
cur="\${COMP_WORDS[COMP_CWORD]}"
|
||||
prev="\${COMP_WORDS[COMP_CWORD-1]}"
|
||||
|
||||
commands="serve stop restart status tunnel logs update"
|
||||
commands="serve stop restart status schedule session models projects tunnel logs update"
|
||||
tunnel_commands="help providers ready doctor status start stop profile completion"
|
||||
profile_commands="list show add remove"
|
||||
common_flags="--port --foreground --no-daemon --json --all --help --version --plain --quiet"
|
||||
@@ -631,6 +876,10 @@ _openchamber() {
|
||||
'stop:Stop running instance(s)'
|
||||
'restart:Stop and start the server'
|
||||
'status:Show server status'
|
||||
'schedule:Manage scheduled tasks'
|
||||
'session:Create sessions'
|
||||
'models:Show default and favorite models'
|
||||
'projects:Show configured projects and IDs'
|
||||
'tunnel:Tunnel lifecycle commands'
|
||||
'logs:Tail OpenChamber logs'
|
||||
'update:Check for and install updates'
|
||||
@@ -728,6 +977,7 @@ export {
|
||||
DEFAULT_PORT,
|
||||
parseArgs,
|
||||
showHelp,
|
||||
showControlHelp,
|
||||
showStartupHelp,
|
||||
showConnectUrlHelp,
|
||||
showTunnelHelp,
|
||||
|
||||
Reference in New Issue
Block a user