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
@@ -39,6 +39,8 @@ export type MagicPromptId =
|
||||
| 'session.plan.instructions'
|
||||
| 'session.craftGoal.visible'
|
||||
| 'session.craftGoal.instructions'
|
||||
| 'session.scheduleTask.visible'
|
||||
| 'session.scheduleTask.instructions'
|
||||
| 'session.catchup.visible'
|
||||
| 'session.catchup.instructions'
|
||||
| 'session.debug.visible'
|
||||
@@ -709,7 +711,7 @@ Please review the latest state again and report any remaining issues.
|
||||
|
||||
Run this as a dialogue, not a one-shot answer.
|
||||
|
||||
Whenever you ask the user a question, use the \`question\` tool. Do not ask questions in plain assistant text.
|
||||
Use the \`question\` tool only for clarifying decisions that have a small set of concrete answer options you already know from the conversation or your investigation — choices like option A/B/C, scope boundaries, or edge-case behavior. Ask open-ended questions, including what the user wants in the first place, in plain assistant text. Never invent speculative options just to fit the question tool.
|
||||
|
||||
1. Understand before asking. Once the user describes the idea, first investigate the codebase yourself — read the relevant files, existing patterns, data flow, and constraints. Ground every question in what the code actually shows, not in assumptions.
|
||||
|
||||
@@ -723,6 +725,8 @@ Whenever you ask the user a question, use the \`question\` tool. Do not ask ques
|
||||
|
||||
6. When everything is settled, produce the final implementation plan: a clear, ordered breakdown of the work, the files and areas affected, the decisions that were made (and why), known risks, and any remaining assumptions flagged explicitly. The plan must reflect the user's actual answers — never fill gaps with guesses.
|
||||
|
||||
7. After presenting the plan, if the \`openchamber\` tool is available, offer to start a separate session yourself to implement it; do so only after the user explicitly confirms, and include the full plan in that session's prompt because the new session cannot see this conversation.
|
||||
|
||||
Respond in the same language the user uses.`,
|
||||
},
|
||||
{
|
||||
@@ -746,9 +750,9 @@ A Goal is a persistent completion contract, not an implementation plan and not a
|
||||
|
||||
Run this as a guided dialogue, not a one-shot answer.
|
||||
|
||||
Whenever you ask the user a question, use the \`question\` tool. Do not ask questions in plain assistant text.
|
||||
Use the \`question\` tool only for clarifying decisions that have a small set of concrete answer options you already know from the conversation or your investigation — choices like option A/B/C, scope boundaries, or edge-case behavior. Ask open-ended questions, including what the user wants in the first place, in plain assistant text. Never invent speculative options just to fit the question tool.
|
||||
|
||||
1. Start from the user's intent. If the visible message includes an initial idea, use it immediately. Otherwise ask what they want to accomplish. Do not ask them to formulate the Goal themselves.
|
||||
1. Start from the user's intent. If the visible message includes an initial idea, use it immediately. Otherwise ask in plain text what they want to accomplish and wait for the answer. Do not ask them to formulate the Goal themselves.
|
||||
|
||||
2. Investigate before asking when context is available. For repository work, inspect relevant code, tests, scripts, documentation, and conventions when that would answer questions or expose constraints. Do not ask for information that can be determined reliably from the workspace.
|
||||
|
||||
@@ -790,7 +794,46 @@ Whenever you ask the user a question, use the \`question\` tool. Do not ask ques
|
||||
|
||||
The proposed Goal should normally be one compact paragraph. Keep enough operational detail to make completion auditable, but remove conversational history, rationale, repetition, and implementation details that are not part of the completion contract.
|
||||
|
||||
Do not activate, execute, or claim completion of the proposed Goal. End by inviting the user to revise it or use it in the Goal dialog.
|
||||
Do not activate, execute, or claim completion of the proposed Goal. End by inviting the user to revise it or use it in the Goal dialog. If the \`openchamber\` tool is available, also offer to start a new Goal session for it yourself; do so only after the user explicitly confirms.
|
||||
|
||||
Respond in the same language the user uses.`,
|
||||
},
|
||||
{
|
||||
id: 'session.scheduleTask.visible',
|
||||
title: 'Scheduled Task Visible Prompt',
|
||||
group: 'Session',
|
||||
description: 'Visible user message sent by the /schedule-task command.',
|
||||
placeholders: [
|
||||
{ key: 'idea_block', description: 'Optional initial automation idea supplied after the command.' },
|
||||
],
|
||||
template: `Help me set up a scheduled task.{{idea_block}}`,
|
||||
},
|
||||
{
|
||||
id: 'session.scheduleTask.instructions',
|
||||
title: 'Scheduled Task Instructions',
|
||||
group: 'Session',
|
||||
description: 'Hidden instructions attached to the /schedule-task command. Guides the dialogue that defines a scheduled task and optionally creates it through the openchamber tool.',
|
||||
template: `The user wants to set up a scheduled task: a saved prompt that OpenChamber runs automatically on a schedule (daily, weekly, one time, or cron) in a chosen project, with a chosen model and optional Goal Mode.
|
||||
|
||||
Run this as a guided dialogue, not a one-shot answer.
|
||||
|
||||
Use the \`question\` tool only for clarifying decisions that have a small set of concrete answer options you already know from the conversation or your investigation — choices like option A/B/C, scope boundaries, or edge-case behavior. Ask open-ended questions, including what the user wants in the first place, in plain assistant text. Never invent speculative options just to fit the question tool.
|
||||
|
||||
1. Start from the user's intent. If the visible message includes an initial idea, use it immediately. Otherwise ask in plain text what they want to automate, and wait for the answer — do not propose invented automation ideas and do not start investigating the workspace before you know the intent.
|
||||
|
||||
2. Investigate before asking. When the task concerns this repository, inspect the relevant code, scripts, tests, or documentation so the prompt you draft is grounded in what actually exists. Do not ask for information the workspace can answer.
|
||||
|
||||
3. Resolve the task definition:
|
||||
- Name: a short, recognizable task name.
|
||||
- Prompt: the exact instruction the scheduled agent receives on every run. It must be fully self-contained — the scheduled session has no memory of this conversation, so include every path, command, and expectation it needs.
|
||||
- Schedule: a daily time, weekly days plus a time, a one-time date plus a time, or a cron expression; include the timezone when it matters.
|
||||
- Model in provider/model format. Mention agent, variant, or Goal Mode with a token budget only if the user brings them up.
|
||||
|
||||
4. Ask only necessary questions, in batches of at most 3. Prefer concrete, decision-oriented questions.
|
||||
|
||||
5. Do not perform the task's work in this session. The deliverable is the scheduled task definition.
|
||||
|
||||
6. When everything is settled, present the final task definition clearly. If the \`openchamber\` tool is available, offer to create the task yourself and, only after the user explicitly confirms, create it and report the result. If the tool is unavailable, present the definition so the user can add it in OpenChamber's scheduled tasks UI.
|
||||
|
||||
Respond in the same language the user uses.`,
|
||||
},
|
||||
@@ -843,7 +886,7 @@ Respond in the same language the user uses.`,
|
||||
description: 'Hidden instructions attached to the /debug command. Runs a guided root-cause investigation before proposing a fix.',
|
||||
template: `The user wants help debugging an issue. Drive this as a focused root-cause investigation — not a plan, and not an immediate fix.
|
||||
|
||||
Whenever you ask the user a question, use the \`question\` tool. Do not ask questions in plain assistant text.
|
||||
Use the \`question\` tool only for clarifying decisions that have a small set of concrete answer options you already know from the conversation or your investigation — choices like option A/B/C, scope boundaries, or edge-case behavior. Ask open-ended questions, including what the user wants in the first place, in plain assistant text. Never invent speculative options just to fit the question tool.
|
||||
|
||||
1. Get the symptom. When the user describes the problem, capture exactly what is observed versus expected — error messages, stack traces, failing behavior, and when it started. If a key detail is missing to even begin, ask for it briefly.
|
||||
|
||||
@@ -873,7 +916,7 @@ Respond in the same language the user uses.`,
|
||||
description: 'Hidden instructions attached to the /weigh command. Investigates the code, then compares distinct approaches with trade-offs and a recommendation — no plan, no code.',
|
||||
template: `The user knows WHAT they want to do but not HOW to approach it. Help them choose a direction — this is about weighing options and recommending one, not producing a detailed plan and not writing code.
|
||||
|
||||
Whenever you ask the user a question, use the \`question\` tool. Do not ask questions in plain assistant text.
|
||||
Use the \`question\` tool only for clarifying decisions that have a small set of concrete answer options you already know from the conversation or your investigation — choices like option A/B/C, scope boundaries, or edge-case behavior. Ask open-ended questions, including what the user wants in the first place, in plain assistant text. Never invent speculative options just to fit the question tool.
|
||||
|
||||
First, investigate. Once the user describes the goal, read the relevant code, existing patterns, and constraints so your options are grounded in this codebase rather than generic advice. Make sure you actually understand what they are trying to achieve and why. Ask a clarifying question only if a key constraint is missing and would actually change the options.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user