@inhuman.tools/plexus-expectations 0.1.0 → 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/dist/driver/actor-machine.d.ts +1 -1
- package/dist/driver/actor-machine.d.ts.map +1 -1
- package/dist/executor/kernel-intern.d.ts.map +1 -1
- package/dist/executor/kernel-intern.js +11 -5
- package/dist/executor/kernel-intern.js.map +1 -1
- package/dist/executor/orchestrator.d.ts +1 -0
- package/dist/executor/orchestrator.d.ts.map +1 -1
- package/dist/executor/orchestrator.js +18 -7
- package/dist/executor/orchestrator.js.map +1 -1
- package/package.json +10 -10
- package/src/executor/kernel-intern.ts +12 -5
- package/src/executor/orchestrator.ts +15 -7
- package/dist/driver/PEWDriverConnection.d.ts +0 -139
- package/dist/driver/PEWDriverConnection.d.ts.map +0 -1
- package/dist/driver/PEWDriverConnection.js +0 -298
- package/dist/driver/PEWDriverConnection.js.map +0 -1
- package/dist/error-with-invariant.d.ts +0 -9
- package/dist/error-with-invariant.d.ts.map +0 -1
- package/dist/error-with-invariant.js +0 -12
- package/dist/error-with-invariant.js.map +0 -1
- package/dist/shared/attention.d.ts +0 -27
- package/dist/shared/attention.d.ts.map +0 -1
- package/dist/shared/attention.js +0 -116
- package/dist/shared/attention.js.map +0 -1
- package/dist/shared/models/ApprovableExpectation.d.ts +0 -15
- package/dist/shared/models/ApprovableExpectation.d.ts.map +0 -1
- package/dist/shared/models/ApprovableExpectation.js +0 -138
- package/dist/shared/models/ApprovableExpectation.js.map +0 -1
- package/dist/shared/models/IntrospectingPlexusModel.d.ts +0 -8
- package/dist/shared/models/IntrospectingPlexusModel.d.ts.map +0 -1
- package/dist/shared/models/IntrospectingPlexusModel.js +0 -48
- package/dist/shared/models/IntrospectingPlexusModel.js.map +0 -1
- package/dist/shared/models/ProgrammaticJob.d.ts +0 -6
- package/dist/shared/models/ProgrammaticJob.d.ts.map +0 -1
- package/dist/shared/models/ProgrammaticJob.js +0 -80
- package/dist/shared/models/ProgrammaticJob.js.map +0 -1
- package/dist/shared/models/WorkExpectationWithIntrospection.d.ts +0 -4
- package/dist/shared/models/WorkExpectationWithIntrospection.d.ts.map +0 -1
- package/dist/shared/models/WorkExpectationWithIntrospection.js +0 -28
- package/dist/shared/models/WorkExpectationWithIntrospection.js.map +0 -1
- package/dist/shared/resolution.d.ts +0 -39
- package/dist/shared/resolution.d.ts.map +0 -1
- package/dist/shared/resolution.js +0 -124
- package/dist/shared/resolution.js.map +0 -1
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Resolution request / answer shapes. Separate from ordinary TProposal steer.
|
|
3
|
-
* Transport lives on dedicated awareness lanes; parse functions drop junk.
|
|
4
|
-
*/
|
|
5
|
-
export function parseProposalOption(raw) {
|
|
6
|
-
let result = null;
|
|
7
|
-
if (raw != null && typeof raw === "object") {
|
|
8
|
-
const value = raw.value;
|
|
9
|
-
if (typeof value === "string" && value !== "") {
|
|
10
|
-
const label = raw.label;
|
|
11
|
-
result = typeof label === "string" && label !== "" ? { value, label } : { value };
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
return result;
|
|
15
|
-
}
|
|
16
|
-
/** Untrusted awareness field → published ask, or null. */
|
|
17
|
-
export function parseResolutionRequest(raw) {
|
|
18
|
-
let result = null;
|
|
19
|
-
if (raw != null && typeof raw === "object") {
|
|
20
|
-
const o = raw;
|
|
21
|
-
if (typeof o.requestId === "string" &&
|
|
22
|
-
o.requestId !== "" &&
|
|
23
|
-
typeof o.type === "string" &&
|
|
24
|
-
typeof o.description === "string" &&
|
|
25
|
-
o.description.trim() !== "" &&
|
|
26
|
-
Array.isArray(o.options) &&
|
|
27
|
-
o.options.length > 0) {
|
|
28
|
-
const options = [];
|
|
29
|
-
const seen = new Set();
|
|
30
|
-
let valid = true;
|
|
31
|
-
for (const item of o.options) {
|
|
32
|
-
const option = parseProposalOption(item);
|
|
33
|
-
if (option === null || seen.has(option.value)) {
|
|
34
|
-
valid = false;
|
|
35
|
-
break;
|
|
36
|
-
}
|
|
37
|
-
seen.add(option.value);
|
|
38
|
-
options.push(option);
|
|
39
|
-
}
|
|
40
|
-
const defaults = parseDefaults(o.defaults, seen);
|
|
41
|
-
if (valid && (o.defaults === undefined || defaults !== undefined)) {
|
|
42
|
-
result = {
|
|
43
|
-
requestId: o.requestId,
|
|
44
|
-
type: o.type,
|
|
45
|
-
description: o.description,
|
|
46
|
-
options,
|
|
47
|
-
body: o.body,
|
|
48
|
-
defaults,
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return result;
|
|
54
|
-
}
|
|
55
|
-
/** Untrusted awareness field → answer, or null. Missing `requestId` is ignored (no front-run). */
|
|
56
|
-
export function parseResolution(raw) {
|
|
57
|
-
let result = null;
|
|
58
|
-
if (raw != null && typeof raw === "object") {
|
|
59
|
-
const value = raw.value;
|
|
60
|
-
const requestId = raw.requestId;
|
|
61
|
-
if (typeof value === "string" && value !== "" && typeof requestId === "string" && requestId !== "") {
|
|
62
|
-
result = { requestId, value };
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
return result;
|
|
66
|
-
}
|
|
67
|
-
export function normalizeProposalRequest(request) {
|
|
68
|
-
if (typeof request.type !== "string") {
|
|
69
|
-
throw new TypeError("proposal request type must be a string");
|
|
70
|
-
}
|
|
71
|
-
if (typeof request.description !== "string" || request.description.trim() === "") {
|
|
72
|
-
throw new Error("proposal request description is required");
|
|
73
|
-
}
|
|
74
|
-
if (!Array.isArray(request.options) || request.options.length === 0) {
|
|
75
|
-
throw new Error("proposal request options must be a non-empty list");
|
|
76
|
-
}
|
|
77
|
-
const options = [];
|
|
78
|
-
const seen = new Set();
|
|
79
|
-
for (const item of request.options) {
|
|
80
|
-
const option = parseProposalOption(item);
|
|
81
|
-
if (option == null)
|
|
82
|
-
throw new Error("proposal request option value must be a non-empty string");
|
|
83
|
-
if (seen.has(option.value))
|
|
84
|
-
throw new Error(`proposal request option value repeats: ${option.value}`);
|
|
85
|
-
seen.add(option.value);
|
|
86
|
-
options.push(option);
|
|
87
|
-
}
|
|
88
|
-
const defaults = parseDefaults(request.defaults, seen);
|
|
89
|
-
if (request.defaults !== undefined && defaults === undefined) {
|
|
90
|
-
throw new Error("proposal request defaults must name option values");
|
|
91
|
-
}
|
|
92
|
-
return {
|
|
93
|
-
type: request.type,
|
|
94
|
-
description: request.description,
|
|
95
|
-
options,
|
|
96
|
-
body: request.body,
|
|
97
|
-
defaults,
|
|
98
|
-
};
|
|
99
|
-
}
|
|
100
|
-
function parseDefaults(raw, values) {
|
|
101
|
-
let result;
|
|
102
|
-
if (raw != null && typeof raw === "object") {
|
|
103
|
-
const confirm = raw.confirm;
|
|
104
|
-
const brk = raw.break;
|
|
105
|
-
const out = {};
|
|
106
|
-
let valid = true;
|
|
107
|
-
if (confirm !== undefined) {
|
|
108
|
-
if (typeof confirm === "string" && values.has(confirm))
|
|
109
|
-
out.confirm = confirm;
|
|
110
|
-
else
|
|
111
|
-
valid = false;
|
|
112
|
-
}
|
|
113
|
-
if (brk !== undefined) {
|
|
114
|
-
if (typeof brk === "string" && values.has(brk))
|
|
115
|
-
out.break = brk;
|
|
116
|
-
else
|
|
117
|
-
valid = false;
|
|
118
|
-
}
|
|
119
|
-
if (valid && Object.keys(out).length > 0)
|
|
120
|
-
result = out;
|
|
121
|
-
}
|
|
122
|
-
return result;
|
|
123
|
-
}
|
|
124
|
-
//# sourceMappingURL=resolution.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"resolution.js","sourceRoot":"","sources":["../../src/shared/resolution.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAkCH,MAAM,UAAU,mBAAmB,CAAC,GAAY;IAC9C,IAAI,MAAM,GAA0B,IAAI,CAAC;IACzC,IAAI,GAAG,IAAI,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QAC3C,MAAM,KAAK,GAAI,GAA2B,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AAE,OAAO,CAAC,IAAI;QAClB,WAAW,EAAE,OAAO,CAAC,WAAW;QAChC,OAAO;QACP,IAAI,EAAE,OAAO,CAAC,IAAI;QAClB,QAAQ;KACT,CAAC;AACJ,CAAC;AAED,SAAS,aAAa,CACpB,GAAY,EACZ,MAA2B;IAE3B,IAAI,MAA0E,CAAC;IAC/E,IAAI,GAAG,IAAI,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QAC3C,MAAM,OAAO,GAAI,GAA6B,CAAC,OAAO,CAAC;QACvD,MAAM,GAAG,GAAI,GAA2B,CAAC,KAAK,CAAC;QAC/C,MAAM,GAAG,GAAyC,EAAE,CAAC;QACrD,IAAI,KAAK,GAAG,IAAI,CAAC;QACjB,IAAI,OAAO,KAAK,SAAS,EAAE,CAAC;YAC1B,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC;gBAAE,GAAG,CAAC,OAAO,GAAG,OAAO,CAAC;;gBACzE,KAAK,GAAG,KAAK,CAAC;QACrB,CAAC;QACD,IAAI,GAAG,KAAK,SAAS,EAAE,CAAC;YACtB,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC;gBAAE,GAAG,CAAC,KAAK,GAAG,GAAG,CAAC;;gBAC3D,KAAK,GAAG,KAAK,CAAC;QACrB,CAAC;QACD,IAAI,KAAK,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,GAAG,CAAC;YAAE,MAAM,GAAG,GAAG,CAAC;IACzD,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["/**\n * Resolution request / answer shapes. Separate from ordinary TProposal steer.\n * Transport lives on dedicated awareness lanes; parse functions drop junk.\n */\n\n/** One choosable value. `label` is display; identity is `value`. */\nexport type ProposalOption = {\n readonly value: string;\n readonly label?: string;\n};\n\n/**\n * Actor → world ask. Default path is `description` + `options` + `defaults`.\n * `type` / `body` are optional enrichment — unknown `type` is ignored, not rejected.\n */\nexport type ProposalRequest = {\n readonly type: string;\n readonly description: string;\n readonly body?: unknown;\n readonly options: readonly ProposalOption[];\n readonly defaults?: {\n readonly confirm?: string;\n readonly break?: string;\n };\n};\n\n/** Published ask — {@link ProposalRequest} plus the request id on the resolution-request lane. */\nexport type ResolutionRequest = ProposalRequest & {\n readonly requestId: string;\n};\n\n/** Author → actor answer on the resolution lane. */\nexport type Resolution = {\n readonly requestId: string;\n readonly value: string;\n};\n\nexport function parseProposalOption(raw: unknown): ProposalOption | null {\n let result: ProposalOption | null = null;\n if (raw != null && typeof raw === \"object\") {\n const value = (raw as { value?: unknown }).value;\n if (typeof value === \"string\" && value !== \"\") {\n const label = (raw as { label?: unknown }).label;\n result = typeof label === \"string\" && label !== \"\" ? { value, label } : { value };\n }\n }\n return result;\n}\n\n/** Untrusted awareness field → published ask, or null. */\nexport function parseResolutionRequest(raw: unknown): ResolutionRequest | null {\n let result: ResolutionRequest | null = null;\n if (raw != null && typeof raw === \"object\") {\n const o = raw as Record<string, unknown>;\n if (\n typeof o.requestId === \"string\" &&\n o.requestId !== \"\" &&\n typeof o.type === \"string\" &&\n typeof o.description === \"string\" &&\n o.description.trim() !== \"\" &&\n Array.isArray(o.options) &&\n o.options.length > 0\n ) {\n const options: ProposalOption[] = [];\n const seen = new Set<string>();\n let valid = true;\n for (const item of o.options) {\n const option = parseProposalOption(item);\n if (option === null || seen.has(option.value)) {\n valid = false;\n break;\n }\n seen.add(option.value);\n options.push(option);\n }\n const defaults = parseDefaults(o.defaults, seen);\n if (valid && (o.defaults === undefined || defaults !== undefined)) {\n result = {\n requestId: o.requestId,\n type: o.type,\n description: o.description,\n options,\n body: o.body,\n defaults,\n };\n }\n }\n }\n return result;\n}\n\n/** Untrusted awareness field → answer, or null. Missing `requestId` is ignored (no front-run). */\nexport function parseResolution(raw: unknown): Resolution | null {\n let result: Resolution | null = null;\n if (raw != null && typeof raw === \"object\") {\n const value = (raw as { value?: unknown }).value;\n const requestId = (raw as { requestId?: unknown }).requestId;\n if (typeof value === \"string\" && value !== \"\" && typeof requestId === \"string\" && requestId !== \"\") {\n result = { requestId, value };\n }\n }\n return result;\n}\n\nexport function normalizeProposalRequest(request: ProposalRequest): ProposalRequest {\n if (typeof request.type !== \"string\") {\n throw new TypeError(\"proposal request type must be a string\");\n }\n if (typeof request.description !== \"string\" || request.description.trim() === \"\") {\n throw new Error(\"proposal request description is required\");\n }\n if (!Array.isArray(request.options) || request.options.length === 0) {\n throw new Error(\"proposal request options must be a non-empty list\");\n }\n const options: ProposalOption[] = [];\n const seen = new Set<string>();\n for (const item of request.options) {\n const option = parseProposalOption(item);\n if (option == null) throw new Error(\"proposal request option value must be a non-empty string\");\n if (seen.has(option.value)) throw new Error(`proposal request option value repeats: ${option.value}`);\n seen.add(option.value);\n options.push(option);\n }\n const defaults = parseDefaults(request.defaults, seen);\n if (request.defaults !== undefined && defaults === undefined) {\n throw new Error(\"proposal request defaults must name option values\");\n }\n return {\n type: request.type,\n description: request.description,\n options,\n body: request.body,\n defaults,\n };\n}\n\nfunction parseDefaults(\n raw: unknown,\n values: ReadonlySet<string>,\n): { readonly confirm?: string; readonly break?: string } | undefined {\n let result: { readonly confirm?: string; readonly break?: string } | undefined;\n if (raw != null && typeof raw === \"object\") {\n const confirm = (raw as { confirm?: unknown }).confirm;\n const brk = (raw as { break?: unknown }).break;\n const out: { confirm?: string; break?: string } = {};\n let valid = true;\n if (confirm !== undefined) {\n if (typeof confirm === \"string\" && values.has(confirm)) out.confirm = confirm;\n else valid = false;\n }\n if (brk !== undefined) {\n if (typeof brk === \"string\" && values.has(brk)) out.break = brk;\n else valid = false;\n }\n if (valid && Object.keys(out).length > 0) result = out;\n }\n return result;\n}\n"]}
|