@deadair/plugin-sdk 0.77.6 → 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 +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +108 -0
- package/dist/index.js.map +1 -1
- package/dist/match.text.d.ts +10 -0
- package/dist/match.text.d.ts.map +1 -1
- package/dist/message.inbox.d.ts +36 -0
- package/dist/message.inbox.d.ts.map +1 -0
- package/dist/plugin.config.fields.d.ts +24 -1
- package/dist/plugin.config.fields.d.ts.map +1 -1
- package/dist/plugin.error.d.ts +10 -0
- package/dist/plugin.error.d.ts.map +1 -1
- package/dist/plugin.logger.d.ts +20 -0
- package/dist/plugin.logger.d.ts.map +1 -0
- package/package.json +1 -1
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
|
package/dist/index.d.ts.map
CHANGED
|
@@ -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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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,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC;AACjC,cAAc,2BAA2B,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) {
|
|
@@ -995,6 +1001,73 @@ function baseForm(value) {
|
|
|
995
1001
|
return normalize(value.replace(PARENTHETICAL, " ").split(/\s+[-–—]\s+/)[0] ?? value);
|
|
996
1002
|
}
|
|
997
1003
|
__name(baseForm, "baseForm");
|
|
1004
|
+
function textAgreement(candidate, reference) {
|
|
1005
|
+
if (!candidate) return "none";
|
|
1006
|
+
if (normalize(candidate) === normalize(reference)) return "exact";
|
|
1007
|
+
if (baseForm(candidate) === baseForm(reference)) return "base";
|
|
1008
|
+
return "none";
|
|
1009
|
+
}
|
|
1010
|
+
__name(textAgreement, "textAgreement");
|
|
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
|
+
};
|
|
998
1071
|
|
|
999
1072
|
// src/plausible.audio.ts
|
|
1000
1073
|
var MIN_PLAUSIBLE_AUDIO_BYTES = 256;
|
|
@@ -1142,6 +1215,19 @@ function parseRows(raw) {
|
|
|
1142
1215
|
}
|
|
1143
1216
|
}
|
|
1144
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");
|
|
1145
1231
|
function sentToProblems(fields) {
|
|
1146
1232
|
const isAddress = /* @__PURE__ */ __name((type) => type === "url" || type === "string", "isAddress");
|
|
1147
1233
|
const problems = [];
|
|
@@ -1328,6 +1414,22 @@ async function tryJsonBody(response) {
|
|
|
1328
1414
|
}
|
|
1329
1415
|
__name(tryJsonBody, "tryJsonBody");
|
|
1330
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
|
+
|
|
1331
1433
|
// src/plugin.manifest.ts
|
|
1332
1434
|
import { z as z3 } from "zod";
|
|
1333
1435
|
|
|
@@ -1467,6 +1569,7 @@ export {
|
|
|
1467
1569
|
KNOWN_ENRICHMENT_MATCH_KEYS,
|
|
1468
1570
|
KNOWN_PLUGIN_CAPABILITIES,
|
|
1469
1571
|
MIN_PLAUSIBLE_AUDIO_BYTES,
|
|
1572
|
+
MessageInbox,
|
|
1470
1573
|
PLUGIN_API_VERSION,
|
|
1471
1574
|
PLUGIN_CAPABILITY_ALMANAC,
|
|
1472
1575
|
PLUGIN_CAPABILITY_ANALYSIS,
|
|
@@ -1531,6 +1634,7 @@ export {
|
|
|
1531
1634
|
jsonBody,
|
|
1532
1635
|
networkPermissionSchema,
|
|
1533
1636
|
normalize,
|
|
1637
|
+
numberCell,
|
|
1534
1638
|
parseFeed,
|
|
1535
1639
|
parseMultiSelect,
|
|
1536
1640
|
parseRows,
|
|
@@ -1543,9 +1647,12 @@ export {
|
|
|
1543
1647
|
readRowSecret,
|
|
1544
1648
|
retryAfterMs,
|
|
1545
1649
|
rowSecretKey,
|
|
1650
|
+
rowsHaveColumns,
|
|
1651
|
+
scrubSecrets,
|
|
1546
1652
|
sentToProblems,
|
|
1547
1653
|
sentencesOf,
|
|
1548
1654
|
sentencesWithin,
|
|
1655
|
+
textAgreement,
|
|
1549
1656
|
toPluginError,
|
|
1550
1657
|
truncateSentences,
|
|
1551
1658
|
truncateUpstreamMessage,
|
|
@@ -1553,6 +1660,7 @@ export {
|
|
|
1553
1660
|
tryJsonBody,
|
|
1554
1661
|
upstreamDetail,
|
|
1555
1662
|
upstreamField,
|
|
1663
|
+
variadicLogger,
|
|
1556
1664
|
withoutCues
|
|
1557
1665
|
};
|
|
1558
1666
|
//# sourceMappingURL=index.js.map
|