@corvio/cli 0.1.0-beta.14 → 0.1.0-beta.15

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.
Files changed (3) hide show
  1. package/README.md +4 -3
  2. package/dist/cli.js +267 -6
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -7,15 +7,16 @@ npm install --global @corvio/cli@beta
7
7
  export CORVIO_API_KEY='cvu_...'
8
8
  corvio auth status
9
9
  corvio agents connect --provider codex --project . --json
10
+ corvio collaboration status --json --no-input
10
11
  corvio ask --prompt 'Summarize recurring launch risks' --json
11
12
  corvio files upload --file ./research.pdf --json
12
13
  corvio sync init --dir ./knowledge --root-node-id <node_id> --json
13
14
  corvio update check --json
14
15
  ```
15
16
 
16
- When no environment key is configured, run `corvio auth login`. Login creates one user-level `cvu_` control-plane credential; it does not freeze the browser's current Workspace. Run `corvio agents connect --project .` from the project you want to expose. The command verifies the selected Codex, Claude Code, or Copilot host before server mutation, then idempotently creates or restores the Agent for that provider/device/project binding, grants current/future Workspace coverage under live membership/role and ACL limits, saves the one-time `cvg_` in a `0600` multi-binding registry, and starts that project's listener. Another project gets another Agent. Ordinary data commands prefer the binding whose root contains the current directory. Use `corvio workspaces use`, `--workspace`, and `--agent` as explicit routing/reproducibility controls. Legacy Workspace-bound `cvk_`, `cvg_`, and version-1 credential files remain compatible and are never widened. Local sync stores only credential-free handles and revision/hash baselines in `.corvio/state.json`; Markdown lives below `corvio_docs/`, and conflicts require explicit resolution. Update checks compare npm's published `beta` tag with the API compatibility policy but never self-install. See [the Corvio CLI guide](https://corvio.ai/developers/cli) for the full command and receipt contract.
17
+ When no environment key is configured, run `corvio auth login`. Login creates one user-level `cvu_` control-plane credential; it does not freeze the browser's current Workspace. Run `corvio agents connect --project .` from the project you want to expose. The command verifies the selected Codex, Claude Code, or Copilot host before server mutation, then idempotently creates or restores the Agent for that provider/device/project binding, grants current/future Workspace coverage under live membership/role and ACL limits, saves the one-time `cvg_` in a `0600` multi-binding registry, and starts that project's listener. `corvio collaboration status` then checks a separate foreground requirement: the current host must also discover the official Skill at the live server contract version. A listener receives inbound `@Agent` work; it does not make an unrelated foreground coding session collaborate automatically. Another project gets another Agent. Ordinary data commands prefer the binding whose root contains the current directory. Use `corvio workspaces use`, `--workspace`, and `--agent` as explicit routing/reproducibility controls. Legacy Workspace-bound `cvk_`, `cvg_`, and version-1 credential files remain compatible and are never widened. Local sync stores only credential-free handles and revision/hash baselines in `.corvio/state.json`; Markdown lives below `corvio_docs/`, and conflicts require explicit resolution. Update checks compare npm's published `beta` tag with the API compatibility policy but never self-install. See [the Corvio CLI guide](https://corvio.ai/developers/cli) for the full command and receipt contract.
17
18
 
18
- The CLI rejects unknown/duplicate options and malformed integer bounds before network access. Normal API calls have a bounded timeout (`CORVIO_REQUEST_TIMEOUT_MS`, maximum ten minutes); only reads, explicit idempotency contracts, revision guards, and other owner-declared safe operations retry automatically. Document updates preflight the current revision when `--expected-revision` is omitted. When the executing principal is a connected Agent, `docs update` also requires `--change-summary`, creates a visible document-level comment after the guarded write, and returns its receipt; a comment failure is reported as a partial effect rather than silent success. Downloads, uploads, and Markdown pulls verify SHA-256 receipts before replacing local files; local writes are atomic, remote default filenames cannot escape the current directory, and Sync refuses symbolic-link traversal while checkpointing each successful push.
19
+ The CLI rejects unknown/duplicate options and malformed integer bounds before network access. Normal API calls have a bounded timeout (`CORVIO_REQUEST_TIMEOUT_MS`, maximum ten minutes); only reads, explicit idempotency contracts, revision guards, and other owner-declared safe operations retry automatically. Document updates preflight the current revision when `--expected-revision` is omitted. When the executing principal is a connected Agent, `docs update` also requires `--change-summary`, creates a visible document-level comment after the guarded write, and returns its receipt; a comment failure is reported as a partial effect rather than silent success. When a Corvio document or comment supplied the task, use `corvio agent closeout` to return the verified outcome, optionally resolve the thread, and read both document and thread back. Downloads, uploads, and Markdown pulls verify SHA-256 receipts before replacing local files; local writes are atomic, remote default filenames cannot escape the current directory, and Sync refuses symbolic-link traversal while checkpointing each successful push.
19
20
 
20
21
  ## Project Agent collaboration
21
22
 
@@ -25,7 +26,7 @@ Connect the current project with the user credential. User and Agent credentials
25
26
  corvio agents connect --provider codex --project . --json
26
27
  ```
27
28
 
28
- Without `--display-name`, connect derives a provider-aware project name from the authenticated user, such as `Ada Codex · billing-service`; Settings remains the rename owner. The receipt distinguishes `Configured`, `CLI Ready`, `Listening`, and `Offline`, and includes the stable Agent, opaque project binding, Workspace scope, host permission/trigger policy, and Settings link. The default `workspace_write` profile uses the provider's native sandbox. `owner_only` is the safe trigger default. Allowing Workspace members to invoke the local project or granting unrestricted host access requires explicit `--yes`.
29
+ Without `--display-name`, connect derives a provider-aware project name from the authenticated user, such as `Ada Codex · billing-service`; Settings remains the rename owner. The receipt distinguishes `Configured`, `CLI Ready`, `Listening`, `Offline`, and `Foreground collaboration ready`, and includes the stable Agent, opaque project binding, Workspace scope, host permission/trigger policy, Skill status, and Settings link. The default `workspace_write` profile uses the provider's native sandbox. `owner_only` is the safe trigger default. Allowing Workspace members to invoke the local project or granting unrestricted host access requires explicit `--yes`.
29
30
 
30
31
  The listener first runs a read-only provider planning pass, then asks Corvio Query for exact origin-document and collaboration context. `local_project` work runs inside the bound project; online document writes remain Query/Writer-owned. The provider consumes the Query result before replying, and completion records exact event/lease/question/comment lineage plus provider, project fingerprint, claimed files/checks, and observed Git working-tree state. A custom handler remains available for advanced adapters:
31
32
 
package/dist/cli.js CHANGED
@@ -39,13 +39,14 @@ import {
39
39
  agentCredentialPath,
40
40
  } from "./core.js";
41
41
 
42
- const VERSION = "0.1.0-beta.14";
42
+ const VERSION = "0.1.0-beta.15";
43
43
  const DEFAULT_API_BASE = "https://api.corvio.ai/v1";
44
44
  const DEFAULT_APP_BASE = "https://corvio.ai";
45
45
  const USER_AGENT = `corvio-cli/${VERSION}`;
46
46
  const MAX_UPLOAD_BYTES = 100 * 1024 * 1024;
47
47
  const MAX_SYNC_FILES = 2_000;
48
48
  const MAX_MARKDOWN_CHARACTERS = 120_000;
49
+ const CORVIO_SKILL_INSTALL_COMMAND = "npx skills add https://corvio.ai/developers/skills/corvio-operate-workspace/corvio-operate-workspace.zip";
49
50
  const GLOBAL_OPTIONS = Object.freeze([
50
51
  "api-base",
51
52
  "workspace",
@@ -67,6 +68,7 @@ const COMMAND_OPTIONS = Object.freeze({
67
68
  "workspaces:use": ["id"],
68
69
  "workspaces:create": ["name", "kind", "description", "idempotency-key"],
69
70
  "capabilities:": [],
71
+ "collaboration:status": ["project", "provider"],
70
72
  "ask:": ["prompt", "conversation-id", "sources", "allow-actions", "context-file", "idempotency-key"],
71
73
  "agents:list": ["include-revoked"],
72
74
  "agents:connect": [
@@ -85,6 +87,7 @@ const COMMAND_OPTIONS = Object.freeze({
85
87
  "agent:comment": ["document-id", "body", "selection-file", "start-new-chain", "idempotency-key"],
86
88
  "agent:reply": ["document-id", "id", "body", "source-event-id", "source-event-lease-token", "start-new-chain", "idempotency-key"],
87
89
  "agent:status": ["document-id", "id", "status"],
90
+ "agent:closeout": ["document-id", "thread-id", "body", "status", "idempotency-key"],
88
91
  "agent:run": ["once", "handler", "provider", "worker-id", "lease-seconds", "wait-seconds", "sources", "project"],
89
92
  "questions:list": ["limit", "cursor", "conversation-id"],
90
93
  "questions:get": ["id"],
@@ -123,9 +126,10 @@ Usage:
123
126
  corvio auth login|status|logout
124
127
  corvio workspaces list|use|current|create [id]
125
128
  corvio capabilities
129
+ corvio collaboration status [--project <path>] [--provider codex|claude_code|copilot]
126
130
  corvio ask --prompt <text> [--conversation-id <id>] [--allow-actions]
127
131
  corvio agents list|connect|create|update|rotate [id]
128
- corvio agent claim|renew|complete|fail|comments|comment|reply|status|run [id]
132
+ corvio agent claim|renew|complete|fail|comments|comment|reply|status|closeout|run [id]
129
133
  corvio questions list|get [id]
130
134
  corvio conversations list|get [id]
131
135
  corvio search <query>
@@ -151,13 +155,14 @@ const COMMAND_HELP = Object.freeze({
151
155
  auth: `Usage: corvio auth login|status|logout\n\nAuthenticate with a user-level device link, inspect the current principal, or revoke the stored credential.`,
152
156
  workspaces: `Usage:\n corvio workspaces list\n corvio workspaces use <workspace-id>\n corvio workspaces current\n corvio workspaces create --name <name> [--kind personal|team]\n\nWorkspace status and blocked capability reasons are returned with each item.`,
153
157
  capabilities: `Usage: corvio capabilities [--json]\n\nShow live API resources, principal scopes, selected Workspace status, and CLI compatibility.`,
158
+ collaboration: `Usage:\n corvio collaboration status [--project <path>] [--provider codex|claude_code|copilot]\n\nVerify that the current project has a bound Corvio Agent, the official collaboration Skill is discoverable at the live contract version, and the inbound listener state is reported separately. This is the foreground work-loop readiness check; a listening process alone is not enough.`,
154
159
  ask: `Usage: corvio ask --prompt <text> [--conversation-id <id>] [--sources workspace,web,memory] [--allow-actions] [--context-file <json>] [--idempotency-key <key>]`,
155
- agents: `Usage:\n corvio agents list\n corvio agents connect [--provider codex|claude_code|copilot] [--project <path>] [--permission-profile read_only|workspace_write|danger_full_access] [--trigger-policy owner_only|workspace_members] [--display-name <name>] [--recover-credential] [--no-listen]\n corvio agents create --handle <handle> --display-name <name> [--provider codex|claude_code|copilot|custom] [--permissions read,comment,edit]\n corvio agents update <id> [--display-name <name>] [--status active|paused|revoked] [--permissions <list>]\n corvio agents rotate <id>\n\n'connect' binds the current Git project (or --project path) to one stable personal Agent. Repeating it is idempotent; another project creates another Agent. The default workspace_write profile is limited by the provider's native sandbox. owner_only is the safe trigger default. Secrets and absolute project paths stay local.`,
156
- agent: `Usage:\n corvio agent claim [--worker-id <id>] [--wait-seconds <0-30>]\n corvio agent renew <event-id> --lease-token <token> [--lease-seconds <30-900>]\n corvio agent complete <event-id> --lease-token <token> [--result-file <json>]\n corvio agent fail <event-id> --lease-token <token> --error <message>\n corvio agent mentions --document-id <id> [--query <name>]\n corvio agent comments --document-id <id>\n corvio agent comment --document-id <id> --body <text> [--selection-file <json>] [--start-new-chain] [--idempotency-key <key>]\n corvio agent reply <thread-id> --document-id <id> --body <text> [--source-event-id <id> --source-event-lease-token <token>|--start-new-chain] [--idempotency-key <key>]\n corvio agent status <thread-id> --document-id <id> --status open|resolved\n corvio agent run [--provider codex|claude_code|copilot|custom] [--handler <executable>] [--agent <id>] [--once]\n\nUse mentions before commenting when the target is uncertain; aliases resolve to stable user or Agent IDs and ambiguity fails closed. Agent-to-Agent comments require either a claimed source event or explicit --start-new-chain. The runner iteratively exchanges origin-scoped evidence with Corvio Query/Writer, then invokes the bound provider inside its local project. Local code changes use the recorded provider permission profile; complex Corvio document changes belong to Query/Writer. Provider children never receive Corvio credentials.`,
160
+ agents: `Usage:\n corvio agents list\n corvio agents connect [--provider codex|claude_code|copilot] [--project <path>] [--permission-profile read_only|workspace_write|danger_full_access] [--trigger-policy owner_only|workspace_members] [--display-name <name>] [--recover-credential] [--no-listen]\n corvio agents create --handle <handle> --display-name <name> [--provider codex|claude_code|copilot|custom] [--permissions read,comment,edit]\n corvio agents update <id> [--display-name <name>] [--status active|paused|revoked] [--permissions <list>]\n corvio agents rotate <id>\n\n'connect' binds the current Git project (or --project path) to one stable personal Agent. Repeating it is idempotent; another project creates another Agent. It reports provider/CLI, listener, and foreground Skill readiness separately; run corvio collaboration status after installing or refreshing the Skill. The default workspace_write profile is limited by the provider's native sandbox. owner_only is the safe trigger default. Secrets and absolute project paths stay local.`,
161
+ agent: `Usage:\n corvio agent claim [--worker-id <id>] [--wait-seconds <0-30>]\n corvio agent renew <event-id> --lease-token <token> [--lease-seconds <30-900>]\n corvio agent complete <event-id> --lease-token <token> [--result-file <json>]\n corvio agent fail <event-id> --lease-token <token> --error <message>\n corvio agent mentions --document-id <id> [--query <name>]\n corvio agent comments --document-id <id>\n corvio agent comment --document-id <id> --body <text> [--selection-file <json>] [--start-new-chain] [--idempotency-key <key>]\n corvio agent reply <thread-id> --document-id <id> --body <text> [--source-event-id <id> --source-event-lease-token <token>|--start-new-chain] [--idempotency-key <key>]\n corvio agent status <thread-id> --document-id <id> --status open|resolved\n corvio agent closeout --document-id <id> [--thread-id <id>] --body <verified-result> [--status open|resolved] [--idempotency-key <key>]\n corvio agent run [--provider codex|claude_code|copilot|custom] [--handler <executable>] [--agent <id>] [--once]\n\nUse mentions before commenting when the target is uncertain; aliases resolve to stable user or Agent IDs and ambiguity fails closed. Use closeout when a Corvio document or comment owned the task: it returns the verified result to that surface and reads document/comments back. Agent-to-Agent comments require either a claimed source event or explicit --start-new-chain. The runner iteratively exchanges origin-scoped evidence with Corvio Query/Writer, then invokes the bound provider inside its local project. Local code changes use the recorded provider permission profile; complex Corvio document changes belong to Query/Writer. Provider children never receive Corvio credentials.`,
157
162
  questions: `Usage:\n corvio questions list [--limit <n>] [--cursor <cursor>] [--conversation-id <id>]\n corvio questions get <question-id>`,
158
163
  conversations: `Usage:\n corvio conversations list [--limit <n>] [--cursor <cursor>]\n corvio conversations get <conversation-id>`,
159
164
  search: `Usage: corvio search <query> [--limit <n>] [--page-id <id>] [--node-id <id>]`,
160
- docs: `Usage:\n corvio docs list [--limit <n>] [--cursor <cursor>] [--lifecycle active|archived]\n corvio docs get <id> [--output <path>]\n corvio docs create --title <title> [--file <path>|--markdown <text>] [--parent-node-id <id>] [--idempotency-key <key>]\n corvio docs update <id> [--title <title>] [--file <path>|--markdown <text>] [--expected-revision <n>] [--change-summary <text>]\n corvio docs move <id> --parent-node-id <id>\n corvio docs archive <id> --yes\n corvio docs restore <id> --yes\n corvio docs share <id> --yes [--display-name <name>]\n corvio docs open <id>\n\nDirect document commands operate on canonical Page/Markdown. Use \`corvio ask --allow-actions\` for Spreadsheet, Presentation, Code, HTML Artifact, or semantic organization. Agent-authenticated document updates require --change-summary and create a visible document-level comment after the guarded update. When a document/comment is the task owner, use \`corvio agent comments|reply|status\` to return verified work to that same collaboration surface.`,
165
+ docs: `Usage:\n corvio docs list [--limit <n>] [--cursor <cursor>] [--lifecycle active|archived]\n corvio docs get <id> [--output <path>]\n corvio docs create --title <title> [--file <path>|--markdown <text>] [--parent-node-id <id>] [--idempotency-key <key>]\n corvio docs update <id> [--title <title>] [--file <path>|--markdown <text>] [--expected-revision <n>] [--change-summary <text>]\n corvio docs move <id> --parent-node-id <id>\n corvio docs archive <id> --yes\n corvio docs restore <id> --yes\n corvio docs share <id> --yes [--display-name <name>]\n corvio docs open <id>\n\nDirect document commands operate on canonical Page/Markdown. Use \`corvio ask --allow-actions\` for Spreadsheet, Presentation, Code, HTML Artifact, or semantic organization. Agent-authenticated document updates require --change-summary and create a visible document-level comment after the guarded update. When a document/comment is the task owner, use \`corvio agent closeout\` to return verified work to that same collaboration surface and read it back.`,
161
166
  projects: `Usage:\n corvio projects list [--limit <n>]\n corvio projects create --title <title> [--idempotency-key <key>]\n\nProjects are durable grouping owners in the Corvio Docs tree. Reuse a matching Project instead of creating one ceremonial Project per file. 'corvio folders' is an alias.`,
162
167
  files: `Usage:\n corvio files list [--limit <n>]\n corvio files get <id>\n corvio files download <id> [--output <path>]\n corvio files upload --file <path> [--mime-type <type>]\n corvio files organize <id> --instruction <text> --yes [--target-root-node-id <id>]\n corvio files open <id>`,
163
168
  sync: `Usage:\n corvio sync init --root-node-id <id> [--dir <path>] [--name <name>]\n corvio sync status|plan|pull [--dir <path>]\n corvio sync push --yes [--dir <path>]\n corvio sync resolve --conflict-id <id> --strategy use-remote|keep-local --yes [--dir <path>]`,
@@ -185,6 +190,7 @@ function normalizeInvocation(command, action) {
185
190
  projects: "list",
186
191
  files: "list",
187
192
  agents: "list",
193
+ collaboration: "status",
188
194
  agent: "claim",
189
195
  sync: "status",
190
196
  update: "check",
@@ -650,6 +656,141 @@ async function capabilities(options) {
650
656
  }, { json: options.json });
651
657
  }
652
658
 
659
+ async function codexPluginGuidanceCandidates(codexHome) {
660
+ const cacheRoot = join(codexHome, "plugins", "cache");
661
+ const listDirectories = async (directory) => {
662
+ try {
663
+ return (await readdir(directory, { withFileTypes: true }))
664
+ .filter((entry) => entry.isDirectory())
665
+ .slice(0, 256)
666
+ .map((entry) => entry.name);
667
+ } catch (error) {
668
+ if (["ENOENT", "ENOTDIR", "EACCES"].includes(error?.code)) return [];
669
+ throw error;
670
+ }
671
+ };
672
+ const candidates = [];
673
+ for (const marketplace of await listDirectories(cacheRoot)) {
674
+ const marketplaceRoot = join(cacheRoot, marketplace);
675
+ for (const plugin of await listDirectories(marketplaceRoot)) {
676
+ const pluginRoot = join(marketplaceRoot, plugin);
677
+ for (const version of await listDirectories(pluginRoot)) {
678
+ candidates.push({
679
+ scope: "codex_plugin_cache",
680
+ path: join(pluginRoot, version, "skills", "corvio-operate-workspace", "SKILL.md"),
681
+ });
682
+ }
683
+ }
684
+ }
685
+ return candidates;
686
+ }
687
+
688
+ async function inspectCollaborationGuidance(provider, projectRoot, expectedContractVersion) {
689
+ const candidates = [
690
+ { scope: "project_agents", path: join(projectRoot, ".agents", "skills", "corvio-operate-workspace", "SKILL.md") },
691
+ { scope: "user_agents", path: join(homedir(), ".agents", "skills", "corvio-operate-workspace", "SKILL.md") },
692
+ ];
693
+ if (provider === "codex") {
694
+ const codexHome = String(process.env.CODEX_HOME || join(homedir(), ".codex"));
695
+ candidates.push({
696
+ scope: "user_codex",
697
+ path: join(codexHome, "skills", "corvio-operate-workspace", "SKILL.md"),
698
+ });
699
+ candidates.push(...await codexPluginGuidanceCandidates(codexHome));
700
+ }
701
+ if (provider === "claude_code") {
702
+ candidates.push(
703
+ { scope: "project_claude", path: join(projectRoot, ".claude", "skills", "corvio-operate-workspace", "SKILL.md") },
704
+ {
705
+ scope: "user_claude",
706
+ path: join(String(process.env.CLAUDE_CONFIG_DIR || join(homedir(), ".claude")), "skills", "corvio-operate-workspace", "SKILL.md"),
707
+ },
708
+ );
709
+ }
710
+ const found = [];
711
+ for (const candidate of candidates) {
712
+ try {
713
+ const source = await readFile(candidate.path, "utf8");
714
+ if (!/^name:\s*corvio-operate-workspace\s*$/m.test(source)) continue;
715
+ found.push({
716
+ scope: candidate.scope,
717
+ current: Boolean(expectedContractVersion)
718
+ && source.includes(`contract version \`${expectedContractVersion}\``),
719
+ });
720
+ } catch (error) {
721
+ if (error?.code !== "ENOENT") throw error;
722
+ }
723
+ }
724
+ const current = found.filter((item) => item.current);
725
+ const status = !expectedContractVersion
726
+ ? "contract_unavailable"
727
+ : current.length
728
+ ? "ready"
729
+ : found.length
730
+ ? "stale"
731
+ : "missing";
732
+ return {
733
+ status,
734
+ expected_contract_version: expectedContractVersion || null,
735
+ discovered_scopes: found.map((item) => item.scope),
736
+ current_scopes: current.map((item) => item.scope),
737
+ install_command: status === "missing" || status === "stale" ? CORVIO_SKILL_INSTALL_COMMAND : null,
738
+ };
739
+ }
740
+
741
+ async function collaborationStatus(options) {
742
+ const projectRoot = await findProjectRoot(options.project);
743
+ const credential = await readAgentCredential(process.env, {
744
+ required: false,
745
+ agentId: String(options.agent || "").trim() || null,
746
+ projectRoot,
747
+ fallbackToActive: false,
748
+ });
749
+ const provider = String(options.provider || credential?.metadata?.provider || "codex");
750
+ const api = new ApiClient({ baseUrl: baseUrl(options), userAgent: USER_AGENT });
751
+ const index = await api.request("", { auth: false });
752
+ const liveContract = dictLike(index?.coding_agent_collaboration);
753
+ const serverVersion = String(liveContract.version || "").trim() || null;
754
+ const guidance = await inspectCollaborationGuidance(provider, projectRoot, serverVersion);
755
+ const bindingId = String(credential?.metadata?.binding_id || "").trim();
756
+ const runnerState = await readAgentRunnerState();
757
+ const listener = bindingId ? dictLike(runnerState?.listeners?.[bindingId]) : {};
758
+ const listenerStatus = processIsRunning(Number(listener.pid)) ? "listening" : "offline";
759
+ let status = "ready";
760
+ if (!credential) status = "needs_connection";
761
+ else if (!serverVersion) status = "contract_unavailable";
762
+ else if (guidance.status === "missing") status = "needs_skill";
763
+ else if (guidance.status === "stale") status = "stale_skill";
764
+ const nextActions = [];
765
+ if (!credential) nextActions.push(`corvio agents connect --provider ${provider} --project .`);
766
+ if (guidance.install_command) nextActions.push(guidance.install_command);
767
+ if (!serverVersion) nextActions.push("corvio update check --json");
768
+ writeResult({
769
+ status,
770
+ foreground_collaboration_ready: status === "ready",
771
+ contract_version: serverVersion,
772
+ server_contract_version: serverVersion,
773
+ project_agent: credential
774
+ ? {
775
+ connected: true,
776
+ id: credential.metadata?.agent_id || null,
777
+ provider,
778
+ binding_id: bindingId || null,
779
+ }
780
+ : { connected: false, id: null, provider, binding_id: null },
781
+ host_guidance: guidance,
782
+ listener_status: listenerStatus,
783
+ listener_note: "The listener receives inbound @Agent work; it does not activate foreground Coding-Agent collaboration.",
784
+ synchronization: {
785
+ mode: "host_guided_foreground",
786
+ automatic_transcript_capture: false,
787
+ reason: "The host selects decision-relevant context and valuable results; Corvio never records arbitrary chats or local files in the background.",
788
+ work_loop: liveContract.work_loop || ["ground", "work", "checkpoint", "materialize", "verify", "return"],
789
+ },
790
+ next_actions: nextActions,
791
+ }, { json: options.json });
792
+ }
793
+
653
794
  async function workspaces(options, action, id) {
654
795
  const credential = await readWorkspaceCredential();
655
796
  if (!credential) {
@@ -1224,6 +1365,22 @@ async function agents(options, action, id) {
1224
1365
  const listener = options["no-listen"]
1225
1366
  ? { status: "offline", pid: null, reused: false, log: null }
1226
1367
  : await ensureAgentListener({ options, provider, agentId: agent.id, binding });
1368
+ let collaborationVersion = null;
1369
+ try {
1370
+ const collaborationIndex = await api.request("", { auth: false });
1371
+ collaborationVersion = String(
1372
+ dictLike(collaborationIndex?.coding_agent_collaboration).version || "",
1373
+ ).trim() || null;
1374
+ } catch {
1375
+ // The Agent binding and provider readiness are already durable. Keep this
1376
+ // later collaboration check explicit instead of turning a settled connect
1377
+ // into an ambiguous failure.
1378
+ }
1379
+ const hostGuidance = await inspectCollaborationGuidance(
1380
+ provider,
1381
+ binding.project_root,
1382
+ collaborationVersion,
1383
+ );
1227
1384
  result = {
1228
1385
  connected: true,
1229
1386
  idempotent: Boolean(result.idempotent),
@@ -1258,8 +1415,20 @@ async function agents(options, action, id) {
1258
1415
  reused: listener.reused,
1259
1416
  log: listener.log,
1260
1417
  },
1418
+ foreground_collaboration: {
1419
+ status: hostGuidance.status === "ready"
1420
+ ? "ready"
1421
+ : hostGuidance.status === "contract_unavailable"
1422
+ ? "contract_unavailable"
1423
+ : "needs_skill",
1424
+ ready: hostGuidance.status === "ready",
1425
+ host_guidance: hostGuidance,
1426
+ note: "The inbound listener and foreground collaboration are separate readiness facts.",
1427
+ },
1261
1428
  settings_url: result.settings_url,
1262
- next_command: `corvio agent run --provider ${provider} --agent ${agent.id}`,
1429
+ next_command: hostGuidance.status === "ready"
1430
+ ? "corvio collaboration status --json --no-input"
1431
+ : hostGuidance.install_command || "corvio collaboration status --json --no-input",
1263
1432
  };
1264
1433
  } else if (action === "create") {
1265
1434
  result = await api.request("/agents", {
@@ -2196,6 +2365,97 @@ async function agentCommand(options, action, id) {
2196
2365
  method: "POST",
2197
2366
  body: { status: option(options, "status", { required: true }), entry_point: "external_agent_cli_status" },
2198
2367
  });
2368
+ } else if (action === "closeout") {
2369
+ const documentId = option(options, "document-id", { required: true });
2370
+ const threadId = String(options["thread-id"] || "").trim() || null;
2371
+ const bodyText = option(options, "body", { required: true });
2372
+ const status = String(options.status || "open").trim().toLowerCase();
2373
+ if (!["open", "resolved"].includes(status)) {
2374
+ throw new CliError("--status must be open or resolved.", { code: "comment_status_invalid" });
2375
+ }
2376
+ const before = await api.request(`/documents/${resourcePath(documentId)}/comments`);
2377
+ if (threadId && !Array.isArray(before?.threads)) {
2378
+ throw new CliError("The current comment readback is invalid.", { code: "comment_readback_invalid" });
2379
+ }
2380
+ if (threadId && !before.threads.some((thread) => String(thread.id) === threadId)) {
2381
+ throw new CliError("The originating comment thread was not found on this document.", {
2382
+ code: "comment_thread_not_found",
2383
+ });
2384
+ }
2385
+ const stableKey = idempotencyKey(options);
2386
+ const mentionTargets = await resolveAgentMentionTargets(api, documentId, bodyText);
2387
+ const comment = threadId
2388
+ ? await api.request(`/documents/${resourcePath(documentId)}/comments/${resourcePath(threadId)}/replies`, {
2389
+ method: "POST",
2390
+ headers: { "idempotency-key": stableKey },
2391
+ body: {
2392
+ body: bodyText,
2393
+ mention_targets: mentionTargets,
2394
+ entry_point: "external_agent_cli_closeout",
2395
+ start_new_chain: false,
2396
+ },
2397
+ })
2398
+ : await api.request(`/documents/${resourcePath(documentId)}/comments`, {
2399
+ method: "POST",
2400
+ headers: { "idempotency-key": stableKey },
2401
+ body: {
2402
+ body: bodyText,
2403
+ mention_targets: mentionTargets,
2404
+ selection: { target_scope: "document" },
2405
+ entry_point: "external_agent_cli_closeout",
2406
+ start_new_chain: false,
2407
+ },
2408
+ });
2409
+ const closeoutThreadId = String(comment?.id || threadId || "");
2410
+ try {
2411
+ if (status === "resolved" && String(comment?.status || "") !== "resolved") {
2412
+ await api.request(`/documents/${resourcePath(documentId)}/comments/${resourcePath(closeoutThreadId)}/status`, {
2413
+ method: "POST",
2414
+ body: { status: "resolved", entry_point: "external_agent_cli_closeout" },
2415
+ });
2416
+ }
2417
+ } catch {
2418
+ throw new CliError(
2419
+ "The result comment was committed, but the requested closeout status failed. Keep the thread open and retry the status update after readback.",
2420
+ {
2421
+ code: "comment_closeout_partial",
2422
+ exitCode: EXIT.REMOTE,
2423
+ details: { document_id: documentId, thread_id: closeoutThreadId, comment },
2424
+ },
2425
+ );
2426
+ }
2427
+ const [document, comments] = await Promise.all([
2428
+ api.request(`/documents/${resourcePath(documentId)}`),
2429
+ api.request(`/documents/${resourcePath(documentId)}/comments`),
2430
+ ]);
2431
+ const thread = Array.isArray(comments?.threads)
2432
+ ? comments.threads.find((item) => String(item.id) === closeoutThreadId) || null
2433
+ : null;
2434
+ if (!thread) {
2435
+ throw new CliError(
2436
+ "The result comment was committed, but its current thread could not be read back.",
2437
+ {
2438
+ code: "comment_closeout_readback_failed",
2439
+ exitCode: EXIT.REMOTE,
2440
+ details: { document_id: documentId, thread_id: closeoutThreadId, comment },
2441
+ },
2442
+ );
2443
+ }
2444
+ result = {
2445
+ document: {
2446
+ id: document?.id || documentId,
2447
+ node_id: document?.node_id || null,
2448
+ title: document?.title || null,
2449
+ doc_type: document?.doc_type || null,
2450
+ content_revision: document?.content_revision ?? null,
2451
+ url: document?.url || null,
2452
+ },
2453
+ thread,
2454
+ completed: status === "resolved" && thread?.status === "resolved",
2455
+ remaining_boundary: status === "resolved" && thread?.status === "resolved"
2456
+ ? null
2457
+ : "The originating thread remains open for incomplete or unverified work.",
2458
+ };
2199
2459
  } else {
2200
2460
  throw new CliError("Unknown agent runtime action.");
2201
2461
  }
@@ -3037,6 +3297,7 @@ async function main({ options, positionals }) {
3037
3297
  return workspaces(options, action || "list", id);
3038
3298
  }
3039
3299
  if (command === "capabilities") return capabilities(options);
3300
+ if (command === "collaboration") return collaborationStatus(options);
3040
3301
  if (command === "ask") return ask(options, [action, id, ...rest].filter(Boolean));
3041
3302
  if (command === "agents") return agents(options, action || "list", id);
3042
3303
  if (command === "agent") return agentCommand(options, action || "claim", id);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@corvio/cli",
3
- "version": "0.1.0-beta.14",
3
+ "version": "0.1.0-beta.15",
4
4
  "description": "Official Corvio Workspace CLI for questions, knowledge search, documents, and Agent workflows.",
5
5
  "type": "module",
6
6
  "bin": {