@tidegap/core 0.25.0 → 0.27.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.
@@ -13,7 +13,12 @@ export declare const NTFY_DEFAULT_SERVER = "https://ntfy.sh";
13
13
  export declare const NTFY_MAX_BODY_BYTES = 4000;
14
14
  /** The header value of `text`: as is when printable ASCII, else an RFC 2047 base64 encoded word. */
15
15
  export declare function headerText(text: string): string;
16
- /** At most `max` UTF-8 bytes, cut on a character boundary, with an ellipsis when cut. */
16
+ /**
17
+ * At most `max` UTF-8 bytes, with an ellipsis when cut (empty when even the
18
+ * ellipsis does not fit). The cut falls between grapheme clusters
19
+ * ({@link headWithin}): a cluster that would cross the cap is left out whole,
20
+ * and a first cluster longer than the cap is cut between code points.
21
+ */
17
22
  export declare function clipBytes(text: string, max: number): string;
18
23
  /**
19
24
  * The publish URL: the server (any path prefix kept, any query or fragment
@@ -6,6 +6,7 @@
6
6
  * ntfy decodes. The optional access token is a Bearer header; it belongs to
7
7
  * its server (`keepWith`), so a new server never gets the old token.
8
8
  */
9
+ import { headWithin } from "../notice.js";
9
10
  import { optString } from "./shared.js";
10
11
  export const NTFY_DEFAULT_SERVER = "https://ntfy.sh";
11
12
  /** ntfy turns a longer body into an attachment; stay under its 4,096-byte message limit. */
@@ -29,19 +30,28 @@ export function headerText(text) {
29
30
  return `=?UTF-8?B?${Buffer.from(text, "utf8").toString("base64")}?=`;
30
31
  }
31
32
  const ELLIPSIS_BYTES = Buffer.byteLength("…", "utf8");
32
- /** At most `max` UTF-8 bytes, cut on a character boundary, with an ellipsis when cut. */
33
+ /**
34
+ * At most `max` UTF-8 bytes, with an ellipsis when cut (empty when even the
35
+ * ellipsis does not fit). The cut falls between grapheme clusters
36
+ * ({@link headWithin}): a cluster that would cross the cap is left out whole,
37
+ * and a first cluster longer than the cap is cut between code points.
38
+ */
33
39
  export function clipBytes(text, max) {
34
40
  if (Buffer.byteLength(text, "utf8") <= max)
35
41
  return text;
36
- let out = "";
42
+ if (max < ELLIPSIS_BYTES)
43
+ return "";
44
+ // The most code points whose bytes fit before the ellipsis. Every head of at most that many code points fits too,
45
+ // so the longest one that ends between clusters is the cut.
46
+ let fit = 0;
37
47
  let size = ELLIPSIS_BYTES;
38
48
  for (const ch of text) {
39
49
  size += Buffer.byteLength(ch, "utf8");
40
50
  if (size > max)
41
51
  break;
42
- out += ch;
52
+ fit++;
43
53
  }
44
- return `${out}…`;
54
+ return `${headWithin(text, fit)}…`;
45
55
  }
46
56
  /**
47
57
  * The publish URL: the server (any path prefix kept, any query or fragment
@@ -323,7 +323,7 @@ export const TOOL_SURFACE = [
323
323
  kind: "boolean",
324
324
  optional: true,
325
325
  hosts: ["mcp"],
326
- description: "true wakes this Claude Code session when the task finishes, if it sits idle, within 12 hours after its last turn ended: the session starts a turn by itself with the notice. A wake spends a model turn while nobody may be watching, so set it only when the user wants the result acted on at once. Rejected outside a Claude Code session, and when this server's ledger is not the default ~/.tidegap/queue.db (TIDEGAP_DB_PATH set elsewhere): the plugin's hooks read only that one. Omit (default false) to get the notice with the next prompt. With a job repeat, true binds the job to this session and wakes it on a run that failed for good (after its retries); only those runs and the job's end reach the session.",
326
+ description: "true wakes this Claude Code session when the task finishes, if it sits idle, while the session runs (up to 23 days after its last turn): the session starts a turn by itself with the notice; otherwise the notice comes with the next prompt. A wake spends a model turn while nobody may be watching, so set it only when the user wants the result acted on at once. Rejected outside a Claude Code session, and when this server's ledger is not the default ~/.tidegap/queue.db (TIDEGAP_DB_PATH set elsewhere): the plugin's hooks read only that one. Omit (default false) to get the notice with the next prompt. With a job repeat, true binds the job to this session and wakes it on a run that failed for good (after its retries); only those runs and the job's end reach the session.",
327
327
  },
328
328
  {
329
329
  name: "wake_match",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tidegap/core",
3
- "version": "0.25.0",
3
+ "version": "0.27.0",
4
4
  "description": "Carbon-aware scheduling for agentic AI workflows — core TypeScript library.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Vitalii Borovyk",