@moberg_hr/work-tree 2.22.0 → 2.22.1

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 (40) hide show
  1. package/dist/{answer-MWBEM7P7.js → answer-HQVJNI26.js} +2 -2
  2. package/dist/bin.js +1 -1
  3. package/dist/{child-OAKEKASR.js → child-ZN7PG7DR.js} +2 -2
  4. package/dist/{chunk-KWHHB737.js → chunk-BRIYWWE3.js} +7 -2
  5. package/dist/chunk-BRIYWWE3.js.map +1 -0
  6. package/dist/{chunk-ZLIW4G24.js → chunk-FGWGPTQC.js} +10 -10
  7. package/dist/chunk-VQ63WDRZ.js +9 -0
  8. package/dist/{cli-KRTX5VN7.js → cli-FK3WEKNF.js} +3 -3
  9. package/dist/{pty-host-4LWIAULG.js → pty-host-UWBE2OIL.js} +2 -2
  10. package/dist/{report-2NXU55QS.js → report-3YX5PLOE.js} +2 -2
  11. package/dist/{send-S3BBWJHD.js → send-4CKKTNQX.js} +2 -2
  12. package/dist/{start-JGVD2O5V.js → start-E7KVWGW6.js} +21 -12
  13. package/dist/start-E7KVWGW6.js.map +1 -0
  14. package/dist/{wait-RULOZMLR.js → wait-BVU2IHP3.js} +2 -2
  15. package/dist/wd-bin.js +2 -2
  16. package/dist/web/assets/{PtyView-BTvDVP2F.js → PtyView-CI7F38MV.js} +27 -27
  17. package/dist/web/assets/PtyView-CI7F38MV.js.map +1 -0
  18. package/dist/web/assets/{index-CBDCRV_L.js → index-45mmMijZ.js} +9 -9
  19. package/dist/web/assets/index-45mmMijZ.js.map +1 -0
  20. package/dist/web/index.html +1 -1
  21. package/dist/{web-4JKMKTTD.js → web-B4C2O7GU.js} +9 -5
  22. package/dist/web-B4C2O7GU.js.map +1 -0
  23. package/npm-shrinkwrap.json +2 -2
  24. package/package.json +1 -1
  25. package/plugins/work-tree/skills/work-sessions/SKILL.md +1 -1
  26. package/dist/chunk-KWHHB737.js.map +0 -1
  27. package/dist/chunk-TIRRXH6I.js +0 -9
  28. package/dist/start-JGVD2O5V.js.map +0 -1
  29. package/dist/web/assets/PtyView-BTvDVP2F.js.map +0 -1
  30. package/dist/web/assets/index-CBDCRV_L.js.map +0 -1
  31. package/dist/web-4JKMKTTD.js.map +0 -1
  32. /package/dist/{answer-MWBEM7P7.js.map → answer-HQVJNI26.js.map} +0 -0
  33. /package/dist/{child-OAKEKASR.js.map → child-ZN7PG7DR.js.map} +0 -0
  34. /package/dist/{chunk-ZLIW4G24.js.map → chunk-FGWGPTQC.js.map} +0 -0
  35. /package/dist/{chunk-TIRRXH6I.js.map → chunk-VQ63WDRZ.js.map} +0 -0
  36. /package/dist/{cli-KRTX5VN7.js.map → cli-FK3WEKNF.js.map} +0 -0
  37. /package/dist/{pty-host-4LWIAULG.js.map → pty-host-UWBE2OIL.js.map} +0 -0
  38. /package/dist/{report-2NXU55QS.js.map → report-3YX5PLOE.js.map} +0 -0
  39. /package/dist/{send-S3BBWJHD.js.map → send-4CKKTNQX.js.map} +0 -0
  40. /package/dist/{wait-RULOZMLR.js.map → wait-BVU2IHP3.js.map} +0 -0
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  pendingRequest
4
- } from "./chunk-KWHHB737.js";
4
+ } from "./chunk-BRIYWWE3.js";
5
5
  import "./chunk-FZHFD2AY.js";
6
6
  import {
7
7
  sessionFromArgs,
@@ -74,4 +74,4 @@ var answerCommand = {
74
74
  export {
75
75
  answerCommand
76
76
  };
77
- //# sourceMappingURL=answer-MWBEM7P7.js.map
77
+ //# sourceMappingURL=answer-HQVJNI26.js.map
package/dist/bin.js CHANGED
@@ -52,7 +52,7 @@ if (args[0] === "hook" && args[1] === "statusline") {
52
52
  } else {
53
53
  const { default: chalk } = await import("chalk");
54
54
  if (!process.env.NO_COLOR && chalk.level === 0) chalk.level = 1;
55
- const { run } = await import("./cli-KRTX5VN7.js");
55
+ const { run } = await import("./cli-FK3WEKNF.js");
56
56
  const { withReporter } = await import("./report-Z36H65YG.js");
57
57
  const { consoleReporter, reportStreamFor } = await import("./console-reporter-XU6VFUZE.js");
58
58
  await withReporter(consoleReporter(reportStreamFor(args)), () => run(args));
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  sendHowText
4
- } from "./chunk-KWHHB737.js";
4
+ } from "./chunk-BRIYWWE3.js";
5
5
  import "./chunk-FZHFD2AY.js";
6
6
  import {
7
7
  GRANT_HINT,
@@ -145,4 +145,4 @@ var childCommand = {
145
145
  export {
146
146
  childCommand
147
147
  };
148
- //# sourceMappingURL=child-OAKEKASR.js.map
148
+ //# sourceMappingURL=child-ZN7PG7DR.js.map
@@ -5,11 +5,15 @@ import {
5
5
 
6
6
  // src/core/sessions/session-control.ts
7
7
  var MAX_SEND_CHARS = 2e4;
8
+ function archivedRefusal(s) {
9
+ return `it is archived: \`work start ${s.target} ${s.branch}\` restores it (as it was, its conversation too) and starts it; then try again`;
10
+ }
8
11
  async function sendToSession(id, text, deps, opts = {}) {
9
12
  const body = text.trim();
10
13
  if (!body) return { ok: false, status: 400, error: "the message is empty" };
11
14
  if (body.length > MAX_SEND_CHARS) return { ok: false, status: 400, error: `the message is over ${MAX_SEND_CHARS} characters` };
12
- if (deps.archived(id)) return { ok: false, status: 409, error: "it is archived: restore it first" };
15
+ const archived = deps.archived(id);
16
+ if (archived) return { ok: false, status: 409, error: archivedRefusal(archived) };
13
17
  const unsafe = deps.stillUnsafe?.(id);
14
18
  if (unsafe) return { ok: false, status: 409, error: stillUnsafeMessage(unsafe) };
15
19
  const sentAt = (opts.now?.() ?? /* @__PURE__ */ new Date()).toISOString();
@@ -56,10 +60,11 @@ function parseDuration(text) {
56
60
  }
57
61
 
58
62
  export {
63
+ archivedRefusal,
59
64
  sendToSession,
60
65
  sendHowText,
61
66
  waitForTurn,
62
67
  pendingRequest,
63
68
  parseDuration
64
69
  };
65
- //# sourceMappingURL=chunk-KWHHB737.js.map
70
+ //# sourceMappingURL=chunk-BRIYWWE3.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core/sessions/session-control.ts"],"sourcesContent":["import type { AgentState } from '../status/attention.js';\nimport type { PermissionRequest, SendHow } from '../api-types.js';\nimport { stillUnsafeMessage, type LegacyUnsafe } from './legacy-unsafe.js';\n\n/**\n * Driving a session from outside its terminal — another Claude, a script,\n * you in a shell: send it a message, wait for its turn to end, answer its\n * permission prompt. The policy is here; I/O is passed in (the routes in\n * session-control-routes.ts give the real one, tests a fake).\n *\n * A message goes the way every note to a session goes (§ saved prompts): a\n * published comment, which the dashboard types into a terminal it owns when\n * that Claude is idle, or which the prompt hook hands over on its next turn.\n * Never typed into a terminal directly.\n */\n\nexport const MAX_SEND_CHARS = 20_000;\n\nexport type { SendHow } from '../api-types.js';\n\nexport interface SendDeps {\n /** Queue it as a published comment (the comment route), resolving to what that route did with it: typed into an idle host Claude, left for the end of its turn, or null (no host terminal). */\n post: (id: string, body: string) => Promise<'typed' | 'next-turn' | null>;\n /** Its Claude runs in the PTY host. */\n hostRuns: (id: string) => boolean;\n /** Its Claude runs in a terminal outside work (seen in Claude Code's process files). */\n runningOutside: (id: string) => boolean;\n /** Start its Claude in the host, resuming its conversation, its first message saying a note is attached (NOTE_NUDGE). */\n start: (id: string) => Promise<boolean>;\n state: (id: string) => AgentState | null;\n /** Archived: which session (to say how to restore it); null when it isn't. */\n archived: (id: string) => { target: string; branch: string } | null;\n /** Its agent still runs as started `--unsafe` before the retirement (legacy-unsafe.ts). REMOVE IN THE NEXT RELEASE. */\n stillUnsafe?: (id: string) => LegacyUnsafe | null;\n}\n\n/**\n * Why an archived session can't be sent to, and how to bring it back: there is no `work restore`, and an agent told\n * only \"restore it first\" tried commands until `work tree` worked (reported). `work start <alias> <branch>` restores it\n * as it was — worktree, uncommitted work, conversation — and starts its agent in the background. Pure.\n */\nexport function archivedRefusal(s: { target: string; branch: string }): string {\n return `it is archived: \\`work start ${s.target} ${s.branch}\\` restores it (as it was, its conversation too) and starts it; then try again`;\n}\n\nexport type SendResult = { ok: true; how: SendHow; sentAt: string } | { ok: false; status: 400 | 409 | 502; error: string };\n\nexport async function sendToSession(id: string, text: string, deps: SendDeps, opts: { now?: () => Date } = {}): Promise<SendResult> {\n const body = text.trim();\n if (!body) return { ok: false, status: 400, error: 'the message is empty' };\n if (body.length > MAX_SEND_CHARS) return { ok: false, status: 400, error: `the message is over ${MAX_SEND_CHARS} characters` };\n const archived = deps.archived(id);\n if (archived) return { ok: false, status: 409, error: archivedRefusal(archived) };\n // It would act on this unreviewed, and it may have come from another agent (legacy-unsafe.ts; remove next release).\n const unsafe = deps.stillUnsafe?.(id);\n if (unsafe) return { ok: false, status: 409, error: stillUnsafeMessage(unsafe) };\n const sentAt = (opts.now?.() ?? new Date()).toISOString();\n // What the comment route did, as it decided it — not a second look at the state.\n const delivered = await deps.post(id, body);\n if (delivered) return { ok: true, how: delivered, sentAt };\n if (deps.hostRuns(id)) return { ok: true, how: 'next-turn', sentAt };\n if (deps.runningOutside(id)) return { ok: true, how: 'outside', sentAt };\n if (!(await deps.start(id)))\n return { ok: false, status: 502, error: 'queued, but its Claude could not be started: it gets it when you open the session' };\n return { ok: true, how: 'started', sentAt };\n}\n\n/** What `how` means, in a line. */\nexport function sendHowText(how: SendHow): string {\n switch (how) {\n case 'typed':\n return 'sent: typed into its terminal';\n case 'next-turn':\n return 'queued: it is working, so it gets this when the turn ends';\n case 'outside':\n return 'queued: its Claude runs in a terminal outside work, and gets this on its next turn there';\n case 'started':\n return 'sent: its Claude was started (resuming its conversation) with this as the first message';\n }\n}\n\nexport interface TurnStatus {\n state: AgentState;\n /** When it entered that state (ISO). */\n since: string;\n summary?: string;\n}\n\nexport interface WaitDeps {\n status: (id: string) => TurnStatus | null;\n sleep: (ms: number) => Promise<void>;\n now: () => number;\n}\n\nexport type WaitResult = { ok: true; status: TurnStatus } | { ok: false; reason: 'timeout'; status: TurnStatus | null };\n\n/**\n * Wait until the session isn't working: its turn ended (idle) or it asks\n * you something (needs input). With `after` (when a message was sent), only\n * a state entered after it counts — the turn that message started, not the\n * one before.\n */\nexport async function waitForTurn(\n id: string,\n deps: WaitDeps,\n opts: { after?: string; timeoutMs: number; pollMs?: number },\n): Promise<WaitResult> {\n const deadline = deps.now() + opts.timeoutMs;\n const after = opts.after ? Date.parse(opts.after) : null;\n for (;;) {\n const s = deps.status(id);\n const fresh = after === null || (!!s && Date.parse(s.since) > after);\n if (s && s.state !== 'working' && fresh) return { ok: true, status: s };\n if (deps.now() >= deadline) return { ok: false, reason: 'timeout', status: s };\n await deps.sleep(opts.pollMs ?? 1000);\n }\n}\n\n/** The permission prompt it is waiting on, if any (what `work answer` shows, and must send back). */\nexport function pendingRequest(status: { state: AgentState; request?: PermissionRequest } | null): PermissionRequest | null {\n return status?.state === 'needs_input' && status.request ? status.request : null;\n}\n\n/** Parse \"15m\", \"90s\", \"2h\", or a number of seconds. */\nexport function parseDuration(text: string): number | null {\n const m = /^\\s*(\\d+(?:\\.\\d+)?)\\s*(s|m|h)?\\s*$/i.exec(text);\n if (!m) return null;\n const n = Number(m[1]);\n const unit = (m[2] ?? 's').toLowerCase();\n return Math.round(n * (unit === 'h' ? 3_600_000 : unit === 'm' ? 60_000 : 1000));\n}\n"],"mappings":";;;;;;AAgBO,IAAM,iBAAiB;AAyBvB,SAAS,gBAAgB,GAA+C;AAC7E,SAAO,gCAAgC,EAAE,MAAM,IAAI,EAAE,MAAM;AAC7D;AAIA,eAAsB,cAAc,IAAY,MAAc,MAAgB,OAA6B,CAAC,GAAwB;AAClI,QAAM,OAAO,KAAK,KAAK;AACvB,MAAI,CAAC,KAAM,QAAO,EAAE,IAAI,OAAO,QAAQ,KAAK,OAAO,uBAAuB;AAC1E,MAAI,KAAK,SAAS,eAAgB,QAAO,EAAE,IAAI,OAAO,QAAQ,KAAK,OAAO,uBAAuB,cAAc,cAAc;AAC7H,QAAM,WAAW,KAAK,SAAS,EAAE;AACjC,MAAI,SAAU,QAAO,EAAE,IAAI,OAAO,QAAQ,KAAK,OAAO,gBAAgB,QAAQ,EAAE;AAEhF,QAAM,SAAS,KAAK,cAAc,EAAE;AACpC,MAAI,OAAQ,QAAO,EAAE,IAAI,OAAO,QAAQ,KAAK,OAAO,mBAAmB,MAAM,EAAE;AAC/E,QAAM,UAAU,KAAK,MAAM,KAAK,oBAAI,KAAK,GAAG,YAAY;AAExD,QAAM,YAAY,MAAM,KAAK,KAAK,IAAI,IAAI;AAC1C,MAAI,UAAW,QAAO,EAAE,IAAI,MAAM,KAAK,WAAW,OAAO;AACzD,MAAI,KAAK,SAAS,EAAE,EAAG,QAAO,EAAE,IAAI,MAAM,KAAK,aAAa,OAAO;AACnE,MAAI,KAAK,eAAe,EAAE,EAAG,QAAO,EAAE,IAAI,MAAM,KAAK,WAAW,OAAO;AACvE,MAAI,CAAE,MAAM,KAAK,MAAM,EAAE;AACvB,WAAO,EAAE,IAAI,OAAO,QAAQ,KAAK,OAAO,oFAAoF;AAC9H,SAAO,EAAE,IAAI,MAAM,KAAK,WAAW,OAAO;AAC5C;AAGO,SAAS,YAAY,KAAsB;AAChD,UAAQ,KAAK;AAAA,IACX,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,IACT,KAAK;AACH,aAAO;AAAA,EACX;AACF;AAuBA,eAAsB,YACpB,IACA,MACA,MACqB;AACrB,QAAM,WAAW,KAAK,IAAI,IAAI,KAAK;AACnC,QAAM,QAAQ,KAAK,QAAQ,KAAK,MAAM,KAAK,KAAK,IAAI;AACpD,aAAS;AACP,UAAM,IAAI,KAAK,OAAO,EAAE;AACxB,UAAM,QAAQ,UAAU,QAAS,CAAC,CAAC,KAAK,KAAK,MAAM,EAAE,KAAK,IAAI;AAC9D,QAAI,KAAK,EAAE,UAAU,aAAa,MAAO,QAAO,EAAE,IAAI,MAAM,QAAQ,EAAE;AACtE,QAAI,KAAK,IAAI,KAAK,SAAU,QAAO,EAAE,IAAI,OAAO,QAAQ,WAAW,QAAQ,EAAE;AAC7E,UAAM,KAAK,MAAM,KAAK,UAAU,GAAI;AAAA,EACtC;AACF;AAGO,SAAS,eAAe,QAA6F;AAC1H,SAAO,QAAQ,UAAU,iBAAiB,OAAO,UAAU,OAAO,UAAU;AAC9E;AAGO,SAAS,cAAc,MAA6B;AACzD,QAAM,IAAI,sCAAsC,KAAK,IAAI;AACzD,MAAI,CAAC,EAAG,QAAO;AACf,QAAM,IAAI,OAAO,EAAE,CAAC,CAAC;AACrB,QAAM,QAAQ,EAAE,CAAC,KAAK,KAAK,YAAY;AACvC,SAAO,KAAK,MAAM,KAAK,SAAS,MAAM,OAAY,SAAS,MAAM,MAAS,IAAK;AACjF;","names":[]}
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  VERSION
4
- } from "./chunk-TIRRXH6I.js";
4
+ } from "./chunk-VQ63WDRZ.js";
5
5
  import {
6
6
  resolveProjectTarget
7
7
  } from "./chunk-IPHADNF5.js";
@@ -193,15 +193,15 @@ var COMMANDS = [
193
193
  { names: ["usage"], load: async () => (await import("./usage-AB2UAMHM.js")).usageCommand },
194
194
  { names: ["read"], load: async () => (await import("./read-O72SGX7S.js")).readCommand },
195
195
  { names: ["screen"], load: async () => (await import("./screen-YX7C4PXH.js")).screenCommand },
196
- { names: ["send"], load: async () => (await import("./send-S3BBWJHD.js")).sendCommand },
197
- { names: ["wait"], load: async () => (await import("./wait-RULOZMLR.js")).waitCommand },
198
- { names: ["start"], load: async () => (await import("./start-JGVD2O5V.js")).startCommand },
196
+ { names: ["send"], load: async () => (await import("./send-4CKKTNQX.js")).sendCommand },
197
+ { names: ["wait"], load: async () => (await import("./wait-BVU2IHP3.js")).waitCommand },
198
+ { names: ["start"], load: async () => (await import("./start-E7KVWGW6.js")).startCommand },
199
199
  { names: ["stop"], load: async () => (await import("./stop-XXLTBUCF.js")).stopCommand },
200
200
  { names: ["restart"], load: async () => (await import("./restart-P352BMWT.js")).restartCommand },
201
- { names: ["answer"], load: async () => (await import("./answer-MWBEM7P7.js")).answerCommand },
201
+ { names: ["answer"], load: async () => (await import("./answer-HQVJNI26.js")).answerCommand },
202
202
  { names: ["coordinate"], load: async () => (await import("./coordinate-S3HTZFMP.js")).coordinateCommand },
203
- { names: ["child"], load: async () => (await import("./child-OAKEKASR.js")).childCommand },
204
- { names: ["report"], load: async () => (await import("./report-2NXU55QS.js")).reportCommand },
203
+ { names: ["child"], load: async () => (await import("./child-ZN7PG7DR.js")).childCommand },
204
+ { names: ["report"], load: async () => (await import("./report-3YX5PLOE.js")).reportCommand },
205
205
  { names: ["list"], load: async () => (await import("./list-5AVOAFXA.js")).listCommand },
206
206
  { names: ["status"], load: async () => (await import("./status-ZO54EQVF.js")).statusCommand },
207
207
  { names: ["recent"], load: async () => (await import("./recent-TI6O5KHP.js")).recentCommand },
@@ -219,12 +219,12 @@ var COMMANDS = [
219
219
  { names: ["todo"], load: async () => (await import("./todo-ZBFRL2A5.js")).todoCommand },
220
220
  { names: ["hydrate"], load: async () => (await import("./hydrate-F2BZ6K7Y.js")).hydrateCommand },
221
221
  { names: ["diff"], load: async () => (await import("./diff-63GBECFI.js")).diffCommand },
222
- { names: ["web"], load: async () => (await import("./web-4JKMKTTD.js")).webCommand },
222
+ { names: ["web"], load: async () => (await import("./web-B4C2O7GU.js")).webCommand },
223
223
  { names: ["hook"], load: async () => (await import("./hook-2Y4UOTZ6.js")).hookCommand },
224
224
  { names: ["run"], load: async () => (await import("./run-3CYZS4BM.js")).runCommand },
225
225
  { names: ["broadcast"], load: async () => (await import("./broadcast-BUJ5PWPB.js")).broadcastCommand },
226
226
  { names: ["attach", "a"], load: async () => (await import("./attach-OTWK6PD5.js")).attachCommand },
227
- { names: ["pty-host"], load: async () => (await import("./pty-host-4LWIAULG.js")).ptyHostCommand },
227
+ { names: ["pty-host"], load: async () => (await import("./pty-host-UWBE2OIL.js")).ptyHostCommand },
228
228
  { names: ["state"], load: async () => (await import("./state-GM22X3RN.js")).stateCommand },
229
229
  { names: ["move"], load: async () => (await import("./move-75DQHXBR.js")).moveCommand },
230
230
  { names: ["install-skills"], load: async () => (await import("./install-skills-KSLTHRHH.js")).installSkillsCommand },
@@ -328,4 +328,4 @@ export {
328
328
  commandsFor,
329
329
  run
330
330
  };
331
- //# sourceMappingURL=chunk-ZLIW4G24.js.map
331
+ //# sourceMappingURL=chunk-FGWGPTQC.js.map
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/version.ts
4
+ var VERSION = true ? "2.22.1" : "dev";
5
+
6
+ export {
7
+ VERSION
8
+ };
9
+ //# sourceMappingURL=chunk-VQ63WDRZ.js.map
@@ -3,8 +3,8 @@ import {
3
3
  COMMANDS,
4
4
  commandsFor,
5
5
  run
6
- } from "./chunk-ZLIW4G24.js";
7
- import "./chunk-TIRRXH6I.js";
6
+ } from "./chunk-FGWGPTQC.js";
7
+ import "./chunk-VQ63WDRZ.js";
8
8
  import "./chunk-IPHADNF5.js";
9
9
  import "./chunk-JYWX2N5W.js";
10
10
  import "./chunk-3ZPVKUYD.js";
@@ -17,4 +17,4 @@ export {
17
17
  commandsFor,
18
18
  run
19
19
  };
20
- //# sourceMappingURL=cli-KRTX5VN7.js.map
20
+ //# sourceMappingURL=cli-FK3WEKNF.js.map
@@ -58,7 +58,7 @@ import {
58
58
  } from "./chunk-YQSWVHKK.js";
59
59
  import {
60
60
  VERSION
61
- } from "./chunk-TIRRXH6I.js";
61
+ } from "./chunk-VQ63WDRZ.js";
62
62
  import "./chunk-Z6ACV5ZQ.js";
63
63
  import "./chunk-JUGF3YE7.js";
64
64
  import {
@@ -1232,4 +1232,4 @@ export {
1232
1232
  ptyHostCommand,
1233
1233
  stopHost
1234
1234
  };
1235
- //# sourceMappingURL=pty-host-4LWIAULG.js.map
1235
+ //# sourceMappingURL=pty-host-UWBE2OIL.js.map
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  sendHowText
4
- } from "./chunk-KWHHB737.js";
4
+ } from "./chunk-BRIYWWE3.js";
5
5
  import "./chunk-FZHFD2AY.js";
6
6
  import {
7
7
  parentOf,
@@ -71,4 +71,4 @@ var reportCommand = {
71
71
  export {
72
72
  reportCommand
73
73
  };
74
- //# sourceMappingURL=report-2NXU55QS.js.map
74
+ //# sourceMappingURL=report-3YX5PLOE.js.map
@@ -10,7 +10,7 @@ import {
10
10
  parseDuration,
11
11
  sendHowText,
12
12
  waitForTurn
13
- } from "./chunk-KWHHB737.js";
13
+ } from "./chunk-BRIYWWE3.js";
14
14
  import "./chunk-FZHFD2AY.js";
15
15
  import {
16
16
  sessionFromArgs,
@@ -98,4 +98,4 @@ var sendCommand = {
98
98
  export {
99
99
  sendCommand
100
100
  };
101
- //# sourceMappingURL=send-S3BBWJHD.js.map
101
+ //# sourceMappingURL=send-4CKKTNQX.js.map
@@ -38,7 +38,7 @@ import "./chunk-F2ECTTSY.js";
38
38
  import chalk from "chalk";
39
39
  var startCommand = {
40
40
  command: "start [target] [branch]",
41
- describe: "Start a session's agent in the background, resuming its conversation (default: the session for this folder)",
41
+ describe: "Start a session's agent in the background, resuming its conversation; an archived one is restored first (default: the session for this folder)",
42
42
  builder: (yargs) => sessionPositionals(yargs).option("force", {
43
43
  type: "boolean",
44
44
  default: false,
@@ -47,23 +47,32 @@ var startCommand = {
47
47
  handler: async (argv) => {
48
48
  const s = sessionFromArgs(argv);
49
49
  if (!s) return;
50
- const r = await callWorkWeb(
51
- "POST",
52
- `/api/sessions/${sessionIdFor(s)}/agent/start`,
53
- { force: argv.force === true },
54
- 6e4
55
- );
56
- if (!r.ok) {
57
- console.error(chalk.red(r.error));
50
+ const id = sessionIdFor(s);
51
+ const fail = (message) => {
52
+ console.error(chalk.red(message));
58
53
  process.exitCode = 1;
59
- return;
54
+ };
55
+ let restored = false;
56
+ if (s.archivedAt) {
57
+ console.log(chalk.gray(`${s.target} \xB7 ${s.branch} is archived: restoring it\u2026`));
58
+ const back = await callWorkWeb(
59
+ "POST",
60
+ `/api/sessions/${id}/archive`,
61
+ { archived: false },
62
+ 3e5
63
+ );
64
+ if (!back.ok) return fail(`Couldn't restore it: ${back.error}`);
65
+ for (const w of back.body.warnings ?? []) console.log(chalk.yellow(w));
66
+ restored = true;
60
67
  }
68
+ const r = await callWorkWeb("POST", `/api/sessions/${id}/agent/start`, { force: argv.force === true }, 6e4);
69
+ if (!r.ok) return fail(restored ? `Restored it, but couldn't start its agent: ${r.error}` : r.error);
61
70
  console.log(
62
- r.body.how === "running" ? `${s.target} \xB7 ${s.branch}: already running` : `${s.target} \xB7 ${s.branch}: started (\`work attach\` to watch it)`
71
+ r.body.how === "running" ? `${s.target} \xB7 ${s.branch}: already running` : `${s.target} \xB7 ${s.branch}: ${restored ? "restored and started" : "started"} (\`work attach\` to watch it)`
63
72
  );
64
73
  }
65
74
  };
66
75
  export {
67
76
  startCommand
68
77
  };
69
- //# sourceMappingURL=start-JGVD2O5V.js.map
78
+ //# sourceMappingURL=start-E7KVWGW6.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/commands/start.ts"],"sourcesContent":["import chalk from 'chalk';\nimport type { CommandModule } from 'yargs';\nimport { callWorkWeb } from '../core/platform/web-discovery.js';\nimport { sessionIdFor } from '../core/sessions/session-id.js';\nimport type { AgentControlWire } from '../core/api-types.js';\nimport { sessionFromArgs, sessionPositionals } from './shared/session-arg.js';\n\n/**\n * `work start` — start a session's agent in the PTY host, resuming its conversation (work web's POST …/agent/start).\n * An archived session is restored first (asked for: an agent told \"restore it first\" tried commands until `work tree`\n * worked): work web's Restore (POST …/archive {archived: false}) — the worktree, its uncommitted work and the\n * conversation as they were — then started, in the background as ever.\n */\nexport const startCommand: CommandModule = {\n command: 'start [target] [branch]',\n describe:\n \"Start a session's agent in the background, resuming its conversation; an archived one is restored first (default: the session for this folder)\",\n builder: (yargs) =>\n sessionPositionals(yargs).option('force', {\n type: 'boolean',\n default: false,\n describe: 'Start one even though it runs in a terminal outside work (two would share one conversation)',\n }),\n handler: async (argv) => {\n const s = sessionFromArgs(argv);\n if (!s) return;\n const id = sessionIdFor(s);\n const fail = (message: string) => {\n console.error(chalk.red(message));\n process.exitCode = 1;\n };\n let restored = false;\n if (s.archivedAt) {\n console.log(chalk.gray(`${s.target} · ${s.branch} is archived: restoring it…`));\n // Making its worktree again can take a while (a big repo, its setup).\n const back = await callWorkWeb<{ ok?: boolean; warnings?: string[] }>(\n 'POST',\n `/api/sessions/${id}/archive`,\n { archived: false },\n 300_000,\n );\n if (!back.ok) return fail(`Couldn't restore it: ${back.error}`);\n for (const w of back.body.warnings ?? []) console.log(chalk.yellow(w));\n restored = true;\n }\n const r = await callWorkWeb<AgentControlWire>('POST', `/api/sessions/${id}/agent/start`, { force: argv.force === true }, 60_000);\n if (!r.ok) return fail(restored ? `Restored it, but couldn't start its agent: ${r.error}` : r.error);\n console.log(\n r.body.how === 'running'\n ? `${s.target} · ${s.branch}: already running`\n : `${s.target} · ${s.branch}: ${restored ? 'restored and started' : 'started'} (\\`work attach\\` to watch it)`,\n );\n },\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,WAAW;AAaX,IAAM,eAA8B;AAAA,EACzC,SAAS;AAAA,EACT,UACE;AAAA,EACF,SAAS,CAAC,UACR,mBAAmB,KAAK,EAAE,OAAO,SAAS;AAAA,IACxC,MAAM;AAAA,IACN,SAAS;AAAA,IACT,UAAU;AAAA,EACZ,CAAC;AAAA,EACH,SAAS,OAAO,SAAS;AACvB,UAAM,IAAI,gBAAgB,IAAI;AAC9B,QAAI,CAAC,EAAG;AACR,UAAM,KAAK,aAAa,CAAC;AACzB,UAAM,OAAO,CAAC,YAAoB;AAChC,cAAQ,MAAM,MAAM,IAAI,OAAO,CAAC;AAChC,cAAQ,WAAW;AAAA,IACrB;AACA,QAAI,WAAW;AACf,QAAI,EAAE,YAAY;AAChB,cAAQ,IAAI,MAAM,KAAK,GAAG,EAAE,MAAM,SAAM,EAAE,MAAM,kCAA6B,CAAC;AAE9E,YAAM,OAAO,MAAM;AAAA,QACjB;AAAA,QACA,iBAAiB,EAAE;AAAA,QACnB,EAAE,UAAU,MAAM;AAAA,QAClB;AAAA,MACF;AACA,UAAI,CAAC,KAAK,GAAI,QAAO,KAAK,wBAAwB,KAAK,KAAK,EAAE;AAC9D,iBAAW,KAAK,KAAK,KAAK,YAAY,CAAC,EAAG,SAAQ,IAAI,MAAM,OAAO,CAAC,CAAC;AACrE,iBAAW;AAAA,IACb;AACA,UAAM,IAAI,MAAM,YAA8B,QAAQ,iBAAiB,EAAE,gBAAgB,EAAE,OAAO,KAAK,UAAU,KAAK,GAAG,GAAM;AAC/H,QAAI,CAAC,EAAE,GAAI,QAAO,KAAK,WAAW,8CAA8C,EAAE,KAAK,KAAK,EAAE,KAAK;AACnG,YAAQ;AAAA,MACN,EAAE,KAAK,QAAQ,YACX,GAAG,EAAE,MAAM,SAAM,EAAE,MAAM,sBACzB,GAAG,EAAE,MAAM,SAAM,EAAE,MAAM,KAAK,WAAW,yBAAyB,SAAS;AAAA,IACjF;AAAA,EACF;AACF;","names":[]}
@@ -5,7 +5,7 @@ import {
5
5
  import {
6
6
  parseDuration,
7
7
  waitForTurn
8
- } from "./chunk-KWHHB737.js";
8
+ } from "./chunk-BRIYWWE3.js";
9
9
  import "./chunk-FZHFD2AY.js";
10
10
  import {
11
11
  sessionFromArgs,
@@ -68,4 +68,4 @@ var waitCommand = {
68
68
  export {
69
69
  waitCommand
70
70
  };
71
- //# sourceMappingURL=wait-RULOZMLR.js.map
71
+ //# sourceMappingURL=wait-BVU2IHP3.js.map
package/dist/wd-bin.js CHANGED
@@ -1,11 +1,11 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  run
4
- } from "./chunk-ZLIW4G24.js";
4
+ } from "./chunk-FGWGPTQC.js";
5
5
  import {
6
6
  consoleReporter
7
7
  } from "./chunk-S5HJT7CM.js";
8
- import "./chunk-TIRRXH6I.js";
8
+ import "./chunk-VQ63WDRZ.js";
9
9
  import "./chunk-IPHADNF5.js";
10
10
  import "./chunk-JYWX2N5W.js";
11
11
  import "./chunk-3ZPVKUYD.js";