@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,115 @@
|
|
|
1
|
+
/** Types for `comments.cjs`; see that file for the format and the reasons. */
|
|
2
|
+
|
|
3
|
+
export interface CommentChange {
|
|
4
|
+
from: number;
|
|
5
|
+
to: number;
|
|
6
|
+
insert: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export interface CommentEvent {
|
|
10
|
+
at: string;
|
|
11
|
+
author: string;
|
|
12
|
+
/**
|
|
13
|
+
* `suggestion` is Tex's proposed replacement for the anchored words (its
|
|
14
|
+
* `text`); `kept` and `undid` answer the pending one.
|
|
15
|
+
*/
|
|
16
|
+
kind: "comment" | "resolved" | "reopened" | "suggestion" | "kept" | "undid";
|
|
17
|
+
text: string;
|
|
18
|
+
/** The event's lines in the file, `[start, end)`. */
|
|
19
|
+
start: number;
|
|
20
|
+
end: number;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface CommentThread {
|
|
24
|
+
id: string;
|
|
25
|
+
quote: string;
|
|
26
|
+
events: CommentEvent[];
|
|
27
|
+
status: "open" | "resolved";
|
|
28
|
+
/** The suggestion still waiting for Keep or Undo, or null. `index` is its place in `events`. */
|
|
29
|
+
pending: { text: string; at: string; author: string; index: number } | null;
|
|
30
|
+
anchored: boolean;
|
|
31
|
+
headerStart: number;
|
|
32
|
+
end: number;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface CommentAnchor {
|
|
36
|
+
id: string;
|
|
37
|
+
/** Where the opening marker starts. */
|
|
38
|
+
openStart: number;
|
|
39
|
+
/** The highlighted words, `[from, to)`. */
|
|
40
|
+
from: number;
|
|
41
|
+
to: number;
|
|
42
|
+
/** Where the closing marker ends. */
|
|
43
|
+
closeEnd: number;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface CommentsBlock {
|
|
47
|
+
start: number;
|
|
48
|
+
end: number;
|
|
49
|
+
info: string;
|
|
50
|
+
bodyStart: number;
|
|
51
|
+
bodyEnd: number;
|
|
52
|
+
closed: boolean;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export declare const COMMENTS_INFO: "comments";
|
|
56
|
+
export declare const MARKER_RE: RegExp;
|
|
57
|
+
export declare function openMarker(id: string): string;
|
|
58
|
+
export declare function closeMarker(id: string): string;
|
|
59
|
+
export declare function findBlock(text: string): CommentsBlock | null;
|
|
60
|
+
export declare function findAnchors(text: string): Map<string, CommentAnchor>;
|
|
61
|
+
export declare function parseComments(text: string): {
|
|
62
|
+
block: CommentsBlock | null;
|
|
63
|
+
threads: CommentThread[];
|
|
64
|
+
anchors: Map<string, CommentAnchor>;
|
|
65
|
+
};
|
|
66
|
+
export declare function sanitizeAuthor(name: string): string;
|
|
67
|
+
export declare function newThreadId(text: string, random?: () => number): string;
|
|
68
|
+
export declare function locateQuote(
|
|
69
|
+
text: string,
|
|
70
|
+
quote: string,
|
|
71
|
+
occurrence?: number,
|
|
72
|
+
): { from: number; to: number; error?: undefined } | { error: string };
|
|
73
|
+
export declare function addThread(
|
|
74
|
+
text: string,
|
|
75
|
+
options: {
|
|
76
|
+
quote?: string;
|
|
77
|
+
occurrence?: number;
|
|
78
|
+
from?: number;
|
|
79
|
+
to?: number;
|
|
80
|
+
author: string;
|
|
81
|
+
body: string;
|
|
82
|
+
at?: Date | string;
|
|
83
|
+
id?: string;
|
|
84
|
+
random?: () => number;
|
|
85
|
+
/** Allow `from === to`: a thread at the caret with no words highlighted. */
|
|
86
|
+
point?: boolean;
|
|
87
|
+
},
|
|
88
|
+
): { id: string; changes: CommentChange[]; error?: undefined } | { error: string };
|
|
89
|
+
export declare function appendEvent(
|
|
90
|
+
text: string,
|
|
91
|
+
options: {
|
|
92
|
+
thread: string;
|
|
93
|
+
kind: "comment" | "resolved" | "reopened" | "suggestion" | "kept" | "undid";
|
|
94
|
+
author: string;
|
|
95
|
+
body?: string;
|
|
96
|
+
at?: Date | string;
|
|
97
|
+
},
|
|
98
|
+
): { changes: CommentChange[]; error?: undefined } | { error: string };
|
|
99
|
+
export declare function keepSuggestion(
|
|
100
|
+
text: string,
|
|
101
|
+
options: { thread: string; author: string; at?: Date | string },
|
|
102
|
+
): { changes: CommentChange[]; error?: undefined } | { error: string };
|
|
103
|
+
export declare function deleteComment(
|
|
104
|
+
text: string,
|
|
105
|
+
options: {
|
|
106
|
+
thread: string;
|
|
107
|
+
/** Which comment, counting the thread's comments from 0; 0 deletes the thread. */
|
|
108
|
+
index: number;
|
|
109
|
+
/** The comment as the reader saw it; a mismatch is refused. */
|
|
110
|
+
expect?: { at: string; author: string };
|
|
111
|
+
},
|
|
112
|
+
): { changes: CommentChange[]; error?: undefined } | { error: string };
|
|
113
|
+
export declare function applyChanges(text: string, changes: readonly CommentChange[]): string;
|
|
114
|
+
export declare function stripComments(text: string): string;
|
|
115
|
+
export declare function describeComments(text: string): string | null;
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* The content types a stored object may be written as. The store's adapters on both sides use them, so they live in
|
|
4
|
+
* the shared code Tex's tree takes with it; `apps/mcp/src/store/contentTypes.js` and `store/index.js` re-export them.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* What a stored object may be written as.
|
|
9
|
+
*
|
|
10
|
+
* **An enumeration, never free text, and that is a security property rather
|
|
11
|
+
* than tidiness.** The chosen value is interpolated straight into S3's
|
|
12
|
+
* `content-type` request header, so a caller-supplied string is header
|
|
13
|
+
* injection by the same route `assertSafeEtag` exists to close one function
|
|
14
|
+
* above. An allow-list means there is no string an attacker can reach this
|
|
15
|
+
* with at all.
|
|
16
|
+
*
|
|
17
|
+
* Markdown is the default and stays the default: a `put` that names nothing
|
|
18
|
+
* behaves exactly as every `put` in this codebase did before this map existed,
|
|
19
|
+
* so adding it changes no existing write.
|
|
20
|
+
*
|
|
21
|
+
* The image types are the ones `read_image` will hand back
|
|
22
|
+
* (`IMAGE_MIME_TYPES` in `src/index.js`). Writing a type the gateway cannot
|
|
23
|
+
* serve would put bytes in a customer's bucket that nothing can ever read out
|
|
24
|
+
* — and **SVG is deliberately absent from both**: it is a script container, and
|
|
25
|
+
* the gateway refuses to serve one for that reason. A store that would accept
|
|
26
|
+
* it is a store that makes the refusal moot.
|
|
27
|
+
*
|
|
28
|
+
* `application/octet-stream` is the one entry that is not "the gateway can
|
|
29
|
+
* serve this back inline" — it is "a browser will never execute this
|
|
30
|
+
* inline", which is the property a fetched email attachment needs. An
|
|
31
|
+
* attachment's real MIME type is sender-chosen text, exactly as untrusted as
|
|
32
|
+
* its filename, and writing it verbatim as the stored `content-type` would
|
|
33
|
+
* mean a customer's own tooling that later serves their bucket over HTTP
|
|
34
|
+
* (a browser extension, a static file server pointed at it, anything that
|
|
35
|
+
* trusts the object's declared type) could be handed `text/html` or
|
|
36
|
+
* `image/svg+xml` from a stranger and render it as a page rather than
|
|
37
|
+
* download it — the exact class of attack SVG's absence above already
|
|
38
|
+
* guards against, reached from the other direction. So every attachment this
|
|
39
|
+
* product stores is written as `application/octet-stream` regardless of what
|
|
40
|
+
* Gmail reports the part's `mimeType` as; the real type is preserved as text
|
|
41
|
+
* in the channel-day note (`**Attachments**: name — type, size`), which is
|
|
42
|
+
* metadata, never a header a client's transport trusts.
|
|
43
|
+
*/
|
|
44
|
+
const MARKDOWN_CONTENT_TYPE = "text/markdown; charset=utf-8";
|
|
45
|
+
const ATTACHMENT_CONTENT_TYPE = "application/octet-stream";
|
|
46
|
+
const LOGICAL_DELETE_CONTENT_TYPE = "application/x-context-logical-tombstone";
|
|
47
|
+
|
|
48
|
+
const WRITABLE_CONTENT_TYPES = new Set([
|
|
49
|
+
MARKDOWN_CONTENT_TYPE,
|
|
50
|
+
"image/png",
|
|
51
|
+
"image/jpeg",
|
|
52
|
+
"image/gif",
|
|
53
|
+
"image/webp",
|
|
54
|
+
"image/heic",
|
|
55
|
+
"image/heif",
|
|
56
|
+
// A cast scene's uploaded sounds, kept beside images in the asset store and
|
|
57
|
+
// read back only through a note that names them. Their bytes are checked to
|
|
58
|
+
// be the format named before they reach here (`sceneSounds.ts`).
|
|
59
|
+
"audio/mpeg",
|
|
60
|
+
"audio/wav",
|
|
61
|
+
"audio/ogg",
|
|
62
|
+
"audio/mp4",
|
|
63
|
+
ATTACHMENT_CONTENT_TYPE,
|
|
64
|
+
LOGICAL_DELETE_CONTENT_TYPE,
|
|
65
|
+
]);
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* The content type for a write, or a throw.
|
|
69
|
+
*
|
|
70
|
+
* Absent means markdown, which is what every caller predating this meant.
|
|
71
|
+
* Anything not in the set is refused rather than sanitised: a sanitiser is a
|
|
72
|
+
* guess about a header grammar, and there is no reason to accept a type the
|
|
73
|
+
* gateway could not serve back.
|
|
74
|
+
*/
|
|
75
|
+
function assertWritableContentType(value) {
|
|
76
|
+
if (value === undefined || value === null) return MARKDOWN_CONTENT_TYPE;
|
|
77
|
+
if (typeof value !== "string" || !WRITABLE_CONTENT_TYPES.has(value)) {
|
|
78
|
+
throw new Error(
|
|
79
|
+
"unsupported content type: a stored object must be markdown or an image type the gateway can serve",
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
return value;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
module.exports = { MARKDOWN_CONTENT_TYPE, ATTACHMENT_CONTENT_TYPE, LOGICAL_DELETE_CONTENT_TYPE, WRITABLE_CONTENT_TYPES, assertWritableContentType };
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What kind of file a path names, decided in one place.
|
|
3
|
+
*
|
|
4
|
+
* Context keeps two kinds of file as text it reads and writes itself: a note
|
|
5
|
+
* (`.md`, Markdown) and a sheet (`.csv`, a table with typed headers,
|
|
6
|
+
* `docs/decisions/sheets.md`). Everything else (a picture, a PDF, a sound) is
|
|
7
|
+
* a file: bytes Context stores and shows but never opens as text. A path's
|
|
8
|
+
* kind is its last extension in any case, so `Budget.CSV` is a sheet.
|
|
9
|
+
*
|
|
10
|
+
* One question is asked exactly: whether a path may carry its own visibility
|
|
11
|
+
* (`takesExactOverride`). The privacy engine's exact-note parser
|
|
12
|
+
* (`apps/mcp/src/privacy/engine.js`) matches `.md` and `.csv` as written, and
|
|
13
|
+
* one line it refuses makes the whole manifest unreadable, so a gate that
|
|
14
|
+
* writes an override must not hand it a `.CSV`.
|
|
15
|
+
*
|
|
16
|
+
* Before this list, about 150 places asked `path.endsWith(".md")` on their
|
|
17
|
+
* own, and every new text type had to be added to each of them by hand; the
|
|
18
|
+
* ones that were (`|| .csv`) already disagreed with each other. Ask here
|
|
19
|
+
* instead, and add a new text type with one line in `TEXT_KINDS`
|
|
20
|
+
* (`docs/decisions/file-kinds.md`). `scripts/check-file-kinds.mjs` fails a
|
|
21
|
+
* pull request that adds a hard-coded extension test anywhere else.
|
|
22
|
+
*
|
|
23
|
+
* A check that means Markdown on purpose (a form, a `.page.md`, front matter,
|
|
24
|
+
* a routine, live co-editing) asks `isNotePath`. A check that means "text
|
|
25
|
+
* Context reads and writes" (listing, search, visibility, saving) asks
|
|
26
|
+
* `isTextFilePath`.
|
|
27
|
+
*
|
|
28
|
+
* Dependency-free CommonJS, so the gateway, Convex, the app and Tex all read
|
|
29
|
+
* the same copy.
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
const NOTE = "note";
|
|
33
|
+
const SHEET = "sheet";
|
|
34
|
+
const FILE = "file";
|
|
35
|
+
|
|
36
|
+
/** The text kinds, by lowercased extension. One line adds one. */
|
|
37
|
+
const TEXT_KINDS = Object.freeze({
|
|
38
|
+
".md": NOTE,
|
|
39
|
+
".csv": SHEET,
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
/** The extensions Context reads and writes as text, in `TEXT_KINDS` order. */
|
|
43
|
+
const TEXT_EXTENSIONS = Object.freeze(Object.keys(TEXT_KINDS));
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* A path's last extension, lowercased, with its dot: `a/b.CSV` → `.csv`.
|
|
47
|
+
* A name with no dot after its first character has none (`""`), so a
|
|
48
|
+
* dot-file such as `.gitignore` is not an extension.
|
|
49
|
+
*
|
|
50
|
+
* @param {unknown} path
|
|
51
|
+
* @returns {string}
|
|
52
|
+
*/
|
|
53
|
+
function extensionOf(path) {
|
|
54
|
+
return writtenExtensionOf(path).toLowerCase();
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** The last extension as written, with its dot: `a/b.CSV` → `.CSV`. @param {unknown} path */
|
|
58
|
+
function writtenExtensionOf(path) {
|
|
59
|
+
if (typeof path !== "string") return "";
|
|
60
|
+
const name = path.slice(path.lastIndexOf("/") + 1);
|
|
61
|
+
const dot = name.lastIndexOf(".");
|
|
62
|
+
return dot > 0 ? name.slice(dot) : "";
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* `note`, `sheet` or `file`. A folder path, or anything that is not a string,
|
|
67
|
+
* is `file`: callers decide folders by the row, never by the name.
|
|
68
|
+
*
|
|
69
|
+
* @param {unknown} path
|
|
70
|
+
* @returns {"note" | "sheet" | "file"}
|
|
71
|
+
*/
|
|
72
|
+
function kindOf(path) {
|
|
73
|
+
const extension = extensionOf(path);
|
|
74
|
+
return Object.prototype.hasOwnProperty.call(TEXT_KINDS, extension) ? TEXT_KINDS[extension] : FILE;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** A Markdown note (`.md`). @param {unknown} path */
|
|
78
|
+
function isNotePath(path) {
|
|
79
|
+
return kindOf(path) === NOTE;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/** A sheet (`.csv`). @param {unknown} path */
|
|
83
|
+
function isSheetPath(path) {
|
|
84
|
+
return kindOf(path) === SHEET;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/** Text Context reads and writes itself: a note or a sheet. @param {unknown} path */
|
|
88
|
+
function isTextFilePath(path) {
|
|
89
|
+
return kindOf(path) !== FILE;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* A name without its text extension: `readings.csv` → `readings`,
|
|
94
|
+
* `Plan.MD` → `Plan`. Any other name is returned as it is, so `photo.png`
|
|
95
|
+
* keeps its `.png`. @param {string} name
|
|
96
|
+
*/
|
|
97
|
+
function withoutTextExtension(name) {
|
|
98
|
+
return isTextFilePath(name) ? name.slice(0, -extensionOf(name).length) : name;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* Text whose extension is written exactly as `TEXT_KINDS` lists it, the only
|
|
103
|
+
* paths the privacy parsers take an exact override for. `Budget.CSV` is a
|
|
104
|
+
* sheet, but it takes its folder's visibility. @param {unknown} path
|
|
105
|
+
*/
|
|
106
|
+
function takesExactOverride(path) {
|
|
107
|
+
return Object.prototype.hasOwnProperty.call(TEXT_KINDS, writtenExtensionOf(path));
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
module.exports = {
|
|
111
|
+
NOTE,
|
|
112
|
+
SHEET,
|
|
113
|
+
FILE,
|
|
114
|
+
TEXT_KINDS,
|
|
115
|
+
TEXT_EXTENSIONS,
|
|
116
|
+
extensionOf,
|
|
117
|
+
kindOf,
|
|
118
|
+
isNotePath,
|
|
119
|
+
isSheetPath,
|
|
120
|
+
isTextFilePath,
|
|
121
|
+
takesExactOverride,
|
|
122
|
+
withoutTextExtension,
|
|
123
|
+
};
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every feature flag: one id per feature that is built and on production but
|
|
3
|
+
* not yet open to everyone (decided by the owner, 2026-11-08; the design is
|
|
4
|
+
* `docs/decisions/app-and-console/feature-flags.md`).
|
|
5
|
+
*
|
|
6
|
+
* Who has a flag is not here. Staff choose it in the console's Features tab
|
|
7
|
+
* (`apps/convex/functions/featureFlags.ts`): off, a list of people, or
|
|
8
|
+
* everyone. This repository is public, and who is testing what is theirs.
|
|
9
|
+
*
|
|
10
|
+
* ## Every flag expires
|
|
11
|
+
*
|
|
12
|
+
* The owner, 2026-11-08: "put expiration dates on flags, either remove the
|
|
13
|
+
* feature or launch it". `expires` is at most `MAX_FLAG_DAYS` after `added`,
|
|
14
|
+
* and once it has passed, `flagProblems` names the flag and the Convex suite
|
|
15
|
+
* fails (`apps/convex/__tests__/featureFlags.test.ts`) until a pull request
|
|
16
|
+
* launches it (deletes the flag and keeps the code) or removes the feature
|
|
17
|
+
* (deletes both). Moving `expires` later is allowed only within the same
|
|
18
|
+
* limit from `added`, so a flag cannot be kept forever by editing its date.
|
|
19
|
+
*
|
|
20
|
+
* ## On for staff in code
|
|
21
|
+
*
|
|
22
|
+
* `staff: true` turns a flag on for staff (the verified `ADMIN_EMAILS`
|
|
23
|
+
* addresses) before anyone else, as a launch pull request, not a console
|
|
24
|
+
* press. The console's row still wins: `people` and `everyone` widen it as
|
|
25
|
+
* always, and a row set to `off` turns it off for staff too, which is the
|
|
26
|
+
* rollback short of a revert. Read by `apps/convex/functions/lib/featureFlags.ts`.
|
|
27
|
+
*
|
|
28
|
+
* ## Ids
|
|
29
|
+
*
|
|
30
|
+
* `area.name`, lower case words joined by hyphens (`tex.conversation-threads`).
|
|
31
|
+
* An id is never reused once its flag is gone: a person's list from the old
|
|
32
|
+
* flag must not switch on the new one.
|
|
33
|
+
*
|
|
34
|
+
* Read by the control plane, the gateway and the app, so it is CommonJS with
|
|
35
|
+
* its types beside it (`flags.d.cts`), as `folderJobInfo.cjs` is.
|
|
36
|
+
*/
|
|
37
|
+
|
|
38
|
+
/** The longest a flag may live, from `added` to `expires`. */
|
|
39
|
+
const MAX_FLAG_DAYS = 90;
|
|
40
|
+
/** How soon before `expires` the console shows a flag as due. */
|
|
41
|
+
const FLAG_DUE_DAYS = 14;
|
|
42
|
+
|
|
43
|
+
const FLAG_ID = /^[a-z0-9]+(?:-[a-z0-9]+)*\.[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
44
|
+
const DAY = /^\d{4}-\d{2}-\d{2}$/;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* The flags. Add one as
|
|
48
|
+
*
|
|
49
|
+
* "tex.conversation-threads": {
|
|
50
|
+
* label: "Conversation threads",
|
|
51
|
+
* description: "Tex sorts texts into threads before it answers.",
|
|
52
|
+
* added: "2026-11-08",
|
|
53
|
+
* expires: "2026-12-08",
|
|
54
|
+
* },
|
|
55
|
+
*/
|
|
56
|
+
const FLAGS = Object.freeze({
|
|
57
|
+
"mail.in-notes": {
|
|
58
|
+
label: "Mail in notes",
|
|
59
|
+
description: "Gmail is copied into the person's notes again, so new mail starts a Tex check-in at once.",
|
|
60
|
+
added: "2026-11-08",
|
|
61
|
+
expires: "2027-02-06",
|
|
62
|
+
},
|
|
63
|
+
"files.app-saves-in-objects": {
|
|
64
|
+
label: "App saves in objects",
|
|
65
|
+
description: "The app saves whole notes through the gateway into the workspace object, not through Convex.",
|
|
66
|
+
added: "2026-11-24",
|
|
67
|
+
expires: "2027-02-21",
|
|
68
|
+
staff: true,
|
|
69
|
+
},
|
|
70
|
+
"files.app-reads-in-objects": {
|
|
71
|
+
label: "App reads in objects",
|
|
72
|
+
description: "The app's previews, peeks, mail and admin note reads go through the gateway to the workspace object, not through Convex.",
|
|
73
|
+
added: "2026-11-29",
|
|
74
|
+
expires: "2027-02-26",
|
|
75
|
+
staff: true,
|
|
76
|
+
},
|
|
77
|
+
"files.app-trash-list-in-objects": {
|
|
78
|
+
label: "Trash list in objects",
|
|
79
|
+
description: "The app's Trash page lists the trash from the workspace object through the gateway, not from Convex.",
|
|
80
|
+
added: "2026-11-29",
|
|
81
|
+
expires: "2027-02-26",
|
|
82
|
+
},
|
|
83
|
+
"notes.app-visibility-in-objects": {
|
|
84
|
+
label: "App visibility in objects",
|
|
85
|
+
description: "The app changes a note's visibility through the gateway in the workspace object, not through Convex.",
|
|
86
|
+
added: "2026-11-29",
|
|
87
|
+
expires: "2027-02-26",
|
|
88
|
+
},
|
|
89
|
+
"shares.shared-with-me-in-objects": {
|
|
90
|
+
label: "Shared with me from objects",
|
|
91
|
+
description: "The app's Shared with me list follows the person's own object instead of holding a live Convex query.",
|
|
92
|
+
added: "2026-11-29",
|
|
93
|
+
expires: "2027-02-26",
|
|
94
|
+
},
|
|
95
|
+
"files.share-cards-in-objects": {
|
|
96
|
+
label: "Share cards and access lists from objects",
|
|
97
|
+
description: "A share link finds its note, and the share dialog reads who has access, from the workspace object instead of Convex's tree copy.",
|
|
98
|
+
added: "2026-11-29",
|
|
99
|
+
expires: "2027-02-26",
|
|
100
|
+
},
|
|
101
|
+
"shares.granted-in-objects": {
|
|
102
|
+
label: "Granted notes judged in objects",
|
|
103
|
+
description: "A note or folder granted to somebody outside the workspace is judged and read in the workspace object, not from Convex's copy of the rows.",
|
|
104
|
+
added: "2026-11-29",
|
|
105
|
+
expires: "2027-02-26",
|
|
106
|
+
},
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
const FLAG_MODES = Object.freeze(["off", "people", "everyone"]);
|
|
110
|
+
|
|
111
|
+
function isFlagId(value) {
|
|
112
|
+
return typeof value === "string" && Object.prototype.hasOwnProperty.call(FLAGS, value);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** Milliseconds at midnight UTC of a `YYYY-MM-DD` day, or NaN. */
|
|
116
|
+
function dayMs(day) {
|
|
117
|
+
if (typeof day !== "string" || !DAY.test(day)) return NaN;
|
|
118
|
+
const ms = Date.parse(`${day}T00:00:00Z`);
|
|
119
|
+
return Number.isFinite(ms) && new Date(ms).toISOString().slice(0, 10) === day ? ms : NaN;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
/** Whole days from `today` (a `YYYY-MM-DD`) to the flag's `expires`: 0 on the day, negative after. */
|
|
123
|
+
function daysLeft(flag, today) {
|
|
124
|
+
return Math.round((dayMs(flag.expires) - dayMs(today)) / 86_400_000);
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** Today in UTC as `YYYY-MM-DD`. */
|
|
128
|
+
function todayOf(now = Date.now()) {
|
|
129
|
+
return new Date(now).toISOString().slice(0, 10);
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Everything wrong with a registry on `today`, one sentence each; empty when
|
|
134
|
+
* it is fine. An expired flag is one of them, on purpose.
|
|
135
|
+
*/
|
|
136
|
+
function flagProblems(flags, today) {
|
|
137
|
+
const problems = [];
|
|
138
|
+
for (const [id, flag] of Object.entries(flags)) {
|
|
139
|
+
if (!FLAG_ID.test(id)) problems.push(`${id}: an id is area.name in lower case words joined by hyphens.`);
|
|
140
|
+
if (!flag || typeof flag !== "object") {
|
|
141
|
+
problems.push(`${id}: needs label, description, added and expires.`);
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
if (typeof flag.label !== "string" || flag.label.trim() === "") problems.push(`${id}: needs a label.`);
|
|
145
|
+
if (typeof flag.description !== "string" || flag.description.trim() === "") problems.push(`${id}: needs a description.`);
|
|
146
|
+
if (flag.staff !== undefined && typeof flag.staff !== "boolean") problems.push(`${id}: staff is true or left out.`);
|
|
147
|
+
const added = dayMs(flag.added);
|
|
148
|
+
const expires = dayMs(flag.expires);
|
|
149
|
+
if (Number.isNaN(added)) problems.push(`${id}: added must be a YYYY-MM-DD day.`);
|
|
150
|
+
if (Number.isNaN(expires)) problems.push(`${id}: expires must be a YYYY-MM-DD day.`);
|
|
151
|
+
if (Number.isNaN(added) || Number.isNaN(expires)) continue;
|
|
152
|
+
if (expires <= added) problems.push(`${id}: expires must come after added.`);
|
|
153
|
+
if (expires - added > MAX_FLAG_DAYS * 86_400_000) problems.push(`${id}: expires is more than ${MAX_FLAG_DAYS} days after added.`);
|
|
154
|
+
if (daysLeft(flag, today) < 0) problems.push(`${id}: expired on ${flag.expires}. Launch it (delete the flag, keep the code) or remove the feature.`);
|
|
155
|
+
}
|
|
156
|
+
return problems;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
module.exports = { FLAGS, FLAG_MODES, MAX_FLAG_DAYS, FLAG_DUE_DAYS, isFlagId, daysLeft, todayOf, flagProblems };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** Types for `flags.cjs`; see that file for the rules and the reasons. */
|
|
2
|
+
|
|
3
|
+
export type FlagMode = "off" | "people" | "everyone";
|
|
4
|
+
|
|
5
|
+
export interface FlagInfo {
|
|
6
|
+
label: string;
|
|
7
|
+
description: string;
|
|
8
|
+
/** `YYYY-MM-DD`, the day the flag was added. */
|
|
9
|
+
added: string;
|
|
10
|
+
/** `YYYY-MM-DD`, at most `MAX_FLAG_DAYS` after `added`. */
|
|
11
|
+
expires: string;
|
|
12
|
+
/** On for staff unless the console's row is set to `off`. */
|
|
13
|
+
staff?: boolean;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export declare const FLAGS: Readonly<Record<string, FlagInfo>>;
|
|
17
|
+
export declare const FLAG_MODES: readonly FlagMode[];
|
|
18
|
+
export declare const MAX_FLAG_DAYS: number;
|
|
19
|
+
export declare const FLAG_DUE_DAYS: number;
|
|
20
|
+
export declare function isFlagId(value: unknown): value is string;
|
|
21
|
+
export declare function daysLeft(flag: Pick<FlagInfo, "expires">, today: string): number;
|
|
22
|
+
export declare function todayOf(now?: number): string;
|
|
23
|
+
export declare function flagProblems(flags: Readonly<Record<string, unknown>>, today: string): string[];
|