@crewx/sdk 0.8.1 → 0.8.2-rc.2

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.
@@ -1,14 +1,14 @@
1
- 'use strict';var fs=require('fs'),k=require('path'),os=require('os'),U=require('better-sqlite3'),crypto=require('crypto');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var k__namespace=/*#__PURE__*/_interopNamespace(k);var U__default=/*#__PURE__*/_interopDefault(U);var d=class{detach(s){}};function w(i){let s=t=>String(t).padStart(2,"0");return `${i.getFullYear()}${s(i.getMonth()+1)}${s(i.getDate())}T${s(i.getHours())}${s(i.getMinutes())}${s(i.getSeconds())}`}var f=class extends d{name="file-logger";unsubs=[];logFiles=new Map;logsDir;version;constructor(s){super(),this.logsDir=k.join(s?.workspaceRoot??process.cwd(),".crewx","logs"),this.version=s?.version??"unknown";}attach(s){this.unsubs.push(s.on("task:start",t=>{try{fs.existsSync(this.logsDir)||fs.mkdirSync(this.logsDir,{recursive:!0});let r=w(t.timestamp),a=k.join(this.logsDir,`${r}_${t.traceId}.log`);this.logFiles.set(t.traceId,a);let n=`=== TASK LOG: ${t.traceId} ===
1
+ 'use strict';var fs=require('fs'),k=require('path'),os=require('os'),U=require('better-sqlite3'),crypto=require('crypto');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}function _interopNamespace(e){if(e&&e.__esModule)return e;var n=Object.create(null);if(e){Object.keys(e).forEach(function(k){if(k!=='default'){var d=Object.getOwnPropertyDescriptor(e,k);Object.defineProperty(n,k,d.get?d:{enumerable:true,get:function(){return e[k]}});}})}n.default=e;return Object.freeze(n)}var k__namespace=/*#__PURE__*/_interopNamespace(k);var U__default=/*#__PURE__*/_interopDefault(U);var l=class{detach(s){}};function S(i){let s=t=>String(t).padStart(2,"0");return `${i.getFullYear()}${s(i.getMonth()+1)}${s(i.getDate())}T${s(i.getHours())}${s(i.getMinutes())}${s(i.getSeconds())}`}var f=class extends l{name="file-logger";unsubs=[];logFiles=new Map;logsDir;version;constructor(s){super(),this.logsDir=k.join(s?.workspaceRoot??process.cwd(),".crewx","logs"),this.version=s?.version??"unknown";}attach(s){this.unsubs.push(s.on("task:start",t=>{try{fs.existsSync(this.logsDir)||fs.mkdirSync(this.logsDir,{recursive:!0});let r=S(t.timestamp),a=k.join(this.logsDir,`${r}_${t.traceId}.log`);this.logFiles.set(t.traceId,a);let o=`=== TASK LOG: ${t.traceId} ===
2
2
  CrewX Version: ${this.version}
3
3
  Mode: ${t.mode}
4
4
  Agent: ${t.agentRef}
5
5
  Started: ${t.timestamp.toLocaleString()}
6
6
  Message: ${t.message}
7
7
 
8
- `;fs.writeFileSync(a,n,{encoding:"utf8",mode:384});}catch{}}),s.on("task:output",t=>{try{let r=this.logFiles.get(t.traceId);if(!r)return;let a=new Date().toISOString();fs.appendFileSync(r,`[${a}] STDOUT: ${t.output}
9
- `,"utf8");}catch{}}),s.on("task:end",t=>{try{let r=this.logFiles.get(t.traceId);if(!r)return;let a=new Date().toLocaleString(),n=t.error?`failed: ${t.error.message}`:"completed successfully",c=`[${a}] INFO: Task ${n} in ${t.durationMs}ms
8
+ `;fs.writeFileSync(a,o,{encoding:"utf8",mode:384});}catch{}}),s.on("task:output",t=>{try{let r=this.logFiles.get(t.traceId);if(!r)return;let a=new Date().toISOString();fs.appendFileSync(r,`[${a}] STDOUT: ${t.output}
9
+ `,"utf8");}catch{}}),s.on("task:end",t=>{try{let r=this.logFiles.get(t.traceId);if(!r)return;let a=new Date().toLocaleString(),o=t.error?`failed: ${t.error.message}`:"completed successfully",p=`[${a}] INFO: Task ${o} in ${t.durationMs}ms
10
10
  [${a}] INFO: Process closed with exit code: ${t.error?1:0}
11
- `;fs.appendFileSync(r,c,"utf8"),this.logFiles.delete(t.traceId);}catch{}}));}detach(s){this.unsubs.forEach(t=>t()),this.unsubs=[],this.logFiles.clear();}};function R(i){let s=k__namespace.resolve(i);return process.platform==="win32"&&(s=s.replace(/\\/g,"/"),s=s.replace(/^([A-Z]):/,(t,r)=>`${r.toLowerCase()}:`)),s.length>1&&!/^[a-zA-Z]:\/$/.test(s)&&(s=s.replace(/\/+$/,"")),s}function x(i){let s=R(i);return crypto.createHash("sha256").update(s).digest("hex")}var E=class extends d{name="sqlite-tracing";db=null;unsubs=[];dbPath;version;constructor(s){super(),this.dbPath=k.join(s?.dbRoot??os.homedir(),".crewx","crewx.db"),this.version=s?.version??"unknown";}attach(s){let t=k.dirname(this.dbPath);fs.existsSync(t)||fs.mkdirSync(t,{recursive:true}),this.db=new U__default.default(this.dbPath);let r=this.db.prepare("PRAGMA table_info(tasks)").all(),a=e=>r.some(o=>o.name===e);a("parent_task_id")||this.db.exec("ALTER TABLE tasks ADD COLUMN parent_task_id TEXT"),a("caller_agent_id")||this.db.exec("ALTER TABLE tasks ADD COLUMN caller_agent_id TEXT"),a("trace_id")||this.db.exec("ALTER TABLE tasks ADD COLUMN trace_id TEXT");let n=process.cwd(),c=fs.existsSync(k.join(n,"crewx.yaml"))||fs.existsSync(k.join(n,"crewx.yml")),y=c?x(n):null,m=c?k.basename(n):null,g=process.argv.join(" ");this.unsubs.push(s.on("task:start",e=>{try{let o=process.env.CREWX_CALLER_AGENT_ID||null,p=process.env.CREWX_PARENT_TASK_ID||null,C=process.env.CREWX_TRACE_ID||e.traceId,v=e.metadata?JSON.stringify(e.metadata):JSON.stringify({provider:e.provider??"cli/claude"});this.db.prepare(`INSERT OR IGNORE INTO tasks
11
+ `;fs.appendFileSync(r,p,"utf8"),this.logFiles.delete(t.traceId);}catch{}}));}detach(s){this.unsubs.forEach(t=>t()),this.unsubs=[],this.logFiles.clear();}};function O(i){let s=k__namespace.resolve(i);return process.platform==="win32"&&(s=s.replace(/\\/g,"/"),s=s.replace(/^([A-Z]):/,(t,r)=>`${r.toLowerCase()}:`)),s.length>1&&!/^[a-zA-Z]:\/$/.test(s)&&(s=s.replace(/\/+$/,"")),s}function x(i){let s=O(i);return crypto.createHash("sha256").update(s).digest("hex")}var _=class extends l{name="sqlite-tracing";db=null;unsubs=[];dbPath;version;constructor(s){super(),this.dbPath=k.join(s?.dbRoot??os.homedir(),".crewx","crewx.db"),this.version=s?.version??"unknown";}attach(s){let t=k.dirname(this.dbPath);if(fs.existsSync(t)||fs.mkdirSync(t,{recursive:true}),this.db=new U__default.default(this.dbPath),this.db.prepare("SELECT name FROM sqlite_master WHERE type='table' AND name='tasks'").get()!==void 0){let e=this.db.prepare("PRAGMA table_info(tasks)").all(),n=d=>e.some(u=>u.name===d);n("parent_task_id")||this.db.exec("ALTER TABLE tasks ADD COLUMN parent_task_id TEXT"),n("caller_agent_id")||this.db.exec("ALTER TABLE tasks ADD COLUMN caller_agent_id TEXT"),n("trace_id")||this.db.exec("ALTER TABLE tasks ADD COLUMN trace_id TEXT");}let a=process.cwd(),o=fs.existsSync(k.join(a,"crewx.yaml"))||fs.existsSync(k.join(a,"crewx.yml")),p=o?x(a):null,b=o?k.basename(a):null,g=process.argv.join(" ");this.unsubs.push(s.on("task:start",e=>{try{let n=process.env.CREWX_CALLER_AGENT_ID||null,d=process.env.CREWX_PARENT_TASK_ID||null,u=process.env.CREWX_TRACE_ID||e.traceId,C=e.metadata?JSON.stringify(e.metadata):JSON.stringify({provider:e.provider??"cli/claude"});this.db.prepare(`INSERT OR IGNORE INTO tasks
12
12
  (id, agent_id, prompt, mode, status, pid, started_at,
13
13
  crewx_version, platform,
14
14
  model, rendered_prompt, command, coding_agent_command,
@@ -18,14 +18,14 @@ Message: ${t.message}
18
18
  ?, ?,
19
19
  ?, ?, ?, ?,
20
20
  ?, ?,
21
- ?, ?, ?, ?, ?)`).run(e.traceId,e.agentRef.replace(/^@/,""),e.message,e.mode,e.pid??null,e.timestamp.toISOString(),this.version,e.platform??"cli",e.model??null,e.renderedPrompt??null,g,e.codingAgentCommand??null,e.workspaceId??y,e.workspaceName??m,o,p,C,v,e.threadId??null);}catch{}}),s.on("task:output",e=>{try{let o=this.db.prepare("SELECT logs FROM tasks WHERE id=?").get(e.traceId),p=o?.logs?JSON.parse(o.logs):[];p.push({timestamp:e.timestamp.toISOString(),level:e.level??"stdout",message:e.output}),this.db.prepare("UPDATE tasks SET logs=? WHERE id=?").run(JSON.stringify(p),e.traceId);}catch{}}),s.on("task:end",e=>{try{let o=e.error?"failed":"success";this.db.prepare(`UPDATE tasks
21
+ ?, ?, ?, ?, ?)`).run(e.traceId,e.agentRef.replace(/^@/,""),e.message,e.mode,e.pid??null,e.timestamp.toISOString(),this.version,e.platform??"cli",e.model??null,e.renderedPrompt??null,g,e.codingAgentCommand??null,e.workspaceId??p,e.workspaceName??b,n,d,u,C,e.threadId??null);}catch{}}),s.on("task:output",e=>{try{let n=this.db.prepare("SELECT logs FROM tasks WHERE id=?").get(e.traceId),d=n?.logs?JSON.parse(n.logs):[];d.push({timestamp:e.timestamp.toISOString(),level:e.level??"stdout",message:e.output}),this.db.prepare("UPDATE tasks SET logs=? WHERE id=?").run(JSON.stringify(d),e.traceId);}catch{}}),s.on("task:end",e=>{try{let n=e.error?"failed":"success";this.db.prepare(`UPDATE tasks
22
22
  SET status=?, result=?, error=?,
23
23
  completed_at=?, duration_ms=?,
24
24
  exit_code=?,
25
25
  input_tokens=?, output_tokens=?, cached_input_tokens=?,
26
26
  cost_usd=?,
27
27
  model=COALESCE(?, model)
28
- WHERE id=?`).run(o,e.result??null,e.error?JSON.stringify(e.error):null,e.timestamp.toISOString(),e.durationMs,e.exitCode??null,e.inputTokens??0,e.outputTokens??0,e.cachedInputTokens??0,e.costUsd??0,e.model??null,e.traceId);}catch{}}));}detach(s){this.unsubs.forEach(t=>t()),this.unsubs=[],this.db?.close(),this.db=null;}};var H=`
28
+ WHERE id=?`).run(n,e.result??null,e.error?JSON.stringify(e.error):null,e.timestamp.toISOString(),e.durationMs,e.exitCode??null,e.inputTokens??0,e.outputTokens??0,e.cachedInputTokens??0,e.costUsd??0,e.model??null,e.traceId);}catch{}}));}detach(s){this.unsubs.forEach(t=>t()),this.unsubs=[],this.db?.close(),this.db=null;}};var W=`
29
29
  CREATE TABLE IF NOT EXISTS threads (
30
30
  id TEXT PRIMARY KEY,
31
31
  workspace_id TEXT,
@@ -38,15 +38,16 @@ Message: ${t.message}
38
38
  updated_at TEXT NOT NULL,
39
39
  metadata TEXT
40
40
  )
41
- `,X=["id","thread_id","prompt","result","started_at","trace_id","status","parent_task_id","agent_id"];function q(i){return i.replace(/<conversation_history[^>]*>[\s\S]*?<\/conversation_history>/g,"").split(`
41
+ `,H=["id","thread_id","prompt","result","started_at","trace_id","status","parent_task_id","agent_id"];function X(i){return i.replace(/<conversation_history[^>]*>[\s\S]*?<\/conversation_history>/g,"").split(`
42
42
  `).filter(a=>!(a.startsWith("Loaded ")&&a.includes("layouts from")||a.includes("[dotenv@")||a.includes("[Nest]")&&a.includes("DEBUG")||a.startsWith("Registered custom layout:")||a.startsWith("Updated custom layout:"))).join(`
43
- `).trim()}function j(i){if(!i)return "";let s=i;try{let t=JSON.parse(s);Array.isArray(t)?s=t.filter(r=>r?.type==="text"&&r?.text).map(r=>r.text).join(`
44
- `):t&&typeof t=="object"&&t.result!==void 0&&(s=t.result||"");}catch{s=q(s);}return s}var u=class{db;constructor(s){let t=s??k.join(os.homedir(),".crewx","crewx.db");this.db=new U__default.default(t),this.init();}init(){this.db.pragma("journal_mode = WAL"),this.db.exec(H);}async ensureThread(s,t,r){let a=this.db.prepare("SELECT platform FROM threads WHERE id = ?").get(s);if(a){if(a.platform!==t)throw new Error(`Thread '${s}' already exists with platform '${a.platform}' \u2014 cannot change to '${t}' (platform is immutable)`);r&&this.db.prepare("UPDATE threads SET workspace_id = COALESCE(workspace_id, ?) WHERE id = ?").run(r,s);return}let n=new Date().toISOString();this.db.prepare("INSERT INTO threads (id, platform, workspace_id, message_count, created_at, updated_at) VALUES (?, ?, ?, 0, ?, ?)").run(s,t,r??null,n,n);}async fetchHistory(s,t){let r=t?.limit??100,a=["thread_id = ?","(parent_task_id IS NULL OR parent_task_id = '')","(status IN ('done', 'completed', 'success') OR status IS NULL)"],n=[s];t?.currentTraceId&&(a.push("trace_id != ?"),n.push(t.currentTraceId));let c=a.join(" AND "),m=`SELECT ${X.join(", ")} FROM tasks WHERE ${c} ORDER BY started_at ASC LIMIT ?`;n.push(r);let g=this.db.prepare(m).all(...n),e=this.db.prepare("SELECT platform, title, first_message, last_message, message_count, updated_at FROM threads WHERE id = ?").get(s),o=e?.platform??"cli",p=this.rowsToMessages(g);return {threadId:s,platform:o,messages:p,metadata:{title:e?.title??void 0,firstMessage:e?.first_message??void 0,lastMessage:e?.last_message??void 0,messageCount:e?.message_count??0,updatedAt:e?.updated_at?new Date(e.updated_at).getTime():void 0}}}async saveUserMessage(s,t,r,a){let n=new Date().toISOString();this.db.prepare(`UPDATE threads
43
+ `).trim()}function q(i){if(!i)return "";let s=i;try{let t=JSON.parse(s);Array.isArray(t)?s=t.filter(r=>r?.type==="text"&&r?.text).map(r=>r.text).join(`
44
+ `):t&&typeof t=="object"&&t.result!==void 0&&(s=t.result||"");}catch{s=X(s);}return s}var m=class{db;constructor(s){let t=s??k.join(os.homedir(),".crewx","crewx.db");this.db=new U__default.default(t),this.init();}init(){this.db.pragma("journal_mode = WAL"),this.db.exec(W),this.migrateThreadsTable();}migrateThreadsTable(){this.db.prepare("PRAGMA table_info(threads)").all().some(t=>t.name==="title_locked")||this.db.exec("ALTER TABLE threads ADD COLUMN title_locked INTEGER NOT NULL DEFAULT 0");}updateThread(s,t){t.title!==void 0&&this.db.prepare("UPDATE threads SET title = ?, title_locked = 1, updated_at = ? WHERE id = ?").run(t.title,new Date().toISOString(),s);}async ensureThread(s,t,r){let a=this.db.prepare("SELECT platform FROM threads WHERE id = ?").get(s);if(a){if(a.platform!==t)throw new Error(`Thread '${s}' already exists with platform '${a.platform}' \u2014 cannot change to '${t}' (platform is immutable)`);r&&this.db.prepare("UPDATE threads SET workspace_id = COALESCE(workspace_id, ?) WHERE id = ?").run(r,s);return}let o=new Date().toISOString();this.db.prepare("INSERT INTO threads (id, platform, workspace_id, message_count, created_at, updated_at) VALUES (?, ?, ?, 0, ?, ?)").run(s,t,r??null,o,o);}async fetchHistory(s,t){let r=t?.limit??100,a=["thread_id = ?","(parent_task_id IS NULL OR parent_task_id = '')","(status IN ('done', 'completed', 'success') OR status IS NULL)"],o=[s];t?.currentTraceId&&(a.push("trace_id != ?"),o.push(t.currentTraceId));let p=a.join(" AND "),g=`SELECT ${H.join(", ")} FROM tasks WHERE ${p} ORDER BY started_at ASC LIMIT ?`;o.push(r);let e=this.db.prepare(g).all(...o),n=this.db.prepare("SELECT platform, title, first_message, last_message, message_count, updated_at FROM threads WHERE id = ?").get(s),d=n?.platform??"cli",u=this.rowsToMessages(e);return {threadId:s,platform:d,messages:u,metadata:{title:n?.title??void 0,firstMessage:n?.first_message??void 0,lastMessage:n?.last_message??void 0,messageCount:n?.message_count??0,updatedAt:n?.updated_at?new Date(n.updated_at).getTime():void 0}}}async saveUserMessage(s,t,r,a){let o=new Date().toISOString();this.db.prepare(`UPDATE threads
45
45
  SET first_message = COALESCE(first_message, ?),
46
+ title = CASE WHEN title_locked = 0 AND title IS NULL THEN substr(?, 1, 60) ELSE title END,
46
47
  last_message = ?,
47
48
  message_count = message_count + 1,
48
49
  updated_at = ?
49
- WHERE id = ?`).run(t,t,n,s);}async saveAssistantMessage(s,t,r,a){let n=new Date().toISOString();this.db.prepare(`UPDATE threads
50
+ WHERE id = ?`).run(t,t,t,o,s);}async saveAssistantMessage(s,t,r,a){let o=new Date().toISOString();this.db.prepare(`UPDATE threads
50
51
  SET last_message = ?,
51
52
  updated_at = ?
52
- WHERE id = ?`).run(t,n,s);}close(){this.db.close();}rowsToMessages(s){let t=[];for(let r of s){r.prompt&&t.push({id:`${r.id}-user`,text:r.prompt,isAssistant:false,timestamp:new Date(r.started_at).getTime()});let a=j(r.result);a&&t.push({id:`${r.id}-assistant`,text:a,isAssistant:true,timestamp:new Date(r.started_at).getTime()});}return t}};var T=class extends d{name="conversation";_provider;unsubStart=null;unsubEnd=null;constructor(s){super(),this._provider=new u(s?.dbPath);}get conversationProvider(){return this._provider}attach(s){this.unsubStart=s.on("task:start",async t=>{if(!t.threadId)return;let r=t.platform??"cli";try{await this._provider.ensureThread(t.threadId,r,t.workspaceId),await this._provider.saveUserMessage(t.threadId,t.message??"");}catch{}}),this.unsubEnd=s.on("task:end",async t=>{if(!t.result)return;let r=t.metadata?.threadId;if(!r)return;let a=t.agentRef?.replace(/^@/,"")??"";try{await this._provider.saveAssistantMessage(r,t.result,a);}catch{}});}detach(s){this.unsubStart?.(),this.unsubStart=null,this.unsubEnd?.(),this.unsubEnd=null,this._provider.close?.();}};exports.ConversationPlugin=T;exports.FileLoggerPlugin=f;exports.SqliteTracingPlugin=E;
53
+ WHERE id = ?`).run(t,o,s);}close(){this.db.close();}rowsToMessages(s){let t=[];for(let r of s){r.prompt&&t.push({id:`${r.id}-user`,text:r.prompt,isAssistant:false,timestamp:new Date(r.started_at).getTime()});let a=q(r.result);a&&t.push({id:`${r.id}-assistant`,text:a,isAssistant:true,timestamp:new Date(r.started_at).getTime()});}return t}};var T=class extends l{name="conversation";_provider;unsubStart=null;unsubEnd=null;constructor(s){super(),this._provider=new m(s?.dbPath);}get conversationProvider(){return this._provider}attach(s){this.unsubStart=s.on("task:start",async t=>{if(!t.threadId)return;let r=t.platform??"cli";try{await this._provider.ensureThread(t.threadId,r,t.workspaceId),await this._provider.saveUserMessage(t.threadId,t.message??"");}catch{}}),this.unsubEnd=s.on("task:end",async t=>{if(!t.result)return;let r=t.metadata?.threadId;if(!r)return;let a=t.agentRef?.replace(/^@/,"")??"";try{await this._provider.saveAssistantMessage(r,t.result,a);}catch{}});}detach(s){this.unsubStart?.(),this.unsubStart=null,this.unsubEnd?.(),this.unsubEnd=null,this._provider.close?.();}};exports.ConversationPlugin=T;exports.FileLoggerPlugin=f;exports.SqliteTracingPlugin=_;
@@ -2,6 +2,12 @@ export declare class ProviderError extends Error {
2
2
  readonly providerStr: string;
3
3
  constructor(message: string, providerStr: string);
4
4
  }
5
+ export declare class IdleTimeoutError extends ProviderError {
6
+ constructor(message: string, providerStr: string);
7
+ }
8
+ export declare class TotalTimeoutError extends ProviderError {
9
+ constructor(message: string, providerStr: string);
10
+ }
5
11
  export type ProviderFactory = (id: string, providerStr: string) => ProviderRuntime;
6
12
  export interface ProviderUsage {
7
13
  inputTokens: number;
@@ -20,6 +26,9 @@ export interface ProviderQueryOptions {
20
26
  onUsage?: (usage: ProviderUsage) => void;
21
27
  onExitCode?: (code: number) => void;
22
28
  onModel?: (model: string) => void;
29
+ timeoutMs?: number;
30
+ idleTimeoutMs?: number;
31
+ killGraceMs?: number;
23
32
  }
24
33
  export interface ProviderRuntime {
25
34
  query(message: string, options?: ProviderQueryOptions): Promise<string>;
@@ -4,6 +4,28 @@ export declare class ProviderError extends Error {
4
4
  readonly providerStr: string;
5
5
  constructor(message: string, providerStr: string);
6
6
  }
7
+ export declare class IdleTimeoutError extends ProviderError {
8
+ constructor(message: string, providerStr: string);
9
+ }
10
+ export declare class TotalTimeoutError extends ProviderError {
11
+ constructor(message: string, providerStr: string);
12
+ }
13
+ export interface RunCliProcessOptions {
14
+ timeoutMs?: number;
15
+ idleTimeoutMs?: number;
16
+ killGraceMs?: number;
17
+ env?: Record<string, string>;
18
+ cwd?: string;
19
+ onOutput?: (line: string, level: 'stdout' | 'stderr') => void;
20
+ onPid?: (pid: number) => void;
21
+ onExitCode?: (code: number) => void;
22
+ onUsage?: (usage: ProviderUsage) => void;
23
+ onModel?: (model: string) => void;
24
+ }
25
+ export declare function runCliProcess(command: string, args: string[], providerStr: string, _providerId: string, options?: RunCliProcessOptions, stdinMessage?: string): Promise<{
26
+ stdout: string;
27
+ parsed: string;
28
+ }>;
7
29
  export interface ClientToolCall {
8
30
  toolCallId: string;
9
31
  toolName: string;
@@ -44,6 +66,9 @@ export interface ProviderQueryOptions {
44
66
  onModel?: (model: string) => void;
45
67
  env?: Record<string, string>;
46
68
  cwd?: string;
69
+ timeoutMs?: number;
70
+ idleTimeoutMs?: number;
71
+ killGraceMs?: number;
47
72
  tools?: import('../facade/Crewx').ToolDefinition[];
48
73
  maxSteps?: number;
49
74
  }
@@ -79,6 +79,13 @@ export declare const AgentInlineSchema: z.ZodObject<{
79
79
  template: string;
80
80
  }>]>>;
81
81
  }, z.ZodUnknown, "strip">>;
82
+ export declare const AgentSkillsSchema: z.ZodOptional<z.ZodObject<{
83
+ include: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
84
+ }, "strip", z.ZodTypeAny, {
85
+ include?: string[] | undefined;
86
+ }, {
87
+ include?: string[] | undefined;
88
+ }>>;
82
89
  export declare const AgentConfigSchema: z.ZodObject<{
83
90
  id: z.ZodString;
84
91
  name: z.ZodOptional<z.ZodString>;
@@ -167,6 +174,15 @@ export declare const AgentConfigSchema: z.ZodObject<{
167
174
  template: string;
168
175
  }>]>>;
169
176
  }, z.ZodUnknown, "strip">>>;
177
+ timeoutMs: z.ZodOptional<z.ZodNumber>;
178
+ idleTimeoutMs: z.ZodOptional<z.ZodNumber>;
179
+ skills: z.ZodOptional<z.ZodObject<{
180
+ include: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
181
+ }, "strip", z.ZodTypeAny, {
182
+ include?: string[] | undefined;
183
+ }, {
184
+ include?: string[] | undefined;
185
+ }>>;
170
186
  }, "strip", z.ZodUnknown, z.objectOutputType<{
171
187
  id: z.ZodString;
172
188
  name: z.ZodOptional<z.ZodString>;
@@ -255,6 +271,15 @@ export declare const AgentConfigSchema: z.ZodObject<{
255
271
  template: string;
256
272
  }>]>>;
257
273
  }, z.ZodUnknown, "strip">>>;
274
+ timeoutMs: z.ZodOptional<z.ZodNumber>;
275
+ idleTimeoutMs: z.ZodOptional<z.ZodNumber>;
276
+ skills: z.ZodOptional<z.ZodObject<{
277
+ include: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
278
+ }, "strip", z.ZodTypeAny, {
279
+ include?: string[] | undefined;
280
+ }, {
281
+ include?: string[] | undefined;
282
+ }>>;
258
283
  }, z.ZodUnknown, "strip">, z.objectInputType<{
259
284
  id: z.ZodString;
260
285
  name: z.ZodOptional<z.ZodString>;
@@ -343,6 +368,15 @@ export declare const AgentConfigSchema: z.ZodObject<{
343
368
  template: string;
344
369
  }>]>>;
345
370
  }, z.ZodUnknown, "strip">>>;
371
+ timeoutMs: z.ZodOptional<z.ZodNumber>;
372
+ idleTimeoutMs: z.ZodOptional<z.ZodNumber>;
373
+ skills: z.ZodOptional<z.ZodObject<{
374
+ include: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
375
+ }, "strip", z.ZodTypeAny, {
376
+ include?: string[] | undefined;
377
+ }, {
378
+ include?: string[] | undefined;
379
+ }>>;
346
380
  }, z.ZodUnknown, "strip">>;
347
381
  export type AgentConfig = z.infer<typeof AgentConfigSchema>;
348
382
  export interface YamlHookEntry {
@@ -458,6 +492,15 @@ export declare const CrewxProjectConfigSchema: z.ZodObject<{
458
492
  template: string;
459
493
  }>]>>;
460
494
  }, z.ZodUnknown, "strip">>>;
495
+ timeoutMs: z.ZodOptional<z.ZodNumber>;
496
+ idleTimeoutMs: z.ZodOptional<z.ZodNumber>;
497
+ skills: z.ZodOptional<z.ZodObject<{
498
+ include: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
499
+ }, "strip", z.ZodTypeAny, {
500
+ include?: string[] | undefined;
501
+ }, {
502
+ include?: string[] | undefined;
503
+ }>>;
461
504
  }, "strip", z.ZodUnknown, z.objectOutputType<{
462
505
  id: z.ZodString;
463
506
  name: z.ZodOptional<z.ZodString>;
@@ -546,6 +589,15 @@ export declare const CrewxProjectConfigSchema: z.ZodObject<{
546
589
  template: string;
547
590
  }>]>>;
548
591
  }, z.ZodUnknown, "strip">>>;
592
+ timeoutMs: z.ZodOptional<z.ZodNumber>;
593
+ idleTimeoutMs: z.ZodOptional<z.ZodNumber>;
594
+ skills: z.ZodOptional<z.ZodObject<{
595
+ include: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
596
+ }, "strip", z.ZodTypeAny, {
597
+ include?: string[] | undefined;
598
+ }, {
599
+ include?: string[] | undefined;
600
+ }>>;
549
601
  }, z.ZodUnknown, "strip">, z.objectInputType<{
550
602
  id: z.ZodString;
551
603
  name: z.ZodOptional<z.ZodString>;
@@ -634,6 +686,15 @@ export declare const CrewxProjectConfigSchema: z.ZodObject<{
634
686
  template: string;
635
687
  }>]>>;
636
688
  }, z.ZodUnknown, "strip">>>;
689
+ timeoutMs: z.ZodOptional<z.ZodNumber>;
690
+ idleTimeoutMs: z.ZodOptional<z.ZodNumber>;
691
+ skills: z.ZodOptional<z.ZodObject<{
692
+ include: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
693
+ }, "strip", z.ZodTypeAny, {
694
+ include?: string[] | undefined;
695
+ }, {
696
+ include?: string[] | undefined;
697
+ }>>;
637
698
  }, z.ZodUnknown, "strip">>, "many">>;
638
699
  hooks: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
639
700
  settings: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
@@ -729,6 +790,15 @@ export declare const CrewxProjectConfigSchema: z.ZodObject<{
729
790
  template: string;
730
791
  }>]>>;
731
792
  }, z.ZodUnknown, "strip">>>;
793
+ timeoutMs: z.ZodOptional<z.ZodNumber>;
794
+ idleTimeoutMs: z.ZodOptional<z.ZodNumber>;
795
+ skills: z.ZodOptional<z.ZodObject<{
796
+ include: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
797
+ }, "strip", z.ZodTypeAny, {
798
+ include?: string[] | undefined;
799
+ }, {
800
+ include?: string[] | undefined;
801
+ }>>;
732
802
  }, "strip", z.ZodUnknown, z.objectOutputType<{
733
803
  id: z.ZodString;
734
804
  name: z.ZodOptional<z.ZodString>;
@@ -817,6 +887,15 @@ export declare const CrewxProjectConfigSchema: z.ZodObject<{
817
887
  template: string;
818
888
  }>]>>;
819
889
  }, z.ZodUnknown, "strip">>>;
890
+ timeoutMs: z.ZodOptional<z.ZodNumber>;
891
+ idleTimeoutMs: z.ZodOptional<z.ZodNumber>;
892
+ skills: z.ZodOptional<z.ZodObject<{
893
+ include: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
894
+ }, "strip", z.ZodTypeAny, {
895
+ include?: string[] | undefined;
896
+ }, {
897
+ include?: string[] | undefined;
898
+ }>>;
820
899
  }, z.ZodUnknown, "strip">, z.objectInputType<{
821
900
  id: z.ZodString;
822
901
  name: z.ZodOptional<z.ZodString>;
@@ -905,6 +984,15 @@ export declare const CrewxProjectConfigSchema: z.ZodObject<{
905
984
  template: string;
906
985
  }>]>>;
907
986
  }, z.ZodUnknown, "strip">>>;
987
+ timeoutMs: z.ZodOptional<z.ZodNumber>;
988
+ idleTimeoutMs: z.ZodOptional<z.ZodNumber>;
989
+ skills: z.ZodOptional<z.ZodObject<{
990
+ include: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
991
+ }, "strip", z.ZodTypeAny, {
992
+ include?: string[] | undefined;
993
+ }, {
994
+ include?: string[] | undefined;
995
+ }>>;
908
996
  }, z.ZodUnknown, "strip">>, "many">>;
909
997
  hooks: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
910
998
  settings: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
@@ -1000,6 +1088,15 @@ export declare const CrewxProjectConfigSchema: z.ZodObject<{
1000
1088
  template: string;
1001
1089
  }>]>>;
1002
1090
  }, z.ZodUnknown, "strip">>>;
1091
+ timeoutMs: z.ZodOptional<z.ZodNumber>;
1092
+ idleTimeoutMs: z.ZodOptional<z.ZodNumber>;
1093
+ skills: z.ZodOptional<z.ZodObject<{
1094
+ include: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
1095
+ }, "strip", z.ZodTypeAny, {
1096
+ include?: string[] | undefined;
1097
+ }, {
1098
+ include?: string[] | undefined;
1099
+ }>>;
1003
1100
  }, "strip", z.ZodUnknown, z.objectOutputType<{
1004
1101
  id: z.ZodString;
1005
1102
  name: z.ZodOptional<z.ZodString>;
@@ -1088,6 +1185,15 @@ export declare const CrewxProjectConfigSchema: z.ZodObject<{
1088
1185
  template: string;
1089
1186
  }>]>>;
1090
1187
  }, z.ZodUnknown, "strip">>>;
1188
+ timeoutMs: z.ZodOptional<z.ZodNumber>;
1189
+ idleTimeoutMs: z.ZodOptional<z.ZodNumber>;
1190
+ skills: z.ZodOptional<z.ZodObject<{
1191
+ include: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
1192
+ }, "strip", z.ZodTypeAny, {
1193
+ include?: string[] | undefined;
1194
+ }, {
1195
+ include?: string[] | undefined;
1196
+ }>>;
1091
1197
  }, z.ZodUnknown, "strip">, z.objectInputType<{
1092
1198
  id: z.ZodString;
1093
1199
  name: z.ZodOptional<z.ZodString>;
@@ -1176,6 +1282,15 @@ export declare const CrewxProjectConfigSchema: z.ZodObject<{
1176
1282
  template: string;
1177
1283
  }>]>>;
1178
1284
  }, z.ZodUnknown, "strip">>>;
1285
+ timeoutMs: z.ZodOptional<z.ZodNumber>;
1286
+ idleTimeoutMs: z.ZodOptional<z.ZodNumber>;
1287
+ skills: z.ZodOptional<z.ZodObject<{
1288
+ include: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
1289
+ }, "strip", z.ZodTypeAny, {
1290
+ include?: string[] | undefined;
1291
+ }, {
1292
+ include?: string[] | undefined;
1293
+ }>>;
1179
1294
  }, z.ZodUnknown, "strip">>, "many">>;
1180
1295
  hooks: z.ZodOptional<z.ZodArray<z.ZodUnknown, "many">>;
1181
1296
  settings: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crewx/sdk",
3
- "version": "0.8.1",
3
+ "version": "0.8.2-rc.2",
4
4
  "license": "UNLICENSED",
5
5
  "engines": {
6
6
  "node": ">=20.19.0"
@@ -1,59 +1,59 @@
1
- {
2
- "$id": "https://crewx.dev/schemas/hooks",
3
- "type": "array",
4
- "items": {
5
- "type": "object",
6
- "required": ["name"],
7
- "properties": {
8
- "name": { "type": "string" },
9
- "provider": {
10
- "oneOf": [
11
- { "enum": ["claude", "codex", "gemini", "copilot", "opencode"] },
12
- { "type": "array", "items": { "enum": ["claude", "codex", "gemini", "copilot", "opencode"] } }
13
- ]
14
- },
15
- "team": { "oneOf": [{ "type": "string" }, { "type": "array", "items": { "type": "string" } }] },
16
- "role": { "oneOf": [{ "type": "string" }, { "type": "array", "items": { "type": "string" } }] },
17
- "tag": { "oneOf": [{ "type": "string" }, { "type": "array", "items": { "type": "string" } }] },
18
- "agents": { "type": "array", "items": { "type": "string" } },
19
- "event": { "enum": ["PreToolUse"] },
20
- "config": { "type": "object" },
21
- "deny": {
22
- "type": "object",
23
- "required": ["reason"],
24
- "properties": {
25
- "when": { "type": "array", "items": { "type": "string" } },
26
- "pattern": { "type": "string" },
27
- "regex": { "type": "string" },
28
- "pathPattern": { "type": "string" },
29
- "pathSizeMin": { "oneOf": [{ "type": "number" }, { "type": "string" }] },
30
- "pathSizeMax": { "oneOf": [{ "type": "number" }, { "type": "string" }] },
31
- "reason": { "type": "string" }
32
- },
33
- "additionalProperties": false
34
- },
35
- "guide": {
36
- "type": "object",
37
- "required": ["say"],
38
- "properties": {
39
- "when": { "type": "array", "items": { "type": "string" } },
40
- "pattern": { "type": "string" },
41
- "regex": { "type": "string" },
42
- "pathPattern": { "type": "string" },
43
- "pathSizeMin": { "oneOf": [{ "type": "number" }, { "type": "string" }] },
44
- "pathSizeMax": { "oneOf": [{ "type": "number" }, { "type": "string" }] },
45
- "whenInputRegex": { "type": "string" },
46
- "say": { "type": "string" },
47
- "once": { "type": "boolean" }
48
- },
49
- "additionalProperties": false
50
- },
51
- "plugin": { "type": "string" }
52
- },
53
- "oneOf": [
54
- { "required": ["deny"] },
55
- { "required": ["guide"] },
56
- { "required": ["plugin"] }
57
- ]
58
- }
59
- }
1
+ {
2
+ "$id": "https://crewx.dev/schemas/hooks",
3
+ "type": "array",
4
+ "items": {
5
+ "type": "object",
6
+ "required": ["name"],
7
+ "properties": {
8
+ "name": { "type": "string" },
9
+ "provider": {
10
+ "oneOf": [
11
+ { "enum": ["claude", "codex", "gemini", "copilot", "opencode"] },
12
+ { "type": "array", "items": { "enum": ["claude", "codex", "gemini", "copilot", "opencode"] } }
13
+ ]
14
+ },
15
+ "team": { "oneOf": [{ "type": "string" }, { "type": "array", "items": { "type": "string" } }] },
16
+ "role": { "oneOf": [{ "type": "string" }, { "type": "array", "items": { "type": "string" } }] },
17
+ "tag": { "oneOf": [{ "type": "string" }, { "type": "array", "items": { "type": "string" } }] },
18
+ "agents": { "type": "array", "items": { "type": "string" } },
19
+ "event": { "enum": ["PreToolUse"] },
20
+ "config": { "type": "object" },
21
+ "deny": {
22
+ "type": "object",
23
+ "required": ["reason"],
24
+ "properties": {
25
+ "when": { "type": "array", "items": { "type": "string" } },
26
+ "pattern": { "type": "string" },
27
+ "regex": { "type": "string" },
28
+ "pathPattern": { "type": "string" },
29
+ "pathSizeMin": { "oneOf": [{ "type": "number" }, { "type": "string" }] },
30
+ "pathSizeMax": { "oneOf": [{ "type": "number" }, { "type": "string" }] },
31
+ "reason": { "type": "string" }
32
+ },
33
+ "additionalProperties": false
34
+ },
35
+ "guide": {
36
+ "type": "object",
37
+ "required": ["say"],
38
+ "properties": {
39
+ "when": { "type": "array", "items": { "type": "string" } },
40
+ "pattern": { "type": "string" },
41
+ "regex": { "type": "string" },
42
+ "pathPattern": { "type": "string" },
43
+ "pathSizeMin": { "oneOf": [{ "type": "number" }, { "type": "string" }] },
44
+ "pathSizeMax": { "oneOf": [{ "type": "number" }, { "type": "string" }] },
45
+ "whenInputRegex": { "type": "string" },
46
+ "say": { "type": "string" },
47
+ "once": { "type": "boolean" }
48
+ },
49
+ "additionalProperties": false
50
+ },
51
+ "plugin": { "type": "string" }
52
+ },
53
+ "oneOf": [
54
+ { "required": ["deny"] },
55
+ { "required": ["guide"] },
56
+ { "required": ["plugin"] }
57
+ ]
58
+ }
59
+ }