@phnx-labs/artifacts-cli 0.8.3-pre.1 → 0.9.1
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/CHANGELOG.md +42 -0
- package/README.md +35 -1
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +201 -196
- package/dist/cli.js.map +1 -1
- package/dist/commands/share.d.ts +6 -0
- package/dist/commands/share.js +100 -5
- package/dist/commands/share.js.map +1 -1
- package/dist/lib/share/media-core.d.ts +64 -0
- package/dist/lib/share/media-core.js +376 -0
- package/dist/lib/share/media-core.js.map +1 -0
- package/dist/lib/share/media.d.ts +48 -0
- package/dist/lib/share/media.js +76 -0
- package/dist/lib/share/media.js.map +1 -0
- package/dist/lib/share/provision.d.ts +14 -0
- package/dist/lib/share/provision.js +27 -4
- package/dist/lib/share/provision.js.map +1 -1
- package/dist/lib/share/publish.d.ts +9 -8
- package/dist/lib/share/publish.js +633 -28
- package/dist/lib/share/publish.js.map +1 -1
- package/dist/lib/share/worker-media-template.d.ts +1 -0
- package/dist/lib/share/worker-media-template.js +874 -0
- package/dist/lib/share/worker-media-template.js.map +1 -0
- package/dist/lib/share/worker-publish-template.d.ts +1 -0
- package/dist/lib/share/worker-publish-template.js +866 -0
- package/dist/lib/share/worker-publish-template.js.map +1 -0
- package/dist/lib/share/worker-template.js +335 -266
- package/dist/lib/share/worker-template.js.map +1 -1
- package/package.json +3 -2
|
@@ -0,0 +1,376 @@
|
|
|
1
|
+
// Pure pieces of the share Worker's media job (PHNX-4287): Deepgram response →
|
|
2
|
+
// transcript lines, transcript → WebVTT, the OpenRouter summary contract, and
|
|
3
|
+
// the browser script behind the video page's transcript rail.
|
|
4
|
+
//
|
|
5
|
+
// Every function here is serialized into the Worker source (or the viewer page)
|
|
6
|
+
// with Function.prototype.toString, exactly like normalizeSharePath, so each one
|
|
7
|
+
// must stay self-contained: no imports, no module-level references except the
|
|
8
|
+
// other functions in this file that worker-media-template.ts injects alongside.
|
|
9
|
+
/**
|
|
10
|
+
* The transcript lines in a Deepgram pre-recorded response requested with
|
|
11
|
+
* `utterances=true` and `diarize=true`. Throws when the body carries no
|
|
12
|
+
* utterances, naming Deepgram's own error when it sent one.
|
|
13
|
+
*/
|
|
14
|
+
export function mediaTranscriptFromDeepgram(body) {
|
|
15
|
+
const record = body && typeof body === 'object' ? body : {};
|
|
16
|
+
const utterances = record.results && record.results.utterances;
|
|
17
|
+
if (!Array.isArray(utterances)) {
|
|
18
|
+
const reason = record.err_msg || record.error || record.message;
|
|
19
|
+
throw new Error('Deepgram returned no utterances' + (reason ? ': ' + String(reason).slice(0, 200) : ''));
|
|
20
|
+
}
|
|
21
|
+
const round = (n) => Math.round(n * 1000) / 1000;
|
|
22
|
+
const lines = [];
|
|
23
|
+
for (const u of utterances) {
|
|
24
|
+
if (!u || typeof u !== 'object')
|
|
25
|
+
continue;
|
|
26
|
+
const text = typeof u.transcript === 'string' ? u.transcript.trim() : '';
|
|
27
|
+
const start = Number(u.start);
|
|
28
|
+
const end = Number(u.end);
|
|
29
|
+
if (!text || !Number.isFinite(start) || !Number.isFinite(end))
|
|
30
|
+
continue;
|
|
31
|
+
const speaker = Number.isInteger(u.speaker) && u.speaker >= 0 ? u.speaker : 0;
|
|
32
|
+
lines.push({ start: round(Math.max(0, start)), end: round(Math.max(start, end)), speaker, text });
|
|
33
|
+
}
|
|
34
|
+
lines.sort((a, b) => a.start - b.start);
|
|
35
|
+
return lines;
|
|
36
|
+
}
|
|
37
|
+
/** `HH:MM:SS.mmm`, the WebVTT cue timestamp. */
|
|
38
|
+
export function mediaVttTime(seconds) {
|
|
39
|
+
const ms = Math.max(0, Math.round(seconds * 1000));
|
|
40
|
+
const pad = (n, w) => String(n).padStart(w, '0');
|
|
41
|
+
return pad(Math.floor(ms / 3600000), 2) + ':' + pad(Math.floor(ms / 60000) % 60, 2) + ':' +
|
|
42
|
+
pad(Math.floor(ms / 1000) % 60, 2) + '.' + pad(ms % 1000, 3);
|
|
43
|
+
}
|
|
44
|
+
/** A WebVTT captions file, one cue per utterance, voiced by speaker. */
|
|
45
|
+
export function mediaVtt(lines) {
|
|
46
|
+
const escape = (s) => s.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
|
47
|
+
let out = 'WEBVTT\n';
|
|
48
|
+
lines.forEach((line, i) => {
|
|
49
|
+
out += '\n' + (i + 1) + '\n' + mediaVttTime(line.start) + ' --> ' + mediaVttTime(line.end) + '\n' +
|
|
50
|
+
'<v Speaker ' + (line.speaker + 1) + '>' + escape(line.text.replace(/\s*\n+\s*/g, ' ')) + '\n';
|
|
51
|
+
});
|
|
52
|
+
return out;
|
|
53
|
+
}
|
|
54
|
+
/** `m:ss`, or `h:mm:ss` past the hour — the label on every timestamp link. */
|
|
55
|
+
export function mediaClock(seconds) {
|
|
56
|
+
const s = Math.max(0, Math.floor(seconds));
|
|
57
|
+
const pad = (n) => String(n).padStart(2, '0');
|
|
58
|
+
const h = Math.floor(s / 3600);
|
|
59
|
+
const m = Math.floor(s / 60) % 60;
|
|
60
|
+
return h ? h + ':' + pad(m) + ':' + pad(s % 60) : m + ':' + pad(s % 60);
|
|
61
|
+
}
|
|
62
|
+
/** The strict JSON schema the summary request asks OpenRouter to fill. */
|
|
63
|
+
export function mediaSummarySchema() {
|
|
64
|
+
const str = { type: 'string' };
|
|
65
|
+
const strList = { type: 'array', items: str };
|
|
66
|
+
const obj = (properties) => ({
|
|
67
|
+
type: 'object', additionalProperties: false, required: Object.keys(properties), properties,
|
|
68
|
+
});
|
|
69
|
+
return obj({
|
|
70
|
+
title: str,
|
|
71
|
+
summary: str,
|
|
72
|
+
chapters: { type: 'array', items: obj({ t: { type: 'number' }, title: str }) },
|
|
73
|
+
action_items: { type: 'array', items: obj({ text: str, t: { type: 'number' } }) },
|
|
74
|
+
mentions: obj({ prs: strList, tickets: strList }),
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Validate the model's JSON against the summary contract and normalize it:
|
|
79
|
+
* timestamps clamped into the recording, chapters in order, mentions reduced
|
|
80
|
+
* to `owner/repo#N` / `#N` pull requests and `ABC-123` tickets. Throws on any
|
|
81
|
+
* shape mismatch, so a malformed answer fails the job loudly instead of
|
|
82
|
+
* rendering half a summary.
|
|
83
|
+
*/
|
|
84
|
+
export function mediaNormalizeSummary(raw, durationSeconds) {
|
|
85
|
+
const fail = (what) => { throw new Error('summary JSON is malformed: ' + what); };
|
|
86
|
+
if (!raw || typeof raw !== 'object' || Array.isArray(raw))
|
|
87
|
+
fail('expected an object');
|
|
88
|
+
const r = raw;
|
|
89
|
+
const text = (v, what, max) => {
|
|
90
|
+
if (typeof v !== 'string')
|
|
91
|
+
return fail(what + ' must be a string');
|
|
92
|
+
return v.trim().slice(0, max);
|
|
93
|
+
};
|
|
94
|
+
const time = (v, what) => {
|
|
95
|
+
if (typeof v !== 'number' || !Number.isFinite(v))
|
|
96
|
+
return fail(what + ' must be a number of seconds');
|
|
97
|
+
const limit = durationSeconds > 0 ? durationSeconds : v;
|
|
98
|
+
return Math.round(Math.min(Math.max(0, v), limit) * 10) / 10;
|
|
99
|
+
};
|
|
100
|
+
const list = (v, what) => (Array.isArray(v) ? v : fail(what + ' must be an array'));
|
|
101
|
+
const item = (v, what) => (v && typeof v === 'object' && !Array.isArray(v) ? v : fail(what + ' must be an object'));
|
|
102
|
+
const chapters = list(r.chapters, 'chapters').slice(0, 50).map((c, i) => {
|
|
103
|
+
const o = item(c, 'chapters[' + i + ']');
|
|
104
|
+
return { t: time(o.t, 'chapters[' + i + '].t'), title: text(o.title, 'chapters[' + i + '].title', 200) };
|
|
105
|
+
}).filter((c) => c.title).sort((a, b) => a.t - b.t);
|
|
106
|
+
const actionItems = list(r.action_items, 'action_items').slice(0, 50).map((a, i) => {
|
|
107
|
+
const o = item(a, 'action_items[' + i + ']');
|
|
108
|
+
return { text: text(o.text, 'action_items[' + i + '].text', 500), t: time(o.t, 'action_items[' + i + '].t') };
|
|
109
|
+
}).filter((a) => a.text);
|
|
110
|
+
const mentions = item(r.mentions, 'mentions');
|
|
111
|
+
const unique = (values) => values.filter((v, i) => v && values.indexOf(v) === i);
|
|
112
|
+
const prs = unique(list(mentions.prs, 'mentions.prs').map((p) => {
|
|
113
|
+
const s = typeof p === 'string' ? p.trim() : '';
|
|
114
|
+
const url = /^https?:\/\/github\.com\/([\w.-]+\/[\w.-]+)\/pull\/(\d+)/i.exec(s);
|
|
115
|
+
if (url)
|
|
116
|
+
return url[1] + '#' + url[2];
|
|
117
|
+
const ref = /^((?:[\w.-]+\/[\w.-]+)?#\d{1,7})$/.exec(s);
|
|
118
|
+
return ref ? ref[1] : '';
|
|
119
|
+
})).slice(0, 20);
|
|
120
|
+
const tickets = unique(list(mentions.tickets, 'mentions.tickets').map((t) => {
|
|
121
|
+
const s = typeof t === 'string' ? t.trim().toUpperCase() : '';
|
|
122
|
+
return /^[A-Z][A-Z0-9]{1,9}-\d{1,7}$/.test(s) ? s : '';
|
|
123
|
+
})).slice(0, 20);
|
|
124
|
+
return {
|
|
125
|
+
title: text(r.title, 'title', 200),
|
|
126
|
+
summary: text(r.summary, 'summary', 4000),
|
|
127
|
+
chapters,
|
|
128
|
+
action_items: actionItems,
|
|
129
|
+
mentions: { prs, tickets },
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* The `pr` / `ticket` metadata a summary's mentions add to the video, keyed the
|
|
134
|
+
* way `artifacts share list --meta ticket=PHNX-1` filters: the first mention
|
|
135
|
+
* under the bare key, later ones as `-2` … `-5`. A key the owner already set
|
|
136
|
+
* (at publish or with `share edit`) is never overwritten.
|
|
137
|
+
*/
|
|
138
|
+
export function mediaMentionMeta(summary, existing) {
|
|
139
|
+
const out = {};
|
|
140
|
+
const add = (base, values) => {
|
|
141
|
+
values.slice(0, 5).forEach((value, i) => {
|
|
142
|
+
const key = i === 0 ? base : base + '-' + (i + 1);
|
|
143
|
+
if (!Object.prototype.hasOwnProperty.call(existing, key))
|
|
144
|
+
out[key] = value;
|
|
145
|
+
});
|
|
146
|
+
};
|
|
147
|
+
add('pr', summary.mentions.prs);
|
|
148
|
+
add('ticket', summary.mentions.tickets);
|
|
149
|
+
return out;
|
|
150
|
+
}
|
|
151
|
+
/** The transcript as prompt text: one `[seconds] Speaker N: text` line per utterance. */
|
|
152
|
+
export function mediaPromptTranscript(lines, maxChars) {
|
|
153
|
+
let out = '';
|
|
154
|
+
for (const line of lines) {
|
|
155
|
+
const next = '[' + line.start.toFixed(1) + '] Speaker ' + (line.speaker + 1) + ': ' + line.text + '\n';
|
|
156
|
+
if (out.length + next.length > maxChars)
|
|
157
|
+
return out + '[transcript truncated here]\n';
|
|
158
|
+
out += next;
|
|
159
|
+
}
|
|
160
|
+
return out;
|
|
161
|
+
}
|
|
162
|
+
/** `?t=` value → seconds: `90`, `90.5`, `1:30`, `1:02:03`, `1m30s`, `1h2m3s`. Null when unreadable. */
|
|
163
|
+
export function mediaParseTime(raw) {
|
|
164
|
+
if (raw == null)
|
|
165
|
+
return null;
|
|
166
|
+
const s = String(raw).trim().toLowerCase();
|
|
167
|
+
if (/^\d+(\.\d+)?$/.test(s))
|
|
168
|
+
return Number(s);
|
|
169
|
+
if (/^\d+(:\d{1,2}){1,2}$/.test(s))
|
|
170
|
+
return s.split(':').reduce((acc, part) => acc * 60 + Number(part), 0);
|
|
171
|
+
const units = /^(?:(\d+)h)?(?:(\d+)m)?(?:(\d+(?:\.\d+)?)s)?$/.exec(s);
|
|
172
|
+
if (units && (units[1] || units[2] || units[3])) {
|
|
173
|
+
return Number(units[1] || 0) * 3600 + Number(units[2] || 0) * 60 + Number(units[3] || 0);
|
|
174
|
+
}
|
|
175
|
+
return null;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* The video page's browser script: `?t=` deep links, click-to-seek timestamps,
|
|
179
|
+
* the current transcript line highlighted (and kept in view) during playback,
|
|
180
|
+
* in-page transcript search, chapter ticks on the scrub strip, and — while the
|
|
181
|
+
* media job runs — status polling, plus the owner's retry control after a
|
|
182
|
+
* failure. Reads everything from the server-rendered DOM; injected as an IIFE
|
|
183
|
+
* after `mediaParseTime`, which it calls.
|
|
184
|
+
*/
|
|
185
|
+
export function mediaViewerClient() {
|
|
186
|
+
const doc = document;
|
|
187
|
+
const root = doc.querySelector('[data-mv]');
|
|
188
|
+
const video = doc.querySelector('[data-mv-video]');
|
|
189
|
+
if (!root || !video)
|
|
190
|
+
return;
|
|
191
|
+
const state = root.getAttribute('data-mv-state');
|
|
192
|
+
function seek(t, play) {
|
|
193
|
+
if (!isFinite(t))
|
|
194
|
+
return;
|
|
195
|
+
video.currentTime = Math.max(0, t);
|
|
196
|
+
if (play)
|
|
197
|
+
video.play().catch(function () { });
|
|
198
|
+
history.replaceState(null, '', location.pathname + '?t=' + Math.floor(t));
|
|
199
|
+
}
|
|
200
|
+
const initial = mediaParseTime(new URLSearchParams(location.search).get('t'));
|
|
201
|
+
if (initial !== null) {
|
|
202
|
+
const go = function () { video.currentTime = initial; };
|
|
203
|
+
if (video.readyState >= 1)
|
|
204
|
+
go();
|
|
205
|
+
else
|
|
206
|
+
video.addEventListener('loadedmetadata', go, { once: true });
|
|
207
|
+
}
|
|
208
|
+
doc.addEventListener('click', function (e) {
|
|
209
|
+
const target = e.target;
|
|
210
|
+
const link = target && target.closest ? target.closest('[data-mv-seek]') : null;
|
|
211
|
+
if (!link)
|
|
212
|
+
return;
|
|
213
|
+
e.preventDefault();
|
|
214
|
+
seek(Number(link.getAttribute('data-mv-seek')), true);
|
|
215
|
+
});
|
|
216
|
+
const rail = doc.querySelector('[data-mv-lines]');
|
|
217
|
+
const lines = Array.prototype.slice.call(doc.querySelectorAll('[data-mv-line]'));
|
|
218
|
+
const starts = lines.map(function (l) { return Number(l.getAttribute('data-mv-seek')); });
|
|
219
|
+
let current = -1;
|
|
220
|
+
let userScrolledAt = 0;
|
|
221
|
+
if (rail)
|
|
222
|
+
rail.addEventListener('wheel', function () { userScrolledAt = Date.now(); }, { passive: true });
|
|
223
|
+
const strip = doc.querySelector('[data-mv-strip]');
|
|
224
|
+
const fill = doc.querySelector('[data-mv-fill]');
|
|
225
|
+
const ticks = Array.prototype.slice.call(doc.querySelectorAll('[data-mv-tick]'));
|
|
226
|
+
function placeTicks() {
|
|
227
|
+
const d = video.duration;
|
|
228
|
+
if (!isFinite(d) || d <= 0)
|
|
229
|
+
return;
|
|
230
|
+
ticks.forEach(function (tick) {
|
|
231
|
+
tick.style.left = Math.min(100, (Number(tick.getAttribute('data-mv-seek')) / d) * 100) + '%';
|
|
232
|
+
tick.hidden = false;
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
video.addEventListener('loadedmetadata', placeTicks);
|
|
236
|
+
video.addEventListener('durationchange', placeTicks);
|
|
237
|
+
placeTicks();
|
|
238
|
+
if (strip) {
|
|
239
|
+
strip.addEventListener('click', function (e) {
|
|
240
|
+
if (e.target.closest('[data-mv-tick]'))
|
|
241
|
+
return;
|
|
242
|
+
const d = video.duration;
|
|
243
|
+
if (!isFinite(d) || d <= 0)
|
|
244
|
+
return;
|
|
245
|
+
const box = strip.getBoundingClientRect();
|
|
246
|
+
seek(((e.clientX - box.left) / box.width) * d, false);
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
function sync() {
|
|
250
|
+
const t = video.currentTime;
|
|
251
|
+
if (fill && isFinite(video.duration) && video.duration > 0)
|
|
252
|
+
fill.style.width = (t / video.duration) * 100 + '%';
|
|
253
|
+
let lo = 0;
|
|
254
|
+
let hi = starts.length - 1;
|
|
255
|
+
let found = -1;
|
|
256
|
+
while (lo <= hi) {
|
|
257
|
+
const mid = (lo + hi) >> 1;
|
|
258
|
+
if (starts[mid] <= t + 0.05) {
|
|
259
|
+
found = mid;
|
|
260
|
+
lo = mid + 1;
|
|
261
|
+
}
|
|
262
|
+
else
|
|
263
|
+
hi = mid - 1;
|
|
264
|
+
}
|
|
265
|
+
if (found === current)
|
|
266
|
+
return;
|
|
267
|
+
if (current >= 0 && lines[current]) {
|
|
268
|
+
lines[current].classList.remove('on');
|
|
269
|
+
lines[current].removeAttribute('aria-current');
|
|
270
|
+
}
|
|
271
|
+
current = found;
|
|
272
|
+
if (current < 0)
|
|
273
|
+
return;
|
|
274
|
+
const line = lines[current];
|
|
275
|
+
line.classList.add('on');
|
|
276
|
+
line.setAttribute('aria-current', 'true');
|
|
277
|
+
if (rail && Date.now() - userScrolledAt > 4000 && !line.hidden) {
|
|
278
|
+
const top = line.offsetTop - rail.offsetTop;
|
|
279
|
+
if (top < rail.scrollTop || top > rail.scrollTop + rail.clientHeight - line.offsetHeight) {
|
|
280
|
+
rail.scrollTop = top - rail.clientHeight / 3;
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
video.addEventListener('timeupdate', sync);
|
|
285
|
+
video.addEventListener('seeked', sync);
|
|
286
|
+
const search = doc.querySelector('[data-mv-search]');
|
|
287
|
+
const count = doc.querySelector('[data-mv-count]');
|
|
288
|
+
const originals = lines.map(function (l) {
|
|
289
|
+
const t = l.querySelector('.mv-txt');
|
|
290
|
+
return t ? t.textContent || '' : '';
|
|
291
|
+
});
|
|
292
|
+
function highlight(el, text, q) {
|
|
293
|
+
while (el.firstChild)
|
|
294
|
+
el.removeChild(el.firstChild);
|
|
295
|
+
if (!q) {
|
|
296
|
+
el.appendChild(doc.createTextNode(text));
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
299
|
+
const lower = text.toLowerCase();
|
|
300
|
+
let at = 0;
|
|
301
|
+
let hit = lower.indexOf(q);
|
|
302
|
+
while (hit !== -1) {
|
|
303
|
+
el.appendChild(doc.createTextNode(text.slice(at, hit)));
|
|
304
|
+
const mark = doc.createElement('mark');
|
|
305
|
+
mark.textContent = text.slice(hit, hit + q.length);
|
|
306
|
+
el.appendChild(mark);
|
|
307
|
+
at = hit + q.length;
|
|
308
|
+
hit = lower.indexOf(q, at);
|
|
309
|
+
}
|
|
310
|
+
el.appendChild(doc.createTextNode(text.slice(at)));
|
|
311
|
+
}
|
|
312
|
+
if (search) {
|
|
313
|
+
search.addEventListener('input', function () {
|
|
314
|
+
const q = search.value.trim().toLowerCase();
|
|
315
|
+
let matches = 0;
|
|
316
|
+
lines.forEach(function (line, i) {
|
|
317
|
+
const hit = !q || originals[i].toLowerCase().indexOf(q) !== -1;
|
|
318
|
+
line.hidden = !hit;
|
|
319
|
+
if (hit && q)
|
|
320
|
+
matches += 1;
|
|
321
|
+
const txt = line.querySelector('.mv-txt');
|
|
322
|
+
if (txt)
|
|
323
|
+
highlight(txt, originals[i], hit ? q : '');
|
|
324
|
+
});
|
|
325
|
+
if (count)
|
|
326
|
+
count.textContent = q ? matches + (matches === 1 ? ' match' : ' matches') : '';
|
|
327
|
+
});
|
|
328
|
+
search.addEventListener('keydown', function (e) {
|
|
329
|
+
if (e.key !== 'Enter')
|
|
330
|
+
return;
|
|
331
|
+
const first = lines.filter(function (l) { return !l.hidden; })[0];
|
|
332
|
+
if (first)
|
|
333
|
+
seek(Number(first.getAttribute('data-mv-seek')), true);
|
|
334
|
+
});
|
|
335
|
+
}
|
|
336
|
+
const statusUrl = location.pathname + '?media=status';
|
|
337
|
+
const note = doc.querySelector('[data-mv-note]');
|
|
338
|
+
function poll() {
|
|
339
|
+
fetch(statusUrl, { credentials: 'include', headers: { accept: 'application/json' } })
|
|
340
|
+
.then(function (res) { return res.json(); })
|
|
341
|
+
.then(function (s) {
|
|
342
|
+
if (s && s.media === 'pending') {
|
|
343
|
+
setTimeout(poll, 5000);
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
346
|
+
location.reload();
|
|
347
|
+
}, function () { setTimeout(poll, 10000); });
|
|
348
|
+
}
|
|
349
|
+
if (state === 'pending')
|
|
350
|
+
setTimeout(poll, 5000);
|
|
351
|
+
const retry = doc.querySelector('[data-mv-retry]');
|
|
352
|
+
if (retry) {
|
|
353
|
+
retry.addEventListener('click', function () {
|
|
354
|
+
retry.disabled = true;
|
|
355
|
+
fetch(location.pathname + '?media=retry', { method: 'POST', credentials: 'include', headers: { accept: 'application/json' } })
|
|
356
|
+
.then(function (res) { return res.json().then(function (body) { return { ok: res.ok, body: body }; }); })
|
|
357
|
+
.then(function (r) {
|
|
358
|
+
if (r.ok) {
|
|
359
|
+
if (note)
|
|
360
|
+
note.textContent = 'Processing again — this page refreshes when the transcript is ready.';
|
|
361
|
+
root.setAttribute('data-mv-state', 'pending');
|
|
362
|
+
setTimeout(poll, 5000);
|
|
363
|
+
return;
|
|
364
|
+
}
|
|
365
|
+
retry.disabled = false;
|
|
366
|
+
if (note)
|
|
367
|
+
note.textContent = 'Retry failed: ' + String((r.body && r.body.error) || 'unknown error');
|
|
368
|
+
}, function () {
|
|
369
|
+
retry.disabled = false;
|
|
370
|
+
if (note)
|
|
371
|
+
note.textContent = 'Retry failed: network error';
|
|
372
|
+
});
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
//# sourceMappingURL=media-core.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"media-core.js","sourceRoot":"","sources":["../../../src/lib/share/media-core.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,8EAA8E;AAC9E,8DAA8D;AAC9D,EAAE;AACF,gFAAgF;AAChF,iFAAiF;AACjF,8EAA8E;AAC9E,gFAAgF;AAiBhF;;;;GAIG;AACH,MAAM,UAAU,2BAA2B,CAAC,IAAa;IACvD,MAAM,MAAM,GAAG,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAE,IAA4B,CAAC,CAAC,CAAC,EAAE,CAAC;IACrF,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC;IAC/D,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;QAC/B,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,IAAI,MAAM,CAAC,KAAK,IAAI,MAAM,CAAC,OAAO,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EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;iBACxG,IAAI,CAAC,UAAU,CAAC;gBACf,IAAI,CAAC,CAAC,EAAE,EAAE,CAAC;oBACT,IAAI,IAAI;wBAAE,IAAI,CAAC,WAAW,GAAG,sEAAsE,CAAC;oBACpG,IAAI,CAAC,YAAY,CAAC,eAAe,EAAE,SAAS,CAAC,CAAC;oBAC9C,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;oBACvB,OAAO;gBACT,CAAC;gBACD,KAAK,CAAC,QAAQ,GAAG,KAAK,CAAC;gBACvB,IAAI,IAAI;oBAAE,IAAI,CAAC,WAAW,GAAG,gBAAgB,GAAG,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,eAAe,CAAC,CAAC;YACtG,CAAC,EAAE;gBACD,KAAK,CAAC,QAAQ,GAAG,KAAK,CAAC;gBACvB,IAAI,IAAI;oBAAE,IAAI,CAAC,WAAW,GAAG,6BAA6B,CAAC;YAC7D,CAAC,CAAC,CAAC;QACP,CAAC,CAAC,CAAC;IACL,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type ShareBackend } from './backend.js';
|
|
2
|
+
import type { ShareConfig } from './config.js';
|
|
3
|
+
import type { PhoenixSession } from '../identity/client.js';
|
|
4
|
+
export type ShareMediaState = 'none' | 'pending' | 'ready' | 'failed';
|
|
5
|
+
export interface ShareMediaStatus {
|
|
6
|
+
/** `<user>/<slug>` of the video. */
|
|
7
|
+
path: string;
|
|
8
|
+
media: ShareMediaState;
|
|
9
|
+
/** transcribe | summary | done, while a job exists. */
|
|
10
|
+
stage: string | null;
|
|
11
|
+
job: string | null;
|
|
12
|
+
updatedAt: string | null;
|
|
13
|
+
/** Why it failed — the full reason for the owner, a generic one otherwise. */
|
|
14
|
+
error: string | null;
|
|
15
|
+
/** Whether media=/pr=/ticket= reached the video's own listing metadata, once finished. */
|
|
16
|
+
listed: boolean | null;
|
|
17
|
+
/** Why they did not (owner only), e.g. a video too large to rewrite in place. */
|
|
18
|
+
listedNote: string | null;
|
|
19
|
+
/** The derived files, once ready. */
|
|
20
|
+
files: {
|
|
21
|
+
transcript: string;
|
|
22
|
+
captions: string;
|
|
23
|
+
summary: string;
|
|
24
|
+
} | null;
|
|
25
|
+
}
|
|
26
|
+
export interface ShareMediaRetry {
|
|
27
|
+
path: string;
|
|
28
|
+
media: 'pending';
|
|
29
|
+
/** Where the retry restarted: the summary alone, or a fresh transcription. */
|
|
30
|
+
stage: 'summary' | 'transcribe';
|
|
31
|
+
job: string;
|
|
32
|
+
}
|
|
33
|
+
export interface ShareMediaOpts {
|
|
34
|
+
/** An already-resolved endpoint; otherwise resolved from the session/config below. */
|
|
35
|
+
backend?: ShareBackend;
|
|
36
|
+
githubUser?: string;
|
|
37
|
+
config?: ShareConfig;
|
|
38
|
+
writeToken?: string;
|
|
39
|
+
byo?: boolean;
|
|
40
|
+
session?: PhoenixSession | null;
|
|
41
|
+
fetchImpl?: typeof fetch;
|
|
42
|
+
}
|
|
43
|
+
/** Where a published video's transcript and summary stand. */
|
|
44
|
+
export declare function runShareMediaStatus(target: string, opts?: ShareMediaOpts): Promise<ShareMediaStatus>;
|
|
45
|
+
/** Restart a failed (or never-run) media job on a video you own. */
|
|
46
|
+
export declare function runShareMediaRetry(target: string, opts?: ShareMediaOpts): Promise<ShareMediaRetry>;
|
|
47
|
+
export declare function formatShareMediaStatus(status: ShareMediaStatus, json?: boolean): string;
|
|
48
|
+
export declare function formatShareMediaRetry(retry: ShareMediaRetry, json?: boolean): string;
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// `artifacts share media status|retry <target>` (PHNX-4287): read and restart
|
|
2
|
+
// the share Worker's transcript + summary job for one published video.
|
|
3
|
+
import { resolveShareBackend } from './backend.js';
|
|
4
|
+
import { resolveDeleteTarget } from './delete.js';
|
|
5
|
+
const OUTDATED_HINT = "This share endpoint's Worker has no media routes — it predates video transcripts. " +
|
|
6
|
+
"Run 'artifacts share update' to deploy the current Worker template, then retry.";
|
|
7
|
+
async function mediaRequest(target, action, opts) {
|
|
8
|
+
const backend = opts.backend ?? resolveShareBackend({
|
|
9
|
+
githubUser: opts.githubUser,
|
|
10
|
+
config: opts.config,
|
|
11
|
+
writeToken: opts.writeToken,
|
|
12
|
+
byo: opts.byo,
|
|
13
|
+
session: opts.session,
|
|
14
|
+
requireToken: action === 'retry',
|
|
15
|
+
});
|
|
16
|
+
const githubUser = backend.kind === 'managed' ? backend.namespace : opts.githubUser || backend.namespace || undefined;
|
|
17
|
+
const { key } = await resolveDeleteTarget(target, { githubUser });
|
|
18
|
+
const url = `${backend.baseUrl.replace(/\/+$/, '')}/${key.split('/').map(encodeURIComponent).join('/')}?media=${action}`;
|
|
19
|
+
const headers = { accept: 'application/json' };
|
|
20
|
+
if (backend.token)
|
|
21
|
+
headers.authorization = `Bearer ${backend.token}`;
|
|
22
|
+
const res = await (opts.fetchImpl ?? fetch)(url, { method: action === 'retry' ? 'POST' : 'GET', headers, redirect: 'manual' });
|
|
23
|
+
const text = await res.text();
|
|
24
|
+
if (res.status === 302) {
|
|
25
|
+
throw new Error(`Media ${action} for ${key} needs a signed-in viewer. Run 'artifacts auth login'.`);
|
|
26
|
+
}
|
|
27
|
+
let body;
|
|
28
|
+
try {
|
|
29
|
+
body = JSON.parse(text);
|
|
30
|
+
}
|
|
31
|
+
catch {
|
|
32
|
+
// An older Worker answers ?media= with the video itself, or a viewer page.
|
|
33
|
+
throw new Error(res.ok ? OUTDATED_HINT : `Media ${action} failed (${res.status}) for ${key}: ${text.slice(0, 200) || 'no body'}`);
|
|
34
|
+
}
|
|
35
|
+
if (!res.ok) {
|
|
36
|
+
const detail = body && typeof body === 'object' && typeof body.error === 'string'
|
|
37
|
+
? body.error
|
|
38
|
+
: text.slice(0, 200);
|
|
39
|
+
throw new Error(`Media ${action} failed (${res.status}) for ${key}: ${detail}`);
|
|
40
|
+
}
|
|
41
|
+
if (!body || typeof body !== 'object' || typeof body.media !== 'string')
|
|
42
|
+
throw new Error(OUTDATED_HINT);
|
|
43
|
+
return { key, body };
|
|
44
|
+
}
|
|
45
|
+
/** Where a published video's transcript and summary stand. */
|
|
46
|
+
export async function runShareMediaStatus(target, opts = {}) {
|
|
47
|
+
return (await mediaRequest(target, 'status', opts)).body;
|
|
48
|
+
}
|
|
49
|
+
/** Restart a failed (or never-run) media job on a video you own. */
|
|
50
|
+
export async function runShareMediaRetry(target, opts = {}) {
|
|
51
|
+
return (await mediaRequest(target, 'retry', opts)).body;
|
|
52
|
+
}
|
|
53
|
+
export function formatShareMediaStatus(status, json = false) {
|
|
54
|
+
if (json)
|
|
55
|
+
return JSON.stringify(status, null, 2);
|
|
56
|
+
const lines = [`${status.path} media: ${status.media}${status.stage && status.media === 'pending' ? ` (${status.stage})` : ''}`];
|
|
57
|
+
if (status.media === 'none')
|
|
58
|
+
lines.push("No transcript job has run for this video. Start one with 'artifacts share media retry'.");
|
|
59
|
+
if (status.error)
|
|
60
|
+
lines.push(`error: ${status.error}`);
|
|
61
|
+
if (status.files) {
|
|
62
|
+
lines.push(`transcript ${status.files.transcript}`, `captions ${status.files.captions}`, `summary ${status.files.summary}`);
|
|
63
|
+
}
|
|
64
|
+
if (status.listedNote)
|
|
65
|
+
lines.push(`listing: ${status.listedNote}`);
|
|
66
|
+
if (status.updatedAt)
|
|
67
|
+
lines.push(`updated ${status.updatedAt}`);
|
|
68
|
+
return lines.join('\n');
|
|
69
|
+
}
|
|
70
|
+
export function formatShareMediaRetry(retry, json = false) {
|
|
71
|
+
if (json)
|
|
72
|
+
return JSON.stringify(retry, null, 2);
|
|
73
|
+
const what = retry.stage === 'summary' ? 'Re-running the summary from the saved transcript' : 'Transcribing again from the start';
|
|
74
|
+
return `${what} (job ${retry.job}). Check progress with 'artifacts share media status ${retry.path}'.`;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=media.js.map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M,CAAC,KAAK,EAAE,CAAC;QACjB,KAAK,CAAC,IAAI,CAAC,eAAe,MAAM,CAAC,KAAK,CAAC,UAAU,EAAE,EAAE,eAAe,MAAM,CAAC,KAAK,CAAC,QAAQ,EAAE,EAAE,eAAe,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,CAAC,CAAC;IACtI,CAAC;IACD,IAAI,MAAM,CAAC,UAAU;QAAE,KAAK,CAAC,IAAI,CAAC,YAAY,MAAM,CAAC,UAAU,EAAE,CAAC,CAAC;IACnE,IAAI,MAAM,CAAC,SAAS;QAAE,KAAK,CAAC,IAAI,CAAC,WAAW,MAAM,CAAC,SAAS,EAAE,CAAC,CAAC;IAChE,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,KAAsB,EAAE,IAAI,GAAG,KAAK;IACxE,IAAI,IAAI;QAAE,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;IAChD,MAAM,IAAI,GAAG,KAAK,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,kDAAkD,CAAC,CAAC,CAAC,mCAAmC,CAAC;IAClI,OAAO,GAAG,IAAI,SAAS,KAAK,CAAC,GAAG,wDAAwD,KAAK,CAAC,IAAI,IAAI,CAAC;AACzG,CAAC"}
|
|
@@ -48,6 +48,9 @@ interface ProvisionOptions {
|
|
|
48
48
|
/** Bind hosted review threads. Omitted, a deploy carries an existing
|
|
49
49
|
* complete pair forward and binds nothing new. */
|
|
50
50
|
collab?: CollabBinding;
|
|
51
|
+
/** Bind the media job's vendor keys. Omitted, a deploy carries an existing
|
|
52
|
+
* complete set forward and binds nothing new. */
|
|
53
|
+
media?: MediaBinding;
|
|
51
54
|
}
|
|
52
55
|
/** The Worker env names for hosted review threads (PHNX-3835). */
|
|
53
56
|
export declare const WORKER_COLLAB_API_BASE_SECRET = "COLLAB_API_BASE";
|
|
@@ -67,6 +70,17 @@ export interface CollabBinding {
|
|
|
67
70
|
/** The binding `--collab-api <url>` asks for, with its token from the
|
|
68
71
|
* environment. `undefined` when the flag was not passed. */
|
|
69
72
|
export declare function collabBindingFromFlag(apiBase: string | undefined, env?: NodeJS.ProcessEnv): CollabBinding | undefined;
|
|
73
|
+
/**
|
|
74
|
+
* The Worker secrets behind video transcripts and summaries (PHNX-4287), read
|
|
75
|
+
* from the environment under these same names: Deepgram transcribes, OpenRouter
|
|
76
|
+
* summarizes, and MEDIA_JOB_SECRET signs Deepgram's source link and callback.
|
|
77
|
+
* Always all three: the Worker treats a partial set as unbound.
|
|
78
|
+
*/
|
|
79
|
+
export declare const MEDIA_KEY_SECRETS: readonly ["DEEPGRAM_API_KEY", "OPENROUTER_API_KEY", "MEDIA_JOB_SECRET"];
|
|
80
|
+
export type MediaBinding = Record<(typeof MEDIA_KEY_SECRETS)[number], string>;
|
|
81
|
+
/** The binding `--media-keys` asks for, every value from the environment.
|
|
82
|
+
* `undefined` when the flag was not passed; throws naming any missing key. */
|
|
83
|
+
export declare function mediaBindingFromFlag(mediaKeys: boolean | undefined, env?: NodeJS.ProcessEnv): MediaBinding | undefined;
|
|
70
84
|
/** Create the R2 bucket (idempotent). */
|
|
71
85
|
export declare function createBucket(apiToken: string, accountId: string, name: string, opts?: ProvisionOptions): Promise<void>;
|
|
72
86
|
export declare function buildShareLifecycleRule(days?: number): R2LifecycleRule;
|
|
@@ -73,6 +73,24 @@ export function collabBindingFromFlag(apiBase, env = process.env) {
|
|
|
73
73
|
}
|
|
74
74
|
return normalizeCollabBinding({ apiBase, serviceToken });
|
|
75
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* The Worker secrets behind video transcripts and summaries (PHNX-4287), read
|
|
78
|
+
* from the environment under these same names: Deepgram transcribes, OpenRouter
|
|
79
|
+
* summarizes, and MEDIA_JOB_SECRET signs Deepgram's source link and callback.
|
|
80
|
+
* Always all three: the Worker treats a partial set as unbound.
|
|
81
|
+
*/
|
|
82
|
+
export const MEDIA_KEY_SECRETS = ['DEEPGRAM_API_KEY', 'OPENROUTER_API_KEY', 'MEDIA_JOB_SECRET'];
|
|
83
|
+
/** The binding `--media-keys` asks for, every value from the environment.
|
|
84
|
+
* `undefined` when the flag was not passed; throws naming any missing key. */
|
|
85
|
+
export function mediaBindingFromFlag(mediaKeys, env = process.env) {
|
|
86
|
+
if (!mediaKeys)
|
|
87
|
+
return undefined;
|
|
88
|
+
const missing = MEDIA_KEY_SECRETS.filter((name) => !env[name]?.trim());
|
|
89
|
+
if (missing.length) {
|
|
90
|
+
throw new Error(`--media-keys needs ${missing.join(', ')} in the environment so all three media secrets are bound together. Run it under your secrets manager, e.g. \`secrets exec <bundle> -- artifacts share update --media-keys\`.`);
|
|
91
|
+
}
|
|
92
|
+
return Object.fromEntries(MEDIA_KEY_SECRETS.map((name) => [name, env[name].trim()]));
|
|
93
|
+
}
|
|
76
94
|
/** True if the CF error looks like "the thing already exists" (idempotent create). */
|
|
77
95
|
function isAlreadyExists(e) {
|
|
78
96
|
return /already exists|duplicate|10004|10014/i.test(String(e));
|
|
@@ -128,7 +146,7 @@ export async function deployWorker(apiToken, accountId, workerName, worker, buck
|
|
|
128
146
|
JSON.stringify(parseUnlimitedStorage(JSON.stringify(opts.unlimitedStorage)));
|
|
129
147
|
const collab = opts.collab === undefined ? undefined : normalizeCollabBinding(opts.collab);
|
|
130
148
|
let existing = [];
|
|
131
|
-
if (unlimitedStorage === undefined || collab === undefined) {
|
|
149
|
+
if (unlimitedStorage === undefined || collab === undefined || opts.media === undefined) {
|
|
132
150
|
try {
|
|
133
151
|
const settings = await request({
|
|
134
152
|
apiToken,
|
|
@@ -148,6 +166,8 @@ export async function deployWorker(apiToken, accountId, workerName, worker, buck
|
|
|
148
166
|
// dormant, and an upload without it lets the stray half drop.
|
|
149
167
|
const inheritCollab = collab === undefined &&
|
|
150
168
|
existing.includes(WORKER_COLLAB_API_BASE_SECRET) && existing.includes(WORKER_COLLAB_SERVICE_TOKEN_SECRET);
|
|
169
|
+
// Same for the media keys: all three, or none carried forward.
|
|
170
|
+
const inheritMedia = opts.media === undefined && MEDIA_KEY_SECRETS.every((name) => existing.includes(name));
|
|
151
171
|
const metadata = {
|
|
152
172
|
main_module: 'worker.js',
|
|
153
173
|
compatibility_date: '2024-11-06',
|
|
@@ -163,6 +183,8 @@ export async function deployWorker(apiToken, accountId, workerName, worker, buck
|
|
|
163
183
|
{ type: 'secret_text', name: WORKER_COLLAB_API_BASE_SECRET, text: collab.apiBase },
|
|
164
184
|
{ type: 'secret_text', name: WORKER_COLLAB_SERVICE_TOKEN_SECRET, text: collab.serviceToken },
|
|
165
185
|
] : []),
|
|
186
|
+
...(inheritMedia ? MEDIA_KEY_SECRETS.map((name) => ({ type: 'inherit', name })) : []),
|
|
187
|
+
...(opts.media ? MEDIA_KEY_SECRETS.map((name) => ({ type: 'secret_text', name, text: opts.media[name] })) : []),
|
|
166
188
|
],
|
|
167
189
|
};
|
|
168
190
|
const form = new FormData();
|
|
@@ -198,9 +220,10 @@ export const WORKER_PHOENIX_ID_BASE_SECRET = 'PHOENIX_ID_BASE';
|
|
|
198
220
|
export async function updateWorker(apiToken, accountId, workerName, bucketName, worker, writeToken, previousHash, opts = {}) {
|
|
199
221
|
const script = typeof worker === 'string' ? worker : worker.script;
|
|
200
222
|
const templateHash = hashWorkerScript(script);
|
|
201
|
-
// Binding review threads always uploads: the upload metadata
|
|
202
|
-
//
|
|
203
|
-
|
|
223
|
+
// Binding review threads or media keys always uploads: the upload metadata
|
|
224
|
+
// carries the whole set in one request, where the Secrets API would set them
|
|
225
|
+
// one at a time.
|
|
226
|
+
if (!opts.force && previousHash === templateHash && opts.collab === undefined && opts.media === undefined) {
|
|
204
227
|
// Script is current so we skip the upload (which would wipe secrets). A
|
|
205
228
|
// managed Worker still needs PHOENIX_ID_BASE present — a prior upload from
|
|
206
229
|
// a CLI that never set it left the secret missing, and this is the heal
|