@ftai/dsh-plugin-acn 0.0.0-stage → 0.1.1
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 +90 -0
- package/LICENSE-APACHE +201 -0
- package/LICENSE-MIT +19 -0
- package/README.md +82 -2
- package/README_EN.md +83 -0
- package/cordis.patch.yml +29 -0
- package/docs/acn-compat.md +33 -0
- package/docs/architecture.md +130 -0
- package/docs/assets/acn-claim-reuse.png +0 -0
- package/docs/assets/activity-view.png +0 -0
- package/docs/assets/install-package.png +0 -0
- package/docs/assets/knowledge-model.png +0 -0
- package/docs/assets/knowledge-view.png +0 -0
- package/docs/assets/personal-configuration.png +0 -0
- package/docs/assets/session-upstream.png +0 -0
- package/docs/assets/upstream-settings.png +0 -0
- package/docs/assets/upstream-team.png +0 -0
- package/docs/command-reference.md +201 -0
- package/docs/config.md +253 -0
- package/docs/development.md +197 -0
- package/docs/dsh-compat.md +59 -0
- package/docs/index.md +16 -0
- package/docs/outstanding-issues.md +61 -0
- package/docs/user_guide.md +185 -0
- package/icon.svg +8 -0
- package/lib/activities-B8U-iW4-.js +407 -0
- package/lib/alignment-CwH0nBf-.js +80 -0
- package/lib/auth-DFI9yowX.js +71 -0
- package/lib/checkpoint-CPFPOxBM.js +188 -0
- package/lib/checkpoint-c7aI4D-X.js +318 -0
- package/lib/claim-DOAGe8ZK.js +168 -0
- package/lib/client.js +18417 -0
- package/lib/deliver-C-dmhkfm.js +168 -0
- package/lib/delivery-status-M7-Rwoyj.js +89 -0
- package/lib/dispute-CtrInHzf.js +20 -0
- package/lib/disputes-ByEmi43j.js +51 -0
- package/lib/dream-agent-BVqxbKFc.js +249 -0
- package/lib/dream.js +4 -0
- package/lib/effects-DX1iy6FM.js +268 -0
- package/lib/errors-Bp_2WXBr.js +19 -0
- package/lib/errors-pPumDOGD.js +18 -0
- package/lib/evidence-store-DW7kj20i.js +1030 -0
- package/lib/formation-D4LO31WW.js +187 -0
- package/lib/formation-replay-Bf4TSBiz.js +87 -0
- package/lib/formation.js +9 -0
- package/lib/history-DPMHX3ZE.js +214 -0
- package/lib/inbox-2CugZZQm.js +188 -0
- package/lib/inbox-DFtE2fOp.js +71 -0
- package/lib/inbox.js +3 -0
- package/lib/index.js +1373 -0
- package/lib/lock-DbmlKOoX.js +332 -0
- package/lib/pages-BEWC3kmZ.js +51 -0
- package/lib/paths-B7NI9Ano.js +157 -0
- package/lib/plugins/commands.js +590 -0
- package/lib/plugins/dream.js +66 -0
- package/lib/plugins/formation.js +66 -0
- package/lib/plugins/inbox.js +53 -0
- package/lib/plugins/knowledge.js +1109 -0
- package/lib/plugins/prompt.js +102 -0
- package/lib/plugins/tools.js +280 -0
- package/lib/policy-DnyHh7Bl.js +16 -0
- package/lib/prepare-CGXwBEcu.js +134 -0
- package/lib/protocol.js +8 -0
- package/lib/queue-M917xHPS.js +153 -0
- package/lib/regular-file-BFpqMoub.js +136 -0
- package/lib/render-CJaVcKKC.js +48 -0
- package/lib/reported-sets-DdEKdeVb.js +122 -0
- package/lib/revision-DeoL_IUN.js +11 -0
- package/lib/scheduler-BfJSY1eq.js +64 -0
- package/lib/service-BPwaZzFF.js +1106 -0
- package/lib/service-BQaszW_v.js +344 -0
- package/lib/service-BhniAHLo.js +305 -0
- package/lib/service-C2lXoygJ.js +505 -0
- package/lib/session-binding-zCSuizHs.js +342 -0
- package/lib/session-state-CYqUhC95.js +38 -0
- package/lib/sessions-C2xuPFQv.js +218 -0
- package/lib/store.js +16 -0
- package/lib/structured-C9byFuzm.js +453 -0
- package/lib/subagent-yJsFxHmH.js +9 -0
- package/lib/team.js +3 -0
- package/lib/tool-schema-3b4gH1zf.js +28 -0
- package/lib/trace-Da0RnL5R.js +14 -0
- package/lib/traces-CHBo8y1z.js +11 -0
- package/lib/types/activities.d.ts +73 -0
- package/lib/types/advanced-configuration.d.ts +11 -0
- package/lib/types/client/ActivityCard.d.ts +14 -0
- package/lib/types/client/ActivityDetails.d.ts +18 -0
- package/lib/types/client/AdvancedPreferences.d.ts +8 -0
- package/lib/types/client/BlankCommandFeedback.d.ts +10 -0
- package/lib/types/client/ComposerMenu.d.ts +24 -0
- package/lib/types/client/ConfigurationPage.d.ts +11 -0
- package/lib/types/client/ConnectionCheckDialog.d.ts +12 -0
- package/lib/types/client/KnowledgeDetail.d.ts +6 -0
- package/lib/types/client/KnowledgeDirectoryField.d.ts +11 -0
- package/lib/types/client/KnowledgePanel.d.ts +12 -0
- package/lib/types/client/KnowledgeReference.d.ts +13 -0
- package/lib/types/client/SessionToolbar.d.ts +16 -0
- package/lib/types/client/SettingsToast.d.ts +3 -0
- package/lib/types/client/SourceSessionLink.d.ts +16 -0
- package/lib/types/client/TeamCredentialField.d.ts +16 -0
- package/lib/types/client/TeamSettingsPage.d.ts +28 -0
- package/lib/types/client/configuration-errors.d.ts +2 -0
- package/lib/types/client/interaction-styles.d.ts +1 -0
- package/lib/types/client/interaction-ui.d.ts +30 -0
- package/lib/types/client/knowledge-labels.d.ts +5 -0
- package/lib/types/client/locales.d.ts +51 -0
- package/lib/types/commands/claim.d.ts +4 -0
- package/lib/types/commands/import.d.ts +10 -0
- package/lib/types/commands/status.d.ts +5 -0
- package/lib/types/config.d.ts +111 -0
- package/lib/types/configuration.d.ts +235 -0
- package/lib/types/credentials.d.ts +59 -0
- package/lib/types/dream/audit.d.ts +4 -0
- package/lib/types/dream/autonomous.d.ts +185 -0
- package/lib/types/dream/candidates.d.ts +34 -0
- package/lib/types/dream/checkpoint.d.ts +35 -0
- package/lib/types/dream/evidence-files.d.ts +10 -0
- package/lib/types/dream/evidence-store.d.ts +103 -0
- package/lib/types/dream/evidence.d.ts +30 -0
- package/lib/types/dream/index.d.ts +10 -0
- package/lib/types/dream/plan.d.ts +18 -0
- package/lib/types/dream/preservation.d.ts +6 -0
- package/lib/types/dream/review.d.ts +10 -0
- package/lib/types/dream/schema.d.ts +1475 -0
- package/lib/types/dream/service.d.ts +56 -0
- package/lib/types/dream/sync.d.ts +147 -0
- package/lib/types/dsh-adapter/configuration-remote.d.ts +1 -0
- package/lib/types/dsh-adapter/configuration-service.d.ts +28 -0
- package/lib/types/dsh-adapter/dream-agent.d.ts +4 -0
- package/lib/types/dsh-adapter/dream-evidence.d.ts +3 -0
- package/lib/types/dsh-adapter/formation-archive.d.ts +3 -0
- package/lib/types/dsh-adapter/formation-replay.d.ts +5 -0
- package/lib/types/dsh-adapter/formation.d.ts +4 -0
- package/lib/types/dsh-adapter/interaction-service.d.ts +13 -0
- package/lib/types/dsh-adapter/knowledge-paths.d.ts +3 -0
- package/lib/types/dsh-adapter/llm.d.ts +10 -0
- package/lib/types/dsh-adapter/project-upstream.d.ts +4 -0
- package/lib/types/dsh-adapter/runtime-pool.d.ts +110 -0
- package/lib/types/dsh-adapter/session-binding.d.ts +43 -0
- package/lib/types/dsh-adapter/source-sessions.d.ts +3 -0
- package/lib/types/dsh-adapter/team-credentials.d.ts +5 -0
- package/lib/types/dsh-adapter/tool-schema.d.ts +4 -0
- package/lib/types/dsh-adapter/tools.d.ts +5 -0
- package/lib/types/formation/capture.d.ts +19 -0
- package/lib/types/formation/checkpoint.d.ts +136 -0
- package/lib/types/formation/index.d.ts +10 -0
- package/lib/types/formation/prepare.d.ts +16 -0
- package/lib/types/formation/schema.d.ts +45 -0
- package/lib/types/formation/service.d.ts +58 -0
- package/lib/types/formation/transcript.d.ts +75 -0
- package/lib/types/formation/triggers.d.ts +3 -0
- package/lib/types/inbox/cascade.d.ts +3 -0
- package/lib/types/inbox/effects.d.ts +275 -0
- package/lib/types/inbox/index.d.ts +5 -0
- package/lib/types/inbox/prepare.d.ts +380 -0
- package/lib/types/inbox/service.d.ts +26 -0
- package/lib/types/inbox/sync.d.ts +9 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/types/interaction-messages.d.ts +69 -0
- package/lib/types/interaction.d.ts +541 -0
- package/lib/types/knowledge/alignment.d.ts +49 -0
- package/lib/types/knowledge/catalog.d.ts +5 -0
- package/lib/types/knowledge/changes.d.ts +32 -0
- package/lib/types/knowledge/disputes.d.ts +3 -0
- package/lib/types/knowledge/errors.d.ts +9 -0
- package/lib/types/knowledge/ordering.d.ts +7 -0
- package/lib/types/knowledge/pages.d.ts +7 -0
- package/lib/types/knowledge/safety.d.ts +2 -0
- package/lib/types/knowledge/service.d.ts +52 -0
- package/lib/types/knowledge/sessions.d.ts +59 -0
- package/lib/types/knowledge/sources.d.ts +2 -0
- package/lib/types/knowledge/timestamps.d.ts +1 -0
- package/lib/types/knowledge/types.d.ts +84 -0
- package/lib/types/llm/response.d.ts +1 -0
- package/lib/types/llm/structured.d.ts +27 -0
- package/lib/types/local-name.d.ts +1 -0
- package/lib/types/plugins/client.d.ts +9 -0
- package/lib/types/plugins/commands.d.ts +11 -0
- package/lib/types/plugins/configuration.d.ts +8 -0
- package/lib/types/plugins/dream.d.ts +16 -0
- package/lib/types/plugins/formation.d.ts +16 -0
- package/lib/types/plugins/inbox.d.ts +16 -0
- package/lib/types/plugins/knowledge.d.ts +19 -0
- package/lib/types/plugins/prompt.d.ts +17 -0
- package/lib/types/plugins/tools.d.ts +10 -0
- package/lib/types/prompt/render.d.ts +2 -0
- package/lib/types/protocol/arbitration.d.ts +154 -0
- package/lib/types/protocol/auth.d.ts +31 -0
- package/lib/types/protocol/claim.d.ts +36 -0
- package/lib/types/protocol/dispute.d.ts +17 -0
- package/lib/types/protocol/ids.d.ts +20 -0
- package/lib/types/protocol/inbox.d.ts +141 -0
- package/lib/types/protocol/index.d.ts +11 -0
- package/lib/types/protocol/policy.d.ts +21 -0
- package/lib/types/protocol/revision.d.ts +2 -0
- package/lib/types/protocol/router.d.ts +114 -0
- package/lib/types/protocol/schema.d.ts +4 -0
- package/lib/types/protocol/time.d.ts +5 -0
- package/lib/types/protocol/trace.d.ts +11 -0
- package/lib/types/store/atomic.d.ts +8 -0
- package/lib/types/store/claim-edits.d.ts +33 -0
- package/lib/types/store/claims.d.ts +7 -0
- package/lib/types/store/context.d.ts +13 -0
- package/lib/types/store/delivery-status.d.ts +48 -0
- package/lib/types/store/disputes.d.ts +6 -0
- package/lib/types/store/entities.d.ts +16 -0
- package/lib/types/store/errors.d.ts +8 -0
- package/lib/types/store/history.d.ts +65 -0
- package/lib/types/store/inbox.d.ts +27 -0
- package/lib/types/store/index.d.ts +16 -0
- package/lib/types/store/jobs.d.ts +5 -0
- package/lib/types/store/library-directory.d.ts +4 -0
- package/lib/types/store/lock.d.ts +11 -0
- package/lib/types/store/path-names.d.ts +2 -0
- package/lib/types/store/paths.d.ts +45 -0
- package/lib/types/store/presentation.d.ts +13 -0
- package/lib/types/store/regular-file.d.ts +2 -0
- package/lib/types/store/rejected-disputes.d.ts +18 -0
- package/lib/types/store/rename.d.ts +1 -0
- package/lib/types/store/reported-sets.d.ts +24 -0
- package/lib/types/store/session-state.d.ts +17 -0
- package/lib/types/store/traces.d.ts +6 -0
- package/lib/types/store/uploads.d.ts +312 -0
- package/lib/types/store/yaml.d.ts +8 -0
- package/lib/types/team/errors.d.ts +10 -0
- package/lib/types/team/http.d.ts +20 -0
- package/lib/types/team/index.d.ts +5 -0
- package/lib/types/team/maintainer-client.d.ts +18 -0
- package/lib/types/team/router-client.d.ts +14 -0
- package/lib/types/team/service.d.ts +28 -0
- package/lib/types/team/system-proxy.d.ts +9 -0
- package/lib/types/tools/claim.d.ts +63 -0
- package/lib/types/tools/consult-router.d.ts +11 -0
- package/lib/types/tools/subagent.d.ts +8 -0
- package/lib/types/tools/validation.d.ts +2 -0
- package/lib/types/upload/consolidation.d.ts +63 -0
- package/lib/types/upload/deliver.d.ts +15 -0
- package/lib/types/upload/index.d.ts +2 -0
- package/lib/types/upload/scheduler.d.ts +19 -0
- package/lib/types/upstreams.d.ts +5 -0
- package/lib/types/worker/queue.d.ts +17 -0
- package/lib/types/worker/types.d.ts +51 -0
- package/lib/types/worker/worker.d.ts +39 -0
- package/lib/types-C2ST2Zdg.js +17 -0
- package/lib/upload.js +3 -0
- package/lib/uploads-BCA2p92b.js +210 -0
- package/lib/upstreams-DEi-56tD.js +495 -0
- package/lib/worker-HMGzJFWd.js +185 -0
- package/locale/commands/en.json +1 -0
- package/locale/commands/zh.json +1 -0
- package/locale/dream/en.json +1 -0
- package/locale/dream/zh.json +1 -0
- package/locale/en.json +7 -0
- package/locale/formation/en.json +1 -0
- package/locale/formation/zh.json +1 -0
- package/locale/inbox/en.json +1 -0
- package/locale/inbox/zh.json +1 -0
- package/locale/knowledge/en.json +1 -0
- package/locale/knowledge/zh.json +1 -0
- package/locale/prompt/en.json +1 -0
- package/locale/prompt/zh.json +1 -0
- package/locale/tools/en.json +1 -0
- package/locale/tools/zh.json +1 -0
- package/locale/zh.json +7 -0
- package/package.json +262 -3
- package/prompts/claim_dream.j2 +77 -0
- package/prompts/claim_dream_legacy.j2 +63 -0
- package/prompts/dream_compaction.j2 +11 -0
- package/prompts/dream_evidence.j2 +5 -0
- package/prompts/inbox_claim_attribute_update_internalize.j2 +112 -0
- package/prompts/inbox_policy_update_internalize.j2 +87 -0
- package/prompts/knowledge.j2 +38 -0
- package/prompts/session_recap.j2 +113 -0
- package/prompts/what_is_claim.j2 +51 -0
- package/prompts/what_is_dispute.j2 +21 -0
- package/prompts/what_is_policy.j2 +22 -0
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { createHash, randomBytes } from "node:crypto";
|
|
3
|
+
//#region src/protocol/time.ts
|
|
4
|
+
const billion = 1000000000n;
|
|
5
|
+
const pattern = /^(\d{4})-(\d{2})-(\d{2})[Tt](\d{2}):(\d{2}):(\d{2})(?:\.(\d+))?([Zz]|[+-]\d{2}:\d{2})$/;
|
|
6
|
+
function parts(input) {
|
|
7
|
+
const match = pattern.exec(input);
|
|
8
|
+
if (match === null) throw new Error("Expected an RFC 3339 timestamp.");
|
|
9
|
+
const [, yearText = "", monthText = "", dayText = "", hourText = "", minuteText = "", secondText = "", fraction = "", zone = ""] = match;
|
|
10
|
+
const [year, month, day, hour, minute, second] = [
|
|
11
|
+
yearText,
|
|
12
|
+
monthText,
|
|
13
|
+
dayText,
|
|
14
|
+
hourText,
|
|
15
|
+
minuteText,
|
|
16
|
+
secondText
|
|
17
|
+
].map(Number);
|
|
18
|
+
if (year === void 0 || month === void 0 || day === void 0 || hour === void 0 || minute === void 0 || second === void 0) throw new Error("Incomplete timestamp.");
|
|
19
|
+
const days = [
|
|
20
|
+
31,
|
|
21
|
+
year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0) ? 29 : 28,
|
|
22
|
+
31,
|
|
23
|
+
30,
|
|
24
|
+
31,
|
|
25
|
+
30,
|
|
26
|
+
31,
|
|
27
|
+
31,
|
|
28
|
+
30,
|
|
29
|
+
31,
|
|
30
|
+
30,
|
|
31
|
+
31
|
|
32
|
+
][month - 1] ?? 0;
|
|
33
|
+
if (month < 1 || month > 12 || day < 1 || day > days || hour > 23 || minute > 59 || second > 60) throw new Error("Invalid calendar timestamp.");
|
|
34
|
+
const offsetHour = zone.length > 1 ? Number(zone.slice(1, 3)) : 0;
|
|
35
|
+
const offsetMinute = zone.length > 1 ? Number(zone.slice(4, 6)) : 0;
|
|
36
|
+
if (offsetHour > 23 || offsetMinute > 59) throw new Error("Invalid timestamp offset.");
|
|
37
|
+
const offset = (zone.startsWith("-") ? -1 : 1) * (offsetHour * 3600 + offsetMinute * 60);
|
|
38
|
+
const date = /* @__PURE__ */ new Date(0);
|
|
39
|
+
date.setUTCFullYear(year, month - 1, day);
|
|
40
|
+
date.setUTCHours(hour, minute, Math.min(second, 59), 0);
|
|
41
|
+
const epochMs = date.getTime();
|
|
42
|
+
if (!Number.isFinite(epochMs)) throw new Error("Timestamp is outside the supported calendar range.");
|
|
43
|
+
return {
|
|
44
|
+
seconds: BigInt(epochMs / 1e3 - offset),
|
|
45
|
+
nanos: BigInt(fraction.slice(0, 9).padEnd(9, "0")),
|
|
46
|
+
leap: second === 60
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
function normalizeTimestamp(input) {
|
|
50
|
+
const value = parts(input);
|
|
51
|
+
const date = /* @__PURE__ */ new Date(Number(value.seconds) * 1e3);
|
|
52
|
+
if (!Number.isFinite(date.getTime())) throw new Error("Timestamp is outside the supported calendar range.");
|
|
53
|
+
const pad = (number) => String(number).padStart(2, "0");
|
|
54
|
+
const year = date.getUTCFullYear();
|
|
55
|
+
if (year < 0 || year > 9999) throw new Error("UTC year must remain within four digits.");
|
|
56
|
+
const yearText = String(year).padStart(4, "0");
|
|
57
|
+
const fractionLength = value.nanos === 0n ? 0 : value.nanos % 1000000n === 0n ? 3 : value.nanos % 1000n === 0n ? 6 : 9;
|
|
58
|
+
const fraction = fractionLength === 0 ? "" : `.${value.nanos.toString().padStart(9, "0").slice(0, fractionLength)}`;
|
|
59
|
+
return `${yearText}-${pad(date.getUTCMonth() + 1)}-${pad(date.getUTCDate())}T${pad(date.getUTCHours())}:${pad(date.getUTCMinutes())}:${value.leap ? "60" : pad(date.getUTCSeconds())}${fraction}Z`;
|
|
60
|
+
}
|
|
61
|
+
function timestampNanos(input) {
|
|
62
|
+
const value = parts(input);
|
|
63
|
+
return value.seconds * billion + value.nanos + (value.leap ? billion : 0n);
|
|
64
|
+
}
|
|
65
|
+
function nowSeconds() {
|
|
66
|
+
return `${(/* @__PURE__ */ new Date()).toISOString().slice(0, 19)}Z`;
|
|
67
|
+
}
|
|
68
|
+
const TimestampSchema = z.string().transform((value, ctx) => {
|
|
69
|
+
try {
|
|
70
|
+
return normalizeTimestamp(value);
|
|
71
|
+
} catch {
|
|
72
|
+
ctx.addIssue({
|
|
73
|
+
code: "custom",
|
|
74
|
+
message: "Invalid RFC 3339 timestamp."
|
|
75
|
+
});
|
|
76
|
+
return z.NEVER;
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
//#endregion
|
|
80
|
+
//#region src/protocol/ids.ts
|
|
81
|
+
const AgentIdSchema = z.string().regex(/^[a-z0-9_-]+$/).brand();
|
|
82
|
+
const ClaimIdSchema = z.string().regex(/^claim_[0-9a-f]{8}$/).brand();
|
|
83
|
+
const TraceIdSchema = z.string().regex(/^trace_[0-9a-f]{8}$/).brand();
|
|
84
|
+
const DisputeIdSchema = z.string().regex(/^dispute_[0-9a-f]{8}$/).brand();
|
|
85
|
+
const PolicyIdSchema = z.string().regex(/^policy_[0-9a-f]{8}$/).brand();
|
|
86
|
+
const InboxIdSchema = z.string().regex(/^inbox_[0-9a-f]{8}$/).brand();
|
|
87
|
+
const ResolutionIdSchema = z.string().regex(/^(resolution|arbitration)_[0-9a-f]{8}$/).brand();
|
|
88
|
+
const SourceIdSchema = z.union([ClaimIdSchema, PolicyIdSchema]);
|
|
89
|
+
function derive(prefix, createdAt, fields, salt) {
|
|
90
|
+
if (!/^[0-9a-f]{4}$/.test(salt)) throw new Error("ID salt must be four lowercase hexadecimal digits.");
|
|
91
|
+
const hash = createHash("sha256");
|
|
92
|
+
for (const field of [
|
|
93
|
+
timestampNanos(createdAt).toString(),
|
|
94
|
+
...fields,
|
|
95
|
+
salt
|
|
96
|
+
]) hash.update(`${Buffer.byteLength(field)}:${field}`);
|
|
97
|
+
return `${prefix}_${hash.digest("hex").slice(0, 8)}`;
|
|
98
|
+
}
|
|
99
|
+
function deriveClaimId(createdAt, name, scope, salt = randomBytes(2).toString("hex")) {
|
|
100
|
+
return ClaimIdSchema.parse(derive("claim", createdAt, [name, scope], salt));
|
|
101
|
+
}
|
|
102
|
+
function deriveTraceId(createdAt, name, inputs, outputs, salt = randomBytes(2).toString("hex")) {
|
|
103
|
+
return TraceIdSchema.parse(derive("trace", createdAt, [
|
|
104
|
+
name,
|
|
105
|
+
inputs.join(""),
|
|
106
|
+
"",
|
|
107
|
+
outputs.join("")
|
|
108
|
+
], salt));
|
|
109
|
+
}
|
|
110
|
+
function deriveDisputeId(createdAt, name, claims, summary, salt = randomBytes(2).toString("hex")) {
|
|
111
|
+
return DisputeIdSchema.parse(derive("dispute", createdAt, [
|
|
112
|
+
name,
|
|
113
|
+
claims.join(""),
|
|
114
|
+
"",
|
|
115
|
+
summary
|
|
116
|
+
], salt));
|
|
117
|
+
}
|
|
118
|
+
//#endregion
|
|
119
|
+
//#region src/protocol/schema.ts
|
|
120
|
+
const TextSchema = z.string().refine((value) => !/[\uD800-\uDFFF]/u.test(value), "Text must contain valid Unicode.");
|
|
121
|
+
const optional = (schema) => z.preprocess((value) => value === null ? void 0 : value, schema.optional());
|
|
122
|
+
function withAliases(schema, aliases) {
|
|
123
|
+
return z.preprocess((value, ctx) => {
|
|
124
|
+
if (typeof value !== "object" || value === null || Array.isArray(value)) return value;
|
|
125
|
+
const record = { ...value };
|
|
126
|
+
for (const [alias, canonical] of Object.entries(aliases)) {
|
|
127
|
+
if (!Object.hasOwn(record, alias)) continue;
|
|
128
|
+
if (Object.hasOwn(record, canonical)) {
|
|
129
|
+
ctx.addIssue({
|
|
130
|
+
code: "custom",
|
|
131
|
+
message: `Duplicate field: ${canonical}.`
|
|
132
|
+
});
|
|
133
|
+
return z.NEVER;
|
|
134
|
+
}
|
|
135
|
+
record[canonical] = record[alias];
|
|
136
|
+
delete record[alias];
|
|
137
|
+
}
|
|
138
|
+
return record;
|
|
139
|
+
}, schema);
|
|
140
|
+
}
|
|
141
|
+
//#endregion
|
|
142
|
+
//#region src/protocol/claim.ts
|
|
143
|
+
const ConfidenceSchema = z.enum([
|
|
144
|
+
"high",
|
|
145
|
+
"medium",
|
|
146
|
+
"low"
|
|
147
|
+
]);
|
|
148
|
+
const ClaimStatusSchema = z.enum([
|
|
149
|
+
"active",
|
|
150
|
+
"stale",
|
|
151
|
+
"deprecated"
|
|
152
|
+
]);
|
|
153
|
+
const ClaimSchema = z.object({
|
|
154
|
+
id: ClaimIdSchema,
|
|
155
|
+
name: TextSchema,
|
|
156
|
+
statement: TextSchema,
|
|
157
|
+
scope: TextSchema,
|
|
158
|
+
holder: AgentIdSchema,
|
|
159
|
+
confidence: ConfidenceSchema,
|
|
160
|
+
status: ClaimStatusSchema,
|
|
161
|
+
created_at: TimestampSchema,
|
|
162
|
+
updated_at: optional(TimestampSchema),
|
|
163
|
+
source_claim_ids: z.array(SourceIdSchema).default([]),
|
|
164
|
+
evidence_summary: TextSchema
|
|
165
|
+
});
|
|
166
|
+
const effectiveUpdatedAt = (claim) => claim.updated_at ?? claim.created_at;
|
|
167
|
+
//#endregion
|
|
168
|
+
export { timestampNanos as S, deriveDisputeId as _, TextSchema as a, normalizeTimestamp as b, AgentIdSchema as c, InboxIdSchema as d, PolicyIdSchema as f, deriveClaimId as g, TraceIdSchema as h, effectiveUpdatedAt as i, ClaimIdSchema as l, SourceIdSchema as m, ClaimStatusSchema as n, optional as o, ResolutionIdSchema as p, ConfidenceSchema as r, withAliases as s, ClaimSchema as t, DisputeIdSchema as u, deriveTraceId as v, nowSeconds as x, TimestampSchema as y };
|