@krapht/ork 1.0.0-alpha.2 → 1.0.0-alpha.20

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 (71) hide show
  1. package/README.md +12 -7
  2. package/dist/__build_info__-D6mXC4cD.mjs +228 -0
  3. package/dist/apply-Mb0fNpCX.mjs +17 -0
  4. package/dist/argument-error-CihH46Le.mjs +27 -0
  5. package/dist/attach-C1OnxyMh.mjs +92 -0
  6. package/dist/attach-CEGbRg1D.mjs +1230 -0
  7. package/dist/bin.mjs +1312 -2390
  8. package/dist/brief-DH66xmj8.mjs +115 -0
  9. package/dist/{decide-CGyx9rv7.mjs → builtin-files-Cf-NZDqM.mjs} +3 -51
  10. package/dist/chips-BqcT58qr.mjs +43 -0
  11. package/dist/command-tree-CEkzWNy6.mjs +63 -0
  12. package/dist/{completion-CSU5vkEt.mjs → completion-DS0gCZRm.mjs} +200 -30
  13. package/dist/context-CGPh12HV.mjs +106 -0
  14. package/dist/detached-Dakw5RZj.mjs +38 -0
  15. package/dist/extra-arguments-BxQMXARO.mjs +13 -0
  16. package/dist/{find-D6Gj1sxg.mjs → find-BTikxc54.mjs} +2 -2
  17. package/dist/flags-C8yCq0j5.mjs +145 -0
  18. package/dist/follow-ups-CtlhHbwe.mjs +563 -0
  19. package/dist/format-BB4E-T6x.mjs +249 -0
  20. package/dist/{help-groups-BwYoAWsh.mjs → help-groups-BpRgBSTh.mjs} +42 -76
  21. package/dist/in-a-run-CbnKjO7t.mjs +27 -0
  22. package/dist/install-CWcpX5g4.mjs +211 -0
  23. package/dist/{limits-B1-DYc3d.mjs → limits-VQqsBoQk.mjs} +2 -2
  24. package/dist/{mcp-DE_EmyVm.mjs → mcp-wGfkMCVF.mjs} +6 -6
  25. package/dist/once-BHxSdZz_.mjs +112 -0
  26. package/dist/orphan-guard-BFKg8VSd.mjs +58 -0
  27. package/dist/output-B1kwo0YU.mjs +439 -0
  28. package/dist/outputs-text-CNTJ7Qq_.mjs +19 -0
  29. package/dist/{pause-CL6N_Xrj.mjs → pause-C_Wxh-KM.mjs} +7 -4
  30. package/dist/print-DNYzq4Rr.mjs +19 -0
  31. package/dist/project-records-XY3ku95x.mjs +233 -0
  32. package/dist/refusals-DQQX3AIb.mjs +116 -0
  33. package/dist/{relay-0SD0erwf.mjs → relay-BA6tsnpc.mjs} +2 -2
  34. package/dist/run-Bvvg-fiF.mjs +234 -0
  35. package/dist/run-DBUAq-Uu.mjs +1452 -0
  36. package/dist/send-nrKtak5F.mjs +105 -0
  37. package/dist/{src-Dujmvv4s.mjs → src-8cOPOgrT.mjs} +12523 -5507
  38. package/dist/{src-BbyEoMn4.mjs → src-CmEvHdju.mjs} +797 -233
  39. package/dist/src-D4JSymhK.mjs +3104 -0
  40. package/dist/{src-DOcK8Jfp.mjs → src-I_RyKu6_.mjs} +1022 -590
  41. package/dist/store-CDpk8Wtz.mjs +16 -0
  42. package/dist/ui/THIRD_PARTY_LICENSES.txt +612 -0
  43. package/dist/ui/assets/app--FijEXiJ.css +1 -0
  44. package/dist/ui/assets/app-BowhjEAe.js +112 -0
  45. package/dist/ui/assets/{index-9dFha9Qn.js → index-CrMa2oHB.js} +3 -3
  46. package/dist/ui/assets/theme-CdXvqTQ6.js +1 -0
  47. package/dist/ui/index.html +2 -2
  48. package/dist/{ui-CTmO2Xzu.mjs → ui-DY3Dnpho.mjs} +54 -25
  49. package/dist/usage-1VwSg_Qt.mjs +257 -0
  50. package/dist/validate-BxayjjkV.mjs +632 -0
  51. package/dist/verdict-CMvPCpWC.mjs +84 -0
  52. package/dist/{watch-CtbgDAcz.mjs → watch-CT0EtLPZ.mjs} +45 -17
  53. package/dist/{workflows-D1_WVukk.mjs → workflows-DHHi-APg.mjs} +30 -5
  54. package/dist/worktrees-CZvbHzbN.mjs +302 -0
  55. package/package.json +10 -8
  56. package/dist/__build_info__-fy6L1Mrd.mjs +0 -615
  57. package/dist/clean-DaHjs__2.mjs +0 -88
  58. package/dist/context-DT8MfEIR.mjs +0 -274
  59. package/dist/format-Dnfv8zMT.mjs +0 -427
  60. package/dist/in-a-run-pLAZeNys.mjs +0 -22
  61. package/dist/list-BrH8KRSJ.mjs +0 -110
  62. package/dist/output-BLQWD6MJ.mjs +0 -950
  63. package/dist/remove-BeGdqroy.mjs +0 -194
  64. package/dist/report-DK4LGqwF.mjs +0 -129
  65. package/dist/send-C8tunWhv.mjs +0 -163
  66. package/dist/src-CCUKRX51.mjs +0 -1204
  67. package/dist/ui/assets/app-BNT0SuIz.css +0 -1
  68. package/dist/ui/assets/app-T7wVAhgx.js +0 -67
  69. package/dist/ui/assets/theme-3xH5jxKs.js +0 -1
  70. package/dist/usage-DYUmP0i4.mjs +0 -419
  71. package/dist/worktrees-DdMYoNOC.mjs +0 -212
@@ -0,0 +1,105 @@
1
+ import { R as openStore, et as TOO_LONG, nt as sendFromScript, tt as scriptRefusal } from "./src-8cOPOgrT.mjs";
2
+ import { u as inheritedScrubber } from "./src-I_RyKu6_.mjs";
3
+ import { l as writeErr } from "./output-B1kwo0YU.mjs";
4
+ import { defineCommand } from "citty";
5
+ // src/commands/send.ts
6
+ /**
7
+ * @file `ork send` (RFC-005): a program in a tool node writes to a session on
8
+ * its run's bus. It prints nothing when it works, as what a program prints is
9
+ * its node's output, and says why on stderr, with exit 1, when it is refused:
10
+ * before reading a message it could not send, and for anything wrong with the
11
+ * command itself, which would otherwise go to stdout as usage.
12
+ */
13
+ const refuse = (message) => {
14
+ writeErr(message);
15
+ process.exitCode = 1;
16
+ };
17
+ /** Stdin, up to the limit: past it, the rest is not worth holding. */
18
+ const readBounded = async () => {
19
+ const chunks = [];
20
+ let size = 0;
21
+ for await (const chunk of process.stdin) {
22
+ const part = Buffer.isBuffer(chunk) ? chunk : Buffer.from(String(chunk));
23
+ size += part.length;
24
+ if (size > 65536) return null;
25
+ chunks.push(part);
26
+ }
27
+ return Buffer.concat(chunks);
28
+ };
29
+ /** The message, or why it can't go. */
30
+ const bodyOf = async (given) => {
31
+ if (given !== void 0) return { body: given };
32
+ const read = await readBounded();
33
+ if (read === null) return { refused: TOO_LONG };
34
+ try {
35
+ return { body: new TextDecoder("utf-8", { fatal: true }).decode(read) };
36
+ } catch {
37
+ return { refused: "The message is not UTF-8 text." };
38
+ }
39
+ };
40
+ const deliver = async (store, to, given) => {
41
+ const sender = {
42
+ run: process.env["ORK_RUN"],
43
+ node: process.env["ORK_NODE"],
44
+ to
45
+ };
46
+ const refused = scriptRefusal(store, sender);
47
+ if (refused !== null) {
48
+ refuse(refused);
49
+ return;
50
+ }
51
+ const message = await bodyOf(given);
52
+ if ("refused" in message) {
53
+ refuse(message.refused);
54
+ return;
55
+ }
56
+ if (message.body.replaceAll(/[\p{Cc}\s]/gu, "") === "") {
57
+ refuse("The message is empty.");
58
+ return;
59
+ }
60
+ const sent = await sendFromScript(store, {
61
+ ...sender,
62
+ body: inheritedScrubber(process.env)(message.body)
63
+ });
64
+ if (!sent.ok) refuse(sent.error);
65
+ };
66
+ const send = defineCommand({
67
+ meta: {
68
+ name: "send",
69
+ description: "From a tool node's program: write to a session in its run"
70
+ },
71
+ args: {
72
+ to: {
73
+ type: "positional",
74
+ description: "The node to write to: the owner, or a channel",
75
+ required: false
76
+ },
77
+ message: {
78
+ type: "string",
79
+ alias: "m",
80
+ description: "The message"
81
+ },
82
+ stdin: {
83
+ type: "boolean",
84
+ description: "Read the message from stdin",
85
+ default: false
86
+ }
87
+ },
88
+ run: async ({ args }) => {
89
+ if (args.to === void 0 || args._.length !== 1) {
90
+ refuse("Give one node to write to: ork send <to> -m <body>.");
91
+ return;
92
+ }
93
+ if (args.message === void 0 === !args.stdin) {
94
+ refuse("Give the message with -m or --stdin, one of them.");
95
+ return;
96
+ }
97
+ const store = openStore();
98
+ try {
99
+ await deliver(store, args.to, args.message);
100
+ } finally {
101
+ store.close();
102
+ }
103
+ }
104
+ });
105
+ export { send };