@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/draft-review.js
CHANGED
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
import { join } from "node:path";
|
|
17
17
|
import { jevConfigOf } from "./providers.js";
|
|
18
18
|
import { jevAdapter } from "./model-preflight.js";
|
|
19
|
-
import { standardSource } from "./mission-standard.js";
|
|
19
|
+
import { MODEL_ASPECT, standardSource } from "./mission-standard.js";
|
|
20
|
+
import { JEV_WITHIN_CLAUDE } from "./claude-models.js";
|
|
20
21
|
import { versionOf } from "./revisions.js";
|
|
21
22
|
import { Ledger } from "./store.js";
|
|
22
23
|
/** Two rounds of report and revision, then the open aspects go on the card (D4). */
|
|
@@ -98,6 +99,26 @@ export function sentencesOf(text, limit = 40) {
|
|
|
98
99
|
.filter((s) => s.length >= 20)
|
|
99
100
|
.slice(0, limit);
|
|
100
101
|
}
|
|
102
|
+
/** Words that set a model or a floor for one: a model's name, a reasoning or review tier, the strongest model (jgwill/Miadi#1028). */
|
|
103
|
+
const FLOOR_WORDS = /\b(opus|fable|sonnet|haiku)\b|\b(?:high|higher|highest|strong|stronger|strongest|top)[- ](?:reasoning|judg(?:e)?ment|capability|model|tier)\b|\b(?:model|review|reasoning)[- ](?:floor|tier)\b|\bmost capable\b/i;
|
|
104
|
+
const PLAIN_FLOOR = /\b(opus|fable|sonnet|haiku|floor|tier)\b|\bmost capable\b/i;
|
|
105
|
+
/** The S7 finding for a mission whose model Jev chooses: a missing task_type, and a floor in the words with no model_floor. */
|
|
106
|
+
export function modelFinding(record, text, aspect) {
|
|
107
|
+
const b = record.body;
|
|
108
|
+
if (b.model_routing !== JEV_WITHIN_CLAUDE || (typeof b.model === "string" && b.model))
|
|
109
|
+
return null;
|
|
110
|
+
const notes = [];
|
|
111
|
+
if (typeof b.task_type !== "string")
|
|
112
|
+
notes.push("No task_type: the model is chosen as for an implementation task at normal criticality, which the fit notes give to Sonnet.");
|
|
113
|
+
// The sentence that sets the floor most plainly (a model's name, a floor, a tier) is the one shown.
|
|
114
|
+
const sentences = typeof b.model_floor === "string" ? [] : sentencesOf(text, 200).filter((s) => FLOOR_WORDS.test(s));
|
|
115
|
+
const said = typeof b.model_floor === "string" ? null : (sentences.find((s) => PLAIN_FLOOR.test(s)) ?? sentences[0] ?? text.match(FLOOR_WORDS)?.[0] ?? null);
|
|
116
|
+
if (said)
|
|
117
|
+
notes.push("The mission's words set a model or a floor, and no model_floor carries it to the choice: Jev never reads the words.");
|
|
118
|
+
if (!notes.length)
|
|
119
|
+
return null;
|
|
120
|
+
return { ...finding(aspect, "code", said ?? undefined), note: notes.join(" ") };
|
|
121
|
+
}
|
|
101
122
|
const missionText = (r) => {
|
|
102
123
|
const b = r.body;
|
|
103
124
|
return b.task ?? [b.title, b.desired_outcome].filter(Boolean).join("\n\n");
|
|
@@ -119,12 +140,14 @@ export async function reviewDraft({ record, records, standard, adapter, now = Da
|
|
|
119
140
|
const delivery = typeof body.delivery === "string" ? body.delivery.trim() : "";
|
|
120
141
|
const personWords = typeof body.person_words === "string" ? body.person_words.trim() : "";
|
|
121
142
|
const text = missionText(record);
|
|
122
|
-
|
|
123
|
-
const
|
|
143
|
+
// S7 is checked in code; the built-in words stand until the prompt store's standard has its own (jgwill/Miadi#1028).
|
|
144
|
+
const aspects = standard.aspects.some((a) => a.code === MODEL_ASPECT.code) ? standard.aspects : [...standard.aspects, MODEL_ASPECT];
|
|
145
|
+
const aspect = (code) => aspects.find((a) => a.code === code);
|
|
146
|
+
const handledInCode = new Set(["S1", "S3", "S6", "S7"]);
|
|
124
147
|
// What goes to Jev: the delivery on its own when code cannot vouch for it, the mission for everything else.
|
|
125
148
|
const s1 = aspect("S1");
|
|
126
149
|
const askDelivery = Boolean(s1?.jev && delivery && !namesExactPlace(delivery));
|
|
127
|
-
const onTask =
|
|
150
|
+
const onTask = aspects.filter((a) => a.jev && !handledInCode.has(a.code) && !(a.code === "S5" && personWords));
|
|
128
151
|
const asks = [];
|
|
129
152
|
const paid = [];
|
|
130
153
|
let jev = adapter ? { state: "ran", model: standard.jev_model, uncalibrated: true } : { state: "unconfigured" };
|
|
@@ -156,8 +179,13 @@ export async function reviewDraft({ record, records, standard, adapter, now = Da
|
|
|
156
179
|
const needs = [];
|
|
157
180
|
const notChecked = [];
|
|
158
181
|
const running = runningMissions(records, record.id, now);
|
|
159
|
-
for (const a of
|
|
160
|
-
if (a.code === "
|
|
182
|
+
for (const a of aspects) {
|
|
183
|
+
if (a.code === "S7") {
|
|
184
|
+
const f = modelFinding(record, text, a);
|
|
185
|
+
if (f)
|
|
186
|
+
needs.push(f);
|
|
187
|
+
}
|
|
188
|
+
else if (a.code === "S1") {
|
|
161
189
|
if (!delivery)
|
|
162
190
|
needs.push(finding(a, "code"));
|
|
163
191
|
else if (askDelivery) {
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* A transcription made on this host, for a video whose captions are missing (jgwill/Miadi#995).
|
|
3
3
|
*
|
|
4
4
|
* It is the second reader a transcript job tries, after YouTube's captions, and only where the host's
|
|
5
|
-
* operator enabled it (`MIADI_TRANSCRIPT_LOCAL=faster-whisper`)
|
|
6
|
-
*
|
|
7
|
-
* no money. The resources are bounded: one transcription at a time, a longest video
|
|
5
|
+
* operator enabled it (`MIADI_TRANSCRIPT_LOCAL=faster-whisper`). It downloads the video's audio, which a
|
|
6
|
+
* withheld source does not allow: the job holds such a source before it reaches this reader. It calls no
|
|
7
|
+
* model service and costs no money. The resources are bounded: one transcription at a time, a longest video
|
|
8
8
|
* (`MIADI_TRANSCRIPT_LOCAL_MAX_MINUTES`, default 90) and a time limit.
|
|
9
9
|
*/
|
|
10
10
|
import { execFile } from "node:child_process";
|
|
@@ -53,6 +53,11 @@ export interface MissionStandard {
|
|
|
53
53
|
/** Standing preferences by person id, returned to the agent drafting for that person. */
|
|
54
54
|
preferences: Record<string, string[]>;
|
|
55
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* What the model of a mission is chosen from (jgwill/Miadi#1028). Checked in code, so it runs while the
|
|
58
|
+
* prompt store's standard has no S7: a store standard that has one replaces its words.
|
|
59
|
+
*/
|
|
60
|
+
export declare const MODEL_ASPECT: StandardAspect;
|
|
56
61
|
export declare const BUILT_IN_STANDARD: MissionStandard;
|
|
57
62
|
/** The stored document, or an error saying what is outside the contract. A model alias is refused: one pinned version per standard. */
|
|
58
63
|
export declare function parseStandard(text: string, version: number): MissionStandard;
|
package/dist/mission-standard.js
CHANGED
|
@@ -16,6 +16,19 @@ export const STANDARD_NAME = "mission-standard";
|
|
|
16
16
|
const CACHE_MS = 10 * 60 * 1000;
|
|
17
17
|
const STORE_TIMEOUT_MS = 3000;
|
|
18
18
|
const DEFAULT_STORE_URL = "https://cloud.langfuse.com";
|
|
19
|
+
/**
|
|
20
|
+
* What the model of a mission is chosen from (jgwill/Miadi#1028). Checked in code, so it runs while the
|
|
21
|
+
* prompt store's standard has no S7: a store standard that has one replaces its words.
|
|
22
|
+
*/
|
|
23
|
+
export const MODEL_ASPECT = {
|
|
24
|
+
code: "S7",
|
|
25
|
+
name: "the model the mission needs",
|
|
26
|
+
requires: "A mission whose model Jev chooses says its task_type, and sets model_floor when its words set a floor or name a model.",
|
|
27
|
+
why: "Jev reads only the task type and criticality, never the words. A missing task type is chosen as implementation, which goes to Sonnet, and a floor written only in the text never reaches the choice.",
|
|
28
|
+
ask: "What kind of task is this, and what is the weakest model it may run on?",
|
|
29
|
+
fix: "Set task_type and criticality, and model_floor when the words set a floor (or model when the person named one).",
|
|
30
|
+
settled_by: "drafter",
|
|
31
|
+
};
|
|
19
32
|
export const BUILT_IN_STANDARD = {
|
|
20
33
|
name: STANDARD_NAME,
|
|
21
34
|
version: 1,
|
|
@@ -100,6 +113,7 @@ export const BUILT_IN_STANDARD = {
|
|
|
100
113
|
fix: "Name them in refs and primary_issue.",
|
|
101
114
|
settled_by: "drafter",
|
|
102
115
|
},
|
|
116
|
+
MODEL_ASPECT,
|
|
103
117
|
],
|
|
104
118
|
};
|
|
105
119
|
const isText = (v) => typeof v === "string" && v.trim().length > 0;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A connector record shared through a talking circle or with one person: the rule jgwill/Miadi#1005 gives a
|
|
3
|
+
* shelf report, for a record (an inquiry, a handoff, a proposal).
|
|
4
|
+
*
|
|
5
|
+
* A share is a `link` record its author makes, from the record, to `miadi-circle:<circle id>` (or the bare
|
|
6
|
+
* `circle:<id>`) or a person's node id, with the relation `shared_with`. A later link from the author with
|
|
7
|
+
* the relation `share_withdrawn`, from the same record to the same reader, ends it. The ledger keeps both, so
|
|
8
|
+
* who shared what with whom, and when it ended, stays readable. A link anyone else makes shares nothing: the
|
|
9
|
+
* author decides each share.
|
|
10
|
+
*
|
|
11
|
+
* Ref: jgwill/Miadi#1005, jgwill/Miadi#879
|
|
12
|
+
*/
|
|
13
|
+
import type { ConnectorRecord } from "./records.js";
|
|
14
|
+
export declare const SHARE_RELATION = "shared_with";
|
|
15
|
+
export declare const WITHDRAW_RELATION = "share_withdrawn";
|
|
16
|
+
export interface RecordShare {
|
|
17
|
+
/** The person's node id or the talking circle's id, as the share names it. */
|
|
18
|
+
to: string;
|
|
19
|
+
person_id?: string;
|
|
20
|
+
circle?: string;
|
|
21
|
+
/** Who shared it, and when: the author, by name. */
|
|
22
|
+
by: string;
|
|
23
|
+
at: string;
|
|
24
|
+
/** The link record that made the share. */
|
|
25
|
+
link: string;
|
|
26
|
+
}
|
|
27
|
+
export interface RecordReader {
|
|
28
|
+
id: string;
|
|
29
|
+
api_tier?: string | null;
|
|
30
|
+
/** The talking circles the reader sits in now; read only when a record is shared with a circle. */
|
|
31
|
+
circles?: Iterable<string>;
|
|
32
|
+
}
|
|
33
|
+
export interface RecordAccess {
|
|
34
|
+
as: "author" | "shared" | "read_tier";
|
|
35
|
+
/** For a share: every share that reaches this reader. */
|
|
36
|
+
routes: RecordShare[];
|
|
37
|
+
}
|
|
38
|
+
/** Whom a share link names: a talking circle or a person, else nobody. */
|
|
39
|
+
export declare function shareTarget(to: string): {
|
|
40
|
+
person_id?: string;
|
|
41
|
+
circle?: string;
|
|
42
|
+
} | null;
|
|
43
|
+
export declare function isShareRelation(relation: unknown): boolean;
|
|
44
|
+
/** The shares of a record that stand now, oldest first. */
|
|
45
|
+
export declare function recordShares(record: ConnectorRecord, ledger: readonly ConnectorRecord[]): RecordShare[];
|
|
46
|
+
export declare function recordSharedWithACircle(record: ConnectorRecord, ledger: readonly ConnectorRecord[]): boolean;
|
|
47
|
+
/** How a reader may read a record: as its author, through a share (each one named), or with Miadi's read tier; null when not at all. */
|
|
48
|
+
export declare function recordAccess(record: ConnectorRecord, ledger: readonly ConnectorRecord[], reader: RecordReader): RecordAccess | null;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A connector record shared through a talking circle or with one person: the rule jgwill/Miadi#1005 gives a
|
|
3
|
+
* shelf report, for a record (an inquiry, a handoff, a proposal).
|
|
4
|
+
*
|
|
5
|
+
* A share is a `link` record its author makes, from the record, to `miadi-circle:<circle id>` (or the bare
|
|
6
|
+
* `circle:<id>`) or a person's node id, with the relation `shared_with`. A later link from the author with
|
|
7
|
+
* the relation `share_withdrawn`, from the same record to the same reader, ends it. The ledger keeps both, so
|
|
8
|
+
* who shared what with whom, and when it ended, stays readable. A link anyone else makes shares nothing: the
|
|
9
|
+
* author decides each share.
|
|
10
|
+
*
|
|
11
|
+
* Ref: jgwill/Miadi#1005, jgwill/Miadi#879
|
|
12
|
+
*/
|
|
13
|
+
export const SHARE_RELATION = "shared_with";
|
|
14
|
+
export const WITHDRAW_RELATION = "share_withdrawn";
|
|
15
|
+
/** Whom a share link names: a talking circle or a person, else nobody. */
|
|
16
|
+
export function shareTarget(to) {
|
|
17
|
+
const t = to.trim().replace(/^miadi-circle:(?:\/\/)?/i, "");
|
|
18
|
+
if (/^circle:[A-Za-z0-9._~:-]+$/.test(t))
|
|
19
|
+
return { circle: t };
|
|
20
|
+
if (/^(?:node:)?(?:human|agent|person)[:A-Za-z0-9._~-]*$/.test(t) && t.includes(":"))
|
|
21
|
+
return { person_id: t };
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
export function isShareRelation(relation) {
|
|
25
|
+
return relation === SHARE_RELATION || relation === WITHDRAW_RELATION;
|
|
26
|
+
}
|
|
27
|
+
/** The shares of a record that stand now, oldest first. */
|
|
28
|
+
export function recordShares(record, ledger) {
|
|
29
|
+
const active = new Map();
|
|
30
|
+
const links = ledger
|
|
31
|
+
.filter((l) => l.kind === "link" && l.actor?.person_id === record.actor?.person_id && l.body?.from === record.id)
|
|
32
|
+
.sort((a, b) => a.created_at.localeCompare(b.created_at));
|
|
33
|
+
for (const l of links) {
|
|
34
|
+
const b = l.body;
|
|
35
|
+
const who = typeof b.to === "string" ? shareTarget(b.to) : null;
|
|
36
|
+
if (!who)
|
|
37
|
+
continue;
|
|
38
|
+
const key = who.circle ?? who.person_id;
|
|
39
|
+
if (b.relation === SHARE_RELATION)
|
|
40
|
+
active.set(key, { to: key, ...who, by: l.actor.name, at: l.created_at, link: l.id });
|
|
41
|
+
else if (b.relation === WITHDRAW_RELATION)
|
|
42
|
+
active.delete(key);
|
|
43
|
+
}
|
|
44
|
+
return [...active.values()];
|
|
45
|
+
}
|
|
46
|
+
export function recordSharedWithACircle(record, ledger) {
|
|
47
|
+
return recordShares(record, ledger).some((s) => s.circle);
|
|
48
|
+
}
|
|
49
|
+
/** How a reader may read a record: as its author, through a share (each one named), or with Miadi's read tier; null when not at all. */
|
|
50
|
+
export function recordAccess(record, ledger, reader) {
|
|
51
|
+
if (record.actor?.person_id === reader.id)
|
|
52
|
+
return { as: "author", routes: [] };
|
|
53
|
+
const circles = new Set(reader.circles ?? []);
|
|
54
|
+
const routes = recordShares(record, ledger).filter((s) => s.person_id === reader.id || (s.circle !== undefined && circles.has(s.circle)));
|
|
55
|
+
if (routes.length)
|
|
56
|
+
return { as: "shared", routes };
|
|
57
|
+
if (reader.api_tier)
|
|
58
|
+
return { as: "read_tier", routes: [] };
|
|
59
|
+
return null;
|
|
60
|
+
}
|
package/dist/server.d.ts
CHANGED
|
@@ -47,7 +47,7 @@ export interface ConnectorDeps {
|
|
|
47
47
|
clones?: (repository: string) => string | undefined;
|
|
48
48
|
/** Reads a video's captions for an approved create; the service passes youtubeCaptions, tests their own. */
|
|
49
49
|
captions?: FetchCaptions;
|
|
50
|
-
/** A transcription made on this host, tried
|
|
50
|
+
/** A transcription made on this host from the video's audio, tried when the video has no captions (jgwill/Miadi#995). */
|
|
51
51
|
localTranscription?: FetchCaptions;
|
|
52
52
|
/** The event folder: the review.created facts this connector takes, and the ledger it announces outcomes in (jgwill/Miadi#995). */
|
|
53
53
|
eventsDir?: string;
|
|
@@ -61,4 +61,4 @@ export declare function createConnectorApp(config: ConnectorConfig, deps: Connec
|
|
|
61
61
|
provider: MiadiOAuthProvider;
|
|
62
62
|
ledger: Ledger<ConnectorRecord>;
|
|
63
63
|
};
|
|
64
|
-
export declare const INSTRUCTIONS = "Miadi is a relational software factory: agent sessions, Miadi reviews of screenwalks, Chronicle episodes, talking circles and the five accountable circles (Story, Stewardship, Engineering, Evaluation, Continuity) across three domains (Creative, Ceremonial, Engineering).\n\nStart with get_capabilities: it says who you are signed in as, which tools are live, and which return not_implemented.\n\nEvery tool is offered on every connection. A client that loads tools on demand shows only those its last tool search matched: a tool you do not see is not missing. Search for it by its exact name, get_capabilities first, before telling the person a tool is absent. The main reads are get_capabilities, get_context, search, fetch, list_records, list_sessions, search_sessions, get_session, review_lookup, read_episode_file and show_decisions.\n\nRules every tool keeps:\n- Every record names the person who made it, with a claim category: observed, hypothesis, desired_future, fiction or verified_implementation. Keep fiction and desired futures apart from what was observed.\n- Requests (runs, work proposals, review operations, Deep Diver, review-to-episode links, inquiry-to-episode weaves, session completion) are recorded as awaiting_approval. Nothing runs, publishes or closes until a person decides. After making a request, call show_decisions: it shows the request as a card in the conversation, where the person decides with their own click (or follows its approval page). Never claim a decision the card has not reported. The person may approve, approve with changes (their instructions are carried into what runs), send it back for revision with instructions (approval_state revision_requested; read the instructions with get_run_result and revise it in place with revise_pending_request), or decline.\n- A new or revised run or work proposal answers with draft_review: the aspects of the mission standard to revise, each with why, the question to settle and who can settle it. Read it before show_decisions. It carries no verdict, it advises and blocks nothing, and next_action says what to do. Answer what your conversation holds, ask the person the rest, then revise. preferences lists the person's standing preferences for you to apply. Fill delivery with the one exact place the result lands, and person_words with the person's own words, verbatim, for anything credited to them.\n- A mission is revised, never re-requested: to change a run or work proposal that still awaits a decision, call revise_pending_request with its id and the version you read (expected_version). It keeps one id, one approval page and one card; get_request_history shows every version. A new request_authorized_run or propose_work is for a new mission only. Requests made earlier as separate versions are joined with supersede_pending_requests, naming their exact ids, only when the person names or confirms them.\n- A research report (a Deep Research report) is delivered with save_research exactly as written, never summarised or shortened, with its sources; a long report goes in parts. Check the bytes and first and last lines the answer returns against what you sent.\n- A review's transcript is acquired by ensure_review_transcript, for a review made anywhere. It needs no decision and no pasted text, takes the video's own captions, never overwrites and calls no model. review_lookup and review_versions carry the transcript's state (unknown, absent, acquiring, stored, held or failed). review_transcript_status follows a job, and every answer carries plain links that work when no card is shown.\n- An unknown id is answered as not found, never invented. A missing backing service is answered as unavailable.\n- Use the miadi-review:<uuid>, miadi-chronicle://<n>, owner/repo#n and session:<uuid> reference forms.";
|
|
64
|
+
export declare const INSTRUCTIONS = "Miadi is a relational software factory: agent sessions, Miadi reviews of screenwalks, Chronicle episodes, talking circles and the five accountable circles (Story, Stewardship, Engineering, Evaluation, Continuity) across three domains (Creative, Ceremonial, Engineering).\n\nStart with get_capabilities: it says who you are signed in as, which tools are live, and which return not_implemented.\n\nEvery tool is offered on every connection. A client that loads tools on demand shows only those its last tool search matched: a tool you do not see is not missing. Search for it by its exact name, get_capabilities first, before telling the person a tool is absent. The main reads are get_capabilities, get_context, search, fetch, list_records, list_sessions, search_sessions, get_session, review_lookup, read_episode_file and show_decisions.\n\nRules every tool keeps:\n- Every record names the person who made it, with a claim category: observed, hypothesis, desired_future, fiction or verified_implementation. Keep fiction and desired futures apart from what was observed.\n- Requests (runs, work proposals, review operations, Deep Diver, review-to-episode links, inquiry-to-episode weaves, session completion) are recorded as awaiting_approval. Nothing runs, publishes or closes until a person decides. After making a request, call show_decisions: it shows the request as a card in the conversation, where the person decides with their own click (or follows its approval page). Never claim a decision the card has not reported. The person may approve, approve with changes (their instructions are carried into what runs), send it back for revision with instructions (approval_state revision_requested; read the instructions with get_run_result and revise it in place with revise_pending_request), or decline.\n- A new or revised run or work proposal answers with draft_review: the aspects of the mission standard to revise, each with why, the question to settle and who can settle it. Read it before show_decisions. It carries no verdict, it advises and blocks nothing, and next_action says what to do. Answer what your conversation holds, ask the person the rest, then revise. preferences lists the person's standing preferences for you to apply. Fill delivery with the one exact place the result lands, and person_words with the person's own words, verbatim, for anything credited to them.\n- A mission is revised, never re-requested: to change a run or work proposal that still awaits a decision, call revise_pending_request with its id and the version you read (expected_version). It keeps one id, one approval page and one card; get_request_history shows every version. A new request_authorized_run or propose_work is for a new mission only. Requests made earlier as separate versions are joined with supersede_pending_requests, naming their exact ids, only when the person names or confirms them.\n- A research report (a Deep Research report) is delivered with save_research exactly as written, never summarised or shortened, with its sources; a long report goes in parts. Check the bytes and first and last lines the answer returns against what you sent.\n- A review's transcript is acquired by ensure_review_transcript, for a review made anywhere. It needs no decision and no pasted text, takes the video's own captions, or transcribes its audio on the Miadi host when the video has none, never overwrites and calls no model service. review_lookup and review_versions carry the transcript's state (unknown, absent, acquiring, stored, held or failed). review_transcript_status follows a job, and every answer carries plain links that work when no card is shown.\n- An unknown id is answered as not found, never invented. A missing backing service is answered as unavailable.\n- Use the miadi-review:<uuid>, miadi-chronicle://<n>, owner/repo#n and session:<uuid> reference forms.";
|
package/dist/server.js
CHANGED
|
@@ -192,6 +192,6 @@ Rules every tool keeps:
|
|
|
192
192
|
- A new or revised run or work proposal answers with draft_review: the aspects of the mission standard to revise, each with why, the question to settle and who can settle it. Read it before show_decisions. It carries no verdict, it advises and blocks nothing, and next_action says what to do. Answer what your conversation holds, ask the person the rest, then revise. preferences lists the person's standing preferences for you to apply. Fill delivery with the one exact place the result lands, and person_words with the person's own words, verbatim, for anything credited to them.
|
|
193
193
|
- A mission is revised, never re-requested: to change a run or work proposal that still awaits a decision, call revise_pending_request with its id and the version you read (expected_version). It keeps one id, one approval page and one card; get_request_history shows every version. A new request_authorized_run or propose_work is for a new mission only. Requests made earlier as separate versions are joined with supersede_pending_requests, naming their exact ids, only when the person names or confirms them.
|
|
194
194
|
- A research report (a Deep Research report) is delivered with save_research exactly as written, never summarised or shortened, with its sources; a long report goes in parts. Check the bytes and first and last lines the answer returns against what you sent.
|
|
195
|
-
- A review's transcript is acquired by ensure_review_transcript, for a review made anywhere. It needs no decision and no pasted text, takes the video's own captions, never overwrites and calls no model. review_lookup and review_versions carry the transcript's state (unknown, absent, acquiring, stored, held or failed). review_transcript_status follows a job, and every answer carries plain links that work when no card is shown.
|
|
195
|
+
- A review's transcript is acquired by ensure_review_transcript, for a review made anywhere. It needs no decision and no pasted text, takes the video's own captions, or transcribes its audio on the Miadi host when the video has none, never overwrites and calls no model service. review_lookup and review_versions carry the transcript's state (unknown, absent, acquiring, stored, held or failed). review_transcript_status follows a job, and every answer carries plain links that work when no card is shown.
|
|
196
196
|
- An unknown id is answered as not found, never invented. A missing backing service is answered as unavailable.
|
|
197
197
|
- Use the miadi-review:<uuid>, miadi-chronicle://<n>, owner/repo#n and session:<uuid> reference forms.`;
|
package/dist/tools.js
CHANGED
|
@@ -16,18 +16,20 @@ import { reviewIdOf, videoIdOf } from "./reviews.js";
|
|
|
16
16
|
import { SCOPE_APPROVE, SCOPE_CONTRIBUTE } from "./oauth.js";
|
|
17
17
|
import { CIRCLES, CIRCLE_IDS, CLAIM_CATEGORIES, DOMAINS, HANDOFF_STATES, current, newRecordId, } from "./records.js";
|
|
18
18
|
import { VERSION } from "./version.js";
|
|
19
|
-
import { AlreadyDecided, DECISIONS, DecisionConflict, KIND_LABELS, ProviderChoiceRequired, STILL_RUNNING, StaleVersion, approvalStateOf, consequenceOf, decide, decisionWaitOf, isApprovable, isBeingDecided, logDecision, readQueueState, transcriptJobIo, requestProjection, settleWithin, } from "./approve.js";
|
|
19
|
+
import { AlreadyDecided, DECISIONS, DecisionConflict, KIND_LABELS, ModelFloorUnmet, ProviderChoiceRequired, STILL_RUNNING, StaleVersion, approvalStateOf, approverRoutingOf, consequenceOf, decide, decisionWaitOf, isApprovable, isBeingDecided, isClaudeRouted, logDecision, readQueueState, transcriptJobIo, requestProjection, settleWithin, } from "./approve.js";
|
|
20
20
|
import { RevisionRefused, requestHistory, revisionRecord, supersedeRecords, versionOf } from "./revisions.js";
|
|
21
21
|
import { coverage } from "./captions.js";
|
|
22
22
|
import { readingRuntimeReport } from "./reading/runtime-report.js";
|
|
23
23
|
import { ensureTranscript, transcriptStatus } from "./transcript-job.js";
|
|
24
24
|
import { DECISIONS_CARD_EARLIER_URIS, DECISIONS_CARD_HTML, DECISIONS_CARD_URI, DECISION_TOKENS_META } from "./decisions.js";
|
|
25
|
-
import { CLAUDE_MODELS, CLAUDE_MODELS_VERIFIED, claudeModelCandidates, claudeModelConfig, firstModelInTranscript, JEV_WITHIN_CLAUDE, MODEL_NAME, modelPlan } from "./claude-models.js";
|
|
25
|
+
import { applyFloor, CLAUDE_MODELS, CLAUDE_MODELS_VERIFIED, claudeModelCandidates, claudeModelConfig, firstModelInTranscript, floorOf, floorRefusal, JEV_WITHIN_CLAUDE, labelsOf, MODEL_NAME, modelPlan, modelsMeetingFloor, } from "./claude-models.js";
|
|
26
26
|
import { discoverProviders, jevConfigOf, resolveProvider, routerPreflight, PROVIDERS } from "./providers.js";
|
|
27
|
+
import { MODEL_ASPECT } from "./mission-standard.js";
|
|
27
28
|
import { authorizesActions, missionStatus, primaryIssueOf, resolveMissionSubject } from "./mission-status.js";
|
|
28
29
|
import { authorizationReceipt, authorizeProvider, CHOICE_PROVIDERS, isPersonId, needsPersonChoice, providerPolicyOf } from "./provider-policy.js";
|
|
29
30
|
import { candidatesFor, CRITICALITIES, jevAdapter, modelPreflight, PREFLIGHT_CONTRACT, PREFLIGHT_VERSION, TASK_TYPES, } from "./model-preflight.js";
|
|
30
31
|
import { ShelfRefusal, listShelfArtefacts, readShelfArtefact } from "./research-shelf.js";
|
|
32
|
+
import { isShareRelation, shareTarget } from "./record-shares.js";
|
|
31
33
|
import { DELIVERY_STATES, readSteerDelivery, revokeInInbox, settlementOf, transcriptPathOf } from "./runtime-steer.js";
|
|
32
34
|
import { ADAPTERS, readFactoryConfig, runSteering, STEERING_CONTRACT_ID, steeringSupport } from "./steering-adapters.js";
|
|
33
35
|
import { checkGrant, isBusy, steerAttempts, steeringGrantOf, steeringRevoked, steerSession } from "./steer.js";
|
|
@@ -51,7 +53,14 @@ async function standardStatus(service) {
|
|
|
51
53
|
version: standard.version,
|
|
52
54
|
source: standard.source,
|
|
53
55
|
...(standard.note ? { note: standard.note } : {}),
|
|
54
|
-
|
|
56
|
+
// S7 is checked in code while the stored standard has none of its own (jgwill/Miadi#1028).
|
|
57
|
+
aspects: [...standard.aspects, ...(standard.aspects.some((a) => a.code === MODEL_ASPECT.code) ? [] : [{ ...MODEL_ASPECT, checked_in: "code" }])].map((a) => ({
|
|
58
|
+
code: a.code,
|
|
59
|
+
name: a.name,
|
|
60
|
+
requires: a.requires,
|
|
61
|
+
settled_by: a.settled_by,
|
|
62
|
+
...("checked_in" in a ? { checked_in: a.checked_in } : {}),
|
|
63
|
+
})),
|
|
55
64
|
jev: service.jevConfigured ? "configured" : "unconfigured",
|
|
56
65
|
};
|
|
57
66
|
}
|
|
@@ -220,8 +229,16 @@ const launchModelFields = {
|
|
|
220
229
|
.regex(MODEL_NAME)
|
|
221
230
|
.optional()
|
|
222
231
|
.describe("The Claude Code model to launch on. Name it only when the person asked for that model; leave it out and Jev chooses among the permitted Claude Code models when it is approved. A model on a mission that runs on any other provider is refused."),
|
|
223
|
-
task_type: z
|
|
224
|
-
|
|
232
|
+
task_type: z
|
|
233
|
+
.enum(TASK_TYPES)
|
|
234
|
+
.optional()
|
|
235
|
+
.describe("The kind of task, which with criticality is all Jev learns of it when it chooses the model. Set it: left out, the task is labelled implementation, which the fit notes give to Sonnet, and the draft review and the approval page say the label was a default."),
|
|
236
|
+
criticality: z.enum(CRITICALITIES).optional().describe("Left out, normal, and the approval page says it was a default."),
|
|
237
|
+
model_floor: z
|
|
238
|
+
.string()
|
|
239
|
+
.regex(MODEL_NAME)
|
|
240
|
+
.optional()
|
|
241
|
+
.describe("The weakest Claude Code model this mission may run on (opus, sonnet, haiku or fable), when the person's words set a floor such as \"needs a high-reasoning model\" or \"at least opus\". Jev then chooses only among permitted models at or above it, and reads no words. When no permitted model meets it, approving is refused and the approval page says so before the click."),
|
|
225
242
|
};
|
|
226
243
|
export function registerTools(server, ctx) {
|
|
227
244
|
const { config, miadi, reviews, ledger } = ctx;
|
|
@@ -381,6 +398,19 @@ export function registerTools(server, ctx) {
|
|
|
381
398
|
const receipts = () => readFactoryReceipts(factoryLedgerPath(ctx.factoryDir ?? defaultFactoryDir()));
|
|
382
399
|
/** The Claude Code models this host permits, and the one it falls back to (jgwill/Miadi#943). */
|
|
383
400
|
const modelConfig = () => claudeModelConfig(ctx.factoryDir ?? defaultFactoryDir(), ctx.modelOf);
|
|
401
|
+
/** What the card offers a person approving with changes, and what the mission is chosen from now (jgwill/Miadi#1029). */
|
|
402
|
+
const modelChoiceOf = (r) => {
|
|
403
|
+
const b = r.body;
|
|
404
|
+
const config = modelConfig();
|
|
405
|
+
const t = labelsOf(b);
|
|
406
|
+
const floor = floorOf(b);
|
|
407
|
+
const named = typeof b.model === "string" && b.model ? b.model : null;
|
|
408
|
+
return {
|
|
409
|
+
permitted: config.permitted,
|
|
410
|
+
...(named ? { requested_model: named } : { task_types: TASK_TYPES, criticalities: CRITICALITIES, labels: { task_type: { value: t.type, set_by: t.labels.task_type }, criticality: { value: t.criticality, set_by: t.labels.criticality } } }),
|
|
411
|
+
...(floor ? { floor, met_by: modelsMeetingFloor(config, floor) } : {}),
|
|
412
|
+
};
|
|
413
|
+
};
|
|
384
414
|
/** The body mark of a request whose model Jev chooses, when it runs on Claude Code. */
|
|
385
415
|
const routedOn = (provider) => (provider === "claude" ? { model_routing: JEV_WITHIN_CLAUDE } : {});
|
|
386
416
|
const factoryConfig = () => readFactoryConfig(ctx.factoryDir ?? defaultFactoryDir());
|
|
@@ -428,7 +458,7 @@ export function registerTools(server, ctx) {
|
|
|
428
458
|
follow: "review_transcript_status",
|
|
429
459
|
status_page: `${config.publicUrl}/transcripts/<review id>`,
|
|
430
460
|
captions: ctx.approval?.captions ? "on (the video's spoken-language track)" : "off",
|
|
431
|
-
local_transcription: ctx.approval?.localTranscription ? "on (a
|
|
461
|
+
local_transcription: ctx.approval?.localTranscription ? "on (a video with no captions is transcribed from its audio on this host, never a withheld source)" : "off (the operator enables it with MIADI_TRANSCRIPT_LOCAL=faster-whisper)",
|
|
432
462
|
review_service_token: reviews.canSearch ? "present" : "absent",
|
|
433
463
|
decision_required: false,
|
|
434
464
|
independent_of_public_import: true,
|
|
@@ -940,7 +970,7 @@ export function registerTools(server, ctx) {
|
|
|
940
970
|
}));
|
|
941
971
|
server.registerTool("ensure_review_transcript", {
|
|
942
972
|
title: "Make sure a review holds its video's transcript",
|
|
943
|
-
description: "For an existing review made anywhere (the review service's own page, a manual edit, another client), acquire its video's transcript, store it on the review and read it back. It runs now under the authority that already covers processing a review: no transcript decision is asked, and nothing needs pasting. A transcript the review already holds is reused and kept. It takes the video's spoken-language YouTube captions,
|
|
973
|
+
description: "For an existing review made anywhere (the review service's own page, a manual edit, another client), acquire its video's transcript, store it on the review and read it back. It runs now under the authority that already covers processing a review: no transcript decision is asked, and nothing needs pasting. A transcript the review already holds is reused and kept. It takes the video's spoken-language YouTube captions and, when the video has none, transcribes its audio on the Miadi host where the operator enabled that. It calls no model service. A source registered as withheld is held until released. It never overwrites, never creates a version and never publishes. It answers within about 20 seconds with the job's progress, a plain summary and links, and the job goes on if it needs longer: follow it with review_transcript_status or the status link. Asking again is safe; it joins the running attempt. Needs a person who may contribute and who holds the write tier or registered the video's source.",
|
|
944
974
|
inputSchema: { review: z.string().min(1).describe("Review id, miadi-review:<uuid>, review URL, or the video's YouTube URL or id (when exactly one review of it exists)."), intention: z.string().max(2000).optional().describe("Why the transcript is needed, recorded with the job.") },
|
|
945
975
|
annotations: { readOnlyHint: false, destructiveHint: false, idempotentHint: true, openWorldHint: true },
|
|
946
976
|
}, wrap(async (a, extra) => {
|
|
@@ -1182,8 +1212,8 @@ export function registerTools(server, ctx) {
|
|
|
1182
1212
|
description: "A typed, versioned, read-only preflight for one mission (jgwill/Miadi#913): the candidate providers with their concrete model when the host shows one (one candidate per permitted Claude Code model), sign-in evidence (config directory only), quota unknown, policy eligibility (the approved provider is kept; only Claude Code runs unnamed), a review floor, and a recommendation or an abstention with its reasons. It says where the choice came from: static_fallback, jev or a synthetic fixture. Jev is asked only with consult_jev and a Jev key in the connector's environment; that call is charged, and it carries no task text, mission id or repository name. A reported launch on another provider than the approved one fails closed as provider_mismatch. It authorizes nothing. Needs Miadi's write tier.",
|
|
1183
1213
|
inputSchema: {
|
|
1184
1214
|
ref: z.string().min(1).describe("The mission: run_request:<id> or work_proposal:<id> (an issue or session ref resolves only through its primary relation)."),
|
|
1185
|
-
task_type: z.enum(TASK_TYPES),
|
|
1186
|
-
criticality: z.enum(CRITICALITIES).
|
|
1215
|
+
task_type: z.enum(TASK_TYPES).optional().describe("Left out, the mission's own: the approver's when they set one, else the requester's, else the default a launch uses. labels says which (jgwill/Miadi#1028)."),
|
|
1216
|
+
criticality: z.enum(CRITICALITIES).optional().describe("Left out, the mission's own, as task_type."),
|
|
1187
1217
|
consult_jev: z.boolean().default(false).describe("Ask Jev to choose among the eligible options. Charged by Jev; off by default."),
|
|
1188
1218
|
launch: z
|
|
1189
1219
|
.object({
|
|
@@ -1218,12 +1248,16 @@ export function registerTools(server, ctx) {
|
|
|
1218
1248
|
const listed = candidatesFor(onHost, provider, ctx.modelOf, basis, authorization);
|
|
1219
1249
|
const claudeRow = listed.find((c) => c.provider === "claude");
|
|
1220
1250
|
// The same options a launch offers Jev, so a consult here is a dry run of it (jgwill/Miadi#943).
|
|
1221
|
-
|
|
1251
|
+
// The mission's own floor narrows the Claude Code options as it does at launch (jgwill/Miadi#1028).
|
|
1252
|
+
const candidates = claudeRow?.installed ? [...applyFloor(claudeModelCandidates(onHost, modelConfig(), claudeRow), floorOf(body)), ...listed.filter((c) => c.provider !== "claude")] : listed;
|
|
1253
|
+
// The labels a launch reads, unless the caller names its own: the approver's fields, else the requester's, else the default.
|
|
1254
|
+
const changes = record.completion_receipt?.routing_changes;
|
|
1255
|
+
const own = labelsOf(body, changes);
|
|
1222
1256
|
const jevConfig = jevConfigOf(process.env);
|
|
1223
1257
|
const jev = a.consult_jev ? (ctx.jevAdapter ?? (jevConfig ? jevAdapter(jevConfig, ctx.approval?.fetchImpl ?? fetch) : undefined)) : undefined;
|
|
1224
1258
|
const configured = Boolean(jevConfig);
|
|
1225
1259
|
const primary = primaryIssueOf(record);
|
|
1226
|
-
|
|
1260
|
+
const answer = await modelPreflight({
|
|
1227
1261
|
mission: {
|
|
1228
1262
|
id: record.id,
|
|
1229
1263
|
resolution: found.resolution,
|
|
@@ -1232,13 +1266,14 @@ export function registerTools(server, ctx) {
|
|
|
1232
1266
|
},
|
|
1233
1267
|
approved_provider: provider,
|
|
1234
1268
|
provider_basis: basis,
|
|
1235
|
-
task: a.task_type,
|
|
1236
|
-
criticality: a.criticality,
|
|
1269
|
+
task: a.task_type ?? own.type,
|
|
1270
|
+
criticality: a.criticality ?? own.criticality,
|
|
1237
1271
|
candidates,
|
|
1238
1272
|
...(authorization ? { provider_authorization: authorizationOut(authorization) } : {}),
|
|
1239
1273
|
...(a.launch ? { launch: a.launch } : {}),
|
|
1240
1274
|
...(jev ? { adapter: jev } : { routerWhenAbsent: configured ? "not_requested" : "router_unconfigured" }),
|
|
1241
1275
|
});
|
|
1276
|
+
return { ...answer, labels: { task_type: a.task_type ? "caller" : own.labels.task_type, criticality: a.criticality ? "caller" : own.labels.criticality } };
|
|
1242
1277
|
}));
|
|
1243
1278
|
// search / fetch: the pair ChatGPT uses for connectors in search and deep research.
|
|
1244
1279
|
server.registerTool("search", {
|
|
@@ -1366,12 +1401,22 @@ export function registerTools(server, ctx) {
|
|
|
1366
1401
|
}));
|
|
1367
1402
|
server.registerTool("link_records", {
|
|
1368
1403
|
title: "Relate two references",
|
|
1369
|
-
description: "Record a relation between two references (a review and an episode, a session and an issue, a beat and a source), with the relation's name and why."
|
|
1404
|
+
description: "Record a relation between two references (a review and an episode, a session and an issue, a beat and a source), with the relation's name and why. " +
|
|
1405
|
+
"To share a record you made (an inquiry, a handoff, a proposal) with a talking circle or one person, link from the record's id to miadi-circle:<circle id> or the person's id with the relation shared_with: its members, or that person, then read it on the record's page and in My Research. The relation share_withdrawn, from the same record to the same reader, ends the share. Only a record's author shares it.",
|
|
1370
1406
|
inputSchema: { from: z.string().min(1), to: z.string().min(1), relation: z.string().min(1).max(80), note: z.string().max(2000).optional(), ...base },
|
|
1371
1407
|
annotations: WRITE,
|
|
1372
1408
|
}, wrap(async (a, extra) => {
|
|
1373
1409
|
const { person, auth } = who(extra);
|
|
1374
1410
|
requireContribute(auth);
|
|
1411
|
+
if (isShareRelation(a.relation)) {
|
|
1412
|
+
const shared = all().find((r) => r.id === a.from);
|
|
1413
|
+
if (!shared)
|
|
1414
|
+
throw new ToolRefusal("not_found", `No record with the id ${a.from}: a share links from a record's id.`);
|
|
1415
|
+
if (shared.actor.person_id !== person.id)
|
|
1416
|
+
throw new ToolRefusal("forbidden", "Only a record's author shares it, or withdraws a share; this record was made by someone else.");
|
|
1417
|
+
if (!shareTarget(a.to))
|
|
1418
|
+
throw new ToolRefusal("invalid_ref", "A share reaches a talking circle (miadi-circle:<circle id>) or one person (their node id).");
|
|
1419
|
+
}
|
|
1375
1420
|
return append("link", person, auth, {
|
|
1376
1421
|
refs: [a.from, a.to],
|
|
1377
1422
|
intention: a.intention,
|
|
@@ -1571,7 +1616,7 @@ export function registerTools(server, ctx) {
|
|
|
1571
1616
|
const resolution = resolveProvider(undefined, discoverProviders(ctx.providersProbe), policyOf(person.id).default_provider);
|
|
1572
1617
|
if (resolution.state !== "ok")
|
|
1573
1618
|
return { state: resolution.state, message: resolution.message, available: resolution.available, note: "Nothing was recorded; the proposal is unstarted." };
|
|
1574
|
-
const plan = modelPlan(resolution.provider.id, a.model, modelConfig().permitted);
|
|
1619
|
+
const plan = modelPlan(resolution.provider.id, a.model, modelConfig().permitted, a.model_floor);
|
|
1575
1620
|
if ("refusal" in plan)
|
|
1576
1621
|
throw new ToolRefusal(plan.refusal.code, plan.refusal.message, { permitted: plan.refusal.permitted });
|
|
1577
1622
|
const capabilities = a.capabilities?.length ? declareCapabilities(a.capabilities) : undefined;
|
|
@@ -1840,7 +1885,7 @@ export function registerTools(server, ctx) {
|
|
|
1840
1885
|
if (resolution.state !== "ok") {
|
|
1841
1886
|
return { state: resolution.state, message: resolution.message, available: resolution.available, note: "Nothing was recorded or queued; the mission is unstarted." };
|
|
1842
1887
|
}
|
|
1843
|
-
const plan = modelPlan(resolution.provider.id, a.model, modelConfig().permitted);
|
|
1888
|
+
const plan = modelPlan(resolution.provider.id, a.model, modelConfig().permitted, a.model_floor);
|
|
1844
1889
|
if ("refusal" in plan)
|
|
1845
1890
|
throw new ToolRefusal(plan.refusal.code, plan.refusal.message, { permitted: plan.refusal.permitted });
|
|
1846
1891
|
const capabilities = a.capabilities?.length ? declareCapabilities(a.capabilities) : undefined;
|
|
@@ -1882,7 +1927,9 @@ export function registerTools(server, ctx) {
|
|
|
1882
1927
|
// Known before anyone depends on it: whether a person can steer this run once it works (jgwill/Miadi#942).
|
|
1883
1928
|
steering: steeringOf(resolution.provider.id, resolution.provider.version),
|
|
1884
1929
|
},
|
|
1885
|
-
...(resolution.provider.id === "claude"
|
|
1930
|
+
...(resolution.provider.id === "claude"
|
|
1931
|
+
? { model: { requested: a.model ?? null, chosen_by: a.model ? "request" : "jev_when_approved", permitted: modelConfig().permitted, ...(a.model_floor ? { floor: a.model_floor, met_by: modelsMeetingFloor(modelConfig(), a.model_floor) } : {}) } }
|
|
1932
|
+
: {}),
|
|
1886
1933
|
approval_url: approvalUrl(r.id),
|
|
1887
1934
|
...(authorization.authorized
|
|
1888
1935
|
? {}
|
|
@@ -1928,6 +1975,7 @@ export function registerTools(server, ctx) {
|
|
|
1928
1975
|
cwd: z.string().max(300).optional(),
|
|
1929
1976
|
provider: z.enum(["codex", "pi", "copilot", "claude"]).optional().describe("Verified installed on the connector host again, as request_authorized_run does."),
|
|
1930
1977
|
model: z.string().regex(MODEL_NAME).nullable().optional().describe("The Claude Code model, as request_authorized_run takes it. null removes a model named earlier, so Jev chooses."),
|
|
1978
|
+
model_floor: z.string().regex(MODEL_NAME).nullable().optional().describe("The weakest Claude Code model the mission may run on, as request_authorized_run takes it. null removes it."),
|
|
1931
1979
|
task_type: z.enum(TASK_TYPES).optional(),
|
|
1932
1980
|
criticality: z.enum(CRITICALITIES).optional(),
|
|
1933
1981
|
steering: z
|
|
@@ -1979,12 +2027,14 @@ export function registerTools(server, ctx) {
|
|
|
1979
2027
|
for (const k of ["task_type", "criticality"])
|
|
1980
2028
|
if (c[k] !== undefined)
|
|
1981
2029
|
body[k] = c[k];
|
|
1982
|
-
if (c.model !== undefined || c.provider !== undefined) {
|
|
1983
|
-
const
|
|
2030
|
+
if (c.model !== undefined || c.provider !== undefined || c.model_floor !== undefined) {
|
|
2031
|
+
const floor = c.model_floor === undefined ? body.model_floor : c.model_floor;
|
|
2032
|
+
const plan = modelPlan((body.resolved_provider ?? body.provider ?? null), c.model === undefined ? body.model : c.model, modelConfig().permitted, floor);
|
|
1984
2033
|
if ("refusal" in plan)
|
|
1985
2034
|
throw new ToolRefusal(plan.refusal.code, plan.refusal.message, { permitted: plan.refusal.permitted, ...(live ? revisionOut(live) : {}) });
|
|
1986
2035
|
delete body.model;
|
|
1987
2036
|
delete body.model_routing;
|
|
2037
|
+
delete body.model_floor;
|
|
1988
2038
|
Object.assign(body, plan.fields);
|
|
1989
2039
|
}
|
|
1990
2040
|
}
|
|
@@ -2710,7 +2760,7 @@ export function registerTools(server, ctx) {
|
|
|
2710
2760
|
created_at: r.created_at,
|
|
2711
2761
|
circle: r.circle,
|
|
2712
2762
|
intention: r.intention,
|
|
2713
|
-
consequence: consequenceOf(r, providerAuthorizationOf(r), records(), runProvider(r) ? steeringOfCard(runProvider(r)) : undefined),
|
|
2763
|
+
consequence: consequenceOf(r, providerAuthorizationOf(r), records(), runProvider(r) ? steeringOfCard(runProvider(r)) : undefined, Boolean(floorRefusal(r, undefined, modelConfig()))),
|
|
2714
2764
|
detail: detailOf(r),
|
|
2715
2765
|
...(r.kind === "run_request" || r.kind === "work_proposal"
|
|
2716
2766
|
? {
|
|
@@ -2719,6 +2769,7 @@ export function registerTools(server, ctx) {
|
|
|
2719
2769
|
draft_review: ctx.draftReview?.stored(r) ?? null,
|
|
2720
2770
|
}
|
|
2721
2771
|
: {}),
|
|
2772
|
+
...(isClaudeRouted(r) ? { model_choice: modelChoiceOf(r) } : {}),
|
|
2722
2773
|
...(r.kind === "run_request" ? { provider_authorization: authorizationOut(providerAuthorizationOf(r)) } : {}),
|
|
2723
2774
|
approval_url: approvalUrl(r.id),
|
|
2724
2775
|
projection: requestProjection(r, { reviewBase: ctx.approval?.config.reviewUrl, factoryDir: ctx.factoryDir }),
|
|
@@ -2754,6 +2805,9 @@ export function registerTools(server, ctx) {
|
|
|
2754
2805
|
record_id: z.string().min(1),
|
|
2755
2806
|
decision: z.enum(DECISIONS),
|
|
2756
2807
|
instructions: z.string().max(20000).optional(),
|
|
2808
|
+
model: z.string().max(80).optional().describe("Approve with my changes: the Claude Code model this mission runs on, from the permitted list. It wins over the request's model and over Jev."),
|
|
2809
|
+
task_type: z.enum(TASK_TYPES).optional().describe("Approve with my changes: the task type Jev chooses the model from, in place of the request's."),
|
|
2810
|
+
criticality: z.enum(CRITICALITIES).optional().describe("Approve with my changes: the criticality Jev chooses the model from, in place of the request's."),
|
|
2757
2811
|
decision_token: z.string().min(10).max(200),
|
|
2758
2812
|
},
|
|
2759
2813
|
annotations: { readOnlyHint: false, destructiveHint: false, openWorldHint: true },
|
|
@@ -2788,14 +2842,21 @@ export function registerTools(server, ctx) {
|
|
|
2788
2842
|
if (check !== "ok")
|
|
2789
2843
|
throw new ToolRefusal("invalid_token", "This decision did not come from the person's card.");
|
|
2790
2844
|
const instructions = a.instructions?.trim() || undefined;
|
|
2791
|
-
|
|
2792
|
-
|
|
2845
|
+
// The model fields take part in the choice, checked as the approval page checks them (jgwill/Miadi#1029).
|
|
2846
|
+
const fields = approverRoutingOf(r, { model: a.model, task_type: a.task_type, criticality: a.criticality }, modelConfig().permitted);
|
|
2847
|
+
if ("refusal" in fields)
|
|
2848
|
+
throw new ToolRefusal(fields.refusal.code, fields.refusal.message, fields.refusal.permitted ? { permitted: fields.refusal.permitted } : undefined);
|
|
2849
|
+
if (fields.routing && a.decision !== "approve_with_changes")
|
|
2850
|
+
throw new ToolRefusal("fields_need_changes", "A model field changes the request: decide it with approve_with_changes.");
|
|
2851
|
+
const routing = fields.routing;
|
|
2852
|
+
if (r.approval_state === "awaiting_approval" && !isBeingDecided(r.id) && ((a.decision === "approve_with_changes" && !routing) || a.decision === "request_revision") && !instructions) {
|
|
2853
|
+
throw new ToolRefusal("instructions_required", a.decision === "request_revision" ? "Say what to revise." : "Write the changes to apply, or set a model field.");
|
|
2793
2854
|
}
|
|
2794
2855
|
const client = ctx.oauthState.read().clients[auth.clientId];
|
|
2795
2856
|
const via = `card:${String(client?.client_name ?? auth.clientId).slice(0, 50)}`;
|
|
2796
2857
|
let decided;
|
|
2797
2858
|
try {
|
|
2798
|
-
const running = decide(r, person, a.decision, ctx.approval, { instructions, via, expectedVersion: versionOf(r) });
|
|
2859
|
+
const running = decide(r, person, a.decision, ctx.approval, { instructions, ...(routing ? { routing } : {}), via, expectedVersion: versionOf(r) });
|
|
2799
2860
|
// A host gives up on a call after about a minute and may send it again; a review create can take longer.
|
|
2800
2861
|
// Past the bound the answer is the decision, recorded and running, and the card follows it to its outcome (#924).
|
|
2801
2862
|
const settled = await settleWithin(running, decisionWaitOf(ctx.approval));
|
|
@@ -2825,6 +2886,8 @@ export function registerTools(server, ctx) {
|
|
|
2825
2886
|
}
|
|
2826
2887
|
if (error instanceof StaleVersion)
|
|
2827
2888
|
throw new ToolRefusal("stale_version", error.message, { projection: projectionNow(), approval_url: approvalUrl(r.id) });
|
|
2889
|
+
if (error instanceof ModelFloorUnmet)
|
|
2890
|
+
throw new ToolRefusal("model_floor_unmet", error.message, { approval_url: approvalUrl(r.id) });
|
|
2828
2891
|
// A different decision recorded a moment earlier, by another click or client, is reported with where it stands.
|
|
2829
2892
|
if (error instanceof DecisionConflict)
|
|
2830
2893
|
throw new ToolRefusal("decision_conflict", error.message, { projection: projectionNow() });
|
package/dist/transcript-job.d.ts
CHANGED
|
@@ -50,6 +50,10 @@ export interface TranscriptJobReceipt {
|
|
|
50
50
|
stored_at?: string;
|
|
51
51
|
readback?: Readback;
|
|
52
52
|
failure?: JobFailure;
|
|
53
|
+
/** The approved mission a worker later ran this job under (missionAuthority), recorded with the job it joined. */
|
|
54
|
+
authority?: Record<string, unknown>;
|
|
55
|
+
/** How many times this window ran the host's transcription of the audio. */
|
|
56
|
+
local_attempts?: number;
|
|
53
57
|
stages: JobStage[];
|
|
54
58
|
}
|
|
55
59
|
export interface ServiceAnswer {
|
|
@@ -95,7 +99,7 @@ export interface TranscriptJobIo {
|
|
|
95
99
|
service: ReviewTranscriptService;
|
|
96
100
|
/** The video's spoken-language captions. */
|
|
97
101
|
captions?: FetchCaptions;
|
|
98
|
-
/** A transcription made on this host, tried when captions
|
|
102
|
+
/** A transcription of the video's audio made on this host, tried when the video has no captions. Never for a withheld source. */
|
|
99
103
|
local?: FetchCaptions;
|
|
100
104
|
now?: () => number;
|
|
101
105
|
log?: (event: Record<string, unknown>) => void;
|
|
@@ -109,6 +113,8 @@ export interface TranscriptJobIo {
|
|
|
109
113
|
/** Told once each time a job reaches an ending (stored, held, failed), to announce it as a fact. Never fails the job. */
|
|
110
114
|
outcome?: (job: ConnectorRecord, receipt: TranscriptJobReceipt) => void | Promise<unknown>;
|
|
111
115
|
}
|
|
116
|
+
/** How many times one window runs this host's transcription of the audio before the job fails with what it last answered. */
|
|
117
|
+
export declare const MAX_LOCAL_ATTEMPTS = 3;
|
|
112
118
|
/** How long an attempt this process does not run may go without writing a stage before it counts as abandoned. */
|
|
113
119
|
export declare const STALE_MS: number;
|
|
114
120
|
export declare const jobKey: (reviewId: string) => string;
|