@supa-media/tex-contract 0.0.0-stage → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (227) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +33 -2
  3. package/package.json +16 -4
  4. package/texContract/aboutLines.cjs +117 -0
  5. package/texContract/aboutLines.d.cts +14 -0
  6. package/texContract/aboutNoteLimits.cjs +41 -0
  7. package/texContract/aboutNoteLimits.d.cts +5 -0
  8. package/texContract/actionManual.cjs +104 -0
  9. package/texContract/activityHint.cjs +40 -0
  10. package/texContract/activityHint.d.cts +4 -0
  11. package/texContract/asks.cjs +16 -0
  12. package/texContract/asks.d.cts +6 -0
  13. package/texContract/asksToFile.cjs +20 -0
  14. package/texContract/asksToFile.d.cts +2 -0
  15. package/texContract/attention.cjs +138 -0
  16. package/texContract/attention.d.cts +20 -0
  17. package/texContract/browserHandback.cjs +13 -0
  18. package/texContract/browserHandback.d.cts +3 -0
  19. package/texContract/browserOwner.cjs +31 -0
  20. package/texContract/browserOwner.d.cts +2 -0
  21. package/texContract/bytes.cjs +12 -0
  22. package/texContract/capabilities.cjs +47 -0
  23. package/texContract/capabilities.d.cts +27 -0
  24. package/texContract/capabilities.generated.json +77 -0
  25. package/texContract/chatHistoryPath.cjs +38 -0
  26. package/texContract/chatHistoryPath.d.cts +5 -0
  27. package/texContract/chatLedger.cjs +91 -0
  28. package/texContract/chatLedger.d.cts +21 -0
  29. package/texContract/computerTool.cjs +102 -0
  30. package/texContract/computerTool.d.cts +16 -0
  31. package/texContract/consentYes.cjs +22 -0
  32. package/texContract/consentYes.d.cts +5 -0
  33. package/texContract/contextGateway.cjs +52 -0
  34. package/texContract/contextGateway.d.cts +19 -0
  35. package/texContract/deskEligible.cjs +20 -0
  36. package/texContract/deskEligible.d.cts +3 -0
  37. package/texContract/downloads.cjs +129 -0
  38. package/texContract/downloads.d.cts +15 -0
  39. package/texContract/egressLedger.cjs +114 -0
  40. package/texContract/egressLedger.d.cts +14 -0
  41. package/texContract/emailRead.cjs +38 -0
  42. package/texContract/emailRead.d.cts +5 -0
  43. package/texContract/eventWords.cjs +35 -0
  44. package/texContract/eventWords.d.cts +4 -0
  45. package/texContract/fileParts.cjs +43 -0
  46. package/texContract/fileParts.d.cts +6 -0
  47. package/texContract/fileTables.cjs +243 -0
  48. package/texContract/fileWords.cjs +169 -0
  49. package/texContract/folded.cjs +16 -0
  50. package/texContract/folded.d.cts +3 -0
  51. package/texContract/googleAiAccess.cjs +12 -0
  52. package/texContract/googleAiAccess.d.cts +2 -0
  53. package/texContract/graphWires.cjs +18 -0
  54. package/texContract/graphWires.d.cts +5 -0
  55. package/texContract/groupSession.cjs +28 -0
  56. package/texContract/groupSession.d.cts +7 -0
  57. package/texContract/guestNames.cjs +136 -0
  58. package/texContract/guestNames.d.cts +35 -0
  59. package/texContract/heard.cjs +19 -0
  60. package/texContract/heard.d.cts +4 -0
  61. package/texContract/heldOffer.cjs +57 -0
  62. package/texContract/heldOffer.d.cts +8 -0
  63. package/texContract/helperCallers.cjs +29 -0
  64. package/texContract/helperCallers.d.cts +4 -0
  65. package/texContract/identity.cjs +179 -0
  66. package/texContract/identity.d.cts +8 -0
  67. package/texContract/jobLogEntries.cjs +93 -0
  68. package/texContract/jobLogEntries.d.cts +12 -0
  69. package/texContract/judgedActions.cjs +20 -0
  70. package/texContract/judgedActions.d.cts +4 -0
  71. package/texContract/labSandboxGate.cjs +63 -0
  72. package/texContract/labSandboxGate.d.cts +9 -0
  73. package/texContract/ledgerReadChars.cjs +4 -0
  74. package/texContract/ledgerReadChars.d.cts +3 -0
  75. package/texContract/mailCheck.cjs +90 -0
  76. package/texContract/mailCheck.d.cts +12 -0
  77. package/texContract/mailEntries.cjs +64 -0
  78. package/texContract/mailEntries.d.cts +13 -0
  79. package/texContract/mailHealth.cjs +60 -0
  80. package/texContract/mailHealth.d.cts +10 -0
  81. package/texContract/notePath.cjs +99 -0
  82. package/texContract/notePath.d.cts +4 -0
  83. package/texContract/noteRunFacts.cjs +136 -0
  84. package/texContract/noteRunFacts.d.cts +32 -0
  85. package/texContract/objectEtag.cjs +84 -0
  86. package/texContract/objectEtag.d.cts +4 -0
  87. package/texContract/objectPlace.cjs +32 -0
  88. package/texContract/objectPlace.d.cts +5 -0
  89. package/texContract/pageJobs.cjs +226 -0
  90. package/texContract/pageJobs.d.cts +13 -0
  91. package/texContract/pdfLinks.cjs +135 -0
  92. package/texContract/pdfLinks.d.cts +4 -0
  93. package/texContract/personHub.cjs +38 -0
  94. package/texContract/personHub.d.cts +5 -0
  95. package/texContract/personNameText.cjs +18 -0
  96. package/texContract/personNameText.d.cts +3 -0
  97. package/texContract/pinnedContext.cjs +12 -0
  98. package/texContract/pinnedContext.d.cts +3 -0
  99. package/texContract/quietHoursWindow.cjs +36 -0
  100. package/texContract/quietHoursWindow.d.cts +3 -0
  101. package/texContract/reactEmoji.cjs +79 -0
  102. package/texContract/reactEmoji.d.cts +2 -0
  103. package/texContract/scopeClamp.cjs +117 -0
  104. package/texContract/scopeClamp.d.cts +5 -0
  105. package/texContract/scopes.cjs +29 -0
  106. package/texContract/scopes.d.cts +7 -0
  107. package/texContract/searchSettings.cjs +54 -0
  108. package/texContract/searchSettings.d.cts +6 -0
  109. package/texContract/settingHabits.cjs +87 -0
  110. package/texContract/settingHabits.d.cts +20 -0
  111. package/texContract/settingsNotes.cjs +217 -0
  112. package/texContract/settingsNotes.d.cts +26 -0
  113. package/texContract/shownEmail.cjs +181 -0
  114. package/texContract/texClients.cjs +53 -0
  115. package/texContract/texClients.d.cts +12 -0
  116. package/texContract/texGraph.cjs +593 -0
  117. package/texContract/texGraph.d.cts +55 -0
  118. package/texContract/texKeys.cjs +100 -0
  119. package/texContract/texKeys.d.cts +13 -0
  120. package/texContract/texNumber.cjs +20 -0
  121. package/texContract/texNumber.d.cts +3 -0
  122. package/texContract/texOwnSources.cjs +9 -0
  123. package/texContract/texOwnSources.d.cts +3 -0
  124. package/texContract/texSettings.cjs +22 -0
  125. package/texContract/texSettings.d.cts +20 -0
  126. package/texContract/texSettings.generated.json +25 -0
  127. package/texContract/texStateFiles.cjs +22 -0
  128. package/texContract/texStateFiles.d.cts +9 -0
  129. package/texContract/texSteps.cjs +27 -0
  130. package/texContract/texSteps.d.cts +14 -0
  131. package/texContract/texSteps.generated.json +41 -0
  132. package/texContract/texStoreNames.cjs +26 -0
  133. package/texContract/texStoreNames.d.cts +12 -0
  134. package/texContract/texStoreWire.cjs +306 -0
  135. package/texContract/texStoreWire.d.cts +32 -0
  136. package/texContract/threadsFold.cjs +75 -0
  137. package/texContract/threadsFold.d.cts +22 -0
  138. package/texContract/toolActions.cjs +253 -0
  139. package/texContract/toolCatalog.cjs +49 -0
  140. package/texContract/toolCatalog.generated.json +90 -0
  141. package/texContract/toolContract.cjs +52 -0
  142. package/texContract/toolContract.d.cts +12 -0
  143. package/texContract/toolShapes.cjs +14 -0
  144. package/texContract/transcription.cjs +101 -0
  145. package/texContract/transcription.d.cts +3 -0
  146. package/texContract/treeJobs.cjs +31 -0
  147. package/texContract/treeJobs.d.cts +3 -0
  148. package/texContract/turnSession.cjs +90 -0
  149. package/texContract/turnSession.d.cts +19 -0
  150. package/texContract/turnWords.cjs +90 -0
  151. package/texContract/turnWords.d.cts +9 -0
  152. package/texContract/uploadImages.cjs +131 -0
  153. package/texContract/uploadImages.d.cts +13 -0
  154. package/texContract/v2Names.cjs +41 -0
  155. package/texContract/v2SearchFetch.cjs +316 -0
  156. package/texContract/v2Translate.cjs +123 -0
  157. package/texContract/vaultTools.cjs +112 -0
  158. package/texContract/vaultTools.d.cts +15 -0
  159. package/texContract/yesWords.cjs +91 -0
  160. package/texShared/argumentCoercion.cjs +93 -0
  161. package/texShared/cellComments.cjs +122 -0
  162. package/texShared/cellComments.d.cts +21 -0
  163. package/texShared/comments.cjs +586 -0
  164. package/texShared/comments.d.cts +115 -0
  165. package/texShared/contentTypes.cjs +85 -0
  166. package/texShared/fileKinds.cjs +123 -0
  167. package/texShared/flags.cjs +159 -0
  168. package/texShared/flags.d.cts +23 -0
  169. package/texShared/folderJobInfo.cjs +301 -0
  170. package/texShared/folderJobInfo.d.cts +40 -0
  171. package/texShared/folderRoles.cjs +512 -0
  172. package/texShared/folderRoles.d.cts +73 -0
  173. package/texShared/githubOidc.ts +98 -0
  174. package/texShared/groupRunQuestions.cjs +98 -0
  175. package/texShared/groupRunQuestions.d.cts +4 -0
  176. package/texShared/inboxFolders.cjs +49 -0
  177. package/texShared/inboxFolders.d.cts +5 -0
  178. package/texShared/ink/drawing.cjs +474 -0
  179. package/texShared/ink/texFigure.cjs +252 -0
  180. package/texShared/ink/texFigure.d.cts +36 -0
  181. package/texShared/ink/texPoses.cjs +180 -0
  182. package/texShared/ink/texPoses.d.cts +20 -0
  183. package/texShared/jobPartEnd.cjs +133 -0
  184. package/texShared/jobPartEnd.d.cts +13 -0
  185. package/texShared/jobResume.cjs +31 -0
  186. package/texShared/jobResume.d.cts +5 -0
  187. package/texShared/jobSplit.cjs +90 -0
  188. package/texShared/jobSplit.d.cts +6 -0
  189. package/texShared/jobStart.cjs +56 -0
  190. package/texShared/jobStart.d.cts +9 -0
  191. package/texShared/mail.cjs +400 -0
  192. package/texShared/mail.d.cts +56 -0
  193. package/texShared/messageAnchors.cjs +38 -0
  194. package/texShared/models/aiKeys.cjs +137 -0
  195. package/texShared/models/aiKeys.d.cts +42 -0
  196. package/texShared/models/aiKeys.json +56 -0
  197. package/texShared/models/creditRest.cjs +269 -0
  198. package/texShared/models/promptBudget.cjs +295 -0
  199. package/texShared/models/promptSections.cjs +29 -0
  200. package/texShared/noteAppLink.cjs +23 -0
  201. package/texShared/notePreview.cjs +219 -0
  202. package/texShared/notePreview.d.cts +21 -0
  203. package/texShared/pages/blocks.cjs +215 -0
  204. package/texShared/pages/cover.cjs +164 -0
  205. package/texShared/pages/css.cjs +181 -0
  206. package/texShared/pages/cssBlocks.cjs +264 -0
  207. package/texShared/pages/draw.cjs +212 -0
  208. package/texShared/pages/drawRich.cjs +232 -0
  209. package/texShared/pages/html.cjs +168 -0
  210. package/texShared/pages/inline.cjs +251 -0
  211. package/texShared/pages/layout.cjs +76 -0
  212. package/texShared/pages/parse.cjs +418 -0
  213. package/texShared/pages/render.cjs +200 -0
  214. package/texShared/pages/skill.cjs +147 -0
  215. package/texShared/pages/skill.d.cts +5 -0
  216. package/texShared/pages/templates.cjs +336 -0
  217. package/texShared/r2Store.cjs +163 -0
  218. package/texShared/remoteImage.cjs +177 -0
  219. package/texShared/routines.cjs +656 -0
  220. package/texShared/routines.d.cts +86 -0
  221. package/texShared/servedListing.cjs +250 -0
  222. package/texShared/servedListing.d.cts +17 -0
  223. package/texShared/sheetCsv.cjs +566 -0
  224. package/texShared/sheetCsv.d.cts +91 -0
  225. package/texShared/storageLayout.cjs +88 -0
  226. package/texShared/storeKeys.cjs +144 -0
  227. package/texShared/toolArguments.cjs +323 -0
@@ -0,0 +1,31 @@
1
+ /**
2
+ * TEX'S BROWSER TAGS: which Browserbase browser is whose.
3
+ *
4
+ * Tex finds a person's (or a group chat's) browser again by this tag, and
5
+ * Context checks it before typing a saved login or card into that browser
6
+ * (`apps/mcp/src/tools/vaultType.js`), so both sides make it the same way.
7
+ * Made from the person's id and the deployment's `GATEWAY_SECRET`, never
8
+ * from a request; never sent to a model.
9
+ */
10
+
11
+ /** The person's browser tag, or null when this deployment cannot make one. */
12
+ async function browserOwner(env, userId) {
13
+ const secret = typeof env?.GATEWAY_SECRET === "string" ? env.GATEWAY_SECRET : "";
14
+ if (!secret || typeof userId !== "string" || !userId) return null;
15
+ const key = await crypto.subtle.importKey("raw", new TextEncoder().encode(secret), { name: "HMAC", hash: "SHA-256" }, false, ["sign"]);
16
+ const mac = await crypto.subtle.sign("HMAC", key, new TextEncoder().encode(`tex-browser:${userId}`));
17
+ return [...new Uint8Array(mac)].map((b) => b.toString(16).padStart(2, "0")).join("");
18
+ }
19
+
20
+ /**
21
+ * A group chat's browser tag (the owner, 2026-10-24): one browser per chat and
22
+ * set of people in it, so a sign-in code texted after Tex asks for it lands in
23
+ * the same browser, and somebody added to the chat gets a new one. Its own
24
+ * label, so it never equals any person's tag.
25
+ */
26
+ async function groupBrowserOwner(env, group) {
27
+ if (typeof group?.key !== "string" || !group.key || typeof group?.members !== "string" || !group.members) return null;
28
+ return await browserOwner(env, `group:${group.key}:${group.members}`);
29
+ }
30
+
31
+ module.exports = { browserOwner, groupBrowserOwner };
@@ -0,0 +1,2 @@
1
+ export function browserOwner(env: { GATEWAY_SECRET?: unknown } | null | undefined, userId: unknown): Promise<string | null>;
2
+ export function groupBrowserOwner(env: { GATEWAY_SECRET?: unknown } | null | undefined, group: { key?: unknown; members?: unknown } | null | undefined): Promise<string | null>;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ /** Base64 without a dependency, chunked so a large image cannot blow the stack. Shared by the gateway (`notes/embeds.js`) and Tex. */
3
+ function base64FromBytes(bytes) {
4
+ let binary = "";
5
+ const CHUNK = 0x8000;
6
+ for (let i = 0; i < bytes.length; i += CHUNK) {
7
+ binary += String.fromCharCode.apply(null, bytes.subarray(i, i + CHUNK));
8
+ }
9
+ return btoa(binary);
10
+ }
11
+
12
+ module.exports = { base64FromBytes };
@@ -0,0 +1,47 @@
1
+ /**
2
+ * WHAT A PERSON CAN GET TEX TO DO, AS CONTEXT CHECKS IT (contract 0.3.0; Dev2, 2026-11-08, "One capability list
3
+ * everywhere", and the agent-first rule in Context's CLAUDE.md: no feature is buttons-only).
4
+ *
5
+ * Each capability names the actions and app routes it covers, and what Tex can't do yet with the way around it (an
6
+ * agent prompt, an app path, a vault entry, a link, or words). Context's CI checks every action and app route against
7
+ * this list, so a feature added to Context without a line here fails there. The words Tex is told about each
8
+ * capability are Tex's own (`packages/tex/gateway/agent/capabilities.js` in Supa-Media/tex) and are not in the
9
+ * contract.
10
+ *
11
+ * Data only, written by `scripts/tex-contract/snapshot.mjs` into `capabilities.generated.json`.
12
+ */
13
+ "use strict";
14
+
15
+ const SNAPSHOT = require("./capabilities.generated.json");
16
+
17
+ const deepFreeze = (value) => {
18
+ if (value && typeof value === "object") {
19
+ for (const inner of Object.values(value)) deepFreeze(inner);
20
+ Object.freeze(value);
21
+ }
22
+ return value;
23
+ };
24
+
25
+ /** Every capability, in the list's order. */
26
+ const CAPABILITIES = deepFreeze(SNAPSHOT.capabilities);
27
+ /** Where a can't holds. */
28
+ const CANT_WHERE = deepFreeze(SNAPSHOT.where);
29
+ /** The kinds of way around a can't. */
30
+ const WORKAROUND_KINDS = deepFreeze(SNAPSHOT.workaroundKinds);
31
+
32
+ /** Every action the list covers (`write.x`, `manage.x`, `send.x`, `command.x`, `words.x`). */
33
+ function coveredActions() {
34
+ return new Set(CAPABILITIES.flatMap((entry) => entry.actions));
35
+ }
36
+
37
+ /** Every app route the list covers, with the capability that covers it. */
38
+ function coveredAppRoutes() {
39
+ const covered = new Map();
40
+ for (const entry of CAPABILITIES) {
41
+ for (const route of entry.appRoutes ?? []) covered.set(route, entry.name);
42
+ for (const cant of entry.cant) for (const route of cant.appRoutes ?? []) covered.set(route, `${entry.name} (can't)`);
43
+ }
44
+ return covered;
45
+ }
46
+
47
+ module.exports = { CAPABILITIES, CANT_WHERE, WORKAROUND_KINDS, coveredActions, coveredAppRoutes };
@@ -0,0 +1,27 @@
1
+ /** Types for `capabilities.cjs`; see that file. */
2
+
3
+ export type CantWhere = "everywhere" | "1:1" | "group" | "guest";
4
+ export type WorkaroundKind = "agent_prompt" | "app_path" | "vault_env" | "link" | "words";
5
+
6
+ export interface TexCant {
7
+ where: CantWhere;
8
+ what: string;
9
+ appRoutes?: readonly string[];
10
+ workaround: { kind: WorkaroundKind; text: string };
11
+ }
12
+
13
+ export interface TexCapability {
14
+ name: string;
15
+ /** `write.x`, `manage.x`, `send.x`, `command.x` or `words.x`. */
16
+ actions: readonly string[];
17
+ appRoutes?: readonly string[];
18
+ /** Kept off the list Tex is told. */
19
+ shelf?: true;
20
+ cant: readonly TexCant[];
21
+ }
22
+
23
+ export declare const CAPABILITIES: readonly TexCapability[];
24
+ export declare const CANT_WHERE: Readonly<Record<CantWhere, string>>;
25
+ export declare const WORKAROUND_KINDS: readonly WorkaroundKind[];
26
+ export declare function coveredActions(): Set<string>;
27
+ export declare function coveredAppRoutes(): Map<string, string>;
@@ -0,0 +1,77 @@
1
+ {
2
+ "where": {"everywhere":"anywhere","1:1":"in a 1:1 text","group":"in a group chat","guest":"in a guest chat"},
3
+ "workaroundKinds": [
4
+ "agent_prompt",
5
+ "app_path",
6
+ "vault_env",
7
+ "link",
8
+ "words"
9
+ ],
10
+ "capabilities": [
11
+ {"name":"Who is in a chat","actions":["send.name_guest","send.who_can_open"],"cant":[{"where":"group","what":"see the account of someone whose number here isn't on Context","workaround":{"kind":"words","text":"they sign in to the Context app with the number they use in this chat, or text you once on their own from it; either puts it on their account"}},{"where":"everywhere","what":"read anyone's phone contacts to learn guests' names","workaround":{"kind":"app_path","text":"Context app on their phone → Tex → Settings → Names from my contacts"}}]},
12
+ {"name":"Who someone is, for a form","actions":[],"cant":[{"where":"group","what":"know the name, phone number or email of someone here for a form","workaround":{"kind":"words","text":"ask them in the chat for what the form needs"}}]},
13
+ {"name":"Ask Tex in another chat","actions":["send.ask_chat","send.post_in_chat"],"cant":[{"where":"group","what":"ask another chat, or anyone's personal Tex","workaround":{"kind":"words","text":"ask from your own 1:1 with Tex, which can ask any group you are in"}},{"where":"1:1","what":"ask a group you are not in","workaround":{"kind":"words","text":"ask someone in that group to tag Tex there"}}]},
14
+ {"name":"Following up on the side, both ways","actions":["send.text_privately"],"cant":[{"where":"group","what":"ask someone who isn't on Context, or never texted you on their own, for something sensitive","workaround":{"kind":"words","text":"they text you once on their own from their phone (which sets up an account if they have none), then ask again"}}]},
15
+ {"name":"Saying hello when added to a group","actions":[],"cant":[{"where":"group","what":"say hello when the person who added you isn't on Context","workaround":{"kind":"words","text":"the first time someone here tags you, answer them; they can sign in to the Context app with their number"}}]},
16
+ {"name":"Member cards: what each person's own Tex lets a group use","actions":[],"cant":[{"where":"group","what":"use what someone told their own Tex beyond their card","workaround":{"kind":"words","text":"they say it in the chat, or add it to their card (tex/group-card.md)"}}]},
17
+ {"name":"Notes","actions":["write.save","write.save_many","write.comment","write.upload","write.remember","manage.move","manage.move_many","manage.move_folder","manage.archive","manage.suggest_destination","manage.layout","manage.folder_job","manage.encrypt"],"cant":[{"where":"everywhere","what":"delete a note","workaround":{"kind":"words","text":"archive it (manage archive): it moves to the Archive folder, where it can be found or moved back"}},{"where":"group","what":"read anyone else's personal notes, or anyone's saved logins, or someone else's calendar they haven't shared with this chat","workaround":{"kind":"words","text":"the note's owner names their own workspace with @ in their text: that ask reads it"}},{"where":"everywhere","what":"delete a workspace or close their account","workaround":{"kind":"app_path","text":"Context app → Settings → General → Delete this workspace, or Settings → Profile → Delete account"}},{"where":"everywhere","what":"change their username (twice in a lifetime; the old name stays theirs and keeps working)","workaround":{"kind":"app_path","text":"Context app → Settings → Profile → Username → Change"}},{"where":"everywhere","what":"make or change a people group, or switch a plugin on or off","workaround":{"kind":"app_path","text":"Context app → Settings → People & sharing (groups), or Settings → Plugins (that row shows only to people already using plugins)"}}]},
18
+ {"name":"Sheets","actions":["write.rows"],"cant":[{"where":"everywhere","what":"make a key that lets a script, a CI job or another service add rows to a sheet by itself","workaround":{"kind":"app_path","text":"an editor opens the sheet in the Context app → Data sources → Make a key, and copies the key and the one call there; a key is shown once, there and never in a chat, and Data sources is also where it is revoked"}}]},
19
+ {"name":"Who sees a note","actions":["manage.visibility","manage.folder_visibility","manage.share_link","manage.revoke_link"],"cant":[]},
20
+ {"name":"Forms","actions":["write.answer","write.update_answer","write.retract_answer","write.vote"],"cant":[]},
21
+ {"name":"The note open in the app","actions":[],"cant":[]},
22
+ {"name":"Shared workspaces","actions":["manage.create_workspace"],"cant":[{"where":"everywhere","what":"open a shared workspace to everyone at an email domain","workaround":{"kind":"app_path","text":"the owner opens Context app → Settings → People & sharing → Your organization"}}]},
23
+ {"name":"Inviting people","actions":["manage.invite","words.invite","send.chat_add_everyone"],"cant":[{"where":"everywhere","what":"change a member's role, remove someone from a workspace, or cancel an invitation","workaround":{"kind":"app_path","text":"the owner opens Context app → Settings → People & sharing → Members"}}]},
24
+ {"name":"Website","actions":["manage.website"],"cant":[]},
25
+ {"name":"Data sources and metrics","actions":[],"cant":[{"where":"everywhere","what":"connect a data source or make the key that sends rows to one","workaround":{"kind":"app_path","text":"someone who can edit the shared workspace opens the Context app → the data folder → Connect a source (the sidebar's + → Data source… makes the data folder the first time)"}},{"where":"everywhere","what":"start or restart a Fetch from a URL source's hourly sync (you can write its about.md, but the sync runs on the standing of a person who edits the workspace)","workaround":{"kind":"app_path","text":"an owner or editor opens the Context app → the data folder → the source → Sync now; its page then says when it last synced or why it was refused"}}]},
26
+ {"name":"Saved logins, keys and cards (the vault)","actions":["manage.vault_add","manage.vault_share","manage.vault_view","send.fill_login","send.make_login","send.fill_card","send.api","send.vault_access"],"cant":[{"where":"everywhere","what":"see, say or take by text a password, key, env variable or card number","workaround":{"kind":"vault_env","text":"send manage vault_add's link (type secret with the field names, and perEnv for dev, staging and prod values; type card for a card) for them to save it; to let someone else in a shared workspace use it, send manage vault_share's link and they press Share"}},{"where":"everywhere","what":"use a login on a site other than the one it was saved for","workaround":{"kind":"vault_env","text":"send manage vault_add's link with that other site, so they save it there too"}},{"where":"everywhere","what":"share a login saved in a personal workspace","workaround":{"kind":"vault_env","text":"they save it in the shared workspace (manage vault_add with that context), then you give it with send vault_access"}},{"where":"everywhere","what":"change who has a login someone else saved","workaround":{"kind":"words","text":"whoever saved it asks you, or changes it in Context app → Vault, on the right rail (on a phone, in your account menu)"}},{"where":"everywhere","what":"delete a saved key, or cut off one particular AI (send vault_access cuts off every AI)","workaround":{"kind":"app_path","text":"Context app → Vault, on the right rail (on a phone, in your account menu)"}},{"where":"group","what":"use someone's own saved login or card","workaround":{"kind":"words","text":"they text you on their own for it, or save it in the workspace's vault and give it to everyone there"}},{"where":"guest","what":"pay with a card when whoever tagged you isn't on Context","workaround":{"kind":"words","text":"someone here who is on Context tags you to pay, and their own plain yes allows it"}},{"where":"everywhere","what":"type a code you weren't texted, solve a captcha you can't get past, pass a passkey only their own device holds, or pay without them","workaround":{"kind":"link","text":"add a handoff step in browse: they get a link to your browser (in a group chat, the chat's own Tex page, for anyone here signed in to Context) and do only that step, then press Done there and you carry on by yourself (texting \"done\" works too); with no link, or if they've said they won't take the browser, keep the browser where it got to and say the one step left, never the whole form again"}}]},
27
+ {"name":"The web","actions":["send.search_web","send.open_page","send.browse","send.travel_time"],"cant":[{"where":"everywhere","what":"show them your browser inside a text","workaround":{"kind":"link","text":"they watch or take over your browser live at context.lc/tex/@their-handle?view=computer&full=1 (a group chat's at context.lc/tex/group/<its words>/computer?full=1), or at the handoff link browse sends"}}]},
28
+ {"name":"Sending email","actions":["send.email"],"cant":[{"where":"everywhere","what":"read or send Outlook, Microsoft 365, iCloud or other mail that isn't Gmail","workaround":{"kind":"link","text":"browse to that web mail and do the step there, signing in with a saved login"}},{"where":"everywhere","what":"add or remove a Gmail \"Send mail as\" address","workaround":{"kind":"link","text":"https://mail.google.com/mail/u/0/#settings/accounts, \"Send mail as\" → Add another email address; Tex sends from it once Gmail shows it verified"}}]},
29
+ {"name":"Reading email","actions":[],"cant":[{"where":"group","what":"read someone's mail they haven't shared with this chat","workaround":{"kind":"words","text":"the mailbox's own person asks you here in any words to share it, or says yes when you offer (you call send action chat_share_mail), or texts you on their own to search it; never hand them a phrase to type"}}]},
30
+ {"name":"Sharing someone's mail with a group chat","actions":["command.chat_share_mail","command.chat_unshare_mail","words.share_mail","words.unshare_mail"],"cant":[{"where":"1:1","what":"share someone's mail with a group chat from a 1:1 text","workaround":{"kind":"words","text":"they type \"Tex, share my mail from <their address> here\" in that group chat"}}]},
31
+ {"name":"Sharing someone's calendar with a group chat","actions":["command.chat_share_calendar","command.chat_unshare_calendar"],"cant":[{"where":"1:1","what":"share someone's calendar with a group chat from a 1:1 text","workaround":{"kind":"words","text":"they ask you to share their calendar in that group chat"}}]},
32
+ {"name":"A group chat's own email address","actions":[],"cant":[{"where":"everywhere","what":"send or reply from a group chat's address","workaround":{"kind":"words","text":"reply from someone here's own Gmail (send action email with as), on that person's 👍"}}]},
33
+ {"name":"Gmail drafts, mail forwarding and Google Chat","actions":["send.email_draft","send.forward_rule","send.google_chat","manage.connect_google"],"cant":[{"where":"everywhere","what":"disconnect a Google account","workaround":{"kind":"app_path","text":"Context app → Settings → Connected apps"}}]},
34
+ {"name":"Calendar","actions":["send.calendar"],"cant":[]},
35
+ {"name":"Slack and other connected apps","actions":["send.slack","send.app","manage.connect"],"cant":[{"where":"everywhere","what":"disconnect an app you use","workaround":{"kind":"app_path","text":"Context app → Settings → Apps Tex uses → Disconnect"}}]},
36
+ {"name":"Meetings","actions":[],"cant":[{"where":"everywhere","what":"start, stop or join a meeting recording","workaround":{"kind":"app_path","text":"the Context Mac app records from its menu bar"}},{"where":"everywhere","what":"change the default meeting folder or how meetings are joined","workaround":{"kind":"app_path","text":"Context app → Settings → Meetings"}}]},
37
+ {"name":"People and their messages","actions":[],"cant":[]},
38
+ {"name":"Their texts from their Mac","actions":[],"cant":[{"where":"everywhere","what":"turn the Mac's Messages backup on or off, grant it Full Disk Access, or choose what it copies","workaround":{"kind":"app_path","text":"on the Mac, Context app → Settings → Messages"}}]},
39
+ {"name":"Texting them later","actions":["send.notify"],"cant":[{"where":"everywhere","what":"text or call anyone but the person or chat you are in","workaround":{"kind":"words","text":"write the exact words for them to send (\"I can't text Sam, but here's one you can send:\"), or send it as an email on their 👍"}}]},
40
+ {"name":"Reminders and routines","actions":[],"cant":[{"where":"everywhere","what":"run a routine more often than every 5 minutes, keep more than 200 in one workspace, or send a one-off reminder whose time has passed","workaround":{"kind":"words","text":"offer every 5 minutes or hourly, archive routines no longer needed, or set the reminder for the next time that works"}},{"where":"everywhere","what":"move check-in times or add more check-in texts","workaround":{"kind":"words","text":"set a routine at the time they want, or write in the body of tex/heartbeat.md what to leave alone (\"only text me about deadlines\")"}},{"where":"guest","what":"set a reminder or routine for someone here who isn't on Context","workaround":{"kind":"words","text":"someone here who is on Context sets it for the chat, or the person joins Context and texts you for their own"}}]},
41
+ {"name":"Housekeeping","actions":[],"cant":[]},
42
+ {"name":"Background jobs","actions":["send.background","send.steer_job","send.restart_job","send.job_status","send.mail_agent","send.plan","write.mail"],"cant":[]},
43
+ {"name":"Handing work to another agent","actions":["send.delegate"],"cant":[]},
44
+ {"name":"Tex's own computer","actions":["send.tex_computer"],"shelf":true,"cant":[]},
45
+ {"name":"Setting up their computers (community compute)","actions":["send.computers"],"appRoutes":["/machines/app/list","/machines/app/set","/machines/app/disconnect","/machines/app/lend","/machines/app/unlend","/machines/app/raise","/machines/app/chat-people","/machines/app/sign-in","/machines/app/install"],"cant":[{"where":"1:1","what":"answer a computer's \"Ask me first\" from a 1:1 text","appRoutes":["/machines/app/answer"],"workaround":{"kind":"app_path","text":"the owner taps 👍 on the ask in the group chat it came from, or answers it on the computer's page on their Tex page (context.lc/tex/@their-handle)"}},{"where":"everywhere","what":"change which of a computer's folders, coding tools, trusted repos or computer use Tex may use, or turn on \"Let Tex use this Mac\" in the Mac app","workaround":{"kind":"app_path","text":"they open the computer on their Tex page in the Context app (context.lc/tex/@their-handle), or, for the Mac app's switch and folders, Settings → Tex in the Mac app"}}]},
46
+ {"name":"Pairing a session's computer for mail","actions":["manage.pair_device"],"cant":[]},
47
+ {"name":"Pages","actions":[],"cant":[]},
48
+ {"name":"Pictures and cards","actions":["send.draw_visual","send.draw_picture","send.make_picture"],"cant":[{"where":"everywhere","what":"send tappable Context cards, swipeable picture sets or one-tap pick cards on WhatsApp","workaround":{"kind":"words","text":"the picture or words still arrive there as a picture, a document or a link preview"}}]},
49
+ {"name":"Files and voice memos they send","actions":[],"cant":[{"where":"everywhere","what":"watch a video, open other file types, or read a file over 25 MB (a PDF over 10 MB, a voice memo over 8 MB)","workaround":{"kind":"words","text":"ask for a screenshot of the part that matters, a shorter recording, or the file as a PDF"}}]},
50
+ {"name":"Tapbacks","actions":[],"cant":[]},
51
+ {"name":"Polls","actions":[],"cant":[{"where":"everywhere","what":"vote in a poll yourself","workaround":{"kind":"words","text":"say which option you would pick"}},{"where":"everywhere","what":"see a poll on the old Sendblue number or WhatsApp","workaround":{"kind":"words","text":"ask them to say which option they picked"}}]},
52
+ {"name":"Running the group","actions":[],"cant":[]},
53
+ {"name":"Tags, effects and other apps' cards","actions":[],"cant":[{"where":"everywhere","what":"send a card of another app yourself","workaround":{"kind":"words","text":"say it in words"}},{"where":"everywhere","what":"see tags, effects or other apps' cards on the old Sendblue number or WhatsApp","workaround":{"kind":"words","text":"ask them to say it in words"}}]},
54
+ {"name":"Threaded replies","actions":[],"cant":[{"where":"everywhere","what":"be sure a reply threads on the old Sendblue number or WhatsApp","workaround":{"kind":"words","text":"name the text you are answering in a few words"}}]},
55
+ {"name":"Edited and unsent texts","actions":[],"cant":[{"where":"everywhere","what":"see an edit or unsend on the old Sendblue number or WhatsApp, which don't send them","workaround":{"kind":"words","text":"ask them to send the corrected text again, or say which text to ignore"}}]},
56
+ {"name":"Texting while you work","actions":[],"cant":[]},
57
+ {"name":"This chat's history","actions":[],"cant":[{"where":"everywhere","what":"find a text by its meaning when it used other words","workaround":{"kind":"words","text":"search again with the plain words they would have used, or read the day summaries around when it likely was"}}]},
58
+ {"name":"Group chats","actions":[],"cant":[]},
59
+ {"name":"Your advisor","actions":["send.advisor"],"cant":[]},
60
+ {"name":"Progress lines and silence","actions":["send.progress","send.say_nothing","send.tapback","send.reply_under"],"cant":[]},
61
+ {"name":"Sending a chat's stickers","actions":["send.send_sticker"],"cant":[]},
62
+ {"name":"How you talk, and your settings","actions":["command.tex_settings","command.tex_instructions","send.setting"],"cant":[]},
63
+ {"name":"An answer held from a group","actions":["send.share_held"],"cant":[]},
64
+ {"name":"Their name on their account","actions":["send.account_name"],"cant":[]},
65
+ {"name":"When you speak up in a group","actions":["command.chat_mute","command.chat_status","words.stop","words.start","words.status"],"cant":[]},
66
+ {"name":"Sharing their conversations with the Context team","actions":["command.review_sharing","words.review_sharing"],"cant":[]},
67
+ {"name":"Bug reports","actions":["write.report_problem"],"cant":[]},
68
+ {"name":"Your memory of them","actions":["manage.dream_now","write.save_session"],"cant":[]},
69
+ {"name":"Areas and their bots","actions":["manage.area"],"cant":[{"where":"everywhere","what":"show a saved webhook's address or key","workaround":{"kind":"app_path","text":"Replace under the bot's Reach in the app's area panel"}},{"where":"everywhere","what":"send an area routine to its bot now, out of turn","workaround":{"kind":"app_path","text":"Run now on the routine's row under Routines in the app's area panel (an editor or owner; it waits like any run when the bot's share there is spent)"}}]},
70
+ {"name":"Date properties","actions":["manage.fill_dates"],"cant":[]},
71
+ {"name":"Their account","actions":[],"cant":[{"where":"everywhere","what":"change the phone or emails they sign in with, sign out their other devices, or pause phone sign-in","workaround":{"kind":"app_path","text":"Context app → Settings → Profile (each needs a code sent to them)"}},{"where":"everywhere","what":"block or unblock someone","workaround":{"kind":"app_path","text":"Report or block beside the note or invitation they sent, or Context app → Settings → Profile → Blocked people to unblock"}},{"where":"everywhere","what":"see or manage where their notes are stored","workaround":{"kind":"app_path","text":"Context app → Settings → Storage"}}]},
72
+ {"name":"Connecting AI apps to Context","actions":[],"cant":[{"where":"everywhere","what":"take away an AI app's access","workaround":{"kind":"app_path","text":"Context app → Settings → Connected apps → AI apps → Revoke"}}]},
73
+ {"name":"Chatting in the Context app","actions":[],"cant":[{"where":"everywhere","what":"send or receive files other than pictures, PDFs, text files and Word documents, or voice notes, in the app chat yet","workaround":{"kind":"words","text":"they text the file or voice note to you over iMessage, and you see it in the same history"}}]},
74
+ {"name":"Tex in a note's comments","actions":[],"cant":[]},
75
+ {"name":"Tex in a note's mail","actions":[],"cant":[]}
76
+ ]
77
+ }
@@ -0,0 +1,38 @@
1
+ /**
2
+ * A chat's history file: `tex/history.ledger.json` for a person, `tex/groups/<words>/history.ledger.json` for a group
3
+ * chat (`agent/historyFile.js`, which refuses writes to it by this same predicate).
4
+ *
5
+ * The one predicate for both, because two callers judge the same path for opposite reasons and must not drift: the
6
+ * write side refuses it, and the egress ledger marks a read of it untrusted (`privacy/egress.js`) — every word in a
7
+ * chat is somebody else's, as `read_texts` already says, and `fetch` routes this file to `read_note`, so the mark has
8
+ * to follow the path rather than the tool's name.
9
+ *
10
+ * Normalized here rather than by `normalizePath`, which leaves a `@context/` prefix on: an id naming another context's
11
+ * history file is still a chat's history.
12
+ */
13
+ // The conversations file beside it is a view of the same chat (`texStore/historyView.js`), judged the same way.
14
+ const CHAT_HISTORY_PATH = /(?:^|\/)tex\/(?:groups\/[^/]+\/)?(?:history|conversations)\.ledger\.json$/i;
15
+
16
+ function isChatHistoryPath(path) {
17
+ if (typeof path !== "string") return false;
18
+ const bare = path
19
+ .trim()
20
+ .replace(/^(?:\.\/|\/)+/, "")
21
+ .replace(/^@[^/]*\/+/, "")
22
+ .replace(/\/{2,}/g, "/");
23
+ return CHAT_HISTORY_PATH.test(bare);
24
+ }
25
+
26
+ /** A person's history file (`agent/historyFile.js`, `texStore/historyView.js` `HISTORY_FILE`). */
27
+ const HISTORY_PATH = "tex/history.ledger.json";
28
+
29
+ /**
30
+ * The words a tool call naming the history file is refused with, or null for any other path (`tools/dispatch.js`):
31
+ * read only, whatever asks.
32
+ */
33
+ function historyWriteRefusal(path) {
34
+ if (!isChatHistoryPath(path)) return null;
35
+ return "That file is this chat's history, kept by Tex as it happens; it can be read but not written, moved or removed. Nothing was changed.";
36
+ }
37
+
38
+ module.exports = { isChatHistoryPath, HISTORY_PATH, historyWriteRefusal };
@@ -0,0 +1,5 @@
1
+ /** Types for `chatHistoryPath.cjs`; see that file for the reasons. */
2
+
3
+ export declare function isChatHistoryPath(path: unknown): boolean;
4
+ export declare const HISTORY_PATH: string;
5
+ export declare function historyWriteRefusal(path: unknown): string | null;
@@ -0,0 +1,91 @@
1
+ /**
2
+ * Where a chat's ledger is and the writer that appends to it, which both Tex's turns (`agent/ledger.js`, which
3
+ * re-exports these) and the gateway's own routes (`machines/jobRoutes.js`, a computer part's steps) write through.
4
+ * The rows are kept by Context's Tex store (`apps/mcp/src/texStore/ledger.js`); what an entry says is Tex's
5
+ * (`agent/ledger.js`). Pure: the ledger itself is handed in.
6
+ */
7
+
8
+ const { TEXTS_GROUP_CLIENT_ID } = require("./groupSession.cjs");
9
+ const { ONE_TO_ONE_CHAT } = require("./texStoreNames.cjs");
10
+
11
+ const GROUP_KEY = /^[0-9a-f]{64}$/;
12
+
13
+ /**
14
+ * The ledgers in one owner's Tex object (`{person: workspaceId}` or `{chat: groupKey}`, as `ledgerPlace` names it),
15
+ * from a store opener by owner name (`texStoreWire.cjs` `gatewayTexStoreWith`), or null when it names none or the
16
+ * opener has no object: `{append(chat, entries), read(chat, options), chats()}`.
17
+ */
18
+ function ledgerIn(storeOf, owner) {
19
+ const name = owner?.person ? `person:${owner.person}` : owner?.chat ? `chat:${owner.chat}` : null;
20
+ if (name === null) return null;
21
+ const store = storeOf(name);
22
+ return store?.ledger ?? null;
23
+ }
24
+
25
+ /**
26
+ * A writer for one chat that never throws and keeps the order it was given:
27
+ * `write(entries)` queues them, `flush()` waits for every write so far. A
28
+ * write that failed is logged by count and kind, never its words.
29
+ */
30
+ function ledgerWriter(ledger, chat) {
31
+ if (ledger === null || typeof chat !== "string" || chat === "") return null;
32
+ let chain = Promise.resolve();
33
+ const write = (entries) => {
34
+ const list = (Array.isArray(entries) ? entries : [entries]).filter(Boolean);
35
+ if (list.length === 0) return chain;
36
+ chain = chain.then(async () => {
37
+ for (let at = 0; at < list.length; at += 100) {
38
+ try {
39
+ await ledger.append(chat, list.slice(at, at + 100));
40
+ } catch (error) {
41
+ console.log(JSON.stringify({ event: "ledger_write_failed", count: list.length, kinds: [...new Set(list.map((entry) => entry.kind))], reason: String(error?.name ?? "error").slice(0, 40) }));
42
+ }
43
+ }
44
+ });
45
+ return chain;
46
+ };
47
+ return { write, flush: () => chain };
48
+ }
49
+
50
+ /**
51
+ * Whose ledger a session's turn writes and under which chat: a group's when
52
+ * the grant names one (`chat:<groupKey>`, chat = the group key), the person's
53
+ * own one-to-one chat on their personal workspace (`person:<workspaceId>`,
54
+ * chat `texts`), otherwise none.
55
+ */
56
+ function ledgerPlace(session) {
57
+ if (typeof session?.texChatId === "string" && GROUP_KEY.test(session.texChatId)) return { owner: { chat: session.texChatId }, chat: session.texChatId };
58
+ // A group grant that names no chat keeps none: never the person's own one-to-one ledger, which a group's words must not reach.
59
+ if (session?.actorClientId === TEXTS_GROUP_CLIENT_ID) return null;
60
+ if (session?.workspaceKind === "personal" && typeof session.workspaceId === "string" && session.workspaceId !== "") return { owner: { person: session.workspaceId }, chat: ONE_TO_ONE_CHAT };
61
+ return null;
62
+ }
63
+
64
+ /**
65
+ * The writer for the ledger of the chat a session's turn is in, through the
66
+ * turn's own store (`store/texRouting.js` `texLedger`), or null when the
67
+ * session keeps none (the app, a shared workspace's own connection).
68
+ */
69
+ function storeLedger(store, session) {
70
+ const place = ledgerPlace(session);
71
+ if (place === null || typeof store?.texLedger !== "function") return null;
72
+ return ledgerWriter(store.texLedger(place.owner.chat ?? null), place.chat);
73
+ }
74
+
75
+ /**
76
+ * A writer that marks every entry with the background job whose turn wrote it
77
+ * (`jobId`, `jobTitle`), so the chat's one record says which work was a job's
78
+ * (the owner, 2026-11-02: sub-agent work "in the chat's history, tagged").
79
+ * `job` entries keep their own `job` field; this never replaces it.
80
+ */
81
+ function jobTagged(writer, job) {
82
+ if (writer === null || !job || typeof job.id !== "string") return writer;
83
+ const tag = { jobId: job.id, ...(typeof job.title === "string" && job.title ? { jobTitle: job.title } : {}) };
84
+ return {
85
+ ...writer,
86
+ write: (entries) => writer.write((Array.isArray(entries) ? entries : [entries]).filter(Boolean).map((entry) => ({ ...entry, ...tag }))),
87
+ flush: () => writer.flush(),
88
+ };
89
+ }
90
+
91
+ module.exports = { ONE_TO_ONE_CHAT, ledgerIn, ledgerWriter, ledgerPlace, storeLedger, jobTagged };
@@ -0,0 +1,21 @@
1
+ /** Types for `chatLedger.cjs`; see that file. */
2
+
3
+ export interface ChatLedger {
4
+ append(chat: string, entries: unknown[]): Promise<unknown>;
5
+ read(chat: string, options?: Record<string, unknown>): Promise<any>;
6
+ chats(): Promise<any>;
7
+ }
8
+ export interface LedgerWriter {
9
+ write(entries: unknown): Promise<void>;
10
+ flush(): Promise<void>;
11
+ }
12
+ export interface LedgerOwner {
13
+ person?: string;
14
+ chat?: string;
15
+ }
16
+ export declare const ONE_TO_ONE_CHAT: string;
17
+ export declare function ledgerIn(storeOf: (name: string) => any, owner: LedgerOwner | null | undefined): ChatLedger | null;
18
+ export declare function ledgerWriter(ledger: ChatLedger | null, chat: string): LedgerWriter | null;
19
+ export declare function ledgerPlace(session: any): { owner: LedgerOwner; chat: string } | null;
20
+ export declare function storeLedger(store: any, session: any): LedgerWriter | null;
21
+ export declare function jobTagged(writer: LedgerWriter | null, job: { id?: unknown; title?: unknown } | null | undefined): LedgerWriter | null;
@@ -0,0 +1,102 @@
1
+ /**
2
+ * Tex's tools for a person's own computers, as Tex and the gateway both name them
3
+ * (docs/decisions/texting-assistant/machines.md, computer-setup.md).
4
+ *
5
+ * The work is the gateway's (`apps/mcp/src/machines/texActions.js`, `forJobs.js`, `forTurn.js`, `groupAsk.js`),
6
+ * reached by Tex over MCP like any tool (`packages/tex/gateway/agent/machineDoor.js`):
7
+ *
8
+ * - `tex_computers`: the tool the model calls, `send` action `computers`;
9
+ * - `tex_machines`: the computers a chat turn may name (`list`), how a job picks one (`pick`), and the turn's
10
+ * words about them (`words`). Not offered to any model;
11
+ * - `tex_machine_thumb`: a computer owner's tapback on the chat's ask to run a job there. Not offered to any model.
12
+ *
13
+ * Only Tex's own texting clients may call any of them (`TEX_MACHINE_TOOLS`, `apps/mcp/src/machines/texTools.js`).
14
+ */
15
+
16
+ const { TEXTS_CLIENT_ID, TEXTS_GROUP_CLIENT_ID } = require("./texClients.cjs");
17
+
18
+ const COMPUTER_TOOL = "tex_computers";
19
+ const MACHINE_TOOL = "tex_machines";
20
+ const MACHINE_THUMB_TOOL = "tex_machine_thumb";
21
+ /** Every tool here: answered by the gateway for Tex's texting clients only, and never listed. */
22
+ const TEX_MACHINE_TOOLS = Object.freeze(new Set([COMPUTER_TOOL, MACHINE_TOOL, MACHINE_THUMB_TOOL]));
23
+
24
+ /** The argument Tex lays its own facts under (the person's words, the judge's answer); never the model's. */
25
+ const TEX_FACTS = "_tex";
26
+
27
+ const COMPUTER_DOES = Object.freeze(["list", "setup_prompt", "pair", "lend", "unlend", "rename", "limits", "more_time", "install", "sign_in", "sign_in_code", "disconnect"]);
28
+ const SETUP_SYSTEMS = Object.freeze(["mac", "linux", "headless"]);
29
+ const CODING_TOOLS = Object.freeze({ claude: "Claude Code", codex: "Codex" });
30
+ const CHAT_KEY = /^[0-9a-f]{64}$/;
31
+
32
+ const COMPUTER_TOOL_DEFINITION = Object.freeze({
33
+ name: COMPUTER_TOOL,
34
+ description:
35
+ "Set up and run the person's own computers yourself, instead of sending them to buttons: never tell them to do in the app what this does. " +
36
+ "do: list (their computers and how each is set), setup_prompt (the prompt for Claude Code or Codex on a computer that isn't paired yet; pass system mac, linux or headless), " +
37
+ "pair (approve the code its runner shows, passed exactly as they texted it; their own texts only), lend / unlend (lend it to this group chat or take it back, " +
38
+ "who: everyone, me, or @handles, ask_first true or false; a group only), rename (name), limits (slots, day_hours, week_hours, others_day_hours), " +
39
+ "more_time (hours, today only), install (tool claude or codex), sign_in (tool; texts them the link; their own texts only), sign_in_code (code they texted back), disconnect. " +
40
+ "computer names one of theirs; leave it out when they have one. What only they can do: paste the prompt into their agent (or run it), sign in to their own account on the page " +
41
+ "the link opens, and text you the code. Say just that, and do the rest.",
42
+ inputSchema: {
43
+ type: "object",
44
+ properties: {
45
+ do: { type: "string", enum: COMPUTER_DOES },
46
+ computer: { type: "string" },
47
+ system: { type: "string", enum: SETUP_SYSTEMS },
48
+ code: { type: "string" },
49
+ who: { type: "string" },
50
+ ask_first: { type: "boolean" },
51
+ name: { type: "string" },
52
+ tool: { type: "string", enum: Object.keys(CODING_TOOLS) },
53
+ hours: { type: "number" },
54
+ slots: { type: "integer" },
55
+ day_hours: { type: "number" },
56
+ week_hours: { type: "number" },
57
+ others_day_hours: { type: "number" },
58
+ },
59
+ required: ["do"],
60
+ },
61
+ });
62
+
63
+ /** The `send` action the tool is shown as (`sixTools.js`). */
64
+ const COMPUTER_SEND_ACTIONS = Object.freeze({
65
+ computers: { tool: COMPUTER_TOOL, summary: "Set up and run their own computers yourself: list, setup prompt, pair by texted code, lend to this group, rename, limits, more time, install, sign in, disconnect." },
66
+ });
67
+
68
+ /**
69
+ * Whether a texted turn is offered `tex_computers`: a person's own texts, or a group chat's turn, and never a
70
+ * guest's tag or a grant without its person.
71
+ */
72
+ function computerToolOffered(session, group) {
73
+ const own = session?.actorClientId === TEXTS_CLIENT_ID && group === null;
74
+ const groupKey = session?.actorClientId === TEXTS_GROUP_CLIENT_ID && CHAT_KEY.test(session.texChatId ?? "") ? session.texChatId : null;
75
+ if (!own && groupKey === null) return false;
76
+ return !(group?.guestTagger === true || typeof session.actorUserId !== "string" || session.actorUserId === "");
77
+ }
78
+
79
+ /** The agents `delegate` reaches on the web that a paired computer runs itself. */
80
+ const COMPUTER_AGENTS = Object.freeze(new Set(["claude-code", "codex"]));
81
+
82
+ /** The computers that can take code: Claude Code or Codex on them. */
83
+ function codeComputers(machines) {
84
+ return (Array.isArray(machines) ? machines : []).filter((machine) => (machine?.tools ?? []).some((tool) => tool === "claude" || tool === "codex"));
85
+ }
86
+
87
+ module.exports = {
88
+ COMPUTER_TOOL,
89
+ MACHINE_TOOL,
90
+ MACHINE_THUMB_TOOL,
91
+ TEX_MACHINE_TOOLS,
92
+ TEX_FACTS,
93
+ COMPUTER_DOES,
94
+ SETUP_SYSTEMS,
95
+ CODING_TOOLS,
96
+ CHAT_KEY,
97
+ COMPUTER_TOOL_DEFINITION,
98
+ COMPUTER_SEND_ACTIONS,
99
+ computerToolOffered,
100
+ COMPUTER_AGENTS,
101
+ codeComputers,
102
+ };
@@ -0,0 +1,16 @@
1
+ /** Types for `computerTool.cjs`; see that file. */
2
+
3
+ export declare const COMPUTER_TOOL: "tex_computers";
4
+ export declare const MACHINE_TOOL: "tex_machines";
5
+ export declare const MACHINE_THUMB_TOOL: "tex_machine_thumb";
6
+ export declare const TEX_MACHINE_TOOLS: ReadonlySet<string>;
7
+ export declare const TEX_FACTS: "_tex";
8
+ export declare const COMPUTER_DOES: readonly string[];
9
+ export declare const SETUP_SYSTEMS: readonly string[];
10
+ export declare const CODING_TOOLS: Readonly<Record<string, string>>;
11
+ export declare const CHAT_KEY: RegExp;
12
+ export declare const COMPUTER_TOOL_DEFINITION: { name: string; description: string; inputSchema: Record<string, unknown> };
13
+ export declare const COMPUTER_SEND_ACTIONS: Readonly<Record<string, { tool: string; summary: string }>>;
14
+ export declare function computerToolOffered(session: unknown, group: unknown): boolean;
15
+ export declare const COMPUTER_AGENTS: ReadonlySet<string>;
16
+ export declare function codeComputers<T>(machines: T[] | null | undefined): T[];
@@ -0,0 +1,22 @@
1
+ /**
2
+ * The consent check's words test (`consentContext.js`): a reply that names the thing, or, with a judge, answers Tex's
3
+ * own offer. The gateway's texting actions (`machines/texActions.js`) run it on the same words.
4
+ */
5
+
6
+ /** The longest reply that may answer Tex's offer instead of naming the thing itself ("ok yeah go ahead and share it"). */
7
+ const MAX_YES = 160;
8
+
9
+ /**
10
+ * The code word check before a consent judge: the person's own words name the thing (`pattern`), or (Dev2,
11
+ * 2026-11-22) they are a short reply to Tex's last text and that text names it, so "yes", "go ahead" or "do it" can
12
+ * answer Tex's own offer. Only with a judge (`judged`): the judge, shown the same offer as `offered`, still decides
13
+ * whether the reply agrees to it.
14
+ */
15
+ function namesOrAnswers(pattern, words, offered = "", judged = false) {
16
+ const said = typeof words === "string" ? words.trim() : "";
17
+ if (pattern.test(said)) return true;
18
+ if (!judged || said === "" || said.length > MAX_YES) return false;
19
+ return typeof offered === "string" && offered !== "" && pattern.test(offered);
20
+ }
21
+
22
+ module.exports = { MAX_YES, namesOrAnswers };
@@ -0,0 +1,5 @@
1
+ /** Types for `consentYes.cjs`; see that file. */
2
+
3
+ export declare const MAX_YES: number;
4
+
5
+ export declare function namesOrAnswers(pattern: RegExp, words: unknown, offered?: unknown, judged?: boolean): boolean;
@@ -0,0 +1,52 @@
1
+ /**
2
+ * WHAT TEX STILL TAKES FROM THE GATEWAY IT RUNS IN, HANDED OVER AT START-UP RATHER THAN IMPORTED.
3
+ *
4
+ * Tex is becoming its own service, an MCP client of Context like any other
5
+ * (docs/decisions/texting-assistant/tex-service.md). Until it moves out, the gateway answers a few of its needs
6
+ * in-process: an MCP `tools/call` as one person, a call of an action only Tex's own code makes, marking a turn's egress ledger for a read, the privacy engine's
7
+ * answers about a key, the egress judge, the control-plane client, and a session's tool list (and the plugin switches it
8
+ * reads) when Tex runs in-process, without the `CONTEXT_MCP` binding. The gateway connects them here once, when its dispatcher loads
9
+ * (`apps/mcp/src/tools/session.js`), and Tex reaches them only through `packages/tex/gateway/contextMcp.js`, so Tex's
10
+ * code imports no gateway module and each of these is one named seam to swap for MCP when it moves.
11
+ *
12
+ * Nothing here decides anything: each function is the gateway's own, unchanged, so every gate and privacy rule still
13
+ * runs where it ran.
14
+ */
15
+
16
+ /** The names the gateway must hand over, every one a function. */
17
+ const CONTEXT_GATEWAY_PARTS = Object.freeze(["callTool", "callTexAction", "recordRead", "controlPlane", "isPlumbing", "readsAsChat", "canSee", "storeRules", "teamCanSee", "judgeWords", "listTools", "disabledTools"]);
18
+
19
+ let connected = null;
20
+
21
+ /**
22
+ * Connect the gateway's parts. Once per isolate: connecting again with the very same functions is a no-op, and with
23
+ * any other is refused, so nothing loaded later can swap the dispatcher Tex calls through.
24
+ */
25
+ function connectContextGateway(parts) {
26
+ const given = {};
27
+ for (const name of CONTEXT_GATEWAY_PARTS) {
28
+ if (typeof parts?.[name] !== "function") throw new TypeError(`connectContextGateway: ${name} must be a function`);
29
+ given[name] = parts[name];
30
+ }
31
+ if (connected !== null) {
32
+ if (CONTEXT_GATEWAY_PARTS.every((name) => connected[name] === given[name])) return;
33
+ throw new Error("connectContextGateway: the gateway is already connected");
34
+ }
35
+ connected = Object.freeze(given);
36
+ }
37
+
38
+ /** The gateway's parts, or a loud failure when no gateway has connected (Tex code run without one). */
39
+ function contextGateway() {
40
+ if (connected === null) throw new Error("contextGateway: no gateway has connected (apps/mcp/src/tools/session.js connects it)");
41
+ return connected;
42
+ }
43
+
44
+ /**
45
+ * Whether a gateway connected in this isolate: true wherever Tex runs in-process in the gateway, false in Tex's own
46
+ * Worker, which never loads the dispatcher. Read only by a seam that, in Tex's Worker, leaves its check to the door.
47
+ */
48
+ function gatewayConnected() {
49
+ return connected !== null;
50
+ }
51
+
52
+ module.exports = { CONTEXT_GATEWAY_PARTS, connectContextGateway, contextGateway, gatewayConnected };
@@ -0,0 +1,19 @@
1
+ /** Types for `contextGateway.cjs`; see that file. */
2
+
3
+ export interface ContextGatewayParts {
4
+ callTool: (params: unknown, store: unknown, session: unknown, options?: unknown) => Promise<any>;
5
+ callTexAction: (params: unknown, store: unknown, session: unknown) => Promise<any>;
6
+ recordRead: (ledger: unknown, call: { name: string; args?: unknown; result: unknown; writing?: boolean }) => void;
7
+ controlPlane: (env: unknown) => any;
8
+ isPlumbing: (key: string) => boolean;
9
+ readsAsChat: (names: unknown) => boolean;
10
+ canSee: (key: string, scope: string, rules: unknown, overrides: unknown) => boolean;
11
+ storeRules: (store: unknown) => Promise<{ rules: unknown; overrides: unknown } | { error: string }>;
12
+ teamCanSee: (store: unknown, path: string) => Promise<boolean>;
13
+ judgeWords: (input: unknown, config: unknown, options?: { model?: string; effort?: string; fetchImpl?: unknown }) => Promise<{ allow: boolean; reason: string }>;
14
+ }
15
+
16
+ export declare const CONTEXT_GATEWAY_PARTS: readonly (keyof ContextGatewayParts)[];
17
+ export declare function connectContextGateway(parts: ContextGatewayParts): void;
18
+ export declare function contextGateway(): ContextGatewayParts;
19
+ export declare function gatewayConnected(): boolean;