zooid 0.5.1 → 0.6.0
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/README.md +195 -163
- package/dist/chunk-AR456MHY.js +29 -0
- package/dist/index.js +2423 -765
- package/dist/template-T5IB4YWC.js +92 -0
- package/package.json +5 -5
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
parseGitHubUrl
|
|
4
|
+
} from "./chunk-AR456MHY.js";
|
|
5
|
+
|
|
6
|
+
// src/lib/template.ts
|
|
7
|
+
import fs from "fs";
|
|
8
|
+
import path from "path";
|
|
9
|
+
import os from "os";
|
|
10
|
+
import { execSync } from "child_process";
|
|
11
|
+
async function fetchTemplate(url, targetDir, options) {
|
|
12
|
+
const parts = parseGitHubUrl(url);
|
|
13
|
+
if (!parts) {
|
|
14
|
+
throw new Error(
|
|
15
|
+
"Only GitHub URLs are supported. Use https://github.com/owner/repo or https://github.com/owner/repo/tree/ref/path"
|
|
16
|
+
);
|
|
17
|
+
}
|
|
18
|
+
const fetchFn = options?.fetch ?? globalThis.fetch;
|
|
19
|
+
const tarballUrl = `https://api.github.com/repos/${parts.owner}/${parts.repo}/tarball/${parts.ref}`;
|
|
20
|
+
const res = await fetchFn(tarballUrl, {
|
|
21
|
+
headers: {
|
|
22
|
+
Accept: "application/vnd.github+json",
|
|
23
|
+
"User-Agent": "zooid-cli"
|
|
24
|
+
},
|
|
25
|
+
redirect: "follow"
|
|
26
|
+
});
|
|
27
|
+
if (!res.ok) {
|
|
28
|
+
throw new Error(`Failed to fetch template from GitHub: HTTP ${res.status}`);
|
|
29
|
+
}
|
|
30
|
+
const tmpTarball = path.join(
|
|
31
|
+
os.tmpdir(),
|
|
32
|
+
`zooid-template-${Date.now()}.tar.gz`
|
|
33
|
+
);
|
|
34
|
+
const arrayBuffer = await res.arrayBuffer();
|
|
35
|
+
const buffer = new Uint8Array(arrayBuffer);
|
|
36
|
+
if (buffer.byteLength === 0) {
|
|
37
|
+
throw new Error(
|
|
38
|
+
"This doesn't look like a Zooid template (no .zooid/workforce.json found)"
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
fs.writeFileSync(tmpTarball, new Uint8Array(buffer));
|
|
42
|
+
try {
|
|
43
|
+
const tmpExtract = fs.mkdtempSync(
|
|
44
|
+
path.join(os.tmpdir(), "zooid-template-extract-")
|
|
45
|
+
);
|
|
46
|
+
execSync(`tar xzf "${tmpTarball}" -C "${tmpExtract}"`, {
|
|
47
|
+
stdio: "pipe"
|
|
48
|
+
});
|
|
49
|
+
const entries = fs.readdirSync(tmpExtract);
|
|
50
|
+
const topDir = entries[0];
|
|
51
|
+
if (!topDir) {
|
|
52
|
+
throw new Error("Empty tarball");
|
|
53
|
+
}
|
|
54
|
+
const extractRoot = path.join(tmpExtract, topDir);
|
|
55
|
+
const sourceRoot = parts.path ? path.join(extractRoot, parts.path) : extractRoot;
|
|
56
|
+
if (!fs.existsSync(sourceRoot)) {
|
|
57
|
+
throw new Error(
|
|
58
|
+
`Path "${parts.path}" not found in ${parts.owner}/${parts.repo}`
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
const sourceZooid = path.join(sourceRoot, ".zooid");
|
|
62
|
+
const targetZooid = path.join(targetDir, ".zooid");
|
|
63
|
+
let channelCount = 0;
|
|
64
|
+
let roleCount = 0;
|
|
65
|
+
if (fs.existsSync(sourceZooid)) {
|
|
66
|
+
fs.cpSync(sourceZooid, targetZooid, { recursive: true });
|
|
67
|
+
const wfPath = path.join(sourceZooid, "workforce.json");
|
|
68
|
+
if (fs.existsSync(wfPath)) {
|
|
69
|
+
const wf = JSON.parse(fs.readFileSync(wfPath, "utf-8"));
|
|
70
|
+
channelCount = Object.keys(wf.channels ?? {}).length;
|
|
71
|
+
roleCount = Object.keys(wf.roles ?? {}).length + Object.keys(wf.agents ?? {}).length;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
const sourceConfig = path.join(sourceRoot, "zooid.json");
|
|
75
|
+
const targetConfig = path.join(targetDir, "zooid.json");
|
|
76
|
+
if (fs.existsSync(sourceConfig) && !fs.existsSync(targetConfig)) {
|
|
77
|
+
fs.copyFileSync(sourceConfig, targetConfig);
|
|
78
|
+
}
|
|
79
|
+
fs.rmSync(tmpExtract, { recursive: true, force: true });
|
|
80
|
+
if (channelCount === 0 && roleCount === 0) {
|
|
81
|
+
throw new Error(
|
|
82
|
+
"This doesn't look like a Zooid template (no .zooid/workforce.json found)"
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
return { channelCount, roleCount };
|
|
86
|
+
} finally {
|
|
87
|
+
fs.rmSync(tmpTarball, { force: true });
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
export {
|
|
91
|
+
fetchTemplate
|
|
92
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zooid",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Open-source pub/sub server for AI agents. Publish signals, subscribe via webhook, WebSocket, polling, or RSS.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -24,12 +24,12 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@inquirer/checkbox": "^5.0.7",
|
|
26
26
|
"commander": "^14.0.3",
|
|
27
|
-
"@zooid/
|
|
28
|
-
"@zooid/types": "^0.
|
|
29
|
-
"@zooid/
|
|
27
|
+
"@zooid/server": "^0.6.0",
|
|
28
|
+
"@zooid/types": "^0.6.0",
|
|
29
|
+
"@zooid/sdk": "^0.6.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@cloudflare/vitest-pool-workers": "^0.
|
|
32
|
+
"@cloudflare/vitest-pool-workers": "^0.12.21",
|
|
33
33
|
"execa": "^9.5.3",
|
|
34
34
|
"tsup": "^8.5.1",
|
|
35
35
|
"vitest": "^3.2.0"
|