@paradow/ledge 0.11.0 → 0.12.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.
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  pickName
3
- } from "./chunk-JOCNCNRP.js";
3
+ } from "./chunk-VY45MACP.js";
4
4
  import {
5
5
  paths
6
6
  } from "./chunk-FGOFRWIB.js";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  run
3
- } from "./chunk-YV7BMEEB.js";
3
+ } from "./chunk-ZEHTNFPV.js";
4
4
  import {
5
5
  ensureLedgeDir,
6
6
  paths
@@ -1,11 +1,18 @@
1
1
  import {
2
+ MESSAGE_MAX,
2
3
  PROTOCOL_PORT,
4
+ SUMMARY_MAX,
3
5
  parseServerMessage,
4
6
  readDaemonToken
5
- } from "./chunk-JOCNCNRP.js";
7
+ } from "./chunk-VY45MACP.js";
6
8
 
7
9
  // src/client.ts
8
10
  import WebSocket from "ws";
11
+ async function sendMessageAndAwaitAck(client, msg, timeoutMs) {
12
+ if (msg.text.length > MESSAGE_MAX) return { type: "message.ack", rid: msg.rid, outcome: "refused", reason: `message trop long (${msg.text.length} caract\xE8res, ${MESSAGE_MAX} au plus)` };
13
+ client.send(msg.summary && msg.summary.length > SUMMARY_MAX ? { ...msg, summary: msg.summary.slice(0, SUMMARY_MAX) } : msg);
14
+ return client.next("message.ack", timeoutMs);
15
+ }
9
16
  var DaemonRefusedError = class extends Error {
10
17
  };
11
18
  function connect(opts = {}) {
@@ -82,6 +89,7 @@ function connect(opts = {}) {
82
89
  }
83
90
 
84
91
  export {
92
+ sendMessageAndAwaitAck,
85
93
  DaemonRefusedError,
86
94
  connect
87
95
  };
@@ -81,8 +81,8 @@ function realTmux(socket = "ledge", opts = {}) {
81
81
  async killSession(name) {
82
82
  await t(["kill-session", "-t", `=${name}`]);
83
83
  },
84
- attachArgs(name) {
85
- return [...base(), "attach-session", "-t", `=${name}`];
84
+ attachArgs(name, opts2) {
85
+ return [...base(), "attach-session", ...opts2?.readOnly ? ["-r"] : [], "-t", `=${name}`];
86
86
  }
87
87
  };
88
88
  }
@@ -1,20 +1,20 @@
1
+ import {
2
+ DaemonRefusedError,
3
+ connect
4
+ } from "./chunk-XXFUYME7.js";
1
5
  import {
2
6
  exitFile,
3
7
  spawnSession
4
- } from "./chunk-TSA5LD4D.js";
8
+ } from "./chunk-X34LPKG7.js";
9
+ import {
10
+ PROTOCOL_PORT
11
+ } from "./chunk-VY45MACP.js";
5
12
  import {
6
13
  realTmux
7
- } from "./chunk-YV7BMEEB.js";
14
+ } from "./chunk-ZEHTNFPV.js";
8
15
  import {
9
16
  log
10
17
  } from "./chunk-YUSY3E47.js";
11
- import {
12
- DaemonRefusedError,
13
- connect
14
- } from "./chunk-TC3XJUJA.js";
15
- import {
16
- PROTOCOL_PORT
17
- } from "./chunk-JOCNCNRP.js";
18
18
  import {
19
19
  ensureLedgeDir
20
20
  } from "./chunk-FGOFRWIB.js";