@gaia-ai/gaia 0.1.4 → 0.1.6

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.
Files changed (2) hide show
  1. package/dist/index.js +43 -8
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1156,22 +1156,57 @@ Next steps:
1156
1156
  );
1157
1157
  return program;
1158
1158
  }
1159
+ function dropshConfigHint(resolvedPath) {
1160
+ return `gaia dropsh: no conductor config could be loaded (looked at ${resolvedPath}).
1161
+ Point at one with --config <path>, set $DROPSH_CONFIG, or run from a directory containing .gaia/conductor.config.js.`;
1162
+ }
1159
1163
  async function attachDropsh(program, deps) {
1160
1164
  const config = deps.config ?? await tryConfig(deps);
1161
- if (!config) {
1162
- return;
1163
- }
1164
- if (!process.env.DROPSH_CONFIG) {
1165
+ if (config && !process.env.DROPSH_CONFIG) {
1165
1166
  process.env.DROPSH_CONFIG = config.config_path;
1166
1167
  }
1167
- program.addCommand(
1168
- buildDropshProgram({ plugins: config.plugins ?? [] })
1169
- );
1168
+ const dropsh = buildDropshProgram({
1169
+ plugins: config?.plugins ?? []
1170
+ });
1171
+ if (!config) {
1172
+ dropsh.hook("preSubcommand", async (thisCommand) => {
1173
+ const override = thisCommand.opts().config ?? process.env.DROPSH_CONFIG;
1174
+ const resolved = defaultConfigPath(override);
1175
+ let ok = false;
1176
+ try {
1177
+ await loadConductorConfig(resolved);
1178
+ ok = true;
1179
+ } catch {
1180
+ ok = false;
1181
+ }
1182
+ if (!ok) {
1183
+ throw new Error(dropshConfigHint(resolved));
1184
+ }
1185
+ if (!process.env.DROPSH_CONFIG) {
1186
+ process.env.DROPSH_CONFIG = resolved;
1187
+ }
1188
+ });
1189
+ }
1190
+ program.addCommand(dropsh);
1170
1191
  }
1171
1192
  async function runGaiaCli(argv, deps = {}) {
1172
1193
  const program = buildProgram(deps);
1173
1194
  await attachDropsh(program, deps);
1174
- await program.parseAsync(argv, { from: "user" });
1195
+ try {
1196
+ await program.parseAsync(argv, { from: "user" });
1197
+ } catch (err) {
1198
+ const e = err;
1199
+ if (e.code === "commander.helpDisplayed" || e.code === "commander.version") {
1200
+ return;
1201
+ }
1202
+ if (typeof e.code === "string" && e.code.startsWith("commander.")) {
1203
+ process.exitCode = process.exitCode ?? 1;
1204
+ return;
1205
+ }
1206
+ process.stderr.write(`${e.message ?? String(err)}
1207
+ `);
1208
+ process.exitCode = process.exitCode ?? 1;
1209
+ }
1175
1210
  }
1176
1211
  async function main(argv) {
1177
1212
  await runGaiaCli(argv.slice(2));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gaia-ai/gaia",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "GAIA Network conductor node: registers, claims tickets via JSON:API, runs agents through spawn plugins.",
5
5
  "type": "module",
6
6
  "license": "MIT",