@crewx/cli 0.9.0-rc.190 → 0.9.0-rc.191
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/commands/ai-account.d.ts +14 -2
- package/dist/commands/ai-account.js +38 -27
- package/dist/commands/command-help.d.ts +1 -0
- package/dist/commands/command-help.js +27 -3
- package/dist/commands/detached.d.ts +23 -4
- package/dist/commands/detached.js +15 -15
- package/dist/commands/execute.js +13 -13
- package/dist/commands/query.js +15 -15
- package/dist/commands/restart.js +8 -8
- package/dist/main.js +9 -7
- package/package.json +15 -15
|
@@ -1,4 +1,16 @@
|
|
|
1
|
+
type SignalHost = Pick<NodeJS.Process, 'on' | 'removeListener'>;
|
|
2
|
+
type SdkExports = Readonly<Record<string, unknown>>;
|
|
3
|
+
export interface AiAccountCommandDependencies {
|
|
4
|
+
/** SDK override used by focused command and process-boundary tests. */
|
|
5
|
+
sdk?: SdkExports;
|
|
6
|
+
isAgentTask?: () => boolean;
|
|
7
|
+
isInteractive?: () => boolean;
|
|
8
|
+
signalHost?: SignalHost;
|
|
9
|
+
}
|
|
10
|
+
/** True only for the exact command that must bypass normal CLI bootstrap. */
|
|
11
|
+
export declare function isAiAccountCapabilitiesRequest(args: readonly string[]): boolean;
|
|
1
12
|
/** Run one `crewx ai-account` subcommand. Returns the process exit code. */
|
|
2
|
-
export declare function runAiAccountCommand(args: string[]): number
|
|
13
|
+
export declare function runAiAccountCommand(args: string[], dependencies?: AiAccountCommandDependencies): Promise<number>;
|
|
3
14
|
/** Entry used by main.ts. */
|
|
4
|
-
export declare function handleAiAccount(args: string[]): Promise<void>;
|
|
15
|
+
export declare function handleAiAccount(args: string[], dependencies?: AiAccountCommandDependencies): Promise<void>;
|
|
16
|
+
export {};
|
|
@@ -1,27 +1,38 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.runAiAccountCommand=
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
`);
|
|
9
|
-
`)
|
|
10
|
-
`)
|
|
11
|
-
`);const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
`);
|
|
15
|
-
`)}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
`)
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
`);return 0}
|
|
23
|
-
|
|
24
|
-
`);return 0}
|
|
25
|
-
`)
|
|
26
|
-
|
|
27
|
-
`)
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.isAiAccountCapabilitiesRequest=un;exports.runAiAccountCommand=G;exports.handleAiAccount=an;const y=require("child_process");const N=require("./parse-common-flags");const U=require("./command-help");const a="cli/antigravity";const k={claude:"cli/claude","cli/claude":"cli/claude",codex:"cli/codex","cli/codex":"cli/codex",antigravity:a,"cli/antigravity":a};const M=new Set(["ACCOUNT_LABEL_INVALID","ACCOUNT_PROVIDER_INVALID","ACCOUNT_PROVIDER_UNSUPPORTED","ACCOUNT_NOT_FOUND","ACCOUNT_UNKNOWN","ACCOUNT_DEFAULT_PROTECTED","ACCOUNT_ACTIVE_PROTECTED","ACCOUNT_RESUME_REMOVED","ACCOUNT_RUNTIME_UNAVAILABLE","ACCOUNT_RUNTIME_CAPABILITY","ACCOUNT_RUNTIME_CAPABILITY_UNSUPPORTED","ACCOUNT_RUNTIME_MISMATCH","ACCOUNT_RUNTIME_CONTEXT_REQUIRED","ACCOUNT_INSTALL_FAILED","ACCOUNT_OPTION_UNSUPPORTED","ACCOUNT_NOT_SIGNED_IN","ACCOUNT_LOGIN_IN_PROGRESS","ACCOUNT_LOGIN_INCOMPLETE","ACCOUNT_LOGIN_UNSUPPORTED_HOST","ACCOUNT_LOGIN_UNSUPPORTED_POLICY","ACCOUNT_LOGIN_FAILED","ACCOUNT_LOGIN_CANCELLED","ACCOUNT_BUSY","ACCOUNT_RESUME_AUTH_CHANGED","ACCOUNT_RESUME_NOT_FOUND","ACCOUNT_LOGIN_FLOW_UNSUPPORTED","ACCOUNT_REGISTRY_INVALID","ACCOUNT_CAPABILITIES_UNSUPPORTED","ACCOUNT_LOGIN_REQUIRES_LOCAL_UI","ACCOUNT_COMMAND_FAILED","ACCOUNT_OPERATION_FAILED"]);class C extends Error{code;constructor(e){super(e);this.code=e;this.name="AiAccountCommandError"}}function I(n){return typeof n==="object"&&n!==null&&!Array.isArray(n)}function R(n,e){const i=n[e];return typeof i==="function"?i:void 0}function A(n,e,i="ACCOUNT_RUNTIME_CAPABILITY"){const t=R(n,e);if(!t)throw new C(i);return t}function b(){return require("@crewx/sdk")}function m(n,e){return typeof n==="string"&&M.has(n)?n:e}function w(n,e){if(n instanceof C)return n.code;if(I(n))return m(n.code,e);return e}function p(n,e){process.stderr.write(`Error [${m(n,"ACCOUNT_OPERATION_FAILED")}]${e?`: ${e}`:""}
|
|
2
|
+
`)}function x(n){if(n===void 0)return void 0;const e=k[n];if(!e){throw new N.UnknownOptionError(`Unknown provider: ${n} (use claude, codex, or antigravity)`)}return e}function B(n){const e={positional:[],json:false};for(let i=0;i<n.length;i+=1){const t=n[i];if(t==="--json"){e.json=true}else if(t==="--provider"||t.startsWith("--provider=")){const o=t.includes("=")?t.slice("--provider=".length):n[++i];e.provider=x(o)}else if(t==="--label"||t.startsWith("--label=")){e.label=t.includes("=")?t.slice("--label=".length):n[++i]}else if(t.startsWith("--")){throw new N.UnknownOptionError(`Unknown option: ${t}`)}else{e.positional.push(t)}}return e}function v(n){let e=0;for(const i of n){const t=i.codePointAt(0)??0;const o=t>=4352&&t<=4447||t>=11904&&t<=42191||t>=44032&&t<=55203||t>=63744&&t<=64255||t>=65280&&t<=65376;e+=o?2:1}return e}function F(n){const e=n.map(r=>[r.provider,r.id,r.active?"*":"",r.label,r.provider===a?"":r.dir]);const i=["PROVIDER","ID","ACTIVE","LABEL","DIR"];const t=i.map((r,s)=>Math.max(v(r),...e.map(c=>v(c[s]))));const o=r=>r.map((s,c)=>s+" ".repeat(t[c]-v(s))).join(" ").trimEnd();return[o(i),...e.map(o)].join("\n")}function V(n){if(n.provider!==a)return n;const{dir:e,...i}=n;return i}function j(n){return n?[n]:["cli/claude","cli/codex",a]}function q(n,e,i,t){if(n==="cli/codex"){const c=e.trim();return{loggedIn:i===0,lines:[...c?[c]:[],`loggedIn:${i===0}`,`configDirectory:${t}`]}}let o={};try{o=JSON.parse(e)}catch{}const r=o.loggedIn===true;const s=[`loggedIn:${r}`];if(typeof o.authMethod==="string")s.push(`authMethod:${o.authMethod}`);if(typeof o.subscriptionType==="string")s.push(`subscriptionType:${o.subscriptionType}`);s.push(`configDirectory:${t}`);return{loggedIn:r,lines:s}}function S(n,e){const i=A(n,"listAiAccounts");return i(e)}function P(n,e,i){if(e===a)return n!=="default";if(e!==void 0)return false;return S(i,a).some(t=>t.id===n&&!t.builtIn&&t.loginKind==="acp-flow")}function J(n,e,i,t){const o=A(t,"getStatusInvocation");const r=A(t,"applyAiAccountEnv");const s=o(n,e);const c=(0,y.spawnSync)(s.command,s.argv,{env:r(process.env,s),encoding:"utf8",timeout:3e4});if(c.error)throw new C("ACCOUNT_COMMAND_FAILED");const u=e??(s.command==="codex"?"cli/codex":s.command==="agy"?a:"cli/claude");if(u===a){const T=c.status===0;if(i)process.stdout.write(`${JSON.stringify({id:n,provider:u,loggedIn:T})}
|
|
3
|
+
`);else process.stdout.write(`loggedIn:${T}
|
|
4
|
+
`);return T?0:1}const d=s.env.CLAUDE_CONFIG_DIR??s.env.CODEX_HOME??Y(t,u);const l=u==="cli/codex"?`${c.stdout??""}${c.stderr??""}`:c.stdout??"";const _=q(u,l,c.status??1,d);if(i){process.stdout.write(`${JSON.stringify({id:n,provider:u,loggedIn:_.loggedIn,configDirectory:d})}
|
|
5
|
+
`)}else{process.stdout.write(`${_.lines.join("\n")}
|
|
6
|
+
`)}return _.loggedIn?0:1}function Y(n,e){return S(n,e).find(i=>i.builtIn)?.dir??""}function H(n,e,i){const t=A(i,"getLoginInvocation");const o=A(i,"applyAiAccountEnv");const r=t(n,e);process.stdout.write(`Running official login: ${r.command} ${r.argv.join(" ")}
|
|
7
|
+
`);const s=(0,y.spawnSync)(r.command,r.argv,{env:o(process.env,r),stdio:"inherit"});if(s.error)throw new C("ACCOUNT_COMMAND_FAILED");return s.status??1}function D(n,e=()=>void 0){const i=n.signalHost??process;const t=new AbortController;let o=false;let r;let s;const c=new Promise(_=>{s=_});const u=_=>{if(o||r)return;r=_;t.abort();e();s(_)};const d=()=>u("SIGINT");const l=()=>u("SIGTERM");i.on("SIGINT",d);i.on("SIGTERM",l);return{signal:t.signal,whenInterrupted:c,interruptedBy:()=>r,isCompleted:()=>o,markComplete:()=>{o=true},dispose:()=>{i.removeListener("SIGINT",d);i.removeListener("SIGTERM",l)}}}function L(n){return n==="SIGINT"?130:143}function z(n){return n.isAgentTask?.()??Boolean(process.env["CREWX_AGENT_ID"])}function W(n){return n.isInteractive?.()??(process.stdin.isTTY===true&&process.stderr.isTTY===true)}function X(n){const e=n.state==="signed-out"?"ACCOUNT_NOT_SIGNED_IN":n.state==="login-in-progress"?"ACCOUNT_LOGIN_IN_PROGRESS":n.state==="login-incomplete"?"ACCOUNT_LOGIN_INCOMPLETE":"ACCOUNT_RUNTIME_UNAVAILABLE";return m(n.code,e)}function K(n){try{const e=new URL(n);if(e.protocol!=="https:"||!e.hostname||e.username||e.password)return void 0;return e.href}catch{return void 0}}const Q=new Set(["signed-in","signed-out","runtime-missing","login-in-progress","login-incomplete","error"]);function Z(n,e,i){const t=typeof e.state==="string"&&Q.has(e.state)?e.state:"error";const o={id:n,provider:a,state:t};if(typeof e.runtimeVersion==="string")o.runtimeVersion=e.runtimeVersion;const r=m(e.code,"ACCOUNT_RUNTIME_UNAVAILABLE");if(e.code!==void 0||t==="error")o.code=r;if(i)process.stdout.write(`${JSON.stringify(o)}
|
|
8
|
+
`);else{process.stdout.write(`state:${t}
|
|
9
|
+
`);if(typeof e.runtimeVersion==="string")process.stdout.write(`runtimeVersion:${e.runtimeVersion}
|
|
10
|
+
`);if(e.code!==void 0||t==="error")process.stdout.write(`code:${r}
|
|
11
|
+
`)}if(t==="error")return 2;return t==="signed-in"?0:1}async function nn(n,e,i){const t=A(i,"getAiAccountStatus");const o=await t(n);if(!I(o))throw new C("ACCOUNT_RUNTIME_UNAVAILABLE");return Z(n,o,e)}async function en(n,e,i,t){if(e||z(t)||!W(t)){p("ACCOUNT_LOGIN_REQUIRES_LOCAL_UI","Sign in from CrewX Settings > Accounts.");return 2}const o=A(i,"startAiAccountLogin");let r;let s;const c=()=>{if(!r||typeof r.cancel!=="function")return Promise.resolve();s??=Promise.resolve().then(()=>(r?.cancel).call(r)).then(()=>void 0,()=>void 0);return s};const u=D(t,()=>{void c()});try{const d=await o(n,{signal:u.signal});if(!I(d))throw new C("ACCOUNT_LOGIN_FAILED");r=d;if(typeof r.cancel!=="function"||!("done"in r)||!("authorizationUrl"in r)){await c();throw new C("ACCOUNT_LOGIN_FAILED")}const l=Promise.resolve(r.done).then(f=>{u.markComplete();return{kind:"done",value:f}},f=>{u.markComplete();return{kind:"error",error:f}});const _=Promise.resolve(r.authorizationUrl).then(f=>{if(typeof f==="string"&&f.length>0&&!u.isCompleted()&&!u.interruptedBy()){const h=K(f);if(h){process.stderr.write(`Open this link in your browser to sign in:
|
|
12
|
+
${h}
|
|
13
|
+
`)}}return{kind:"authorization"}},()=>({kind:"authorization"}));const T=u.whenInterrupted.then(f=>({kind:"interrupted",signal:f}));const E=await Promise.race([l,_,T]);let O;let g=u.interruptedBy();if(E.kind==="done"||E.kind==="error"){O=E}else if(E.kind==="interrupted"){g=E.signal;await c();O=await l}else{const f=await Promise.race([l,T]);if(f.kind==="interrupted"){g=f.signal;await c();O=await l}else{O=f}}if(O.kind==="done"&&I(O.value)&&O.value.state==="signed-in"&&O.value.browserSuppressionObserved===true){if(e)process.stdout.write(`${JSON.stringify({id:n,provider:a,state:"signed-in"})}
|
|
14
|
+
`);else process.stdout.write(`signed-in:${n}
|
|
15
|
+
`);return 0}if(g){p("ACCOUNT_LOGIN_CANCELLED");return L(g)}p(w(O.kind==="error"?O.error:void 0,"ACCOUNT_LOGIN_FAILED"));return 2}catch(d){const l=u.interruptedBy();if(l){await c();p("ACCOUNT_LOGIN_CANCELLED");return L(l)}p(w(d,"ACCOUNT_LOGIN_FAILED"));return 2}finally{if(u.interruptedBy())await c();u.dispose()}}const tn=new Set(["unsupported_platform","not_installed","digest_mismatch","helper_path_unsupported"]);function rn(n,e){const i={provider:n,installed:e.installed===true,platformSupported:e.platformSupported===true};if(typeof e.version==="string"||e.version===null)i.version=e.version;if(typeof e.reason==="string"&&tn.has(e.reason)){i.reason=e.reason}return i}function $(n,e,i){const t=rn(n,e);if(i)process.stdout.write(`${JSON.stringify(t)}
|
|
16
|
+
`);else{process.stdout.write(`installed:${t.installed}
|
|
17
|
+
`);process.stdout.write(`version:${t.version??"none"}
|
|
18
|
+
`);process.stdout.write(`platformSupported:${t.platformSupported}
|
|
19
|
+
`);if(t.reason!==void 0)process.stdout.write(`reason:${t.reason}
|
|
20
|
+
`)}return t.installed?0:1}async function on(n,e){const i=A(e,"getAiAccountRuntimeStatus");const t=i(a);if(!I(t))throw new C("ACCOUNT_RUNTIME_UNAVAILABLE");return $(a,t,n)}async function sn(n,e,i){const t=A(e,"installAiAccountRuntime");const o=D(i);try{const r=await Promise.resolve().then(()=>t(a,{signal:o.signal})).then(s=>{o.markComplete();return{ok:true,value:s}},s=>{o.markComplete();return{ok:false,error:s}});if(!r.ok){if(o.interruptedBy()){p("ACCOUNT_INSTALL_FAILED");return L(o.interruptedBy())}p(w(r.error,"ACCOUNT_INSTALL_FAILED"));return 2}if(!I(r.value))throw new C("ACCOUNT_INSTALL_FAILED");return $(a,r.value,n)}finally{o.dispose()}}async function cn(n,e){if(n.length!==1||n[0]!=="--json"){p("ACCOUNT_OPTION_UNSUPPORTED");return 2}const i=R(e,"getAiAccountCapabilities");if(!i){p("ACCOUNT_CAPABILITIES_UNSUPPORTED");return 2}try{const t=i();if(!I(t))throw new C("ACCOUNT_CAPABILITIES_UNSUPPORTED");const o=JSON.stringify(t);if(!o)throw new C("ACCOUNT_CAPABILITIES_UNSUPPORTED");process.stdout.write(`${o}
|
|
21
|
+
`);return 0}catch(t){p(w(t,"ACCOUNT_CAPABILITIES_UNSUPPORTED"));return 2}}function un(n){return n.length===3&&n[0]==="ai-account"&&n[1]==="capabilities"&&n[2]==="--json"}async function G(n,e={}){const[i,...t]=n;if(t.includes("--help")||t.includes("-h")){process.stdout.write(`${U.AI_ACCOUNT_USAGE}
|
|
22
|
+
`);return 0}let o;try{o=e.sdk??b()}catch{p(i==="capabilities"?"ACCOUNT_CAPABILITIES_UNSUPPORTED":"ACCOUNT_RUNTIME_CAPABILITY");return 2}if(i==="capabilities")return cn(t,o);try{const r=B(t);const s=r.positional[0];switch(i){case"list":{const c=j(r.provider).flatMap(u=>S(o,u));process.stdout.write(r.json?`${JSON.stringify(c.map(V))}
|
|
23
|
+
`:`${F(c)}
|
|
24
|
+
`);return 0}case"add":{if(!r.provider)throw new N.UnknownOptionError("add requires --provider claude|codex|antigravity");if(r.label===void 0)throw new N.UnknownOptionError("add requires --label <name>");const c=A(o,"addAiAccount");const u=c(r.provider,r.label);if(r.json){const d=r.provider===a?{provider:r.provider,id:u.id}:{provider:r.provider,...u};process.stdout.write(`${JSON.stringify(d)}
|
|
25
|
+
`)}else if(r.provider===a){process.stdout.write(`added ${u.id} for ${r.provider}
|
|
26
|
+
next: crewx ai-account login ${u.id} --provider antigravity
|
|
27
|
+
`)}else{process.stdout.write(`added ${u.id} for ${r.provider}
|
|
28
|
+
configDirectory:${u.dir}
|
|
29
|
+
next: crewx ai-account login ${u.id}
|
|
30
|
+
`)}return 0}case"login":{if(!s)throw new N.UnknownOptionError(`login requires an account id
|
|
31
|
+
${U.AI_ACCOUNT_USAGE}`);if(P(s,r.provider,o)){return await en(s,r.json,o,e)}return H(s,r.provider,o)}case"status":{if(!s)throw new N.UnknownOptionError(`status requires an account id
|
|
32
|
+
${U.AI_ACCOUNT_USAGE}`);if(P(s,r.provider,o))return await nn(s,r.json,o);return J(s,r.provider,r.json,o)}case"use":{if(!s)throw new N.UnknownOptionError(`use requires an account id
|
|
33
|
+
${U.AI_ACCOUNT_USAGE}`);if(!r.provider)throw new N.UnknownOptionError("use requires --provider claude|codex|antigravity");if(r.provider===a&&s!=="default"){const u=A(o,"getAiAccountStatus");const d=await u(s);if(!I(d)||d.state!=="signed-in"){throw new C(I(d)?X(d):"ACCOUNT_RUNTIME_UNAVAILABLE")}}const c=A(o,"setActiveAiAccount");await c(r.provider,s);process.stdout.write(`active account for ${r.provider}: ${s}
|
|
34
|
+
`);return 0}case"remove":{if(!s)throw new N.UnknownOptionError(`remove requires an account id
|
|
35
|
+
${U.AI_ACCOUNT_USAGE}`);const c=S(o,a).some(l=>l.id===s&&!l.builtIn&&l.loginKind==="acp-flow");const u=c?A(o,"removeAiAccountGuarded"):A(o,"removeAiAccount");const d=await u(s);if(r.json)process.stdout.write(`${JSON.stringify(d)}
|
|
36
|
+
`);else process.stdout.write(`removed ${s}; its config directory was kept on disk
|
|
37
|
+
`);return 0}case"runtime":{const c=s;if(r.positional.length!==1||c!=="status"&&c!=="install"){throw new N.UnknownOptionError(`runtime requires status or install
|
|
38
|
+
${U.AI_ACCOUNT_USAGE}`)}if(r.provider!==void 0&&r.provider!==a){throw new C("ACCOUNT_PROVIDER_UNSUPPORTED")}return c==="status"?await on(r.json,o):await sn(r.json,o,e)}default:p("ACCOUNT_OPTION_UNSUPPORTED");return 2}}catch(r){if(r instanceof N.UnknownOptionError){p("ACCOUNT_OPTION_UNSUPPORTED");return 2}const s=i==="login"?"ACCOUNT_LOGIN_FAILED":i==="runtime"?"ACCOUNT_RUNTIME_UNAVAILABLE":"ACCOUNT_OPERATION_FAILED";p(w(r,s));return 2}}async function an(n,e={}){process.exitCode=await G(n,e)}
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
export declare const INIT_USAGE = "Usage: crewx init [--force] [--provider cli/claude|cli/codex]\n\nCreate crewx.yaml, support folders, and a git repository in the current folder.\n\n --force Overwrite the existing configuration\n --provider cli/claude|cli/codex Provider for the generated agents\n (detected from PATH when omitted)";
|
|
9
9
|
export declare const STOP_USAGE = "Usage:\n crewx stop <task-id> [--grace=<ms>] Stop a running task\n crewx stop --all Stop all running tasks\n crewx kill <task-id> Alias for stop";
|
|
10
10
|
export declare const RESTART_USAGE = "Usage: crewx restart <task-id>\n\nRestart a failed task as a new task, reusing its thread, agent, and provider.";
|
|
11
|
+
export declare const AI_ACCOUNT_USAGE = "Usage:\n crewx ai-account list [--provider claude|cli/claude|codex|cli/codex|antigravity|cli/antigravity] [--json]\n crewx ai-account add --provider claude|cli/claude|codex|cli/codex|antigravity|cli/antigravity --label <name> [--json]\n crewx ai-account login <id> [--provider claude|cli/claude|codex|cli/codex|antigravity|cli/antigravity] [--json]\n crewx ai-account status <id> [--provider claude|cli/claude|codex|cli/codex|antigravity|cli/antigravity] [--json]\n crewx ai-account use <id> --provider claude|cli/claude|codex|cli/codex|antigravity|cli/antigravity\n crewx ai-account remove <id> [--json]\n crewx ai-account capabilities --json\n crewx ai-account runtime status [--json]\n crewx ai-account runtime install [--json]\n\nAntigravity account login requires a local interactive terminal. If a login is needed\nfrom an agent task or a non-interactive command, sign in from CrewX Settings > Accounts.\nRuntime installation is explicit; list, account status, and task execution never install it.\n\nAntigravity exit codes:\n 0 Operation completed; status commands report signed-in or installed.\n 1 Account is signed-out, or runtime is unsupported, missing, or corrupt.\n 2 Invalid usage or an SDK operation failed; stderr contains a stable error code.\n 130 Cancelled with SIGINT (Ctrl+C), after SDK cleanup.\n 143 Cancelled with SIGTERM, after SDK cleanup.\n\nClaude/Codex login keep the official CLI exit code. Their status commands exit 0\nwhen logged in and 1 when signed out. The native Antigravity default account keeps\nthe existing agy login and status commands; native login keeps the official CLI exit code.";
|
|
11
12
|
export declare const HOOK_USAGE = "Usage: crewx hook install|uninstall|status [options]\n\n install [--yes] [--provider claude|codex] Install the PreToolUse hook in .claude/settings.json\n uninstall [--provider claude|codex] Remove the crewx hook\n status Show hook installation status and plugins";
|
|
12
13
|
export declare const HOOK_DISPATCH_USAGE = "Usage: crewx hook-dispatch --provider <claude|codex>\n\nInternal IPC router: reads one hook payload from stdin and writes the decision to stdout.\nAgent CLI hooks call it; people do not need to run it.";
|
|
13
14
|
export declare const HISTORY_USAGE = "Usage:\n crewx history toc <ref> [--from N] [--limit N]\n crewx history search <ref> (--query <text> | --query-stdin | --query64 <base64url>) [--limit N] [--cursor C]\n crewx history read <ref> --entry N [--offset B] [--bytes B]\n\nRead bounded pages from original messages, activity, and highlights for the current task.\nSearch is literal and accepts up to 256 UTF-8 bytes; --limit accepts 1-20 results.\n--query-stdin reads through EOF, validates UTF-8, and removes at most one trailing LF or CRLF.\nGenerated search continuations use portable --query64 arguments.\n\nExit codes: 2 invalid arguments/query/ref/cursor; 3 missing, expired, out-of-scope, or unavailable data; 4 tampered or unsafe history data.\nSize and I/O failures use exit code 3.";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.AGENT_INTERCEPTOR_USAGE=exports.AGENT_PROMPT_USAGE=exports.AGENT_LS_USAGE=exports.AGENT_USAGE=exports.SLACK_USAGE=exports.HISTORY_USAGE=exports.HOOK_DISPATCH_USAGE=exports.HOOK_USAGE=exports.RESTART_USAGE=exports.STOP_USAGE=exports.INIT_USAGE=void 0;exports.isHelpRequest=
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.AGENT_INTERCEPTOR_USAGE=exports.AGENT_PROMPT_USAGE=exports.AGENT_LS_USAGE=exports.AGENT_USAGE=exports.SLACK_USAGE=exports.HISTORY_USAGE=exports.HOOK_DISPATCH_USAGE=exports.HOOK_USAGE=exports.AI_ACCOUNT_USAGE=exports.RESTART_USAGE=exports.STOP_USAGE=exports.INIT_USAGE=void 0;exports.isHelpRequest=r;exports.agentHelpUsage=i;exports.helpUsageFor=s;exports.INIT_USAGE=`Usage: crewx init [--force] [--provider cli/claude|cli/codex]
|
|
2
2
|
|
|
3
3
|
Create crewx.yaml, support folders, and a git repository in the current folder.
|
|
4
4
|
|
|
@@ -9,7 +9,31 @@ Create crewx.yaml, support folders, and a git repository in the current folder.
|
|
|
9
9
|
crewx stop --all Stop all running tasks
|
|
10
10
|
crewx kill <task-id> Alias for stop`;exports.RESTART_USAGE=`Usage: crewx restart <task-id>
|
|
11
11
|
|
|
12
|
-
Restart a failed task as a new task, reusing its thread, agent, and provider.`;exports.
|
|
12
|
+
Restart a failed task as a new task, reusing its thread, agent, and provider.`;exports.AI_ACCOUNT_USAGE=`Usage:
|
|
13
|
+
crewx ai-account list [--provider claude|cli/claude|codex|cli/codex|antigravity|cli/antigravity] [--json]
|
|
14
|
+
crewx ai-account add --provider claude|cli/claude|codex|cli/codex|antigravity|cli/antigravity --label <name> [--json]
|
|
15
|
+
crewx ai-account login <id> [--provider claude|cli/claude|codex|cli/codex|antigravity|cli/antigravity] [--json]
|
|
16
|
+
crewx ai-account status <id> [--provider claude|cli/claude|codex|cli/codex|antigravity|cli/antigravity] [--json]
|
|
17
|
+
crewx ai-account use <id> --provider claude|cli/claude|codex|cli/codex|antigravity|cli/antigravity
|
|
18
|
+
crewx ai-account remove <id> [--json]
|
|
19
|
+
crewx ai-account capabilities --json
|
|
20
|
+
crewx ai-account runtime status [--json]
|
|
21
|
+
crewx ai-account runtime install [--json]
|
|
22
|
+
|
|
23
|
+
Antigravity account login requires a local interactive terminal. If a login is needed
|
|
24
|
+
from an agent task or a non-interactive command, sign in from CrewX Settings > Accounts.
|
|
25
|
+
Runtime installation is explicit; list, account status, and task execution never install it.
|
|
26
|
+
|
|
27
|
+
Antigravity exit codes:
|
|
28
|
+
0 Operation completed; status commands report signed-in or installed.
|
|
29
|
+
1 Account is signed-out, or runtime is unsupported, missing, or corrupt.
|
|
30
|
+
2 Invalid usage or an SDK operation failed; stderr contains a stable error code.
|
|
31
|
+
130 Cancelled with SIGINT (Ctrl+C), after SDK cleanup.
|
|
32
|
+
143 Cancelled with SIGTERM, after SDK cleanup.
|
|
33
|
+
|
|
34
|
+
Claude/Codex login keep the official CLI exit code. Their status commands exit 0
|
|
35
|
+
when logged in and 1 when signed out. The native Antigravity default account keeps
|
|
36
|
+
the existing agy login and status commands; native login keeps the official CLI exit code.`;exports.HOOK_USAGE=`Usage: crewx hook install|uninstall|status [options]
|
|
13
37
|
|
|
14
38
|
install [--yes] [--provider claude|codex] Install the PreToolUse hook in .claude/settings.json
|
|
15
39
|
uninstall [--provider claude|codex] Remove the crewx hook
|
|
@@ -60,4 +84,4 @@ List configured agents. Filters take comma-separated values; --provider also mat
|
|
|
60
84
|
Print the fully rendered system prompt of one agent.`;exports.AGENT_INTERCEPTOR_USAGE=`Usage: crewx agent interceptor test <id> --phase request|response --text "<text>" [--json]
|
|
61
85
|
|
|
62
86
|
Run an agent's interceptor chain once on a text without starting the agent.
|
|
63
|
-
Exit 0 when the lane passes; exit 1 when it is blocked or the chain configuration is invalid.`;function
|
|
87
|
+
Exit 0 when the lane passes; exit 1 when it is blocked or the chain configuration is invalid.`;function r(e){return e.includes("--help")||e.includes("-h")}function i(e){const t=e.filter((a,n)=>e[n-1]!=="--text");if(!r(t))return void 0;switch((e[0]??"").toLowerCase()){case"ls":case"list":return exports.AGENT_LS_USAGE;case"prompt":case"p":return exports.AGENT_PROMPT_USAGE;case"interceptor":return exports.AGENT_INTERCEPTOR_USAGE;default:return exports.AGENT_USAGE}}function s(e,t){if(e==="history"){const a=t[0];if(a==="--help"||a==="-h")return exports.HISTORY_USAGE;if(t.length===2&&(a==="toc"||a==="search"||a==="read")&&(t[1]==="--help"||t[1]==="-h"))return exports.HISTORY_USAGE;return void 0}if(!r(t))return void 0;switch(e){case"agent":return i(t);case"init":return exports.INIT_USAGE;case"stop":case"kill":return exports.STOP_USAGE;case"restart":return exports.RESTART_USAGE;case"ai-account":return exports.AI_ACCOUNT_USAGE;case"hook":return exports.HOOK_USAGE;case"hook-dispatch":return exports.HOOK_DISPATCH_USAGE;case"slack":case"slack:files":return exports.SLACK_USAGE;default:return void 0}}
|
|
@@ -71,12 +71,31 @@ export type AssignedTaskAdoption = {
|
|
|
71
71
|
export declare function adoptAssignedTask(taskRepo: Pick<TaskRepository, 'adoptPendingTask'>, taskId: string, detachedRunner: boolean): AssignedTaskAdoption;
|
|
72
72
|
/** Read the actor persisted on the receipt after the runner adopts it. */
|
|
73
73
|
export declare function readAssignedTaskActor(taskRepo: Pick<TaskRepository, 'getTask'>, taskId: string): TaskActor;
|
|
74
|
+
export interface RecordedTaskProviderAccountBinding {
|
|
75
|
+
provider?: string;
|
|
76
|
+
providerAccountId?: string;
|
|
77
|
+
providerAccountLabel?: string;
|
|
78
|
+
providerRuntime?: string;
|
|
79
|
+
providerRuntimeVersion?: string;
|
|
80
|
+
providerAccountAuthEpoch?: string;
|
|
81
|
+
}
|
|
82
|
+
/** Preserve SDK replay intent for recorded ACP pins, including provider drift. */
|
|
83
|
+
export declare function shouldReplayRecordedAntigravityAcp(binding: RecordedTaskProviderAccountBinding): boolean;
|
|
84
|
+
/** Build SDK option fields only from runtime pins explicitly recorded on a task. */
|
|
85
|
+
export declare function buildRecordedProviderAccountOptions(binding: RecordedTaskProviderAccountBinding | undefined): Record<string, string>;
|
|
86
|
+
/** Parse only provider pins explicitly recorded on a task. */
|
|
87
|
+
export declare function readTaskProviderAccountBinding(metadata: unknown): RecordedTaskProviderAccountBinding;
|
|
88
|
+
/**
|
|
89
|
+
* Read the provider/account/runtime binding from the adopted task row. All
|
|
90
|
+
* values come from task metadata, never from process.env or a conversation id.
|
|
91
|
+
*/
|
|
92
|
+
export declare function readAssignedTaskProviderAccountBinding(taskRepo: Pick<TaskRepository, 'getTask'>, taskId: string): RecordedTaskProviderAccountBinding;
|
|
74
93
|
/**
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
* from the row, never from process.env. Absent or unreadable metadata means
|
|
78
|
-
* "no pin": the SDK resolves the account as for any other run.
|
|
94
|
+
* Merge authoritative recorded pins into SDK metadata. Caller-supplied pin
|
|
95
|
+
* fields are discarded so they cannot change the adopted task's account.
|
|
79
96
|
*/
|
|
97
|
+
export declare function mergeAssignedTaskProviderAccountMetadata(metadata: Record<string, unknown>, binding: RecordedTaskProviderAccountBinding): Record<string, unknown>;
|
|
98
|
+
/** Backward-compatible accessor for callers that only need the account id. */
|
|
80
99
|
export declare function readAssignedTaskProviderAccountId(taskRepo: Pick<TaskRepository, 'getTask'>, taskId: string): string | undefined;
|
|
81
100
|
export interface DetachedMiddleHop {
|
|
82
101
|
taskId: string;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.resolveCliTaskActor=
|
|
2
|
-
`)}const
|
|
3
|
-
`);return false}const
|
|
4
|
-
`);return false}function I(e,t,n,
|
|
5
|
-
`);return}if(
|
|
6
|
-
`);process.stdout.write(`${
|
|
7
|
-
`);process.stderr.write(`Task ${
|
|
8
|
-
`);if(
|
|
9
|
-
`);const
|
|
10
|
-
`);return{kind:"failed"}}process.stderr.write(`${
|
|
11
|
-
`);return{kind:"stale"}}function
|
|
12
|
-
`);process.exit(1);return}process.exit(0)}async function
|
|
13
|
-
`);(0,
|
|
14
|
-
`);process.exit(2);return}const
|
|
15
|
-
`);process.exit(1);return}
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.resolveCliTaskActor=b;exports.resolveReceiptActor=B;exports.reportAdmissionBlocked=X;exports.extractReceiptFlags=Ae;exports.resolveReceiptMode=me;exports.buildDetachedRunnerArgs=z;exports.adoptAssignedTask=we;exports.readAssignedTaskActor=Te;exports.shouldReplayRecordedAntigravityAcp=ee;exports.buildRecordedProviderAccountOptions=Re;exports.readTaskProviderAccountBinding=re;exports.readAssignedTaskProviderAccountBinding=te;exports.mergeAssignedTaskProviderAccountMetadata=ye;exports.readAssignedTaskProviderAccountId=Ie;exports.readDetachedMiddleHop=De;exports.runDetachedMiddle=$e;exports.runDetached=Ne;const P=require("child_process");const p=require("fs");const E=require("path");const se=require("os");const y=require("@crewx/sdk");const ce=require("@crewx/sdk/node");const de=require("@crewx/sdk/repository");const ae=require("./parse-agent-message");const j=require("./parse-common-flags");const ue=require("./resolve-recipient");const pe=require("./resolve-prompt");const le=require("../utils/version");const G=require("../utils/inherited-trace");const U=require("./cal");const fe=require("./emit-trailer");function F(r){return typeof r==="string"&&r.trim().length>0?r.trim():void 0}function b(r,e=process.env["CREWX_AGENT_ID"]){const t=F(r.schedule_id);if(t)return{actorKind:"system",actorId:`cron:${t}`};const n=r.workflow;const o=n!==null&&typeof n==="object"&&!Array.isArray(n)?n:void 0;const i=F(o?.exec_id);if(i)return{actorKind:"system",actorId:`workflow:${i}`};const s=F(e);if(s)return{actorKind:"agent",actorId:s};if(process.stdin.isTTY===true||process.stderr.isTTY===true){return{actorKind:"human",actorId:(0,ce.getLocalActorId)()}}return{actorKind:"unknown",actorId:null}}function B(r,e=process.env["CREWX_AGENT_ID"]){const t=b(r,e);return{kind:t.actorKind,id:t.actorId}}function X(r){process.stderr.write(`${r.message}
|
|
2
|
+
`)}const _e=200;const J=3e4;const ve=["--to","--thread","--provider","--model","--metadata","--config","-c","--output-format","--effort","--prompt-file","-f","--out","-o"];const Y="--__crewx-detached-middle";const C="--__crewx-detached-task";const L="--__crewx-detached-log";const M="--__crewx-detached-token";const O="CREWX_DETACHED_HOP_TOKEN";function he(r){return ve.some(e=>r===e||r.startsWith(`${e}=`))}function ge(r){return r==="--prompt-file"||r==="-f"||r.startsWith("--prompt-file=")||r.startsWith("-f=")}function Ae(r){const e=[];let t=false;let n=false;let o=false;for(const i of r){if(!o&&i==="--"){o=true;e.push(i);continue}if(!o&&(i==="--detach"||i==="--async")){t=true;continue}if(!o&&(i==="--wait"||i.startsWith("--wait="))){n=true;continue}e.push(i)}return{detach:t,wait:n,rest:e}}function me(r){if(r.wait)return{receipt:false,reason:"wait"};if(r.detachedRunner)return{receipt:false,reason:"detached-runner"};if(r.detach)return{receipt:true,reason:"explicit-detach"};if(r.agentContext)return{receipt:true,reason:"agent-context"};return{receipt:false,reason:"default"}}function v(r){return r instanceof Error?r.message:String(r)}function ke(r,e,t,n={}){return new Promise((o,i)=>{let s=false;let c;let h;const k=()=>{if(c!==void 0)clearInterval(c);if(h!==void 0)clearTimeout(h)};const w=d=>{if(s)return;s=true;k();o(d)};const g=(d,_=false)=>{try{const l=r.getTask(e);if(l&&l.status!=="pending"){w({kind:"adopted"});return}if(d!==void 0){w({kind:"exited",reason:d});return}if(_)w({kind:"timeout"})}catch(l){if(s)return;s=true;k();i(l)}};t.on("error",d=>{g(`Runner failed before adopting task: ${v(d)}`)});t.on("exit",(d,_)=>{if(n.ignoreSuccessfulExit&&d===0&&_===null)return;const l=_?`signal ${_}`:`exit ${d??"unknown"}`;g(`Runner exited before adopting task (${l})`)});c=setInterval(()=>g(),_e);h=setTimeout(()=>g(void 0,true),J);g()})}function q(r,e,t){try{const n=r.failPendingTask(e,t);if(n){process.stderr.write(`Detached task ${e} failed: ${t}
|
|
3
|
+
`);return false}const o=r.getTask(e);if(o&&o.status!=="pending")return true}catch(n){t+=`; could not persist failure: ${v(n)}`}process.stderr.write(`Detached task ${e} failed: ${t}
|
|
4
|
+
`);return false}function I(r,e,t,n,o,i,s){let c="pending";try{const k=r.getTask(e);c=k?.status==="pending"?"pending":"running"}catch{}if(i==="json"){process.stdout.write(`${JSON.stringify({taskId:e,status:c,mode:"receipt",logPath:t})}
|
|
5
|
+
`);return}if(o)process.stderr.write(`mode=receipt reason=${n}
|
|
6
|
+
`);process.stdout.write(`${e}
|
|
7
|
+
`);process.stderr.write(`Task ${e} accepted. This ID is the handle (not a PID).
|
|
8
|
+
`);if(s&&o)process.stderr.write(`${s}
|
|
9
|
+
`);const h=(0,U.suggestWaitSeconds)({startedAt:null});(0,U.writeCalFooter)({commandId:"crewx.receipt",params:{taskId:e,wait:String(h)}})}function z(r,e,t){const n=[];for(let o=0;o<r.length;o+=1){const i=r[o];if(i==="--")break;if(i==="--verbose"||i==="--overdrive"){n.push(i);continue}if(i==="--var"){const s=r[o+1];if(s!==void 0){n.push(i,s);o+=1}continue}if(i.startsWith("--var=")){n.push(i);continue}if(i==="--to"){o+=1;continue}if(i.startsWith("--to="))continue;if(!he(i))continue;if(ge(i)){if(!i.includes("="))o+=1;continue}n.push(i);if(!i.includes("=")){const s=r[o+1];if(s!==void 0){n.push(s);o+=1}}}return[...n,...e?[e]:[],"--",t]}function Q(r){if(r==="execute")return"x";if(r==="query")return"q";return r}function Z(r){const e={...process.env};delete e[O];if(process.versions.electron){e.ELECTRON_RUN_AS_NODE="1"}e.CREWX_DETACHED_RUNNER="1";e.CREWX_ASSIGNED_TASK_ID=r;return e}function we(r,e,t){if(r.adoptPendingTask(e)){return{kind:"adopted",taskId:e}}const n=`stale assigned id ${e}: expected pending task with pid NULL`;if(t){process.stderr.write(`Detached runner failed to adopt task ${e}: ${n}
|
|
10
|
+
`);return{kind:"failed"}}process.stderr.write(`${n}
|
|
11
|
+
`);return{kind:"stale"}}function Te(r,e){const t=r.getTask(e);const n=t?.actor_kind;if(n===null||n===void 0){return{actorKind:"unknown",actorId:null}}if(n==="human"||n==="agent"||n==="system"||n==="unknown"){return{actorKind:n,actorId:t?.actor_id??null}}return{actorKind:"unknown",actorId:t?.actor_id??null}}function ee(r){if(r.providerRuntime==="acp"||r.providerRuntimeVersion!==void 0||r.providerAccountAuthEpoch!==void 0)return true;return r.provider==="cli/antigravity"&&r.providerAccountId!==void 0&&r.providerAccountId!=="default"}function Re(r){const e={};if(r?.providerAccountId!==void 0)e.providerAccountId=r.providerAccountId;if(r?.providerRuntime!==void 0)e.providerAccountRuntime=r.providerRuntime;if(r?.providerRuntimeVersion!==void 0)e.providerAccountRuntimeVersion=r.providerRuntimeVersion;if(r?.providerAccountAuthEpoch!==void 0)e.providerAccountAuthEpoch=r.providerAccountAuthEpoch;return e}const Ee=["provider_account_id","provider_runtime","provider_runtime_version","provider_account_auth_epoch"];function re(r){if(typeof r!=="object"||r===null||Array.isArray(r))return{};const e=r;const t={};if(typeof e.provider==="string"&&e.provider.trim().length>0){t.provider=e.provider}if(typeof e.provider_account_id==="string"&&e.provider_account_id.trim().length>0){t.providerAccountId=e.provider_account_id.trim()}if(typeof e.provider_account_label==="string"&&e.provider_account_label.length>0){t.providerAccountLabel=e.provider_account_label}if(typeof e.provider_runtime==="string"&&e.provider_runtime.trim().length>0){t.providerRuntime=e.provider_runtime}if(typeof e.provider_runtime_version==="string"&&e.provider_runtime_version.trim().length>0){t.providerRuntimeVersion=e.provider_runtime_version}if(typeof e.provider_account_auth_epoch==="string"&&e.provider_account_auth_epoch.trim().length>0){t.providerAccountAuthEpoch=e.provider_account_auth_epoch}return t}function te(r,e){const t=r.getTask(e)?.metadata;if(!t)return{};try{return re(JSON.parse(t))}catch{return{}}}function ye(r,e){const t={...r};for(const n of Ee)delete t[n];if(e.provider!==void 0)t.provider=e.provider;if(e.providerAccountId!==void 0)t.provider_account_id=e.providerAccountId;if(ee(e)){delete t.provider_account_label;if(e.providerAccountLabel!==void 0)t.provider_account_label=e.providerAccountLabel}if(e.providerRuntime!==void 0)t.provider_runtime=e.providerRuntime;if(e.providerRuntimeVersion!==void 0)t.provider_runtime_version=e.providerRuntimeVersion;if(e.providerAccountAuthEpoch!==void 0)t.provider_account_auth_epoch=e.providerAccountAuthEpoch;return t}function Ie(r,e){return te(r,e).providerAccountId}function xe(r){const e={...process.env};if(process.versions.electron){e.ELECTRON_RUN_AS_NODE="1"}e[O]=r;return e}function De(r){let e=false;let t;let n;let o;let i=false;const s=[];for(const c of r){if(!i&&c==="--"){i=true;s.push(c);continue}if(!i&&c===Y){e=true;continue}if(!i&&c.startsWith(`${C}=`)){t=c.slice(`${C}=`.length);continue}if(!i&&c.startsWith(`${L}=`)){n=c.slice(`${L}=`.length);continue}if(!i&&c.startsWith(`${M}=`)){o=c.slice(`${M}=`.length);continue}s.push(c)}if(!e||!t||!n||!o||o!==process.env[O]){return void 0}return{taskId:t,logPath:n,runnerArgs:s}}async function $e(r,e){let t;try{const n=(0,E.dirname)(e.logPath);if(!(0,p.existsSync)(n))(0,p.mkdirSync)(n,{recursive:true});t=(0,p.openSync)(e.logPath,"a");const o=process.argv[1];const i=(0,P.spawn)(process.execPath,[o,Q(r),...e.runnerArgs],{detached:true,windowsHide:true,stdio:["ignore",t,t],env:Z(e.taskId)});(0,p.closeSync)(t);t=void 0;i.unref()}catch(n){if(t!==void 0)(0,p.closeSync)(t);process.stderr.write(`Runner failed before adopting task: ${v(n)}
|
|
12
|
+
`);process.exit(1);return}process.exit(0)}async function Ne(r,e,t,n=e){const o=(0,j.parseCommonFlags)(e);const{thread:i,metadata:s,promptFile:c,rest:h,to:k}=o;const{agentRef:w,message:g}=(0,ae.parseAgentMessage)(h);const d=await(0,pe.resolvePrompt)(g,c);let _;try{({agentRef:_}=(0,ue.resolveRecipient)({positionalRef:w,toFlag:k,agentContext:Boolean(process.env["CREWX_AGENT_ID"]),bodyForHint:d,command:r,invocationArgs:n}))}catch(u){const R=v(u);process.stderr.write(`Error: ${R}
|
|
13
|
+
`);(0,fe.emitDelegationResult)({command:r,trace:(0,G.readInheritedTrace)(),isError:true});process.exit(2);return}if(!d){console.error("Usage: crewx q|x --to <agent> <message> [options]");console.error(" @agent is a positional shorthand for selecting a recipient.");console.error(" Task body can also be supplied via stdin pipe or --prompt-file.");process.exit(1);return}let l;try{l=(0,j.parseMetadata)(s)}catch(u){process.stderr.write(`Error: ${v(u)}
|
|
14
|
+
`);process.exit(2);return}const T=(0,y.admitDurableTask)(`direct-cli:${r}`);if(!T.ok){X(T);process.exit(1);return}const a=T.taskId;const ne=new Date().toISOString();const x=process.cwd();const oe=(0,p.existsSync)((0,E.join)(x,"crewx.yaml"))||(0,p.existsSync)((0,E.join)(x,"crewx.yml"));const N=(0,G.readInheritedTrace)();const ie=N?.rootTraceId||a;const f=new de.TaskRepository;const W=B(l);try{f.startTask({id:a,agentId:_.replace(/^@/,""),actorKind:W.kind,actorId:W.id,prompt:d,mode:r==="q"||r==="query"?"query":"execute",status:"pending",startedAt:ne,pid:null,parentTaskId:N?.parentTaskId??null,callerAgentId:N?.callerAgentId??null,traceId:ie,command:process.argv.join(" "),metadata:Object.keys(l).length>0?JSON.stringify(l):null,workspaceId:oe?(0,y.hashWorkspaceId)((0,y.resolveWorkspaceOwnerPath)(x)):null,cwd:(0,y.normalizeWorkspacePath)(x),projectId:null,platform:"cli",crewxVersion:le.CLI_VERSION,threadId:i??null})}catch(u){T.release();process.stderr.write(`Failed to create detached task receipt: ${v(u)}
|
|
15
|
+
`);process.exit(1);return}T.release();const K=z(e,_,d);const H=Q(r);const S=(0,E.join)((0,se.homedir)(),".crewx","logs");const A=(0,E.join)(S,`${a}.log`);let m;let D;let V=false;try{if(!(0,p.existsSync)(S))(0,p.mkdirSync)(S,{recursive:true});if(process.platform==="win32"){V=true;const u=(0,y.generateId)("req");D=(0,P.spawn)(process.execPath,[process.argv[1],H,Y,`${C}=${a}`,`${L}=${A}`,`${M}=${u}`,...K],{detached:true,windowsHide:true,stdio:"ignore",env:xe(u)})}else{m=(0,p.openSync)(A,"a");D=(0,P.spawn)(process.execPath,[process.argv[1],H,...K],{detached:true,windowsHide:true,stdio:["ignore",m,m],env:Z(a)});(0,p.closeSync)(m);m=void 0}D.unref()}catch(u){if(m!==void 0)(0,p.closeSync)(m);const R=`Runner failed before adopting task: ${v(u)}`;if(!q(f,a,R))process.exit(1);else{I(f,a,A,t,o.verbose,o.outputFormat);process.exit(0)}return}let $;try{$=await ke(f,a,D,{ignoreSuccessfulExit:V})}catch(u){const R=`Runner adoption check failed: ${v(u)}`;if(!q(f,a,R))process.exit(1);else{I(f,a,A,t,o.verbose,o.outputFormat);process.exit(0)}return}if($.kind==="adopted"){I(f,a,A,t,o.verbose,o.outputFormat);process.exit(0);return}if($.kind==="timeout"){I(f,a,A,t,o.verbose,o.outputFormat,`Warning: runner alive, row not yet adopted after ${J/1e3}s.`);process.exit(0);return}if(!q(f,a,$.reason))process.exit(1);else{I(f,a,A,t,o.verbose,o.outputFormat);process.exit(0)}}
|
package/dist/commands/execute.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.runDetachedMiddle=void 0;exports.handleExecute=
|
|
2
|
-
`);(0,
|
|
3
|
-
`);process.stderr.write(`\u{1F4CB} Task: ${
|
|
4
|
-
`);process.stderr.write(`\u{1F916} Agent: ${
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.runDetachedMiddle=void 0;exports.handleExecute=Z;const j=require("@crewx/sdk");const z=require("@crewx/sdk/repository");const K=require("./parse-agent-message");const N=require("./parse-common-flags");const L=require("./resolve-recipient");const Q=require("./resolve-prompt");const S=require("../bootstrap/crewx-cli");const m=require("../utils/inherited-trace");const D=require("./write-output");const t=require("./detached");const a=require("./emit-trailer");var Y=require("./detached");Object.defineProperty(exports,"runDetachedMiddle",{enumerable:true,get:function(){return Y.runDetachedMiddle}});async function Z(p,r="execute",n=(0,a.createDelegationEmitState)()){const b=(0,t.readDetachedMiddleHop)(p);if(b){await(0,t.runDetachedMiddle)(r,b);return}const f=(0,t.extractReceiptFlags)(p);const k=(0,t.resolveReceiptMode)({detach:f.detach,wait:f.wait,detachedRunner:(0,m.isDetachedRunner)(),agentContext:Boolean(process.env["CREWX_AGENT_ID"])});if(k.receipt){await(0,t.runDetached)(r,f.rest,k.reason,p);return}let I;try{I=(0,N.parseCommonFlags)(f.rest)}catch(e){(0,a.emitDelegationResult)({command:r,isError:true,state:n});throw e}const{thread:x,provider:R,model:E,metadata:B,verbose:g,config:H,outputFormat:M,effort:y,promptFile:G,overdrive:T,vars:$,out:_,rest:W,to:X}=I;const i=(0,m.readInheritedTrace)();let q;let C;let d;try{({agentRef:q,message:C}=(0,K.parseAgentMessage)(W));d=await(0,Q.resolvePrompt)(C,G)}catch(e){(0,a.emitDelegationResult)({command:r,trace:i,isError:true,state:n});throw e}let h;try{({agentRef:h}=(0,L.resolveRecipient)({positionalRef:q,toFlag:X,agentContext:Boolean(process.env["CREWX_AGENT_ID"]),bodyForHint:d,command:r,invocationArgs:p}))}catch(e){const o=e instanceof Error?e.message:String(e);process.stderr.write(`Error: ${o}
|
|
2
|
+
`);(0,a.emitDelegationResult)({command:r,trace:i,isError:true,state:n});process.exit(2);return}if(!d){console.error("Usage: crewx execute --to <agent> <task> [options]");console.error(" crewx x --to <agent> <task> [options]");console.error(' Human-terminal shorthand: crewx x "@agent <task>"');console.error("");console.error(" Agent calls require --to or a positional @agent recipient.");console.error(" Human terminal and cron calls default to @crewx when omitted.");console.error(" Task body can also be supplied via stdin pipe or --prompt-file.");console.error("");console.error("Examples:");console.error(' crewx x --to agent "do something"');console.error(" crewx x --to agent -f task.md");console.error(" Prompt files contain only the body; set the recipient separately with --to.");console.error("");console.error("Options:");console.error(" --to <agent> Explicit agent recipient");console.error(" --thread <name> Conversation thread name");console.error(" --provider <cli/xxx> Provider override");console.error(" --model <name> Model override (e.g. claude-sonnet-5)");console.error(" --metadata <json> Extra metadata (JSON object, double-quoted).");console.error(" Propagated to events/hooks/tracing.");console.error(" Invalid JSON aborts with exit code 2.");console.error(` e.g. --metadata='{"workflow_id":"wf-1"}'`);console.error(" --verbose Debug output mode");console.error(" --config/-c <path> Config file path");console.error(" --output-format <fmt> Output format (json|text|stream-json)");console.error(" --out/-o <path> Save result to file (stdout suppressed)");console.error(" --effort <level> Model effort (high|medium|low)");console.error(" -f/--prompt-file <path> Read body only from file; set recipient separately with --to");console.error(" --var key=value Template variable (repeatable)");console.error(" --overdrive Activate overdrive (boost) profile for this request");(0,a.emitDelegationResult)({command:r,trace:i,isError:true,state:n});process.exit(1);return}const J=H??process.env.CREWX_CONFIG??"crewx.yaml";(0,j.setAuditVerbose)(g);let A;try{A=await(0,S.createCliCrewx)(J)}catch(e){(0,a.emitDelegationResult)({command:r,trace:i,isError:true,state:n});throw e}if(g){process.stderr.write(`mode=sync reason=${k.reason}
|
|
3
|
+
`);process.stderr.write(`\u{1F4CB} Task: ${d}
|
|
4
|
+
`);process.stderr.write(`\u{1F916} Agent: ${h}
|
|
5
5
|
`);if(x)process.stderr.write(`\u{1F517} Thread: ${x}
|
|
6
|
-
`);if(
|
|
6
|
+
`);if(R)process.stderr.write(`\u{1F50C} Provider: ${R}
|
|
7
7
|
`);if(E)process.stderr.write(`\u{1F9E0} Model: ${E}
|
|
8
|
-
`);if(
|
|
9
|
-
`);if(
|
|
10
|
-
`);if(
|
|
11
|
-
`);(0,
|
|
12
|
-
\u{1F4CA} Results from ${
|
|
13
|
-
`);process.stderr.write("\u2550".repeat(60)+"\n");process.stderr.write("\u{1F7E2} Status: Success\n");process.stderr.write(`\u{1F916} Provider: ${
|
|
14
|
-
`);process.stderr.write(`\u23F1\uFE0F Duration: ${
|
|
15
|
-
`);process.stderr.write("\n\u{1F4C4} Response:\n");process.stderr.write("\u2500".repeat(40)+"\n")}(0,D.writeResult)(_,
|
|
8
|
+
`);if(M)process.stderr.write(`\u{1F4C4} Output-format: ${M}
|
|
9
|
+
`);if(y)process.stderr.write(`\u26A1 Effort: ${y}
|
|
10
|
+
`);if(T)process.stderr.write("\u{1F680} Overdrive: ON\n");process.stderr.write("\u2500".repeat(60)+"\n")}let v={};try{v=(0,N.parseMetadata)(B)}catch(e){const o=e instanceof Error?e.message:String(e);process.stderr.write(`Error: ${o}
|
|
11
|
+
`);(0,a.emitDelegationResult)({command:r,trace:i,isError:true,state:n});process.exit(2);return}const U=(0,t.resolveCliTaskActor)(v);const V=(0,m.isDetachedRunner)();const O=(0,m.readRunnerAssignment)();let w;let P;let c;if(O!==void 0){const e=new z.TaskRepository;const o=(0,t.adoptAssignedTask)(e,O,V);if(o.kind==="failed"){(0,a.emitDelegationResult)({command:r,trace:i,isError:true,state:n});process.exit(1);return}if(o.kind==="adopted"){w=o.taskId;P=(0,t.readAssignedTaskActor)(e,o.taskId);c=(0,t.readAssignedTaskProviderAccountBinding)(e,o.taskId)}}let l;if(w===void 0){l=(0,j.admitDurableTask)(`direct-cli:${r}`);if(!l.ok){(0,t.reportAdmissionBlocked)(l);(0,a.emitDelegationResult)({command:r,trace:i,isError:true,state:n});process.exit(1);return}}const F=c?(0,t.mergeAssignedTaskProviderAccountMetadata)(v,c):v;let u=0;let s;try{try{s=await A.execute(h,d,{provider:c?.provider??R,model:E,effort:y||void 0,overdrive:T||void 0,threadId:x,taskId:w,actor:w===void 0?U:P,metadata:Object.keys(F).length>0?F:void 0,vars:Object.keys($).length>0?$:void 0,trace:i,...(0,t.buildRecordedProviderAccountOptions)(c),...c&&(0,t.shouldReplayRecordedAntigravityAcp)(c)?{providerAccountReplay:true}:{}});if(!s.ok){const e=s.error?.message??"Execute failed";console.error(e);(0,D.appendError)(_,e);u=1}else{if(g){process.stderr.write(`
|
|
12
|
+
\u{1F4CA} Results from ${h}:
|
|
13
|
+
`);process.stderr.write("\u2550".repeat(60)+"\n");process.stderr.write("\u{1F7E2} Status: Success\n");process.stderr.write(`\u{1F916} Provider: ${s.meta.provider}
|
|
14
|
+
`);process.stderr.write(`\u23F1\uFE0F Duration: ${s.meta.durationMs}ms
|
|
15
|
+
`);process.stderr.write("\n\u{1F4C4} Response:\n");process.stderr.write("\u2500".repeat(40)+"\n")}(0,D.writeResult)(_,s.data);if(g)process.stderr.write("\n\u2705 Execute completed successfully\n")}}catch(e){const o=e instanceof Error?e.message:String(e);console.error(`Error: ${o}`);(0,D.appendError)(_,`Error: ${o}`);u=1}finally{try{await A.close()}catch(e){(0,a.emitDelegationResult)({command:r,trace:i,taskId:s?.meta.taskId,agentId:s?.meta.agentId,isError:true,state:n});throw e}}}finally{if(l?.ok)l.release()}(0,a.emitDelegationResult)({command:r,trace:i,taskId:s?.meta.taskId,agentId:s?.meta.agentId,isError:u!==0||s?.ok===false,state:n});if(u!==0)process.exit(u)}
|
package/dist/commands/query.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.handleQuery=
|
|
2
|
-
`);(0,
|
|
3
|
-
`);process.stderr.write(`\u{1F4CB} Task: ${
|
|
4
|
-
`);process.stderr.write(`\u{1F916} Agent: ${
|
|
5
|
-
`);if(
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.handleQuery=Y;const j=require("@crewx/sdk");const V=require("@crewx/sdk/repository");const z=require("./parse-agent-message");const N=require("./parse-common-flags");const K=require("./resolve-recipient");const L=require("./resolve-prompt");const S=require("../bootstrap/crewx-cli");const m=require("../utils/inherited-trace");const q=require("./write-output");const t=require("./detached");const a=require("./emit-trailer");async function Y(u,r="query",n=(0,a.createDelegationEmitState)()){const D=(0,t.readDetachedMiddleHop)(u);if(D){await(0,t.runDetachedMiddle)(r,D);return}const f=(0,t.extractReceiptFlags)(u);const y=(0,t.resolveReceiptMode)({detach:f.detach,wait:f.wait,detachedRunner:(0,m.isDetachedRunner)(),agentContext:Boolean(process.env["CREWX_AGENT_ID"])});if(y.receipt){await(0,t.runDetached)(r,f.rest,y.reason,u);return}let b;try{b=(0,N.parseCommonFlags)(f.rest)}catch(e){(0,a.emitDelegationResult)({command:r,isError:true,state:n});throw e}const{thread:R,provider:k,model:E,metadata:B,verbose:g,config:H,outputFormat:I,effort:_,promptFile:Q,overdrive:M,vars:T,out:x,rest:G,to:W}=b;const i=(0,m.readInheritedTrace)();let $;let C;let d;try{({agentRef:$,message:C}=(0,z.parseAgentMessage)(G));d=await(0,L.resolvePrompt)(C,Q)}catch(e){(0,a.emitDelegationResult)({command:r,trace:i,isError:true,state:n});throw e}let w;try{({agentRef:w}=(0,K.resolveRecipient)({positionalRef:$,toFlag:W,agentContext:Boolean(process.env["CREWX_AGENT_ID"]),bodyForHint:d,command:r,invocationArgs:u}))}catch(e){const o=e instanceof Error?e.message:String(e);process.stderr.write(`Error: ${o}
|
|
2
|
+
`);(0,a.emitDelegationResult)({command:r,trace:i,isError:true,state:n});process.exit(2);return}if(!d){console.error("Usage: crewx query --to <agent> <message> [options]");console.error(" crewx q --to <agent> <message> [options]");console.error(' Human-terminal shorthand: crewx q "@agent <message>"');console.error("");console.error(" Agent calls require --to or a positional @agent recipient.");console.error(" Human terminal and cron calls default to @crewx when omitted.");console.error(" Prompt can also be supplied via stdin pipe or --prompt-file.");console.error("");console.error("Examples:");console.error(' crewx q --to agent "hello"');console.error(" crewx q --to agent -f brief.md");console.error(" Prompt files contain only the body; set the recipient separately with --to.");console.error("");console.error("Options:");console.error(" --to <agent> Explicit agent recipient");console.error(" --thread <name> Conversation thread name");console.error(" --provider <cli/xxx> Provider override");console.error(" --model <name> Model override (e.g. claude-sonnet-5)");console.error(" --metadata <json> Extra metadata (JSON object, double-quoted).");console.error(" Propagated to events/hooks/tracing.");console.error(" Invalid JSON aborts with exit code 2.");console.error(` e.g. --metadata='{"workflow_id":"wf-1"}'`);console.error(" --verbose Debug output mode");console.error(" --config/-c <path> Config file path");console.error(" --output-format <fmt> Output format (json|text|stream-json)");console.error(" --out/-o <path> Save result to file (stdout suppressed)");console.error(" --effort <level> Model effort (high|medium|low)");console.error(" -f/--prompt-file <path> Read body only from file; set recipient separately with --to");console.error(" --var key=value Template variable (repeatable)");console.error(" --overdrive Activate overdrive (boost) profile for this request");(0,a.emitDelegationResult)({command:r,trace:i,isError:true,state:n});process.exit(1);return}const X=H??process.env.CREWX_CONFIG??"crewx.yaml";(0,j.setAuditVerbose)(g);let A;try{A=await(0,S.createCliCrewx)(X)}catch(e){(0,a.emitDelegationResult)({command:r,trace:i,isError:true,state:n});throw e}if(g){process.stderr.write(`mode=sync reason=${y.reason}
|
|
3
|
+
`);process.stderr.write(`\u{1F4CB} Task: ${d}
|
|
4
|
+
`);process.stderr.write(`\u{1F916} Agent: ${w}
|
|
5
|
+
`);if(R)process.stderr.write(`\u{1F517} Thread: ${R}
|
|
6
6
|
`);if(k)process.stderr.write(`\u{1F50C} Provider: ${k}
|
|
7
|
-
`);if(
|
|
8
|
-
`);if(
|
|
9
|
-
`);if(
|
|
10
|
-
`);if(
|
|
11
|
-
`);process.stderr.write("\u2500".repeat(60)+"\n")}let
|
|
12
|
-
`);(0,
|
|
13
|
-
\u{1F4CA} Results from ${
|
|
14
|
-
`);process.stderr.write("\u2550".repeat(60)+"\n");process.stderr.write("\u{1F7E2} Status: Success\n");process.stderr.write(`\u{1F916} Provider: ${
|
|
15
|
-
`);process.stderr.write(`\u23F1\uFE0F Duration: ${
|
|
16
|
-
`);process.stderr.write("\n\u{1F4C4} Response:\n");process.stderr.write("\u2500".repeat(40)+"\n")}(0,
|
|
7
|
+
`);if(E)process.stderr.write(`\u{1F9E0} Model: ${E}
|
|
8
|
+
`);if(I)process.stderr.write(`\u{1F4C4} Output-format: ${I}
|
|
9
|
+
`);if(_)process.stderr.write(`\u26A1 Effort: ${_}
|
|
10
|
+
`);if(M)process.stderr.write(`\u{1F680} Overdrive: ON
|
|
11
|
+
`);process.stderr.write("\u2500".repeat(60)+"\n")}let h={};try{h=(0,N.parseMetadata)(B)}catch(e){const o=e instanceof Error?e.message:String(e);process.stderr.write(`Error: ${o}
|
|
12
|
+
`);(0,a.emitDelegationResult)({command:r,trace:i,isError:true,state:n});process.exit(2);return}const J=(0,t.resolveCliTaskActor)(h);const U=(0,m.isDetachedRunner)();const P=(0,m.readRunnerAssignment)();let v;let O;let c;if(P!==void 0){const e=new V.TaskRepository;const o=(0,t.adoptAssignedTask)(e,P,U);if(o.kind==="failed"){(0,a.emitDelegationResult)({command:r,trace:i,isError:true,state:n});process.exit(1);return}if(o.kind==="adopted"){v=o.taskId;O=(0,t.readAssignedTaskActor)(e,o.taskId);c=(0,t.readAssignedTaskProviderAccountBinding)(e,o.taskId)}}let l;if(v===void 0){l=(0,j.admitDurableTask)(`direct-cli:${r}`);if(!l.ok){(0,t.reportAdmissionBlocked)(l);(0,a.emitDelegationResult)({command:r,trace:i,isError:true,state:n});process.exit(1);return}}const F=c?(0,t.mergeAssignedTaskProviderAccountMetadata)(h,c):h;let p=0;let s;try{try{s=await A.query(w,d,{provider:c?.provider??k,model:E,effort:_||void 0,overdrive:M||void 0,threadId:R,taskId:v,actor:v===void 0?J:O,metadata:Object.keys(F).length>0?F:void 0,vars:Object.keys(T).length>0?T:void 0,trace:i,...(0,t.buildRecordedProviderAccountOptions)(c),...c&&(0,t.shouldReplayRecordedAntigravityAcp)(c)?{providerAccountReplay:true}:{}});if(!s.ok){const e=s.error?.message??"Query failed";console.error(e);(0,q.appendError)(x,e);p=1}else{if(g){process.stderr.write(`
|
|
13
|
+
\u{1F4CA} Results from ${w}:
|
|
14
|
+
`);process.stderr.write("\u2550".repeat(60)+"\n");process.stderr.write("\u{1F7E2} Status: Success\n");process.stderr.write(`\u{1F916} Provider: ${s.meta.provider}
|
|
15
|
+
`);process.stderr.write(`\u23F1\uFE0F Duration: ${s.meta.durationMs}ms
|
|
16
|
+
`);process.stderr.write("\n\u{1F4C4} Response:\n");process.stderr.write("\u2500".repeat(40)+"\n")}(0,q.writeResult)(x,s.data);if(g){process.stderr.write("\n\u2705 Query completed successfully\n")}}}catch(e){const o=e instanceof Error?e.message:String(e);console.error(`Error: ${o}`);(0,q.appendError)(x,`Error: ${o}`);p=1}finally{try{await A.close()}catch(e){(0,a.emitDelegationResult)({command:r,trace:i,taskId:s?.meta.taskId,agentId:s?.meta.agentId,isError:true,state:n});throw e}}}finally{if(l?.ok)l.release()}(0,a.emitDelegationResult)({command:r,trace:i,taskId:s?.meta.taskId,agentId:s?.meta.agentId,isError:p!==0||s?.ok===false,state:n});if(p!==0)process.exit(p)}
|
package/dist/commands/restart.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.handleRestart=I;const n=require("@crewx/sdk");const
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.handleRestart=I;const n=require("@crewx/sdk");const T=require("../bootstrap/crewx-cli");const _=require("../utils/inherited-trace");const u=require("./detached");function b(o){return`<crewx_system_message type="retry">
|
|
2
2
|
Retrying a failed task.
|
|
3
3
|
You must run \`crewx dreaming --task=${o}\` to review where it stopped before continuing.
|
|
4
4
|
</crewx_system_message>
|
|
5
5
|
|
|
6
|
-
`}function
|
|
6
|
+
`}function R(o){if(!o)return{};try{const t=JSON.parse(o);return t&&typeof t==="object"&&!Array.isArray(t)?t:{}}catch{return{}}}function A(o){const t=o.provider;return typeof t==="string"&&t.length>0?t:void 0}async function I(o){const t=o.includes("--verbose");const r=o.find(s=>!s.startsWith("--"));if(!r){process.stderr.write("Usage: crewx restart <task-id>\n");process.exit(1);return}const h=new n.TaskRepository;const e=h.getTask(r);if(!e){process.stderr.write(`Error: Task not found: ${r}
|
|
7
7
|
`);process.exit(1);return}if(!(0,n.isTaskRetryableByDefault)(e)){if((0,n.normalizeTaskStatus)(e)==="failed"){process.stderr.write(`Error: Task ${r} was not restarted: the end of the run was not observed (runner lost), so it may have done part of the work or may still be running. Check it with \`crewx log ${r}\` or \`crewx ps\` before running it again.
|
|
8
8
|
`)}else{process.stderr.write(`Error: Task ${r} is not in failed state (current: ${e.status??"unknown"}). Only failed tasks can be restarted.
|
|
9
9
|
`)}process.exit(1);return}if(!e.prompt){process.stderr.write(`Error: Task ${r} has no prompt to restart.
|
|
10
10
|
`);process.exit(1);return}if(!e.agent_id){process.stderr.write(`Error: Task ${r} has no agent to restart.
|
|
11
|
-
`);process.exit(1);return}const
|
|
12
|
-
`);process.stderr.write(`\u{1F916} Agent: ${
|
|
11
|
+
`);process.exit(1);return}const p=e.mode==="query"?"query":"execute";const l=`@${e.agent_id}`;const a=(0,n.generateId)("tsk");const g=`${b(r)}${e.prompt}`;const m=e.model??void 0;const i=R(e.metadata);const d=(0,u.readTaskProviderAccountBinding)(i);const x=d.provider??A(i);const k=i.overdrive===true;const v=i.overdriveState==="latch"?"latch":"count";(0,n.setAuditVerbose)(t);if(t){process.stderr.write(`\u{1F501} Restart: ${r} \u2192 ${a}
|
|
12
|
+
`);process.stderr.write(`\u{1F916} Agent: ${l} Mode: ${p}
|
|
13
13
|
`);if(e.thread_id)process.stderr.write(`\u{1F517} Thread: ${e.thread_id}
|
|
14
|
-
`);process.stderr.write("\u2500".repeat(60)+"\n")}const
|
|
15
|
-
`);process.stderr.write(`taskId=${
|
|
16
|
-
`);
|
|
14
|
+
`);process.stderr.write("\u2500".repeat(60)+"\n")}const f=await(0,T.createCliCrewx)();const y={taskId:a,threadId:e.thread_id??void 0,model:m,provider:x,...(0,u.buildRecordedProviderAccountOptions)(d),...(0,u.shouldReplayRecordedAntigravityAcp)(d)?{providerAccountReplay:true}:{},...k?{overdrive:{mode:v}}:{},metadata:(0,u.mergeAssignedTaskProviderAccountMetadata)({restartedFromTaskId:r,retriedFromTaskId:r,...k?{overdrive:true,overdriveState:v,overdriveMode:p}:{}},d),trace:(0,_.readInheritedTrace)()};let c=0;try{const s=p==="query"?await f.query(l,g,y):await f.execute(l,g,y);if(s.ok){process.stdout.write(s.data+"\n")}else{const w=s.error?.message??"Restart failed";const $=s.meta?.taskId??a;process.stderr.write(`Error: ${w}
|
|
15
|
+
`);process.stderr.write(`taskId=${$}
|
|
16
|
+
`);c=1}}catch(s){const w=s instanceof Error?s.message:String(s);process.stderr.write(`Error: ${w}
|
|
17
17
|
`);process.stderr.write(`taskId=${a}
|
|
18
|
-
`);
|
|
18
|
+
`);c=1}finally{await f.close()}if(c!==0)process.exit(c)}
|
package/dist/main.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
"use strict";var
|
|
2
|
+
"use strict";var v=exports&&exports.__createBinding||(Object.create?(function(s,e,t,r){if(r===void 0)r=t;var o=Object.getOwnPropertyDescriptor(e,t);if(!o||("get"in o?!e.__esModule:o.writable||o.configurable)){o={enumerable:true,get:function(){return e[t]}}}Object.defineProperty(s,r,o)}):(function(s,e,t,r){if(r===void 0)r=t;s[r]=e[t]}));var k=exports&&exports.__setModuleDefault||(Object.create?(function(s,e){Object.defineProperty(s,"default",{enumerable:true,value:e})}):function(s,e){s["default"]=e});var _=exports&&exports.__importStar||(function(){var s=function(e){s=Object.getOwnPropertyNames||function(t){var r=[];for(var o in t)if(Object.prototype.hasOwnProperty.call(t,o))r[r.length]=o;return r};return s(e)};return function(e){if(e&&e.__esModule)return e;var t={};if(e!=null){for(var r=s(e),o=0;o<r.length;o++)if(r[o]!=="default")v(t,e,r[o])}k(t,e);return t}})();Object.defineProperty(exports,"__esModule",{value:true});const d=require("./utils/sdk-compat");const y=require("@crewx/sdk/account");const b=require("@crewx/sdk");const x=require("./utils/inherited-trace");const l=require("./commands/ai-account");const q=(0,l.isAiAccountCapabilitiesRequest)(process.argv.slice(2));if(!q){process.env.CREWX_CLI??=d.sdkCompat.resolveCrewxCli();process.env.CREWX_WORKSPACE??=d.sdkCompat.resolveCrewxWorkspace();(0,y.loadCrewxEnvFiles)();(0,x.consumeInheritedRunnerIdentity)();d.sdkCompat.initPricingRemote()}const C=require("./commands/query");const S=require("./commands/execute");const O=require("./commands/agent");const P=require("./commands/ps");const h=require("./commands/stop");const I=require("./commands/result");const A=require("./commands/restart");const D=require("./commands/log");const R=require("./commands/doctor");const p=require("./commands/init");const E=require("./commands/shortcut");const M=require("./commands/publish");const g=require("./builtin");const j=require("./commands/slack");const N=require("./commands/hook/install");const U=require("./commands/hook/uninstall");const L=require("./commands/hook/status");const T=require("./commands/hook-dispatch");const B=require("./commands/db");const W=require("./commands/history");const $=require("./commands/command-help");const F=require("./commands/parse-common-flags");const u=require("./commands/registry");const H=require("./utils/version");const K=require("./utils/product-package-root");const f=require("./commands/emit-trailer");async function G(){const{join:s}=await Promise.resolve().then(()=>_(require("path")));const{createRequire:e}=require("module");const t=e(__filename);const r=s(__dirname,"../../../bin/cli-commands.js");const{CLI_SUBCOMMANDS:o}=t(r);const n=new Set([...u.KNOWN_COMMANDS,...u.BUILTIN_COMMAND_NAMES,...u.NOT_YET_MIGRATED]);const i=[...n].filter(c=>!o.has(c));const a=[...o].filter(c=>!n.has(c));if(i.length>0||a.length>0){throw new Error(`[crewx dev] SSOT drift detected!
|
|
3
3
|
`+(i.length?` registry has, CLI_SUBCOMMANDS missing: ${i.join(", ")}
|
|
4
|
-
`:"")+(a.length?` CLI_SUBCOMMANDS has, registry missing: ${a.join(", ")}`:""))}}async function
|
|
5
|
-
CrewX CLI v${
|
|
4
|
+
`:"")+(a.length?` CLI_SUBCOMMANDS has, registry missing: ${a.join(", ")}`:""))}}async function V(s){const e=process.argv.slice(2);if((0,l.isAiAccountCapabilitiesRequest)(e)){await(0,l.handleAiAccount)(e.slice(1));return}if(process.env["NODE_ENV"]==="development"){await G()}const t=e[0];if(!t){m();process.exit(0)}if(g.BUILTIN_COMMANDS.has(t)){const o=t==="skill"?(0,K.resolveProductRootFromCliEntry)(process.argv[1]):void 0;await(0,g.handleBuiltin)(t,e.slice(1),o);return}const r=(0,$.helpUsageFor)(t,e.slice(1));if(r!==void 0){console.log(r);return}switch(t){case"history":await(0,W.handleHistory)(e.slice(1));return;case"q":case"query":await(0,C.handleQuery)(e.slice(1),t,s);return;case"x":case"execute":await(0,S.handleExecute)(e.slice(1),t,s);return;case"agent":await(0,O.handleAgent)(e.slice(1));return;case"ps":await(0,P.handlePs)(e.slice(1));return;case"stop":await(0,h.handleStop)(e.slice(1),"stop");return;case"kill":await(0,h.handleStop)(e.slice(1),"kill");return;case"result":await(0,I.handleResult)(e.slice(1));return;case"restart":await(0,A.handleRestart)(e.slice(1));return;case"log":await(0,D.handleLog)(e.slice(1));return;case"doctor":await(0,R.handleDoctor)(e.slice(1));return;case"init":{const o=e.slice(1);const n=o.includes("--force")||o.includes("-f");try{const i=(0,p.parseInitProvider)(o);const a=await(0,p.handleInit)({path:process.cwd(),force:n,provider:i});if(a.skippedReason==="yaml-exists"){console.log("\u2713 crewx.yaml already exists (use --force to overwrite)")}else{console.log(a.yamlCreated?"\u2713 crewx.yaml created":"\u2713 yaml skipped");console.log(a.hookInstalled?"\u2713 hook installed":"\u26A0 hook skipped");if(a.errors.length>0)console.warn("Warnings:",a.errors.join("; "))}const c=(0,b.getDefaultAgentProfile)(a.provider);if(c){console.log(`\u2713 default agents: ${a.provider} (${c.planner.model} / ${c.worker.model})`)}if(a.workspaceId)console.log(`\u2713 workspace registered (id=${a.workspaceId}, slug=${a.slug})`);console.log("\u2713 done")}catch(i){console.error("\u2717 init failed:",i.message);process.exit(1)}return}case"db":await(0,B.handleDb)(e.slice(1));return;case"shortcut":await(0,E.handleShortcut)(e.slice(1));return;case"ai-account":await(0,l.handleAiAccount)(e.slice(1));return;case"publish":await(0,M.handlePublish)(e.slice(1));return;case"slack":case"slack:files":await(0,j.handleSlack)(e.slice(1));return;case"hook-dispatch":await(0,T.handleHookDispatch)(e.slice(1));return;case"help":case"--help":case"-h":m();return;case"--version":case"-v":{const o=require("../package.json");console.log(o.version);return}}if(u.NOT_YET_MIGRATED.has(t)){console.error(`Command '${t}' is not yet migrated in SDK refactor round. See packages/cli-bak for reference.`);process.exit(1)}if(t==="hook"){const o=e[1];const n=e.slice(2);switch(o){case"install":await(0,N.handleHookInstall)(n);return;case"uninstall":await(0,U.handleHookUninstall)(n);return;case"status":await(0,L.handleHookStatus)(n);return;default:console.error(`Unknown hook subcommand: ${o??"(none)"}`);console.error("Usage: crewx hook install|uninstall|status");process.exit(1)}}console.error(`Unknown command: ${t}`);console.error("Run `crewx --help` for usage.");process.exit(1)}function m(){console.log(`
|
|
5
|
+
CrewX CLI v${H.CLI_VERSION}
|
|
6
6
|
|
|
7
7
|
Usage:
|
|
8
8
|
crewx Launch web dashboard + open browser (default)
|
|
@@ -51,9 +51,11 @@ Agent Management:
|
|
|
51
51
|
agent prompt <@id> Show rendered system prompt for an agent
|
|
52
52
|
|
|
53
53
|
Provider Accounts:
|
|
54
|
-
ai-account list|add|login|status|use|remove
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
ai-account list|add|login|status|use|remove [options]
|
|
55
|
+
Manage Claude, Codex, and isolated Antigravity accounts
|
|
56
|
+
ai-account capabilities --json Print the SDK capability contract without bootstrap
|
|
57
|
+
ai-account runtime status|install [--json]
|
|
58
|
+
Inspect or explicitly install the Antigravity runtime
|
|
57
59
|
|
|
58
60
|
Task Management:
|
|
59
61
|
ps List running tasks
|
|
@@ -112,4 +114,4 @@ Hook Platform:
|
|
|
112
114
|
Global Options:
|
|
113
115
|
--help, -h Show this help
|
|
114
116
|
--version, -v Show version
|
|
115
|
-
`.trim())}function
|
|
117
|
+
`.trim())}function X(s){if(s instanceof F.UnknownOptionError)return 2;if(typeof s==="object"&&s!==null&&"exitCode"in s){const e=s.exitCode;if(typeof e==="number")return e}return 1}const w=(0,f.createDelegationEmitState)();V(w).catch(s=>{console.error(s instanceof Error?s.message:String(s));(0,f.emitDelegationResult)({command:process.argv[2],isError:true,state:w});process.exit(X(s))});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crewx/cli",
|
|
3
|
-
"version": "0.9.0-rc.
|
|
3
|
+
"version": "0.9.0-rc.191",
|
|
4
4
|
"license": "UNLICENSED",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=20.19.0"
|
|
@@ -25,20 +25,20 @@
|
|
|
25
25
|
"better-sqlite3": "*",
|
|
26
26
|
"dotenv": "17.2.3",
|
|
27
27
|
"isomorphic-git": "1.37.1",
|
|
28
|
-
"@crewx/sdk": "0.9.0-rc.
|
|
29
|
-
"@crewx/
|
|
30
|
-
"@crewx/
|
|
31
|
-
"@crewx/
|
|
32
|
-
"@crewx/search": "0.1.10-rc.
|
|
33
|
-
"@crewx/
|
|
34
|
-
"@crewx/
|
|
35
|
-
"@crewx/
|
|
36
|
-
"@crewx/
|
|
37
|
-
"@crewx/cron": "0.1.10-rc.
|
|
38
|
-
"@crewx/
|
|
39
|
-
"@crewx/
|
|
40
|
-
"@crewx/app": "0.1.0-rc.
|
|
41
|
-
"@crewx/
|
|
28
|
+
"@crewx/sdk": "0.9.0-rc.191",
|
|
29
|
+
"@crewx/memory": "0.1.23-rc.208",
|
|
30
|
+
"@crewx/doc": "0.1.9-rc.184",
|
|
31
|
+
"@crewx/knowledge-core": "0.1.17-rc.201",
|
|
32
|
+
"@crewx/search": "0.1.10-rc.187",
|
|
33
|
+
"@crewx/wi": "0.1.10-rc.211",
|
|
34
|
+
"@crewx/skill": "0.1.20-rc.85",
|
|
35
|
+
"@crewx/chromex": "0.1.0-rc.224",
|
|
36
|
+
"@crewx/workflow": "0.3.22-rc.237",
|
|
37
|
+
"@crewx/cron": "0.1.10-rc.226",
|
|
38
|
+
"@crewx/notify": "0.1.0-rc.162",
|
|
39
|
+
"@crewx/wbs": "0.1.10-rc.217",
|
|
40
|
+
"@crewx/app": "0.1.0-rc.72",
|
|
41
|
+
"@crewx/shared": "0.0.6-rc.106"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@types/better-sqlite3": "*",
|