@supa-media/tex-contract 0.6.0 → 0.13.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/LICENSE +682 -21
- package/README.md +12 -0
- package/package.json +1 -1
- package/texContract/doorBatch.cjs +35 -0
- package/texContract/doorBatch.d.cts +7 -0
- package/texContract/identity.cjs +2 -1
- package/texContract/instructionsNote.cjs +214 -0
- package/texContract/instructionsNote.d.cts +22 -0
- package/texContract/lineRoutes.cjs +37 -0
- package/texContract/lineRoutes.d.cts +17 -0
- package/texContract/membersSeal.cjs +202 -0
- package/texContract/membersSeal.d.cts +13 -0
- package/texContract/shownEmail.cjs +1 -1
- package/texContract/texGraph.cjs +1 -1
- package/texContract/toolCatalog.generated.json +3 -3
- package/texShared/jobStart.cjs +1 -1
- package/texShared/models/promptBudget.cjs +203 -29
package/README.md
CHANGED
|
@@ -26,6 +26,18 @@ Since 0.5.0:
|
|
|
26
26
|
|
|
27
27
|
- `texContract/labLedger.cjs` (with its types) names the Lab's read-only ledger door, `tex_lab_ledger`: one op, `read`, with `owner` (`{ person }` or `{ chat }`) and that owner's own `chat` (`labLedgerChatOf`). It reaches the chats the Lab page shows the developer, their own, their group chats and the ones shared with developers, which `tex_ledger` cannot, and the gateway asks the control plane on the caller's token before it opens one.
|
|
28
28
|
|
|
29
|
+
Since 0.7.0:
|
|
30
|
+
|
|
31
|
+
- `texShared/models/promptBudget.cjs` keeps a reserved share for the newest history (`HISTORY_RESERVE`) so a system prompt over the cut no longer drops every earlier turn.
|
|
32
|
+
|
|
33
|
+
Since 0.8.0:
|
|
34
|
+
|
|
35
|
+
- `texContract/membersSeal.cjs` (with its types) reads a group chat's members log from its ledger's `members` steps (`membersSnapshot`) and seals what readers outside a turn see (`roomSealOf`, `sealedAnswer`, `sealedThreadIds`). It leaves out anything said while someone in the chat now was away, unless a member released it to them, and strips the plain hashes `from.who` and `people`.
|
|
36
|
+
|
|
37
|
+
Since 0.9.0:
|
|
38
|
+
|
|
39
|
+
- `texContract/doorBatch.cjs` (with its types) names the door's batch: `BATCH_PATH` (`/tex-mcp/batch`), `BATCH_METHOD`, `MAX_BATCH_CALLS` (16) and `NOT_BATCHED`. Several calls of one turn go in one request, so the door resolves the token, opens the storage binding and opens and saves the turn once for all of them. Each entry answers `{ result }` or `{ error: { status, code } }`; a call to an outside service answers `not_batched` and goes alone, and a gateway without the path answers 404. Since 0.10.0, `params.stream: true` asks for `STREAM_CONTENT_TYPE` (NDJSON): each entry's `{ at, result }` or `{ at, error }` as soon as it has answered and its marks are kept, then `{ done: true }`. An older gateway answers JSON as before, so read the answer by its content type.
|
|
40
|
+
|
|
29
41
|
The contract carries facts, never Tex's wording, and Tex's titles, lines and judge questions stay in Tex.
|
|
30
42
|
|
|
31
43
|
The snapshots are written by `node scripts/tex-contract/snapshot.mjs [--tex <Tex checkout>]`, and `--check` fails when they are stale. When Tex adds a model step or changes what a person can get it to do, it runs the snapshot against its checkout and a Context pull request bumps the contract.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@supa-media/tex-contract",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.0",
|
|
4
4
|
"description": "The contract Context's gateway and Tex both keep: tool names, the MCP catalog snapshot, wire formats and the shared readings Tex takes with it",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Several calls to Context's door in one request (`apps/mcp/src/http/texMcpBatch.js`): how Tex's Worker sends the calls
|
|
3
|
+
* one turn makes together, so the door resolves the token, opens the storage binding and opens and saves the turn once
|
|
4
|
+
* for all of them instead of once each.
|
|
5
|
+
*
|
|
6
|
+
* `POST BATCH_PATH` on the `TexMcp` binding, the person's own grant token in `Authorization: Bearer`, body
|
|
7
|
+
* `{ jsonrpc: "2.0", id, method: BATCH_METHOD, params: { calls, _meta } }`:
|
|
8
|
+
*
|
|
9
|
+
* - `calls`: 1 to `MAX_BATCH_CALLS` entries, each `{ kind: "call", name, arguments, legacy? }` (a tool, as
|
|
10
|
+
* `/tex-mcp/call`), `{ kind: "action", name, arguments }` (a Tex action, as `/tex-mcp/action`) or
|
|
11
|
+
* `{ kind: "list", shape? }` (`tools/list`).
|
|
12
|
+
* - `_meta`: the batch's one turn meta (`turn`, `ownRun`, `mailTurn`, `search`), as a single call carries it.
|
|
13
|
+
*
|
|
14
|
+
* The answer is `{ result: { answers } }`, one per entry in order: `{ result }`, or `{ error: { status, code } }` with
|
|
15
|
+
* the status and code that entry's single request would have been refused with. `not_batched` (400) means send that
|
|
16
|
+
* call alone (a call to an outside service). A refusal of the whole request (no token, no read scope, a bad body) is
|
|
17
|
+
* an HTTP status as on the single paths; a gateway without this path answers 404, and the caller sends each call alone.
|
|
18
|
+
*
|
|
19
|
+
* STREAMED ANSWERS (since 0.10.0). With `params.stream: true` the answer is `STREAM_CONTENT_TYPE` instead: one JSON
|
|
20
|
+
* object per line, each entry's `{ at, result }` or `{ at, error: { status, code } }` as soon as that entry has
|
|
21
|
+
* answered and what it marked on the turn is kept, in the order they finish (`at` is its index in `calls`), then
|
|
22
|
+
* `{ done: true }` last. A fast call is never held back by a slow one beside it. A stream that ends without `done`
|
|
23
|
+
* broke: an entry it did not answer may have run, so it is not sent again. A gateway older than 0.10.0 ignores
|
|
24
|
+
* `stream` and answers the whole batch as JSON, so a caller reads the answer by its content type.
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
"use strict";
|
|
28
|
+
|
|
29
|
+
const BATCH_PATH = "/tex-mcp/batch";
|
|
30
|
+
const BATCH_METHOD = "tools/batch";
|
|
31
|
+
const MAX_BATCH_CALLS = 16;
|
|
32
|
+
const NOT_BATCHED = "not_batched";
|
|
33
|
+
const STREAM_CONTENT_TYPE = "application/x-ndjson";
|
|
34
|
+
|
|
35
|
+
module.exports = { BATCH_PATH, BATCH_METHOD, MAX_BATCH_CALLS, NOT_BATCHED, STREAM_CONTENT_TYPE };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Types for `doorBatch.cjs`; see that file for the wire. */
|
|
2
|
+
|
|
3
|
+
export declare const BATCH_PATH: "/tex-mcp/batch";
|
|
4
|
+
export declare const BATCH_METHOD: "tools/batch";
|
|
5
|
+
export declare const MAX_BATCH_CALLS: number;
|
|
6
|
+
export declare const NOT_BATCHED: "not_batched";
|
|
7
|
+
export declare const STREAM_CONTENT_TYPE: "application/x-ndjson";
|
package/texContract/identity.cjs
CHANGED
|
@@ -166,7 +166,8 @@ function contextsFor(session) {
|
|
|
166
166
|
current: entry.workspaceId === session.workspaceId,
|
|
167
167
|
canWrite: reach.canWrite,
|
|
168
168
|
grantWrites: reach.grantWrites,
|
|
169
|
-
tier
|
|
169
|
+
// A group asker's own personal workspace reads at the grant's tier and opens none of its notes to the chat (P-8).
|
|
170
|
+
tier: reach.tier,
|
|
170
171
|
...(entry.askerOwn === true ? { askerOwn: true } : {}),
|
|
171
172
|
};
|
|
172
173
|
});
|
|
@@ -0,0 +1,214 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* How a person's own Tex talks to them, kept as a note in their Tex store: `tex/instructions.md` (the Tex/Context split,
|
|
3
|
+
* 2026-11-30; Architect: a note in the person's `tex/` folder, as `tex/heartbeat.md` and the other settings notes are,
|
|
4
|
+
* read and written through the Tex-store door with the note's etag as a compare-and-set).
|
|
5
|
+
*
|
|
6
|
+
* ---
|
|
7
|
+
* updates: planOnly
|
|
8
|
+
* before: |
|
|
9
|
+
* Be friendly. ...
|
|
10
|
+
* ---
|
|
11
|
+
* Answer in French.
|
|
12
|
+
* Use no emoji.
|
|
13
|
+
*
|
|
14
|
+
* The body is the instructions, in the person's own words. `updates` is the progress-updates level (absent: normal).
|
|
15
|
+
* `before` is the one undo copy: the text before the last change, set only when the body changes, kept as a block
|
|
16
|
+
* scalar so no line of it can end the front matter. Group chats keep theirs elsewhere; nobody's personal instructions
|
|
17
|
+
* reach a group.
|
|
18
|
+
*
|
|
19
|
+
* The parser never loses text: a note whose front matter does not close, or holds anything this file did not write, is
|
|
20
|
+
* read whole as instructions.
|
|
21
|
+
*/
|
|
22
|
+
"use strict";
|
|
23
|
+
|
|
24
|
+
const { readNote, writeNote } = require("./settingsNotes.cjs");
|
|
25
|
+
|
|
26
|
+
/** Where a person's instructions live, in their own Tex store. */
|
|
27
|
+
const INSTRUCTIONS_PATH = "tex/instructions.md";
|
|
28
|
+
/** The most the instructions may hold, as one custom-instructions box does. */
|
|
29
|
+
const MAX_INSTRUCTIONS = 1_500;
|
|
30
|
+
/** Put after instructions cut to `MAX_INSTRUCTIONS` for a prompt, so the cut is visible. */
|
|
31
|
+
const TRUNCATED_MARK = "\n[cut: longer than 1,500 characters]";
|
|
32
|
+
const TEX_UPDATES = Object.freeze(["off", "planOnly", "normal"]);
|
|
33
|
+
|
|
34
|
+
/** Every quick pick: its id, a label, the family one line of which a text holds, and the line it writes. */
|
|
35
|
+
const QUICK_PICKS = Object.freeze(
|
|
36
|
+
[
|
|
37
|
+
["professional", "Professional", "tone", "Be professional. Write with polish and precision, courteous and to the point, the way a trusted advisor texts a client. Skip small talk and slang."],
|
|
38
|
+
["friendly", "Friendly", "tone", "Be friendly. Sound warm and relaxed, like a good friend who happens to know the answer. Keep it natural and kind."],
|
|
39
|
+
["candid", "Candid", "tone", "Be candid. Say plainly what you think, including when it is not what they hoped to hear. Stay kind, and give your reasons briefly."],
|
|
40
|
+
["quirky", "Quirky", "tone", "Be quirky. Let some playfulness and an odd turn of phrase show now and then. Never let it get in the way of the answer."],
|
|
41
|
+
["efficient", "Efficient", "tone", "Be efficient. Give the answer and stop: no greeting, no recap, no sign-off, no filler. Stay polite, but keep every word working."],
|
|
42
|
+
["nerdy", "Nerdy", "tone", "Be nerdy. Enjoy the details and share the interesting why behind things when it helps. Lead with the answer, then the fun part."],
|
|
43
|
+
["cynical", "Cynical", "tone", "Be a little cynical. Keep a dry wit and a light touch of sarcasm. Still give the practical answer straight."],
|
|
44
|
+
["warmth_more", "More warmth", "warmth", "Be warmer: show that you care."],
|
|
45
|
+
["warmth_less", "Less warmth", "warmth", "Keep it neutral and skip the reassurance."],
|
|
46
|
+
["enthusiasm_more", "More enthusiasm", "enthusiasm", "Be upbeat and energetic."],
|
|
47
|
+
["enthusiasm_less", "Less enthusiasm", "enthusiasm", "Stay calm and matter-of-fact, with no exclamation marks."],
|
|
48
|
+
["emoji_more", "More emoji", "emoji", "Use emoji freely where they fit."],
|
|
49
|
+
["emoji_less", "Less emoji", "emoji", "Use emoji sparingly."],
|
|
50
|
+
["emoji_none", "No emoji", "emoji", "Use no emoji."],
|
|
51
|
+
["short", "Short answers", "length", "Keep answers short: the answer and nothing more."],
|
|
52
|
+
["detailed", "Detailed answers", "length", "Give detailed answers: the reasons, the options and the next step."],
|
|
53
|
+
["one_bubble", "One bubble", "bubbles", "Send each answer as one text, with no blank lines."],
|
|
54
|
+
["humor_more", "More humor", "humor", "Joke more when it fits."],
|
|
55
|
+
["humor_less", "Less humor", "humor", "Joke rarely."],
|
|
56
|
+
["humor_none", "No humor", "humor", "No jokes."],
|
|
57
|
+
].map(([id, label, family, line]) => Object.freeze({ id, label, family, line })),
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
const tidy = (text) =>
|
|
61
|
+
String(text ?? "")
|
|
62
|
+
.replace(/\r\n?/g, "\n")
|
|
63
|
+
.split("\n")
|
|
64
|
+
.map((line) => line.trim())
|
|
65
|
+
.filter((line) => line !== "")
|
|
66
|
+
.join("\n");
|
|
67
|
+
|
|
68
|
+
/** The whole note read as instructions, for a note this file cannot read as its own. */
|
|
69
|
+
const whole = (raw) => ({ instructions: tidy(raw), broken: true });
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* `{ instructions, updates?, before?, broken? }` from a note's text. `instructions` is "" for none. `broken` says the
|
|
73
|
+
* front matter could not be read, and the whole text was taken as the instructions.
|
|
74
|
+
*/
|
|
75
|
+
function parseInstructionsNote(text) {
|
|
76
|
+
const raw = String(text ?? "").replace(/^\uFEFF/, "").replace(/\r\n?/g, "\n");
|
|
77
|
+
const lines = raw.split("\n");
|
|
78
|
+
if (lines[0]?.trimEnd() !== "---") return { instructions: tidy(raw) };
|
|
79
|
+
// The closing fence starts its line: an indented "---" is a line of the undo copy.
|
|
80
|
+
const close = lines.findIndex((line, i) => i > 0 && line.trimEnd() === "---");
|
|
81
|
+
if (close === -1) return whole(raw);
|
|
82
|
+
const out = { instructions: tidy(lines.slice(close + 1).join("\n")) };
|
|
83
|
+
for (let i = 1; i < close; i++) {
|
|
84
|
+
const line = lines[i];
|
|
85
|
+
if (line.trim() === "") continue;
|
|
86
|
+
const updates = /^updates:\s*(\S+)\s*$/.exec(line);
|
|
87
|
+
if (updates && TEX_UPDATES.includes(updates[1])) {
|
|
88
|
+
out.updates = updates[1];
|
|
89
|
+
continue;
|
|
90
|
+
}
|
|
91
|
+
if (/^before:\s*\|\s*$/.test(line)) {
|
|
92
|
+
const kept = [];
|
|
93
|
+
while (i + 1 < close && (lines[i + 1].startsWith(" ") || lines[i + 1] === "")) kept.push(lines[++i].slice(2));
|
|
94
|
+
out.before = tidy(kept.join("\n"));
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
if (/^before:\s*""\s*$/.test(line)) {
|
|
98
|
+
out.before = "";
|
|
99
|
+
continue;
|
|
100
|
+
}
|
|
101
|
+
return whole(raw);
|
|
102
|
+
}
|
|
103
|
+
return out;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** The note's text for `{ instructions, updates?, before? }`. A note with nothing set is "". */
|
|
107
|
+
function formatInstructionsNote({ instructions = "", updates, before } = {}) {
|
|
108
|
+
const body = tidy(instructions);
|
|
109
|
+
const front = [];
|
|
110
|
+
if (updates !== undefined && updates !== "normal" && TEX_UPDATES.includes(updates)) front.push(`updates: ${updates}`);
|
|
111
|
+
if (typeof before === "string") {
|
|
112
|
+
const kept = tidy(before);
|
|
113
|
+
if (kept === "") front.push('before: ""');
|
|
114
|
+
else front.push("before: |", ...kept.split("\n").map((line) => ` ${line}`));
|
|
115
|
+
}
|
|
116
|
+
// A body whose first line is "---" would read as front matter: an empty one goes first.
|
|
117
|
+
if (front.length === 0) return body === "" ? "" : body.split("\n")[0] === "---" ? `---\n---\n${body}\n` : `${body}\n`;
|
|
118
|
+
return `---\n${front.join("\n")}\n---\n${body === "" ? "" : `${body}\n`}`;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* `kept` with `change` applied (`{ pick } | { add } | { remove } | { replace } | { clear: true } | { undo: true }`):
|
|
123
|
+
* the `{ instructions, before? }` to keep, or `{ refused }`. Text past `MAX_INSTRUCTIONS` and a pick nobody made are
|
|
124
|
+
* refused whole, never cut short. `before` changes only when the body does.
|
|
125
|
+
*/
|
|
126
|
+
function applyInstructionsChange(kept, change) {
|
|
127
|
+
const now = tidy(kept?.instructions ?? "");
|
|
128
|
+
const before = kept?.before;
|
|
129
|
+
if (change?.undo === true) {
|
|
130
|
+
if (before === undefined) return { refused: "nothing_to_undo" };
|
|
131
|
+
return { instructions: tidy(before), before: now };
|
|
132
|
+
}
|
|
133
|
+
let next;
|
|
134
|
+
if (change?.pick !== undefined) {
|
|
135
|
+
const pick = QUICK_PICKS.find((entry) => entry.id === change.pick);
|
|
136
|
+
if (pick === undefined) return { refused: "bad_request" };
|
|
137
|
+
const family = new Set(QUICK_PICKS.filter((entry) => entry.family === pick.family).map((entry) => entry.line));
|
|
138
|
+
next = [...now.split("\n").filter((line) => !family.has(line.trim())), pick.line].join("\n");
|
|
139
|
+
} else if (typeof change?.add === "string") next = `${now}\n${change.add}`;
|
|
140
|
+
else if (typeof change?.remove === "string") {
|
|
141
|
+
const gone = tidy(change.remove);
|
|
142
|
+
next = now.split("\n").filter((line) => line.trim() !== gone).join("\n");
|
|
143
|
+
} else if (typeof change?.replace === "string") next = change.replace;
|
|
144
|
+
else if (change?.clear === true) next = "";
|
|
145
|
+
else return { refused: "bad_request" };
|
|
146
|
+
const text = tidy(next);
|
|
147
|
+
if (text.length > MAX_INSTRUCTIONS) return { refused: "too_long" };
|
|
148
|
+
if (text === now) return { instructions: now, ...(before !== undefined ? { before } : {}) };
|
|
149
|
+
return { instructions: text, before: now };
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/** The instructions as a prompt carries them: at most `MAX_INSTRUCTIONS`, with `TRUNCATED_MARK` when cut. */
|
|
153
|
+
function instructionsForPrompt(instructions) {
|
|
154
|
+
const text = tidy(instructions);
|
|
155
|
+
return text.length <= MAX_INSTRUCTIONS ? text : `${text.slice(0, MAX_INSTRUCTIONS)}${TRUNCATED_MARK}`;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* The person's instructions read through `call` (the tool door, as `settingsNotes.cjs` reads `tex/heartbeat.md`):
|
|
160
|
+
* `{ found: true, etag, instructions, updates?, before? }`, or `{ found: false }` when there is no note yet (or it could
|
|
161
|
+
* not be read), so a caller falls back to the copy it already holds and instructions never silently disappear.
|
|
162
|
+
*/
|
|
163
|
+
async function readInstructions(call) {
|
|
164
|
+
const read = await readNote(call, INSTRUCTIONS_PATH);
|
|
165
|
+
if (read === null) return { found: false };
|
|
166
|
+
return { found: true, etag: read.etag, ...parseInstructionsNote(read.note) };
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* `change` applied to the note and written back with the etag it was read at, so a change made meanwhile (by a text
|
|
171
|
+
* to Tex, or another page) is refused as `changed` rather than overwritten. With no note yet, `fallback` (the copy
|
|
172
|
+
* the caller already holds) is the text the change applies to, and the note is created. Answers
|
|
173
|
+
* `{ ok: true, instructions }` or `{ ok: false, error }`.
|
|
174
|
+
*/
|
|
175
|
+
async function setInstructions(call, change, fallback = "") {
|
|
176
|
+
const read = await readInstructions(call);
|
|
177
|
+
const kept = read.found ? read : { instructions: tidy(fallback) };
|
|
178
|
+
const next = applyInstructionsChange(kept, change);
|
|
179
|
+
if (next.refused) return { ok: false, error: next.refused };
|
|
180
|
+
if (read.found && next.instructions === kept.instructions && next.before === kept.before) return { ok: true, instructions: next.instructions };
|
|
181
|
+
const content = formatInstructionsNote({ instructions: next.instructions, updates: kept.updates, before: next.before });
|
|
182
|
+
const written = await writeNote(call, INSTRUCTIONS_PATH, content, read.found ? read.etag : null);
|
|
183
|
+
return written.ok ? { ok: true, instructions: next.instructions } : written;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* The note made from a copy the caller holds (the control plane's, until the import is done), create-only: a note
|
|
188
|
+
* that is there already is never changed. Answers one outcome to count, never the text: `created`, `skipped` (a note
|
|
189
|
+
* is there), `empty` (no copy to make one from) or `error`.
|
|
190
|
+
*/
|
|
191
|
+
async function importInstructions(call, copy) {
|
|
192
|
+
const text = tidy(copy);
|
|
193
|
+
if (text === "") return "empty";
|
|
194
|
+
if (text.length > MAX_INSTRUCTIONS) return "error";
|
|
195
|
+
if ((await readInstructions(call)).found) return "skipped";
|
|
196
|
+
// No etag: the gateway refuses a write over a note that is there, so a read that failed is never an overwrite.
|
|
197
|
+
const written = await writeNote(call, INSTRUCTIONS_PATH, formatInstructionsNote({ instructions: text }), null);
|
|
198
|
+
return written.ok ? "created" : "error";
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
module.exports = {
|
|
202
|
+
INSTRUCTIONS_PATH,
|
|
203
|
+
MAX_INSTRUCTIONS,
|
|
204
|
+
TRUNCATED_MARK,
|
|
205
|
+
TEX_UPDATES,
|
|
206
|
+
QUICK_PICKS,
|
|
207
|
+
parseInstructionsNote,
|
|
208
|
+
formatInstructionsNote,
|
|
209
|
+
applyInstructionsChange,
|
|
210
|
+
instructionsForPrompt,
|
|
211
|
+
readInstructions,
|
|
212
|
+
setInstructions,
|
|
213
|
+
importInstructions,
|
|
214
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/** Types for `instructionsNote.cjs`; see that file for the reasons. */
|
|
2
|
+
export declare const INSTRUCTIONS_PATH: "tex/instructions.md";
|
|
3
|
+
export declare const MAX_INSTRUCTIONS: number;
|
|
4
|
+
export declare const TRUNCATED_MARK: string;
|
|
5
|
+
export type TexUpdates = "off" | "planOnly" | "normal";
|
|
6
|
+
export declare const TEX_UPDATES: readonly TexUpdates[];
|
|
7
|
+
export type QuickPick = { readonly id: string; readonly label: string; readonly family: string; readonly line: string };
|
|
8
|
+
export declare const QUICK_PICKS: readonly QuickPick[];
|
|
9
|
+
export type InstructionsNote = { instructions: string; updates?: TexUpdates; before?: string; broken?: true };
|
|
10
|
+
export declare function parseInstructionsNote(text: unknown): InstructionsNote;
|
|
11
|
+
export declare function formatInstructionsNote(note?: { instructions?: string; updates?: TexUpdates; before?: string }): string;
|
|
12
|
+
export type InstructionsChange = { pick?: string; add?: string; remove?: string; replace?: string; clear?: boolean; undo?: boolean };
|
|
13
|
+
export declare function applyInstructionsChange(
|
|
14
|
+
kept: { instructions?: string; before?: string } | null | undefined,
|
|
15
|
+
change: InstructionsChange,
|
|
16
|
+
): { instructions: string; before?: string } | { refused: "bad_request" | "too_long" | "nothing_to_undo" };
|
|
17
|
+
export declare function instructionsForPrompt(instructions: unknown): string;
|
|
18
|
+
|
|
19
|
+
export type ToolCall = (name: string, args: Record<string, unknown>) => Promise<unknown>;
|
|
20
|
+
export declare function readInstructions(call: ToolCall): Promise<({ found: true; etag: string | null } & InstructionsNote) | { found: false }>;
|
|
21
|
+
export declare function setInstructions(call: ToolCall, change: InstructionsChange, fallback?: string): Promise<{ ok: true; instructions: string } | { ok: false; error: string }>;
|
|
22
|
+
export declare function importInstructions(call: ToolCall, copy: unknown): Promise<"created" | "skipped" | "empty" | "error">;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* STAFF SWITCHING ONE TEX CHAT BETWEEN PRODUCTION AND STAGING, FROM CONTEXT'S STAFF CONSOLE (Sayo, 2026-12-01).
|
|
3
|
+
*
|
|
4
|
+
* The route table, the roster of who may be on staging, the member check, the audit and the one-line notice a chat
|
|
5
|
+
* gets when it moves are Tex's (its Photon bridge and `tex_dev route`). The staff console's People page asks Tex's
|
|
6
|
+
* Worker through the gateway, which hands each call over its `TEXTING` binding as `lineRoutes({ token, ...call })`:
|
|
7
|
+
*
|
|
8
|
+
* - `POST LINE_ROUTES_PATH` `{ op, ... }`, the bearer the person's own control-plane sign-in token, exactly as
|
|
9
|
+
* `STAFF_DATA_PATH` (`staffData.cjs`). The gateway decides nothing; Tex's Worker asks the control plane who that
|
|
10
|
+
* sign-in is (`functions/texLineAdmin:myStaffHandle`, answered only for staff, about its caller alone) and records
|
|
11
|
+
* them in the audit.
|
|
12
|
+
* - Ops: `list` `{}`: the chats on staging now; `switch` `{ to, phone }` for a person's 1:1 with Tex, or
|
|
13
|
+
* `{ to, groupKey }` for a group chat named by its key (the control plane's `textGroups.groupKey`).
|
|
14
|
+
*
|
|
15
|
+
* Answers are `{ status: "ok", data }`, `{ status: "refused" }` (not staff) or `{ status: "unavailable" }`. `data` is
|
|
16
|
+
* `{ ok: true, ... }` or `{ ok: false, error }` with a sentence for staff when Tex said no (not on the roster, staging
|
|
17
|
+
* not answering, or a deployment with no line, such as a preview). Only production's Tex has the line.
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
const LINE_ROUTES_PATH = "/tex/line-routes";
|
|
21
|
+
const LINE_ROUTE_OPS = Object.freeze(["list", "switch"]);
|
|
22
|
+
const LINE_ROUTE_TARGETS = Object.freeze(["staging", "production"]);
|
|
23
|
+
const PHONE = /^\+[1-9][0-9]{6,14}$/;
|
|
24
|
+
const GROUP_KEY = /^[0-9a-f]{64}$/;
|
|
25
|
+
|
|
26
|
+
/** A switch call read strictly: `{ op: "list" }`, `{ op: "switch", to, phone }` or `{ op: "switch", to, groupKey }`; else null. */
|
|
27
|
+
function lineRouteRequest(body) {
|
|
28
|
+
if (body === null || typeof body !== "object" || Array.isArray(body)) return null;
|
|
29
|
+
if (body.op === "list") return { op: "list" };
|
|
30
|
+
if (body.op !== "switch" || !LINE_ROUTE_TARGETS.includes(body.to)) return null;
|
|
31
|
+
const phone = typeof body.phone === "string" && PHONE.test(body.phone) ? body.phone : null;
|
|
32
|
+
const groupKey = typeof body.groupKey === "string" && GROUP_KEY.test(body.groupKey) ? body.groupKey : null;
|
|
33
|
+
if ((phone === null) === (groupKey === null)) return null;
|
|
34
|
+
return phone !== null ? { op: "switch", to: body.to, phone } : { op: "switch", to: body.to, groupKey };
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
module.exports = { LINE_ROUTES_PATH, LINE_ROUTE_OPS, LINE_ROUTE_TARGETS, lineRouteRequest };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Types for `lineRoutes.cjs`; see that file for the reasons. The answers are Tex's Worker's. */
|
|
2
|
+
|
|
3
|
+
export declare const LINE_ROUTES_PATH: "/tex/line-routes";
|
|
4
|
+
export declare const LINE_ROUTE_OPS: readonly ["list", "switch"];
|
|
5
|
+
export declare const LINE_ROUTE_TARGETS: readonly ["staging", "production"];
|
|
6
|
+
|
|
7
|
+
export type LineRouteTarget = (typeof LINE_ROUTE_TARGETS)[number];
|
|
8
|
+
export type LineRouteRequest = { op: "list" } | { op: "switch"; to: LineRouteTarget; phone: string } | { op: "switch"; to: LineRouteTarget; groupKey: string };
|
|
9
|
+
export declare function lineRouteRequest(body: unknown): LineRouteRequest | null;
|
|
10
|
+
|
|
11
|
+
/** One chat on staging: a 1:1 by its person's phone, a group by its key. */
|
|
12
|
+
export type LineRoute = { kind: "dm" | "group"; phone?: string; groupKey?: string; to: LineRouteTarget; by: string | null; at: number };
|
|
13
|
+
|
|
14
|
+
/** `op: "list"`. */
|
|
15
|
+
export type LineRouteList = { ok: true; routes: LineRoute[] } | { ok: false; error: string };
|
|
16
|
+
/** `op: "switch"`: where the chat was, where it is, and whether it was told in one line. */
|
|
17
|
+
export type LineRouteSwitch = { ok: true; to: LineRouteTarget; was: LineRouteTarget; told: boolean; stagingCommit?: string | null } | { ok: false; error: string };
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WHAT A GROUP CHAT'S PEOPLE MAY READ OF ITS HISTORY OUTSIDE A TURN: nothing said while someone in the chat now was
|
|
3
|
+
* away from it, unless a member who was there released it to them, and never a plain hash of anyone's number.
|
|
4
|
+
*
|
|
5
|
+
* The chat's members log is kept by Tex's texting Worker in the chat's own object, as keyed ids and times only, and
|
|
6
|
+
* mirrored into the chat's ledger as `members` steps: one snapshot `{snap, part, of, started, members: {w: spans},
|
|
7
|
+
* releases}` split into parts. A turn reads the chat under its own seal; every other reader of a group chat's ledger
|
|
8
|
+
* (its history and conversations files, the Tex page, a person's Download as folders, the Lab) reads it through
|
|
9
|
+
* this one, with no asker: a text is shown only when everyone here now was here when it was said, or was released
|
|
10
|
+
* it. Decided by the owner's security review, 2026-11-30.
|
|
11
|
+
*
|
|
12
|
+
* - A chat whose ledger holds no `members` step has no log, and reads as before.
|
|
13
|
+
* - A `members` step that can't be read as a whole snapshot, or a snapshot read that fails, seals everything but the
|
|
14
|
+
* log's own steps (fail closed).
|
|
15
|
+
* - A day summary is sealed when any sealed time falls within a day either side of its day; a thread when any of its
|
|
16
|
+
* texts, or its start, is sealed, and then every one of its entries is.
|
|
17
|
+
* - Every entry kept loses `from.who` and `people`: plain hashes of numbers, never shown outside a turn.
|
|
18
|
+
*
|
|
19
|
+
* Pure, with no imports: the gateway's object (synchronously) and its Workers (over the wire) read it alike.
|
|
20
|
+
*/
|
|
21
|
+
|
|
22
|
+
const MEMBERS_STEP = "members";
|
|
23
|
+
const RELEASE_STEP = "release";
|
|
24
|
+
const MEMBER_ID = /^[0-9a-f]{32}$/;
|
|
25
|
+
const RELEASE_ID = /^r[0-9a-z]{8,32}$/;
|
|
26
|
+
const MAX_SPANS = 64;
|
|
27
|
+
const DAY_MS = 86_400_000;
|
|
28
|
+
const DAY_ID = /^(\d{4})-(\d{2})-(\d{2})$/;
|
|
29
|
+
const TIME_IN_ID = /^\D*(\d{13})/;
|
|
30
|
+
|
|
31
|
+
/** The read that finds a chat's newest snapshot: its `members` steps, newest first. */
|
|
32
|
+
const MEMBERS_SNAPSHOT_READ = Object.freeze({ kinds: ["step"], steps: [MEMBERS_STEP], before: Number.MAX_SAFE_INTEGER, limit: 200 });
|
|
33
|
+
|
|
34
|
+
const finite = (value) => typeof value === "number" && Number.isFinite(value);
|
|
35
|
+
const endOf = (value) => (value === null ? null : finite(value) ? value : undefined);
|
|
36
|
+
|
|
37
|
+
function spansOf(value) {
|
|
38
|
+
if (!Array.isArray(value) || value.length > MAX_SPANS) return null;
|
|
39
|
+
const spans = [];
|
|
40
|
+
for (const span of value) {
|
|
41
|
+
if (!Array.isArray(span) || span.length !== 2) return null;
|
|
42
|
+
const [from, to] = [endOf(span[0]), endOf(span[1])];
|
|
43
|
+
if (from === undefined || to === undefined || (from !== null && to !== null && from >= to)) return null;
|
|
44
|
+
spans.push([from, to]);
|
|
45
|
+
}
|
|
46
|
+
return spans;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
function releaseOf(value) {
|
|
50
|
+
if (value === null || typeof value !== "object") return null;
|
|
51
|
+
const spans = spansOf(value.spans);
|
|
52
|
+
if (typeof value.id !== "string" || !RELEASE_ID.test(value.id) || !MEMBER_ID.test(String(value.by)) || !MEMBER_ID.test(String(value.to)) || spans === null || !finite(value.at)) return null;
|
|
53
|
+
return { to: value.to, spans, stopped: finite(value.stopped) ? value.stopped : null };
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const isLogStep = (entry) => entry?.kind === "step" && (entry.step === MEMBERS_STEP || entry.step === RELEASE_STEP);
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The newest whole snapshot in `entries` (a chat's `members` steps, any order): `{started, members: Map<w, spans>,
|
|
60
|
+
* releases}`, `null` when there is no `members` step at all, or `{broken: true}` when there is one but no whole,
|
|
61
|
+
* readable snapshot.
|
|
62
|
+
*/
|
|
63
|
+
function membersSnapshot(entries) {
|
|
64
|
+
const parts = new Map();
|
|
65
|
+
let seen = false;
|
|
66
|
+
for (const entry of Array.isArray(entries) ? entries : []) {
|
|
67
|
+
if (entry?.kind !== "step" || entry.step !== MEMBERS_STEP) continue;
|
|
68
|
+
seen = true;
|
|
69
|
+
const out = entry.output;
|
|
70
|
+
if (out === null || typeof out !== "object" || typeof out.snap !== "string" || !Number.isSafeInteger(out.part) || !Number.isSafeInteger(out.of) || out.of < 1 || out.part < 0 || out.part >= out.of) continue;
|
|
71
|
+
const held = parts.get(out.snap) ?? { at: 0, of: out.of, got: new Map() };
|
|
72
|
+
held.got.set(out.part, out);
|
|
73
|
+
held.at = Math.max(held.at, finite(entry.at) ? entry.at : 0);
|
|
74
|
+
parts.set(out.snap, held);
|
|
75
|
+
}
|
|
76
|
+
if (!seen) return null;
|
|
77
|
+
const whole = [...parts.values()].filter((held) => held.got.size === held.of).sort((a, b) => b.at - a.at);
|
|
78
|
+
if (whole.length === 0) return { broken: true };
|
|
79
|
+
const members = new Map();
|
|
80
|
+
const releases = [];
|
|
81
|
+
let started = null;
|
|
82
|
+
for (const out of whole[0].got.values()) {
|
|
83
|
+
if (finite(out.started)) started = out.started;
|
|
84
|
+
for (const [w, raw] of Object.entries(out.members ?? {})) {
|
|
85
|
+
const spans = spansOf(raw);
|
|
86
|
+
if (!MEMBER_ID.test(w) || spans === null) return { broken: true };
|
|
87
|
+
members.set(w, spans);
|
|
88
|
+
}
|
|
89
|
+
for (const raw of Array.isArray(out.releases) ? out.releases : []) {
|
|
90
|
+
const release = releaseOf(raw);
|
|
91
|
+
if (release !== null) releases.push(release);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
return started === null || members.size === 0 ? { broken: true } : { started, members, releases };
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** `[from, to)` windows (null open) not covered by `spans`, from the beginning of time to the end. */
|
|
98
|
+
function gapsOf(spans) {
|
|
99
|
+
const sorted = spans.map(([from, to]) => [from ?? -Infinity, to ?? Infinity]).sort((a, b) => a[0] - b[0]);
|
|
100
|
+
const gaps = [];
|
|
101
|
+
let cursor = -Infinity;
|
|
102
|
+
for (const [from, to] of sorted) {
|
|
103
|
+
if (from > cursor) gaps.push([cursor, from]);
|
|
104
|
+
cursor = Math.max(cursor, to);
|
|
105
|
+
}
|
|
106
|
+
if (cursor < Infinity) gaps.push([cursor, Infinity]);
|
|
107
|
+
return gaps;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/** `windows` with `spans` taken out. */
|
|
111
|
+
function without(windows, spans) {
|
|
112
|
+
let out = windows;
|
|
113
|
+
for (const [rawFrom, rawTo] of spans) {
|
|
114
|
+
const [from, to] = [rawFrom ?? -Infinity, rawTo ?? Infinity];
|
|
115
|
+
out = out.flatMap(([a, b]) => (to <= a || from >= b ? [[a, b]] : [...(a < from ? [[a, from]] : []), ...(to < b ? [[to, b]] : [])]));
|
|
116
|
+
}
|
|
117
|
+
return out;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* The seal a group chat's history is read under, from its `members` steps (`MEMBERS_SNAPSHOT_READ`), or null when it
|
|
122
|
+
* keeps no log. `{sealedAt(at), sealedEntry(entry), broken}`: the windows when someone here now was away, less what a
|
|
123
|
+
* member released to them and has not stopped.
|
|
124
|
+
*/
|
|
125
|
+
function roomSealOf(snapshotEntries) {
|
|
126
|
+
const snapshot = membersSnapshot(snapshotEntries);
|
|
127
|
+
if (snapshot === null) return null;
|
|
128
|
+
if (snapshot.broken) return brokenSeal();
|
|
129
|
+
const windows = [];
|
|
130
|
+
for (const [w, spans] of snapshot.members) {
|
|
131
|
+
// Only someone here now: a member who left reads nothing here.
|
|
132
|
+
if (!spans.some(([, to]) => to === null)) continue;
|
|
133
|
+
const released = snapshot.releases.filter((release) => release.to === w && release.stopped === null).flatMap((release) => release.spans);
|
|
134
|
+
windows.push(...without(gapsOf(spans), released).filter(([from, to]) => from < to));
|
|
135
|
+
}
|
|
136
|
+
const sealedAt = (at) => !finite(at) || windows.some(([from, to]) => at >= from && at < to);
|
|
137
|
+
const overlaps = (lo, hi) => windows.some(([from, to]) => from < hi && to > lo);
|
|
138
|
+
const sealedEntry = (entry) => {
|
|
139
|
+
if (isLogStep(entry)) return false;
|
|
140
|
+
if (entry?.kind === "day") {
|
|
141
|
+
const day = typeof entry.day === "string" ? DAY_ID.exec(entry.day) : null;
|
|
142
|
+
if (day === null) return true;
|
|
143
|
+
const midnight = Date.UTC(Number(day[1]), Number(day[2]) - 1, Number(day[3]));
|
|
144
|
+
// A day is in its chat's own time zone: a day either side of UTC covers every one.
|
|
145
|
+
return !finite(midnight) || overlaps(midnight - DAY_MS, midnight + 2 * DAY_MS);
|
|
146
|
+
}
|
|
147
|
+
if (Array.isArray(entry?.texts) && entry.texts.some((id) => sealedAt(timeOfId(id)))) return true;
|
|
148
|
+
return sealedAt(entry?.at);
|
|
149
|
+
};
|
|
150
|
+
return { broken: false, sealedAt, sealedEntry, windows: windows.length };
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function brokenSeal() {
|
|
154
|
+
return { broken: true, sealedAt: () => true, sealedEntry: (entry) => !isLogStep(entry), windows: 1 };
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/** The time a text's id carries (its first 13 digits), or NaN. */
|
|
158
|
+
function timeOfId(id) {
|
|
159
|
+
const found = TIME_IN_ID.exec(String(id ?? ""));
|
|
160
|
+
return found === null ? Number.NaN : Number(found[1]);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/** An entry as a reader outside a turn may see it: no plain hash of anyone's number. */
|
|
164
|
+
function shownEntry(entry) {
|
|
165
|
+
if (entry === null || typeof entry !== "object") return entry;
|
|
166
|
+
const { people: _people, ...rest } = entry;
|
|
167
|
+
if (rest.from && typeof rest.from === "object" && "who" in rest.from) {
|
|
168
|
+
const { who: _who, ...from } = rest.from;
|
|
169
|
+
rest.from = from;
|
|
170
|
+
}
|
|
171
|
+
return rest;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* `answer` (a ledger read's `{entries, ...}`) as a reader outside a turn may see it, under `seal` (`roomSealOf`, null
|
|
176
|
+
* for a chat with no log): sealed entries left out and counted in `sealed`, every kept entry without plain hashes.
|
|
177
|
+
* `threadIds`, for a chat's threads ledger: the threads sealed whole (`sealedThreadIds`).
|
|
178
|
+
*/
|
|
179
|
+
function sealedAnswer(answer, seal, { threadIds = null } = {}) {
|
|
180
|
+
const entries = Array.isArray(answer?.entries) ? answer.entries : [];
|
|
181
|
+
const kept = [];
|
|
182
|
+
let sealed = 0;
|
|
183
|
+
for (const entry of entries) {
|
|
184
|
+
const out = seal !== null && (seal.sealedEntry(entry) || (threadIds !== null && typeof entry?.thread === "string" && threadIds.has(entry.thread)));
|
|
185
|
+
if (out) sealed += 1;
|
|
186
|
+
else kept.push(shownEntry(entry));
|
|
187
|
+
}
|
|
188
|
+
return { ...(answer && typeof answer === "object" ? answer : {}), entries: kept, ...(seal !== null ? { sealed } : {}) };
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/** Of a threads ledger's entries (all of them, any order), the thread ids sealed whole: any entry of theirs sealed. */
|
|
192
|
+
function sealedThreadIds(threadEntries, seal) {
|
|
193
|
+
const ids = new Set();
|
|
194
|
+
if (seal === null) return ids;
|
|
195
|
+
for (const entry of Array.isArray(threadEntries) ? threadEntries : []) {
|
|
196
|
+
if (entry?.kind !== "thread" || typeof entry.thread !== "string") continue;
|
|
197
|
+
if (seal.broken || seal.sealedEntry(entry)) ids.add(entry.thread);
|
|
198
|
+
}
|
|
199
|
+
return ids;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
module.exports = { MEMBERS_STEP, RELEASE_STEP, MEMBERS_SNAPSHOT_READ, membersSnapshot, roomSealOf, brokenSeal, sealedAnswer, sealedThreadIds, shownEntry, timeOfId };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare const MEMBERS_STEP: "members";
|
|
2
|
+
export declare const RELEASE_STEP: "release";
|
|
3
|
+
export declare const MEMBERS_SNAPSHOT_READ: Readonly<{ kinds: string[]; steps: string[]; before: number; limit: number }>;
|
|
4
|
+
export type Span = [number | null, number | null];
|
|
5
|
+
export type MembersSnapshot = { started: number; members: Map<string, Span[]>; releases: { to: string; spans: Span[]; stopped: number | null }[] } | { broken: true } | null;
|
|
6
|
+
export declare function membersSnapshot(entries: unknown): MembersSnapshot;
|
|
7
|
+
export type RoomSeal = { broken: boolean; sealedAt(at: unknown): boolean; sealedEntry(entry: unknown): boolean; windows: number };
|
|
8
|
+
export declare function roomSealOf(snapshotEntries: unknown): RoomSeal | null;
|
|
9
|
+
export declare function brokenSeal(): RoomSeal;
|
|
10
|
+
export declare function sealedAnswer<T extends { entries?: unknown[] }>(answer: T, seal: RoomSeal | null, options?: { threadIds?: Set<string> | null }): T & { entries: unknown[]; sealed?: number };
|
|
11
|
+
export declare function sealedThreadIds(threadEntries: unknown, seal: RoomSeal | null): Set<string>;
|
|
12
|
+
export declare function shownEntry<T>(entry: T): T;
|
|
13
|
+
export declare function timeOfId(id: unknown): number;
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
|
|
20
20
|
const { folded } = require("./folded.cjs");
|
|
21
21
|
|
|
22
|
-
/** A text that ends by asking whether to send: "Send?", "Send it? 👍 or 👎?", "Send to bram@
|
|
22
|
+
/** A text that ends by asking whether to send: "Send?", "Send it? 👍 or 👎?", "Send to bram@example.com on his thread?". */
|
|
23
23
|
const SEND_ASK = /(?:^|\n)\s*(?:(?:ok(?:ay)?\s+to|should\s+I|shall\s+I)\s+)?send(?:\s+(?:it|this|that|the email|the reply))?(?:\s+(?:to|on|as)\b[^?\n]{0,160})?\s*\?[\s\u{1F44D}\u{1F44E}or?]*$/iu;
|
|
24
24
|
|
|
25
25
|
/** Whether Tex's text ends by asking whether to send what it showed. */
|
package/texContract/texGraph.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* TEX RUNS ITS CONFIG'S GRAPH (Dev2, 2026-11-14: "it's fine for node to be code, but it's not fine for the connections
|
|
3
3
|
* between node to be code. They should be predefined").
|
|
4
4
|
*
|
|
5
|
-
*
|
|
5
|
+
* Tex's config names every step (a node) and every wire between them (an edge). This file is the one interpreter of
|
|
6
6
|
* the wires, shared by the gateway (where every node runs, Dev2 2026-11-14) and the Lab, so what runs, in what order, what waits for what and
|
|
7
7
|
* what runs in the background is read from the config and never written as code. A node is code: one function, given its input
|
|
8
8
|
* and a handle to only the nodes its wires reach, that returns its output.
|