@deadair/plugin-sdk 0.77.7 → 0.77.8

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.
package/dist/index.d.ts CHANGED
@@ -23,6 +23,7 @@ export * from './define.plugin.js';
23
23
  export * from './feed.parse.js';
24
24
  export * from './html.text.js';
25
25
  export * from './match.text.js';
26
+ export * from './message.inbox.js';
26
27
  export * from './plausible.audio.js';
27
28
  export * from './plugin.api.version.js';
28
29
  export * from './plugin.base.js';
@@ -33,6 +34,7 @@ export * from './plugin.host.js';
33
34
  export * from './plugin.host.response.js';
34
35
  export * from './plugin.http.js';
35
36
  export * from './plugin.lifecycle.js';
37
+ export * from './plugin.logger.js';
36
38
  export * from './plugin.manifest.js';
37
39
  export * from './plugin.permissions.js';
38
40
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,yBAAyB,CAAC;AACxC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AACtC,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,yBAAyB,CAAC;AACxC,cAAc,kCAAkC,CAAC;AACjD,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC;AACvC,cAAc,0BAA0B,CAAC;AACzC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,4BAA4B,CAAC;AAC3C,cAAc,0BAA0B,CAAC;AACzC,cAAc,8BAA8B,CAAC;AAC7C,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,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A2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,kBAAkB,CAAC;AACjC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC"}
package/dist/index.js CHANGED
@@ -308,6 +308,12 @@ function toPluginError(error, fallback = "internal") {
308
308
  }
309
309
  __name(toPluginError, "toPluginError");
310
310
  var errorText = /* @__PURE__ */ __name((error) => error instanceof Error ? error.message : String(error), "errorText");
311
+ function scrubSecrets(text2, secrets) {
312
+ let scrubbed = text2;
313
+ for (const secret of secrets) if (secret !== "") scrubbed = scrubbed.split(secret).join("<token>");
314
+ return scrubbed;
315
+ }
316
+ __name(scrubSecrets, "scrubSecrets");
311
317
 
312
318
  // src/capabilities/llm.ts
313
319
  async function collectGeneration(handle, signal) {
@@ -1003,6 +1009,66 @@ function textAgreement(candidate, reference) {
1003
1009
  }
1004
1010
  __name(textAgreement, "textAgreement");
1005
1011
 
1012
+ // src/message.inbox.ts
1013
+ var MessageInbox = class {
1014
+ static {
1015
+ __name(this, "MessageInbox");
1016
+ }
1017
+ max;
1018
+ held = [];
1019
+ wake;
1020
+ overflowed = false;
1021
+ /** @param max - How many messages are held at once. */
1022
+ constructor(max) {
1023
+ this.max = max;
1024
+ }
1025
+ /**
1026
+ * Queue one message, dropping the oldest past the bound, and wake a `take` that is waiting.
1027
+ *
1028
+ * Answers `true` the FIRST time a message is dropped and never again, so the caller can say so
1029
+ * once in its log rather than once per message in a flood.
1030
+ */
1031
+ deliver(message) {
1032
+ this.held.push(message);
1033
+ let firstDrop = false;
1034
+ if (this.held.length > this.max) {
1035
+ this.held.shift();
1036
+ firstDrop = !this.overflowed;
1037
+ this.overflowed = true;
1038
+ }
1039
+ this.wake?.();
1040
+ return firstDrop;
1041
+ }
1042
+ /**
1043
+ * Everything held, emptying the inbox. When nothing is held it first waits up to `waitMs` for a
1044
+ * message, an {@link interrupt} or a {@link close}, whichever comes first.
1045
+ */
1046
+ async take(waitMs) {
1047
+ if (this.held.length === 0 && waitMs > 0) await this.waitForMessages(waitMs);
1048
+ return this.held.splice(0);
1049
+ }
1050
+ /** Wake a waiting `take` without delivering anything, for a socket that has stopped for good. */
1051
+ interrupt() {
1052
+ this.wake?.();
1053
+ }
1054
+ /** Wake a waiting `take` and drop everything held, for a plugin being disposed. */
1055
+ close() {
1056
+ this.wake?.();
1057
+ this.held.length = 0;
1058
+ }
1059
+ waitForMessages(waitMs) {
1060
+ return new Promise((resolve) => {
1061
+ const done = /* @__PURE__ */ __name(() => {
1062
+ clearTimeout(timer);
1063
+ if (this.wake === done) this.wake = void 0;
1064
+ resolve();
1065
+ }, "done");
1066
+ const timer = setTimeout(done, waitMs);
1067
+ this.wake = done;
1068
+ });
1069
+ }
1070
+ };
1071
+
1006
1072
  // src/plausible.audio.ts
1007
1073
  var MIN_PLAUSIBLE_AUDIO_BYTES = 256;
1008
1074
  function plausibleAudio({ engine, asked, advice }) {
@@ -1149,6 +1215,19 @@ function parseRows(raw) {
1149
1215
  }
1150
1216
  }
1151
1217
  __name(parseRows, "parseRows");
1218
+ function rowsHaveColumns(raw, columns) {
1219
+ if (raw === void 0) return true;
1220
+ return parseRows(raw).every((row) => columns.every((column) => Boolean(row[column]?.trim())));
1221
+ }
1222
+ __name(rowsHaveColumns, "rowsHaveColumns");
1223
+ function numberCell(raw, options = {}) {
1224
+ if (raw === void 0 || raw.trim().length === 0) return void 0;
1225
+ const parsed = Number(raw);
1226
+ if (!Number.isFinite(parsed)) return void 0;
1227
+ if (options.positive === true && parsed <= 0) return void 0;
1228
+ return options.range === void 0 ? parsed : Math.min(options.range.max, Math.max(options.range.min, parsed));
1229
+ }
1230
+ __name(numberCell, "numberCell");
1152
1231
  function sentToProblems(fields) {
1153
1232
  const isAddress = /* @__PURE__ */ __name((type) => type === "url" || type === "string", "isAddress");
1154
1233
  const problems = [];
@@ -1335,6 +1414,22 @@ async function tryJsonBody(response) {
1335
1414
  }
1336
1415
  __name(tryJsonBody, "tryJsonBody");
1337
1416
 
1417
+ // src/plugin.logger.ts
1418
+ function variadicLogger(logger) {
1419
+ const meta = /* @__PURE__ */ __name((rest) => {
1420
+ const first = rest[0];
1421
+ return first !== null && typeof first === "object" && !Array.isArray(first) ? first : void 0;
1422
+ }, "meta");
1423
+ return {
1424
+ error: /* @__PURE__ */ __name((message, ...rest) => logger.error(String(message), meta(rest)), "error"),
1425
+ warn: /* @__PURE__ */ __name((message, ...rest) => logger.warn(String(message), meta(rest)), "warn"),
1426
+ info: /* @__PURE__ */ __name((message, ...rest) => logger.info(String(message), meta(rest)), "info"),
1427
+ debug: /* @__PURE__ */ __name((message, ...rest) => logger.debug(String(message), meta(rest)), "debug"),
1428
+ trace: /* @__PURE__ */ __name((message, ...rest) => logger.debug(String(message), meta(rest)), "trace")
1429
+ };
1430
+ }
1431
+ __name(variadicLogger, "variadicLogger");
1432
+
1338
1433
  // src/plugin.manifest.ts
1339
1434
  import { z as z3 } from "zod";
1340
1435
 
@@ -1474,6 +1569,7 @@ export {
1474
1569
  KNOWN_ENRICHMENT_MATCH_KEYS,
1475
1570
  KNOWN_PLUGIN_CAPABILITIES,
1476
1571
  MIN_PLAUSIBLE_AUDIO_BYTES,
1572
+ MessageInbox,
1477
1573
  PLUGIN_API_VERSION,
1478
1574
  PLUGIN_CAPABILITY_ALMANAC,
1479
1575
  PLUGIN_CAPABILITY_ANALYSIS,
@@ -1538,6 +1634,7 @@ export {
1538
1634
  jsonBody,
1539
1635
  networkPermissionSchema,
1540
1636
  normalize,
1637
+ numberCell,
1541
1638
  parseFeed,
1542
1639
  parseMultiSelect,
1543
1640
  parseRows,
@@ -1550,6 +1647,8 @@ export {
1550
1647
  readRowSecret,
1551
1648
  retryAfterMs,
1552
1649
  rowSecretKey,
1650
+ rowsHaveColumns,
1651
+ scrubSecrets,
1553
1652
  sentToProblems,
1554
1653
  sentencesOf,
1555
1654
  sentencesWithin,
@@ -1561,6 +1660,7 @@ export {
1561
1660
  tryJsonBody,
1562
1661
  upstreamDetail,
1563
1662
  upstreamField,
1663
+ variadicLogger,
1564
1664
  withoutCues
1565
1665
  };
1566
1666
  //# sourceMappingURL=index.js.map