@maiaos/cli 0.1.0-canary.41 → 0.1.0-canary.42

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.
@@ -15,6 +15,7 @@ export type CreateSessionInput = {
15
15
  readonly effort?: SessionCreateParameters["effort"];
16
16
  readonly executor?: SessionCreateParameters["executor"];
17
17
  readonly hostAuthority?: SessionCreateParameters["hostAuthority"];
18
+ readonly labels?: SessionCreateParameters["labels"];
18
19
  readonly model?: string;
19
20
  readonly permission?: SessionCreateParameters["permission"];
20
21
  readonly role?: SessionCreateParameters["role"];
@@ -14,6 +14,7 @@ const SESSION_CREATE_OPTIONS = new Set([
14
14
  "--cwd",
15
15
  "--effort",
16
16
  "--executor",
17
+ "--label",
17
18
  "--model",
18
19
  "--name",
19
20
  "--permission",
@@ -38,6 +39,9 @@ const summarizeSessionCreation = (result) => ({
38
39
  revision: result.session.revision,
39
40
  sessionId: result.session.id,
40
41
  state: result.session.state,
42
+ ...(result.session.labels === undefined
43
+ ? {}
44
+ : { labels: result.session.labels }),
41
45
  ...(result.session.title === undefined
42
46
  ? {}
43
47
  : { title: result.session.title }),
@@ -124,6 +128,30 @@ const readAgentId = (options) => {
124
128
  throw new CliArgumentError(`Option '--agent' fixes the harness, Connection, model and effort; drop '${clash}'.`);
125
129
  return { agentId };
126
130
  };
131
+ const LABEL_OPTION = new Set(["--label"]);
132
+ const requireOneLabelPerOption = (tokens) => {
133
+ const given = tokens.flatMap((token, index) => {
134
+ if (tokens[index - 1] === "--label")
135
+ return [token];
136
+ return token.startsWith("--label=") ? [token.slice("--label=".length)] : [];
137
+ });
138
+ if (given.some((value) => value.includes(",")))
139
+ throw new CliArgumentError("Option '--label' takes one key=value; repeat the option for more.");
140
+ };
141
+ const readLabels = (value) => {
142
+ if (value === undefined)
143
+ return {};
144
+ const pairs = value.split(",").map((pair) => {
145
+ const separator = pair.indexOf("=");
146
+ if (separator < 1)
147
+ throw new CliArgumentError("Option '--label' takes key=value.");
148
+ return [pair.slice(0, separator), pair.slice(separator + 1)];
149
+ });
150
+ const duplicate = pairs.find(([key], index) => pairs.findIndex(([other]) => other === key) !== index);
151
+ if (duplicate !== undefined)
152
+ throw new CliArgumentError(`Label '${duplicate[0]}' is given twice.`);
153
+ return { labels: Object.fromEntries(pairs) };
154
+ };
127
155
  const readSessionTitle = (options) => {
128
156
  if (options.has("--name") && options.has("--title"))
129
157
  throw new CliArgumentError("Use one of '--name' or '--title'.");
@@ -146,6 +174,7 @@ const readSessionSelection = ({ flags, options }, workspaceId) => {
146
174
  ...(effort === undefined ? {} : { effort }),
147
175
  ...(executor === undefined ? {} : { executor }),
148
176
  ...(model === undefined ? {} : { model }),
177
+ ...readLabels(options.get("--label")),
149
178
  ...readSessionRole(options.get("--role")),
150
179
  ...(title === undefined ? {} : { title }),
151
180
  ...readHostAuthority({ flags, options }),
@@ -239,6 +268,8 @@ const taskSource = (parsed) => {
239
268
  if (file !== undefined &&
240
269
  (parsed.options.has("--title") || parsed.options.has("--name")))
241
270
  throw new CliArgumentError("Option '--title' or '--name' names one Session; with '--from-file' each Session takes its task's first line.");
271
+ if (file !== undefined && parsed.options.has("--label"))
272
+ throw new CliArgumentError("Option '--label' labels one Session; it cannot be used with '--from-file'.");
242
273
  if (file !== undefined)
243
274
  return { kind: "file", path: file };
244
275
  if (message !== undefined)
@@ -271,7 +302,12 @@ const readSessionTasks = (parsed, source) => {
271
302
  };
272
303
  };
273
304
  export const runSessionCreate = (tokens, context) => {
274
- const parsed = parseOptions(tokens, TASK_OPTIONS, new Set(["--host-authority", "--prompt-stdin"]));
305
+ requireOneLabelPerOption(tokens);
306
+ const parsed = parseOptionsWith(tokens, {
307
+ allowed: TASK_OPTIONS,
308
+ allowedFlags: new Set(["--host-authority", "--prompt-stdin"]),
309
+ repeatable: LABEL_OPTION,
310
+ });
275
311
  const source = taskSource(parsed);
276
312
  if (source !== undefined)
277
313
  return runSessionTasks(readSessionTasks(parsed, source), context);
@@ -21,17 +21,21 @@ const readText = (source, context) => {
21
21
  const refusalMessage = (refusal) => refusal.reason === "too_long"
22
22
  ? `Task line ${String(refusal.line)} exceeds ${String(MAX_TURN_INPUT_BYTES)} bytes.`
23
23
  : `A batch holds at most ${String(MAX_SESSION_CREATION_TASKS)} tasks; line ${String(refusal.line)} is beyond it.`;
24
+ const toStartFields = ({ cwd, hostAuthority, permission, }) => ({
25
+ ...(cwd === undefined ? {} : { cwd }),
26
+ ...(hostAuthority === undefined ? {} : { hostAuthority }),
27
+ ...(permission === undefined ? {} : { permission }),
28
+ });
24
29
  const toTemplate = (selection) => {
25
- const { agentId, baseRef, connectionId, cwd, effort, executor, hostAuthority, model, permission, role, title, } = selection;
30
+ const { agentId, baseRef, connectionId, effort, executor, labels, model, role, title, } = selection;
26
31
  return {
27
32
  ...(agentId === undefined ? {} : { agentId }),
28
33
  ...(connectionId === undefined ? {} : { connectionId }),
29
- ...(cwd === undefined ? {} : { cwd }),
34
+ ...toStartFields(selection),
30
35
  ...(effort === undefined ? {} : { effort }),
31
36
  ...(executor === undefined ? {} : { executor }),
32
- ...(hostAuthority === undefined ? {} : { hostAuthority }),
37
+ ...(labels === undefined ? {} : { labels }),
33
38
  ...(model === undefined ? {} : { model }),
34
- ...(permission === undefined ? {} : { permission }),
35
39
  ...(role === undefined ? {} : { role }),
36
40
  ...(title === undefined ? {} : { title }),
37
41
  ...(baseRef === undefined ? {} : { worktree: { baseRef } }),
@@ -2,7 +2,7 @@ import { cell, fields, formatRows, tab, withPrunedHistory, writeNodeResult, } fr
2
2
  import { formatSessionDiff } from "./diff.js";
3
3
  import { formatFailure, formatSessionEvents } from "./failure.js";
4
4
  import { formatSessionObservation } from "./observe.js";
5
- import { formatSessionList, formatSessionTasks, } from "./tasks.js";
5
+ import { formatSessionList, formatSessionTasks, labelCells, } from "./tasks.js";
6
6
  const formatSessionInbox = (deliveries) => formatRows(deliveries, (delivery) => `${delivery.deliveryId}\t${delivery.sequence}\t${cell(delivery.message.senderSessionId)}\t${cell(delivery.message.subject)}\t${cell(delivery.message.body)}`);
7
7
  const formatSessionCreation = (result) => `${fields([
8
8
  ["session", result.sessionId],
@@ -38,6 +38,11 @@ export const formatSessionShow = ({ session, }) => `${fields([
38
38
  ["revision", session.revision],
39
39
  ["workspace", session.workspaceId],
40
40
  ["containment", session.containment],
41
+ [
42
+ "labels",
43
+ session.labels === undefined ? undefined : labelCells(session.labels),
44
+ ],
45
+ ["updated", session.updatedAt],
41
46
  ])}${formatFailure(session.failure)}`;
42
47
  const formatLifecycle = ({ revision, sessionId, state, }) => `${fields([
43
48
  ["session", sessionId],
@@ -17,6 +17,7 @@ export type CliSessionTasksResult = {
17
17
  };
18
18
  export declare const formatSessionTasks: ({ items }: CliSessionTasksResult) => string;
19
19
  type ListedSession = SessionListResult["items"][number];
20
+ export declare const labelCells: (labels: Readonly<Record<string, string>> | undefined) => string;
20
21
  export declare const formatSessionList: (result: SessionListResult) => string;
21
22
  type Labeled<TValue> = TValue & {
22
23
  readonly node: string;
@@ -32,7 +32,14 @@ const SESSION_HEADERS = [
32
32
  "ATTENTION",
33
33
  "CONTAINMENT",
34
34
  "TITLE",
35
+ "LABELS",
36
+ "LAST ACTIVE",
35
37
  ];
38
+ export const labelCells = (labels) => labels === undefined
39
+ ? "-"
40
+ : Object.entries(labels)
41
+ .map(([key, value]) => `${key}=${value}`)
42
+ .join(",");
36
43
  const sessionCells = (session, attention) => [
37
44
  session.id,
38
45
  session.state,
@@ -40,6 +47,8 @@ const sessionCells = (session, attention) => [
40
47
  attention ?? "-",
41
48
  session.containment ?? "-",
42
49
  cell(session.title ?? "-"),
50
+ labelCells(session.labels),
51
+ session.updatedAt,
43
52
  ];
44
53
  export const formatSessionList = (result) => {
45
54
  const attention = new Map((result.attention ?? []).map((item) => [item.sessionId, item.attention]));
@@ -18,7 +18,7 @@ export const SESSION_TREE = {
18
18
  ],
19
19
  leaves: [
20
20
  [
21
- "session create (--workspace <workspace-id> | --project <project-id>) [--command-id <id>] [--role <worker|orchestrator>] [--connection <connection-id> [--executor <codex-cli|claude-code>] [--model <id>] | --executor <codex-cli|claude-code> | --agent <agent-id> | --agent-definition <key> --agent-definition-version <version> --agent-definition-digest <sha256>] [--effort <low|medium|high|xhigh|max|ultra>] [--base <branch-tag-or-commit> | --host-authority [--permission <mode>]] [--cwd <path>] [--title <text> | --name <text>] [--message <text> | --prompt-stdin | --from-file <path>]",
21
+ "session create (--workspace <workspace-id> | --project <project-id>) [--command-id <id>] [--role <worker|orchestrator>] [--connection <connection-id> [--executor <codex-cli|claude-code>] [--model <id>] | --executor <codex-cli|claude-code> | --agent <agent-id> | --agent-definition <key> --agent-definition-version <version> --agent-definition-digest <sha256>] [--effort <low|medium|high|xhigh|max|ultra>] [--base <branch-tag-or-commit> | --host-authority [--permission <mode>]] [--cwd <path>] [--title <text> | --name <text>] [--label <key=value>...] [--message <text> | --prompt-stdin | --from-file <path>]",
22
22
  0,
23
23
  "session.create",
24
24
  "Create a Session, optionally starting it with a first message.",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@maiaos/cli",
3
- "version": "0.1.0-canary.41",
3
+ "version": "0.1.0-canary.42",
4
4
  "description": "The maia CLI and MCP server: start, drive, observe and stop swarms of Claude Code and Codex agents from a terminal, a script or another agent.",
5
5
  "keywords": [
6
6
  "maia",
@@ -64,9 +64,9 @@
64
64
  "dependencies": {
65
65
  "@earendil-works/pi-tui": "1.0.0",
66
66
  "@effect/platform-node-shared": "4.0.0",
67
- "@maiaos/agent": "0.1.0-canary.41",
68
- "@maiaos/client-core": "0.1.0-canary.41",
69
- "@maiaos/sdk": "0.1.0-canary.41",
67
+ "@maiaos/agent": "0.1.0-canary.42",
68
+ "@maiaos/client-core": "0.1.0-canary.42",
69
+ "@maiaos/sdk": "0.1.0-canary.42",
70
70
  "effect": "4.0.0"
71
71
  },
72
72
  "scripts": {