@aiaiai-pt/martha-cli 0.31.0 → 0.32.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.
Files changed (2) hide show
  1. package/dist/index.js +54 -25
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -11076,7 +11076,7 @@ init_config();
11076
11076
  init_errors();
11077
11077
 
11078
11078
  // src/version.ts
11079
- var CLI_VERSION = "0.31.0";
11079
+ var CLI_VERSION = "0.32.0";
11080
11080
 
11081
11081
  // src/commands/sessions.ts
11082
11082
  function relativeTime(iso) {
@@ -16751,6 +16751,52 @@ function registerAskCommands(program2) {
16751
16751
  import { readFileSync as readFileSync2 } from "node:fs";
16752
16752
  init_errors();
16753
16753
  var truncate2 = (s, n) => s.length > n ? s.slice(0, n - 1) + "…" : s;
16754
+ var UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
16755
+ async function resolveAgentId(ctx, ref) {
16756
+ if (UUID_RE.test(ref))
16757
+ return ref;
16758
+ try {
16759
+ const agent = await ctx.api.get(`/api/admin/definitions/agents/${encodeURIComponent(ref)}`);
16760
+ return agent.id;
16761
+ } catch {
16762
+ throw new CLIError(`Agent '${ref}' not found (pass a valid agent name or UUID)`, 4 /* Validation */);
16763
+ }
16764
+ }
16765
+ async function resolveTeamId(ctx, ref) {
16766
+ if (UUID_RE.test(ref))
16767
+ return ref;
16768
+ const teams = await ctx.api.get("/api/admin/teams");
16769
+ const match = (Array.isArray(teams) ? teams : []).find((t) => t.name === ref);
16770
+ if (!match) {
16771
+ throw new CLIError(`Team '${ref}' not found (pass a valid team name or UUID)`, 4 /* Validation */);
16772
+ }
16773
+ return match.id;
16774
+ }
16775
+ async function buildCreateTaskBody(ctx, opts) {
16776
+ if (opts.agent && opts.team) {
16777
+ throw new CLIError("--agent and --team are mutually exclusive — a task has one assignee", 4 /* Validation */);
16778
+ }
16779
+ const body = {
16780
+ goal: opts.goal,
16781
+ priority: opts.priority
16782
+ };
16783
+ if (opts.agent)
16784
+ body.agent_id = await resolveAgentId(ctx, opts.agent);
16785
+ if (opts.team)
16786
+ body.team_id = await resolveTeamId(ctx, opts.team);
16787
+ if (opts.title)
16788
+ body.title = opts.title;
16789
+ if (opts.context) {
16790
+ try {
16791
+ body.context_data = JSON.parse(opts.context);
16792
+ } catch {
16793
+ throw new CLIError("--context must be valid JSON", 4 /* Validation */);
16794
+ }
16795
+ }
16796
+ if (opts.sticky)
16797
+ body.sticky_assignment = true;
16798
+ return body;
16799
+ }
16754
16800
  var sleep4 = (ms, signal) => new Promise((resolve2) => {
16755
16801
  if (signal?.aborted) {
16756
16802
  resolve2();
@@ -16889,30 +16935,13 @@ ${items.length} task(s)`));
16889
16935
  }
16890
16936
  console.log(`Open: ${source_default.yellow(data.open ?? 0)} ` + `Running: ${source_default.blue(data.running ?? 0)} ` + `Claimed: ${source_default.magenta(data.claimed ?? 0)} ` + `Completed: ${source_default.green(data.completed ?? 0)} ` + `Failed: ${source_default.red(data.failed ?? 0)} ` + `Cancelled: ${source_default.dim(data.cancelled ?? 0)}`);
16891
16937
  });
16892
- cmd.command("create").description("Create a new task").requiredOption("--agent <name-or-id>", "Agent definition ID").requiredOption("--goal <text>", "Goal / instruction for the agent").option("--title <text>", "Short title for the task").option("--priority <priority>", "Priority (low, medium, high, urgent)", "medium").option("--context <json>", "Structured context as JSON string").option("--team <team-id>", "Assign task to a team").option("--assigned-agent <agent-id>", "Assign task to a specific agent").option("--sticky", "Keep assignment even if agent goes offline").option("--no-auto-execute", "Create the task as claimable (open) for an external runner to pull, instead of auto-running it via the cloud workflow").action(async (opts) => {
16938
+ cmd.command("create").description("Create a task. Assign it to an agent or a team to dispatch it, or omit " + "both to leave it in the backlog (#774: assignment is the dispatch moment).").requiredOption("--goal <text>", "Goal / instruction for the agent").option("--agent <name-or-id>", "Assign to an agent (dispatches; venue derives from its type)").option("--team <name-or-id>", "Assign to a team").option("--title <text>", "Short title for the task").option("--priority <priority>", "Priority (low, medium, high, urgent)", "medium").option("--context <json>", "Structured context as JSON string").option("--sticky", "Keep assignment even if agent goes offline").option("--no-auto-execute", "Deprecated (#774): venue now derives from the assignee. Accepted and ignored.").action(async (opts) => {
16893
16939
  const ctx = getCtx();
16894
- const body = {
16895
- agent_definition_id: opts.agent,
16896
- goal: opts.goal,
16897
- priority: opts.priority
16898
- };
16899
- if (opts.title)
16900
- body.title = opts.title;
16901
- if (opts.context) {
16902
- try {
16903
- body.context_data = JSON.parse(opts.context);
16904
- } catch {
16905
- throw new CLIError("--context must be valid JSON", 4 /* Validation */);
16906
- }
16940
+ if (opts.autoExecute === false) {
16941
+ process.stderr.write("Warning: --no-auto-execute is deprecated (#774) — the venue derives " + `from the assignee. Ignoring.
16942
+ `);
16907
16943
  }
16908
- if (opts.team)
16909
- body.assigned_team_id = opts.team;
16910
- if (opts.assignedAgent)
16911
- body.assigned_agent_id = opts.assignedAgent;
16912
- if (opts.sticky)
16913
- body.sticky_assignment = true;
16914
- if (opts.autoExecute === false)
16915
- body.auto_execute = false;
16944
+ const body = await buildCreateTaskBody(ctx, opts);
16916
16945
  const result = await ctx.api.post("/api/admin/tasks", body);
16917
16946
  if (isJson()) {
16918
16947
  console.log(JSON.stringify(result, null, 2));
@@ -20424,9 +20453,9 @@ init_errors();
20424
20453
 
20425
20454
  // src/lib/collections.ts
20426
20455
  init_errors();
20427
- var UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
20456
+ var UUID_RE2 = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
20428
20457
  async function resolveCollectionIdForGrant(ctx, ref) {
20429
- if (UUID_RE.test(ref)) {
20458
+ if (UUID_RE2.test(ref)) {
20430
20459
  return ref;
20431
20460
  }
20432
20461
  const all = await ctx.api.get("/api/admin/collections", {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aiaiai-pt/martha-cli",
3
- "version": "0.31.0",
3
+ "version": "0.32.0",
4
4
  "description": "Terminal-first client for the Martha AI platform",
5
5
  "homepage": "https://docs.martha.nomadriver.co",
6
6
  "repository": {