@miadi/connector 0.1.37 → 0.1.39
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 +6 -3
- package/dist/approve.d.ts +29 -4
- package/dist/approve.js +201 -29
- package/dist/claude-models.d.ts +69 -4
- package/dist/claude-models.js +111 -22
- package/dist/decisions.d.ts +1 -1
- package/dist/decisions.js +68 -7
- package/dist/draft-review.d.ts +3 -1
- package/dist/draft-review.js +34 -6
- package/dist/local-transcription.js +3 -3
- package/dist/mission-standard.d.ts +5 -0
- package/dist/mission-standard.js +14 -0
- package/dist/record-shares.d.ts +48 -0
- package/dist/record-shares.js +60 -0
- package/dist/server.d.ts +2 -2
- package/dist/server.js +1 -1
- package/dist/tools.js +86 -23
- package/dist/transcript-job.d.ts +7 -1
- package/dist/transcript-job.js +44 -9
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +6 -2
package/dist/transcript-job.js
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* 1. reuse: the review service already holds one, which stays (it is read back and its digest kept);
|
|
9
9
|
* 2. source: a source registered as withheld is neither read nor stored, until it is released;
|
|
10
10
|
* 3. acquire: the video's spoken-language captions, then a local transcription where the host enables it
|
|
11
|
-
*
|
|
11
|
+
* when the video has none. No model service is called and nothing here costs money;
|
|
12
12
|
* 4. store: one POST that never overwrites;
|
|
13
13
|
* 5. readback: the stored text is read from the service and its digest compared with what was sent.
|
|
14
14
|
*
|
|
@@ -74,6 +74,8 @@ const clock = (io) => (io.now ?? Date.now)();
|
|
|
74
74
|
const iso = (ms) => new Date(ms).toISOString();
|
|
75
75
|
/** A job that waits three days keeps the last stages only, so its receipt does not grow with every retry. */
|
|
76
76
|
const MAX_STAGES = 24;
|
|
77
|
+
/** How many times one window runs this host's transcription of the audio before the job fails with what it last answered. */
|
|
78
|
+
export const MAX_LOCAL_ATTEMPTS = 3;
|
|
77
79
|
/** How long an attempt this process does not run may go without writing a stage before it counts as abandoned. */
|
|
78
80
|
export const STALE_MS = 5 * 60_000;
|
|
79
81
|
export const jobKey = (reviewId) => `transcript:${reviewId}`;
|
|
@@ -203,6 +205,22 @@ const failures = {
|
|
|
203
205
|
owner: "operator",
|
|
204
206
|
retry: "none scheduled; ensure_review_transcript starts a new three-day window",
|
|
205
207
|
}),
|
|
208
|
+
// The video has no captions and this host does not transcribe audio: the job still retries (a track can arrive late),
|
|
209
|
+
// and names who can change the answer instead of saying nothing is needed.
|
|
210
|
+
local_off: (message) => ({
|
|
211
|
+
code: "waiting_for_captions",
|
|
212
|
+
message: `${message} Local transcription is off on this host, so the video's audio is not transcribed.`,
|
|
213
|
+
remedy: "An operator enables local transcription on the host (MIADI_TRANSCRIPT_LOCAL=faster-whisper). The next pass then transcribes the audio.",
|
|
214
|
+
owner: "operator",
|
|
215
|
+
retry: "every 15 minutes",
|
|
216
|
+
}),
|
|
217
|
+
local_failed: (message, attempts) => ({
|
|
218
|
+
code: "local_transcription_failed",
|
|
219
|
+
message: `The video has no usable captions, and this host's transcription of its audio produced no transcript in ${attempts} attempts. Last answer: ${message}`,
|
|
220
|
+
remedy: "Read the last answer. A video past the host's limit needs MIADI_TRANSCRIPT_LOCAL_MAX_MINUTES raised, and an engine error needs the host repaired. Then run ensure_review_transcript again, or the source owner supplies the exact transcript through request_review_operation store_transcript.",
|
|
221
|
+
owner: "operator",
|
|
222
|
+
retry: "none scheduled; ensure_review_transcript starts a new window",
|
|
223
|
+
}),
|
|
206
224
|
no_provider: () => ({
|
|
207
225
|
code: "provider_unavailable",
|
|
208
226
|
message: "This connector host has no way to read captions.",
|
|
@@ -240,11 +258,11 @@ async function attempt(io, startJob) {
|
|
|
240
258
|
delete r.next_attempt_at;
|
|
241
259
|
return save(note);
|
|
242
260
|
};
|
|
243
|
-
const wait = (code, message, stage, usedLocal = false) => {
|
|
261
|
+
const wait = (code, message, stage, usedLocal = false, specific) => {
|
|
244
262
|
const expired = clock(io) - Date.parse(r.since) >= TRANSCRIPT_WINDOW_MS;
|
|
245
263
|
if (expired)
|
|
246
264
|
return fail(failures.no_captions(message, usedLocal), stage, "Three days passed without a transcript.");
|
|
247
|
-
mark(stage, "waiting", message);
|
|
265
|
+
mark(stage, "waiting", specific?.message ?? message);
|
|
248
266
|
const next = clock(io) + TRANSCRIPT_RETRY_MS;
|
|
249
267
|
r = {
|
|
250
268
|
...r,
|
|
@@ -252,7 +270,9 @@ async function attempt(io, startJob) {
|
|
|
252
270
|
phase: code,
|
|
253
271
|
next_attempt_at: iso(next),
|
|
254
272
|
give_up_at: iso(Date.parse(r.since) + TRANSCRIPT_WINDOW_MS),
|
|
255
|
-
failure:
|
|
273
|
+
failure: specific
|
|
274
|
+
? { ...specific, retry: `every 15 minutes until ${iso(Date.parse(r.since) + TRANSCRIPT_WINDOW_MS)}` }
|
|
275
|
+
: { code, message, remedy: "None needed: the connector tries again by itself.", owner: "none", retry: `every 15 minutes until ${iso(Date.parse(r.since) + TRANSCRIPT_WINDOW_MS)}` },
|
|
256
276
|
};
|
|
257
277
|
return save(`Tries again at ${r.next_attempt_at}.`);
|
|
258
278
|
};
|
|
@@ -300,7 +320,7 @@ async function attempt(io, startJob) {
|
|
|
300
320
|
return save("Waiting for the source to be released.");
|
|
301
321
|
}
|
|
302
322
|
mark("source_check", "completed", source === "released" ? "The source is released for review." : "No source is registered for this video, and none is withheld.");
|
|
303
|
-
// 3. Acquire: captions first, then a
|
|
323
|
+
// 3. Acquire: captions first, then a transcription of the audio on this host where its operator enabled it.
|
|
304
324
|
if (!io.captions && !io.local)
|
|
305
325
|
return fail(failures.no_provider(), "acquire", "The host has no captions reader.");
|
|
306
326
|
mark("acquire", "started", "YouTube captions in the spoken language");
|
|
@@ -310,14 +330,23 @@ async function attempt(io, startJob) {
|
|
|
310
330
|
// The audio is downloaded and transcribed only when the video has no usable caption track. A reader that failed or a
|
|
311
331
|
// track not made yet waits and retries: a transient failure must not start sixteen minutes of work on this host.
|
|
312
332
|
const captionsAbsent = !io.captions || (answer?.state === "none_yet" && answer.absent === true);
|
|
313
|
-
|
|
314
|
-
|
|
333
|
+
// Every job starts from an authority that covers processing its review: the review service's review.created fact, a
|
|
334
|
+
// person with the write tier or the source's registrant, or an approved mission. So a review whose video has no
|
|
335
|
+
// captions gets its transcript from the audio as soon as it exists. A withheld source never reaches this point.
|
|
336
|
+
if ((!answer || answer.state !== "found") && io.local && captionsAbsent) {
|
|
337
|
+
r = { ...r, local_attempts: (r.local_attempts ?? 0) + 1 };
|
|
338
|
+
mark("acquire", "waiting", `Captions: ${answer?.state === "none_yet" ? answer.message ?? "none yet" : "no reader"} Transcribing the audio on this host (attempt ${r.local_attempts} of ${MAX_LOCAL_ATTEMPTS}).`);
|
|
315
339
|
save();
|
|
316
340
|
usedLocal = true;
|
|
317
341
|
answer = await io.local(r.video_id);
|
|
318
342
|
}
|
|
319
|
-
if (!answer || answer.state !== "found")
|
|
320
|
-
|
|
343
|
+
if (!answer || answer.state !== "found") {
|
|
344
|
+
const message = answer?.message ?? "YouTube has no captions for this video yet.";
|
|
345
|
+
// A transcription that keeps producing nothing ends as a failure a person reads, not as three days of retries.
|
|
346
|
+
if (usedLocal && (r.local_attempts ?? 0) >= MAX_LOCAL_ATTEMPTS)
|
|
347
|
+
return fail(failures.local_failed(message, r.local_attempts ?? MAX_LOCAL_ATTEMPTS), "acquire", "This host's transcription produced no transcript.");
|
|
348
|
+
return wait("waiting_for_captions", message, "acquire", usedLocal, !usedLocal && captionsAbsent ? failures.local_off(message) : undefined);
|
|
349
|
+
}
|
|
321
350
|
const text = answer.text.trim();
|
|
322
351
|
if (!text)
|
|
323
352
|
return wait("waiting_for_captions", "The captions hold no words.", "acquire", usedLocal);
|
|
@@ -435,11 +464,17 @@ export function ensureTranscript(io, input) {
|
|
|
435
464
|
}
|
|
436
465
|
else {
|
|
437
466
|
prior = receiptOf(job);
|
|
467
|
+
// A job an event opened records the approved mission a worker now runs it under.
|
|
468
|
+
if (input.authority?.basis === "approved_mission" && prior.authority?.mission !== input.authority.mission) {
|
|
469
|
+
prior = { ...prior, authority: input.authority };
|
|
470
|
+
job = commit(io, job, prior);
|
|
471
|
+
}
|
|
438
472
|
// A person asking again starts a new window when the job failed or was held, because the cause is usually repaired.
|
|
439
473
|
if (prior.state === "failed" || prior.state === "held") {
|
|
440
474
|
const next = { ...prior, state: "acquiring", phase: "requested", trigger: input.trigger, since: iso(now), stages: [...prior.stages, requested(iso(now), input.trigger)].slice(-MAX_STAGES) };
|
|
441
475
|
delete next.failure;
|
|
442
476
|
delete next.next_attempt_at;
|
|
477
|
+
delete next.local_attempts;
|
|
443
478
|
job = commit(io, job, next);
|
|
444
479
|
}
|
|
445
480
|
}
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "0.1.
|
|
1
|
+
export declare const VERSION = "0.1.39";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "0.1.
|
|
1
|
+
export const VERSION = "0.1.39";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@miadi/connector",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.39",
|
|
4
4
|
"description": "The Miadi connector: one remote MCP service through which a person signed in with their Miadi person token, from ChatGPT or any MCP client, reads sessions, reviews, episodes and circles and records observations, inquiries, handoffs and proposals with their name on each record.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Miadi",
|
|
@@ -36,6 +36,10 @@
|
|
|
36
36
|
"types": "./dist/research-shelf.d.ts",
|
|
37
37
|
"import": "./dist/research-shelf.js"
|
|
38
38
|
},
|
|
39
|
+
"./record-shares": {
|
|
40
|
+
"types": "./dist/record-shares.d.ts",
|
|
41
|
+
"import": "./dist/record-shares.js"
|
|
42
|
+
},
|
|
39
43
|
"./package.json": "./package.json"
|
|
40
44
|
},
|
|
41
45
|
"bin": {
|
|
@@ -47,7 +51,7 @@
|
|
|
47
51
|
"STEERING.md"
|
|
48
52
|
],
|
|
49
53
|
"dependencies": {
|
|
50
|
-
"@miadi/hooks-core": "^0.6.
|
|
54
|
+
"@miadi/hooks-core": "^0.6.2",
|
|
51
55
|
"@miadi/hooks-gateway": "^0.2.1",
|
|
52
56
|
"@miadi/inquiry-weave": "0.18.14",
|
|
53
57
|
"@miadi/node-service-kit": "0.1.2",
|