@anybio/govern 0.2.2 → 0.3.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.
- package/CHANGELOG.md +41 -0
- package/README.md +115 -30
- package/dist/adapters-DBLr_Frn.d.cts +39 -0
- package/dist/adapters-DBLr_Frn.d.ts +39 -0
- package/dist/chunk-3JV2R5IW.js +64 -0
- package/dist/chunk-CPNPQMEU.js +1860 -0
- package/dist/chunk-I5XIXB5M.cjs +1910 -0
- package/dist/chunk-XZHZBIZA.cjs +72 -0
- package/dist/cli.js +465 -115
- package/dist/{client-CU46a__g.d.cts → client-BeyMec7E.d.cts} +870 -152
- package/dist/{client-CU46a__g.d.ts → client-BeyMec7E.d.ts} +870 -152
- package/dist/index.cjs +165 -1536
- package/dist/index.d.cts +49 -7
- package/dist/index.d.ts +49 -7
- package/dist/index.js +1 -1503
- package/dist/langchain.cjs +65 -1501
- package/dist/langchain.d.cts +154 -17
- package/dist/langchain.d.ts +154 -17
- package/dist/langchain.js +59 -1495
- package/dist/vercel-ai.cjs +106 -1526
- package/dist/vercel-ai.d.cts +129 -8
- package/dist/vercel-ai.d.ts +129 -8
- package/dist/vercel-ai.js +100 -1520
- package/package.json +1 -1
- package/spec/README.md +1 -1
- package/spec/openapi.json +752 -158
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var chunkI5XIXB5M_cjs = require('./chunk-I5XIXB5M.cjs');
|
|
4
|
+
|
|
5
|
+
// src/adapters.ts
|
|
6
|
+
function delivers(reply) {
|
|
7
|
+
return !reply.held || reply.showHoldText;
|
|
8
|
+
}
|
|
9
|
+
async function deliveredOutcome(hook, info) {
|
|
10
|
+
const answer = await hook(info);
|
|
11
|
+
if (answer === null || answer === "") return { kind: "discarded", reason: chunkI5XIXB5M_cjs.OUTCOME_REASONS.nothingDelivered };
|
|
12
|
+
if (typeof answer === "string") return { kind: "released", content: answer };
|
|
13
|
+
if (typeof answer === "object" && typeof answer.text === "string") {
|
|
14
|
+
const { text, deliveredAt, deliveryRef } = answer;
|
|
15
|
+
const report = text === "" ? { kind: "discarded", reason: chunkI5XIXB5M_cjs.OUTCOME_REASONS.nothingDelivered } : { kind: "released", content: text };
|
|
16
|
+
if (deliveredAt !== void 0 && deliveredAt !== null) report.at = timeOf(deliveredAt);
|
|
17
|
+
if (deliveryRef !== void 0 && deliveryRef !== null) {
|
|
18
|
+
const fault = chunkI5XIXB5M_cjs.shortTextFault(deliveryRef);
|
|
19
|
+
if (fault !== void 0) throw invalid(`a \`deliveryRef\` that ${fault} (the API takes a non-blank string of at most ${chunkI5XIXB5M_cjs.MAX_SHORT_TEXT_CHARS} characters, with no control characters)`);
|
|
20
|
+
report.deliveryRef = deliveryRef;
|
|
21
|
+
}
|
|
22
|
+
return report;
|
|
23
|
+
}
|
|
24
|
+
throw invalid(answer === void 0 ? "undefined" : `a ${typeof answer} with no string \`text\``);
|
|
25
|
+
}
|
|
26
|
+
function timeOf(value) {
|
|
27
|
+
const time = chunkI5XIXB5M_cjs.timeValue(value);
|
|
28
|
+
if (time !== void 0) return time;
|
|
29
|
+
throw invalid(
|
|
30
|
+
typeof value === "string" ? "a `deliveredAt` string that is not an RFC 3339 date-time (such as 2026-09-16T10:00:00Z)" : "a `deliveredAt` that is neither a valid Date nor an RFC 3339 date-time string"
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
function invalid(what) {
|
|
34
|
+
return new chunkI5XIXB5M_cjs.GovernConfigError(
|
|
35
|
+
`deliveredText must return a string, { text, deliveredAt?, deliveryRef? } or null (or a promise of one); it returned ${what}. No outcome was reported for the decision.`
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
function handedOver(text, reason) {
|
|
39
|
+
return text === null || text === "" ? { kind: "discarded", reason } : { kind: "released", content: text };
|
|
40
|
+
}
|
|
41
|
+
function postReport(govern, decisionId, report, onFailure) {
|
|
42
|
+
const at = report.at ?? /* @__PURE__ */ new Date();
|
|
43
|
+
const input = report.kind === "released" ? { kind: "released", at, content: report.content } : { kind: "discarded", at, reason: report.reason };
|
|
44
|
+
if (report.deliveryRef !== void 0) input.deliveryRef = report.deliveryRef;
|
|
45
|
+
return govern.reportForAdapter(decisionId, input, onFailure);
|
|
46
|
+
}
|
|
47
|
+
function failureReporter(onError) {
|
|
48
|
+
return (error) => {
|
|
49
|
+
try {
|
|
50
|
+
onError?.(error);
|
|
51
|
+
} catch {
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
function callSafely(run, reportFailure) {
|
|
56
|
+
try {
|
|
57
|
+
run();
|
|
58
|
+
} catch (error) {
|
|
59
|
+
reportFailure(error);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
function hasOutcomeOnRecord(decision) {
|
|
63
|
+
return decision?.outcome?.state != null;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
exports.callSafely = callSafely;
|
|
67
|
+
exports.deliveredOutcome = deliveredOutcome;
|
|
68
|
+
exports.delivers = delivers;
|
|
69
|
+
exports.failureReporter = failureReporter;
|
|
70
|
+
exports.handedOver = handedOver;
|
|
71
|
+
exports.hasOutcomeOnRecord = hasOutcomeOnRecord;
|
|
72
|
+
exports.postReport = postReport;
|