@maiaos/cli 0.1.0-canary.6 → 0.1.0-canary.61

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 (266) hide show
  1. package/README.md +8 -7
  2. package/dist/agents/client.d.ts +47 -27
  3. package/dist/agents/client.js +10 -3
  4. package/dist/agents/commands.d.ts +1 -0
  5. package/dist/agents/commands.js +24 -2
  6. package/dist/agents/index.d.ts +1 -1
  7. package/dist/agents/index.js +1 -1
  8. package/dist/agents/input.js +6 -0
  9. package/dist/agents/output/format.js +11 -0
  10. package/dist/agents/tree/tree.js +13 -1
  11. package/dist/bin/maia.cdx.json +19 -19
  12. package/dist/bin/maia.mjs +1 -1
  13. package/dist/cli/cli.d.ts +8 -2
  14. package/dist/cli/cli.js +29 -6
  15. package/dist/cli/index.d.ts +1 -1
  16. package/dist/cli/index.js +1 -1
  17. package/dist/command-line/context.d.ts +4 -2
  18. package/dist/command-line/emit/index.d.ts +4 -0
  19. package/dist/command-line/emit/index.js +4 -0
  20. package/dist/command-line/{output.d.ts → emit/output.d.ts} +2 -2
  21. package/dist/command-line/{rows.d.ts → emit/rows.d.ts} +2 -0
  22. package/dist/command-line/{rows.js → emit/rows.js} +8 -0
  23. package/dist/command-line/index.d.ts +5 -5
  24. package/dist/command-line/index.js +5 -5
  25. package/dist/command-line/input/arguments.d.ts +10 -0
  26. package/dist/command-line/input/arguments.js +30 -10
  27. package/dist/command-line/input/index.d.ts +2 -1
  28. package/dist/command-line/input/index.js +2 -1
  29. package/dist/command-line/input/manager-options.d.ts +10 -0
  30. package/dist/command-line/input/manager-options.js +38 -0
  31. package/dist/command-line/two-phase/index.d.ts +2 -0
  32. package/dist/command-line/two-phase/index.js +2 -0
  33. package/dist/command-line/{two-phase.d.ts → two-phase/two-phase.d.ts} +12 -12
  34. package/dist/command-line/{two-phase.js → two-phase/two-phase.js} +2 -2
  35. package/dist/command-receipt/command.js +1 -1
  36. package/dist/command-tree/tree.d.ts +1 -1
  37. package/dist/command-tree/tree.js +6 -1
  38. package/dist/connection/input.js +2 -2
  39. package/dist/connection/system.js +3 -2
  40. package/dist/connection/tree/tree.js +5 -5
  41. package/dist/events/commands.js +65 -0
  42. package/dist/events/index.js +2 -0
  43. package/dist/events/tree/index.js +2 -0
  44. package/dist/events/tree/tree.js +17 -0
  45. package/dist/import/batch.js +196 -0
  46. package/dist/import/client.d.ts +3 -3
  47. package/dist/import/client.js +1 -1
  48. package/dist/import/commands.d.ts +1 -0
  49. package/dist/import/commands.js +82 -8
  50. package/dist/import/index.d.ts +1 -1
  51. package/dist/import/index.js +1 -1
  52. package/dist/import/input.js +38 -3
  53. package/dist/import/manifest.js +107 -0
  54. package/dist/import/output.js +46 -2
  55. package/dist/local-node/client.d.ts +1 -0
  56. package/dist/local-node/client.js +1 -0
  57. package/dist/local-node/index.d.ts +2 -1
  58. package/dist/local-node/index.js +2 -1
  59. package/dist/local-node/wait.d.ts +10 -0
  60. package/dist/local-node/wait.js +17 -0
  61. package/dist/login/gateway.js +2 -2
  62. package/dist/login/vendor-input.js +2 -2
  63. package/dist/mcp/calls.js +6 -1
  64. package/dist/mcp/routing.js +1 -0
  65. package/dist/project-guard/client.d.ts +12 -0
  66. package/dist/project-guard/input.js +15 -1
  67. package/dist/project-guard/output/format.js +5 -0
  68. package/dist/project-workspace/tree/tree.js +1 -1
  69. package/dist/reference/resolve.js +9 -2
  70. package/dist/remote-node/connector.js +8 -1
  71. package/dist/run-ledger/client.d.ts +2 -0
  72. package/dist/session/agent-permission.d.ts +2 -2
  73. package/dist/session/approval/client.d.ts +5 -2
  74. package/dist/session/approval/client.js +2 -2
  75. package/dist/session/approval/commands.d.ts +1 -0
  76. package/dist/session/approval/commands.js +97 -17
  77. package/dist/session/approval/index.d.ts +1 -1
  78. package/dist/session/approval/index.js +1 -1
  79. package/dist/session/client.d.ts +14 -3
  80. package/dist/session/client.js +17 -2
  81. package/dist/session/coding-client.d.ts +2 -0
  82. package/dist/session/coding-client.js +1 -2
  83. package/dist/session/coding-commands.js +24 -7
  84. package/dist/session/commands.d.ts +1 -0
  85. package/dist/session/commands.js +131 -18
  86. package/dist/session/create-tasks.js +10 -2
  87. package/dist/session/index.d.ts +1 -1
  88. package/dist/session/index.js +1 -1
  89. package/dist/session/output/human.js +32 -5
  90. package/dist/session/output/index.js +1 -1
  91. package/dist/session/output/tasks.js +51 -7
  92. package/dist/session/tree/tree.js +52 -19
  93. package/dist/session/turn/client.js +7 -9
  94. package/dist/session/turn/commands.js +67 -20
  95. package/dist/session/turn/output.d.ts +6 -0
  96. package/dist/session/turn/output.js +12 -2
  97. package/dist/status/client.d.ts +14 -3
  98. package/dist/status/command.js +3 -1
  99. package/dist/status/doctor.d.ts +5 -1
  100. package/dist/status/doctor.js +10 -4
  101. package/dist/status/output/compact.d.ts +3 -0
  102. package/dist/status/output/compact.js +17 -7
  103. package/dist/status/output/human.js +15 -0
  104. package/dist/terminal/control-commands.js +26 -9
  105. package/dist/terminal/keys.js +62 -0
  106. package/dist/terminal/output/compact-list.js +3 -0
  107. package/dist/terminal/output/human.js +2 -2
  108. package/dist/terminal/tree/tree.js +1 -1
  109. package/dist/webhooks/client.d.ts +156 -0
  110. package/dist/webhooks/client.js +8 -0
  111. package/dist/webhooks/commands.d.ts +17 -0
  112. package/dist/webhooks/commands.js +76 -0
  113. package/dist/webhooks/index.d.ts +3 -0
  114. package/dist/webhooks/index.js +3 -0
  115. package/dist/webhooks/input.js +125 -0
  116. package/dist/webhooks/output/format.js +75 -0
  117. package/dist/webhooks/output/index.js +2 -0
  118. package/dist/webhooks/tree/index.js +2 -0
  119. package/dist/webhooks/tree/tree.js +49 -0
  120. package/guidance/maia-cli/SKILL.md +1 -1
  121. package/guidance/maia-node/SKILL.md +54 -0
  122. package/guidance/maia-orchestration/SKILL.md +1 -2
  123. package/guidance/maia-sessions/SKILL.md +69 -0
  124. package/package.json +5 -5
  125. package/dist/address-space/address-space.d.ts +0 -38
  126. package/dist/address-space/index.d.ts +0 -2
  127. package/dist/agents/input.d.ts +0 -130
  128. package/dist/agents/output/format.d.ts +0 -8
  129. package/dist/agents/output/index.d.ts +0 -2
  130. package/dist/agents/tree/index.d.ts +0 -2
  131. package/dist/agents/tree/tree.d.ts +0 -3
  132. package/dist/bootstrap/exit.d.ts +0 -14
  133. package/dist/bootstrap/exit.js +0 -42
  134. package/dist/bootstrap/index.d.ts +0 -3
  135. package/dist/bootstrap/index.js +0 -3
  136. package/dist/bootstrap/process.d.ts +0 -5
  137. package/dist/bootstrap/process.js +0 -23
  138. package/dist/bootstrap/run.d.ts +0 -25
  139. package/dist/bootstrap/run.js +0 -95
  140. package/dist/bootstrap/stdio.d.ts +0 -4
  141. package/dist/bootstrap/stdio.js +0 -9
  142. package/dist/cli/environment.d.ts +0 -8
  143. package/dist/cli/services.d.ts +0 -4
  144. package/dist/command-line/input/stdin-stream.d.ts +0 -4
  145. package/dist/command-line/json-decoder.d.ts +0 -3
  146. package/dist/command-receipt/command.d.ts +0 -4
  147. package/dist/command-receipt/compact-list.d.ts +0 -20
  148. package/dist/command-receipt/index.d.ts +0 -3
  149. package/dist/command-tree/completion.d.ts +0 -6
  150. package/dist/command-tree/local.d.ts +0 -3
  151. package/dist/command-tree/row.js +0 -2
  152. package/dist/connection/access/format.d.ts +0 -8
  153. package/dist/connection/access/input.d.ts +0 -53
  154. package/dist/connection/input.d.ts +0 -50
  155. package/dist/connection/signin.d.ts +0 -4
  156. package/dist/connection/tree/index.d.ts +0 -2
  157. package/dist/connection/tree/tree.d.ts +0 -3
  158. package/dist/container/output/format.d.ts +0 -11
  159. package/dist/container/output/index.d.ts +0 -2
  160. package/dist/context/client.d.ts +0 -7
  161. package/dist/context/commands.d.ts +0 -3
  162. package/dist/context/index.d.ts +0 -3
  163. package/dist/dashboard/cockpit-client.d.ts +0 -6
  164. package/dist/dashboard/cockpit-client.js +0 -27
  165. package/dist/dashboard/cockpits.d.ts +0 -29
  166. package/dist/dashboard/cockpits.js +0 -65
  167. package/dist/dashboard/dashboard.d.ts +0 -7
  168. package/dist/dashboard/draw.d.ts +0 -15
  169. package/dist/dashboard/frame.d.ts +0 -4
  170. package/dist/dashboard/index.d.ts +0 -2
  171. package/dist/dashboard/modes.d.ts +0 -5
  172. package/dist/dashboard/node-connection.d.ts +0 -15
  173. package/dist/dashboard/node-connection.js +0 -51
  174. package/dist/dashboard/pi-tui.d.ts +0 -6
  175. package/dist/dashboard/status-bar.d.ts +0 -4
  176. package/dist/dashboard/terminal.d.ts +0 -53
  177. package/dist/dashboard/tree-model.d.ts +0 -28
  178. package/dist/dashboard/tree.d.ts +0 -10
  179. package/dist/development/cli.d.ts +0 -3
  180. package/dist/development/cli.js +0 -44
  181. package/dist/execution/tree/index.d.ts +0 -2
  182. package/dist/execution/tree/tree.d.ts +0 -3
  183. package/dist/hold/output/format.d.ts +0 -11
  184. package/dist/hold/output/index.d.ts +0 -2
  185. package/dist/hold/tree/index.d.ts +0 -2
  186. package/dist/hold/tree/tree.d.ts +0 -3
  187. package/dist/import/input.d.ts +0 -16
  188. package/dist/import/output.d.ts +0 -6
  189. package/dist/integration/output.d.ts +0 -22
  190. package/dist/login/failure.d.ts +0 -3
  191. package/dist/login/gateway.d.ts +0 -12
  192. package/dist/login/menu.d.ts +0 -4
  193. package/dist/login/output/format.d.ts +0 -16
  194. package/dist/login/output/index.d.ts +0 -2
  195. package/dist/login/vendor-account.d.ts +0 -95
  196. package/dist/login/vendor-input.d.ts +0 -14
  197. package/dist/mcp/calls.d.ts +0 -8
  198. package/dist/orchestration/output/compact-aggregate.d.ts +0 -121
  199. package/dist/orchestration/output/compact-run-list.d.ts +0 -20
  200. package/dist/orchestration/output/human.d.ts +0 -80
  201. package/dist/orchestration/output/index.d.ts +0 -4
  202. package/dist/orchestration/tree/index.d.ts +0 -2
  203. package/dist/orchestration/tree/tree.d.ts +0 -3
  204. package/dist/port-lease/input.d.ts +0 -65
  205. package/dist/port-lease/output/format.d.ts +0 -11
  206. package/dist/port-lease/output/index.d.ts +0 -2
  207. package/dist/presentation/output/format.d.ts +0 -11
  208. package/dist/presentation/output/index.d.ts +0 -3
  209. package/dist/project-guard/input.d.ts +0 -18
  210. package/dist/project-guard/output/format.d.ts +0 -11
  211. package/dist/project-guard/output/index.d.ts +0 -2
  212. package/dist/project-workspace/output/human.d.ts +0 -139
  213. package/dist/project-workspace/output/index.d.ts +0 -3
  214. package/dist/project-workspace/output/metadata.d.ts +0 -11
  215. package/dist/project-workspace/tree/index.d.ts +0 -2
  216. package/dist/project-workspace/tree/tree.d.ts +0 -3
  217. package/dist/provider/client.d.ts +0 -6
  218. package/dist/provider/commands.d.ts +0 -3
  219. package/dist/provider/index.d.ts +0 -3
  220. package/dist/reference/commands.d.ts +0 -3
  221. package/dist/reference/index.d.ts +0 -3
  222. package/dist/reference/resolve.d.ts +0 -31
  223. package/dist/reference/tree/index.d.ts +0 -2
  224. package/dist/reference/tree/tree.d.ts +0 -3
  225. package/dist/remote-node/reachability.d.ts +0 -64
  226. package/dist/remote-node/text.d.ts +0 -10
  227. package/dist/remote-node/tree/index.d.ts +0 -2
  228. package/dist/remote-node/tree/tree.d.ts +0 -3
  229. package/dist/routine/input.d.ts +0 -28
  230. package/dist/routine/output/format.d.ts +0 -23
  231. package/dist/routine/output/index.d.ts +0 -2
  232. package/dist/routine/tree/index.d.ts +0 -2
  233. package/dist/routine/tree/tree.d.ts +0 -3
  234. package/dist/run-ledger/input.d.ts +0 -42
  235. package/dist/run-ledger/output/format.d.ts +0 -11
  236. package/dist/run-ledger/output/index.d.ts +0 -2
  237. package/dist/session/approval/output/format.d.ts +0 -23
  238. package/dist/session/approval/output/index.d.ts +0 -2
  239. package/dist/session/attach-render.d.ts +0 -16
  240. package/dist/session/create-tasks.d.ts +0 -20
  241. package/dist/session/interaction/input.d.ts +0 -15
  242. package/dist/session/interaction/output/format.d.ts +0 -11
  243. package/dist/session/interaction/output/index.d.ts +0 -2
  244. package/dist/session/output/diff.d.ts +0 -3
  245. package/dist/session/output/failure.d.ts +0 -11
  246. package/dist/session/output/human.d.ts +0 -112
  247. package/dist/session/output/index.d.ts +0 -6
  248. package/dist/session/output/observe.d.ts +0 -4
  249. package/dist/session/output/tasks.d.ts +0 -34
  250. package/dist/session/task-file.d.ts +0 -5
  251. package/dist/session/tree/index.d.ts +0 -2
  252. package/dist/session/tree/tree.d.ts +0 -3
  253. package/dist/team-workspace/ceremony.d.ts +0 -19
  254. package/dist/team-workspace/confirmation.d.ts +0 -4
  255. package/dist/team-workspace/dependencies.js +0 -2
  256. package/dist/team-workspace/output.d.ts +0 -15
  257. package/dist/terminal/arguments.d.ts +0 -13
  258. package/dist/terminal/output/compact-list.d.ts +0 -148
  259. package/dist/terminal/output/human.d.ts +0 -42
  260. package/dist/terminal/output/index.d.ts +0 -3
  261. package/dist/terminal/tree/index.d.ts +0 -2
  262. package/dist/terminal/tree/tree.d.ts +0 -3
  263. /package/dist/command-line/{json-decoder.js → emit/json-decoder.js} +0 -0
  264. /package/dist/command-line/{json.d.ts → emit/json.d.ts} +0 -0
  265. /package/dist/command-line/{json.js → emit/json.js} +0 -0
  266. /package/dist/command-line/{output.js → emit/output.js} +0 -0
@@ -1,18 +1,23 @@
1
- import { MAX_SESSION_INBOX_CHECK_LIMIT, MAX_SESSION_MESSAGE_BODY_BYTES, MAX_SESSION_OBSERVE_IDS, MAX_SESSION_STALL_AFTER_SECONDS, MIN_SESSION_STALL_AFTER_SECONDS, SESSION_EFFORT_LEVELS, sessionBaseRefSchema, sessionCreateParametersSchema, } from "@maiaos/sdk";
1
+ import { MAX_SESSION_INBOX_CHECK_LIMIT, MAX_SESSION_MESSAGE_BODY_BYTES, MAX_SESSION_OBSERVE_IDS, MAX_SESSION_SETTLED_IDLE_SECONDS, MAX_SESSION_STALL_AFTER_SECONDS, MIN_SESSION_STALL_AFTER_SECONDS, SESSION_EFFORT_LEVELS, sessionBaseRefSchema, sessionCreateParametersSchema, } from "@maiaos/sdk";
2
2
  import { Effect } from "effect";
3
3
  import { listEach, writeMerged } from "../address-space/index.js";
4
- import { CliArgumentError, parseOptions, readCursor, readDuration, readExpectedRevision, readPageSize, requirePositionals, } from "../command-line/index.js";
4
+ import { CliArgumentError, LABEL_OPTION, parseOptions, parseOptionsWith, readCursor, readDuration, readExpectedRevision, readLabels, readPageSize, readPermission, readSessionRole, readSessionTitle, readWaitTimeoutSeconds, requireOneLabelPerOption, requirePositionals, writeNodeResult, } from "../command-line/index.js";
5
5
  import { mergeLists } from "../fleet/index.js";
6
6
  import { runSessionTasks, } from "./create-tasks.js";
7
- import { formatMergedSessions, writeSessionResult } from "./output/index.js";
7
+ import { formatMergedSessions, formatSessionShow, writeSessionResult, } from "./output/index.js";
8
+ const EXIT_DEADLINE = 74;
8
9
  const SESSION_CREATE_OPTIONS = new Set([
9
10
  "--agent",
10
11
  "--base",
11
12
  "--command-id",
12
13
  "--connection",
14
+ "--cwd",
13
15
  "--effort",
14
16
  "--executor",
17
+ "--label",
15
18
  "--model",
19
+ "--name",
20
+ "--permission",
16
21
  "--agent-definition",
17
22
  "--agent-definition-version",
18
23
  "--agent-definition-digest",
@@ -20,6 +25,12 @@ const SESSION_CREATE_OPTIONS = new Set([
20
25
  "--title",
21
26
  ]);
22
27
  const summarizeSessionCreation = (result) => ({
28
+ ...(result.session.containment === undefined
29
+ ? {}
30
+ : { containment: result.session.containment }),
31
+ ...(result.session.permission === undefined
32
+ ? {}
33
+ : { permission: result.session.permission }),
23
34
  ...(result.session.agentDefinitionRef === undefined
24
35
  ? {}
25
36
  : { agentDefinitionRef: result.session.agentDefinitionRef }),
@@ -31,6 +42,9 @@ const summarizeSessionCreation = (result) => ({
31
42
  revision: result.session.revision,
32
43
  sessionId: result.session.id,
33
44
  state: result.session.state,
45
+ ...(result.session.labels === undefined
46
+ ? {}
47
+ : { labels: result.session.labels }),
34
48
  ...(result.session.title === undefined
35
49
  ? {}
36
50
  : { title: result.session.title }),
@@ -62,7 +76,7 @@ const readSessionCreateOptions = (parsed) => {
62
76
  throw new CliArgumentError(parsed.options.has("--project")
63
77
  ? "Option '--project' needs '--message', '--prompt-stdin' or '--from-file'; name a Workspace with '--workspace' otherwise."
64
78
  : "Option '--workspace' is required.");
65
- const input = readSessionSelection(parsed.options, workspaceId);
79
+ const input = readSessionSelection(parsed, workspaceId);
66
80
  const definition = readDefinitionSelection(parsed.options, input);
67
81
  requireOneSelection({ ...input, ...definition });
68
82
  return { ...input, ...definition };
@@ -92,13 +106,6 @@ const readEffort = (value) => {
92
106
  return level;
93
107
  throw new CliArgumentError(`Option '--effort' must be ${SESSION_EFFORT_LEVELS["codex-cli"].slice(0, -1).join(", ")} or ${SESSION_EFFORT_LEVELS["codex-cli"].at(-1) ?? "ultra"}.`);
94
108
  };
95
- const readSessionRole = (value) => {
96
- if (value === undefined)
97
- return {};
98
- if (value === "worker" || value === "orchestrator")
99
- return { role: value };
100
- throw new CliArgumentError("Option '--role' must be worker or orchestrator.");
101
- };
102
109
  const AGENT_FIXED_OPTIONS = [
103
110
  "--agent-definition",
104
111
  "--agent-definition-digest",
@@ -117,28 +124,61 @@ const readAgentId = (options) => {
117
124
  throw new CliArgumentError(`Option '--agent' fixes the harness, Connection, model and effort; drop '${clash}'.`);
118
125
  return { agentId };
119
126
  };
120
- const readSessionSelection = (options, workspaceId) => {
127
+ const readSessionSelection = ({ flags, options }, workspaceId) => {
121
128
  const agent = readAgentId(options);
122
129
  const commandId = options.get("--command-id");
123
130
  const connectionId = options.get("--connection");
124
131
  const executor = readExecutorKind(options.get("--executor"));
125
132
  const effort = readEffort(options.get("--effort"));
133
+ const cwd = options.get("--cwd");
126
134
  const model = options.get("--model");
127
- const title = options.get("--title");
135
+ const title = readSessionTitle(options);
128
136
  const selection = {
129
137
  ...agent,
130
138
  ...(commandId === undefined ? {} : { commandId }),
131
139
  ...(connectionId === undefined ? {} : { connectionId }),
140
+ ...(cwd === undefined ? {} : { cwd }),
132
141
  ...(effort === undefined ? {} : { effort }),
133
142
  ...(executor === undefined ? {} : { executor }),
134
143
  ...(model === undefined ? {} : { model }),
144
+ ...readLabels(options.get("--label")),
135
145
  ...readSessionRole(options.get("--role")),
136
146
  ...(title === undefined ? {} : { title }),
147
+ ...readHostAuthority({ flags, options }),
137
148
  workspaceId,
138
149
  };
139
150
  const baseRef = readBaseRef(options.get("--base"), selection);
140
151
  return { ...selection, ...(baseRef === undefined ? {} : { baseRef }) };
141
152
  };
153
+ const validPermission = (permission, executor) => {
154
+ const valid = sessionCreateParametersSchema.safeParse({
155
+ commandId: "command_validate",
156
+ ...(executor === undefined
157
+ ? { connectionId: "connection_validate" }
158
+ : { executor }),
159
+ expectedRevision: "0",
160
+ hostAuthority: true,
161
+ permission,
162
+ workspaceId: "workspace_validate",
163
+ });
164
+ return valid.success ? valid.data.permission : undefined;
165
+ };
166
+ const readHostAuthority = ({ flags, options, }) => {
167
+ const permission = options.get("--permission");
168
+ if (!flags.has("--host-authority")) {
169
+ if (permission !== undefined)
170
+ throw new CliArgumentError("Option '--permission' needs '--host-authority'.");
171
+ return {};
172
+ }
173
+ if (options.has("--base"))
174
+ throw new CliArgumentError("Option '--host-authority' runs in an existing '--cwd', not a Maia worktree; drop '--base'.");
175
+ if (!options.has("--connection") && !options.has("--executor"))
176
+ throw new CliArgumentError("Option '--host-authority' needs '--connection' or '--executor'.");
177
+ return {
178
+ hostAuthority: true,
179
+ ...readPermission(permission, (value) => validPermission(value, readExecutorKind(options.get("--executor")))),
180
+ };
181
+ };
142
182
  const readBaseRef = (value, selection) => {
143
183
  if (value === undefined)
144
184
  return;
@@ -188,8 +228,11 @@ const taskSource = (parsed) => {
188
228
  const stdin = parsed.flags.has("--prompt-stdin");
189
229
  if ([file, message, stdin ? "" : undefined].filter((value) => value !== undefined).length > 1)
190
230
  throw new CliArgumentError("Use one of '--message', '--prompt-stdin' or '--from-file'.");
191
- if (file !== undefined && parsed.options.has("--title"))
192
- throw new CliArgumentError("Option '--title' names one Session; with '--from-file' each Session takes its task's first line.");
231
+ if (file !== undefined &&
232
+ (parsed.options.has("--title") || parsed.options.has("--name")))
233
+ throw new CliArgumentError("Option '--title' or '--name' names one Session; with '--from-file' each Session takes its task's first line.");
234
+ if (file !== undefined && parsed.options.has("--label"))
235
+ throw new CliArgumentError("Option '--label' labels one Session; it cannot be used with '--from-file'.");
193
236
  if (file !== undefined)
194
237
  return { kind: "file", path: file };
195
238
  if (message !== undefined)
@@ -211,7 +254,7 @@ const readSessionTasks = (parsed, source) => {
211
254
  const workspaceId = readTaskWorkspace(parsed, source);
212
255
  const projectId = parsed.options.get("--project");
213
256
  const commandId = parsed.options.get("--command-id");
214
- const { workspaceId: _placeholder, ...selection } = readSessionSelection(parsed.options, workspaceId ?? "workspace_default");
257
+ const { workspaceId: _placeholder, ...selection } = readSessionSelection(parsed, workspaceId ?? "workspace_default");
215
258
  requireOneSelection({ ...selection, workspaceId: _placeholder });
216
259
  return {
217
260
  ...(commandId === undefined ? {} : { commandId }),
@@ -222,7 +265,12 @@ const readSessionTasks = (parsed, source) => {
222
265
  };
223
266
  };
224
267
  export const runSessionCreate = (tokens, context) => {
225
- const parsed = parseOptions(tokens, TASK_OPTIONS, new Set(["--prompt-stdin"]));
268
+ requireOneLabelPerOption(tokens);
269
+ const parsed = parseOptionsWith(tokens, {
270
+ allowed: TASK_OPTIONS,
271
+ allowedFlags: new Set(["--host-authority", "--prompt-stdin"]),
272
+ repeatable: LABEL_OPTION,
273
+ });
226
274
  const source = taskSource(parsed);
227
275
  if (source !== undefined)
228
276
  return runSessionTasks(readSessionTasks(parsed, source), context);
@@ -231,8 +279,39 @@ export const runSessionCreate = (tokens, context) => {
231
279
  result: summarizeSessionCreation(value),
232
280
  })));
233
281
  };
282
+ const readSettled = ({ flags, options, }) => {
283
+ const idleFor = options.get("--idle-for");
284
+ if (!flags.has("--settled")) {
285
+ if (idleFor !== undefined)
286
+ throw new CliArgumentError("Use '--idle-for' with '--settled'.");
287
+ return {};
288
+ }
289
+ return {
290
+ ...(idleFor === undefined
291
+ ? {}
292
+ : {
293
+ idleForSeconds: readDuration(idleFor, "--idle-for", {
294
+ max: MAX_SESSION_SETTLED_IDLE_SECONDS,
295
+ min: 1,
296
+ }),
297
+ }),
298
+ settled: true,
299
+ };
300
+ };
234
301
  const readSessionList = (tokens) => {
235
- const parsed = parseOptions(tokens, new Set(["--after", "--limit", "--project", "--state"]), new Set(["--all", "--attention"]));
302
+ requireOneLabelPerOption(tokens);
303
+ const parsed = parseOptionsWith(tokens, {
304
+ allowed: new Set([
305
+ "--after",
306
+ "--idle-for",
307
+ "--label",
308
+ "--limit",
309
+ "--project",
310
+ "--state",
311
+ ]),
312
+ allowedFlags: new Set(["--all", "--attention", "--settled"]),
313
+ repeatable: LABEL_OPTION,
314
+ });
236
315
  requirePositionals(parsed.positionals, 0);
237
316
  const projectId = parsed.options.get("--project");
238
317
  if ((projectId === undefined) === !parsed.flags.has("--all"))
@@ -240,7 +319,9 @@ const readSessionList = (tokens) => {
240
319
  const states = parsed.options.get("--state")?.split(",");
241
320
  return {
242
321
  afterCursor: readCursor(parsed.options.get("--after")),
322
+ ...readSettled(parsed),
243
323
  limit: readPageSize(parsed.options.get("--limit")),
324
+ ...readLabels(parsed.options.get("--label")),
244
325
  ...(projectId === undefined ? {} : { projectId }),
245
326
  ...(parsed.flags.has("--attention") ? { attention: true } : {}),
246
327
  ...(states === undefined ? {} : { states }),
@@ -287,6 +368,38 @@ export const runSessionShow = (tokens, context) => Effect.gen(function* () {
287
368
  result: value,
288
369
  }));
289
370
  });
371
+ const readWaitInput = (tokens) => {
372
+ const parsed = parseOptionsWith(tokens, {
373
+ allowed: new Set(["--activity", "--timeout", "--until"]),
374
+ allowedFlags: new Set(),
375
+ repeatable: new Set(["--activity", "--until"]),
376
+ });
377
+ requirePositionals(parsed.positionals, 1);
378
+ const [sessionId] = parsed.positionals;
379
+ const states = parsed.options.get("--until")?.split(",");
380
+ const activities = parsed.options.get("--activity")?.split(",");
381
+ if (sessionId === undefined ||
382
+ (states === undefined && activities === undefined))
383
+ throw new CliArgumentError("Name the Session and the states ('--until') or activities ('--activity') to wait for.");
384
+ return {
385
+ ...(activities === undefined ? {} : { activities }),
386
+ sessionId,
387
+ ...(states === undefined ? {} : { states }),
388
+ timeoutMilliseconds: readWaitTimeoutSeconds(parsed.options.get("--timeout")) * 1000,
389
+ };
390
+ };
391
+ export const runSessionWait = (tokens, context) => Effect.gen(function* () {
392
+ const input = readWaitInput(tokens);
393
+ const { waitSession } = context.dependencies;
394
+ if (waitSession === undefined)
395
+ throw new CliArgumentError("Session wait is unavailable.");
396
+ const result = yield* waitSession(input);
397
+ const code = writeNodeResult(result, context, {
398
+ toResult: (value) => ({ command: "session.wait", result: value }),
399
+ toText: ({ result: waited }) => formatSessionShow(waited),
400
+ });
401
+ return result.ok && !result.value.satisfied ? EXIT_DEADLINE : code;
402
+ });
290
403
  const readLifecycleInput = (parsed) => {
291
404
  const sessionId = parsed.positionals[0];
292
405
  if (sessionId === undefined) {
@@ -21,13 +21,20 @@ 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, effort, executor, model, 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 }),
34
+ ...toStartFields(selection),
29
35
  ...(effort === undefined ? {} : { effort }),
30
36
  ...(executor === undefined ? {} : { executor }),
37
+ ...(labels === undefined ? {} : { labels }),
31
38
  ...(model === undefined ? {} : { model }),
32
39
  ...(role === undefined ? {} : { role }),
33
40
  ...(title === undefined ? {} : { title }),
@@ -88,10 +95,11 @@ const batchError = (items) => {
88
95
  const failed = items.find((item) => item.error !== undefined);
89
96
  if (failed?.error === undefined)
90
97
  return undefined;
91
- const { code, failure, kind, operationId, retryable } = failed.error;
98
+ const { code, failure, kind, message, operationId, retryable } = failed.error;
92
99
  return {
93
100
  code: failure?.code ?? code ?? kind,
94
101
  message: failure?.message ??
102
+ message ??
95
103
  `Line ${String(failed.line)} stopped at ${operationId}: ${code ?? kind}.`,
96
104
  retryable,
97
105
  };
@@ -4,6 +4,6 @@ export { type AttachSessionInput, makeAttachClient, type SessionAttachStream, }
4
4
  export { type CreateSessionInput, type ListSessionsInput, makeSessionClient, type StartSessionInput, } from "./client.js";
5
5
  export { type ArchiveSessionInput, type DiffSessionInput, } from "./coding-client.js";
6
6
  export { runSessionArchive, runSessionDiff } from "./coding-commands.js";
7
- export { runSessionCreate, runSessionEventsList, runSessionInboxAck, runSessionInboxCheck, runSessionList, runSessionMessageSend, runSessionObserve, runSessionResume, runSessionShow, runSessionStart, runSessionStop, } from "./commands.js";
7
+ export { runSessionCreate, runSessionEventsList, runSessionInboxAck, runSessionInboxCheck, runSessionList, runSessionMessageSend, runSessionObserve, runSessionResume, runSessionShow, runSessionStart, runSessionStop, runSessionWait, } from "./commands.js";
8
8
  export { runSessionRename } from "./rename.js";
9
9
  //# sourceMappingURL=index.d.ts.map
@@ -3,6 +3,6 @@ export { runSessionAttach } from "./attach.js";
3
3
  export { makeAttachClient, } from "./attach-client.js";
4
4
  export { makeSessionClient, } from "./client.js";
5
5
  export { runSessionArchive, runSessionDiff } from "./coding-commands.js";
6
- export { runSessionCreate, runSessionEventsList, runSessionInboxAck, runSessionInboxCheck, runSessionList, runSessionMessageSend, runSessionObserve, runSessionResume, runSessionShow, runSessionStart, runSessionStop, } from "./commands.js";
6
+ export { runSessionCreate, runSessionEventsList, runSessionInboxAck, runSessionInboxCheck, runSessionList, runSessionMessageSend, runSessionObserve, runSessionResume, runSessionShow, runSessionStart, runSessionStop, runSessionWait, } from "./commands.js";
7
7
  export { runSessionRename } from "./rename.js";
8
8
  //# sourceMappingURL=index.js.map
@@ -1,12 +1,14 @@
1
- import { cell, fields, formatRows, tab, writeNodeResult, } from "../../command-line/index.js";
1
+ import { cell, fields, formatRows, labelCells, tab, withPrunedHistory, writeNodeResult, } from "../../command-line/index.js";
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 { activityLabel, formatSessionList, formatSessionTasks, } 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],
9
9
  ["account", result.executor?.connectionId],
10
+ ["containment", result.containment],
11
+ ["permission", result.permission],
10
12
  [
11
13
  "workspace",
12
14
  result.worktree === undefined ? undefined : result.workspaceId,
@@ -31,12 +33,36 @@ const formatCodingSession = (result) => {
31
33
  const formatAgentPermission = (result) => result.command === "session.agent-permission.preview"
32
34
  ? `${result.result.sessionId}\t${result.result.expiresAt}\n`
33
35
  : `${result.result.receipt.receiptId}\t${result.result.delivery}\n`;
34
- const formatSessionShow = ({ session, }) => `${fields([
36
+ const formatPrompt = (prompt) => prompt === undefined
37
+ ? ""
38
+ : `prompt: ${prompt.approvalId}\t${prompt.kind}\texpires=${prompt.expiresAt}\n${(prompt.summary ?? "")
39
+ .split("\n")
40
+ .map((line) => ` ${line}`)
41
+ .join("\n")}\n${(prompt.options ?? [])
42
+ .map((option) => ` ${option.optionId}\t${option.label}\n`)
43
+ .join("")}`;
44
+ export const formatSessionShow = ({ session, }) => `${fields([
35
45
  ["session", session.id],
36
46
  ["state", session.state],
47
+ ...(session.status === undefined
48
+ ? []
49
+ : [["status", session.status]]),
50
+ ...(session.activity === undefined
51
+ ? []
52
+ : [["activity", activityLabel(session)]]),
53
+ ...(session.latestTurnState === undefined
54
+ ? []
55
+ : [["latest-turn", session.latestTurnState]]),
37
56
  ["revision", session.revision],
38
57
  ["workspace", session.workspaceId],
39
- ])}${formatFailure(session.failure)}`;
58
+ ["containment", session.containment],
59
+ ["permission", session.permission],
60
+ [
61
+ "labels",
62
+ session.labels === undefined ? undefined : labelCells(session.labels),
63
+ ],
64
+ ["updated", session.updatedAt],
65
+ ])}${formatPrompt(session.prompt)}${formatFailure(session.failure)}${formatFailure(session.recovery, "recovering")}`;
40
66
  const formatLifecycle = ({ revision, sessionId, state, }) => `${fields([
41
67
  ["session", sessionId],
42
68
  ["state", state],
@@ -45,6 +71,7 @@ const formatLifecycle = ({ revision, sessionId, state, }) => `${fields([
45
71
  const formatSessions = (result) => result.items.length === 0 ? "No Sessions.\n" : formatSessionList(result);
46
72
  const formatInboxAck = ({ delivery, deliveryRecord, mailboxRevision, }) => `${tab([deliveryRecord.deliveryId, delivery, mailboxRevision])}\n`;
47
73
  const formatMessageSend = ({ delivery, deliveryId, sequence, }) => `${tab([deliveryId, delivery, sequence])}\n`;
74
+ const formatEventsPage = ({ items, oldestRetainedCursor, }) => withPrunedHistory(formatSessionEvents(items), oldestRetainedCursor);
48
75
  export const formatSessionResult = (result) => {
49
76
  switch (result.command) {
50
77
  case "session.agent-permission.confirm":
@@ -56,7 +83,7 @@ export const formatSessionResult = (result) => {
56
83
  case "session.diff":
57
84
  return formatCodingSession(result);
58
85
  case "session.events.list":
59
- return formatSessionEvents(result.result.items);
86
+ return formatEventsPage(result.result);
60
87
  case "session.inbox.ack":
61
88
  return formatInboxAck(result.result);
62
89
  case "session.inbox.check":
@@ -1,6 +1,6 @@
1
1
  export { formatSessionDiff } from "./diff.js";
2
2
  export { formatFailure, formatFailureCell, formatSessionEvents, } from "./failure.js";
3
- export { formatSessionResult, writeSessionResult, } from "./human.js";
3
+ export { formatSessionResult, formatSessionShow, writeSessionResult, } from "./human.js";
4
4
  export { formatSessionObservation } from "./observe.js";
5
5
  export { formatMergedSessions, formatSessionList, formatSessionTasks, } from "./tasks.js";
6
6
  //# sourceMappingURL=index.js.map
@@ -1,9 +1,17 @@
1
1
  import { formatMerged } from "../../address-space/index.js";
2
- import { cell, fields, formatRows, tab, withNextPage, } from "../../command-line/index.js";
2
+ import { cell, fields, formatRows, labelCells, tab, withNextPage, } from "../../command-line/index.js";
3
3
  import { formatFailureCell } from "./failure.js";
4
- const failure = ({ error }) => error === undefined
5
- ? undefined
6
- : `${error.operationId}:${error.code ?? error.kind}${error.failure === undefined ? "" : ` (${formatFailureCell(error.failure)})`}`;
4
+ const failureDetail = ({ failure, message, }) => {
5
+ if (failure !== undefined)
6
+ return formatFailureCell(failure);
7
+ return message === undefined ? undefined : cell(message);
8
+ };
9
+ const failure = ({ error }) => {
10
+ if (error === undefined)
11
+ return undefined;
12
+ const detail = failureDetail(error);
13
+ return `${error.operationId}:${error.code ?? error.kind}${detail === undefined ? "" : ` (${detail})`}`;
14
+ };
7
15
  export const formatSessionTasks = ({ items }) => items.length === 1
8
16
  ? items
9
17
  .map((item) => fields([
@@ -25,17 +33,49 @@ export const formatSessionTasks = ({ items }) => items.length === 1
25
33
  empty: "",
26
34
  headers: ["LINE", "STAGE", "SESSION", "TURN", "COMMAND", "ERROR"],
27
35
  });
28
- const SESSION_HEADERS = ["SESSION", "STATE", "WORKSPACE", "ATTENTION", "TITLE"];
36
+ const SESSION_HEADERS = [
37
+ "SESSION",
38
+ "STATE",
39
+ "ACTIVITY",
40
+ "STATUS",
41
+ "WORKSPACE",
42
+ "ATTENTION",
43
+ "CONTAINMENT",
44
+ "TITLE",
45
+ "LABELS",
46
+ "LAST ACTIVE",
47
+ ];
48
+ export const activityLabel = (session) => {
49
+ const completed = session.status === undefined
50
+ ? session.latestTurnState === "completed"
51
+ : session.status === "done";
52
+ return session.activity === "idle" && completed
53
+ ? "done"
54
+ : (session.activity ?? "-");
55
+ };
56
+ const sessionHeaders = (items) => items.some((session) => session.settledReason !== undefined)
57
+ ? [...SESSION_HEADERS, "SETTLED"]
58
+ : SESSION_HEADERS;
59
+ const settledCells = (session, headers) => headers.length > SESSION_HEADERS.length ? [session.settledReason ?? "-"] : [];
29
60
  const sessionCells = (session, attention) => [
30
61
  session.id,
31
62
  session.state,
63
+ activityLabel(session),
64
+ session.status ?? "-",
32
65
  session.workspaceId,
33
66
  attention ?? "-",
67
+ session.containment ?? "-",
34
68
  cell(session.title ?? "-"),
69
+ labelCells(session.labels),
70
+ session.updatedAt,
35
71
  ];
36
72
  export const formatSessionList = (result) => {
37
73
  const attention = new Map((result.attention ?? []).map((item) => [item.sessionId, item.attention]));
38
- return withNextPage(formatRows(result.items, (session) => tab(sessionCells(session, attention.get(session.id))), { empty: "No Sessions.", headers: SESSION_HEADERS }), result.nextCursor);
74
+ const headers = sessionHeaders(result.items);
75
+ return withNextPage(formatRows(result.items, (session) => tab([
76
+ ...sessionCells(session, attention.get(session.id)),
77
+ ...settledCells(session, headers),
78
+ ]), { empty: "No Sessions.", headers }), result.nextCursor);
39
79
  };
40
80
  const sessionKey = (node, id) => `${node} ${id}`;
41
81
  export const formatMergedSessions = ({ result, }) => {
@@ -43,6 +83,10 @@ export const formatMergedSessions = ({ result, }) => {
43
83
  sessionKey(item.node, item.sessionId),
44
84
  item.attention,
45
85
  ]));
46
- return formatMerged(result, (session) => tab(sessionCells(session, attention.get(sessionKey(session.node, session.id)))), { empty: "No Sessions.", headers: SESSION_HEADERS });
86
+ const headers = sessionHeaders(result.items);
87
+ return formatMerged(result, (session) => tab([
88
+ ...sessionCells(session, attention.get(sessionKey(session.node, session.id))),
89
+ ...settledCells(session, headers),
90
+ ]), { empty: "No Sessions.", headers });
47
91
  };
48
92
  //# sourceMappingURL=tasks.js.map