@crewx/sdk 0.9.0-rc.136 → 0.9.0-rc.138

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.
@@ -0,0 +1,93 @@
1
+ export type JsonObject = Record<string, unknown>;
2
+ export type JsonSchema = Readonly<{
3
+ type: 'object';
4
+ properties: Readonly<Record<string, unknown>>;
5
+ required: readonly string[];
6
+ additionalProperties: false;
7
+ }>;
8
+ export type ToolResult = void | JsonObject | Promise<void | JsonObject>;
9
+ export interface AppDefinition {
10
+ readonly manifestVersion: 2;
11
+ readonly pluginId: string;
12
+ readonly definitionId: string;
13
+ readonly version: number;
14
+ readonly name: string;
15
+ readonly description: string;
16
+ readonly icon?: string;
17
+ readonly tone?: string;
18
+ readonly entry: string;
19
+ readonly initialState: Readonly<{
20
+ path: string;
21
+ }>;
22
+ readonly dataPaths?: readonly string[];
23
+ readonly surfaces: readonly string[];
24
+ readonly size?: Readonly<Record<string, number>>;
25
+ readonly stateProjection: Readonly<{
26
+ allow: readonly string[];
27
+ }>;
28
+ }
29
+ export interface ToolOptions {
30
+ readonly name: string;
31
+ readonly description: string;
32
+ readonly inputSchema: JsonSchema;
33
+ readonly capability?: string;
34
+ readonly confirmation?: string;
35
+ readonly mutation?: boolean;
36
+ readonly dataInputs?: readonly string[];
37
+ readonly resultProjection?: Readonly<{
38
+ allow: readonly string[];
39
+ }>;
40
+ }
41
+ export interface AppRuntimeOptions<State extends JsonObject = JsonObject> {
42
+ readonly state?: State;
43
+ readonly workspaceRoot: string;
44
+ }
45
+ export interface AppErrorMapping {
46
+ readonly code: string;
47
+ readonly detail: string | null;
48
+ }
49
+ export interface AppErrorContext {
50
+ readonly input: unknown;
51
+ readonly state: unknown;
52
+ }
53
+ export type DeepReadonly<T> = T extends (...args: never[]) => unknown ? T : T extends readonly (infer Item)[] ? readonly DeepReadonly<Item>[] : T extends object ? {
54
+ readonly [Key in keyof T]: DeepReadonly<T[Key]>;
55
+ } : T;
56
+ export declare class AppError extends Error {
57
+ readonly code: string;
58
+ readonly detail: string | null;
59
+ constructor(code: string, detail?: string | null);
60
+ }
61
+ export declare class CrewXApp<State extends JsonObject = JsonObject> {
62
+ static readonly devtools: {
63
+ readonly log: boolean;
64
+ } | undefined;
65
+ private currentState;
66
+ private stateWasSet;
67
+ readonly workspaceRoot: string;
68
+ constructor(options?: AppRuntimeOptions<State>);
69
+ get state(): DeepReadonly<State>;
70
+ get didSetState(): boolean;
71
+ setState(next: State): void;
72
+ emptyState(): State;
73
+ validate(_actionId: string, _input: JsonObject, _state: JsonObject): void | Promise<void>;
74
+ mapError(_error: unknown): AppErrorMapping;
75
+ errorState(code: string, detail: string | null, context: AppErrorContext): State;
76
+ }
77
+ export interface ToolDeclaration {
78
+ readonly methodName: string;
79
+ readonly options: ToolOptions;
80
+ }
81
+ export type CrewXAppConstructor = (new (options: AppRuntimeOptions) => CrewXApp) & {
82
+ readonly devtools?: {
83
+ readonly log?: boolean;
84
+ };
85
+ readonly definition: AppDefinition;
86
+ readonly [key: string]: unknown;
87
+ };
88
+ type DecoratedMethod<This, Input extends object, Result extends ToolResult> = (this: This, input: Input) => Result;
89
+ export declare function Tool(options: ToolOptions): <This, Input extends object, Result extends ToolResult>(_method: DecoratedMethod<This, Input, Result>, context: ClassMethodDecoratorContext<This, DecoratedMethod<This, Input, Result>>) => void;
90
+ export declare function getToolDeclarations(appClass: CrewXAppConstructor): ToolDeclaration[];
91
+ export declare function generateManifest(appClass: CrewXAppConstructor, backendCommand: readonly string[]): JsonObject;
92
+ export declare function isPlainRecord(value: unknown): value is JsonObject;
93
+ export {};
@@ -0,0 +1,7 @@
1
+ import type { JsonObject } from './app.js';
2
+ export interface AppEntryOptions {
3
+ readonly sanitize?: (value: unknown) => unknown;
4
+ readonly emptyState?: JsonObject;
5
+ readonly inputFd?: number;
6
+ }
7
+ export declare function runAppEntry(importApp: () => Promise<unknown>, options?: AppEntryOptions): Promise<void>;
@@ -0,0 +1,6 @@
1
+ export { AppError, CrewXApp, Tool, generateManifest, getToolDeclarations, } from './app.js';
2
+ export type { AppDefinition, AppErrorContext, AppErrorMapping, AppRuntimeOptions, CrewXAppConstructor, DeepReadonly, JsonObject, JsonSchema, ToolDeclaration, ToolOptions, ToolResult, } from './app.js';
3
+ export { executeAppRequest, runSkillApp } from './runtime.js';
4
+ export type { RunSkillAppOptions } from './runtime.js';
5
+ export { runAppEntry } from './entry.js';
6
+ export type { AppEntryOptions } from './entry.js';
@@ -0,0 +1,9 @@
1
+ 'use strict';var fs=require('fs'),util=require('util'),console$1=require('console'),stream=require('stream');var j=Symbol;j.metadata===void 0&&Object.defineProperty(Symbol,"metadata",{configurable:false,value:Symbol.for("Symbol.metadata")});var N=j.metadata,O=Symbol.for("crewx.app.tool-metadata"),w=class extends Error{code;detail;constructor(e,r=null){super(e),this.name="AppError",this.code=e,this.detail=r;}},b=class{static devtools=process.env.CREWX_APP_DEV==="1"?Object.freeze({log:true}):void 0;currentState;stateWasSet=false;workspaceRoot;constructor(e={workspaceRoot:process.cwd()}){this.currentState=e.state??{},this.workspaceRoot=e.workspaceRoot;}get state(){return this.currentState}get didSetState(){return this.stateWasSet}setState(e){this.currentState=e,this.stateWasSet=true;}emptyState(){return {}}validate(e,r,n){}mapError(e){return {code:"EXECUTION_FAILED",detail:null}}errorState(e,r,n){return {...g(n.state)?n.state:{},error:{code:e,detail:r}}}};function P(t){return function(e,r){if(r.static||r.private||r.kind!=="method")throw new TypeError("@Tool can decorate public instance methods only");let n=r.metadata;if(!n)throw new TypeError("standard decorator metadata is unavailable");let i=Object.hasOwn(n,O)?n[O]:[];if(i.some(a=>a.methodName===String(r.name)))throw new TypeError(`@Tool is declared more than once for ${String(r.name)}`);n[O]=[...i,{methodName:String(r.name),options:Object.freeze({...t})}];}}function S(t){let e=t[N],r=e&&Object.hasOwn(e,O)?e[O]:[],n=new Map(r.map(a=>[a.methodName,a])),i=Object.getOwnPropertyNames(t.prototype).map(a=>n.get(a)).filter(a=>a!==void 0);if(i.length!==r.length)throw new TypeError("a @Tool method is missing from the App prototype");return i}function J(t,e){if(e.length===0)throw new TypeError("backendCommand must name the skill command");let r=t.definition,n=S(t),i=new Set,a=n.map(({options:o})=>{if(i.has(o.name))throw new TypeError(`duplicate @Tool name: ${o.name}`);return i.add(o.name),{actionId:o.name,...o.dataInputs===void 0?{}:{dataInputs:[...o.dataInputs]},confirmation:o.confirmation??"none",capability:o.capability??"app.read",mutation:o.mutation??true,inputSchema:o.inputSchema,resultProjection:o.resultProjection??{allow:[...r.stateProjection.allow]},backend:{type:"skill",command:[...e]},_meta:{description:o.description}}});return {...r,actions:a}}function g(t){if(t===null||typeof t!="object"||Array.isArray(t))return false;let e=Object.getPrototypeOf(t);return e===Object.prototype||e===null}var L=1,U=64*1024;function M(t,e,r=process.env.CREWX_WORKSPACE_ROOT??process.cwd()){return _(t,e,r)}async function _(t,e,r,n,i=true){let a=g(e)?e:void 0,o=a?.input,d=a?.state,s=new t({state:g(d)?d:{},workspaceRoot:r}),y=g(o)?o:{},h=g(d)?d:s.emptyState();try{if(!a||Object.keys(a).length!==4||!["schemaVersion","actionId","input","state"].every(p=>Object.hasOwn(a,p))||a.schemaVersion!==L||typeof a.actionId!="string"||!g(o)||!g(d))throw new w("INPUT_INVALID");y=o,h=d,s=new t({state:h,workspaceRoot:r}),await s.validate(a.actionId,y,h);let c=S(t).find(({options:p})=>p.name===a.actionId);if(!c)throw new w("INPUT_INVALID");let u=s[c.methodName];if(typeof u!="function")throw new w("EXECUTION_FAILED");let f=()=>u.call(s,y),l=i?await $(f):await f();if(l!==void 0&&!g(l))throw new w("EXECUTION_FAILED");return {...s.didSetState?{state:s.state}:{},...l===void 0?{}:{result:l}}}catch(c){let u,f=c;if(c instanceof w)u={code:c.code,detail:c.detail};else try{u=s.mapError(c);}catch(E){u={code:"EXECUTION_FAILED",detail:null},f=E;}let l=K(u?.code)?u.code:"EXECUTION_FAILED",p=typeof u?.detail=="string"?u.detail:null,m;try{m=s.errorState(l,p,{input:y,state:h});}catch(E){f=new AggregateError([f,E],"App error handling failed"),m=s.emptyState();}return n?.(l,f),{outcome:"failed",errorCode:l,state:g(m)?m:s.emptyState()}}}async function z(t,e={}){let r=e.output??process.stdout,n;if(e.preloadedInput!==void 0)n=e.preloadedInput.value;else try{n=JSON.parse(W(e.inputFd??0,U));}catch{n=void 0;}let i=false,a=(s,y)=>{i=true,e.onFailure?.(s,y);},o;try{o=await _(t,n,process.env.CREWX_WORKSPACE_ROOT??process.cwd(),a,e.consoleManaged!==!0);}catch(s){a("EXECUTION_FAILED",s),o=D(e.emptyState);}q(o)&&!i&&a(o.errorCode);let d;try{o=(e.sanitize??x)(o),d=`${JSON.stringify(o)}
2
+ `;}catch(s){a("EXECUTION_FAILED",s),o=D(e.emptyState);try{d=`${JSON.stringify((e.sanitize??x)(o))}
3
+ `;}catch(y){a("EXECUTION_FAILED",y),d=`${JSON.stringify(o)}
4
+ `;}}r.write(d);}function W(t,e){let r=new TextDecoder,n="",i=0;for(;;){let a=new Uint8Array(8192),o=fs.readSync(t,a,0,a.length,null);if(o===0)break;if(i+=o,i>e)throw new w("INPUT_INVALID");n+=r.decode(a.subarray(0,o),{stream:true});}return n+r.decode()}async function $(t){let e=["log","info","debug"],r=new Map;for(let n of e)r.set(n,console[n]),console[n]=(...i)=>process.stderr.write(`${util.format(...i)}
5
+ `);try{return await t()}finally{for(let n of e)console[n]=r.get(n);}}function D(t={}){return {outcome:"failed",errorCode:"EXECUTION_FAILED",state:{...t,error:{code:"EXECUTION_FAILED",detail:null}}}}function q(t){return (t.outcome==="failed"||t.outcome==="rejected")&&typeof t.errorCode=="string"}function K(t){return typeof t=="string"&&/^[A-Z][A-Z0-9_]{0,127}$/u.test(t)}function x(t){return t}var H=64*1024,I={depth:null,maxArrayLength:null,maxStringLength:null},C=class extends stream.Writable{#e="buffer";#t=[];_write(e,r,n){if(this.#e==="buffer"){this.#t.push(typeof e=="string"?e:Uint8Array.from(e)),n();return}if(this.#e==="discard"){n();return}process.stderr.write(e,n);}flushToStderr(){this.#e="stderr";for(let e of this.#t)process.stderr.write(e);this.#t=[];}discard(){this.#e="discard",this.#t=[];}};async function Z(t,e={}){let r=process.stdout,n=r.write.bind(r),i=new C,a=new console$1.Console({stdout:i,stderr:i,inspectOptions:{...I}});globalThis.console=a;let o=false,d="-",s="-",y,h=false,c,u;try{let p=Q(e.inputFd??0);d=G(p.value),s=k(process.env.CREWX_APP_REQUEST_ID),y=new Date().toISOString();try{c=await t();}catch(A){h=!0,u=A;}let m=c?.default;if(!h&&m?.devtools?.log===!0?(Object.assign(util.inspect.defaultOptions,I),f(y),i.flushToStderr()):i.discard(),h){l("EXECUTION_FAILED",u),R(n,e,l);return}try{if(typeof c?.runSkillApp!="function")throw new TypeError("App module does not export runSkillApp");let A={sanitize:e.sanitize,emptyState:e.emptyState,preloadedInput:{value:p.value},onFailure:l,consoleManaged:!0,output:{write:n}};await c.runSkillApp(m,A);}catch(A){l("EXECUTION_FAILED",A),R(n,e,l);}}catch(p){l("EXECUTION_FAILED",p),R(n,e,l);}finally{process.exitCode=0;}function f(p){o||(process.stderr.write(`[crewx-app] ${p??new Date().toISOString()} ${k(d)} req=${s}
6
+ `),o=true);}function l(p,m){f(),process.stderr.write(`[crewx-app] failed ${k(p)}
7
+ `),m!==void 0&&process.stderr.write(`${util.inspect(m,I)}
8
+ `);}}function Q(t){try{let e=[],r=0;for(;;){let n=new Uint8Array(8192),i=fs.readSync(t,n,0,n.length,null);if(i===0)break;if(r+=i,r>H)return {value:void 0};e.push(n.subarray(0,i));}return {value:JSON.parse(Buffer.concat(e,r).toString("utf8"))}}catch{return {value:void 0}}}function G(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)&&typeof t.actionId=="string"?t.actionId:"-"}function k(t){return typeof t!="string"||t.length===0?"-":t.replace(/[\u0000-\u001f\u007f\u2028\u2029]/gu,"_")}function R(t,e,r){let n={code:"EXECUTION_FAILED",detail:null},a={outcome:"failed",errorCode:"EXECUTION_FAILED",state:e.emptyState!==null&&typeof e.emptyState=="object"&&!Array.isArray(e.emptyState)?{...e.emptyState,error:n}:{error:n}},o=a;try{o=(e.sanitize??ee)(a);}catch(d){r("EXECUTION_FAILED",d);}t(`${JSON.stringify(o)}
9
+ `);}function ee(t){return t}exports.AppError=w;exports.CrewXApp=b;exports.Tool=P;exports.executeAppRequest=M;exports.generateManifest=J;exports.getToolDeclarations=S;exports.runAppEntry=Z;exports.runSkillApp=z;
@@ -0,0 +1,14 @@
1
+ import { type CrewXAppConstructor, type JsonObject } from './app.js';
2
+ export interface RunSkillAppOptions {
3
+ readonly sanitize?: (value: unknown) => unknown;
4
+ readonly inputFd?: number;
5
+ readonly output?: Pick<NodeJS.WriteStream, 'write'>;
6
+ readonly emptyState?: JsonObject;
7
+ readonly preloadedInput?: {
8
+ readonly value: unknown;
9
+ };
10
+ readonly onFailure?: (errorCode: string, error?: unknown) => void;
11
+ readonly consoleManaged?: boolean;
12
+ }
13
+ export declare function executeAppRequest(appClass: CrewXAppConstructor, rawRequest: unknown, workspaceRoot?: string): Promise<JsonObject>;
14
+ export declare function runSkillApp(appClass: CrewXAppConstructor, options?: RunSkillAppOptions): Promise<void>;
@@ -0,0 +1,9 @@
1
+ import {readSync}from'fs';import {format,inspect}from'util';import {Console}from'console';import {Writable}from'stream';var D=Symbol;D.metadata===void 0&&Object.defineProperty(Symbol,"metadata",{configurable:false,value:Symbol.for("Symbol.metadata")});var P=D.metadata,O=Symbol.for("crewx.app.tool-metadata"),w=class extends Error{code;detail;constructor(e,r=null){super(e),this.name="AppError",this.code=e,this.detail=r;}},b=class{static devtools=process.env.CREWX_APP_DEV==="1"?Object.freeze({log:true}):void 0;currentState;stateWasSet=false;workspaceRoot;constructor(e={workspaceRoot:process.cwd()}){this.currentState=e.state??{},this.workspaceRoot=e.workspaceRoot;}get state(){return this.currentState}get didSetState(){return this.stateWasSet}setState(e){this.currentState=e,this.stateWasSet=true;}emptyState(){return {}}validate(e,r,n){}mapError(e){return {code:"EXECUTION_FAILED",detail:null}}errorState(e,r,n){return {...g(n.state)?n.state:{},error:{code:e,detail:r}}}};function J(t){return function(e,r){if(r.static||r.private||r.kind!=="method")throw new TypeError("@Tool can decorate public instance methods only");let n=r.metadata;if(!n)throw new TypeError("standard decorator metadata is unavailable");let i=Object.hasOwn(n,O)?n[O]:[];if(i.some(a=>a.methodName===String(r.name)))throw new TypeError(`@Tool is declared more than once for ${String(r.name)}`);n[O]=[...i,{methodName:String(r.name),options:Object.freeze({...t})}];}}function S(t){let e=t[P],r=e&&Object.hasOwn(e,O)?e[O]:[],n=new Map(r.map(a=>[a.methodName,a])),i=Object.getOwnPropertyNames(t.prototype).map(a=>n.get(a)).filter(a=>a!==void 0);if(i.length!==r.length)throw new TypeError("a @Tool method is missing from the App prototype");return i}function X(t,e){if(e.length===0)throw new TypeError("backendCommand must name the skill command");let r=t.definition,n=S(t),i=new Set,a=n.map(({options:o})=>{if(i.has(o.name))throw new TypeError(`duplicate @Tool name: ${o.name}`);return i.add(o.name),{actionId:o.name,...o.dataInputs===void 0?{}:{dataInputs:[...o.dataInputs]},confirmation:o.confirmation??"none",capability:o.capability??"app.read",mutation:o.mutation??true,inputSchema:o.inputSchema,resultProjection:o.resultProjection??{allow:[...r.stateProjection.allow]},backend:{type:"skill",command:[...e]},_meta:{description:o.description}}});return {...r,actions:a}}function g(t){if(t===null||typeof t!="object"||Array.isArray(t))return false;let e=Object.getPrototypeOf(t);return e===Object.prototype||e===null}var U=1,M=64*1024;function z(t,e,r=process.env.CREWX_WORKSPACE_ROOT??process.cwd()){return v(t,e,r)}async function v(t,e,r,n,i=true){let a=g(e)?e:void 0,o=a?.input,d=a?.state,s=new t({state:g(d)?d:{},workspaceRoot:r}),y=g(o)?o:{},h=g(d)?d:s.emptyState();try{if(!a||Object.keys(a).length!==4||!["schemaVersion","actionId","input","state"].every(p=>Object.hasOwn(a,p))||a.schemaVersion!==U||typeof a.actionId!="string"||!g(o)||!g(d))throw new w("INPUT_INVALID");y=o,h=d,s=new t({state:h,workspaceRoot:r}),await s.validate(a.actionId,y,h);let c=S(t).find(({options:p})=>p.name===a.actionId);if(!c)throw new w("INPUT_INVALID");let u=s[c.methodName];if(typeof u!="function")throw new w("EXECUTION_FAILED");let f=()=>u.call(s,y),l=i?await q(f):await f();if(l!==void 0&&!g(l))throw new w("EXECUTION_FAILED");return {...s.didSetState?{state:s.state}:{},...l===void 0?{}:{result:l}}}catch(c){let u,f=c;if(c instanceof w)u={code:c.code,detail:c.detail};else try{u=s.mapError(c);}catch(E){u={code:"EXECUTION_FAILED",detail:null},f=E;}let l=V(u?.code)?u.code:"EXECUTION_FAILED",p=typeof u?.detail=="string"?u.detail:null,m;try{m=s.errorState(l,p,{input:y,state:h});}catch(E){f=new AggregateError([f,E],"App error handling failed"),m=s.emptyState();}return n?.(l,f),{outcome:"failed",errorCode:l,state:g(m)?m:s.emptyState()}}}async function W(t,e={}){let r=e.output??process.stdout,n;if(e.preloadedInput!==void 0)n=e.preloadedInput.value;else try{n=JSON.parse($(e.inputFd??0,M));}catch{n=void 0;}let i=false,a=(s,y)=>{i=true,e.onFailure?.(s,y);},o;try{o=await v(t,n,process.env.CREWX_WORKSPACE_ROOT??process.cwd(),a,e.consoleManaged!==!0);}catch(s){a("EXECUTION_FAILED",s),o=x(e.emptyState);}K(o)&&!i&&a(o.errorCode);let d;try{o=(e.sanitize??_)(o),d=`${JSON.stringify(o)}
2
+ `;}catch(s){a("EXECUTION_FAILED",s),o=x(e.emptyState);try{d=`${JSON.stringify((e.sanitize??_)(o))}
3
+ `;}catch(y){a("EXECUTION_FAILED",y),d=`${JSON.stringify(o)}
4
+ `;}}r.write(d);}function $(t,e){let r=new TextDecoder,n="",i=0;for(;;){let a=new Uint8Array(8192),o=readSync(t,a,0,a.length,null);if(o===0)break;if(i+=o,i>e)throw new w("INPUT_INVALID");n+=r.decode(a.subarray(0,o),{stream:true});}return n+r.decode()}async function q(t){let e=["log","info","debug"],r=new Map;for(let n of e)r.set(n,console[n]),console[n]=(...i)=>process.stderr.write(`${format(...i)}
5
+ `);try{return await t()}finally{for(let n of e)console[n]=r.get(n);}}function x(t={}){return {outcome:"failed",errorCode:"EXECUTION_FAILED",state:{...t,error:{code:"EXECUTION_FAILED",detail:null}}}}function K(t){return (t.outcome==="failed"||t.outcome==="rejected")&&typeof t.errorCode=="string"}function V(t){return typeof t=="string"&&/^[A-Z][A-Z0-9_]{0,127}$/u.test(t)}function _(t){return t}var Z=64*1024,k={depth:null,maxArrayLength:null,maxStringLength:null},j=class extends Writable{#e="buffer";#t=[];_write(e,r,n){if(this.#e==="buffer"){this.#t.push(typeof e=="string"?e:Uint8Array.from(e)),n();return}if(this.#e==="discard"){n();return}process.stderr.write(e,n);}flushToStderr(){this.#e="stderr";for(let e of this.#t)process.stderr.write(e);this.#t=[];}discard(){this.#e="discard",this.#t=[];}};async function Q(t,e={}){let r=process.stdout,n=r.write.bind(r),i=new j,a=new Console({stdout:i,stderr:i,inspectOptions:{...k}});globalThis.console=a;let o=false,d="-",s="-",y,h=false,c,u;try{let p=G(e.inputFd??0);d=ee(p.value),s=R(process.env.CREWX_APP_REQUEST_ID),y=new Date().toISOString();try{c=await t();}catch(A){h=!0,u=A;}let m=c?.default;if(!h&&m?.devtools?.log===!0?(Object.assign(inspect.defaultOptions,k),f(y),i.flushToStderr()):i.discard(),h){l("EXECUTION_FAILED",u),C(n,e,l);return}try{if(typeof c?.runSkillApp!="function")throw new TypeError("App module does not export runSkillApp");let A={sanitize:e.sanitize,emptyState:e.emptyState,preloadedInput:{value:p.value},onFailure:l,consoleManaged:!0,output:{write:n}};await c.runSkillApp(m,A);}catch(A){l("EXECUTION_FAILED",A),C(n,e,l);}}catch(p){l("EXECUTION_FAILED",p),C(n,e,l);}finally{process.exitCode=0;}function f(p){o||(process.stderr.write(`[crewx-app] ${p??new Date().toISOString()} ${R(d)} req=${s}
6
+ `),o=true);}function l(p,m){f(),process.stderr.write(`[crewx-app] failed ${R(p)}
7
+ `),m!==void 0&&process.stderr.write(`${inspect(m,k)}
8
+ `);}}function G(t){try{let e=[],r=0;for(;;){let n=new Uint8Array(8192),i=readSync(t,n,0,n.length,null);if(i===0)break;if(r+=i,r>Z)return {value:void 0};e.push(n.subarray(0,i));}return {value:JSON.parse(Buffer.concat(e,r).toString("utf8"))}}catch{return {value:void 0}}}function ee(t){return t!==null&&typeof t=="object"&&!Array.isArray(t)&&typeof t.actionId=="string"?t.actionId:"-"}function R(t){return typeof t!="string"||t.length===0?"-":t.replace(/[\u0000-\u001f\u007f\u2028\u2029]/gu,"_")}function C(t,e,r){let n={code:"EXECUTION_FAILED",detail:null},a={outcome:"failed",errorCode:"EXECUTION_FAILED",state:e.emptyState!==null&&typeof e.emptyState=="object"&&!Array.isArray(e.emptyState)?{...e.emptyState,error:n}:{error:n}},o=a;try{o=(e.sanitize??te)(a);}catch(d){r("EXECUTION_FAILED",d);}t(`${JSON.stringify(o)}
9
+ `);}function te(t){return t}export{w as AppError,b as CrewXApp,J as Tool,z as executeAppRequest,X as generateManifest,S as getToolDeclarations,Q as runAppEntry,W as runSkillApp};