@aitoroses/telar 0.1.0 → 0.2.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/README.md +5 -1
- package/dist/compile.js +4 -2
- package/dist/contract.d.ts +1 -1
- package/dist/contract.js +28 -34
- package/dist/evidence.d.ts +23 -0
- package/dist/evidence.js +74 -0
- package/dist/iso.d.ts +2 -0
- package/dist/iso.js +5 -0
- package/dist/node/build.d.ts +1 -0
- package/dist/node/build.js +23 -1
- package/dist/observer.d.ts +2 -11
- package/dist/powers.d.ts +1 -1
- package/dist/protocol.d.ts +9 -1
- package/dist/protocol.js +7 -0
- package/dist/runner.d.ts +11 -10
- package/dist/runner.js +2 -2
- package/dist/scenario/types.d.ts +2 -11
- package/dist/scenario.d.ts +1 -1
- package/dist/schema.d.ts +2 -0
- package/dist/schema.js +6 -0
- package/dist/seating.d.ts +0 -2
- package/dist/spec.d.ts +7 -6
- package/dist/spec.js +4 -3
- package/dist/std/actions.d.ts +0 -1
- package/dist/std/actions.js +0 -1
- package/dist/std/claude-code.js +9 -2
- package/dist/std/observe-github-checks.d.ts +0 -2
- package/dist/std/observe-github-checks.js +3 -13
- package/dist/std/observe-http-status.js +14 -2
- package/dist/types.d.ts +4 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -193,6 +193,8 @@ const exchanges = bound("exchanges", {
|
|
|
193
193
|
|
|
194
194
|
### 8. Needs and effects
|
|
195
195
|
|
|
196
|
+
`casesEnded({ field })` holds when every case id in the named `t.array(caseRef)` data field has ended (closed or cancelled), the same terms as `childrenEnded`. The cases need not be children. An empty array holds. An unset optional field does not hold, and an id that names no case never holds, so a typo keeps the step waiting and the case shows as waiting on other cases, not on a seat. Admission refuses with `CASES_ENDED_FIELD_NOT_CASE_REFS` at `<step>.needs[i].field` when the field is absent from the protocol's data or is not an array of `caseRef` (strings branded `CaseRef`).
|
|
197
|
+
|
|
196
198
|
```ts
|
|
197
199
|
import {
|
|
198
200
|
answer,
|
|
@@ -200,6 +202,7 @@ import {
|
|
|
200
202
|
append,
|
|
201
203
|
authorize,
|
|
202
204
|
boundReached,
|
|
205
|
+
casesEnded,
|
|
203
206
|
childrenEnded,
|
|
204
207
|
childrenEndedIn,
|
|
205
208
|
childrenIn,
|
|
@@ -219,6 +222,7 @@ authorize(irreversible);
|
|
|
219
222
|
authorize.fromField(caseData.area, [decideAsUser, irreversible]);
|
|
220
223
|
ciGreen({ repo: caseData.area, head: fromAnswer("head") });
|
|
221
224
|
childrenEnded({ allowEmpty: true });
|
|
225
|
+
casesEnded({ field: caseData.after });
|
|
222
226
|
childrenIn(missedAck, "open", { allowEmpty: false });
|
|
223
227
|
childrenEndedIn(missedAck, "closed", {
|
|
224
228
|
where: { childField: "subject", parentField: caseData.area },
|
|
@@ -296,7 +300,7 @@ fills: {
|
|
|
296
300
|
|
|
297
301
|
### 11. Building the installation module (`telar/build`, `telar-module`)
|
|
298
302
|
|
|
299
|
-
telar loads one ES module that imports only `telar/spec`, `telar/std` and `telar/scenario`. `telar-module <entry> [--out <file>]` bundles your entry with rolldown (an optional peer dependency: install `rolldown` beside `telar` to use it) into that module, keeps the three SDK specifiers external, and drops code your exports never reach (Node imports included). `buildModule(entry)` from `telar/build` does the same and returns the module text. Then `telar build <module.mjs> <types.d.mts>` refuses any other import and packs the module and your declarations into `<name>.telar.json`:
|
|
303
|
+
telar loads one ES module that imports only `telar/spec`, `telar/std` and `telar/scenario`. `telar-module <entry> [--out <file>]` bundles your entry with rolldown (an optional peer dependency: install `rolldown` beside `telar` to use it) into that module, keeps the three SDK specifiers external, and drops code your exports never reach (Node imports included). `buildModule(entry)` from `telar/build` does the same and returns the module text. Its first line stamps the SDK that made it, `// telar-sdk @aitoroses/telar@<version>`. Then `telar build <module.mjs> <types.d.mts>` refuses a module whose stamp is missing or names another version (`BUILD_SDK`), refuses any other import, and packs the module and your declarations into `<name>.telar.json`:
|
|
300
304
|
|
|
301
305
|
```sh
|
|
302
306
|
telar-module installation.ts --out installation.mjs
|
package/dist/compile.js
CHANGED
|
@@ -682,6 +682,8 @@ function lowerNeed(ctx, need, caseFields, path) {
|
|
|
682
682
|
}
|
|
683
683
|
case "bound-reached-need":
|
|
684
684
|
return { kind: "bound-reached", step: checkId(need.step, `${path}.step`), ...guideProp() };
|
|
685
|
+
case "cases-ended-need":
|
|
686
|
+
return { kind: "cases-ended", field: need.field, ...guideProp() };
|
|
685
687
|
default:
|
|
686
688
|
return exhaustive(need);
|
|
687
689
|
}
|
|
@@ -1008,8 +1010,8 @@ function lowerNetworkGrant(g, path) {
|
|
|
1008
1010
|
if (g.secrets !== undefined) {
|
|
1009
1011
|
for (let i = 0; i < g.secrets.length; i += 1) {
|
|
1010
1012
|
const s = g.secrets[i];
|
|
1011
|
-
if (s === undefined ||
|
|
1012
|
-
fail(`${path}.secrets[${i}]`, `invalid secret
|
|
1013
|
+
if (s === undefined || !/^env:[A-Za-z_][A-Za-z0-9_]*$/.test(s)) {
|
|
1014
|
+
fail(`${path}.secrets[${i}]`, `invalid secret reference ${JSON.stringify(s)}: expected "env:NAME"`);
|
|
1013
1015
|
}
|
|
1014
1016
|
}
|
|
1015
1017
|
}
|
package/dist/contract.d.ts
CHANGED
|
@@ -64,7 +64,7 @@ export interface RunnerFixture<Options = unknown> {
|
|
|
64
64
|
readonly onPhase?: (phase: "work" | "ended") => void;
|
|
65
65
|
readonly expectedWork?: number;
|
|
66
66
|
}
|
|
67
|
-
/** Runner contract (interfaces.md §4.1): wake/ref, resume, poll work once by id, ended -> end, GRANT_REFUSED. */
|
|
67
|
+
/** Runner contract (interfaces.md §4.1): wake/ref, resume, poll work once by id, ended -> end (twice, idempotent), GRANT_REFUSED. */
|
|
68
68
|
export declare function checkRunner<Options>(runner: RunnerSubject<Options>, fixture: RunnerFixture<Options>): ContractViolation[];
|
|
69
69
|
export interface EvaluatorFixture {
|
|
70
70
|
readonly cases: readonly {
|
package/dist/contract.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { decodeEvaluation, isValidEvaluatorId, } from "./evaluator.js";
|
|
2
|
+
import { evidenceProblems, workEvidenceProblems } from "./evidence.js";
|
|
2
3
|
import { isValidObserverId } from "./observer.js";
|
|
3
4
|
import { isValidActionId } from "./pieces.js";
|
|
4
5
|
import { fakeRead } from "./read.js";
|
|
@@ -68,25 +69,6 @@ export function checkSource(source, fixture) {
|
|
|
68
69
|
}
|
|
69
70
|
return out;
|
|
70
71
|
}
|
|
71
|
-
function evidenceProblems(evidence) {
|
|
72
|
-
const out = [];
|
|
73
|
-
for (const ref of evidence.refs ?? []) {
|
|
74
|
-
if (typeof ref.kind !== "string" || ref.kind.length === 0)
|
|
75
|
-
out.push("a ref needs a kind");
|
|
76
|
-
}
|
|
77
|
-
const { status, durationMs, readings } = evidence;
|
|
78
|
-
if (status !== undefined && (!Number.isInteger(status) || status < 100 || status > 599)) {
|
|
79
|
-
out.push(`status ${String(status)} is not an HTTP status`);
|
|
80
|
-
}
|
|
81
|
-
if (durationMs !== undefined && (!Number.isInteger(durationMs) || durationMs < 0)) {
|
|
82
|
-
out.push(`durationMs ${String(durationMs)} is not a non-negative integer`);
|
|
83
|
-
}
|
|
84
|
-
for (const [name, value] of Object.entries(readings ?? {})) {
|
|
85
|
-
if (!Number.isFinite(value))
|
|
86
|
-
out.push(`reading ${name} is not a finite number`);
|
|
87
|
-
}
|
|
88
|
-
return out;
|
|
89
|
-
}
|
|
90
72
|
/**
|
|
91
73
|
* The observer contract: the behaviour telar's host relies on from every observer, std or not.
|
|
92
74
|
* Each case observes one check in a world the case supplies, and names the answer it expects.
|
|
@@ -160,8 +142,9 @@ const DEFAULT_SEAT = {
|
|
|
160
142
|
binding: { kind: "case", case_id: "c-000001" },
|
|
161
143
|
};
|
|
162
144
|
const RUNNER_STATES = new Set(["working", "idle", "ended"]);
|
|
163
|
-
const REPORT_KEYS = new Set(["ref", "state", "holder", "work"]);
|
|
164
|
-
const
|
|
145
|
+
const REPORT_KEYS = new Set(["ref", "state", "holder", "identity", "work"]);
|
|
146
|
+
const ENV_NAME = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
147
|
+
const WORK_KEYS = new Set(["id", "startedAt", "endedAt", "evidence"]);
|
|
165
148
|
const refuseRead = () => {
|
|
166
149
|
throw new PowerError("GRANT_REFUSED", "read is not granted");
|
|
167
150
|
};
|
|
@@ -186,17 +169,14 @@ function checkWorkItem(item, seen, out) {
|
|
|
186
169
|
if (!isRec(item))
|
|
187
170
|
return void out.push({ rule: "work", message: "work item must be an object" });
|
|
188
171
|
checkKeys(item, WORK_KEYS, "work", out);
|
|
189
|
-
const { id, startedAt, endedAt,
|
|
172
|
+
const { id, startedAt, endedAt, evidence } = item;
|
|
190
173
|
if (typeof id !== "string" || !id)
|
|
191
174
|
return void out.push({ rule: "work", message: "work item requires non-empty id" });
|
|
192
175
|
if (typeof startedAt !== "string" || !startedAt || typeof endedAt !== "string" || !endedAt)
|
|
193
176
|
out.push({ rule: "work", message: `${id} requires non-empty startedAt and endedAt` });
|
|
194
|
-
if (
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
for (const [k, v] of Object.entries(readings)) {
|
|
198
|
-
if (!k || typeof v !== "number" || !Number.isFinite(v))
|
|
199
|
-
out.push({ rule: "work", message: `${id} reading ${JSON.stringify(k)} must be finite` });
|
|
177
|
+
if (evidence !== undefined) {
|
|
178
|
+
for (const problem of workEvidenceProblems(evidence)) {
|
|
179
|
+
out.push({ rule: "work", message: `${id}: ${problem}` });
|
|
200
180
|
}
|
|
201
181
|
}
|
|
202
182
|
seen.add(id);
|
|
@@ -220,13 +200,25 @@ function checkRunnerReport(rule, r, seen, out) {
|
|
|
220
200
|
out.push({ rule: "holder", message: `${rule} holder[${JSON.stringify(k)}] empty` });
|
|
221
201
|
}
|
|
222
202
|
}
|
|
203
|
+
const identity = r.identity;
|
|
204
|
+
if (identity !== undefined &&
|
|
205
|
+
!(isRec(identity) &&
|
|
206
|
+
typeof identity["env"] === "string" &&
|
|
207
|
+
ENV_NAME.test(identity["env"]) &&
|
|
208
|
+
typeof identity["value"] === "string" &&
|
|
209
|
+
identity["value"].length > 0 &&
|
|
210
|
+
Object.keys(identity).every((k) => k === "env" || k === "value")))
|
|
211
|
+
out.push({
|
|
212
|
+
rule: "identity",
|
|
213
|
+
message: `${rule} identity must be { env: <variable name>, value: <non-empty> }`,
|
|
214
|
+
});
|
|
223
215
|
if (r.work !== undefined && !Array.isArray(r.work))
|
|
224
216
|
out.push({ rule: "work", message: `${rule} work must be an array` });
|
|
225
217
|
else
|
|
226
218
|
for (const item of r.work ?? [])
|
|
227
219
|
checkWorkItem(item, seen, out);
|
|
228
220
|
}
|
|
229
|
-
/** Runner contract (interfaces.md §4.1): wake/ref, resume, poll work once by id, ended -> end, GRANT_REFUSED. */
|
|
221
|
+
/** Runner contract (interfaces.md §4.1): wake/ref, resume, poll work once by id, ended -> end (twice, idempotent), GRANT_REFUSED. */
|
|
230
222
|
export function checkRunner(runner, fixture) {
|
|
231
223
|
const out = [];
|
|
232
224
|
const add = (rule, message) => out.push({ rule, message });
|
|
@@ -262,11 +254,13 @@ export function checkRunner(runner, fixture) {
|
|
|
262
254
|
checkRunnerReport("end", ending, seen, out);
|
|
263
255
|
if (fixture.onPhase !== undefined && ending.state !== "ended")
|
|
264
256
|
add("end", `expected ended, got ${ending.state}`);
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
257
|
+
for (const call of ["end", "a second end on the same ref"]) {
|
|
258
|
+
try {
|
|
259
|
+
runner.end({ seat, ref, options: fixture.options }, powers);
|
|
260
|
+
}
|
|
261
|
+
catch (err) {
|
|
262
|
+
add("end", `${call} threw: ${String(err)}`);
|
|
263
|
+
}
|
|
270
264
|
}
|
|
271
265
|
}
|
|
272
266
|
try {
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export interface EvidenceRef {
|
|
2
|
+
readonly kind: string;
|
|
3
|
+
readonly id?: string | undefined;
|
|
4
|
+
readonly url?: string | undefined;
|
|
5
|
+
}
|
|
6
|
+
export interface Readings {
|
|
7
|
+
readonly "tokens.input"?: number | undefined;
|
|
8
|
+
readonly "tokens.output"?: number | undefined;
|
|
9
|
+
readonly "tokens.cacheRead"?: number | undefined;
|
|
10
|
+
readonly "tokens.cacheWrite"?: number | undefined;
|
|
11
|
+
readonly usd?: number | undefined;
|
|
12
|
+
readonly [key: string]: number | undefined;
|
|
13
|
+
}
|
|
14
|
+
export interface Evidence {
|
|
15
|
+
readonly at?: string | undefined;
|
|
16
|
+
readonly refs?: readonly EvidenceRef[] | undefined;
|
|
17
|
+
readonly status?: number | undefined;
|
|
18
|
+
readonly durationMs?: number | undefined;
|
|
19
|
+
readonly readings?: Readings | undefined;
|
|
20
|
+
}
|
|
21
|
+
export type WorkEvidence = Omit<Evidence, "at" | "durationMs">;
|
|
22
|
+
export declare function evidenceProblems(raw: unknown): string[];
|
|
23
|
+
export declare function workEvidenceProblems(raw: unknown): string[];
|
package/dist/evidence.js
ADDED
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { formatIsoUtc, isCanonicalIsoUtc, parseIsoUtc } from "./iso.js";
|
|
2
|
+
const EV_KEYS = new Set(["at", "refs", "status", "durationMs", "readings"]);
|
|
3
|
+
const REF_KEYS = new Set(["kind", "id", "url"]);
|
|
4
|
+
const isRec = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
5
|
+
const nonEmpty = (v) => typeof v === "string" && v.length > 0;
|
|
6
|
+
const isIntIn = (v, min, max) => typeof v === "number" && Number.isInteger(v) && v >= min && v <= max;
|
|
7
|
+
export function evidenceProblems(raw) {
|
|
8
|
+
if (!isRec(raw))
|
|
9
|
+
return ["evidence must be an object"];
|
|
10
|
+
const out = [];
|
|
11
|
+
for (const k of Object.keys(raw))
|
|
12
|
+
if (!EV_KEYS.has(k))
|
|
13
|
+
out.push(`unknown evidence key ${JSON.stringify(k)}`);
|
|
14
|
+
const { at, refs, status, durationMs, readings } = raw;
|
|
15
|
+
if (at !== undefined)
|
|
16
|
+
checkAt(at, out);
|
|
17
|
+
if (refs !== undefined)
|
|
18
|
+
checkRefs(refs, out);
|
|
19
|
+
if (status !== undefined && !isIntIn(status, 100, 599))
|
|
20
|
+
out.push(`status ${JSON.stringify(status)} is not an HTTP status`);
|
|
21
|
+
if (durationMs !== undefined && !isIntIn(durationMs, 0, Number.MAX_SAFE_INTEGER))
|
|
22
|
+
out.push(`durationMs ${JSON.stringify(durationMs)} is not a non-negative integer`);
|
|
23
|
+
if (readings !== undefined)
|
|
24
|
+
checkReadings(readings, out);
|
|
25
|
+
return out;
|
|
26
|
+
}
|
|
27
|
+
export function workEvidenceProblems(raw) {
|
|
28
|
+
if (!isRec(raw))
|
|
29
|
+
return ["evidence must be an object"];
|
|
30
|
+
const out = [];
|
|
31
|
+
for (const f of ["at", "durationMs"])
|
|
32
|
+
if (raw[f] !== undefined)
|
|
33
|
+
out.push(`work evidence must not carry ${f} (work time is startedAt/endedAt; the host measures actions)`);
|
|
34
|
+
return out.concat(evidenceProblems(raw));
|
|
35
|
+
}
|
|
36
|
+
function checkAt(at, out) {
|
|
37
|
+
if (typeof at !== "string")
|
|
38
|
+
return void out.push("at must be canonical UTC (YYYY-MM-DDTHH:MM:SS.sssZ)");
|
|
39
|
+
if (!isCanonicalIsoUtc(at)) {
|
|
40
|
+
const p = parseIsoUtc(at);
|
|
41
|
+
const ex = p !== undefined ? `, e.g. ${JSON.stringify(formatIsoUtc(p))}` : "";
|
|
42
|
+
out.push(`at ${JSON.stringify(at)} is not canonical UTC (use YYYY-MM-DDTHH:MM:SS.sssZ${ex})`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
function checkRefs(refs, out) {
|
|
46
|
+
if (!Array.isArray(refs))
|
|
47
|
+
return void out.push("refs must be an array");
|
|
48
|
+
for (const ref of refs) {
|
|
49
|
+
if (!isRec(ref)) {
|
|
50
|
+
out.push("a ref must be an object");
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
for (const k of Object.keys(ref))
|
|
54
|
+
if (!REF_KEYS.has(k))
|
|
55
|
+
out.push(`unknown ref key ${JSON.stringify(k)}`);
|
|
56
|
+
if (!nonEmpty(ref["kind"]))
|
|
57
|
+
out.push("a ref needs a non-empty kind");
|
|
58
|
+
for (const f of ["id", "url"])
|
|
59
|
+
if (ref[f] !== undefined && !nonEmpty(ref[f]))
|
|
60
|
+
out.push(`ref.${f} must be a non-empty string`);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function checkReadings(readings, out) {
|
|
64
|
+
if (!isRec(readings))
|
|
65
|
+
return void out.push("readings must be an object");
|
|
66
|
+
for (const [k, v] of Object.entries(readings)) {
|
|
67
|
+
if (!k)
|
|
68
|
+
out.push("reading key must be non-empty");
|
|
69
|
+
if (k === "durationMs")
|
|
70
|
+
out.push("readings must not carry durationMs; use evidence.durationMs (observers)");
|
|
71
|
+
if (typeof v !== "number" || !Number.isFinite(v))
|
|
72
|
+
out.push(`reading ${JSON.stringify(k)} is not a finite number`);
|
|
73
|
+
}
|
|
74
|
+
}
|
package/dist/iso.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/** Milliseconds since the epoch of an ISO-UTC instant, or undefined. Pure: telar's QuickJS has no `Date`. */
|
|
2
2
|
export declare function parseIsoUtc(value: string): number | undefined;
|
|
3
|
+
/** True iff `value` is the single canonical UTC form (`YYYY-MM-DDTHH:MM:SS.sssZ`) and a real instant. */
|
|
4
|
+
export declare function isCanonicalIsoUtc(value: string): boolean;
|
|
3
5
|
export declare function formatIsoUtc(ms: number): string;
|
|
4
6
|
/**
|
|
5
7
|
* The UTC offset of an IANA zone at an instant, in minutes, or undefined for an unknown zone.
|
package/dist/iso.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
const ISO_UTC_RE = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{3}))?Z$/;
|
|
2
|
+
const CANONICAL_ISO_UTC_RE = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/;
|
|
2
3
|
const DAY_MS = 86_400_000;
|
|
3
4
|
function daysFromCivil(year, month, day) {
|
|
4
5
|
const y = month <= 2 ? year - 1 : year;
|
|
@@ -48,6 +49,10 @@ export function parseIsoUtc(value) {
|
|
|
48
49
|
function pad(n, width = 2) {
|
|
49
50
|
return String(n).padStart(width, "0");
|
|
50
51
|
}
|
|
52
|
+
/** True iff `value` is the single canonical UTC form (`YYYY-MM-DDTHH:MM:SS.sssZ`) and a real instant. */
|
|
53
|
+
export function isCanonicalIsoUtc(value) {
|
|
54
|
+
return CANONICAL_ISO_UTC_RE.test(value) && parseIsoUtc(value) !== undefined;
|
|
55
|
+
}
|
|
51
56
|
export function formatIsoUtc(ms) {
|
|
52
57
|
const days = Math.floor(ms / DAY_MS);
|
|
53
58
|
const [year, month, day] = civilFromDays(days);
|
package/dist/node/build.d.ts
CHANGED
package/dist/node/build.js
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
1
2
|
const SDK_SPECIFIERS = ["telar/spec", "telar/std", "telar/scenario"];
|
|
2
3
|
const ROLLDOWN_PEER = "rolldown@^1.3.4";
|
|
4
|
+
const SDK_PACKAGE = "@aitoroses/telar";
|
|
5
|
+
export const SDK_STAMP = "// telar-sdk ";
|
|
6
|
+
function sdkVersion() {
|
|
7
|
+
for (const candidate of ["../package.json", "../../package.json"]) {
|
|
8
|
+
try {
|
|
9
|
+
const manifest = JSON.parse(readFileSync(new URL(candidate, import.meta.url), "utf8"));
|
|
10
|
+
if (typeof manifest === "object" &&
|
|
11
|
+
manifest !== null &&
|
|
12
|
+
"name" in manifest &&
|
|
13
|
+
manifest.name === SDK_PACKAGE &&
|
|
14
|
+
"version" in manifest &&
|
|
15
|
+
typeof manifest.version === "string") {
|
|
16
|
+
return manifest.version;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
continue;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
throw new Error(`telar-module cannot find its own ${SDK_PACKAGE} package.json`);
|
|
24
|
+
}
|
|
3
25
|
async function loadRolldown() {
|
|
4
26
|
try {
|
|
5
27
|
return (await import("rolldown")).rolldown;
|
|
@@ -26,7 +48,7 @@ export async function buildModule(entry) {
|
|
|
26
48
|
if (chunk === undefined || chunk.type !== "chunk" || rest.length > 0) {
|
|
27
49
|
throw new Error(`${entry} must bundle into one module`);
|
|
28
50
|
}
|
|
29
|
-
return chunk.code
|
|
51
|
+
return `${SDK_STAMP}${SDK_PACKAGE}@${sdkVersion()}\n${chunk.code}`;
|
|
30
52
|
}
|
|
31
53
|
finally {
|
|
32
54
|
await bundle.close();
|
package/dist/observer.d.ts
CHANGED
|
@@ -1,18 +1,9 @@
|
|
|
1
|
+
import type { Evidence, EvidenceRef } from "./evidence.js";
|
|
1
2
|
import type { WorldPowers } from "./powers.js";
|
|
2
3
|
import { type RunnerOptionValidation } from "./runner.js";
|
|
3
4
|
import type { StandardSchema } from "./standard-schema.js";
|
|
5
|
+
export type { Evidence, EvidenceRef };
|
|
4
6
|
export type ObserverId = `${string}/observe/${string}/${number}`;
|
|
5
|
-
export interface EvidenceRef {
|
|
6
|
-
readonly kind: string;
|
|
7
|
-
readonly id?: string;
|
|
8
|
-
readonly url?: string;
|
|
9
|
-
}
|
|
10
|
-
export interface Evidence {
|
|
11
|
-
readonly refs?: readonly EvidenceRef[];
|
|
12
|
-
readonly status?: number;
|
|
13
|
-
readonly durationMs?: number;
|
|
14
|
-
readonly readings?: Readonly<Record<string, number>>;
|
|
15
|
-
}
|
|
16
7
|
/** What the world says about a check: `ok: null` means "not yet" and writes nothing. */
|
|
17
8
|
export interface Observed {
|
|
18
9
|
readonly ok: boolean | null;
|
package/dist/powers.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export interface WorldNetworkRequest {
|
|
|
19
19
|
readonly method?: WorldHttpMethod;
|
|
20
20
|
readonly headers?: Readonly<Record<string, string>>;
|
|
21
21
|
readonly body?: string;
|
|
22
|
-
/** Secret
|
|
22
|
+
/** Secret reference ("env:NAME"), resolved in Rust after the matching (method, path) grant entry passes (HTTPS or loopback HTTP only). */
|
|
23
23
|
readonly bearerSecret?: string;
|
|
24
24
|
readonly timeoutMs?: number;
|
|
25
25
|
}
|
package/dist/protocol.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Guide } from "./guide.js";
|
|
2
2
|
import type { AckDef, AnyAuthClass, AnyMessageKind, AnyRole, ArgsForContract, CallActionEffectNode, CheckNeedNode, MessageKind, ProtocolTarget, Role, RoleBriefOverride, RoleViewOverride, SeatLabelsDef, StepBoundInput } from "./pieces.js";
|
|
3
|
-
import type { AnyContract, AnyStructContract, Brand, FieldHandlesOf, FieldSchemaMap, Infer, OptionalType, StructContract, StructFieldsOfContract, VariantsOf } from "./schema.js";
|
|
3
|
+
import type { AnyContract, AnyStructContract, Brand, CaseRef, FieldHandlesOf, FieldSchemaMap, Infer, OptionalType, StructContract, StructFieldsOfContract, VariantsOf } from "./schema.js";
|
|
4
4
|
import type { BriefPiece, NonEmpty, Rec, RecordMode } from "./types.js";
|
|
5
5
|
import { type FieldRef, type FieldTable, type RecordInput } from "./values.js";
|
|
6
6
|
type LabelsOfRole<R> = R extends Role<string, infer L> ? L : never;
|
|
@@ -51,6 +51,10 @@ export type Need = CheckNeedNode | {
|
|
|
51
51
|
readonly kind: "bound-reached-need";
|
|
52
52
|
readonly step: string;
|
|
53
53
|
readonly guide?: string;
|
|
54
|
+
} | {
|
|
55
|
+
readonly kind: "cases-ended-need";
|
|
56
|
+
readonly field: string;
|
|
57
|
+
readonly guide?: string;
|
|
54
58
|
} | {
|
|
55
59
|
readonly kind: "any-need";
|
|
56
60
|
readonly of: readonly [Need, Need, ...Need[]];
|
|
@@ -157,6 +161,10 @@ export declare function childrenEndedIn<F extends string>(target: Protocol<strin
|
|
|
157
161
|
readonly allowEmpty: boolean;
|
|
158
162
|
readonly guide?: Guide | undefined;
|
|
159
163
|
}): Need;
|
|
164
|
+
export declare function casesEnded(opts: {
|
|
165
|
+
readonly field: FieldRef<string, readonly CaseRef[] | undefined>;
|
|
166
|
+
readonly guide?: Guide | undefined;
|
|
167
|
+
}): Need;
|
|
160
168
|
export declare function received(msgKind: AnyMessageKind, opts: {
|
|
161
169
|
readonly from: AnyRole | NonEmpty<AnyRole>;
|
|
162
170
|
readonly guide?: Guide | undefined;
|
package/dist/protocol.js
CHANGED
|
@@ -96,6 +96,13 @@ export function childrenEndedIn(target, state, opts) {
|
|
|
96
96
|
...(opts.guide !== undefined ? { guide: opts.guide.template } : {}),
|
|
97
97
|
});
|
|
98
98
|
}
|
|
99
|
+
export function casesEnded(opts) {
|
|
100
|
+
return Object.freeze({
|
|
101
|
+
kind: "cases-ended-need",
|
|
102
|
+
field: opts.field.name,
|
|
103
|
+
...(opts.guide !== undefined ? { guide: opts.guide.template } : {}),
|
|
104
|
+
});
|
|
105
|
+
}
|
|
99
106
|
export function received(msgKind, opts) {
|
|
100
107
|
return Object.freeze({
|
|
101
108
|
kind: "message-need",
|
package/dist/runner.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { WorkEvidence } from "./evidence.js";
|
|
1
2
|
import type { WorldPowers } from "./powers.js";
|
|
2
3
|
import type { SeatKey } from "./seating.js";
|
|
3
4
|
import type { StandardSchema } from "./standard-schema.js";
|
|
@@ -19,25 +20,24 @@ export interface RunnerHolder {
|
|
|
19
20
|
readonly ref?: never;
|
|
20
21
|
readonly [key: string]: string | undefined;
|
|
21
22
|
}
|
|
22
|
-
export interface RunnerReadings {
|
|
23
|
-
readonly "tokens.input"?: number | undefined;
|
|
24
|
-
readonly "tokens.output"?: number | undefined;
|
|
25
|
-
readonly "tokens.cacheRead"?: number | undefined;
|
|
26
|
-
readonly "tokens.cacheWrite"?: number | undefined;
|
|
27
|
-
readonly usd?: number | undefined;
|
|
28
|
-
readonly durationMs?: number | undefined;
|
|
29
|
-
readonly [key: string]: number | undefined;
|
|
30
|
-
}
|
|
31
23
|
export interface RunnerWork {
|
|
32
24
|
readonly id: string;
|
|
33
25
|
readonly startedAt: string;
|
|
34
26
|
readonly endedAt: string;
|
|
35
|
-
readonly
|
|
27
|
+
readonly evidence?: WorkEvidence | undefined;
|
|
28
|
+
}
|
|
29
|
+
/** How a command in the runner's thread finds this seat without TELAR_SEAT (ADR 0051 §6). */
|
|
30
|
+
export interface RunnerIdentity {
|
|
31
|
+
/** An environment variable name the thread's commands can read, such as `BB_THREAD_ID`. */
|
|
32
|
+
readonly env: string;
|
|
33
|
+
/** Its value for this seat. */
|
|
34
|
+
readonly value: string;
|
|
36
35
|
}
|
|
37
36
|
export interface RunnerReport {
|
|
38
37
|
readonly ref: string;
|
|
39
38
|
readonly state: RunnerState;
|
|
40
39
|
readonly holder?: RunnerHolder;
|
|
40
|
+
readonly identity?: RunnerIdentity;
|
|
41
41
|
readonly work?: readonly RunnerWork[];
|
|
42
42
|
}
|
|
43
43
|
export interface RunnerWakeInput<Options = Readonly<Record<string, unknown>>> {
|
|
@@ -51,6 +51,7 @@ export interface RunnerPollInput<Options = Readonly<Record<string, unknown>>> {
|
|
|
51
51
|
readonly options: Options;
|
|
52
52
|
}
|
|
53
53
|
export interface RunnerEndInput<Options = Readonly<Record<string, unknown>>> {
|
|
54
|
+
readonly seat: RunnerSeatRef;
|
|
54
55
|
readonly ref: string;
|
|
55
56
|
readonly options: Options;
|
|
56
57
|
}
|
package/dist/runner.js
CHANGED
|
@@ -52,7 +52,7 @@ function readSeatRef(raw) {
|
|
|
52
52
|
typeof raw["installation"] !== "string" ||
|
|
53
53
|
typeof raw["seat"] !== "string" ||
|
|
54
54
|
typeof raw["role"] !== "string") {
|
|
55
|
-
throw new RunnerError("INVALID_INPUT", "runner:wake
|
|
55
|
+
throw new RunnerError("INVALID_INPUT", "runner:wake and runner:end require seat {installation, seat, role, binding}");
|
|
56
56
|
}
|
|
57
57
|
return {
|
|
58
58
|
installation: raw["installation"],
|
|
@@ -119,7 +119,7 @@ export function defineRunner(input) {
|
|
|
119
119
|
if (point === "runner:poll") {
|
|
120
120
|
return input.poll({ ref: args["ref"], options: validated.value }, powers);
|
|
121
121
|
}
|
|
122
|
-
input.end({ ref: args["ref"], options: validated.value }, powers);
|
|
122
|
+
input.end({ seat: readSeatRef(args["seat"]), ref: args["ref"], options: validated.value }, powers);
|
|
123
123
|
return {};
|
|
124
124
|
};
|
|
125
125
|
return Object.freeze({
|
package/dist/scenario/types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Evidence } from "../evidence.js";
|
|
1
2
|
import type { RunnerReport } from "../runner.js";
|
|
2
3
|
import type { Installation, JsonObject, NonEmpty, TelarSpecV1 } from "../spec.js";
|
|
3
4
|
type Rec<V = unknown> = Readonly<Record<string, V>>;
|
|
@@ -288,16 +289,6 @@ export interface RoleAvailabilityInput {
|
|
|
288
289
|
readonly available: boolean;
|
|
289
290
|
readonly reason?: string | undefined;
|
|
290
291
|
}
|
|
291
|
-
export interface CheckEvidenceInput {
|
|
292
|
-
readonly refs?: readonly {
|
|
293
|
-
readonly kind: string;
|
|
294
|
-
readonly id?: string | undefined;
|
|
295
|
-
readonly url?: string | undefined;
|
|
296
|
-
}[] | undefined;
|
|
297
|
-
readonly status?: number | undefined;
|
|
298
|
-
readonly durationMs?: number | undefined;
|
|
299
|
-
readonly readings?: Readonly<Record<string, number>> | undefined;
|
|
300
|
-
}
|
|
301
292
|
interface CheckEventBase {
|
|
302
293
|
readonly kind: "check";
|
|
303
294
|
readonly check: CheckInput;
|
|
@@ -308,7 +299,7 @@ export type WorldEventInput<Src extends string = string> = (CheckEventBase & {
|
|
|
308
299
|
readonly hint?: string | undefined;
|
|
309
300
|
readonly evidence?: undefined;
|
|
310
301
|
}) | (CheckEventBase & {
|
|
311
|
-
readonly evidence:
|
|
302
|
+
readonly evidence: Evidence;
|
|
312
303
|
readonly hint?: undefined;
|
|
313
304
|
}) | {
|
|
314
305
|
/** Polls one `config.sources` instance at the scenario clock (ADR 0047 decision 8). */
|
package/dist/scenario.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { absent, bindCase, bindMessage, bindSeatRef, contains, scenario, } from "./scenario/builder.js";
|
|
2
2
|
export { checkGateHappyPath, refusalPreservesState, type CheckGateStep, type CheckGateTemplateParams, type RefusalTemplateParams, } from "./scenario/templates.js";
|
|
3
|
-
export { ScenarioCompileError, type ActionStub, type AdoptInput, type AllAliases, type AnswerInput, type BindSeatInput, type BindStepOptions, type BoundCasesFrom, type BoundMessagesFrom, type BoundSeatsFrom, type CancelInput, type CaseBindingDescriptor, type CasePhase, type CheckInput, type CheckStub, type ClockInput, type ConfigInput, type CountExpect, type DebtExpect, type DebtReason, type EmptyBindings, type ExactStepExpect, type FieldInstructionExpect, type FieldProblemExpect, type LiteralAlias, type LiteralBindMap, type MessageBindingDescriptor, type MessageInput, type MessageKindInput, type NamedCheckRef, type NamedContractRef, type NamedMessageRef, type NamedProtocolRef, type NamedRoleRef, type NamespacedInput, type NetworkStub, type OpenInput, type ProcessStub, type ProtocolInput, type ReadInput, type ResultExpect, type RoleAvailabilityInput, type RoleDebtExpect, type RoleInput, type RunnerReportInput, type ScenarioBuilder, type ScenarioInit, type ScenarioIssue, type ScenarioStepV1, type ScopeAliasMap, type ScriptedSeatReply, type SeatBindingDescriptor, type SeatDebtExpect, type ShapeInput, type SpecInput, type StepBindMap, type StepBindingDescriptor, type StepExpect, type StepOptions, type TelarScenarioV1, type TrailExpect, type TrailMatcher, type ViewExpect, type WorldConfig, type WorldEventInput, type
|
|
3
|
+
export { ScenarioCompileError, type ActionStub, type AdoptInput, type AllAliases, type AnswerInput, type BindSeatInput, type BindStepOptions, type BoundCasesFrom, type BoundMessagesFrom, type BoundSeatsFrom, type CancelInput, type CaseBindingDescriptor, type CasePhase, type CheckInput, type CheckStub, type ClockInput, type ConfigInput, type CountExpect, type DebtExpect, type DebtReason, type EmptyBindings, type ExactStepExpect, type FieldInstructionExpect, type FieldProblemExpect, type LiteralAlias, type LiteralBindMap, type MessageBindingDescriptor, type MessageInput, type MessageKindInput, type NamedCheckRef, type NamedContractRef, type NamedMessageRef, type NamedProtocolRef, type NamedRoleRef, type NamespacedInput, type NetworkStub, type OpenInput, type ProcessStub, type ProtocolInput, type ReadInput, type ResultExpect, type RoleAvailabilityInput, type RoleDebtExpect, type RoleInput, type RunnerReportInput, type ScenarioBuilder, type ScenarioInit, type ScenarioIssue, type ScenarioStepV1, type ScopeAliasMap, type ScriptedSeatReply, type SeatBindingDescriptor, type SeatDebtExpect, type ShapeInput, type SpecInput, type StepBindMap, type StepBindingDescriptor, type StepExpect, type StepOptions, type TelarScenarioV1, type TrailExpect, type TrailMatcher, type ViewExpect, type WorldConfig, type WorldEventInput, type WorldExpect, } from "./scenario/types.js";
|
|
4
4
|
export { stepById, stepIdOf } from "./scenario/validate.js";
|
package/dist/schema.d.ts
CHANGED
|
@@ -211,6 +211,8 @@ export declare const t: {
|
|
|
211
211
|
readonly optional: <S extends AnyTypeDef>(schema: S) => OptionalType<S>;
|
|
212
212
|
readonly ref: <T = unknown>(schema: string, opts?: AnnotationsInput) => TypeDef<T>;
|
|
213
213
|
};
|
|
214
|
+
export type CaseRef = Brand<string, "CaseRef">;
|
|
215
|
+
export declare const caseRef: TypeDef<CaseRef>;
|
|
214
216
|
type VariantOfTypeDef<S> = S extends TaggedStructType<infer Tag, FieldSchemaMap, string> ? Tag : S extends {
|
|
215
217
|
readonly [variantSymbol]?: infer V;
|
|
216
218
|
} ? V : never;
|
package/dist/schema.js
CHANGED
|
@@ -195,6 +195,12 @@ export const t = Object.freeze({
|
|
|
195
195
|
return Object.freeze({ kind: "type", node });
|
|
196
196
|
},
|
|
197
197
|
});
|
|
198
|
+
export const caseRef = t.string({
|
|
199
|
+
nonEmpty: true,
|
|
200
|
+
brand: "CaseRef",
|
|
201
|
+
audience: "agent",
|
|
202
|
+
description: "Id of another case",
|
|
203
|
+
});
|
|
198
204
|
export function contract(name, shape, opts) {
|
|
199
205
|
if (isAnyTypeDef(shape)) {
|
|
200
206
|
return Object.freeze({
|
package/dist/seating.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { AnyRunner, RunnerIdOf, RunnerOptionsOf } from "./runner.js";
|
|
2
|
-
export type SeatBindingChoice = "all" | "scope" | "case";
|
|
3
2
|
/** The key a seat is bound by, as `seat-bound.binding` records it in `telar.trail/1`. */
|
|
4
3
|
export type SeatKey = {
|
|
5
4
|
readonly kind: "case";
|
|
@@ -26,7 +25,6 @@ export type RunnerChoice<Runners extends readonly AnyRunner[] = readonly []> = I
|
|
|
26
25
|
};
|
|
27
26
|
export type SeatRunner<Runners extends readonly AnyRunner[] = readonly []> = RunnerIdOf<Runners[number]>;
|
|
28
27
|
export interface RoleSeatingBase {
|
|
29
|
-
readonly binding?: SeatBindingChoice | undefined;
|
|
30
28
|
readonly manual?: boolean | undefined;
|
|
31
29
|
}
|
|
32
30
|
/** How `telar host` seats one role. Unset fields fall back to the seating's own. */
|
package/dist/spec.d.ts
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
export { PluginCallError, defineInstallation, type AdmissionProblem, type ConfiguredInstallation, type DeclareFrame, type DefineInstallationInput, type DefinedInstallation, type InstallationCallReply, type InstallationConfigBase, type InstallationTest, type SeatingFor, type SourcesFor, type TrailProof, } from "./install.js";
|
|
2
2
|
export { SpecCompileError, compile, installation, type Installation, type InstallationInput, type RosterInput, } from "./compile.js";
|
|
3
3
|
export { guide, type Guide } from "./guide.js";
|
|
4
|
-
export { mergeSeating, type InstalledRunnerChoice, type RoleSeating, type RoleSeatingBase, type RunnerChoice, type RunnerOptions, type
|
|
5
|
-
export { RunnerError, defineRunner, isValidRunnerId, validateRunnerOptions, type AnyRunner, type DefineRunnerInput, type Runner, type RunnerEndInput, type RunnerId, type RunnerIdOf, type RunnerHolder, type RunnerOptionIssue, type RunnerOptionValidation, type RunnerOptionsOf, type RunnerPoint, type RunnerPollInput, type
|
|
4
|
+
export { mergeSeating, type InstalledRunnerChoice, type RoleSeating, type RoleSeatingBase, type RunnerChoice, type RunnerOptions, type SeatKey, type SeatRunner, type Seating, } from "./seating.js";
|
|
5
|
+
export { RunnerError, defineRunner, isValidRunnerId, validateRunnerOptions, type AnyRunner, type DefineRunnerInput, type Runner, type RunnerEndInput, type RunnerId, type RunnerIdOf, type RunnerHolder, type RunnerIdentity, type RunnerOptionIssue, type RunnerOptionValidation, type RunnerOptionsOf, type RunnerPoint, type RunnerPollInput, type RunnerReport, type RunnerSeatRef, type RunnerState, type RunnerWakeInput, type RunnerWork, type StandardValidation, validateStandard, } from "./runner.js";
|
|
6
6
|
export type { StandardSchema, StandardSchemaIssue, StandardSchemaIssuePath, StandardSchemaResult, } from "./standard-schema.js";
|
|
7
|
-
export {
|
|
8
|
-
export {
|
|
7
|
+
export { evidenceProblems, workEvidenceProblems, type Evidence, type EvidenceRef, type Readings, type WorkEvidence, } from "./evidence.js";
|
|
8
|
+
export { formatIsoUtc, isCanonicalIsoUtc, parseIsoUtc, zoneOffset } from "./iso.js";
|
|
9
|
+
export { ObserverError, defineObserver, isValidObserverId, type AnyObserver, type DefineObserverInput, type ObserveInput, type Observed, type Observer, type ObserverId, } from "./observer.js";
|
|
9
10
|
export { PowerError, hostWorldPowers, type WorldHttpMethod, type WorldNetworkRequest, type WorldNetworkResponse, type WorldPowers, type WorldProcessRequest, type WorldProcessResult, } from "./powers.js";
|
|
10
11
|
export { fakeRead, type FakeReadSeat, type Read, type ReadSeatsFilter } from "./read.js";
|
|
11
12
|
export { SourceError, defineSource, isValidSourceId, type AnySource, type DefineSourceInput, type Source, type SourceEvent, type SourceEventData, type SourceEventFields, type SourceChoice, type SourceEventIssue, type SourceFieldsOf, type SourceIdOf, type SourceOptionsOf, type SourcesConfig, type SourceId, type SourceLast, type SourcePollInput, type SourcePollReply, } from "./source.js";
|
|
12
13
|
export { EvaluatorError, defineEvaluator, isValidEvaluatorId, type AnyEvaluator, type Evaluation, type EvaluatorArgs, type EvaluatorId, type Evaluator, type StdEvaluatorId, } from "./evaluator.js";
|
|
13
14
|
export { QueryError, bindQuery, decodeQueryRows, defineQuery, type NoQueryArgs, type Query, type QueryArg, type QueryArgInput, type QueryArgs, type QueryBinding, type QueryParam, type QueryRowIssue, type QueryRowIssuePath, type QueryRowResult, type QueryRowSchema, } from "./query.js";
|
|
14
15
|
export { ack, ActionError, bound, check, defineAction, defineClass, isValidActionId, message, msg, openOnMiss, redeliver, role, roleBrief, roleView, type AckDef, type Action, type ActionId, type AnyAction, type AnyAuthClass, type AnyCheck, type AnyMessageKind, type AnyNamedBound, type AnyRole, type ArgsForContract, type AuthClass, type BoundByFieldInput, type BoundSpecInput, type CallActionEffectNode, type Check, type CheckNeedNode, type DelegationInput, type InlineBound, type MessageArgRef, type MessageKind, type MissActionDef, type MissArgInput, type NamedBound, type ProtocolTarget, type Role, type RunnableAction, type RoleBriefOverride, type RoleViewOverride, type SeatLabelsDef, type StepBoundInput, } from "./pieces.js";
|
|
15
|
-
export { answer, anyOf, append, authorize, boundReached, childrenEnded, childrenEndedIn, childrenIn, emit, openChild, protocol, protocolRef, received, set, step, withGuide, type AnswerNeedOpts, type AnyProtocol, type AnyProtocolRef, type AnyStep, type ChildFilterInput, type Effect, type FieldHandlesOfProtocolData, type Need, type Protocol, type ProtocolAckOverride, type ProtocolDataInput, type ProtocolRef, type SeatLabelReq, type Step, } from "./protocol.js";
|
|
16
|
-
export { contract, t, type AnnotationsInput, type AnyContract, type AnyFieldSchemaEntry, type AnyStructContract, type AnyStructType, type AnyTaggedStruct, type AnyTypeDef, type AnyUnionType, type ArrayOpts, type BooleanOpts, type Brand, type Contract, type FieldHandlesOf, type FieldSchemaMap, type FlattenedUnionType, type Infer, type InferStruct, type NumberOpts, type OptionalType, type StringOpts, type StructContract, type StructGuideOpts, type StructOpts, type StructType, type TaggedGuideOpts, type TaggedOpts, type TaggedStructType, type TypeDef, type UnionMemberInput, type UnionOpts, type UnionType, type VariantsOf, } from "./schema.js";
|
|
16
|
+
export { answer, anyOf, append, authorize, boundReached, casesEnded, childrenEnded, childrenEndedIn, childrenIn, emit, openChild, protocol, protocolRef, received, set, step, withGuide, type AnswerNeedOpts, type AnyProtocol, type AnyProtocolRef, type AnyStep, type ChildFilterInput, type Effect, type FieldHandlesOfProtocolData, type Need, type Protocol, type ProtocolAckOverride, type ProtocolDataInput, type ProtocolRef, type SeatLabelReq, type Step, } from "./protocol.js";
|
|
17
|
+
export { caseRef, contract, t, type AnnotationsInput, type AnyContract, type AnyFieldSchemaEntry, type AnyStructContract, type AnyStructType, type AnyTaggedStruct, type AnyTypeDef, type AnyUnionType, type ArrayOpts, type BooleanOpts, type Brand, type CaseRef, type Contract, type FieldHandlesOf, type FieldSchemaMap, type FlattenedUnionType, type Infer, type InferStruct, type NumberOpts, type OptionalType, type StringOpts, type StructContract, type StructGuideOpts, type StructOpts, type StructType, type TaggedGuideOpts, type TaggedOpts, type TaggedStructType, type TypeDef, type UnionMemberInput, type UnionOpts, type UnionType, type VariantsOf, } from "./schema.js";
|
|
17
18
|
export type { ActionDecl, ArgValue, Audience, BoundByFieldDecl, BoundDecl, BoundRefDecl, BriefPiece, CheckDecl, CheckObserveDecl, ChildFilterDecl, ClassDecl, DelegationDecl, EffectDecl, EffortLevel, EngineManagedFieldPolicy, FallbackSeatBindingDecl, FieldByFieldDecl, GitGrantDecl, GranteeGrantsDecl, HooksDecl, HttpMethod, JsonObject, JsonPrimitive, JsonValue, MessageDecl, MessageFieldName, MissActionDecl, MissArgDecl, NeedDecl, NetworkGrantDecl, NetworkScheme, NonEmpty, ProcessGrantDecl, ProtocolDecl, RecordMode, RootGrantDecl, RoleBindingDecl, RoleDecl, RosterDecl, SchemaAnnotations, SeatBindingDecl, SeatLabelNeedDecl, SeatLabelsDecl, SpecAckDecl, StepBoundDecl, StepDecl, StructFieldDecl, TelarSpecV1, TypeSchema, ViewKind, ViewPolicyDecl, } from "./types.js";
|
|
18
19
|
export { cause, engine, field, fields, fromAnswer, literal, seat, type AnswerRef, type AnyArgRef, type ArgInput, type ArgMapInput, type CauseRef, type EngineByFieldOpts, type EngineDigestOpts, type EngineFieldDef, type EngineFieldOpts, type FieldRef, type FieldTable, type LiteralRef, type ProtocolFieldEntry, type ProtocolFieldMap, type RecordInput, type SeatRef, } from "./values.js";
|
|
19
20
|
export { decodeSendHookArgs, decodeSendVerdict, type SendHookArgs, type SendHookCase, type SendHookSeat, type SendHookSubject, type SendOrigin, type SendVerdict, } from "./send-hook.js";
|
package/dist/spec.js
CHANGED
|
@@ -3,7 +3,8 @@ export { SpecCompileError, compile, installation, } from "./compile.js";
|
|
|
3
3
|
export { guide } from "./guide.js";
|
|
4
4
|
export { mergeSeating, } from "./seating.js";
|
|
5
5
|
export { RunnerError, defineRunner, isValidRunnerId, validateRunnerOptions, validateStandard, } from "./runner.js";
|
|
6
|
-
export {
|
|
6
|
+
export { evidenceProblems, workEvidenceProblems, } from "./evidence.js";
|
|
7
|
+
export { formatIsoUtc, isCanonicalIsoUtc, parseIsoUtc, zoneOffset } from "./iso.js";
|
|
7
8
|
export { ObserverError, defineObserver, isValidObserverId, } from "./observer.js";
|
|
8
9
|
export { PowerError, hostWorldPowers, } from "./powers.js";
|
|
9
10
|
export { fakeRead } from "./read.js";
|
|
@@ -11,7 +12,7 @@ export { SourceError, defineSource, isValidSourceId, } from "./source.js";
|
|
|
11
12
|
export { EvaluatorError, defineEvaluator, isValidEvaluatorId, } from "./evaluator.js";
|
|
12
13
|
export { QueryError, bindQuery, decodeQueryRows, defineQuery, } from "./query.js";
|
|
13
14
|
export { ack, ActionError, bound, check, defineAction, defineClass, isValidActionId, message, msg, openOnMiss, redeliver, role, roleBrief, roleView, } from "./pieces.js";
|
|
14
|
-
export { answer, anyOf, append, authorize, boundReached, childrenEnded, childrenEndedIn, childrenIn, emit, openChild, protocol, protocolRef, received, set, step, withGuide, } from "./protocol.js";
|
|
15
|
-
export { contract, t, } from "./schema.js";
|
|
15
|
+
export { answer, anyOf, append, authorize, boundReached, casesEnded, childrenEnded, childrenEndedIn, childrenIn, emit, openChild, protocol, protocolRef, received, set, step, withGuide, } from "./protocol.js";
|
|
16
|
+
export { caseRef, contract, t, } from "./schema.js";
|
|
16
17
|
export { cause, engine, field, fields, fromAnswer, literal, seat, } from "./values.js";
|
|
17
18
|
export { decodeSendHookArgs, decodeSendVerdict, } from "./send-hook.js";
|
package/dist/std/actions.d.ts
CHANGED
package/dist/std/actions.js
CHANGED
|
@@ -118,7 +118,6 @@ const gitPush = declareAction({
|
|
|
118
118
|
const githubApi = {
|
|
119
119
|
apiScheme: scheme(),
|
|
120
120
|
apiAuthority: t.optional(t.string({ nonEmpty: true })),
|
|
121
|
-
secretRef: t.optional(t.string({ nonEmpty: true })),
|
|
122
121
|
};
|
|
123
122
|
const githubChecks = declareAction({
|
|
124
123
|
id: "telar.std/action/github-checks/1",
|
package/dist/std/claude-code.js
CHANGED
|
@@ -56,7 +56,6 @@ function extractReadings(parsed) {
|
|
|
56
56
|
out[k] = v;
|
|
57
57
|
};
|
|
58
58
|
put("usd", optNum(parsed, "total_cost_usd"));
|
|
59
|
-
put("durationMs", optNum(parsed, "duration_ms"));
|
|
60
59
|
const usage = parsed["usage"];
|
|
61
60
|
if (isRec(usage))
|
|
62
61
|
for (const [s, d] of USAGE_KEYS)
|
|
@@ -94,11 +93,19 @@ export const claudeCodeRunner = defineRunner({
|
|
|
94
93
|
};
|
|
95
94
|
const id = optStr(parsed, "uuid") ?? `${runnerRef}:${out.startedAt}`;
|
|
96
95
|
const readings = extractReadings(parsed);
|
|
96
|
+
const evidence = Object.keys(readings).length > 0 ? { readings } : undefined;
|
|
97
97
|
return {
|
|
98
98
|
ref: runnerRef,
|
|
99
99
|
state: "idle",
|
|
100
100
|
holder,
|
|
101
|
-
work: [
|
|
101
|
+
work: [
|
|
102
|
+
{
|
|
103
|
+
id,
|
|
104
|
+
startedAt: out.startedAt,
|
|
105
|
+
endedAt: out.endedAt,
|
|
106
|
+
...(evidence !== undefined ? { evidence } : {}),
|
|
107
|
+
},
|
|
108
|
+
],
|
|
102
109
|
};
|
|
103
110
|
},
|
|
104
111
|
poll: ({ ref }) => ({ ref, state: "idle" }),
|
|
@@ -7,7 +7,6 @@ export interface GithubChecksEntry {
|
|
|
7
7
|
readonly head?: string;
|
|
8
8
|
readonly apiScheme?: "http" | "https";
|
|
9
9
|
readonly apiAuthority?: string;
|
|
10
|
-
readonly secretRef?: string;
|
|
11
10
|
}
|
|
12
11
|
/** Direct GitHub repo config or a table keyed by the check's `repo`. */
|
|
13
12
|
export type GithubChecksParams = GithubChecksEntry | {
|
|
@@ -16,7 +15,6 @@ export type GithubChecksParams = GithubChecksEntry | {
|
|
|
16
15
|
readonly head?: string;
|
|
17
16
|
readonly apiScheme?: "http" | "https";
|
|
18
17
|
readonly apiAuthority?: string;
|
|
19
|
-
readonly secretRef?: string;
|
|
20
18
|
};
|
|
21
19
|
export declare const GITHUB_CHECKS_OBSERVER_ID = "telar.std/observe/github-checks/1";
|
|
22
20
|
/**
|
|
@@ -46,15 +46,12 @@ function parseEntry(raw, path) {
|
|
|
46
46
|
const head = optStr(raw, "head", path);
|
|
47
47
|
const scheme = optScheme(raw, path);
|
|
48
48
|
const authority = optStr(raw, "apiAuthority", path);
|
|
49
|
-
const sec = optStr(raw, "secretRef", path);
|
|
50
49
|
if ("issues" in head)
|
|
51
50
|
return head;
|
|
52
51
|
if ("issues" in scheme)
|
|
53
52
|
return scheme;
|
|
54
53
|
if ("issues" in authority)
|
|
55
54
|
return authority;
|
|
56
|
-
if ("issues" in sec)
|
|
57
|
-
return sec;
|
|
58
55
|
return {
|
|
59
56
|
value: {
|
|
60
57
|
owner,
|
|
@@ -63,7 +60,6 @@ function parseEntry(raw, path) {
|
|
|
63
60
|
...head.value,
|
|
64
61
|
...scheme.value,
|
|
65
62
|
...authority.value,
|
|
66
|
-
...sec.value,
|
|
67
63
|
},
|
|
68
64
|
};
|
|
69
65
|
}
|
|
@@ -73,15 +69,12 @@ function parseParams(raw) {
|
|
|
73
69
|
const head = optStr(raw, "head", []);
|
|
74
70
|
const scheme = optScheme(raw, []);
|
|
75
71
|
const authority = optStr(raw, "apiAuthority", []);
|
|
76
|
-
const sec = optStr(raw, "secretRef", []);
|
|
77
72
|
if ("issues" in head)
|
|
78
73
|
return head;
|
|
79
74
|
if ("issues" in scheme)
|
|
80
75
|
return scheme;
|
|
81
76
|
if ("issues" in authority)
|
|
82
77
|
return authority;
|
|
83
|
-
if ("issues" in sec)
|
|
84
|
-
return sec;
|
|
85
78
|
if ("byRepo" in raw) {
|
|
86
79
|
const rawTable = raw["byRepo"];
|
|
87
80
|
if (!isRec(rawTable)) {
|
|
@@ -108,7 +101,6 @@ function parseParams(raw) {
|
|
|
108
101
|
...head.value,
|
|
109
102
|
...scheme.value,
|
|
110
103
|
...authority.value,
|
|
111
|
-
...sec.value,
|
|
112
104
|
},
|
|
113
105
|
};
|
|
114
106
|
}
|
|
@@ -130,12 +122,11 @@ function selectEntry(p, args) {
|
|
|
130
122
|
}
|
|
131
123
|
return entry;
|
|
132
124
|
}
|
|
133
|
-
function getGithubJson(powers, url
|
|
125
|
+
function getGithubJson(powers, url) {
|
|
134
126
|
const resp = powers.network({
|
|
135
127
|
url,
|
|
136
128
|
method: "GET",
|
|
137
129
|
headers: { Accept: "application/vnd.github+json", "User-Agent": "telar-std" },
|
|
138
|
-
...(secretRef !== undefined ? { bearerSecret: secretRef } : {}),
|
|
139
130
|
});
|
|
140
131
|
if (resp.status < 200 || resp.status >= 300) {
|
|
141
132
|
throw new ObserverError("GITHUB_API_ERROR", `GitHub API error (status ${String(resp.status)}): ${resp.body}`);
|
|
@@ -275,12 +266,11 @@ export const githubChecksObserver = defineObserver({
|
|
|
275
266
|
}
|
|
276
267
|
const scheme = entry.apiScheme ?? p.apiScheme ?? "https";
|
|
277
268
|
const authority = nonEmpty(entry.apiAuthority) ?? nonEmpty(p.apiAuthority) ?? "api.github.com";
|
|
278
|
-
const secretRef = nonEmpty(entry.secretRef) ?? nonEmpty(p.secretRef);
|
|
279
269
|
const base = `${scheme}://${authority}/repos/${entry.owner}/${entry.name}/commits/${head}`;
|
|
280
270
|
const states = new Map();
|
|
281
271
|
const runs = [];
|
|
282
|
-
collectCheckRuns(getGithubJson(powers, `${base}/check-runs
|
|
283
|
-
collectStatuses(getGithubJson(powers, `${base}/status
|
|
272
|
+
collectCheckRuns(getGithubJson(powers, `${base}/check-runs`), states, runs);
|
|
273
|
+
collectStatuses(getGithubJson(powers, `${base}/status`), states, runs);
|
|
284
274
|
let allGreen = true;
|
|
285
275
|
for (const reqName of entry.required) {
|
|
286
276
|
const st = states.get(reqName);
|
|
@@ -31,6 +31,18 @@ function optStr(raw, key, path) {
|
|
|
31
31
|
? { value: { [key]: value } }
|
|
32
32
|
: { issues: [{ path: [...path, key], message: `${key} must be a string` }] };
|
|
33
33
|
}
|
|
34
|
+
const ENV_SECRET_REF_RE = /^env:[A-Za-z_][A-Za-z0-9_]*$/;
|
|
35
|
+
function optSecretRef(raw, path) {
|
|
36
|
+
const value = raw["secretRef"];
|
|
37
|
+
if (value === undefined)
|
|
38
|
+
return { value: {} };
|
|
39
|
+
if (typeof value === "string" && ENV_SECRET_REF_RE.test(value)) {
|
|
40
|
+
return { value: { secretRef: value } };
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
issues: [{ path: [...path, "secretRef"], message: 'secretRef must have the form "env:NAME"' }],
|
|
44
|
+
};
|
|
45
|
+
}
|
|
34
46
|
function parseEntry(raw, path) {
|
|
35
47
|
if (!isRec(raw))
|
|
36
48
|
return { issues: [{ path, message: "an http-status entry must be an object" }] };
|
|
@@ -52,7 +64,7 @@ function parseEntry(raw, path) {
|
|
|
52
64
|
}
|
|
53
65
|
const vf = optStr(raw, "versionField", path);
|
|
54
66
|
const head = optStr(raw, "head", path);
|
|
55
|
-
const sec =
|
|
67
|
+
const sec = optSecretRef(raw, path);
|
|
56
68
|
if ("issues" in vf)
|
|
57
69
|
return vf;
|
|
58
70
|
if ("issues" in head)
|
|
@@ -79,7 +91,7 @@ function parseParams(raw) {
|
|
|
79
91
|
if (!isRec(raw))
|
|
80
92
|
return { issues: [{ path: [], message: "params must be an object" }] };
|
|
81
93
|
const head = optStr(raw, "head", []);
|
|
82
|
-
const sec =
|
|
94
|
+
const sec = optSecretRef(raw, []);
|
|
83
95
|
if ("issues" in head)
|
|
84
96
|
return head;
|
|
85
97
|
if ("issues" in sec)
|
package/dist/types.d.ts
CHANGED
|
@@ -198,6 +198,10 @@ export type NeedDecl = {
|
|
|
198
198
|
readonly kind: "bound-reached";
|
|
199
199
|
readonly step: string;
|
|
200
200
|
readonly guide?: string;
|
|
201
|
+
} | {
|
|
202
|
+
readonly kind: "cases-ended";
|
|
203
|
+
readonly field: string;
|
|
204
|
+
readonly guide?: string;
|
|
201
205
|
};
|
|
202
206
|
export type EffectDecl = {
|
|
203
207
|
readonly kind: "record-data";
|