@mirrowel/opencode-openshare 0.2.1 → 0.3.0-dev.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 +46 -26
- package/ci/README.md +30 -14
- package/ci/openshare.js +461 -61
- package/dist/binding-queue.js +2 -2
- package/dist/commands.js +8 -8
- package/dist/config.d.ts +34 -14
- package/dist/config.js +108 -33
- package/dist/contract.d.ts +5 -5
- package/dist/contract.js +5 -5
- package/dist/core.d.ts +12 -1
- package/dist/core.js +388 -138
- package/dist/dialogs.d.ts +9 -10
- package/dist/dialogs.js +25 -28
- package/dist/redact.d.ts +46 -0
- package/dist/redact.js +130 -0
- package/dist/settings.d.ts +10 -7
- package/dist/settings.js +136 -54
- package/dist/share-flow.d.ts +30 -6
- package/dist/share-flow.js +73 -18
- package/dist/tui.js +251 -59
- package/dist/ui-prefs.js +6 -6
- package/dist/v2-server.js +5 -6
- package/package.json +1 -1
- package/src/binding-queue.ts +2 -2
- package/src/commands.ts +8 -8
- package/src/config.ts +112 -29
- package/src/contract.ts +5 -5
- package/src/core.ts +364 -137
- package/src/dialogs.tsx +29 -32
- package/src/redact.ts +134 -0
- package/src/settings.ts +132 -52
- package/src/share-flow.ts +76 -20
- package/src/sidebar.tsx +7 -7
- package/src/tui.tsx +22 -24
- package/src/ui-prefs.ts +6 -6
- package/src/v2-server.ts +5 -6
package/dist/binding-queue.js
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* the servers map) and the TUI (`patchSessionBinding` in share-flow.ts —
|
|
6
6
|
* opt-outs, collision resolution). Their PATCHes interleave at the host:
|
|
7
7
|
* writer A reads at T0, writer B reads at T1, A PATCHes at T2, B PATCHes
|
|
8
|
-
* at T3
|
|
9
|
-
*
|
|
8
|
+
* at T3, and A's change is silently lost (a TUI opt-out erased by the
|
|
9
|
+
* engine's binding refresh).
|
|
10
10
|
*
|
|
11
11
|
* Both route their whole read-modify-write through this per-session FIFO.
|
|
12
12
|
* The queue never breaks on errors; entries drop when the process exits.
|
package/dist/commands.js
CHANGED
|
@@ -5,14 +5,14 @@
|
|
|
5
5
|
// auth — one surface, no duplicated manager); on an unshared session it
|
|
6
6
|
// asks consent and creates the share. /openshare opens settings.
|
|
7
7
|
//
|
|
8
|
-
// LAYER SHAPE
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
//
|
|
8
|
+
// LAYER SHAPE: the v1 host keymap gates layers that declare `mode` on the
|
|
9
|
+
// mode stack (resting mode is "base"), so a plugin layer MUST NOT pass mode
|
|
10
|
+
// ("global" made the whole layer unreachable: no palette entries, no slash
|
|
11
|
+
// commands, no shadow) and must not carry undefined-valued command fields.
|
|
12
|
+
// The registration shape is exactly what the proven family plugins use:
|
|
13
|
+
// {commands, bindings}, commands with only defined fields, category
|
|
14
|
+
// "OpenShare" (own group, deliberately NOT joined into the shared family
|
|
15
|
+
// palette category).
|
|
16
16
|
import { clearGoneBindingEntries, currentConfig, hostOf, isConfigured, patchSessionBinding, readBindings, resolveRoot, shareWithConsent, verifyShare, } from "./share-flow.js";
|
|
17
17
|
import { onboardingDialog, settingsDialog } from "./settings.js";
|
|
18
18
|
import { engineTargetUrls } from "./core.js";
|
package/dist/config.d.ts
CHANGED
|
@@ -12,6 +12,9 @@ export type ServerEntry = {
|
|
|
12
12
|
label?: string;
|
|
13
13
|
active?: boolean;
|
|
14
14
|
adminToken?: string;
|
|
15
|
+
/** The user DECLINED onboarding for this server (asked once, remembered):
|
|
16
|
+
* shares go out anonymously (public servers only). Cleared by enrolling. */
|
|
17
|
+
anonymous?: boolean;
|
|
15
18
|
};
|
|
16
19
|
export type ShareConfig = {
|
|
17
20
|
workerUrl: string;
|
|
@@ -22,14 +25,33 @@ export type ShareConfig = {
|
|
|
22
25
|
debounceMs: number;
|
|
23
26
|
completedDelayMs: number;
|
|
24
27
|
modelLabel: string;
|
|
25
|
-
|
|
28
|
+
/** Default share lifetime in HOURS (Wave 3; default 2160 = 90d).
|
|
29
|
+
* Legacy ttlDays config/env is accepted and converted x24. */
|
|
30
|
+
ttlHours: number;
|
|
26
31
|
authLogin: string;
|
|
27
32
|
authPassword: string;
|
|
28
33
|
spoolDir: string;
|
|
29
34
|
urlFile: string;
|
|
35
|
+
/** urlFile line format: "url" (default, one bare URL per line) or
|
|
36
|
+
* "json" (one JSON object per line: id, url, status, gated) for CI
|
|
37
|
+
* consumers that want machine-readable lines without parsing URLs. */
|
|
38
|
+
urlFileFormat: "url" | "json";
|
|
30
39
|
/** false silences the `[openshare] live:` (and `url file:`) stderr
|
|
31
40
|
* lines. The share itself is unaffected. */
|
|
32
41
|
announceStderr: boolean;
|
|
42
|
+
/** Wave 3 redaction: user-supplied regex rules (client-side only)
|
|
43
|
+
* applied beside the built-in detectors on UNGATED shares. */
|
|
44
|
+
redact?: {
|
|
45
|
+
patterns?: string[];
|
|
46
|
+
};
|
|
47
|
+
/** B4: which named config set on the server token this agent uses
|
|
48
|
+
* (unset = the token's first/default set). Rides the create frame. */
|
|
49
|
+
configSet?: string;
|
|
50
|
+
/** Free-form string metadata stamped onto every share at create
|
|
51
|
+
* (labels for team directories/admin listings). Values may reference
|
|
52
|
+
* env vars as ${NAME} - interpolated at send time; unresolved refs
|
|
53
|
+
* stay literal so misconfiguration is visible. */
|
|
54
|
+
meta?: Record<string, string>;
|
|
33
55
|
shareMode?: ShareMode;
|
|
34
56
|
};
|
|
35
57
|
export declare const METADATA_KEY = "openshare";
|
|
@@ -64,9 +86,8 @@ export type WriteCandidate = {
|
|
|
64
86
|
};
|
|
65
87
|
/** Write-target candidates for the TUI picker: the global settings home
|
|
66
88
|
* (always writable) plus every OTHER file in the read chain that already
|
|
67
|
-
* exists on disk
|
|
68
|
-
*
|
|
69
|
-
* precedence (highest first). */
|
|
89
|
+
* exists on disk, since the TUI never creates deploy-time overrides. Order:
|
|
90
|
+
* global first (default), then the rest by read precedence (highest first). */
|
|
70
91
|
export declare function writeCandidates(pluginDir: string, env?: NodeJS.ProcessEnv): WriteCandidate[];
|
|
71
92
|
/** Per-key source attribution mirroring loadConfig precedence exactly
|
|
72
93
|
* (env > adjacent > package root > local walks > global > default).
|
|
@@ -77,15 +98,14 @@ export declare function configSourceMap(pluginDir: string, env?: NodeJS.ProcessE
|
|
|
77
98
|
export declare function normalizeServers(raw: unknown): Record<string, ServerEntry> | undefined;
|
|
78
99
|
/** Field-level merge of servers groups: entries only carry present fields
|
|
79
100
|
* (normalizeServers), so a static `code` in plugin options and a persisted
|
|
80
|
-
* `token` in the settings home combine instead of shadowing
|
|
81
|
-
* wholesale replacement would re-enroll on every boot
|
|
82
|
-
* suite design review). */
|
|
101
|
+
* `token` in the settings home combine instead of shadowing. Per-URL
|
|
102
|
+
* wholesale replacement would re-enroll on every boot. */
|
|
83
103
|
export declare function mergeServerGroups(base: Record<string, ServerEntry> | undefined, add: Record<string, ServerEntry>): Record<string, ServerEntry>;
|
|
84
104
|
/** The server new sessions share to: the `active` entry (or the first).
|
|
85
|
-
* Legacy workerUrl/createToken merge in as the implicit first entry
|
|
86
|
-
* the root token ALSO filed as adminToken
|
|
87
|
-
* it only as `token`
|
|
88
|
-
* holder
|
|
105
|
+
* Legacy workerUrl/createToken merge in as the implicit first entry, with
|
|
106
|
+
* the root token ALSO filed as adminToken: the createToken IS root, and
|
|
107
|
+
* filing it only as `token` offers user-actions like rotate to a root
|
|
108
|
+
* holder, while an identity is either admin or user, not both. */
|
|
89
109
|
export declare function resolveServer(cfg: ShareConfig): {
|
|
90
110
|
url: string;
|
|
91
111
|
token: string;
|
|
@@ -110,9 +130,9 @@ export declare function loadConfig(pluginDir: string, options?: Record<string, u
|
|
|
110
130
|
export declare function spoolDirFor(cfg: ShareConfig): string;
|
|
111
131
|
/** Does this plugin spec (tui.json entry) point at the openshare package?
|
|
112
132
|
* Accepts the bare npm name, name@version, and the /tui (or any) subpath
|
|
113
|
-
* form
|
|
114
|
-
* never silently miss it
|
|
115
|
-
* believes they installed manual mode
|
|
133
|
+
* form. Older docs shipped the subpath spec, and presence detection must
|
|
134
|
+
* never silently miss it: all-mode would keep auto-sharing while the user
|
|
135
|
+
* believes they installed manual mode. */
|
|
116
136
|
export declare function isOpenShareSpec(spec: unknown): spec is string;
|
|
117
137
|
/** tui.json layers the TUI reads (mirrors the family selfwire path rules,
|
|
118
138
|
* read-only). The walk runs from the session directory up to the worktree
|
package/dist/config.js
CHANGED
|
@@ -35,11 +35,13 @@ export const DEFAULTS = {
|
|
|
35
35
|
// pending flip, so CI runs still land their final status.
|
|
36
36
|
completedDelayMs: 5000,
|
|
37
37
|
modelLabel: "$Provider/$Model",
|
|
38
|
-
|
|
38
|
+
ttlHours: 90 * 24,
|
|
39
39
|
authLogin: "",
|
|
40
40
|
authPassword: "",
|
|
41
41
|
spoolDir: "",
|
|
42
42
|
urlFile: "",
|
|
43
|
+
urlFileFormat: "url",
|
|
44
|
+
configSet: "",
|
|
43
45
|
announceStderr: true,
|
|
44
46
|
};
|
|
45
47
|
const CONFIG_NAME = "openshare.config.json";
|
|
@@ -97,9 +99,8 @@ export function configHomePath(env = process.env) {
|
|
|
97
99
|
}
|
|
98
100
|
/** Write-target candidates for the TUI picker: the global settings home
|
|
99
101
|
* (always writable) plus every OTHER file in the read chain that already
|
|
100
|
-
* exists on disk
|
|
101
|
-
*
|
|
102
|
-
* precedence (highest first). */
|
|
102
|
+
* exists on disk, since the TUI never creates deploy-time overrides. Order:
|
|
103
|
+
* global first (default), then the rest by read precedence (highest first). */
|
|
103
104
|
export function writeCandidates(pluginDir, env = process.env) {
|
|
104
105
|
const candidates = [{ path: configHomePath(env), label: "global settings (~/.config/opencode)", always: true }];
|
|
105
106
|
const labels = [
|
|
@@ -135,10 +136,13 @@ export function configSourceMap(pluginDir, env = process.env) {
|
|
|
135
136
|
debounceMs: env.OPENSHARE_DEBOUNCE_MS,
|
|
136
137
|
completedDelayMs: env.OPENSHARE_COMPLETED_DELAY_MS,
|
|
137
138
|
modelLabel: env.OPENSHARE_MODEL_LABEL,
|
|
139
|
+
ttlHours: env.OPENSHARE_TTL_HOURS,
|
|
138
140
|
ttlDays: env.OPENSHARE_TTL_DAYS,
|
|
139
141
|
authLogin: env.OPENSHARE_AUTH_LOGIN,
|
|
140
142
|
authPassword: env.OPENSHARE_AUTH_PASSWORD,
|
|
141
143
|
urlFile: env.OPENSHARE_URL_FILE,
|
|
144
|
+
urlFileFormat: env.OPENSHARE_URL_FILE_FORMAT,
|
|
145
|
+
configSet: env.OPENSHARE_CONFIG_SET,
|
|
142
146
|
spoolDir: env.OPENSHARE_SPOOL_DIR,
|
|
143
147
|
announceStderr: env.OPENSHARE_ANNOUNCE_STDERR,
|
|
144
148
|
shareMode: env.OPENSHARE_SHARE_MODE,
|
|
@@ -147,6 +151,28 @@ export function configSourceMap(pluginDir, env = process.env) {
|
|
|
147
151
|
if (value !== undefined && value !== "")
|
|
148
152
|
sources[key] = "environment";
|
|
149
153
|
}
|
|
154
|
+
// legacy days-shaped env feeds the same knob as ttlHours
|
|
155
|
+
if (sources.ttlDays && !sources.ttlHours)
|
|
156
|
+
sources.ttlHours = sources.ttlDays;
|
|
157
|
+
delete sources.ttlDays;
|
|
158
|
+
// OPENSHARE_CONFIG_JSON sits between env and the files: it loses only
|
|
159
|
+
// to a specific env var, so it overrides any file's key
|
|
160
|
+
if (env.OPENSHARE_CONFIG_JSON) {
|
|
161
|
+
try {
|
|
162
|
+
const raw = JSON.parse(env.OPENSHARE_CONFIG_JSON);
|
|
163
|
+
if (raw && typeof raw === "object") {
|
|
164
|
+
for (const [key, value] of Object.entries(raw)) {
|
|
165
|
+
if (typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean")
|
|
166
|
+
continue;
|
|
167
|
+
if (sources[key] === "environment")
|
|
168
|
+
continue;
|
|
169
|
+
if (key === "servers" || known.has(key))
|
|
170
|
+
sources[key] = "OPENSHARE_CONFIG_JSON";
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
catch { }
|
|
175
|
+
}
|
|
150
176
|
// configPaths() is ordered lowest-priority-first? No: index 0 is the
|
|
151
177
|
// ADJACENT file (highest). Merge order reverses it; attribution walks
|
|
152
178
|
// it as-is so the first hit is the winning (highest) source.
|
|
@@ -206,15 +232,16 @@ export function normalizeServers(raw) {
|
|
|
206
232
|
entry.adminToken = e.adminToken;
|
|
207
233
|
if (e.active === true)
|
|
208
234
|
entry.active = true;
|
|
235
|
+
if (e.anonymous === true)
|
|
236
|
+
entry.anonymous = true;
|
|
209
237
|
out[url] = entry;
|
|
210
238
|
}
|
|
211
239
|
return Object.keys(out).length ? out : undefined;
|
|
212
240
|
}
|
|
213
241
|
/** Field-level merge of servers groups: entries only carry present fields
|
|
214
242
|
* (normalizeServers), so a static `code` in plugin options and a persisted
|
|
215
|
-
* `token` in the settings home combine instead of shadowing
|
|
216
|
-
* wholesale replacement would re-enroll on every boot
|
|
217
|
-
* suite design review). */
|
|
243
|
+
* `token` in the settings home combine instead of shadowing. Per-URL
|
|
244
|
+
* wholesale replacement would re-enroll on every boot. */
|
|
218
245
|
export function mergeServerGroups(base, add) {
|
|
219
246
|
const merged = { ...(base ?? {}) };
|
|
220
247
|
for (const [url, entry] of Object.entries(add))
|
|
@@ -222,10 +249,10 @@ export function mergeServerGroups(base, add) {
|
|
|
222
249
|
return merged;
|
|
223
250
|
}
|
|
224
251
|
/** The server new sessions share to: the `active` entry (or the first).
|
|
225
|
-
* Legacy workerUrl/createToken merge in as the implicit first entry
|
|
226
|
-
* the root token ALSO filed as adminToken
|
|
227
|
-
* it only as `token`
|
|
228
|
-
* holder
|
|
252
|
+
* Legacy workerUrl/createToken merge in as the implicit first entry, with
|
|
253
|
+
* the root token ALSO filed as adminToken: the createToken IS root, and
|
|
254
|
+
* filing it only as `token` offers user-actions like rotate to a root
|
|
255
|
+
* holder, while an identity is either admin or user, not both. */
|
|
229
256
|
export function resolveServer(cfg) {
|
|
230
257
|
const servers = {};
|
|
231
258
|
if (cfg.workerUrl)
|
|
@@ -302,29 +329,58 @@ export function loadConfig(pluginDir, options) {
|
|
|
302
329
|
const cfg = { ...DEFAULTS };
|
|
303
330
|
const emptyMeansUnset = new Set(["workerUrl", "createToken", "urlFile", "spoolDir"]);
|
|
304
331
|
const known = new Set([...Object.keys(DEFAULTS), "shareMode"]);
|
|
332
|
+
const applyObject = (raw) => {
|
|
333
|
+
if (!raw || typeof raw !== "object")
|
|
334
|
+
return;
|
|
335
|
+
for (const [key, value] of Object.entries(raw)) {
|
|
336
|
+
if (key === "servers") {
|
|
337
|
+
const servers = normalizeServers(value);
|
|
338
|
+
if (servers)
|
|
339
|
+
cfg.servers = mergeServerGroups(cfg.servers, servers);
|
|
340
|
+
continue;
|
|
341
|
+
}
|
|
342
|
+
if (key === "redact") {
|
|
343
|
+
if (value && typeof value === "object" && Array.isArray(value.patterns)) {
|
|
344
|
+
const pats = value.patterns.filter((x) => typeof x === "string" && x.length > 0 && x.length < 500).slice(0, 50);
|
|
345
|
+
cfg.redact = { patterns: pats };
|
|
346
|
+
}
|
|
347
|
+
continue;
|
|
348
|
+
}
|
|
349
|
+
if (key === "meta") {
|
|
350
|
+
// string-to-string only: meta rides the create frame verbatim
|
|
351
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
352
|
+
const clean = {};
|
|
353
|
+
for (const [mk, mv] of Object.entries(value)) {
|
|
354
|
+
if (typeof mv === "string" && mv.length <= 500 && mk.length <= 64)
|
|
355
|
+
clean[mk] = mv;
|
|
356
|
+
}
|
|
357
|
+
if (Object.keys(clean).length)
|
|
358
|
+
cfg.meta = { ...cfg.meta, ...clean };
|
|
359
|
+
}
|
|
360
|
+
continue;
|
|
361
|
+
}
|
|
362
|
+
if (key === "ttlDays") {
|
|
363
|
+
// legacy days-shaped file/options value converts to hours once
|
|
364
|
+
const d = Math.floor(Number(value));
|
|
365
|
+
if (Number.isFinite(d) && d > 0)
|
|
366
|
+
cfg.ttlHours = d * 24;
|
|
367
|
+
continue;
|
|
368
|
+
}
|
|
369
|
+
if (!known.has(key))
|
|
370
|
+
continue;
|
|
371
|
+
if (typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean")
|
|
372
|
+
continue;
|
|
373
|
+
if (typeof value === "string" && value === "" && emptyMeansUnset.has(key))
|
|
374
|
+
continue;
|
|
375
|
+
cfg[key] = value;
|
|
376
|
+
}
|
|
377
|
+
};
|
|
305
378
|
for (const path of [...configPaths(pluginDir)].reverse()) {
|
|
306
379
|
try {
|
|
307
380
|
// strict JSON: the $comment key (what our templates use) is valid
|
|
308
381
|
// JSON; comment-stripping is deliberately avoided because a naive
|
|
309
382
|
// stripper eats "//" inside workerUrl values
|
|
310
|
-
|
|
311
|
-
if (!raw || typeof raw !== "object")
|
|
312
|
-
continue;
|
|
313
|
-
for (const [key, value] of Object.entries(raw)) {
|
|
314
|
-
if (key === "servers") {
|
|
315
|
-
const servers = normalizeServers(value);
|
|
316
|
-
if (servers)
|
|
317
|
-
cfg.servers = mergeServerGroups(cfg.servers, servers);
|
|
318
|
-
continue;
|
|
319
|
-
}
|
|
320
|
-
if (!known.has(key))
|
|
321
|
-
continue;
|
|
322
|
-
if (typeof value !== "string" && typeof value !== "number" && typeof value !== "boolean")
|
|
323
|
-
continue;
|
|
324
|
-
if (typeof value === "string" && value === "" && emptyMeansUnset.has(key))
|
|
325
|
-
continue;
|
|
326
|
-
cfg[key] = value;
|
|
327
|
-
}
|
|
383
|
+
applyObject(JSON.parse(readFileSync(path, "utf8")));
|
|
328
384
|
}
|
|
329
385
|
catch (e) {
|
|
330
386
|
// a malformed config file is a real setup error the user must hear
|
|
@@ -353,6 +409,19 @@ export function loadConfig(pluginDir, options) {
|
|
|
353
409
|
cfg.shareMode = mode;
|
|
354
410
|
}
|
|
355
411
|
const env = process.env;
|
|
412
|
+
// OPENSHARE_CONFIG_JSON: a complete config object in one env var. Sits
|
|
413
|
+
// between the file/options layers and the per-key OPENSHARE_* env (a
|
|
414
|
+
// specific env var still wins) - CI sets one variable instead of nine,
|
|
415
|
+
// and secrets never touch a file. Malformed JSON is a loud error, not
|
|
416
|
+
// silence (same rule as files).
|
|
417
|
+
if (env.OPENSHARE_CONFIG_JSON) {
|
|
418
|
+
try {
|
|
419
|
+
applyObject(JSON.parse(env.OPENSHARE_CONFIG_JSON));
|
|
420
|
+
}
|
|
421
|
+
catch (e) {
|
|
422
|
+
console.error("[openshare] OPENSHARE_CONFIG_JSON could not be parsed - ignored:", e?.message ?? e);
|
|
423
|
+
}
|
|
424
|
+
}
|
|
356
425
|
if (env.OPENSHARE_WORKER_URL)
|
|
357
426
|
cfg.workerUrl = env.OPENSHARE_WORKER_URL;
|
|
358
427
|
if (env.OPENSHARE_CREATE_TOKEN)
|
|
@@ -363,14 +432,20 @@ export function loadConfig(pluginDir, options) {
|
|
|
363
432
|
cfg.completedDelayMs = num(env.OPENSHARE_COMPLETED_DELAY_MS, cfg.completedDelayMs);
|
|
364
433
|
if (env.OPENSHARE_MODEL_LABEL !== undefined)
|
|
365
434
|
cfg.modelLabel = env.OPENSHARE_MODEL_LABEL;
|
|
435
|
+
if (env.OPENSHARE_TTL_HOURS)
|
|
436
|
+
cfg.ttlHours = num(env.OPENSHARE_TTL_HOURS, cfg.ttlHours);
|
|
366
437
|
if (env.OPENSHARE_TTL_DAYS)
|
|
367
|
-
cfg.
|
|
438
|
+
cfg.ttlHours = Math.max(1, Math.floor(num(env.OPENSHARE_TTL_DAYS, 90) * 24));
|
|
368
439
|
if (env.OPENSHARE_AUTH_LOGIN !== undefined)
|
|
369
440
|
cfg.authLogin = env.OPENSHARE_AUTH_LOGIN;
|
|
370
441
|
if (env.OPENSHARE_AUTH_PASSWORD !== undefined)
|
|
371
442
|
cfg.authPassword = env.OPENSHARE_AUTH_PASSWORD;
|
|
372
443
|
if (env.OPENSHARE_URL_FILE !== undefined)
|
|
373
444
|
cfg.urlFile = env.OPENSHARE_URL_FILE;
|
|
445
|
+
if (env.OPENSHARE_URL_FILE_FORMAT === "json" || env.OPENSHARE_URL_FILE_FORMAT === "url")
|
|
446
|
+
cfg.urlFileFormat = env.OPENSHARE_URL_FILE_FORMAT;
|
|
447
|
+
if (env.OPENSHARE_CONFIG_SET)
|
|
448
|
+
cfg.configSet = env.OPENSHARE_CONFIG_SET;
|
|
374
449
|
if (env.OPENSHARE_SPOOL_DIR)
|
|
375
450
|
cfg.spoolDir = env.OPENSHARE_SPOOL_DIR;
|
|
376
451
|
if (env.OPENSHARE_ANNOUNCE_STDERR !== undefined)
|
|
@@ -421,9 +496,9 @@ function specPath(spec) {
|
|
|
421
496
|
}
|
|
422
497
|
/** Does this plugin spec (tui.json entry) point at the openshare package?
|
|
423
498
|
* Accepts the bare npm name, name@version, and the /tui (or any) subpath
|
|
424
|
-
* form
|
|
425
|
-
* never silently miss it
|
|
426
|
-
* believes they installed manual mode
|
|
499
|
+
* form. Older docs shipped the subpath spec, and presence detection must
|
|
500
|
+
* never silently miss it: all-mode would keep auto-sharing while the user
|
|
501
|
+
* believes they installed manual mode. */
|
|
427
502
|
export function isOpenShareSpec(spec) {
|
|
428
503
|
if (typeof spec !== "string" || spec.length === 0)
|
|
429
504
|
return false;
|
package/dist/contract.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export declare const CONTRACT_VERSION = 2;
|
|
2
2
|
/** Message tombstone item. sessionID MUST ride along: viewers key
|
|
3
|
-
* messages as message/<sessionID>/<id
|
|
4
|
-
*
|
|
5
|
-
*
|
|
3
|
+
* messages as message/<sessionID>/<id>, so an unstamped del misses the key
|
|
4
|
+
* and undone turns resurrect on the live page (a refresh hides them because
|
|
5
|
+
* the worker keys items differently). */
|
|
6
6
|
export declare function messageTombstone(sessionID: string, messageID: string): {
|
|
7
7
|
readonly type: "message";
|
|
8
8
|
readonly del: true;
|
|
@@ -151,6 +151,6 @@ export declare function normalizeV1Message(info: Record<string, unknown>, parts:
|
|
|
151
151
|
export declare function normalizeV1Diff(diff: unknown): unknown;
|
|
152
152
|
/** v1 hosts paginate messages with an opaque cursor: base64url of
|
|
153
153
|
* {id, time} where time = the page tail's time_created (message-v2.ts
|
|
154
|
-
* cursor codec). A bare message id is rejected with 400
|
|
155
|
-
*
|
|
154
|
+
* cursor codec). A bare message id is rejected with 400, which silently
|
|
155
|
+
* truncates a v1 backfill to one page. */
|
|
156
156
|
export declare function cursorFor(id: string, time: number): string;
|
package/dist/contract.js
CHANGED
|
@@ -19,9 +19,9 @@
|
|
|
19
19
|
// the whole message (parts are embedded; no cascade needed).
|
|
20
20
|
export const CONTRACT_VERSION = 2;
|
|
21
21
|
/** Message tombstone item. sessionID MUST ride along: viewers key
|
|
22
|
-
* messages as message/<sessionID>/<id
|
|
23
|
-
*
|
|
24
|
-
*
|
|
22
|
+
* messages as message/<sessionID>/<id>, so an unstamped del misses the key
|
|
23
|
+
* and undone turns resurrect on the live page (a refresh hides them because
|
|
24
|
+
* the worker keys items differently). */
|
|
25
25
|
export function messageTombstone(sessionID, messageID) {
|
|
26
26
|
return { type: "message", del: true, sessionID, data: { id: messageID } };
|
|
27
27
|
}
|
|
@@ -256,8 +256,8 @@ export function normalizeV1Diff(diff) {
|
|
|
256
256
|
}
|
|
257
257
|
/** v1 hosts paginate messages with an opaque cursor: base64url of
|
|
258
258
|
* {id, time} where time = the page tail's time_created (message-v2.ts
|
|
259
|
-
* cursor codec). A bare message id is rejected with 400
|
|
260
|
-
*
|
|
259
|
+
* cursor codec). A bare message id is rejected with 400, which silently
|
|
260
|
+
* truncates a v1 backfill to one page. */
|
|
261
261
|
export function cursorFor(id, time) {
|
|
262
262
|
return Buffer.from(JSON.stringify({ id, time })).toString("base64url");
|
|
263
263
|
}
|
package/dist/core.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type ShareConfig, type ShareMode } from "./config.js";
|
|
2
|
+
import { type RedactionHit } from "./redact.js";
|
|
2
3
|
export type SessionModel = {
|
|
3
4
|
providerID?: string;
|
|
4
5
|
modelID?: string;
|
|
@@ -55,7 +56,7 @@ export type ShareEvent = {
|
|
|
55
56
|
sessionID: string;
|
|
56
57
|
};
|
|
57
58
|
export type SessionOpts = {
|
|
58
|
-
|
|
59
|
+
ttlHours?: number;
|
|
59
60
|
authLogin?: string;
|
|
60
61
|
authPassword?: string;
|
|
61
62
|
modelLabel?: string;
|
|
@@ -114,5 +115,15 @@ export type Engine = {
|
|
|
114
115
|
mode: ShareMode;
|
|
115
116
|
config: () => ShareConfig;
|
|
116
117
|
};
|
|
118
|
+
/** Preflight stats for the consent dialog: message/tool counts plus the
|
|
119
|
+
* redaction ledger (what would be stripped before publishing). */
|
|
120
|
+
export declare function sessionStatsFor(sid: string): {
|
|
121
|
+
messages: number;
|
|
122
|
+
toolCalls: number;
|
|
123
|
+
redaction: {
|
|
124
|
+
count: number;
|
|
125
|
+
samples: RedactionHit[];
|
|
126
|
+
};
|
|
127
|
+
};
|
|
117
128
|
export declare function engineTargetUrls(): string[];
|
|
118
129
|
export declare function createEngine(deps: EngineDeps): Engine;
|