@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.
- package/LICENSE +21 -0
- package/README.md +33 -2
- package/package.json +16 -4
- package/texContract/aboutLines.cjs +117 -0
- package/texContract/aboutLines.d.cts +14 -0
- package/texContract/aboutNoteLimits.cjs +41 -0
- package/texContract/aboutNoteLimits.d.cts +5 -0
- package/texContract/actionManual.cjs +104 -0
- package/texContract/activityHint.cjs +40 -0
- package/texContract/activityHint.d.cts +4 -0
- package/texContract/asks.cjs +16 -0
- package/texContract/asks.d.cts +6 -0
- package/texContract/asksToFile.cjs +20 -0
- package/texContract/asksToFile.d.cts +2 -0
- package/texContract/attention.cjs +138 -0
- package/texContract/attention.d.cts +20 -0
- package/texContract/browserHandback.cjs +13 -0
- package/texContract/browserHandback.d.cts +3 -0
- package/texContract/browserOwner.cjs +31 -0
- package/texContract/browserOwner.d.cts +2 -0
- package/texContract/bytes.cjs +12 -0
- package/texContract/capabilities.cjs +47 -0
- package/texContract/capabilities.d.cts +27 -0
- package/texContract/capabilities.generated.json +77 -0
- package/texContract/chatHistoryPath.cjs +38 -0
- package/texContract/chatHistoryPath.d.cts +5 -0
- package/texContract/chatLedger.cjs +91 -0
- package/texContract/chatLedger.d.cts +21 -0
- package/texContract/computerTool.cjs +102 -0
- package/texContract/computerTool.d.cts +16 -0
- package/texContract/consentYes.cjs +22 -0
- package/texContract/consentYes.d.cts +5 -0
- package/texContract/contextGateway.cjs +52 -0
- package/texContract/contextGateway.d.cts +19 -0
- package/texContract/deskEligible.cjs +20 -0
- package/texContract/deskEligible.d.cts +3 -0
- package/texContract/downloads.cjs +129 -0
- package/texContract/downloads.d.cts +15 -0
- package/texContract/egressLedger.cjs +114 -0
- package/texContract/egressLedger.d.cts +14 -0
- package/texContract/emailRead.cjs +38 -0
- package/texContract/emailRead.d.cts +5 -0
- package/texContract/eventWords.cjs +35 -0
- package/texContract/eventWords.d.cts +4 -0
- package/texContract/fileParts.cjs +43 -0
- package/texContract/fileParts.d.cts +6 -0
- package/texContract/fileTables.cjs +243 -0
- package/texContract/fileWords.cjs +169 -0
- package/texContract/folded.cjs +16 -0
- package/texContract/folded.d.cts +3 -0
- package/texContract/googleAiAccess.cjs +12 -0
- package/texContract/googleAiAccess.d.cts +2 -0
- package/texContract/graphWires.cjs +18 -0
- package/texContract/graphWires.d.cts +5 -0
- package/texContract/groupSession.cjs +28 -0
- package/texContract/groupSession.d.cts +7 -0
- package/texContract/guestNames.cjs +136 -0
- package/texContract/guestNames.d.cts +35 -0
- package/texContract/heard.cjs +19 -0
- package/texContract/heard.d.cts +4 -0
- package/texContract/heldOffer.cjs +57 -0
- package/texContract/heldOffer.d.cts +8 -0
- package/texContract/helperCallers.cjs +29 -0
- package/texContract/helperCallers.d.cts +4 -0
- package/texContract/identity.cjs +179 -0
- package/texContract/identity.d.cts +8 -0
- package/texContract/jobLogEntries.cjs +93 -0
- package/texContract/jobLogEntries.d.cts +12 -0
- package/texContract/judgedActions.cjs +20 -0
- package/texContract/judgedActions.d.cts +4 -0
- package/texContract/labSandboxGate.cjs +63 -0
- package/texContract/labSandboxGate.d.cts +9 -0
- package/texContract/ledgerReadChars.cjs +4 -0
- package/texContract/ledgerReadChars.d.cts +3 -0
- package/texContract/mailCheck.cjs +90 -0
- package/texContract/mailCheck.d.cts +12 -0
- package/texContract/mailEntries.cjs +64 -0
- package/texContract/mailEntries.d.cts +13 -0
- package/texContract/mailHealth.cjs +60 -0
- package/texContract/mailHealth.d.cts +10 -0
- package/texContract/notePath.cjs +99 -0
- package/texContract/notePath.d.cts +4 -0
- package/texContract/noteRunFacts.cjs +136 -0
- package/texContract/noteRunFacts.d.cts +32 -0
- package/texContract/objectEtag.cjs +84 -0
- package/texContract/objectEtag.d.cts +4 -0
- package/texContract/objectPlace.cjs +32 -0
- package/texContract/objectPlace.d.cts +5 -0
- package/texContract/pageJobs.cjs +226 -0
- package/texContract/pageJobs.d.cts +13 -0
- package/texContract/pdfLinks.cjs +135 -0
- package/texContract/pdfLinks.d.cts +4 -0
- package/texContract/personHub.cjs +38 -0
- package/texContract/personHub.d.cts +5 -0
- package/texContract/personNameText.cjs +18 -0
- package/texContract/personNameText.d.cts +3 -0
- package/texContract/pinnedContext.cjs +12 -0
- package/texContract/pinnedContext.d.cts +3 -0
- package/texContract/quietHoursWindow.cjs +36 -0
- package/texContract/quietHoursWindow.d.cts +3 -0
- package/texContract/reactEmoji.cjs +79 -0
- package/texContract/reactEmoji.d.cts +2 -0
- package/texContract/scopeClamp.cjs +117 -0
- package/texContract/scopeClamp.d.cts +5 -0
- package/texContract/scopes.cjs +29 -0
- package/texContract/scopes.d.cts +7 -0
- package/texContract/searchSettings.cjs +54 -0
- package/texContract/searchSettings.d.cts +6 -0
- package/texContract/settingHabits.cjs +87 -0
- package/texContract/settingHabits.d.cts +20 -0
- package/texContract/settingsNotes.cjs +217 -0
- package/texContract/settingsNotes.d.cts +26 -0
- package/texContract/shownEmail.cjs +181 -0
- package/texContract/texClients.cjs +53 -0
- package/texContract/texClients.d.cts +12 -0
- package/texContract/texGraph.cjs +593 -0
- package/texContract/texGraph.d.cts +55 -0
- package/texContract/texKeys.cjs +100 -0
- package/texContract/texKeys.d.cts +13 -0
- package/texContract/texNumber.cjs +20 -0
- package/texContract/texNumber.d.cts +3 -0
- package/texContract/texOwnSources.cjs +9 -0
- package/texContract/texOwnSources.d.cts +3 -0
- package/texContract/texSettings.cjs +22 -0
- package/texContract/texSettings.d.cts +20 -0
- package/texContract/texSettings.generated.json +25 -0
- package/texContract/texStateFiles.cjs +22 -0
- package/texContract/texStateFiles.d.cts +9 -0
- package/texContract/texSteps.cjs +27 -0
- package/texContract/texSteps.d.cts +14 -0
- package/texContract/texSteps.generated.json +41 -0
- package/texContract/texStoreNames.cjs +26 -0
- package/texContract/texStoreNames.d.cts +12 -0
- package/texContract/texStoreWire.cjs +306 -0
- package/texContract/texStoreWire.d.cts +32 -0
- package/texContract/threadsFold.cjs +75 -0
- package/texContract/threadsFold.d.cts +22 -0
- package/texContract/toolActions.cjs +253 -0
- package/texContract/toolCatalog.cjs +49 -0
- package/texContract/toolCatalog.generated.json +90 -0
- package/texContract/toolContract.cjs +52 -0
- package/texContract/toolContract.d.cts +12 -0
- package/texContract/toolShapes.cjs +14 -0
- package/texContract/transcription.cjs +101 -0
- package/texContract/transcription.d.cts +3 -0
- package/texContract/treeJobs.cjs +31 -0
- package/texContract/treeJobs.d.cts +3 -0
- package/texContract/turnSession.cjs +90 -0
- package/texContract/turnSession.d.cts +19 -0
- package/texContract/turnWords.cjs +90 -0
- package/texContract/turnWords.d.cts +9 -0
- package/texContract/uploadImages.cjs +131 -0
- package/texContract/uploadImages.d.cts +13 -0
- package/texContract/v2Names.cjs +41 -0
- package/texContract/v2SearchFetch.cjs +316 -0
- package/texContract/v2Translate.cjs +123 -0
- package/texContract/vaultTools.cjs +112 -0
- package/texContract/vaultTools.d.cts +15 -0
- package/texContract/yesWords.cjs +91 -0
- package/texShared/argumentCoercion.cjs +93 -0
- package/texShared/cellComments.cjs +122 -0
- package/texShared/cellComments.d.cts +21 -0
- package/texShared/comments.cjs +586 -0
- package/texShared/comments.d.cts +115 -0
- package/texShared/contentTypes.cjs +85 -0
- package/texShared/fileKinds.cjs +123 -0
- package/texShared/flags.cjs +159 -0
- package/texShared/flags.d.cts +23 -0
- package/texShared/folderJobInfo.cjs +301 -0
- package/texShared/folderJobInfo.d.cts +40 -0
- package/texShared/folderRoles.cjs +512 -0
- package/texShared/folderRoles.d.cts +73 -0
- package/texShared/githubOidc.ts +98 -0
- package/texShared/groupRunQuestions.cjs +98 -0
- package/texShared/groupRunQuestions.d.cts +4 -0
- package/texShared/inboxFolders.cjs +49 -0
- package/texShared/inboxFolders.d.cts +5 -0
- package/texShared/ink/drawing.cjs +474 -0
- package/texShared/ink/texFigure.cjs +252 -0
- package/texShared/ink/texFigure.d.cts +36 -0
- package/texShared/ink/texPoses.cjs +180 -0
- package/texShared/ink/texPoses.d.cts +20 -0
- package/texShared/jobPartEnd.cjs +133 -0
- package/texShared/jobPartEnd.d.cts +13 -0
- package/texShared/jobResume.cjs +31 -0
- package/texShared/jobResume.d.cts +5 -0
- package/texShared/jobSplit.cjs +90 -0
- package/texShared/jobSplit.d.cts +6 -0
- package/texShared/jobStart.cjs +56 -0
- package/texShared/jobStart.d.cts +9 -0
- package/texShared/mail.cjs +400 -0
- package/texShared/mail.d.cts +56 -0
- package/texShared/messageAnchors.cjs +38 -0
- package/texShared/models/aiKeys.cjs +137 -0
- package/texShared/models/aiKeys.d.cts +42 -0
- package/texShared/models/aiKeys.json +56 -0
- package/texShared/models/creditRest.cjs +269 -0
- package/texShared/models/promptBudget.cjs +295 -0
- package/texShared/models/promptSections.cjs +29 -0
- package/texShared/noteAppLink.cjs +23 -0
- package/texShared/notePreview.cjs +219 -0
- package/texShared/notePreview.d.cts +21 -0
- package/texShared/pages/blocks.cjs +215 -0
- package/texShared/pages/cover.cjs +164 -0
- package/texShared/pages/css.cjs +181 -0
- package/texShared/pages/cssBlocks.cjs +264 -0
- package/texShared/pages/draw.cjs +212 -0
- package/texShared/pages/drawRich.cjs +232 -0
- package/texShared/pages/html.cjs +168 -0
- package/texShared/pages/inline.cjs +251 -0
- package/texShared/pages/layout.cjs +76 -0
- package/texShared/pages/parse.cjs +418 -0
- package/texShared/pages/render.cjs +200 -0
- package/texShared/pages/skill.cjs +147 -0
- package/texShared/pages/skill.d.cts +5 -0
- package/texShared/pages/templates.cjs +336 -0
- package/texShared/r2Store.cjs +163 -0
- package/texShared/remoteImage.cjs +177 -0
- package/texShared/routines.cjs +656 -0
- package/texShared/routines.d.cts +86 -0
- package/texShared/servedListing.cjs +250 -0
- package/texShared/servedListing.d.cts +17 -0
- package/texShared/sheetCsv.cjs +566 -0
- package/texShared/sheetCsv.d.cts +91 -0
- package/texShared/storageLayout.cjs +88 -0
- package/texShared/storeKeys.cjs +144 -0
- package/texShared/toolArguments.cjs +323 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A grant's scopes clamped by the role its person holds: what a live request may do in one workspace
|
|
3
|
+
* (`apps/mcp/src/session.js`, which imports these and is where every request is clamped), and what orientation says a
|
|
4
|
+
* connection may do in each context it reaches (`texContract/identity.cjs` `contextsFor`). Pure, and one copy, so the
|
|
5
|
+
* description and the decision cannot disagree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const { SCOPE_READ, SCOPE_WRITE, SCOPE_CAPTURE, SCOPE_PRIVATE } = require("./scopes.cjs");
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* The privacy tier this grant was given.
|
|
12
|
+
*
|
|
13
|
+
* **Read from the grant, then clamped by role — never derived from role.**
|
|
14
|
+
* That inversion is the whole change. `visibilityTierForRole(role)` used to
|
|
15
|
+
* live here and answered `private` for every owner, which meant an owner could
|
|
16
|
+
* not connect a client at team level even if that was exactly what they wanted:
|
|
17
|
+
* every note they had ever marked private went to whatever they connected. The
|
|
18
|
+
* tier is now something a person decided at consent time and the grant carries,
|
|
19
|
+
* so an owner who granted `team` gets `team` on every later request, forever.
|
|
20
|
+
*
|
|
21
|
+
* The role clamp stays, and is not redundant with the control plane's. The
|
|
22
|
+
* control plane decides what may be *written* into a grant, at approval time;
|
|
23
|
+
* this decides what a *live request* may do with one, now. Between those two
|
|
24
|
+
* moments a membership can change — and while an owner cannot be demoted, a
|
|
25
|
+
* grant is not the only thing that can go stale. Reading a value the control
|
|
26
|
+
* plane vouched for and enforcing it against the role the control plane
|
|
27
|
+
* reported in the same breath costs one `Set` and closes the gap.
|
|
28
|
+
*/
|
|
29
|
+
function visibilityTierForGrant(grantScopes, role) {
|
|
30
|
+
if (role !== "owner") return "team";
|
|
31
|
+
return new Set(grantScopes).has(SCOPE_PRIVATE) ? "private" : "team";
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** Roles that may change content at all, before per-grant scopes narrow it. */
|
|
35
|
+
function roleCanWrite(role) {
|
|
36
|
+
return role === "owner" || role === "editor";
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Grant scopes ∩ what the role permits.
|
|
41
|
+
*
|
|
42
|
+
* Both halves matter and neither implies the other. A read-only grant issued to
|
|
43
|
+
* an owner must not write — the person deliberately connected a client that way
|
|
44
|
+
* — and a full-scope grant issued to a read-only `member` must not write
|
|
45
|
+
* either, because the grant cannot confer authority the membership never had.
|
|
46
|
+
*
|
|
47
|
+
* `SCOPE_PRIVATE` goes through the same intersection as everything else: it
|
|
48
|
+
* survives only if the grant carries it *and* the caller is the owner. It is
|
|
49
|
+
* kept on a capture-only grant too, where it means nothing — the tier only
|
|
50
|
+
* matters to reads — because filtering it out there would be a special case
|
|
51
|
+
* that has to stay in sync with which scopes read, and there is nothing to gain
|
|
52
|
+
* from one.
|
|
53
|
+
*/
|
|
54
|
+
function effectiveScopes(grantScopes, role) {
|
|
55
|
+
const granted = new Set(grantScopes);
|
|
56
|
+
const effective = [SCOPE_READ];
|
|
57
|
+
if (granted.has(SCOPE_WRITE) && roleCanWrite(role)) {
|
|
58
|
+
effective.push(SCOPE_WRITE, SCOPE_CAPTURE);
|
|
59
|
+
} else if (granted.has(SCOPE_CAPTURE) && roleCanWrite(role)) {
|
|
60
|
+
effective.push(SCOPE_CAPTURE);
|
|
61
|
+
}
|
|
62
|
+
// The tier the person granted, and only for the one role that could grant it.
|
|
63
|
+
// A grant that predates the tier being grantable carries no `context:private`
|
|
64
|
+
// and therefore lands on `team` — a narrowing, which is always allowed, and
|
|
65
|
+
// the only reading that does not leave every legacy grant at full access.
|
|
66
|
+
if (granted.has(SCOPE_PRIVATE) && role === "owner") {
|
|
67
|
+
effective.push(SCOPE_PRIVATE);
|
|
68
|
+
}
|
|
69
|
+
// A grant with no read scope is capture-only: it may drop things into the
|
|
70
|
+
// inbox and may not look at anything.
|
|
71
|
+
if (!granted.has(SCOPE_READ)) {
|
|
72
|
+
return effective.filter((scope) => scope !== SCOPE_READ);
|
|
73
|
+
}
|
|
74
|
+
return effective;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* What this connection may actually do in a context where its person holds
|
|
79
|
+
* `role` — the tier it reads at there, and whether it may write.
|
|
80
|
+
*
|
|
81
|
+
* `writesAnywhere`'s question asked of one context instead of all of them, and
|
|
82
|
+
* here for the same reason that one is: the clamp that answers it is this
|
|
83
|
+
* module's, and a second copy of `effectiveScopes` reasoning is the drift this
|
|
84
|
+
* file exists to prevent. `orient` describes every context a connection
|
|
85
|
+
* reaches, and it described them from the *role* alone — which is neither
|
|
86
|
+
* half of the answer. A read-only grant held by an `editor` was announced as
|
|
87
|
+
* writable; an `owner` was described as reading private notes on a grant that
|
|
88
|
+
* carries no `context:private` and reads that context at `team`.
|
|
89
|
+
*
|
|
90
|
+
* It answers from the grant's own scopes, never the connection's already
|
|
91
|
+
* clamped set, exactly as `sessionForContext` does: re-clamping intersects two
|
|
92
|
+
* roles and would describe a context somebody owns by the role they hold
|
|
93
|
+
* somewhere else.
|
|
94
|
+
*
|
|
95
|
+
* This is a description, never a decision. The gate in `callToolForSession`
|
|
96
|
+
* still decides, from the session `sessionForContext` builds — but both read
|
|
97
|
+
* the same clamp, so what orientation promises and what the call does cannot
|
|
98
|
+
* disagree.
|
|
99
|
+
*/
|
|
100
|
+
function reachForRole(session, role) {
|
|
101
|
+
const granted = session?.grantScopes || session?.scopes || [];
|
|
102
|
+
const scopes = effectiveScopes(granted, role);
|
|
103
|
+
return {
|
|
104
|
+
tier: visibilityTierForGrant(scopes, role),
|
|
105
|
+
canWrite: scopes.includes(SCOPE_WRITE),
|
|
106
|
+
/*
|
|
107
|
+
Which of the two halves said no, because the remedies differ and
|
|
108
|
+
`callToolForSession` already refuses in exactly these two voices. A grant
|
|
109
|
+
that was never given write is a reconnection the person can make; a role
|
|
110
|
+
that cannot back one up is not, and telling them to reconnect for write
|
|
111
|
+
they can never hold there sends them round a loop that cannot end.
|
|
112
|
+
*/
|
|
113
|
+
grantWrites: new Set(granted).has(SCOPE_WRITE),
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
module.exports = { visibilityTierForGrant, effectiveScopes, reachForRole };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Types for `scopeClamp.cjs`; see that file. */
|
|
2
|
+
|
|
3
|
+
export declare function visibilityTierForGrant(grantScopes: Iterable<string>, role: string): "private" | "team";
|
|
4
|
+
export declare function effectiveScopes(grantScopes: Iterable<string>, role: string): string[];
|
|
5
|
+
export declare function reachForRole(session: unknown, role: string): { tier: "private" | "team"; canWrite: boolean; grantWrites: boolean };
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The scope strings a Context grant carries, and the one check on them.
|
|
3
|
+
*
|
|
4
|
+
* Shared by the gateway and Tex, so both name a scope the same way. `apps/mcp/src/session.js` re-exports these, and
|
|
5
|
+
* keeps `SUPPORTED_SCOPES`; `SCOPE_CAPTURE` is here for the role clamp (`scopeClamp.cjs`).
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
/** Read every visible note. */
|
|
9
|
+
const SCOPE_READ = "context:read";
|
|
10
|
+
/** Create, update, move, and archive notes. Implies capture. */
|
|
11
|
+
const SCOPE_WRITE = "context:write";
|
|
12
|
+
/** File into the inbox and nowhere else. */
|
|
13
|
+
const SCOPE_CAPTURE = "context:capture";
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Reach notes marked private.
|
|
17
|
+
*
|
|
18
|
+
* Not an operation — holding it lets a client *do* nothing new. It widens the
|
|
19
|
+
* set of notes every other scope applies to, which is why it is the one scope
|
|
20
|
+
* a person is asked about separately on the consent screen and the one a
|
|
21
|
+
* client's request cannot decide.
|
|
22
|
+
*/
|
|
23
|
+
const SCOPE_PRIVATE = "context:private";
|
|
24
|
+
|
|
25
|
+
function hasScope(session, scope) {
|
|
26
|
+
return Array.isArray(session?.scopes) && session.scopes.includes(scope);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
module.exports = { SCOPE_READ, SCOPE_WRITE, SCOPE_CAPTURE, SCOPE_PRIVATE, hasScope };
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Types for `scopes.cjs`; see that file for the reasons. */
|
|
2
|
+
|
|
3
|
+
export declare const SCOPE_READ: "context:read";
|
|
4
|
+
export declare const SCOPE_WRITE: "context:write";
|
|
5
|
+
export declare const SCOPE_CAPTURE: "context:capture";
|
|
6
|
+
export declare const SCOPE_PRIVATE: "context:private";
|
|
7
|
+
export declare function hasScope(session: { scopes?: readonly string[] } | null | undefined, scope: string): boolean;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A setup's `search:` section, read and checked: the person-facing search
|
|
3
|
+
* settings (`minScore`, `extraNotes`, `snippetChars`, `everywhere`), what each
|
|
4
|
+
* may be, and their front-matter keys. A pure contract the gateway
|
|
5
|
+
* (`apps/mcp/src/search/settings.js` and `config/searchConfig.cjs`, which take
|
|
6
|
+
* the bounds from here) and Tex (`agent/production.js`) both read. Moved verbatim.
|
|
7
|
+
*/
|
|
8
|
+
"use strict";
|
|
9
|
+
|
|
10
|
+
/** What each person-facing setting may be; `searchConfig.cjs` lists them with the ranking knobs. */
|
|
11
|
+
const PERSON_SEARCH_BOUNDS = Object.freeze({
|
|
12
|
+
minScore: Object.freeze({ min: 0, max: 1, integer: false }),
|
|
13
|
+
extraNotes: Object.freeze({ min: 0, max: 10, integer: true }),
|
|
14
|
+
snippetChars: Object.freeze({ min: 50, max: 2000, integer: true }),
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
/** The front-matter and JSON key for each setting. */
|
|
18
|
+
const SEARCH_SETTING_KEYS = Object.freeze({
|
|
19
|
+
everywhere: "everywhere",
|
|
20
|
+
min_score: "minScore",
|
|
21
|
+
extra_notes: "extraNotes",
|
|
22
|
+
snippet_chars: "snippetChars",
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Settings from a plain object of wire keys (`min_score`, …), each checked, or
|
|
27
|
+
* `null` when a value is outside what it may be. Missing keys stay missing,
|
|
28
|
+
* so a partial section lays over another without blanking it.
|
|
29
|
+
*
|
|
30
|
+
* @param {unknown} raw e.g. `{ everywhere: "true", min_score: "0.35" }`
|
|
31
|
+
*/
|
|
32
|
+
function readSearchSettings(raw) {
|
|
33
|
+
if (raw === undefined || raw === null) return {};
|
|
34
|
+
if (typeof raw !== "object" || Array.isArray(raw)) return null;
|
|
35
|
+
const out = {};
|
|
36
|
+
for (const [key, value] of Object.entries(raw)) {
|
|
37
|
+
const name = SEARCH_SETTING_KEYS[key];
|
|
38
|
+
if (!name) return null;
|
|
39
|
+
if (name === "everywhere") {
|
|
40
|
+
if (value === true || value === "true") out.everywhere = true;
|
|
41
|
+
else if (value === false || value === "false") out.everywhere = false;
|
|
42
|
+
else return null;
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
const number = typeof value === "number" ? value : typeof value === "string" && /^\d+(\.\d+)?$/.test(value.trim()) ? Number(value) : NaN;
|
|
46
|
+
const bound = PERSON_SEARCH_BOUNDS[name];
|
|
47
|
+
if (!Number.isFinite(number) || number < bound.min || number > bound.max) return null;
|
|
48
|
+
if (bound.integer && !Number.isInteger(number)) return null;
|
|
49
|
+
out[name] = number;
|
|
50
|
+
}
|
|
51
|
+
return out;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
module.exports = { PERSON_SEARCH_BOUNDS, SEARCH_SETTING_KEYS, readSearchSettings };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Types for `searchSettings.cjs`; see that file. */
|
|
2
|
+
|
|
3
|
+
type Bound = { readonly min: number; readonly max: number; readonly integer: boolean };
|
|
4
|
+
export declare const PERSON_SEARCH_BOUNDS: { readonly minScore: Bound; readonly extraNotes: Bound; readonly snippetChars: Bound };
|
|
5
|
+
export declare const SEARCH_SETTING_KEYS: Readonly<Record<"everywhere" | "min_score" | "extra_notes" | "snippet_chars", string>>;
|
|
6
|
+
export declare function readSearchSettings(raw: unknown): { everywhere?: boolean; minScore?: number; extraNotes?: number; snippetChars?: number } | null;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The `setting` switches Tex changes by text (`packages/tex/gateway/agent/settingsTools.js`; Dev2, 2026-11-12,
|
|
3
|
+
* `docs/decisions/texting-assistant/settings-by-text.md`), read and set through one door, `call(name, args)`, an MCP
|
|
4
|
+
* tool call as the person. Tex's `tex_setting_set` and the Tex page's Settings (`apps/mcp/src/http/texPage/serve.js`)
|
|
5
|
+
* both use these setters, so a value the chat would refuse is refused on the page too, and both read the same notes.
|
|
6
|
+
* What each switch is called and how a change is said stays with Tex (`SETTING_HANDLERS`).
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const { DREAMS_SETTINGS_PATH, HEARTBEAT_SETTINGS_PATH, HOUSEKEEPING_SETTINGS_PATH, frontSet, readCheckinSettings, readSwitches } = require("./settingsNotes.cjs");
|
|
10
|
+
const { ATTENTION_SETTINGS_PATH, TOLERANCES, readAttentionSettings } = require("./attention.cjs");
|
|
11
|
+
const { readQuietHours } = require("./quietHoursWindow.cjs");
|
|
12
|
+
|
|
13
|
+
/** Read one note's front matter through the turn's own tool door, or null. */
|
|
14
|
+
async function readFront(dispatch, path) {
|
|
15
|
+
try {
|
|
16
|
+
const result = await dispatch("read_note", { path });
|
|
17
|
+
if (result?.isError === true) return "";
|
|
18
|
+
const all = (Array.isArray(result?.content) ? result.content : []).map((part) => part?.text ?? "").join("\n");
|
|
19
|
+
const split = all.indexOf("\n\n");
|
|
20
|
+
return split === -1 ? "" : all.slice(split + 2);
|
|
21
|
+
} catch {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const onOff = (value) => (value === true || /^(on|yes|true)$/i.test(String(value ?? "").trim()) ? true : value === false || /^(off|no|false)$/i.test(String(value ?? "").trim()) ? false : null);
|
|
27
|
+
|
|
28
|
+
/** Whether a `quiet_hours` value turns them off. */
|
|
29
|
+
const quietOff = (value) => /^(off|none|no|clear)$/i.test(String(value ?? "").trim());
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Each `setting` switch's setter, by `texSettings.cjs` key: it reads `value` and changes one note's front matter, or
|
|
33
|
+
* answers null when the value is not one it takes.
|
|
34
|
+
*/
|
|
35
|
+
const SETTING_SETTERS = Object.freeze({
|
|
36
|
+
checkins: (call, value) => (onOff(value) === null ? null : frontSet(call, HEARTBEAT_SETTINGS_PATH, "paused", onOff(value) ? "no" : "yes")),
|
|
37
|
+
quiet_hours: (call, value) => {
|
|
38
|
+
const words = String(value ?? "").trim();
|
|
39
|
+
if (quietOff(words)) return frontSet(call, HEARTBEAT_SETTINGS_PATH, "quiet-hours", null);
|
|
40
|
+
return readQuietHours(words) === null ? null : frontSet(call, HEARTBEAT_SETTINGS_PATH, "quiet-hours", words);
|
|
41
|
+
},
|
|
42
|
+
pings: async (call, value) => {
|
|
43
|
+
const words = String(value ?? "").trim().toLowerCase().replace(/ only$/, "");
|
|
44
|
+
if (words === "off") return frontSet(call, ATTENTION_SETTINGS_PATH, "paused", "yes");
|
|
45
|
+
if (!TOLERANCES.includes(words)) return null;
|
|
46
|
+
const paused = await frontSet(call, ATTENTION_SETTINGS_PATH, "paused", null);
|
|
47
|
+
return paused?.ok === true ? frontSet(call, ATTENTION_SETTINGS_PATH, "tolerance", words) : paused;
|
|
48
|
+
},
|
|
49
|
+
overnight: (call, value) => (onOff(value) === null ? null : frontSet(call, DREAMS_SETTINGS_PATH, "paused", onOff(value) ? "no" : "yes")),
|
|
50
|
+
tidy: (call, value) => (onOff(value) === null ? null : frontSet(call, HOUSEKEEPING_SETTINGS_PATH, "paused", onOff(value) ? "no" : "yes")),
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* The `setting` switches as the app's settings page reads them (`/tex/page/list`, kind `settings`, the person's own
|
|
55
|
+
* chat): the same notes `settingsSnapshot` reads for a text, so the page and the chat can't disagree. A note that is
|
|
56
|
+
* missing reads as its default; one that can't be read is null, never guessed.
|
|
57
|
+
*/
|
|
58
|
+
async function readHabits(call) {
|
|
59
|
+
const [checkins, switches, attention] = await Promise.all([
|
|
60
|
+
readCheckinSettings(call).catch(() => null),
|
|
61
|
+
readSwitches(call).catch(() => null),
|
|
62
|
+
readFront(call, ATTENTION_SETTINGS_PATH),
|
|
63
|
+
]);
|
|
64
|
+
const said = attention === null ? null : readAttentionSettings(attention);
|
|
65
|
+
return {
|
|
66
|
+
checkins: checkins === null ? null : !checkins.paused,
|
|
67
|
+
quietHours: checkins === null ? null : (checkins.quietHours ?? ""),
|
|
68
|
+
pings: said === null ? null : said.paused ? "off" : said.tolerance,
|
|
69
|
+
overnight: switches === null ? null : switches.dreams,
|
|
70
|
+
tidy: switches === null ? null : switches.housekeeping,
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* One `setting` switch changed from the app's settings page (`setting.set`): the setter a text uses, so a value the
|
|
76
|
+
* chat would refuse is refused here too. `value` is a boolean for an on/off switch, or the words a text would send.
|
|
77
|
+
*/
|
|
78
|
+
async function settingSet(call, key, value) {
|
|
79
|
+
const setter = typeof key === "string" && Object.hasOwn(SETTING_SETTERS, key) ? SETTING_SETTERS[key] : null;
|
|
80
|
+
const words = typeof value === "boolean" ? (value ? "on" : "off") : typeof value === "string" && value.length <= 80 ? value : null;
|
|
81
|
+
if (setter === null || words === null) return { ok: false, error: "invalid" };
|
|
82
|
+
const done = await Promise.resolve(setter(call, words)).catch(() => ({ ok: false, error: "failed" }));
|
|
83
|
+
if (done === null) return { ok: false, error: "invalid" };
|
|
84
|
+
return done?.ok === true ? { ok: true } : { ok: false, error: done?.error ?? "failed" };
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
module.exports = { SETTING_SETTERS, onOff, quietOff, readFront, readHabits, settingSet };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/** Types for `settingHabits.cjs`; see that file. */
|
|
2
|
+
|
|
3
|
+
type Call = (name: string, args: Record<string, unknown>) => Promise<any>;
|
|
4
|
+
type Done = { ok: true } | { ok: false; error: string };
|
|
5
|
+
type Setter = (call: Call, value: unknown) => Promise<Done> | Done | null;
|
|
6
|
+
|
|
7
|
+
export type SettingKey = "checkins" | "quiet_hours" | "pings" | "overnight" | "tidy";
|
|
8
|
+
export interface Habits {
|
|
9
|
+
checkins: boolean | null;
|
|
10
|
+
quietHours: string | null;
|
|
11
|
+
pings: string | null;
|
|
12
|
+
overnight: boolean | null;
|
|
13
|
+
tidy: boolean | null;
|
|
14
|
+
}
|
|
15
|
+
export declare const SETTING_SETTERS: Readonly<Record<SettingKey, Setter>>;
|
|
16
|
+
export declare function onOff(value: unknown): boolean | null;
|
|
17
|
+
export declare function quietOff(value: unknown): boolean;
|
|
18
|
+
export declare function readFront(dispatch: Call, path: string): Promise<string | null>;
|
|
19
|
+
export declare function readHabits(call: Call): Promise<Habits>;
|
|
20
|
+
export declare function settingSet(call: Call, key: unknown, value: unknown): Promise<Done>;
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tex's own settings notes in a person's `tex/` folder (`tex/heartbeat.md`, `tex/housekeeping.md`, `tex/dreams.md`,
|
|
3
|
+
* `tex/attention.md`, ...), read and changed through one door: `call(name, args)`, an MCP tool call
|
|
4
|
+
* (`read_note`, `write_note`, `archive_note`) as the person. Shared by the Tex page (`apps/mcp/src/http/texPage/notes.js`)
|
|
5
|
+
* and Tex's settings changed by text (`packages/tex/gateway/agent/settingsTools.js`), so both read and write alike.
|
|
6
|
+
* Note text is never returned in an error: an error is one fixed word.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const { frontMatter } = require("../texShared/routines.cjs");
|
|
10
|
+
|
|
11
|
+
/** Switches off Tex's daily tidy of their workspace. */
|
|
12
|
+
const HOUSEKEEPING_SETTINGS_PATH = "tex/housekeeping.md";
|
|
13
|
+
/** Switches off the nightly rewrite of About me; the summaries of their days still run. */
|
|
14
|
+
const DREAMS_SETTINGS_PATH = "tex/dreams.md";
|
|
15
|
+
|
|
16
|
+
/** Whether a settings note's front matter says `paused: yes` (or true, on). A note without front matter is on. */
|
|
17
|
+
function switchedOff(text) {
|
|
18
|
+
const lines = String(text ?? "").replace(/^\uFEFF/, "").split(/\r?\n/);
|
|
19
|
+
if (lines[0]?.trim() !== "---") return false;
|
|
20
|
+
for (const line of lines.slice(1)) {
|
|
21
|
+
if (line.trim() === "---" || line.trim() === "...") return false;
|
|
22
|
+
const match = /^\s*paused\s*:\s*(.+?)\s*$/i.exec(line);
|
|
23
|
+
if (match) return /^(true|yes|on)$/i.test(match[1].replace(/^["']|["']$/g, ""));
|
|
24
|
+
}
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** The person's own check-in settings (`agent/checkIns.js`). */
|
|
29
|
+
const HEARTBEAT_SETTINGS_PATH = "tex/heartbeat.md";
|
|
30
|
+
|
|
31
|
+
const fail = (error) => ({ ok: false, error });
|
|
32
|
+
|
|
33
|
+
/** `@slug` for a context name, as the gateway's tools address one. */
|
|
34
|
+
function atName(name) {
|
|
35
|
+
const text = String(name ?? "").trim();
|
|
36
|
+
return text.startsWith("@") ? text : `@${text}`;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** The `context` argument for a call, or nothing for the caller's own workspace. */
|
|
40
|
+
function ctx(context) {
|
|
41
|
+
return typeof context === "string" && context !== "" ? { context: atName(context) } : {};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function textOf(result) {
|
|
45
|
+
return (Array.isArray(result?.content) ? result.content : [])
|
|
46
|
+
.map((part) => (typeof part?.text === "string" ? part.text : ""))
|
|
47
|
+
.join("\n");
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** A write's refusal as one fixed word. Its own text (a conflict carries the note) is never passed on. */
|
|
51
|
+
function refusalOf(result) {
|
|
52
|
+
const head = textOf(result).split(/[:\n(]/, 1)[0].trim().toLowerCase();
|
|
53
|
+
if (head.startsWith("conflict")) return "changed";
|
|
54
|
+
if (head.startsWith("permission denied")) return "denied";
|
|
55
|
+
return "failed";
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* A note read through the door: `{ etag, note, moved }`, where `note` is the
|
|
60
|
+
* whole note below the header lines. Null when it can't be read, is missing,
|
|
61
|
+
* or has moved (a moved note is not the one that was asked for).
|
|
62
|
+
*/
|
|
63
|
+
async function readNote(call, path, context) {
|
|
64
|
+
let result;
|
|
65
|
+
try {
|
|
66
|
+
result = await call("read_note", { path, ...ctx(context) });
|
|
67
|
+
} catch {
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
if (result?.isError === true) return null;
|
|
71
|
+
const text = textOf(result);
|
|
72
|
+
const split = text.indexOf("\n\n");
|
|
73
|
+
const header = split === -1 ? text : text.slice(0, split);
|
|
74
|
+
if (/^moved_from:/m.test(header)) return null;
|
|
75
|
+
const etag = /^etag: (.+)$/m.exec(header)?.[1]?.trim() || null;
|
|
76
|
+
return { etag, note: split === -1 ? "" : text.slice(split + 2) };
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/** Write `content` to `path`, refusing a stale etag. `expectedEtag` null creates a new note. */
|
|
80
|
+
async function writeNote(call, path, content, expectedEtag, context) {
|
|
81
|
+
const args = { path, content, ...(expectedEtag ? { expected_etag: expectedEtag } : {}), ...ctx(context) };
|
|
82
|
+
let result;
|
|
83
|
+
try {
|
|
84
|
+
result = await call("write_note", args);
|
|
85
|
+
} catch {
|
|
86
|
+
return fail("failed");
|
|
87
|
+
}
|
|
88
|
+
return result?.isError === true ? fail(refusalOf(result)) : { ok: true };
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** Retract a note into the archive, the gateway's removal (`archive_note`, as `routine.js` `stopRoutine` uses it). */
|
|
92
|
+
async function archiveNote(call, path, expectedEtag, context) {
|
|
93
|
+
let result;
|
|
94
|
+
try {
|
|
95
|
+
result = await call("archive_note", { path, expected_etag: expectedEtag, ...ctx(context) });
|
|
96
|
+
} catch {
|
|
97
|
+
return fail("failed");
|
|
98
|
+
}
|
|
99
|
+
return result?.isError === true ? fail(refusalOf(result)) : { ok: true };
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** A note split into its front matter lines (null when it has none) and its body. */
|
|
103
|
+
function splitNote(text) {
|
|
104
|
+
const raw = String(text ?? "").replace(/^\uFEFF/, "");
|
|
105
|
+
const lines = raw.split("\n");
|
|
106
|
+
if (lines[0]?.trim() === "---") {
|
|
107
|
+
for (let i = 1; i < lines.length; i++) {
|
|
108
|
+
const line = lines[i].trim();
|
|
109
|
+
if (line === "---" || line === "...") return { front: lines.slice(1, i), body: lines.slice(i + 1).join("\n") };
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return { front: null, body: raw };
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
function joinNote(front, body) {
|
|
116
|
+
return front === null || front.length === 0 ? body : `---\n${front.join("\n")}\n---\n${body}`;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** The front matter lines with `key` set to `value` (replacing it in place), or removed when `value` is null. */
|
|
120
|
+
function setKey(front, key, value) {
|
|
121
|
+
const same = new RegExp(`^${key}\\s*:`, "i");
|
|
122
|
+
const out = [];
|
|
123
|
+
let placed = false;
|
|
124
|
+
for (const line of front) {
|
|
125
|
+
if (!same.test(line.trim())) {
|
|
126
|
+
out.push(line);
|
|
127
|
+
} else if (value !== null && !placed) {
|
|
128
|
+
out.push(`${key}: ${value}`);
|
|
129
|
+
placed = true;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
if (value !== null && !placed) out.push(`${key}: ${value}`);
|
|
133
|
+
return out;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** The note's text with one front matter key set (or removed); a note with no front matter gains one. */
|
|
137
|
+
function withFrontKey(text, key, value) {
|
|
138
|
+
const note = splitNote(text);
|
|
139
|
+
return joinNote(setKey(note.front ?? [], key, value), note.body);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** The check-in settings (`tex/heartbeat.md`): paused, looks at, quiet hours. Defaults when the note is missing. */
|
|
143
|
+
async function readCheckinSettings(call) {
|
|
144
|
+
const read = await readNote(call, HEARTBEAT_SETTINGS_PATH, null);
|
|
145
|
+
if (read === null) return { looksAt: [], paused: false };
|
|
146
|
+
const fields = frontMatter(read.note);
|
|
147
|
+
const paused = /^(true|yes|on)$/i.test(String(fields.paused ?? "").replace(/^["']|["']$/g, "").trim());
|
|
148
|
+
const looks = fields["looks-at"] ?? fields.looks ?? fields.looks_at;
|
|
149
|
+
const looksAt = typeof looks === "string" ? looks.replace(/^\[|\]$/g, "").split(/\s*,\s*/).map((word) => word.trim()).filter(Boolean) : [];
|
|
150
|
+
const quiet = fields["quiet-hours"] ?? fields.quiet ?? fields.quiet_hours;
|
|
151
|
+
return { looksAt, paused, ...(typeof quiet === "string" && quiet.trim() !== "" ? { quietHours: quiet.trim() } : {}) };
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Tex's own jobs the person can switch off (`agent/texSwitches.js`): the daily
|
|
156
|
+
* tidy and the nightly rewrite of About me, each on unless its note says
|
|
157
|
+
* `paused: yes`. The same switch Tex flips from a text.
|
|
158
|
+
*/
|
|
159
|
+
const SWITCH_PATHS = Object.freeze({ housekeeping: HOUSEKEEPING_SETTINGS_PATH, dreams: DREAMS_SETTINGS_PATH });
|
|
160
|
+
|
|
161
|
+
/** `{ housekeeping, dreams }`, each true when on. A note that is missing or can't be read is on. */
|
|
162
|
+
async function readSwitches(call) {
|
|
163
|
+
const on = async (path) => !switchedOff((await readNote(call, path, null))?.note ?? "");
|
|
164
|
+
const [housekeeping, dreams] = await Promise.all([on(SWITCH_PATHS.housekeeping), on(SWITCH_PATHS.dreams)]);
|
|
165
|
+
return { housekeeping, dreams };
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/** Switch one of Tex's own jobs on or off: `paused: no` or `yes` in its note, made when it is missing. */
|
|
169
|
+
async function switchSet(call, name, on) {
|
|
170
|
+
const path = Object.hasOwn(SWITCH_PATHS, name) ? SWITCH_PATHS[name] : null;
|
|
171
|
+
if (path === null || typeof on !== "boolean") return fail("invalid");
|
|
172
|
+
return await frontSet(call, path, "paused", on ? "no" : "yes");
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* One front matter key of one of Tex's own settings notes in the person's `tex/` folder (`tex/heartbeat.md`,
|
|
177
|
+
* `tex/attention.md`, ...), set to `value` or removed with null; the note is made when it is missing. For the Tex page's
|
|
178
|
+
* switches and for a setting changed by text (`agent/settingsTools.js`).
|
|
179
|
+
*/
|
|
180
|
+
async function frontSet(call, path, key, value) {
|
|
181
|
+
if (typeof path !== "string" || !/^tex\/[a-z-]+\.md$/.test(path)) return fail("invalid");
|
|
182
|
+
let result;
|
|
183
|
+
try {
|
|
184
|
+
result = await call("read_note", { path });
|
|
185
|
+
} catch {
|
|
186
|
+
return fail("failed");
|
|
187
|
+
}
|
|
188
|
+
const missing = result?.isError === true && /^not found\b/i.test(textOf(result).trim());
|
|
189
|
+
if (result?.isError === true && !missing) return fail("failed");
|
|
190
|
+
const read = missing ? { etag: null, note: "" } : await readNote(call, path, null);
|
|
191
|
+
if (read === null || (!missing && !read.etag)) return fail("no_etag");
|
|
192
|
+
return writeNote(call, path, withFrontKey(read.note, key, value), read.etag, null);
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
module.exports = {
|
|
196
|
+
HEARTBEAT_SETTINGS_PATH,
|
|
197
|
+
HOUSEKEEPING_SETTINGS_PATH,
|
|
198
|
+
DREAMS_SETTINGS_PATH,
|
|
199
|
+
SWITCH_PATHS,
|
|
200
|
+
switchedOff,
|
|
201
|
+
fail,
|
|
202
|
+
atName,
|
|
203
|
+
ctx,
|
|
204
|
+
textOf,
|
|
205
|
+
refusalOf,
|
|
206
|
+
readNote,
|
|
207
|
+
writeNote,
|
|
208
|
+
archiveNote,
|
|
209
|
+
splitNote,
|
|
210
|
+
joinNote,
|
|
211
|
+
setKey,
|
|
212
|
+
withFrontKey,
|
|
213
|
+
readCheckinSettings,
|
|
214
|
+
readSwitches,
|
|
215
|
+
switchSet,
|
|
216
|
+
frontSet,
|
|
217
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** Types for `settingsNotes.cjs`; see that file. */
|
|
2
|
+
|
|
3
|
+
type Call = (name: string, args: Record<string, unknown>) => Promise<any>;
|
|
4
|
+
type Done = { ok: true } | { ok: false; error: string };
|
|
5
|
+
|
|
6
|
+
export declare const HEARTBEAT_SETTINGS_PATH: string;
|
|
7
|
+
export declare const HOUSEKEEPING_SETTINGS_PATH: string;
|
|
8
|
+
export declare const DREAMS_SETTINGS_PATH: string;
|
|
9
|
+
export declare const SWITCH_PATHS: Readonly<{ housekeeping: string; dreams: string }>;
|
|
10
|
+
export declare function switchedOff(text: unknown): boolean;
|
|
11
|
+
export declare function fail(error: string): { ok: false; error: string };
|
|
12
|
+
export declare function atName(name: unknown): string;
|
|
13
|
+
export declare function ctx(context: unknown): { context?: string };
|
|
14
|
+
export declare function textOf(result: unknown): string;
|
|
15
|
+
export declare function refusalOf(result: unknown): string;
|
|
16
|
+
export declare function readNote(call: Call, path: string, context: string | null): Promise<{ etag: string | null; note: string } | null>;
|
|
17
|
+
export declare function writeNote(call: Call, path: string, content: string, expectedEtag: string | null, context: string | null): Promise<Done>;
|
|
18
|
+
export declare function archiveNote(call: Call, path: string, expectedEtag: string, context: string | null): Promise<Done>;
|
|
19
|
+
export declare function splitNote(text: unknown): { front: string[] | null; body: string };
|
|
20
|
+
export declare function joinNote(front: string[] | null, body: string): string;
|
|
21
|
+
export declare function setKey(front: string[], key: string, value: string | null): string[];
|
|
22
|
+
export declare function withFrontKey(text: string, key: string, value: string | null): string;
|
|
23
|
+
export declare function readCheckinSettings(call: Call): Promise<{ looksAt: string[]; paused: boolean; quietHours?: string }>;
|
|
24
|
+
export declare function readSwitches(call: Call): Promise<{ housekeeping: boolean; dreams: boolean }>;
|
|
25
|
+
export declare function switchSet(call: Call, name: string, on: boolean): Promise<Done>;
|
|
26
|
+
export declare function frontSet(call: Call, path: string, key: string, value: string | null): Promise<Done>;
|