@orchagent/cli 0.3.71 → 0.3.73
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/init.js +157 -12
- package/dist/commands/publish.js +21 -15
- package/dist/commands/run.js +5 -3
- package/package.json +1 -1
package/dist/commands/init.js
CHANGED
|
@@ -361,6 +361,64 @@ Edit \`main.py\` to customize:
|
|
|
361
361
|
|
|
362
362
|
## Environment Variables
|
|
363
363
|
|
|
364
|
+
| Variable | Required | Description |
|
|
365
|
+
|----------|----------|-------------|
|
|
366
|
+
| \`DISCORD_BOT_TOKEN\` | Yes | Discord bot token (workspace secret) |
|
|
367
|
+
| \`ANTHROPIC_API_KEY\` | Auto | Injected by orchagent via \`supported_providers\` |
|
|
368
|
+
| \`DISCORD_CHANNEL_IDS\` | Yes | Comma-separated channel IDs (workspace secret) |
|
|
369
|
+
| \`MODEL\` | No | Claude model (default: claude-sonnet-4-5-20250929) |
|
|
370
|
+
| \`MAX_TOKENS\` | No | Max response tokens (default: 1024) |
|
|
371
|
+
`;
|
|
372
|
+
}
|
|
373
|
+
if (flavor === 'discord_js') {
|
|
374
|
+
return `# ${agentName}
|
|
375
|
+
|
|
376
|
+
An always-on Discord bot powered by Claude (JavaScript).
|
|
377
|
+
|
|
378
|
+
## Setup
|
|
379
|
+
|
|
380
|
+
### 1. Create a Discord bot
|
|
381
|
+
|
|
382
|
+
1. Go to the [Discord Developer Portal](https://discord.com/developers/applications)
|
|
383
|
+
2. Create a new application, then go to **Bot** and copy the bot token
|
|
384
|
+
3. Under **Privileged Gateway Intents**, enable **Message Content Intent**
|
|
385
|
+
4. Go to **OAuth2 > URL Generator**, select \`bot\` scope, then invite to your server
|
|
386
|
+
|
|
387
|
+
### 2. Get channel IDs
|
|
388
|
+
|
|
389
|
+
Enable Developer Mode in Discord (Settings > Advanced), then right-click a channel and copy its ID.
|
|
390
|
+
|
|
391
|
+
### 3. Local development
|
|
392
|
+
|
|
393
|
+
\`\`\`sh
|
|
394
|
+
cp .env.example .env
|
|
395
|
+
# Fill in DISCORD_BOT_TOKEN, ANTHROPIC_API_KEY, DISCORD_CHANNEL_IDS
|
|
396
|
+
|
|
397
|
+
npm install
|
|
398
|
+
node main.js
|
|
399
|
+
\`\`\`
|
|
400
|
+
|
|
401
|
+
### 4. Deploy
|
|
402
|
+
|
|
403
|
+
\`\`\`sh
|
|
404
|
+
orch publish
|
|
405
|
+
|
|
406
|
+
# Add secrets in your workspace (web dashboard > Settings > Secrets):
|
|
407
|
+
# DISCORD_BOT_TOKEN — your bot token
|
|
408
|
+
# DISCORD_CHANNEL_IDS — comma-separated channel IDs
|
|
409
|
+
|
|
410
|
+
orch service deploy
|
|
411
|
+
\`\`\`
|
|
412
|
+
|
|
413
|
+
## Customization
|
|
414
|
+
|
|
415
|
+
Edit \`main.js\` to customize:
|
|
416
|
+
|
|
417
|
+
- **SYSTEM_PROMPT** — controls how the bot responds
|
|
418
|
+
- **MODEL** / **MAX_TOKENS** — override via env vars
|
|
419
|
+
|
|
420
|
+
## Environment Variables
|
|
421
|
+
|
|
364
422
|
| Variable | Required | Description |
|
|
365
423
|
|----------|----------|-------------|
|
|
366
424
|
| \`DISCORD_BOT_TOKEN\` | Yes | Discord bot token (workspace secret) |
|
|
@@ -514,6 +572,70 @@ if __name__ == "__main__":
|
|
|
514
572
|
`;
|
|
515
573
|
const ORCHESTRATOR_REQUIREMENTS = `orchagent-sdk>=0.1.0
|
|
516
574
|
`;
|
|
575
|
+
const ORCHESTRATOR_MAIN_JS = `/**
|
|
576
|
+
* orchagent orchestrator entrypoint.
|
|
577
|
+
*
|
|
578
|
+
* Reads JSON input from stdin, calls dependency agents via the orchagent SDK,
|
|
579
|
+
* and writes JSON output to stdout.
|
|
580
|
+
*
|
|
581
|
+
* Usage:
|
|
582
|
+
* echo '{"task": "do something"}' | node main.js
|
|
583
|
+
*/
|
|
584
|
+
|
|
585
|
+
const fs = require('fs');
|
|
586
|
+
const { AgentClient } = require('orchagent-sdk');
|
|
587
|
+
|
|
588
|
+
async function main() {
|
|
589
|
+
// Read JSON input from stdin
|
|
590
|
+
const raw = fs.readFileSync('/dev/stdin', 'utf-8');
|
|
591
|
+
let data;
|
|
592
|
+
try {
|
|
593
|
+
data = raw.trim() ? JSON.parse(raw) : {};
|
|
594
|
+
} catch {
|
|
595
|
+
console.log(JSON.stringify({ error: 'Invalid JSON input' }));
|
|
596
|
+
process.exit(1);
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
const task = data.task || '';
|
|
600
|
+
|
|
601
|
+
// --- Your orchestration logic here ---
|
|
602
|
+
// The AgentClient reads ORCHAGENT_SERVICE_KEY from the environment automatically.
|
|
603
|
+
// Do NOT add ORCHAGENT_SERVICE_KEY to required_secrets — the gateway injects it.
|
|
604
|
+
const client = new AgentClient();
|
|
605
|
+
|
|
606
|
+
// Call a dependency agent (must be listed in manifest.dependencies)
|
|
607
|
+
const result = await client.call('org/agent-name@v1', { input: task });
|
|
608
|
+
|
|
609
|
+
// You can chain multiple calls, run them in parallel, or add conditional logic:
|
|
610
|
+
//
|
|
611
|
+
// Sequential:
|
|
612
|
+
// const result2 = await client.call('org/another-agent@v1', { input: result });
|
|
613
|
+
//
|
|
614
|
+
// Parallel:
|
|
615
|
+
// const [r1, r2] = await Promise.all([
|
|
616
|
+
// client.call('org/agent-a@v1', { input: task }),
|
|
617
|
+
// client.call('org/agent-b@v1', { input: task }),
|
|
618
|
+
// ]);
|
|
619
|
+
// --- End orchestration logic ---
|
|
620
|
+
|
|
621
|
+
// Write JSON output to stdout
|
|
622
|
+
console.log(JSON.stringify({ result, success: true }));
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
main().catch(err => {
|
|
626
|
+
console.error(err);
|
|
627
|
+
process.exit(1);
|
|
628
|
+
});
|
|
629
|
+
`;
|
|
630
|
+
const ORCHESTRATOR_PACKAGE_JSON = `{
|
|
631
|
+
"name": "orchestrator",
|
|
632
|
+
"private": true,
|
|
633
|
+
"type": "commonjs",
|
|
634
|
+
"dependencies": {
|
|
635
|
+
"orchagent-sdk": "^0.1.0"
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
`;
|
|
517
639
|
const DISCORD_MAIN_PY = `"""
|
|
518
640
|
Discord bot agent — powered by Claude.
|
|
519
641
|
|
|
@@ -729,9 +851,7 @@ function registerInitCommand(program) {
|
|
|
729
851
|
if (isJavaScript && initMode.flavor === 'managed_loop') {
|
|
730
852
|
throw new errors_1.CliError('JavaScript agent-type agents are not yet supported. Use --type tool for JavaScript agents.');
|
|
731
853
|
}
|
|
732
|
-
|
|
733
|
-
throw new errors_1.CliError('JavaScript orchestrators are not yet supported. Use Python for orchestrator agents.');
|
|
734
|
-
}
|
|
854
|
+
// JS orchestrators are now supported via the orchagent-sdk npm package
|
|
735
855
|
if (options.template) {
|
|
736
856
|
const template = options.template.trim().toLowerCase();
|
|
737
857
|
const validTemplates = ['support-agent', 'discord', 'discord-js', 'github-weekly-summary'];
|
|
@@ -869,6 +989,7 @@ function registerInitCommand(program) {
|
|
|
869
989
|
process.stdout.write(` ${s + 2}. Copy .env.example to .env and add platform tokens\n`);
|
|
870
990
|
process.stdout.write(` ${s + 3}. Test locally: pip install -r requirements.txt && python main.py\n`);
|
|
871
991
|
process.stdout.write(` ${s + 4}. Deploy: orch publish && orch service deploy\n`);
|
|
992
|
+
process.stdout.write(`\n Skill: orch skill install orchagent/agent-builder — gives your AI the full platform builder reference\n`);
|
|
872
993
|
return;
|
|
873
994
|
}
|
|
874
995
|
// Handle github-weekly-summary template separately (own file set + output)
|
|
@@ -924,6 +1045,7 @@ function registerInitCommand(program) {
|
|
|
924
1045
|
process.stdout.write(` ${s + 3}. orch run <org>/${agentName} Test it\n`);
|
|
925
1046
|
process.stdout.write(` ${s + 4}. orch schedule create <org>/${agentName} --cron "0 9 * * 1" Schedule weekly\n`);
|
|
926
1047
|
process.stdout.write(`\n See README.md for full setup guide.\n`);
|
|
1048
|
+
process.stdout.write(`\n Skill: orch skill install orchagent/agent-builder — gives your AI the full platform builder reference\n`);
|
|
927
1049
|
return;
|
|
928
1050
|
}
|
|
929
1051
|
// Handle discord-js template separately (JS Discord bot)
|
|
@@ -954,7 +1076,7 @@ function registerInitCommand(program) {
|
|
|
954
1076
|
await promises_1.default.writeFile(path_1.default.join(targetDir, 'main.js'), DISCORD_MAIN_JS);
|
|
955
1077
|
await promises_1.default.writeFile(path_1.default.join(targetDir, 'package.json'), DISCORD_PACKAGE_JSON);
|
|
956
1078
|
await promises_1.default.writeFile(path_1.default.join(targetDir, '.env.example'), DISCORD_JS_ENV_EXAMPLE);
|
|
957
|
-
await promises_1.default.writeFile(path_1.default.join(targetDir, 'README.md'), readmeTemplate(agentName, '
|
|
1079
|
+
await promises_1.default.writeFile(path_1.default.join(targetDir, 'README.md'), readmeTemplate(agentName, 'discord_js'));
|
|
958
1080
|
const prefix = name ? name + '/' : '';
|
|
959
1081
|
process.stdout.write(`\nInitialized JS Discord bot "${agentName}" in ${targetDir}\n`);
|
|
960
1082
|
process.stdout.write(`\nFiles created:\n`);
|
|
@@ -973,6 +1095,7 @@ function registerInitCommand(program) {
|
|
|
973
1095
|
process.stdout.write(` ${stepNum + 2}. Copy .env.example to .env and fill in your tokens\n`);
|
|
974
1096
|
process.stdout.write(` ${stepNum + 3}. Test locally: npm install && node main.js\n`);
|
|
975
1097
|
process.stdout.write(` ${stepNum + 4}. Deploy: orch publish\n`);
|
|
1098
|
+
process.stdout.write(`\n Skill: orch skill install orchagent/agent-builder — gives your AI the full platform builder reference\n`);
|
|
976
1099
|
return;
|
|
977
1100
|
}
|
|
978
1101
|
const manifestPath = path_1.default.join(targetDir, 'orchagent.json');
|
|
@@ -998,7 +1121,13 @@ function registerInitCommand(program) {
|
|
|
998
1121
|
manifest.run_mode = runMode;
|
|
999
1122
|
if (initMode.flavor === 'orchestrator') {
|
|
1000
1123
|
manifest.description = 'An orchestrator agent that coordinates other agents';
|
|
1001
|
-
|
|
1124
|
+
if (isJavaScript) {
|
|
1125
|
+
manifest.runtime = { command: 'node main.js' };
|
|
1126
|
+
manifest.entrypoint = 'main.js';
|
|
1127
|
+
}
|
|
1128
|
+
else {
|
|
1129
|
+
manifest.runtime = { command: 'python main.py' };
|
|
1130
|
+
}
|
|
1002
1131
|
manifest.manifest = {
|
|
1003
1132
|
manifest_version: 1,
|
|
1004
1133
|
dependencies: [{ id: 'org/agent-name', version: 'v1' }],
|
|
@@ -1034,10 +1163,14 @@ function registerInitCommand(program) {
|
|
|
1034
1163
|
}
|
|
1035
1164
|
await promises_1.default.writeFile(manifestPath, JSON.stringify(manifest, null, 2) + '\n');
|
|
1036
1165
|
if (initMode.flavor === 'orchestrator') {
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1166
|
+
if (isJavaScript) {
|
|
1167
|
+
await promises_1.default.writeFile(path_1.default.join(targetDir, 'main.js'), ORCHESTRATOR_MAIN_JS);
|
|
1168
|
+
await promises_1.default.writeFile(path_1.default.join(targetDir, 'package.json'), ORCHESTRATOR_PACKAGE_JSON);
|
|
1169
|
+
}
|
|
1170
|
+
else {
|
|
1171
|
+
await promises_1.default.writeFile(path_1.default.join(targetDir, 'main.py'), ORCHESTRATOR_MAIN_PY);
|
|
1172
|
+
await promises_1.default.writeFile(path_1.default.join(targetDir, 'requirements.txt'), ORCHESTRATOR_REQUIREMENTS);
|
|
1173
|
+
}
|
|
1041
1174
|
await promises_1.default.writeFile(schemaPath, AGENT_SCHEMA_TEMPLATE);
|
|
1042
1175
|
}
|
|
1043
1176
|
else if (initMode.flavor === 'discord') {
|
|
@@ -1079,8 +1212,14 @@ function registerInitCommand(program) {
|
|
|
1079
1212
|
const prefix = name ? name + '/' : '';
|
|
1080
1213
|
process.stdout.write(` ${prefix}orchagent.json - Agent configuration\n`);
|
|
1081
1214
|
if (initMode.flavor === 'orchestrator') {
|
|
1082
|
-
|
|
1083
|
-
|
|
1215
|
+
if (isJavaScript) {
|
|
1216
|
+
process.stdout.write(` ${prefix}main.js - Orchestrator entrypoint (SDK calls)\n`);
|
|
1217
|
+
process.stdout.write(` ${prefix}package.json - npm dependencies (orchagent-sdk)\n`);
|
|
1218
|
+
}
|
|
1219
|
+
else {
|
|
1220
|
+
process.stdout.write(` ${prefix}main.py - Orchestrator entrypoint (SDK calls)\n`);
|
|
1221
|
+
process.stdout.write(` ${prefix}requirements.txt - Python dependencies (orchagent-sdk)\n`);
|
|
1222
|
+
}
|
|
1084
1223
|
}
|
|
1085
1224
|
else if (initMode.flavor === 'discord') {
|
|
1086
1225
|
process.stdout.write(` ${prefix}main.py - Discord bot (discord.py + Anthropic)\n`);
|
|
@@ -1112,7 +1251,12 @@ function registerInitCommand(program) {
|
|
|
1112
1251
|
process.stdout.write(` 1. cd ${name}\n`);
|
|
1113
1252
|
}
|
|
1114
1253
|
process.stdout.write(` ${stepNum}. Update manifest.dependencies in orchagent.json with your actual agents\n`);
|
|
1115
|
-
|
|
1254
|
+
if (isJavaScript) {
|
|
1255
|
+
process.stdout.write(` ${stepNum + 1}. Edit main.js with your orchestration logic\n`);
|
|
1256
|
+
}
|
|
1257
|
+
else {
|
|
1258
|
+
process.stdout.write(` ${stepNum + 1}. Edit main.py with your orchestration logic\n`);
|
|
1259
|
+
}
|
|
1116
1260
|
process.stdout.write(` ${stepNum + 2}. Publish dependency agents first, then: orchagent publish\n`);
|
|
1117
1261
|
}
|
|
1118
1262
|
else if (initMode.flavor === 'discord') {
|
|
@@ -1153,5 +1297,6 @@ function registerInitCommand(program) {
|
|
|
1153
1297
|
process.stdout.write(` ${stepNum + 1}. Edit schema.json with your input/output schemas\n`);
|
|
1154
1298
|
process.stdout.write(` ${stepNum + 2}. Run: orchagent publish\n`);
|
|
1155
1299
|
}
|
|
1300
|
+
process.stdout.write(`\n Skill: orch skill install orchagent/agent-builder — gives your AI the full platform builder reference\n`);
|
|
1156
1301
|
});
|
|
1157
1302
|
}
|
package/dist/commands/publish.js
CHANGED
|
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.extractTemplateVariables = extractTemplateVariables;
|
|
7
7
|
exports.deriveInputSchema = deriveInputSchema;
|
|
8
8
|
exports.scanUndeclaredEnvVars = scanUndeclaredEnvVars;
|
|
9
|
+
exports.detectSdkCompatible = detectSdkCompatible;
|
|
9
10
|
exports.checkDependencies = checkDependencies;
|
|
10
11
|
exports.registerPublishCommand = registerPublishCommand;
|
|
11
12
|
const promises_1 = __importDefault(require("fs/promises"));
|
|
@@ -914,26 +915,30 @@ function registerPublishCommand(program) {
|
|
|
914
915
|
catch {
|
|
915
916
|
// Optional
|
|
916
917
|
}
|
|
917
|
-
// Include package.json + lockfile for JS agents (overrides DEFAULT_EXCLUDES)
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
process.stdout.write(` Including package.json for sandbox dependencies\n`);
|
|
923
|
-
// Include lockfile for deterministic installs (npm ci)
|
|
924
|
-
const lockPath = path_1.default.join(cwd, 'package-lock.json');
|
|
918
|
+
// Include package.json + lockfile for JS agents only (overrides DEFAULT_EXCLUDES)
|
|
919
|
+
// Guard on JS entrypoint to avoid bundling package.json for Python agents
|
|
920
|
+
// in mixed repos — the sandbox Python template lacks npm and would fail
|
|
921
|
+
if (bundleEntrypoint && bundleEntrypoint.endsWith('.js')) {
|
|
922
|
+
const pkgPath = path_1.default.join(cwd, 'package.json');
|
|
925
923
|
try {
|
|
926
|
-
await promises_1.default.access(
|
|
927
|
-
includePatterns.push('package
|
|
928
|
-
process.stdout.write(` Including package
|
|
924
|
+
await promises_1.default.access(pkgPath);
|
|
925
|
+
includePatterns.push('package.json');
|
|
926
|
+
process.stdout.write(` Including package.json for sandbox dependencies\n`);
|
|
927
|
+
// Include lockfile for deterministic installs (npm ci)
|
|
928
|
+
const lockPath = path_1.default.join(cwd, 'package-lock.json');
|
|
929
|
+
try {
|
|
930
|
+
await promises_1.default.access(lockPath);
|
|
931
|
+
includePatterns.push('package-lock.json');
|
|
932
|
+
process.stdout.write(` Including package-lock.json for deterministic installs\n`);
|
|
933
|
+
}
|
|
934
|
+
catch {
|
|
935
|
+
// No lockfile — npm install will be used instead of npm ci
|
|
936
|
+
}
|
|
929
937
|
}
|
|
930
938
|
catch {
|
|
931
|
-
// No
|
|
939
|
+
// No package.json
|
|
932
940
|
}
|
|
933
941
|
}
|
|
934
|
-
catch {
|
|
935
|
-
// No package.json — not a JS agent
|
|
936
|
-
}
|
|
937
942
|
}
|
|
938
943
|
const bundleResult = await (0, bundle_1.createCodeBundle)(cwd, bundlePath, {
|
|
939
944
|
entrypoint: bundleEntrypoint,
|
|
@@ -1040,5 +1045,6 @@ function registerPublishCommand(program) {
|
|
|
1040
1045
|
process.stdout.write(`\nNote: Hosted code execution is in beta. Contact support for full deployment.\n`);
|
|
1041
1046
|
}
|
|
1042
1047
|
process.stdout.write(`\nView analytics and usage: https://orchagent.io/dashboard\n`);
|
|
1048
|
+
process.stdout.write(`\nSkill: orch skill install orchagent/agent-builder — gives your AI the full platform builder reference\n`);
|
|
1043
1049
|
});
|
|
1044
1050
|
}
|
package/dist/commands/run.js
CHANGED
|
@@ -36,6 +36,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
36
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.localCommandForEntrypoint = localCommandForEntrypoint;
|
|
39
40
|
exports.isKeyedFileArg = isKeyedFileArg;
|
|
40
41
|
exports.readKeyedFiles = readKeyedFiles;
|
|
41
42
|
exports.mountDirectory = mountDirectory;
|
|
@@ -926,11 +927,12 @@ async function loadSkillPrompts(config, skillRefs, defaultOrg) {
|
|
|
926
927
|
}
|
|
927
928
|
return prompts;
|
|
928
929
|
}
|
|
929
|
-
function runCommand(command, args) {
|
|
930
|
+
function runCommand(command, args, options) {
|
|
930
931
|
return new Promise((resolve) => {
|
|
931
932
|
const proc = (0, child_process_1.spawn)(command, args, {
|
|
932
933
|
stdio: ['inherit', 'pipe', 'pipe'],
|
|
933
934
|
shell: true,
|
|
935
|
+
cwd: options?.cwd,
|
|
934
936
|
});
|
|
935
937
|
let stdout = '';
|
|
936
938
|
let stderr = '';
|
|
@@ -1068,7 +1070,7 @@ async function executeBundleAgent(config, org, agentName, version, agentData, ar
|
|
|
1068
1070
|
const npmArgs = useNpmCi
|
|
1069
1071
|
? ['ci', '--no-audit', '--no-fund']
|
|
1070
1072
|
: ['install', '--production', '--no-audit', '--no-fund'];
|
|
1071
|
-
const { code } = await runCommand('npm', npmArgs);
|
|
1073
|
+
const { code } = await runCommand('npm', npmArgs, { cwd: extractDir });
|
|
1072
1074
|
if (code !== 0) {
|
|
1073
1075
|
throw new errors_1.CliError('Failed to install npm dependencies');
|
|
1074
1076
|
}
|
|
@@ -1529,7 +1531,7 @@ async function executeLocalFromDir(dirPath, args, options) {
|
|
|
1529
1531
|
? ['ci', '--no-audit', '--no-fund']
|
|
1530
1532
|
: ['install', '--production', '--no-audit', '--no-fund'];
|
|
1531
1533
|
process.stderr.write('Installing npm dependencies...\n');
|
|
1532
|
-
const { code } = await runCommand('npm', npmArgs);
|
|
1534
|
+
const { code } = await runCommand('npm', npmArgs, { cwd: resolved });
|
|
1533
1535
|
if (code !== 0) {
|
|
1534
1536
|
process.stderr.write('Warning: Failed to install npm dependencies\n');
|
|
1535
1537
|
}
|
package/package.json
CHANGED