@zibby/cli 0.1.81 → 0.1.82
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.
|
@@ -128,7 +128,7 @@ Analyze the input and return a summary with a status.\`,
|
|
|
128
128
|
outputSchema: ExampleOutputSchema,
|
|
129
129
|
};
|
|
130
130
|
`}function D(o,n){return`${JSON.stringify({name:o,description:`${n} workflow`,entryClass:n,triggers:{api:!0}},null,2)}
|
|
131
|
-
`}function Z(){return`${JSON.stringify({type:"module",dependencies:{"@zibby/core":"^0.1.
|
|
131
|
+
`}function Z(){return`${JSON.stringify({type:"module",dependencies:{"@zibby/core":"^0.1.45"}},null,2)}
|
|
132
132
|
`}async function Ze(o,n={}){let e;o?e=o.toLowerCase():(e=Y(),console.log(t.gray(`
|
|
133
133
|
No name provided \u2014 generated: ${t.white(e)}`))),T.test(e)||(console.log(t.red(`
|
|
134
134
|
Invalid workflow name: "${o}"`)),console.log(t.gray(" Must be lowercase, start with a letter, use only a-z, 0-9, hyphens")),console.log(t.gray(" Length: 2\u201364 characters")),console.log(t.gray(` Example: ticket-triage, pr-review, deploy-checker
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{mkdirSync as
|
|
3
|
-
Zibby Custom Workflow Runner`),console.log(` Job: ${
|
|
4
|
-
Running graph (${
|
|
5
|
-
`);let S;try{S=await
|
|
6
|
-
Workflow execution failed: ${
|
|
7
|
-
Workflow "${
|
|
8
|
-
Workflow "${
|
|
2
|
+
import{mkdirSync as U,writeFileSync as B,existsSync as x}from"fs";import{join as w,dirname as G,resolve as y}from"path";import{pathToFileURL as Q}from"url";import{execSync as J,spawn as P}from"node:child_process";import{SQSClient as L,SendMessageCommand as b}from"@aws-sdk/client-sqs";var E=null;function W(){return E||(E=new L({region:process.env.AWS_REGION||"ap-southeast-2"})),E}async function h(s,{status:e,error:t}){let{EXECUTION_ID:n,SQS_AUTH_TOKEN:i,PROGRESS_API_URL:r,PROGRESS_QUEUE_URL:o,PROJECT_API_TOKEN:f}=s;if(!n)return;let l={executionId:n,...i&&{sqsAuthToken:i},status:e,...t&&{error:t},timestamp:new Date().toISOString()},d=r?"HTTP":o?"SQS":"NONE",u=JSON.stringify(l).length;console.log(`Sending final status: ${e} via ${d} (${(u/1024).toFixed(1)}KB)`);try{if(r)await K(r,n,l,f);else if(o){let c=["completed","failed","insufficient_context","blocked"].includes(e)?"execution_completed":"progress_update";await D(o,n,l,c)}else{console.warn("No transport configured for final status \u2014 neither PROGRESS_API_URL nor PROGRESS_QUEUE_URL set");return}console.log(`Final status ${e} sent via ${d}`)}catch(c){console.error(`Failed to send final status (${e}) via ${d}:`),console.error(` Payload: ${(u/1024).toFixed(1)}KB`),console.error(` Error: ${c.message}`),c.name&&console.error(` Error type: ${c.name}`),c.code&&console.error(` Error code: ${c.code}`)}}async function K(s,e,t,n){let i=`${s}/${e}/progress`,r={"Content-Type":"application/json"};n&&(r.Authorization=`Bearer ${n}`);let o=await fetch(i,{method:"POST",headers:r,body:JSON.stringify(t)});if(!o.ok){let f=await o.text();throw new Error(`HTTP ${o.status}: ${f}`)}}async function D(s,e,t,n="progress_update"){let i=JSON.stringify(t),r=(i.length/1024).toFixed(1);i.length>256*1024&&console.error(`\u274C SQS message too large: ${r}KB (limit 256KB) for ${e} [${n}]`),await W().send(new b({QueueUrl:s,MessageBody:i,MessageGroupId:e,MessageAttributes:{executionId:{DataType:"String",StringValue:e},messageType:{DataType:"String",StringValue:n}}}))}import"@zibby/core";var _=process.env.WORKSPACE||"/workspace";async function H(s,e){U(e,{recursive:!0});let t=Date.now();console.log("Fetching pre-built bundle (streaming curl \u2192 tar)...");let n=setInterval(()=>{let r=((Date.now()-t)/1e3).toFixed(1);console.log(` ...still extracting (${r}s elapsed)`)},3e3);try{await new Promise((r,o)=>{let f=P("curl",["-fsSL",s],{stdio:["ignore","pipe","inherit"]}),l=P("tar",["-xzf","-","-C",e],{stdio:["pipe","inherit","inherit"]});f.stdout.pipe(l.stdin);let d,u,c=()=>{if(d!==void 0&&u!==void 0){if(d!==0)return o(new Error(`curl exited ${d}`));if(u!==0)return o(new Error(`tar exited ${u}`));r()}};f.on("close",p=>{d=p,c()}),l.on("close",p=>{u=p,c()}),f.on("error",o),l.on("error",o)})}finally{clearInterval(n)}let i=((Date.now()-t)/1e3).toFixed(1);return console.log(` Bundle extracted in ${i}s`),e}async function T(){let s=process.env.WORKFLOW_SOURCES_URL;if(!s)throw new Error("WORKFLOW_SOURCES_URL env var is required");console.log("Fetching workflow sources via pre-signed URL...");let e=await fetch(s);if(!e.ok)throw new Error(`Failed to fetch sources: ${e.status} ${e.statusText}`);let t=await e.json();if(!t.sources||typeof t.sources!="object")throw new Error('Invalid sources payload \u2014 missing "sources" map');return t}function M(s,e){let t=y(e),n=0;for(let[i,r]of Object.entries(s)){let o=y(e,i);if(!o.startsWith(`${t}/`)&&o!==t){console.error(` \u26D4 Skipping unsafe path: ${i}`);continue}U(G(o),{recursive:!0}),B(o,r,"utf-8"),n++}return n}async function j(s,e){let t=w(s,"graph.mjs");if(!x(t))throw new Error(`graph.mjs not found at ${t}`);let n=await import(Q(t).href),i=e?.entryClass,r=i&&n[i]||n.default||Object.values(n).find(o=>typeof o=="function"&&o.prototype?.buildGraph);if(!r)throw new Error("No WorkflowAgent class found in graph.mjs");return r}async function ne(){if(!process.env.NODE_PATH){process.env.NODE_PATH="/opt/zibby/packages";let a=await import("module");a.default._initPaths&&a.default._initPaths()}let{WORKFLOW_JOB_ID:s,WORKFLOW_TYPE:e,PROJECT_ID:t,AGENT_TYPE:n,MODEL:i}=process.env;e||(console.error("Missing WORKFLOW_TYPE env var"),process.exit(1)),console.log(`
|
|
3
|
+
Zibby Custom Workflow Runner`),console.log(` Job: ${s||"local"}`),console.log(` Workflow: ${e}`),console.log(` Project: ${t||"none"}`),console.log(` Agent: ${n||"default"}`),console.log(` Model: ${i||"auto"}`),console.log("\u2500".repeat(60));let r=process.env.WORKFLOW_BUNDLE_URL,o,f={},l,d;if(r){l=e,o=w(_,".zibby","workflows",l);try{await H(r,o),console.log(" Extracted pre-built bundle (no npm install needed)");try{let a=await T();f=a.input||{},d=a.version}catch(a){console.warn(` Could not fetch input payload: ${a.message}`)}}catch(a){console.warn(` Bundle extract failed (${a.message}); falling back to source install`),o=null}}if(!o){let a=await T(),{sources:$,input:v,workflowType:N,version:k}=a;f=v||{},l=N||e,d=k,console.log(` Workflow v${d||"?"} \u2014 ${Object.keys($).length} source files`),o=w(_,".zibby","workflows",l);let C=M($,o);console.log(` Wrote ${C} files to ${o}`),console.log(" Installing dependencies...");try{J("npm install --silent --no-audit --no-fund",{cwd:o,stdio:"inherit"}),console.log(" Dependencies installed")}catch(F){console.warn(` npm install failed: ${F.message}`)}}let u={},c=w(o,"workflow.json");if(x(c)){let{readFileSync:a}=await import("fs");u=JSON.parse(a(c,"utf-8"))}let p=await j(o,u);console.log(` Loaded ${p.name}`);let I=Date.now(),g=new p({workflow:l||e}),O=g.buildGraph(),A={input:f||{},cwd:_,runId:s||`run-${Date.now()}`};console.log(`
|
|
4
|
+
Running graph (${O.nodes?.size||"?"} nodes)...
|
|
5
|
+
`);let S;try{S=await O.run(g,A)}catch(a){console.error(`
|
|
6
|
+
Workflow execution failed: ${a.message}`),console.error(a.stack),await m("failed",a.message),process.exit(1)}let R=((Date.now()-I)/1e3).toFixed(1);S?.success!==!1?(console.log(`
|
|
7
|
+
Workflow "${l||e}" completed in ${R}s`),await m("completed")):(console.error(`
|
|
8
|
+
Workflow "${l||e}" failed after ${R}s`),await m("failed",S?.error||"Workflow execution failed"),process.exit(1)),g.onComplete&&await g.onComplete(S)}async function m(s,e=null){let t={EXECUTION_ID:process.env.WORKFLOW_JOB_ID,PROGRESS_API_URL:process.env.PROGRESS_API_URL,PROGRESS_QUEUE_URL:process.env.PROGRESS_QUEUE_URL,PROJECT_API_TOKEN:process.env.PROJECT_API_TOKEN,SQS_AUTH_TOKEN:process.env.SQS_AUTH_TOKEN};if(t.EXECUTION_ID)try{await h(t,{status:s,...e&&{error:e}})}catch(n){console.error(`\u26A0\uFE0F Failed to report status: ${n.message}`)}}export{ne as runWorkflowCommand};
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zibby/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.82",
|
|
4
4
|
"description": "Zibby CLI - Test automation generator and runner",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@aws-sdk/client-sqs": "^3.1038.0",
|
|
36
36
|
"@zibby/agent-workflow": "^0.1.2",
|
|
37
|
-
"@zibby/core": "^0.1.
|
|
37
|
+
"@zibby/core": "^0.1.45",
|
|
38
38
|
"@zibby/memory": "^0.1.5",
|
|
39
39
|
"@zibby/skills": "^0.1.11",
|
|
40
40
|
"adm-zip": "^0.5.17",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zibby/cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.82",
|
|
4
4
|
"description": "Zibby CLI - Test automation generator and runner",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@aws-sdk/client-sqs": "^3.1038.0",
|
|
36
36
|
"@zibby/agent-workflow": "^0.1.2",
|
|
37
|
-
"@zibby/core": "^0.1.
|
|
37
|
+
"@zibby/core": "^0.1.45",
|
|
38
38
|
"@zibby/memory": "^0.1.5",
|
|
39
39
|
"@zibby/skills": "^0.1.11",
|
|
40
40
|
"adm-zip": "^0.5.17",
|