@miadi/connector 0.1.29 → 0.1.31
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 +4 -0
- package/dist/approve.js +26 -3
- package/dist/request-state.js +2 -0
- package/dist/source-words.d.ts +13 -0
- package/dist/source-words.js +21 -0
- package/dist/tools.js +9 -6
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -145,6 +145,10 @@ Earned 2026-11-06: 0.1.22 moved the card to `decisions-v2.html` and stopped serv
|
|
|
145
145
|
|
|
146
146
|
A decision is recorded once. An approved run that calls another service (a review operation, Deep Diver, an episode door, a steer) is written to the ledger as approved and running before the call, so a restart can never offer the request for a second approval; a run the connector was recording when it stopped reads as failed and may be run again. A decision whose run takes longer than `MIADI_CONNECTOR_DECISION_WAIT_MS` is answered as recorded and running, and the card reads `get_run_result` every 3 seconds until the outcome is in. The same decision sent again (a host retrying a call, a second click, the page form sent twice) answers with the first one's receipt, marked `replayed`, and runs nothing. A different decision is refused as `decision_conflict`, with where the request stands. When the host gives up on a call, the card reads where the request stands before it offers the buttons again.
|
|
147
147
|
|
|
148
|
+
**A person mentioned and a person on the record (jgwill/Miadi#962).** A person mentioned, by name or as a kind of user, holds nothing back: a spoken name is never a reason to withhold a source or to ask anyone. A person on the record, meaning filmed or with their own voice, words or screens shown, has a release agreed at the start of the production. Nothing but the owner's `withheld` registration holds a source back, and no code counts names. `request_participant_consent` is the door for a person on the record who has no release yet.
|
|
149
|
+
|
|
150
|
+
**An approved create or new version sends the person's words (jgwill/Miadi#963).** `POST /api/reviews` and `POST /api/reviews/:id/versions` carry `source: { title, description, boundaries }` from the `source_intent`: its own fields, or the `TITLE:`, `DESCRIPTION` and `Review boundaries:` lines of its intention. The service keeps none of it, so each generation sends it again, and a new version finds its source through the review's video. The receipt's `source_words.title_taken` reads from the answer whether the service used them. A video already reviewed answers with the existing review, so a `create` on it uses nothing.
|
|
151
|
+
|
|
148
152
|
**A created review gets its transcript (jgwill/Miadi#925).** An approved `create` calls the review service, then reads the video's original-language YouTube captions with a local `uvx yt-dlp` and stores them on the review as `[mm:ss] text`, so an agent reads them through `fetch` and the factory's kind briefs find them with `miadi_review.py transcript`. No model is called for the transcript. The service answers an empty `POST /api/reviews/:id/transcript` by asking Gemini, so an empty one is never sent. `completion_receipt.transcript` says where it stands, and the card and the approval page say the same:
|
|
149
153
|
|
|
150
154
|
| outcome | meaning |
|
package/dist/approve.js
CHANGED
|
@@ -29,6 +29,7 @@ import { contentHash, versionOf } from "./revisions.js";
|
|
|
29
29
|
import { modelAttributes, routeModel } from "./claude-models.js";
|
|
30
30
|
import { TRANSCRIPT_RETRY_MS, transcriptStep } from "./captions.js";
|
|
31
31
|
import { ReviewClient } from "./reviews.js";
|
|
32
|
+
import { sourceWordsOf } from "./source-words.js";
|
|
32
33
|
import { canReadReading } from "./reading/privacy.js";
|
|
33
34
|
import { authorizationReceipt, authorizeProvider, briefAttributes, CHOICE_TTL_MS, CODEX_POLICIES, isPersonId, needsPersonChoice, HOST_ORDER, providerPolicyOf, } from "./provider-policy.js";
|
|
34
35
|
export { factoryDir, runBriefFile, readQueueState } from "./queue-state.js";
|
|
@@ -233,6 +234,16 @@ async function reviewLeftBy(deps, response, videoId) {
|
|
|
233
234
|
return null;
|
|
234
235
|
}
|
|
235
236
|
}
|
|
237
|
+
/** The video of a review a request names only by its id. Unknown when the service cannot say: the request then runs without the source's words. */
|
|
238
|
+
async function videoOfReview(deps, reviewId) {
|
|
239
|
+
try {
|
|
240
|
+
const review = await new ReviewClient(deps.config.reviewUrl, deps.config.reviewToken, deps.fetchImpl ?? fetch).get(reviewId);
|
|
241
|
+
return typeof review?.video_id === "string" ? review.video_id : null;
|
|
242
|
+
}
|
|
243
|
+
catch {
|
|
244
|
+
return null;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
236
247
|
export async function executeApproved(record, approver, deps, instructions) {
|
|
237
248
|
const f = deps.fetchImpl ?? fetch;
|
|
238
249
|
const b = record.body;
|
|
@@ -285,14 +296,26 @@ export async function executeApproved(record, approver, deps, instructions) {
|
|
|
285
296
|
return queueBrief();
|
|
286
297
|
case "review_operation_request": {
|
|
287
298
|
const url = b.video_id ? `https://youtu.be/${b.video_id}` : undefined;
|
|
299
|
+
// The person's title, description and boundaries go with every generation, so it does not read the video alone. The
|
|
300
|
+
// service keeps none of them, so a new version sends them again (jgwill/Miadi#963).
|
|
301
|
+
const video = b.operation === "create" ? b.video_id : b.operation === "new_version" ? (b.video_id ?? (await videoOfReview(deps, b.review_id))) : null;
|
|
302
|
+
const words = video ? sourceWordsOf(current(deps.ledger.all()).find((x) => x.kind === "source_intent" && x.body.video_id === video)) : null;
|
|
288
303
|
const r = b.operation === "create"
|
|
289
|
-
? await reviewCall("POST", "/api/reviews", { url })
|
|
304
|
+
? await reviewCall("POST", "/api/reviews", { url, ...(words ? { source: words } : {}) })
|
|
290
305
|
: b.operation === "import_markdown"
|
|
291
306
|
? await reviewCall("POST", "/api/reviews/import", { url, markdown: b.markdown })
|
|
292
307
|
: b.operation === "new_version"
|
|
293
|
-
? await reviewCall("POST", `/api/reviews/${b.review_id}/versions`, b.transcript ? { transcript: b.transcript } : {})
|
|
308
|
+
? await reviewCall("POST", `/api/reviews/${b.review_id}/versions`, { ...(b.transcript ? { transcript: b.transcript } : {}), ...(words ? { source: words } : {}) })
|
|
294
309
|
: await reviewCall("POST", `/api/reviews/${b.review_id}/transcript`, { transcript: b.transcript });
|
|
295
|
-
const
|
|
310
|
+
const answeredTitle = r.response?.title;
|
|
311
|
+
const result = {
|
|
312
|
+
outcome: r.ok ? "done" : "failed",
|
|
313
|
+
operation: b.operation,
|
|
314
|
+
status: r.status,
|
|
315
|
+
response: r.response,
|
|
316
|
+
// Whether the service used them is read from its answer: a service without the field ignores it and writes its own title.
|
|
317
|
+
...(words ? { source_words: { sent: Object.keys(words), title_taken: words.title ? answeredTitle === words.title : null } } : {}),
|
|
318
|
+
};
|
|
296
319
|
if (b.operation !== "create" || !deps.captions)
|
|
297
320
|
return result;
|
|
298
321
|
const transcript = await transcriptStep({ video_id: b.video_id, review_id: await reviewLeftBy(deps, r.response, b.video_id), since: new Date().toISOString(), ...(b.transcript ? { supplied: b.transcript } : {}) }, transcriptIo(deps));
|
package/dist/request-state.js
CHANGED
|
@@ -208,6 +208,8 @@ function projectCore(record, ctx = {}) {
|
|
|
208
208
|
if (receiptUrl)
|
|
209
209
|
lines.push(`Review: ${receiptUrl}`);
|
|
210
210
|
lines.push(...transcriptLines(receipt.transcript));
|
|
211
|
+
if (receipt.source_words?.title_taken === false)
|
|
212
|
+
lines.push("The source's title and description were sent, and the review service does not use them yet, so this review was written from the video alone.");
|
|
211
213
|
lines.push(...outstanding);
|
|
212
214
|
return finish({
|
|
213
215
|
...base,
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What the person who recorded a video wrote about it: its title, its description and the boundaries of its review.
|
|
3
|
+
* An approved create sends these to generation as evidence (jgwill/Miadi#963). They come from the source's own fields,
|
|
4
|
+
* or from the form a source is registered in today: `TITLE:`, `DESCRIPTION` and `Review boundaries:` lines in its intention.
|
|
5
|
+
*/
|
|
6
|
+
import type { ConnectorRecord } from "./records.js";
|
|
7
|
+
export interface SourceWords {
|
|
8
|
+
title?: string;
|
|
9
|
+
description?: string;
|
|
10
|
+
boundaries?: string;
|
|
11
|
+
}
|
|
12
|
+
/** Null when the source holds none of the three, so a plain source is sent as a bare URL, as before. */
|
|
13
|
+
export declare function sourceWordsOf(source: ConnectorRecord | undefined): SourceWords | null;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
const LIMITS = { title: 200, description: 8000, boundaries: 3000 };
|
|
2
|
+
const clean = (value, limit) => {
|
|
3
|
+
const text = typeof value === "string" ? value.trim() : "";
|
|
4
|
+
return text ? text.slice(0, limit) : undefined;
|
|
5
|
+
};
|
|
6
|
+
/** Null when the source holds none of the three, so a plain source is sent as a bare URL, as before. */
|
|
7
|
+
export function sourceWordsOf(source) {
|
|
8
|
+
if (!source)
|
|
9
|
+
return null;
|
|
10
|
+
const body = source.body;
|
|
11
|
+
const text = source.intention ?? "";
|
|
12
|
+
const boundariesAt = text.search(/^(?:review )?boundaries:/im);
|
|
13
|
+
const beforeBoundaries = boundariesAt >= 0 ? text.slice(0, boundariesAt) : text;
|
|
14
|
+
const words = {
|
|
15
|
+
title: clean(body.title, LIMITS.title) ?? clean(/^TITLE:\s*(.+)$/m.exec(text)?.[1], LIMITS.title),
|
|
16
|
+
description: clean(body.description, LIMITS.description) ?? clean(/^DESCRIPTION:?[ \t]*\n([\s\S]*)$/m.exec(beforeBoundaries)?.[1], LIMITS.description),
|
|
17
|
+
boundaries: clean(body.boundaries, LIMITS.boundaries) ?? (boundariesAt >= 0 ? clean(text.slice(boundariesAt).replace(/^(?:review )?boundaries:/i, ""), LIMITS.boundaries) : undefined),
|
|
18
|
+
};
|
|
19
|
+
const kept = Object.fromEntries(Object.entries(words).filter(([, v]) => v !== undefined));
|
|
20
|
+
return Object.keys(kept).length ? kept : null;
|
|
21
|
+
}
|
package/dist/tools.js
CHANGED
|
@@ -1260,12 +1260,15 @@ export function registerTools(server, ctx) {
|
|
|
1260
1260
|
}));
|
|
1261
1261
|
server.registerTool("register_source_intent", {
|
|
1262
1262
|
title: "Register a pending source",
|
|
1263
|
-
description: "Register a screenwalk or video as a pending source with its intention and readiness, without generating any review. One per video and purpose: registering again returns the first.",
|
|
1263
|
+
description: "Register a screenwalk or video as a pending source with its intention and readiness, without generating any review. One per video and purpose: registering again returns the first. Its title, description and boundaries go to generation when a review is approved. Withhold only when a person is on the record without a release: filmed, or their own voice, words or screens shown. A person mentioned, by name or as a kind of user, holds nothing back, so a spoken name is never a reason to withhold.",
|
|
1264
1264
|
inputSchema: {
|
|
1265
1265
|
video: z.string().min(1).describe("YouTube URL or video id."),
|
|
1266
1266
|
intention: z.string().min(1).max(4000),
|
|
1267
|
-
readiness: z.enum(["uploading", "released_for_review", "withheld"]),
|
|
1267
|
+
readiness: z.enum(["uploading", "released_for_review", "withheld"]).describe("withheld only for a person on the record without a release, never because a name is mentioned."),
|
|
1268
1268
|
purpose: z.string().max(120).default("screenwalk_review"),
|
|
1269
|
+
title: z.string().max(200).optional().describe("What a viewer reads: the review takes this title."),
|
|
1270
|
+
description: z.string().max(8000).optional().describe("What the person wrote under the video, including what has not happened."),
|
|
1271
|
+
boundaries: z.string().max(3000).optional().describe("What the review may not conclude from the video."),
|
|
1269
1272
|
refs,
|
|
1270
1273
|
},
|
|
1271
1274
|
annotations: WRITE,
|
|
@@ -1298,7 +1301,7 @@ export function registerTools(server, ctx) {
|
|
|
1298
1301
|
intention: a.intention,
|
|
1299
1302
|
idempotency_key: `${video}:${a.purpose}`,
|
|
1300
1303
|
state: a.readiness === "released_for_review" ? "ready" : a.readiness === "withheld" ? "blocked" : "pending",
|
|
1301
|
-
body: { video_id: video, supplied: a.video, readiness: a.readiness, purpose: a.purpose },
|
|
1304
|
+
body: { video_id: video, supplied: a.video, readiness: a.readiness, purpose: a.purpose, ...(a.title ? { title: a.title } : {}), ...(a.description ? { description: a.description } : {}), ...(a.boundaries ? { boundaries: a.boundaries } : {}) },
|
|
1302
1305
|
});
|
|
1303
1306
|
}));
|
|
1304
1307
|
server.registerTool("record_handoff", {
|
|
@@ -2109,7 +2112,7 @@ export function registerTools(server, ctx) {
|
|
|
2109
2112
|
}));
|
|
2110
2113
|
server.registerTool("request_participant_consent", {
|
|
2111
2114
|
title: "Ask a person in a video whether its words may be published",
|
|
2112
|
-
description: "
|
|
2115
|
+
description: "For a person on the record in a withheld video: filmed, or their own voice, words or screens shown. A person only mentioned, by name or as a kind of user, needs no question, so never ask because a name is spoken. A person's release from the start of a production will replace this door (jgwill/Miadi#962). This records one question to them, with the video's YouTube captions for them to read, and answers with a link only they decide on, no Miadi sign-in needed. Their yes releases the source and stores the words on the review; their not yet keeps them private, and the source's owner cannot release it around them. It sends nothing: pass consent_url to whoever speaks with that person, or an admin reads the email on approval_url and presses Send.",
|
|
2113
2116
|
inputSchema: {
|
|
2114
2117
|
video: z.string().min(1).describe("YouTube URL or video id of a source you registered."),
|
|
2115
2118
|
person_name: z.string().min(1).max(80).describe("The name they know themselves by; the page greets them with it."),
|
|
@@ -2153,7 +2156,7 @@ export function registerTools(server, ctx) {
|
|
|
2153
2156
|
decider_name: a.person_name,
|
|
2154
2157
|
...(a.person_id ? { decider_person_id: a.person_id } : {}),
|
|
2155
2158
|
...(a.asked_by ? { asked_by: a.asked_by } : {}),
|
|
2156
|
-
question: a.question ?? `${a.asked_by ?? person.name} recorded this video, and you
|
|
2159
|
+
question: a.question ?? `${a.asked_by ?? person.name} recorded this video, and you appear in it. May its words be published beside its review?`,
|
|
2157
2160
|
...(review?.review_id ? { review_id: review.review_id, review_url: review.url } : {}),
|
|
2158
2161
|
transcript: answer.text,
|
|
2159
2162
|
transcript_words: answer.words,
|
|
@@ -2693,7 +2696,7 @@ export const TOOL_STATUS = {
|
|
|
2693
2696
|
request_session_steer: "live, contribute, write tier (one correction to a working agent, forwarded to its runtime; runs inside an approved run's steering grant, else one scoped human decision; get_capabilities.steering says whether the transport works now and which providers have an adapter)",
|
|
2694
2697
|
revoke_session_steering: "live, contribute, write tier (stops a run's steering, or one steer not yet consumed)",
|
|
2695
2698
|
request_review_operation: "live, contribute, needs_approval (create also stores the video's YouTube captions as the review's transcript, no model call)",
|
|
2696
|
-
request_participant_consent: "live, contribute (one question to a person in a withheld video, answered on a link only they decide on; sends nothing)",
|
|
2699
|
+
request_participant_consent: "live, contribute (one question to a person on the record in a withheld video, never for a name only mentioned, answered on a link only they decide on; sends nothing)",
|
|
2697
2700
|
request_screenwalk_reading: "live, contribute, needs_approval (host provider adapter required; stops at editorial decision)",
|
|
2698
2701
|
request_reading_import: "live, contribute, needs_approval (exact public import; atomic service contract required)",
|
|
2699
2702
|
request_deep_diver: "live, contribute, needs_approval",
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "0.1.
|
|
1
|
+
export declare const VERSION = "0.1.31";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "0.1.
|
|
1
|
+
export const VERSION = "0.1.31";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@miadi/connector",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.31",
|
|
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",
|