lattris 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/build.json +1 -4
- package/dist/dispatch-form.js +78 -9
- package/dist/dispatch-words.js +35 -26
- package/dist/dispatch.js +2 -2
- package/dist/entry/setup.js +14 -2
- package/dist/main.js +2 -6
- package/dist/memory/access.js +88 -0
- package/dist/memory/capture-common.js +109 -5
- package/dist/memory/capture-help.js +18 -9
- package/dist/memory/capture-note.js +26 -16
- package/dist/memory/capture-session.js +18 -16
- package/dist/memory/get-help.js +12 -1
- package/dist/memory/get.js +38 -5
- package/dist/memory/recording.js +36 -27
- package/dist/memory/transcript.js +3 -0
- package/dist/memory/views.js +12 -3
- package/dist/nouns/contact.js +119 -23
- package/dist/nouns/index.js +29 -2
- package/dist/nouns/invite.js +45 -19
- package/dist/nouns/questions.js +56 -3
- package/dist/nouns/share.js +199 -30
- package/dist/nouns/words.js +21 -6
- package/dist/registry/memory.js +8 -2
- package/dist/render/rows.js +46 -1
- package/dist/request/door.js +2 -1
- package/package.json +2 -2
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { randomUUID } from 'node:crypto';
|
|
2
2
|
import { ambiguousText, formatEdgeReceipt } from "../render/rows.js";
|
|
3
3
|
import { parseArgs } from "../request/flags.js";
|
|
4
|
-
import { CAPTURE_MEMORY_FLAG_NAMES, SESSION_ONLY_FLAGS,
|
|
4
|
+
import { CAPTURE_MEMORY_FLAG_NAMES, SESSION_ONLY_FLAGS, allowWords, buildCreateNoteBody, checkShareWords, formatSaved, isRefusalValue, needsYesWords, resolveBornShares, retryWords, takeShareFlags } from "../memory/capture-common.js";
|
|
5
5
|
import { CAPTURE_NOTE_HELP, CAPTURE_SESSION_HELP } from "../memory/capture-help.js";
|
|
6
6
|
import { captureSession, captureSessionTranscript } from "../memory/capture-session.js";
|
|
7
7
|
import { composeAddressFor } from "../memory/views.js";
|
|
@@ -34,7 +34,9 @@ export const captureMemory = async (cfg, io, args) => {
|
|
|
34
34
|
const yes = args.includes('--yes');
|
|
35
35
|
const asNew = args.includes('--as-new');
|
|
36
36
|
const allowBanned = args.includes('--allow-banned-words');
|
|
37
|
-
const
|
|
37
|
+
const taken = takeShareFlags(args.filter((a) => a !== '--yes' && a !== '--as-new' && a !== '--allow-banned-words'));
|
|
38
|
+
const { flags, positionals, unknown } = parseArgs(CAPTURE_MEMORY_FLAG_NAMES, taken.rest);
|
|
39
|
+
const sharesNamed = taken.shareWith.length > 0 || taken.deny.length > 0;
|
|
38
40
|
const piped = !io.stdin.isTTY && positionals.length === 0;
|
|
39
41
|
const wantsNote = !asksForSessionForm(args) && (flags.type ?? 'note') === 'note';
|
|
40
42
|
const early = piped && wantsNote ? requireWriteIdentity(io.store, io.stdin.isTTY) : undefined;
|
|
@@ -45,9 +47,12 @@ export const captureMemory = async (cfg, io, args) => {
|
|
|
45
47
|
io.stdout.write(`${asksForSessionForm(args) ? CAPTURE_SESSION_HELP : CAPTURE_NOTE_HELP}\n`);
|
|
46
48
|
return;
|
|
47
49
|
}
|
|
48
|
-
if (unknown) {
|
|
49
|
-
return refusal(`Unknown flag: ${unknown}\n`);
|
|
50
|
+
if (unknown ?? taken.unknown) {
|
|
51
|
+
return refusal(`Unknown flag: ${unknown ?? taken.unknown}\n`);
|
|
50
52
|
}
|
|
53
|
+
const badShareWords = checkShareWords(taken.shareWith, taken.deny);
|
|
54
|
+
if (badShareWords)
|
|
55
|
+
return badShareWords;
|
|
51
56
|
if (flags.contributor !== undefined) {
|
|
52
57
|
const UUID_SHAPE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
53
58
|
if (!UUID_SHAPE.test(flags.contributor)) {
|
|
@@ -76,9 +81,14 @@ export const captureMemory = async (cfg, io, args) => {
|
|
|
76
81
|
return refusal(`Unexpected argument: ${positionals[1]}\n`);
|
|
77
82
|
}
|
|
78
83
|
if (positionals.length === 1) {
|
|
79
|
-
return captureSessionTranscript(cfg, io, positionals[0], flags, asNew);
|
|
84
|
+
return captureSessionTranscript(cfg, io, positionals[0], flags, asNew, sharesNamed);
|
|
80
85
|
}
|
|
81
|
-
return captureSession(cfg, io, content, flags, {
|
|
86
|
+
return captureSession(cfg, io, content, flags, {
|
|
87
|
+
yes,
|
|
88
|
+
asNew,
|
|
89
|
+
shareWith: taken.shareWith,
|
|
90
|
+
deny: taken.deny
|
|
91
|
+
});
|
|
82
92
|
}
|
|
83
93
|
if (positionals.length > 0) {
|
|
84
94
|
return refusal(`Unexpected argument: ${positionals[0]}\n`);
|
|
@@ -110,15 +120,8 @@ export const captureMemory = async (cfg, io, args) => {
|
|
|
110
120
|
if (flags.linksTo !== undefined && !isUuidKey(flags.linksTo)) {
|
|
111
121
|
return refusal(`--links-to must be the FULL block id (the wire addresses the edge by it; it does not search): ${flags.linksTo}\n`);
|
|
112
122
|
}
|
|
113
|
-
if (
|
|
114
|
-
|
|
115
|
-
return refusal(`Unknown audience: ${flags.shareWith}. Accepted: ${SHARE_AUDIENCES.join(', ')}\n`);
|
|
116
|
-
}
|
|
117
|
-
if (!yes) {
|
|
118
|
-
return refusal('This will save the memory AND make it public — anyone, including people ' +
|
|
119
|
-
'without accounts. There is no prompt here (the content already arrived on ' +
|
|
120
|
-
'a pipe) — pass --yes once the person has confirmed both facts.\n');
|
|
121
|
-
}
|
|
123
|
+
if (taken.shareWith.length > 0 && !yes) {
|
|
124
|
+
return refusal(needsYesWords('memory', allowWords(taken.shareWith)));
|
|
122
125
|
}
|
|
123
126
|
const identity = early ?? requireWriteIdentity(io.store, io.stdin.isTTY);
|
|
124
127
|
if (isRefusal(identity))
|
|
@@ -130,7 +133,14 @@ export const captureMemory = async (cfg, io, args) => {
|
|
|
130
133
|
const accessToken = await signedIn(io, cfg);
|
|
131
134
|
if (typeof accessToken !== 'string')
|
|
132
135
|
return accessToken;
|
|
133
|
-
|
|
136
|
+
let shares;
|
|
137
|
+
if (sharesNamed) {
|
|
138
|
+
const resolved = await resolveBornShares(cfg, io, accessToken, taken.shareWith, taken.deny);
|
|
139
|
+
if (isRefusalValue(resolved))
|
|
140
|
+
return resolved;
|
|
141
|
+
shares = resolved;
|
|
142
|
+
}
|
|
143
|
+
const createBody = buildCreateNoteBody(content, flags, allowBanned, shares);
|
|
134
144
|
const requestDraft = {
|
|
135
145
|
door: 'POST /memories/notes',
|
|
136
146
|
idempotencyKey,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { extractChain } from "./extract-claude-jsonl.js";
|
|
2
2
|
import { ChainSaveError, driveChain } from "./save-session-chain.js";
|
|
3
3
|
import { loadReceipts, saveReceipts } from "../store/chains.js";
|
|
4
|
-
import {
|
|
4
|
+
import { allowWords, isRefusalValue, needsYesWords, resolveBornShares, withShares } from "../memory/capture-common.js";
|
|
5
5
|
import { emit } from "../render/output.js";
|
|
6
6
|
import { sanitizeForTerminal } from "../render/text.js";
|
|
7
7
|
import { classifyApiError } from "../request/door.js";
|
|
@@ -17,7 +17,7 @@ export const formatSavedSession = (r) => {
|
|
|
17
17
|
lines.push(` capturedAt ${r.block.capturedAt}`);
|
|
18
18
|
return lines.join('\n');
|
|
19
19
|
};
|
|
20
|
-
export const buildCaptureSessionBody = (turns, flags, asNew) => {
|
|
20
|
+
export const buildCaptureSessionBody = (turns, flags, asNew, shares) => {
|
|
21
21
|
const body = { turns };
|
|
22
22
|
if (flags.title !== undefined)
|
|
23
23
|
body.title = flags.title;
|
|
@@ -35,8 +35,7 @@ export const buildCaptureSessionBody = (turns, flags, asNew) => {
|
|
|
35
35
|
body.from = Number(flags.from);
|
|
36
36
|
if (asNew)
|
|
37
37
|
body.asNewBlock = true;
|
|
38
|
-
|
|
39
|
-
body.audience = flags.shareWith;
|
|
38
|
+
withShares(body, shares);
|
|
40
39
|
if (flags.continuesFrom !== undefined)
|
|
41
40
|
body.continuesFrom = flags.continuesFrom;
|
|
42
41
|
if (flags.forkedFrom !== undefined)
|
|
@@ -62,23 +61,23 @@ export const captureSession = async (cfg, io, content, flags, opts) => {
|
|
|
62
61
|
if (flags.from !== undefined && !/^\d+$/.test(flags.from)) {
|
|
63
62
|
return refusal(`--from must be a non-negative integer, got: ${flags.from}\n`);
|
|
64
63
|
}
|
|
65
|
-
if (
|
|
66
|
-
|
|
67
|
-
return refusal(`Unknown audience: ${flags.shareWith}. Accepted: ${SHARE_AUDIENCES.join(', ')}\n`);
|
|
68
|
-
}
|
|
69
|
-
if (!opts.yes) {
|
|
70
|
-
return refusal('This will save the session AND make it public — anyone, including people ' +
|
|
71
|
-
'without accounts. There is no prompt here (the turns already arrived on ' +
|
|
72
|
-
'a pipe) — pass --yes once the person has confirmed both facts.\n');
|
|
73
|
-
}
|
|
64
|
+
if (opts.shareWith.length > 0 && !opts.yes) {
|
|
65
|
+
return refusal(needsYesWords('session', allowWords(opts.shareWith)));
|
|
74
66
|
}
|
|
75
67
|
const accessToken = await signedIn(io, cfg);
|
|
76
68
|
if (typeof accessToken !== 'string')
|
|
77
69
|
return accessToken;
|
|
70
|
+
let shares;
|
|
71
|
+
if (opts.shareWith.length > 0 || opts.deny.length > 0) {
|
|
72
|
+
const resolved = await resolveBornShares(cfg, io, accessToken, opts.shareWith, opts.deny);
|
|
73
|
+
if (isRefusalValue(resolved))
|
|
74
|
+
return resolved;
|
|
75
|
+
shares = resolved;
|
|
76
|
+
}
|
|
78
77
|
const result = await io.api(accessToken, `${cfg.apiUrl}/memories/sessions`, {
|
|
79
78
|
method: 'POST',
|
|
80
79
|
headers: { 'Content-Type': 'application/json' },
|
|
81
|
-
body: JSON.stringify(buildCaptureSessionBody(turns, flags, opts.asNew))
|
|
80
|
+
body: JSON.stringify(buildCaptureSessionBody(turns, flags, opts.asNew, shares))
|
|
82
81
|
});
|
|
83
82
|
if (!result.ok)
|
|
84
83
|
return refusalOf(result);
|
|
@@ -87,7 +86,6 @@ export const captureSession = async (cfg, io, content, flags, opts) => {
|
|
|
87
86
|
const TRANSCRIPT_INAPPLICABLE_FLAGS = [
|
|
88
87
|
['--intent', 'intent'],
|
|
89
88
|
['--captured-at', 'capturedAt'],
|
|
90
|
-
['--share-with', 'shareWith'],
|
|
91
89
|
['--source', 'source'],
|
|
92
90
|
['--conversation-id', 'conversationId'],
|
|
93
91
|
['--extends', 'extends'],
|
|
@@ -96,13 +94,17 @@ const TRANSCRIPT_INAPPLICABLE_FLAGS = [
|
|
|
96
94
|
['--forked-from', 'forkedFrom']
|
|
97
95
|
];
|
|
98
96
|
const formatChainEpoch = (r) => `epoch ${r.epoch}: ${r.outcome}${r.forked ? ' (forked)' : ''} — block ${r.blockId}, ${r.turnCount} turns stored`;
|
|
99
|
-
export const captureSessionTranscript = async (cfg, io, file, flags, asNew) => {
|
|
97
|
+
export const captureSessionTranscript = async (cfg, io, file, flags, asNew, sharesNamed = false) => {
|
|
100
98
|
for (const [name, key] of TRANSCRIPT_INAPPLICABLE_FLAGS) {
|
|
101
99
|
if (flags[key] !== undefined) {
|
|
102
100
|
return refusal(`${name} does not apply when capturing from a transcript — the chain drive ` +
|
|
103
101
|
`derives it. Only --title and --ai-summary ride this form.\n`);
|
|
104
102
|
}
|
|
105
103
|
}
|
|
104
|
+
if (sharesNamed) {
|
|
105
|
+
return refusal('--share-with and --deny do not apply when capturing from a transcript — the chain ' +
|
|
106
|
+
'drive derives it. Only --title and --ai-summary ride this form.\n');
|
|
107
|
+
}
|
|
106
108
|
if (asNew) {
|
|
107
109
|
return refusal('--as-new does not apply when capturing from a transcript — a fork is detected ' +
|
|
108
110
|
'and saved by the drive itself.\n');
|
package/dist/memory/get-help.js
CHANGED
|
@@ -7,15 +7,17 @@ export const GET_HELP = [
|
|
|
7
7
|
' history one note\u2019s history: every change, newest first, and the head fingerprint',
|
|
8
8
|
' deleted your deleted items, with the fingerprint restore and erase need',
|
|
9
9
|
' questions the questions left on your tree, open first',
|
|
10
|
+
' access may one contact, or one number, see a memory, and because of what',
|
|
10
11
|
'',
|
|
11
12
|
'Usage:',
|
|
12
|
-
' lattris get memories [--shared-with-me] [--q <words>] [--type <name>] [--intent <name>] [--with <audience>] [--limit <n>] [--cursor <token>] [--content 0|1]',
|
|
13
|
+
' lattris get memories [--shared-with-me] [--q <words>] [--type <name>] [--intent <name>] [--with <audience>] [--for <contact> | --for-phone <number>] [--limit <n>] [--cursor <token>] [--content 0|1]',
|
|
13
14
|
' lattris get memories --by <owner-handle> [--limit <n>] [--cursor <token>] [--content 0|1]',
|
|
14
15
|
' lattris get memory <website-address|id> [--by <owner-handle>] [--links 0|1] [--depth <n>] [--content 0|1]',
|
|
15
16
|
' lattris get memory <id-or-prefix> --revision <n> one revision, as history kept it',
|
|
16
17
|
' lattris get history <id-or-prefix> [--limit <n>] [--before <operation-id>]',
|
|
17
18
|
' lattris get deleted [--limit <n>] [--cursor <token>]',
|
|
18
19
|
' lattris get questions [--mine]',
|
|
20
|
+
' lattris get access <memory-id-or-prefix> --for <contact | number>',
|
|
19
21
|
'',
|
|
20
22
|
' --q <words> only memories whose title or content contains these words,',
|
|
21
23
|
' matched as one literal phrase, case-insensitive. Needs 3+',
|
|
@@ -32,6 +34,14 @@ export const GET_HELP = [
|
|
|
32
34
|
' session needs it, while a full address carries it',
|
|
33
35
|
' --shared-with-me list memories other people granted to you; each row',
|
|
34
36
|
' names its owner and whether it is on your graph',
|
|
37
|
+
' --for <contact> what one of your contacts may see of your memories and',
|
|
38
|
+
' of the ones shared with you: an exact name or id from',
|
|
39
|
+
' `lattris contact list`. The rows carry what they would',
|
|
40
|
+
' see, a row of another owner names them, and the first',
|
|
41
|
+
' line names the contact',
|
|
42
|
+
' --for-phone <number> the same for a phone number in full international',
|
|
43
|
+
' form; a number no contact holds is a stranger, who',
|
|
44
|
+
' sees public memories only',
|
|
35
45
|
'',
|
|
36
46
|
' --links 0|1 edges on the one memory (default 1): direction, verb,',
|
|
37
47
|
' reason, and each neighbour\u2019s finding aid. --links 0',
|
|
@@ -53,6 +63,7 @@ export const GET_HELP = [
|
|
|
53
63
|
'Every read of a note prints its fingerprint (the head of its history) and',
|
|
54
64
|
'revisionNo; every read prints structureHash, a hash of the block\u2019s links and',
|
|
55
65
|
'grants as this reader sees them. An edit sends the fingerprint back as --base-fingerprint.',
|
|
66
|
+
'Your own read of a memory also prints `access`: every allow and deny on it.',
|
|
56
67
|
'',
|
|
57
68
|
"A memory's web address is <site>/by/<owner-handle>/memories/<slug>-<memory-handle>.",
|
|
58
69
|
'A /by read asks for JSON with Accept: application/json; it sends a bearer',
|
package/dist/memory/get.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { parseArgs } from "../request/flags.js";
|
|
2
|
+
import { contactIdFor } from "../memory/access.js";
|
|
2
3
|
import { getRevision } from "../memory/history.js";
|
|
3
4
|
import { composeAddress, formatMemoryDetail, formatMemoryPage, formatNodeWalk, ownHandleFor, parseWebsiteMemoryAddress } from "../memory/views.js";
|
|
4
5
|
import { emit } from "../render/output.js";
|
|
@@ -80,9 +81,21 @@ const GET_FLAG_NAMES = {
|
|
|
80
81
|
'--with': 'with',
|
|
81
82
|
'--links': 'links',
|
|
82
83
|
'--depth': 'depth',
|
|
83
|
-
'--content': 'content'
|
|
84
|
+
'--content': 'content',
|
|
85
|
+
'--for': 'for',
|
|
86
|
+
'--for-phone': 'forPhone'
|
|
84
87
|
};
|
|
85
|
-
const LIST_ONLY_FLAGS = [
|
|
88
|
+
const LIST_ONLY_FLAGS = [
|
|
89
|
+
'type',
|
|
90
|
+
'intent',
|
|
91
|
+
'limit',
|
|
92
|
+
'cursor',
|
|
93
|
+
'q',
|
|
94
|
+
'with',
|
|
95
|
+
'sharedWithMe',
|
|
96
|
+
'for',
|
|
97
|
+
'forPhone'
|
|
98
|
+
];
|
|
86
99
|
const WALK_ONLY_FLAGS = ['links', 'depth', 'revision'];
|
|
87
100
|
const listMemories = async (cfg, io, flags) => {
|
|
88
101
|
const accessToken = await signedIn(io, cfg);
|
|
@@ -105,10 +118,22 @@ const listMemories = async (cfg, io, flags) => {
|
|
|
105
118
|
url.searchParams.set('content', flags.content);
|
|
106
119
|
if (flags.sharedWithMe)
|
|
107
120
|
url.searchParams.set('sharedWithMe', '1');
|
|
121
|
+
if (flags.for !== undefined && flags.forPhone !== undefined) {
|
|
122
|
+
return refusal('--for and --for-phone name one audience; pass one.\n');
|
|
123
|
+
}
|
|
124
|
+
if (flags.for !== undefined) {
|
|
125
|
+
const contact = await contactIdFor(cfg, io, accessToken, flags.for);
|
|
126
|
+
if ('exit' in contact)
|
|
127
|
+
return contact;
|
|
128
|
+
url.searchParams.set('forContact', contact.id);
|
|
129
|
+
}
|
|
130
|
+
if (flags.forPhone !== undefined)
|
|
131
|
+
url.searchParams.set('forPhone', flags.forPhone);
|
|
108
132
|
const result = await io.api(accessToken, url);
|
|
109
133
|
if (!result.ok)
|
|
110
134
|
return refusalOf(result);
|
|
111
|
-
|
|
135
|
+
const asked = flags.forPhone ?? flags.for;
|
|
136
|
+
emit(io, result.data, result.rawText, (page) => formatMemoryPage(page, asked));
|
|
112
137
|
if (result.data.nextCursor) {
|
|
113
138
|
const argv = ['get', 'memories'];
|
|
114
139
|
if (flags.type !== undefined)
|
|
@@ -119,6 +144,10 @@ const listMemories = async (cfg, io, flags) => {
|
|
|
119
144
|
argv.push('--q', flags.q);
|
|
120
145
|
if (flags.with !== undefined)
|
|
121
146
|
argv.push('--with', flags.with);
|
|
147
|
+
if (flags.for !== undefined)
|
|
148
|
+
argv.push('--for', flags.for);
|
|
149
|
+
if (flags.forPhone !== undefined)
|
|
150
|
+
argv.push('--for-phone', flags.forPhone);
|
|
122
151
|
if (flags.limit !== undefined)
|
|
123
152
|
argv.push('--limit', flags.limit);
|
|
124
153
|
if (flags.content !== undefined)
|
|
@@ -195,9 +224,13 @@ export const getMemories = async (cfg, io, rest, noun) => {
|
|
|
195
224
|
return refusal(`--${walkFlag} applies to a single memory, not the list.\n`);
|
|
196
225
|
}
|
|
197
226
|
if (flags.by !== undefined) {
|
|
198
|
-
const ownerOnly = ['type', 'intent', 'q', 'with', 'sharedWithMe'].find((key) => flags[key] !== undefined);
|
|
227
|
+
const ownerOnly = ['type', 'intent', 'q', 'with', 'sharedWithMe', 'for', 'forPhone'].find((key) => flags[key] !== undefined);
|
|
199
228
|
if (ownerOnly !== undefined) {
|
|
200
|
-
const flagName = ownerOnly === 'sharedWithMe'
|
|
229
|
+
const flagName = ownerOnly === 'sharedWithMe'
|
|
230
|
+
? 'shared-with-me'
|
|
231
|
+
: ownerOnly === 'forPhone'
|
|
232
|
+
? 'for-phone'
|
|
233
|
+
: ownerOnly;
|
|
201
234
|
return refusal(`--${flagName} does not apply to a wall listing.\n`);
|
|
202
235
|
}
|
|
203
236
|
return getWallMemories(cfg, io, flags.by, flags);
|
package/dist/memory/recording.js
CHANGED
|
@@ -2,7 +2,7 @@ import { createHash } from 'node:crypto';
|
|
|
2
2
|
import { parseArgs } from "../request/flags.js";
|
|
3
3
|
import { HELP_TOKENS } from "../request/flags.js";
|
|
4
4
|
import { RECORDING_FORMATS, TRANSCRIPT_CONVERTERS, buildRecordingBody, formatRecording, mimeForAudio } from "../memory/transcript.js";
|
|
5
|
-
import {
|
|
5
|
+
import { allowWords, checkShareWords, isRefusalValue, needsYesWords, resolveBornShares, takeShareFlags } from "../memory/capture-common.js";
|
|
6
6
|
import { emit } from "../render/output.js";
|
|
7
7
|
import { confirmAction } from "../render/prompt.js";
|
|
8
8
|
import { sanitizeForTerminal } from "../render/text.js";
|
|
@@ -41,7 +41,10 @@ Usage:
|
|
|
41
41
|
--captured-at <t> when it was recorded (ISO 8601; the future is refused)
|
|
42
42
|
--duration <n> length in seconds
|
|
43
43
|
--span <uuid> group it into one of your spans
|
|
44
|
-
--share-with
|
|
44
|
+
--share-with <who> who may see it from birth: public, all-contacts, or a contact
|
|
45
|
+
(repeatable); asks at a terminal, needs --yes on a pipe
|
|
46
|
+
--deny <who> who may not, whatever else allows it: all-contacts or a
|
|
47
|
+
contact (repeatable); asks nothing
|
|
45
48
|
--contributor <id> whose expression it is — a contact id
|
|
46
49
|
--allow-banned-words keep a flagged word in the title deliberately
|
|
47
50
|
|
|
@@ -60,7 +63,6 @@ const RECORDING_FLAG_NAMES = {
|
|
|
60
63
|
'--captured-at': 'capturedAt',
|
|
61
64
|
'--duration': 'duration',
|
|
62
65
|
'--span': 'span',
|
|
63
|
-
'--share-with': 'shareWith',
|
|
64
66
|
'--contributor': 'contributor'
|
|
65
67
|
};
|
|
66
68
|
export const captureRecording = async (cfg, io, args) => {
|
|
@@ -70,22 +72,21 @@ export const captureRecording = async (cfg, io, args) => {
|
|
|
70
72
|
}
|
|
71
73
|
const allowBanned = args.includes('--allow-banned-words');
|
|
72
74
|
const yes = args.includes('--yes');
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
|
|
75
|
+
const taken = takeShareFlags(args.filter((a) => a !== '--allow-banned-words' && a !== '--yes'));
|
|
76
|
+
const { flags, positionals, unknown } = parseArgs(RECORDING_FLAG_NAMES, taken.rest);
|
|
77
|
+
if (unknown ?? taken.unknown) {
|
|
78
|
+
return refusal(`Unknown flag: ${unknown ?? taken.unknown}\n`);
|
|
76
79
|
}
|
|
77
80
|
if (positionals.length > 1) {
|
|
78
81
|
return refusal(`Unexpected argument: ${positionals[1]}\n`);
|
|
79
82
|
}
|
|
80
83
|
const transcriptFile = positionals[0];
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
return
|
|
84
|
-
|
|
85
|
-
if (
|
|
86
|
-
return refusal('
|
|
87
|
-
'without accounts. There is no prompt here (the content already arrived on ' +
|
|
88
|
-
'a pipe) — pass --yes once the person has confirmed both facts.\n');
|
|
84
|
+
const badShareWords = checkShareWords(taken.shareWith, taken.deny);
|
|
85
|
+
if (badShareWords)
|
|
86
|
+
return badShareWords;
|
|
87
|
+
const allows = allowWords(taken.shareWith);
|
|
88
|
+
if (allows.length > 0 && !io.stdin.isTTY && !yes) {
|
|
89
|
+
return refusal(needsYesWords('recording', allows));
|
|
89
90
|
}
|
|
90
91
|
if (transcriptFile === undefined && flags.audio === undefined && flags.sourceUrl === undefined) {
|
|
91
92
|
return refusal('A recording needs at least one of: a transcript file, --audio, or --source-url.\n');
|
|
@@ -134,6 +135,25 @@ export const captureRecording = async (cfg, io, args) => {
|
|
|
134
135
|
if (flags.duration !== undefined && !/^\d+$/.test(flags.duration)) {
|
|
135
136
|
return refusal(`--duration must be a whole number of seconds: ${flags.duration}\n`);
|
|
136
137
|
}
|
|
138
|
+
if (allows.length > 0 && io.stdin.isTTY) {
|
|
139
|
+
const answer = await confirmAction(io, `Share "${sanitizeForTerminal(flags.title ?? '(untitled)')}" with ${allows.join(', ')}? [y/N] `);
|
|
140
|
+
if (answer === 'interrupted')
|
|
141
|
+
return refusal('Cancelled.\n', EXIT.GENERIC);
|
|
142
|
+
if (answer === 'no') {
|
|
143
|
+
io.stderr.write('Cancelled.\n');
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
const accessToken = await signedIn(io, cfg);
|
|
148
|
+
if (typeof accessToken !== 'string')
|
|
149
|
+
return accessToken;
|
|
150
|
+
let shares;
|
|
151
|
+
if (taken.shareWith.length > 0 || taken.deny.length > 0) {
|
|
152
|
+
const resolved = await resolveBornShares(cfg, io, accessToken, taken.shareWith, taken.deny);
|
|
153
|
+
if (isRefusalValue(resolved))
|
|
154
|
+
return resolved;
|
|
155
|
+
shares = resolved;
|
|
156
|
+
}
|
|
137
157
|
const body = buildRecordingBody({
|
|
138
158
|
transcript,
|
|
139
159
|
upload,
|
|
@@ -141,7 +161,8 @@ export const captureRecording = async (cfg, io, args) => {
|
|
|
141
161
|
title: flags.title,
|
|
142
162
|
capturedAt: flags.capturedAt,
|
|
143
163
|
spanId: flags.span,
|
|
144
|
-
audience:
|
|
164
|
+
audience: shares?.audience,
|
|
165
|
+
access: shares !== undefined && shares.access.length > 0 ? shares.access : undefined,
|
|
145
166
|
contributor: flags.contributor,
|
|
146
167
|
sourceName: flags.sourceName,
|
|
147
168
|
titleAtSource: flags.titleAtSource,
|
|
@@ -150,18 +171,6 @@ export const captureRecording = async (cfg, io, args) => {
|
|
|
150
171
|
durationSeconds: flags.duration === undefined ? undefined : Number(flags.duration),
|
|
151
172
|
allowBannedWords: allowBanned
|
|
152
173
|
});
|
|
153
|
-
if (flags.shareWith !== undefined && io.stdin.isTTY) {
|
|
154
|
-
const answer = await confirmAction(io, `Share "${sanitizeForTerminal(flags.title ?? '(untitled)')}" with public — anyone, including people without accounts? [y/N] `);
|
|
155
|
-
if (answer === 'interrupted')
|
|
156
|
-
return refusal('Cancelled.\n', EXIT.GENERIC);
|
|
157
|
-
if (answer === 'no') {
|
|
158
|
-
io.stderr.write('Cancelled.\n');
|
|
159
|
-
return;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
const accessToken = await signedIn(io, cfg);
|
|
163
|
-
if (typeof accessToken !== 'string')
|
|
164
|
-
return accessToken;
|
|
165
174
|
const created = await io.api(accessToken, `${cfg.apiUrl}/memories/recordings`, {
|
|
166
175
|
method: 'POST',
|
|
167
176
|
headers: { 'Content-Type': 'application/json' },
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { waitsForNameLines } from "../render/rows.js";
|
|
1
2
|
import { sanitizeForTerminal } from "../render/text.js";
|
|
2
3
|
const AUDIO_MIME_BY_EXT = {
|
|
3
4
|
mp3: 'audio/mpeg',
|
|
@@ -80,6 +81,8 @@ export const formatRecording = (r) => {
|
|
|
80
81
|
if (r.durationSeconds)
|
|
81
82
|
lines.push(` duration ${r.durationSeconds}s`);
|
|
82
83
|
lines.push(` capturedAt ${r.capturedAt}`);
|
|
84
|
+
for (const sentence of waitsForNameLines(r.access))
|
|
85
|
+
lines.push(` website ${sentence}`);
|
|
83
86
|
return lines.join('\n');
|
|
84
87
|
};
|
|
85
88
|
//# sourceMappingURL=transcript.js.map
|
package/dist/memory/views.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { formatAudiences } from "../render/rows.js";
|
|
1
|
+
import { describeForContact, formatAccess, formatAudiences } from "../render/rows.js";
|
|
2
2
|
import { sanitizeForTerminal } from "../render/text.js";
|
|
3
3
|
import { stripTrailingSlash } from "../store/environment.js";
|
|
4
4
|
export const formatDeletedLine = (b) => `${b.id} ${b.deletedAt ?? '-'} rev ${b.revisionNo ?? '-'} ${b.fingerprint ?? '-'} ${sanitizeForTerminal(b.title ?? '(untitled)')}`;
|
|
5
5
|
export const formatDeletedPage = (page) => page.items.map((i) => formatDeletedLine(i)).join('\n');
|
|
6
|
+
const graphWord = (b) => b.consented === undefined ? '' : `${b.consented ? 'on graph' : 'off graph'} `;
|
|
6
7
|
export const formatBlockLine = (b) => b.ownerHandle === undefined
|
|
7
8
|
? `${b.id} ${b.handle} ${b.capturedAt} ${b.intent ?? '-'} ${b.visibility.public ? 'public' : '-'} ${sanitizeForTerminal(b.title ?? '(untitled)')}`
|
|
8
|
-
: `${b.id} ${b.handle} ${b.capturedAt} by ${sanitizeForTerminal(b.ownerDisplayName ?? b.ownerHandle)} (@${b.ownerHandle}) ${b
|
|
9
|
+
: `${b.id} ${b.handle} ${b.capturedAt} by ${sanitizeForTerminal(b.ownerDisplayName ?? b.ownerHandle)} (@${b.ownerHandle}) ${graphWord(b)}${sanitizeForTerminal(b.title ?? '(untitled)')}`;
|
|
9
10
|
const SLUG_MAX = 60;
|
|
10
11
|
const slugify = (title) => (title ?? '')
|
|
11
12
|
.toLowerCase()
|
|
@@ -74,6 +75,8 @@ export const formatMemoryDetail = (m, address) => {
|
|
|
74
75
|
if (m.source)
|
|
75
76
|
lines.push(`source ${sanitizeForTerminal(m.source)}`);
|
|
76
77
|
lines.push(`audiences ${formatAudiences(m.audiences)}`);
|
|
78
|
+
if (Array.isArray(m.access))
|
|
79
|
+
lines.push(`access ${formatAccess(m.access)}`);
|
|
77
80
|
if (m.fingerprint)
|
|
78
81
|
lines.push(`fingerprint ${m.fingerprint}`);
|
|
79
82
|
if (m.revisionNo)
|
|
@@ -92,7 +95,13 @@ export const formatMemoryDetail = (m, address) => {
|
|
|
92
95
|
}
|
|
93
96
|
return lines.join('\n');
|
|
94
97
|
};
|
|
95
|
-
export const formatMemoryPage = (page
|
|
98
|
+
export const formatMemoryPage = (page, asked) => {
|
|
99
|
+
const rows = page.items.map((i) => formatBlockLine(i));
|
|
100
|
+
if (page.forContact === undefined)
|
|
101
|
+
return rows.join('\n');
|
|
102
|
+
const header = `for ${describeForContact(page.forContact, asked)}`;
|
|
103
|
+
return [header, ...(rows.length === 0 ? ['(nothing they may see)'] : rows)].join('\n');
|
|
104
|
+
};
|
|
96
105
|
export const formatFindingAid = (a) => {
|
|
97
106
|
const lines = [`id ${a.id}`, `handle ${a.handle}`, `type ${a.type}`];
|
|
98
107
|
if (a.title)
|