@miadi/connector 0.1.44 → 0.1.45
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 +21 -1
- package/dist/client-tools.d.ts +119 -0
- package/dist/client-tools.js +196 -0
- package/dist/server.d.ts +3 -2
- package/dist/server.js +23 -2
- package/dist/store.d.ts +1 -0
- package/dist/store.js +4 -0
- package/dist/tools.d.ts +10 -1
- package/dist/tools.js +19 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -91,6 +91,25 @@ The Review Service itself stores no source relation, and the registry has no rel
|
|
|
91
91
|
A step that asks for a review when a screenwalk is registered would call `request_screenwalk_review` from Miadi's registry door, after the registration lands, with the registrant's token (`lib/connector-tool.ts` `callConnectorTool`). That step is not built.
|
|
92
92
|
|
|
93
93
|
|
|
94
|
+
### When a client's tool list is older than the connector
|
|
95
|
+
|
|
96
|
+
A client keeps the tool list it fetched. ChatGPT keeps it until a person refreshes the app, and a terminal client keeps it until it reconnects. After a release, `get_capabilities` names tools such a client cannot call yet. The connector says so itself (jgwill/Miadi#1180).
|
|
97
|
+
|
|
98
|
+
**What is recorded.** At each `tools/list`, the connector writes the version that answered and the tool names it carried to `<state dir>/client-tools.json`. The record is kept per OAuth client id. A client with no client id (a person token used directly) is given an `Mcp-Session-Id` at `initialize` and its record is kept under that id, and the endpoint keeps no session for it. Each record also counts the lists answered and the tool calls made since the last one. The file holds client ids, session ids, versions, tool names, counts and times, and no token or person. Sessions idle for 30 days leave it, and at most 300 are kept.
|
|
99
|
+
|
|
100
|
+
**What `get_capabilities` answers.** When the client's last list is this version's, nothing more. Otherwise a `client_tools` block, before the `tools` map:
|
|
101
|
+
|
|
102
|
+
| the client's last list | `state` | `list_fetched_at_version` | `missing_from_your_list` | the `tools` map |
|
|
103
|
+
|---|---|---|---|---|
|
|
104
|
+
| from another version | `list_older_than_this_version` | that version | the names this version offers that the list lacks, which can be none | each missing tool says "not in your client's tool list" before its status |
|
|
105
|
+
| not recorded | `list_not_recorded` | `unknown` | `unknown`, with `added_by_version`: the tools each recent version added | as it is |
|
|
106
|
+
|
|
107
|
+
The block also carries `refresh`, one sentence for a person (for ChatGPT: Settings, Apps, this app, Refresh), and `until_refresh`: for a tool the list lacks, an older tool that reaches part of the same matter, with what it does and does not do. Today these are `get_context` with a `miadi-screenwalk:<id>` ref in place of `get_screenwalk`, and `review_lookup` in place of `request_screenwalk_review`. The block says what the server offers and what the recorded list holds. It never says that a client can call a tool.
|
|
108
|
+
|
|
109
|
+
A request with neither a client id nor a session id (one bare call from a script) has no record, so it is answered `list_not_recorded` each time.
|
|
110
|
+
|
|
111
|
+
**At a release that adds a tool.** Give the tool an entry in `TOOL_ADDED` (`src/client-tools.ts`) with the version that adds it, and a `meanwhile` when an older tool reaches part of it. `test/client-tools.test.mjs` fails until the entry exists. After the deploy, `client-tools.json` says which clients have fetched the new list and which still call tools from an older one.
|
|
112
|
+
|
|
94
113
|
### Revising a mission before it is decided
|
|
95
114
|
|
|
96
115
|
A mission is revised, never re-requested. `revise_pending_request` changes an agent run or work proposal that still awaits a decision, or that its approver sent back, and gives it its next version. Pass the version you read as `expected_version` and only the fields that change. The request keeps its id, its approval page and its one card. A change of `provider` is verified on the host again. Each revision is a record in the ledger carrying the whole new content, its reason, author, changed fields and `sha256` content hash, so every earlier version stays readable verbatim with `get_request_history`. A request already approved, queued or declined is refused: a change after a decision is a new request or a steer.
|
|
@@ -254,7 +273,7 @@ A service reads the same file with `EnvironmentFile=-/etc/miadi/miadi.env`, and
|
|
|
254
273
|
| `MIADI_CONNECTOR_PORT` / `MIADI_CONNECTOR_HOST` | `3337` / `127.0.0.1` | where it listens |
|
|
255
274
|
| `MIADI_CONNECTOR_MIADI_URL` | `http://127.0.0.1:3335` | the Miadi app it calls, as the person |
|
|
256
275
|
| `MIADI_PUBLIC_URL` | `MIADI_URL_BASE`, else `MIADI_CONNECTOR_MIADI_URL` | the Miadi app's address in the links people open from an answer (`/chronicle/…`, `/research`) |
|
|
257
|
-
| `MIADI_CONNECTOR_STATE_DIR` | `/srv/miadi/connector` | `oauth.json` (token digests, clients)
|
|
276
|
+
| `MIADI_CONNECTOR_STATE_DIR` | `/srv/miadi/connector` | `oauth.json` (token digests, clients), `ledger.jsonl` (records) and `client-tools.json` (the tool list each client last fetched), mode 0700 |
|
|
258
277
|
| `MIADI_REVIEW_BASE_URL` | `https://miadi-review-service.vercel.app` | the review service |
|
|
259
278
|
| `MIADI_REVIEW_TOKEN` | read from `~/.env` | review search and approved review operations |
|
|
260
279
|
| `MIADI_FACTORY_DIR` | `~/.miadi/factory` | the queue approved runs are written to |
|
|
@@ -307,6 +326,7 @@ The issues and the episode behind each part. `jgwill/Miadi` is a private reposit
|
|
|
307
326
|
| the tests the standard's bars were read from | Episode 564 (miadi-chronicle://564), `mission-draft-review-261105/` |
|
|
308
327
|
| the factory's review pages | jgwill/Miadi#961 |
|
|
309
328
|
| registered screenwalks read through the registry door, and the step to their review | jgwill/Miadi#1180 (the registry's identity: jgwill/Miadi#1112) |
|
|
329
|
+
| the tool list each client last fetched, and `client_tools` in `get_capabilities` | jgwill/Miadi#1180 |
|
|
310
330
|
| what a published README holds | jgwill/Miadi#685 |
|
|
311
331
|
|
|
312
332
|
On the factory host (gaia) the connector runs as the user service `miadi-connector.service`, installed from the Miadi repository's `scripts/ops/etc/miadi-connector.user.service`. That host's `/etc/miadi/miadi.env` sets `MIADI_CONNECTOR_PUBLIC_URL`, and the Cloudflare tunnel `gaia` serves that address from the loopback port. Its reading runtime is `packages/connector/scripts/host-reading-runtime.mjs`.
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The tool list each client last fetched (jgwill/Miadi#1180).
|
|
3
|
+
*
|
|
4
|
+
* A client keeps the tool list it fetched: ChatGPT until a person refreshes the app, a terminal client until it
|
|
5
|
+
* reconnects. After a release, get_capabilities names tools such a client cannot call, and the client reads that as
|
|
6
|
+
* the server announcing what it does not offer. So the connector keeps, for each OAuth client and for each session
|
|
7
|
+
* of a client that has no client id, the connector version and the tool names of its last tools/list, and
|
|
8
|
+
* get_capabilities says when that list is older than the running connector.
|
|
9
|
+
*
|
|
10
|
+
* Kept in the state directory as client-tools.json: OAuth client ids, session ids the connector gave, versions, tool
|
|
11
|
+
* names, counts and times. No token and no person.
|
|
12
|
+
*/
|
|
13
|
+
import type { JsonFile } from "./store.js";
|
|
14
|
+
export interface ClientList {
|
|
15
|
+
/** The connector version that answered the list. */
|
|
16
|
+
version: string;
|
|
17
|
+
at: string;
|
|
18
|
+
tools: string[];
|
|
19
|
+
}
|
|
20
|
+
export interface ClientEntry {
|
|
21
|
+
/** The last tools/list this client was answered. Null: it called tools and never fetched the list since recording began. */
|
|
22
|
+
list: ClientList | null;
|
|
23
|
+
/** How many tools/list it was answered since recording began. */
|
|
24
|
+
lists: number;
|
|
25
|
+
/** Tool calls since that list, or since recording began when there is none. */
|
|
26
|
+
calls_since_list: number;
|
|
27
|
+
last_call: {
|
|
28
|
+
at: string;
|
|
29
|
+
version: string;
|
|
30
|
+
} | null;
|
|
31
|
+
seen_at: string;
|
|
32
|
+
}
|
|
33
|
+
export interface ClientToolsState {
|
|
34
|
+
/** The first version that recorded lists on this host, and when. */
|
|
35
|
+
recording_since: {
|
|
36
|
+
version: string;
|
|
37
|
+
at: string;
|
|
38
|
+
} | null;
|
|
39
|
+
clients: Record<string, ClientEntry>;
|
|
40
|
+
sessions: Record<string, ClientEntry>;
|
|
41
|
+
}
|
|
42
|
+
export declare const emptyClientTools: () => ClientToolsState;
|
|
43
|
+
export type ClientKey = {
|
|
44
|
+
kind: "client" | "session";
|
|
45
|
+
id: string;
|
|
46
|
+
};
|
|
47
|
+
/** The version that began recording lists: a client with no record fetched its list before it, or never. */
|
|
48
|
+
export declare const RECORDING_SINCE = "0.1.45";
|
|
49
|
+
/** Under which key a request's list is kept: its OAuth client, else the session id it was given at initialize. */
|
|
50
|
+
export declare function clientKeyOf(clientId: string | undefined, sessionId: string | undefined): ClientKey | null;
|
|
51
|
+
/** Does this request come from a client with no client id, which is given a session id at initialize? */
|
|
52
|
+
export declare const needsSession: (clientId: string | undefined) => boolean;
|
|
53
|
+
export declare class ClientLists {
|
|
54
|
+
private readonly file;
|
|
55
|
+
private readonly warn;
|
|
56
|
+
constructor(file: JsonFile<ClientToolsState>, warn?: (message: string) => void);
|
|
57
|
+
/** What is kept for this key. A state file that cannot be read is no record, never a failed request. */
|
|
58
|
+
read(key: ClientKey | null): ClientEntry | null;
|
|
59
|
+
/** A tools/list was answered: the version and the names it carried. */
|
|
60
|
+
listed(key: ClientKey | null, version: string, tools: string[], at?: string): void;
|
|
61
|
+
/** A tool was called. */
|
|
62
|
+
called(key: ClientKey | null, version: string, at?: string): void;
|
|
63
|
+
private change;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* The tools added since lists are compared, each with the version that added it. A client whose list is not recorded
|
|
67
|
+
* is told these by version, because nothing else says what its list may lack. `meanwhile` names a tool that existed
|
|
68
|
+
* before and reaches part of the same thing, with what it does and does not do.
|
|
69
|
+
*
|
|
70
|
+
* A tool added in a later release gets its entry here: test/client-tools.test.mjs fails until it has one.
|
|
71
|
+
*/
|
|
72
|
+
export declare const TOOL_ADDED: Record<string, {
|
|
73
|
+
since: string;
|
|
74
|
+
meanwhile?: {
|
|
75
|
+
tool: string;
|
|
76
|
+
how: string;
|
|
77
|
+
};
|
|
78
|
+
}>;
|
|
79
|
+
export interface ClientToolsBlock {
|
|
80
|
+
state: "list_older_than_this_version" | "list_not_recorded";
|
|
81
|
+
this_version: string;
|
|
82
|
+
/** The version the client's list was fetched at. "unknown": no list is recorded for it. */
|
|
83
|
+
list_fetched_at_version: string;
|
|
84
|
+
list_fetched_at: string | null;
|
|
85
|
+
/** The tools this version offers that the client's list lacks. "unknown": no list is recorded to compare. */
|
|
86
|
+
missing_from_your_list: string[] | "unknown";
|
|
87
|
+
/** For a list that is not recorded: the tools each recent version added. A list fetched before that version lacks them. */
|
|
88
|
+
added_by_version?: Record<string, string[]>;
|
|
89
|
+
meaning: string;
|
|
90
|
+
/** One sentence for a person: how the client fetches the list again. */
|
|
91
|
+
refresh: string;
|
|
92
|
+
/** What the client can already call for the same matter, each with what it does and does not do. */
|
|
93
|
+
until_refresh: {
|
|
94
|
+
instead_of: string;
|
|
95
|
+
use: string;
|
|
96
|
+
how: string;
|
|
97
|
+
}[];
|
|
98
|
+
}
|
|
99
|
+
type ClientNamed = {
|
|
100
|
+
name?: string | undefined;
|
|
101
|
+
redirect_uris?: readonly unknown[] | undefined;
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* What get_capabilities says about the caller's tool list, or null when the list it last fetched is this version's.
|
|
105
|
+
* It says what the server offers and what the recorded list holds. It never says a tool can be called.
|
|
106
|
+
*/
|
|
107
|
+
export declare function clientToolsBlock(o: {
|
|
108
|
+
key: ClientKey | null;
|
|
109
|
+
entry: ClientEntry | null;
|
|
110
|
+
version: string;
|
|
111
|
+
offered: string[];
|
|
112
|
+
client?: ClientNamed;
|
|
113
|
+
}): ClientToolsBlock | null;
|
|
114
|
+
/**
|
|
115
|
+
* The tools map of get_capabilities. A tool the client's recorded list lacks says so before its status. When no list
|
|
116
|
+
* is recorded nothing is known of any one tool, so the map is left as it is and client_tools says why.
|
|
117
|
+
*/
|
|
118
|
+
export declare function annotateTools(status: Record<string, string>, block: ClientToolsBlock | null): Record<string, string>;
|
|
119
|
+
export {};
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
export const emptyClientTools = () => ({ recording_since: null, clients: {}, sessions: {} });
|
|
2
|
+
/** The version that began recording lists: a client with no record fetched its list before it, or never. */
|
|
3
|
+
export const RECORDING_SINCE = "0.1.45";
|
|
4
|
+
/** A person token used directly has this client id (oauth.ts): it names no client. */
|
|
5
|
+
const DIRECT = "direct";
|
|
6
|
+
const SESSION_ID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
7
|
+
const MAX_SESSIONS = 300;
|
|
8
|
+
const SESSION_DAYS = 30;
|
|
9
|
+
/** Under which key a request's list is kept: its OAuth client, else the session id it was given at initialize. */
|
|
10
|
+
export function clientKeyOf(clientId, sessionId) {
|
|
11
|
+
if (clientId && clientId !== DIRECT)
|
|
12
|
+
return { kind: "client", id: clientId };
|
|
13
|
+
if (sessionId && SESSION_ID.test(sessionId))
|
|
14
|
+
return { kind: "session", id: sessionId.toLowerCase() };
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
/** Does this request come from a client with no client id, which is given a session id at initialize? */
|
|
18
|
+
export const needsSession = (clientId) => clientId === DIRECT;
|
|
19
|
+
export class ClientLists {
|
|
20
|
+
file;
|
|
21
|
+
warn;
|
|
22
|
+
constructor(file, warn = (m) => console.error(m)) {
|
|
23
|
+
this.file = file;
|
|
24
|
+
this.warn = warn;
|
|
25
|
+
}
|
|
26
|
+
/** What is kept for this key. A state file that cannot be read is no record, never a failed request. */
|
|
27
|
+
read(key) {
|
|
28
|
+
if (!key)
|
|
29
|
+
return null;
|
|
30
|
+
try {
|
|
31
|
+
const s = this.file.read();
|
|
32
|
+
return (key.kind === "client" ? s.clients : s.sessions)?.[key.id] ?? null;
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
this.warn(`[connector] client-tools: ${error instanceof Error ? error.message : String(error)}`);
|
|
36
|
+
return null;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/** A tools/list was answered: the version and the names it carried. */
|
|
40
|
+
listed(key, version, tools, at = new Date().toISOString()) {
|
|
41
|
+
this.change(key, version, at, (e) => {
|
|
42
|
+
e.list = { version, at, tools: [...tools] };
|
|
43
|
+
e.lists += 1;
|
|
44
|
+
e.calls_since_list = 0;
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
/** A tool was called. */
|
|
48
|
+
called(key, version, at = new Date().toISOString()) {
|
|
49
|
+
this.change(key, version, at, (e) => {
|
|
50
|
+
e.calls_since_list += 1;
|
|
51
|
+
e.last_call = { at, version };
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
change(key, version, at, fn) {
|
|
55
|
+
if (!key)
|
|
56
|
+
return;
|
|
57
|
+
try {
|
|
58
|
+
let s;
|
|
59
|
+
try {
|
|
60
|
+
s = this.file.read();
|
|
61
|
+
}
|
|
62
|
+
catch (error) {
|
|
63
|
+
// A corrupt file is started again: it holds nothing that cannot be fetched again.
|
|
64
|
+
this.warn(`[connector] client-tools: ${error instanceof Error ? error.message : String(error)}; started again`);
|
|
65
|
+
s = emptyClientTools();
|
|
66
|
+
}
|
|
67
|
+
s.clients ??= {};
|
|
68
|
+
s.sessions ??= {};
|
|
69
|
+
s.recording_since ??= { version, at };
|
|
70
|
+
const bag = key.kind === "client" ? s.clients : s.sessions;
|
|
71
|
+
const entry = (bag[key.id] ??= { list: null, lists: 0, calls_since_list: 0, last_call: null, seen_at: at });
|
|
72
|
+
fn(entry);
|
|
73
|
+
entry.seen_at = at;
|
|
74
|
+
if (key.kind === "session")
|
|
75
|
+
pruneSessions(s, at);
|
|
76
|
+
this.file.write(s);
|
|
77
|
+
}
|
|
78
|
+
catch (error) {
|
|
79
|
+
this.warn(`[connector] client-tools: not written: ${error instanceof Error ? error.message : String(error)}`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/** Sessions end without a word: the idle ones go, and the newest stay when there are many. */
|
|
84
|
+
function pruneSessions(s, at) {
|
|
85
|
+
const limit = Date.parse(at) - SESSION_DAYS * 24 * 60 * 60 * 1000;
|
|
86
|
+
for (const [id, e] of Object.entries(s.sessions))
|
|
87
|
+
if (Date.parse(e.seen_at) < limit)
|
|
88
|
+
delete s.sessions[id];
|
|
89
|
+
const ids = Object.keys(s.sessions);
|
|
90
|
+
if (ids.length <= MAX_SESSIONS)
|
|
91
|
+
return;
|
|
92
|
+
ids.sort((a, b) => Date.parse(s.sessions[a].seen_at) - Date.parse(s.sessions[b].seen_at));
|
|
93
|
+
for (const id of ids.slice(0, ids.length - MAX_SESSIONS))
|
|
94
|
+
delete s.sessions[id];
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* The tools added since lists are compared, each with the version that added it. A client whose list is not recorded
|
|
98
|
+
* is told these by version, because nothing else says what its list may lack. `meanwhile` names a tool that existed
|
|
99
|
+
* before and reaches part of the same thing, with what it does and does not do.
|
|
100
|
+
*
|
|
101
|
+
* A tool added in a later release gets its entry here: test/client-tools.test.mjs fails until it has one.
|
|
102
|
+
*/
|
|
103
|
+
export const TOOL_ADDED = {
|
|
104
|
+
get_screenwalk: {
|
|
105
|
+
since: "0.1.44",
|
|
106
|
+
meanwhile: {
|
|
107
|
+
tool: "get_context",
|
|
108
|
+
how: "get_context with ref miadi-screenwalk:<id>, or the registration's page URL, answers the registration's identity, its canonical video, the names and where they stand, its readiness and its inventory counts. It does not return the whole record, its brief or its moments, and it does not say whether a review exists.",
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
list_screenwalks: { since: "0.1.44" },
|
|
112
|
+
request_screenwalk_review: {
|
|
113
|
+
since: "0.1.44",
|
|
114
|
+
meanwhile: {
|
|
115
|
+
tool: "review_lookup",
|
|
116
|
+
how: "review_lookup with the video's YouTube URL (get_context gives it) answers the review of that video, or no_review. Each review it answers carries screenwalks: the registrations related to it. It relates nothing and prepares no create request.",
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
function isChatGpt(client) {
|
|
121
|
+
if (/chatgpt|openai/i.test(client?.name ?? ""))
|
|
122
|
+
return true;
|
|
123
|
+
return (client?.redirect_uris ?? []).some((u) => {
|
|
124
|
+
try {
|
|
125
|
+
return /(^|\.)chatgpt\.com$|(^|\.)openai\.com$/i.test(new URL(String(u)).hostname);
|
|
126
|
+
}
|
|
127
|
+
catch {
|
|
128
|
+
return false;
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
function refreshSentence(key, client) {
|
|
133
|
+
if (isChatGpt(client))
|
|
134
|
+
return "For a person: in ChatGPT, open Settings, then Apps, choose this app and press Refresh. ChatGPT then fetches the tool list again.";
|
|
135
|
+
if (key?.kind === "client")
|
|
136
|
+
return "For a person: reconnect this connector in the client's settings, or start a new session there, so that the client asks for the tool list again.";
|
|
137
|
+
return "For a person: restart or reconnect the client, so that it asks for the tool list again.";
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* What get_capabilities says about the caller's tool list, or null when the list it last fetched is this version's.
|
|
141
|
+
* It says what the server offers and what the recorded list holds. It never says a tool can be called.
|
|
142
|
+
*/
|
|
143
|
+
export function clientToolsBlock(o) {
|
|
144
|
+
const list = o.entry?.list ?? null;
|
|
145
|
+
const refresh = refreshSentence(o.key, o.client);
|
|
146
|
+
if (list) {
|
|
147
|
+
const held = new Set(list.tools);
|
|
148
|
+
const missing = o.offered.filter((n) => !held.has(n));
|
|
149
|
+
if (list.version === o.version && !missing.length)
|
|
150
|
+
return null;
|
|
151
|
+
return {
|
|
152
|
+
state: "list_older_than_this_version",
|
|
153
|
+
this_version: o.version,
|
|
154
|
+
list_fetched_at_version: list.version,
|
|
155
|
+
list_fetched_at: list.at,
|
|
156
|
+
missing_from_your_list: missing,
|
|
157
|
+
meaning: missing.length
|
|
158
|
+
? `Your client holds the tool list it fetched from version ${list.version}. This connector now runs ${o.version}. The tools in missing_from_your_list are offered by the server and are not in that list: your client cannot call them until it fetches the list again. The tools map below names what the server offers, not what your client can call.`
|
|
159
|
+
: `Your client holds the tool list it fetched from version ${list.version}. This connector now runs ${o.version}. No tool is missing from that list. Descriptions and inputs may have changed since.`,
|
|
160
|
+
refresh,
|
|
161
|
+
until_refresh: missing.flatMap((n) => {
|
|
162
|
+
const m = TOOL_ADDED[n]?.meanwhile;
|
|
163
|
+
return m && held.has(m.tool) ? [{ instead_of: n, use: m.tool, how: m.how }] : [];
|
|
164
|
+
}),
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
const offered = new Set(o.offered);
|
|
168
|
+
const added = {};
|
|
169
|
+
for (const [name, a] of Object.entries(TOOL_ADDED))
|
|
170
|
+
if (offered.has(name))
|
|
171
|
+
(added[a.since] ??= []).push(name);
|
|
172
|
+
return {
|
|
173
|
+
state: "list_not_recorded",
|
|
174
|
+
this_version: o.version,
|
|
175
|
+
list_fetched_at_version: "unknown",
|
|
176
|
+
list_fetched_at: null,
|
|
177
|
+
missing_from_your_list: "unknown",
|
|
178
|
+
added_by_version: added,
|
|
179
|
+
meaning: `This connector has no record of a tool list fetched by your client. It records them since version ${RECORDING_SINCE}, so your client fetched its list before that, or not in this session. The connector cannot tell which tools your client holds. A tool named in the tools map below that your client does not offer you cannot be called until the client fetches the list again. added_by_version names the tools each recent version added: a list fetched before that version lacks them.`,
|
|
180
|
+
refresh,
|
|
181
|
+
until_refresh: Object.entries(TOOL_ADDED).flatMap(([n, a]) => (offered.has(n) && a.meanwhile && offered.has(a.meanwhile.tool) && !TOOL_ADDED[a.meanwhile.tool] ? [{ instead_of: n, use: a.meanwhile.tool, how: a.meanwhile.how }] : [])),
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* The tools map of get_capabilities. A tool the client's recorded list lacks says so before its status. When no list
|
|
186
|
+
* is recorded nothing is known of any one tool, so the map is left as it is and client_tools says why.
|
|
187
|
+
*/
|
|
188
|
+
export function annotateTools(status, block) {
|
|
189
|
+
if (!block || !Array.isArray(block.missing_from_your_list) || !block.missing_from_your_list.length)
|
|
190
|
+
return status;
|
|
191
|
+
const out = { ...status };
|
|
192
|
+
for (const n of block.missing_from_your_list)
|
|
193
|
+
if (n in out)
|
|
194
|
+
out[n] = `not in your client's tool list, fetched from version ${block.list_fetched_at_version} (see client_tools). On the server: ${out[n]}`;
|
|
195
|
+
return out;
|
|
196
|
+
}
|
package/dist/server.d.ts
CHANGED
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
*
|
|
4
4
|
* /.well-known/oauth-* OAuth discovery (MCP authorization spec)
|
|
5
5
|
* /authorize /token /register /revoke, /authorize/confirm sign-in
|
|
6
|
-
* /mcp the MCP endpoint (streamable HTTP, stateless
|
|
6
|
+
* /mcp the MCP endpoint (streamable HTTP, stateless; a client with no
|
|
7
|
+
* client id is given a session id, kept only to name its tool list)
|
|
7
8
|
* /health liveness, no data
|
|
8
9
|
*
|
|
9
10
|
* Every MCP request carries the signed-in person, and each tool call runs
|
|
@@ -61,4 +62,4 @@ export declare function createConnectorApp(config: ConnectorConfig, deps: Connec
|
|
|
61
62
|
provider: MiadiOAuthProvider;
|
|
62
63
|
ledger: Ledger<ConnectorRecord>;
|
|
63
64
|
};
|
|
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, get_screenwalk, list_screenwalks, 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- A registered screenwalk is read with get_screenwalk, by its registry id, miadi-screenwalk:<id> or its page URL, and the registrations are listed with list_screenwalks. What it returns is the Screenwalk Registry's own record, read as the signed-in person: the canonical video, the names and where they stand, and the inventory already prepared (question sets, segments, purpose lists, relations). That inventory is not a review and not a transcript, and nothing copies it into a review. request_screenwalk_review is the one step from a registration to its review: it relates the registration to the review that already exists for its video, or prepares one create request that a person approves. Never ask the person to copy a YouTube URL that a registration already holds.\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>, miadi-screenwalk:<id>, owner/repo#n and session:<uuid> reference forms.";
|
|
65
|
+
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. When its answer carries client_tools, the tool list your client holds is older than this server or not recorded: a tool named there is offered by the server and cannot be called from your client until a person makes it fetch the list again. Tell the person the sentence it gives, and use what until_refresh names meanwhile.\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, get_screenwalk, list_screenwalks, 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- A registered screenwalk is read with get_screenwalk, by its registry id, miadi-screenwalk:<id> or its page URL, and the registrations are listed with list_screenwalks. What it returns is the Screenwalk Registry's own record, read as the signed-in person: the canonical video, the names and where they stand, and the inventory already prepared (question sets, segments, purpose lists, relations). That inventory is not a review and not a transcript, and nothing copies it into a review. request_screenwalk_review is the one step from a registration to its review: it relates the registration to the review that already exists for its video, or prepares one create request that a person approves. Never ask the person to copy a YouTube URL that a registration already holds.\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>, miadi-screenwalk:<id>, owner/repo#n and session:<uuid> reference forms.";
|
package/dist/server.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
1
2
|
import express from "express";
|
|
2
3
|
import { rateLimit } from "express-rate-limit";
|
|
3
4
|
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
@@ -10,6 +11,7 @@ import { logDecision, reconcileInterrupted, registerApprovalRoutes, registerCons
|
|
|
10
11
|
import { DecisionTokens } from "./decisions.js";
|
|
11
12
|
import { JsonFile, Ledger, ensureStateDir, statePaths } from "./store.js";
|
|
12
13
|
import { registerTools } from "./tools.js";
|
|
14
|
+
import { ClientLists, clientKeyOf, emptyClientTools, needsSession } from "./client-tools.js";
|
|
13
15
|
import { MiadiClient } from "./miadi.js";
|
|
14
16
|
import { ReviewClient } from "./reviews.js";
|
|
15
17
|
import { readFactoryConfig, runSteering } from "./steering-adapters.js";
|
|
@@ -22,6 +24,8 @@ export function createConnectorApp(config, deps) {
|
|
|
22
24
|
const paths = statePaths(config.stateDir);
|
|
23
25
|
const oauthState = new JsonFile(paths.oauth, emptyOAuthState);
|
|
24
26
|
const ledger = new Ledger(paths.ledger);
|
|
27
|
+
// The tool list each client last fetched, so get_capabilities can say when it is older than this version (jgwill/Miadi#1180).
|
|
28
|
+
const clientLists = new ClientLists(new JsonFile(paths.clientTools, emptyClientTools));
|
|
25
29
|
// The issuer string exactly as the metadata states it (URL.href, so with its trailing slash).
|
|
26
30
|
const issuer = new URL(config.publicUrl).href;
|
|
27
31
|
const provider = new MiadiOAuthProvider(oauthState, deps.identify, issuer);
|
|
@@ -133,6 +137,18 @@ export function createConnectorApp(config, deps) {
|
|
|
133
137
|
logDecision(approvalDeps, { phase: "card_template_read", uri: String(rpc.params?.uri ?? "").slice(0, 120) });
|
|
134
138
|
if (rpc.method === "tools/call" && rpc.params?.name === "show_decisions")
|
|
135
139
|
logDecision(approvalDeps, { phase: "show_decisions" });
|
|
140
|
+
// Whose tool list this request concerns: its OAuth client, else the session id given at initialize. A client
|
|
141
|
+
// with no client id (a person token used directly) is given one there and sends it back on what follows; the
|
|
142
|
+
// endpoint keeps no session for it.
|
|
143
|
+
const methods = (Array.isArray(req.body) ? req.body : [req.body]).map((m) => String(m?.method ?? ""));
|
|
144
|
+
const clientId = req.auth?.clientId;
|
|
145
|
+
const sent = req.headers["mcp-session-id"];
|
|
146
|
+
let sessionId = typeof sent === "string" ? sent : undefined;
|
|
147
|
+
if (needsSession(clientId) && methods.includes("initialize")) {
|
|
148
|
+
sessionId = randomUUID();
|
|
149
|
+
res.setHeader("Mcp-Session-Id", sessionId);
|
|
150
|
+
}
|
|
151
|
+
const listKey = clientKeyOf(clientId, sessionId);
|
|
136
152
|
const ctx = {
|
|
137
153
|
config,
|
|
138
154
|
miadi,
|
|
@@ -152,9 +168,14 @@ export function createConnectorApp(config, deps) {
|
|
|
152
168
|
...(deps.steeringRuntime ? { steeringRuntime: deps.steeringRuntime } : {}),
|
|
153
169
|
...(deps.wakeRunner ? { wakeRunner: deps.wakeRunner } : {}),
|
|
154
170
|
...(deps.clones ? { clones: deps.clones } : {}),
|
|
171
|
+
clientTools: { lists: clientLists, key: listKey },
|
|
155
172
|
};
|
|
156
173
|
const server = new McpServer({ name: "miadi", version: VERSION }, { instructions: INSTRUCTIONS });
|
|
157
|
-
registerTools(server, ctx);
|
|
174
|
+
const { tools: offered } = registerTools(server, ctx);
|
|
175
|
+
if (methods.includes("tools/list"))
|
|
176
|
+
clientLists.listed(listKey, VERSION, offered);
|
|
177
|
+
else if (methods.includes("tools/call"))
|
|
178
|
+
clientLists.called(listKey, VERSION);
|
|
158
179
|
const transport = new StreamableHTTPServerTransport({ sessionIdGenerator: undefined, enableJsonResponse: true });
|
|
159
180
|
res.on("close", () => {
|
|
160
181
|
transport.close().catch(() => { });
|
|
@@ -182,7 +203,7 @@ export function createConnectorApp(config, deps) {
|
|
|
182
203
|
}
|
|
183
204
|
export 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).
|
|
184
205
|
|
|
185
|
-
Start with get_capabilities: it says who you are signed in as, which tools are live, and which return not_implemented.
|
|
206
|
+
Start with get_capabilities: it says who you are signed in as, which tools are live, and which return not_implemented. When its answer carries client_tools, the tool list your client holds is older than this server or not recorded: a tool named there is offered by the server and cannot be called from your client until a person makes it fetch the list again. Tell the person the sentence it gives, and use what until_refresh names meanwhile.
|
|
186
207
|
|
|
187
208
|
Every 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, get_screenwalk, list_screenwalks, read_episode_file and show_decisions.
|
|
188
209
|
|
package/dist/store.d.ts
CHANGED
package/dist/store.js
CHANGED
|
@@ -9,6 +9,9 @@
|
|
|
9
9
|
* - ledger.jsonl the records people contribute through the connector
|
|
10
10
|
* (observations, handoffs, proposals). Append-only: a record
|
|
11
11
|
* is never edited, a later record supersedes it.
|
|
12
|
+
* - client-tools.json the tool list each client last fetched: its version and
|
|
13
|
+
* tool names, by OAuth client id or by session id. No token and
|
|
14
|
+
* no person (client-tools.ts).
|
|
12
15
|
*/
|
|
13
16
|
import { appendFileSync, chmodSync, closeSync, existsSync, fsyncSync, mkdirSync, openSync, readFileSync, statSync, writeSync } from "node:fs";
|
|
14
17
|
import { createHash, randomBytes } from "node:crypto";
|
|
@@ -108,5 +111,6 @@ export function statePaths(dir) {
|
|
|
108
111
|
return {
|
|
109
112
|
oauth: join(dir, "oauth.json"),
|
|
110
113
|
ledger: join(dir, "ledger.jsonl"),
|
|
114
|
+
clientTools: join(dir, "client-tools.json"),
|
|
111
115
|
};
|
|
112
116
|
}
|
package/dist/tools.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ import { type RuntimeDeps } from "./runtime-steer.js";
|
|
|
14
14
|
import { type AdapterProbe } from "./steering-adapters.js";
|
|
15
15
|
import { type TmuxLike } from "./steer.js";
|
|
16
16
|
import { type GithubGet } from "./mission-result.js";
|
|
17
|
+
import { type ClientKey, type ClientLists } from "./client-tools.js";
|
|
17
18
|
export interface ToolContext {
|
|
18
19
|
config: ConnectorConfig;
|
|
19
20
|
miadi: MiadiClient;
|
|
@@ -46,6 +47,11 @@ export interface ToolContext {
|
|
|
46
47
|
steerSettleMs?: number;
|
|
47
48
|
/** Where a repository's clone lives on this host, for reading the commits of a completion (jgwill/Miadi#993). Default: MIADI_CONNECTOR_CLONES, then the service's own checkout for jgwill/Miadi. */
|
|
48
49
|
clones?: (repository: string) => string | undefined;
|
|
50
|
+
/** The tool list this request's client last fetched, and under which key it is kept (jgwill/Miadi#1180, client-tools.ts). Absent, get_capabilities says nothing of it. */
|
|
51
|
+
clientTools?: {
|
|
52
|
+
lists: ClientLists;
|
|
53
|
+
key: ClientKey | null;
|
|
54
|
+
};
|
|
49
55
|
}
|
|
50
56
|
/**
|
|
51
57
|
* Why GitHub did not answer a reference (jgwill/Miadi#913 B). A 404 without a
|
|
@@ -72,6 +78,9 @@ export declare function steeringTransport(tmux: TmuxLike | undefined): {
|
|
|
72
78
|
transport: "operational" | "unavailable";
|
|
73
79
|
reason?: string;
|
|
74
80
|
};
|
|
75
|
-
|
|
81
|
+
/** Registers every tool, and returns the names it registered: what a tools/list of this server answers. */
|
|
82
|
+
export declare function registerTools(server: McpServer, ctx: ToolContext): {
|
|
83
|
+
tools: string[];
|
|
84
|
+
};
|
|
76
85
|
/** What get_capabilities reports for each tool. */
|
|
77
86
|
export declare const TOOL_STATUS: Record<string, string>;
|
package/dist/tools.js
CHANGED
|
@@ -45,6 +45,7 @@ import { workflowId } from "./reading/workflow.js";
|
|
|
45
45
|
import { readingTask } from "./reading/adapters.js";
|
|
46
46
|
import { recordsSeenBy, redactRecord } from "./record-view.js";
|
|
47
47
|
import { MAX_REGISTRATION_BYTES, MIN_REGISTRATION_BYTES, REGISTRY_REVIEW_KIND, REVIEW_SOURCE_RELATION, ScreenwalkRefusal, inventoryOf, listRegistrations, looksLikeScreenwalk, namesOf, namesScreenwalk, pageText, partIndex, readBrief, readMoments, readRegistration, readinessOf, registryOrigins, relateRegistration, reviewRecordsOf, reviewRelationsOf, screenwalkRefOf, screenwalksOfReview, selectRegistration, videoOf, } from "./screenwalks.js";
|
|
48
|
+
import { annotateTools, clientToolsBlock } from "./client-tools.js";
|
|
48
49
|
import { artefactVisibility, readArtefactWeave, saveResearchArtefact } from "@miadi/inquiry-weave";
|
|
49
50
|
import { ResearchUploads, UploadRefusal } from "./uploads.js";
|
|
50
51
|
import { DEFAULT_PAGE_BYTES, FOUNDATIONS_PERMISSION, FileRefusal, MAX_TEXT_BYTES, MIN_PAGE_BYTES, TEXT_TYPES, checkRelativePath, episodeNumberOf, extensionOf, fileRef, holdsFoundationRead, isFoundationDoc, pageOf, parseFileRef, } from "./episode-files.js";
|
|
@@ -245,8 +246,16 @@ const launchModelFields = {
|
|
|
245
246
|
.optional()
|
|
246
247
|
.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."),
|
|
247
248
|
};
|
|
249
|
+
/** Registers every tool, and returns the names it registered: what a tools/list of this server answers. */
|
|
248
250
|
export function registerTools(server, ctx) {
|
|
249
251
|
const { config, miadi, reviews, ledger } = ctx;
|
|
252
|
+
// The names as they are registered, for the record of what each client last fetched (client-tools.ts).
|
|
253
|
+
const offered = [];
|
|
254
|
+
const registerTool = server.registerTool.bind(server);
|
|
255
|
+
server.registerTool = ((name, ...rest) => {
|
|
256
|
+
offered.push(name);
|
|
257
|
+
return registerTool(name, ...rest);
|
|
258
|
+
});
|
|
250
259
|
// One server is made per request, so the person a tool call runs for is this request's viewer.
|
|
251
260
|
let viewer;
|
|
252
261
|
/**
|
|
@@ -399,7 +408,7 @@ export function registerTools(server, ctx) {
|
|
|
399
408
|
// ── reads ──────────────────────────────────────────────────────────────
|
|
400
409
|
server.registerTool("get_capabilities", {
|
|
401
410
|
title: "What this connector can do for you",
|
|
402
|
-
description: "Start here with the Miadi connector. The capability handshake: who you are signed in as (who am I), your Miadi tier and scopes, the full list of Miadi tools with each one's status (live, needs_approval, write_tier), the services reached and the five circles. Call this first.",
|
|
411
|
+
description: "Start here with the Miadi connector. The capability handshake: who you are signed in as (who am I), your Miadi tier and scopes, the full list of Miadi tools with each one's status (live, needs_approval, write_tier), the services reached and the five circles. When the tool list your client holds is older than this server, client_tools says so: the version of that list, the tools it lacks, and how a person makes the client fetch it again. Call this first.",
|
|
403
412
|
inputSchema: {},
|
|
404
413
|
annotations: READ,
|
|
405
414
|
}, wrap(async (_args, extra) => {
|
|
@@ -412,9 +421,16 @@ export function registerTools(server, ctx) {
|
|
|
412
421
|
}, (e) => (e instanceof MiadiError && e.status === 0 ? "unavailable" : "reachable"));
|
|
413
422
|
// Miadi's answer now, not the sign-in's last one (cached up to five minutes).
|
|
414
423
|
const foundations = holdsFoundationRead(fresh ?? person.permissions);
|
|
424
|
+
// The tool list this client last fetched, against the one this version offers (jgwill/Miadi#1180).
|
|
425
|
+
const oauthClient = ctx.oauthState.read().clients[auth.clientId];
|
|
426
|
+
const clientTools = ctx.clientTools
|
|
427
|
+
? clientToolsBlock({ key: ctx.clientTools.key, entry: ctx.clientTools.lists.read(ctx.clientTools.key), version: VERSION, offered, client: { name: oauthClient?.client_name, redirect_uris: oauthClient?.redirect_uris } })
|
|
428
|
+
: null;
|
|
415
429
|
return {
|
|
416
430
|
service: "@miadi/connector",
|
|
417
431
|
version: VERSION,
|
|
432
|
+
// Said first when it applies: what follows names what the server offers, and this client's list is older.
|
|
433
|
+
...(clientTools ? { client_tools: clientTools } : {}),
|
|
418
434
|
contract: "jgwill/Miadi#815 Connector v2, jgwill/Miadi#816 Review Bridge",
|
|
419
435
|
reading_workflow: {
|
|
420
436
|
contract: "transcript-first-v1",
|
|
@@ -443,7 +459,7 @@ export function registerTools(server, ctx) {
|
|
|
443
459
|
review_service: { url: config.reviewUrl, search: reviews.canSearch ? "enabled" : "disabled: no token on the connector host" },
|
|
444
460
|
ledger: "connector ledger (append-only, /srv/miadi/connector)",
|
|
445
461
|
},
|
|
446
|
-
tools: TOOL_STATUS,
|
|
462
|
+
tools: annotateTools(TOOL_STATUS, clientTools),
|
|
447
463
|
mission_standard: ctx.draftReview ? await standardStatus(ctx.draftReview) : { state: "unavailable" },
|
|
448
464
|
// Registered is not operational: whether a steer can reach a pane on this host now (jgwill/Miadi#909).
|
|
449
465
|
steering: {
|
|
@@ -3465,6 +3481,7 @@ export function registerTools(server, ctx) {
|
|
|
3465
3481
|
return fail({ error: "failed", message: error instanceof Error ? error.message : String(error) });
|
|
3466
3482
|
}
|
|
3467
3483
|
});
|
|
3484
|
+
return { tools: offered };
|
|
3468
3485
|
}
|
|
3469
3486
|
function asState(e) {
|
|
3470
3487
|
if (e instanceof MiadiError)
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "0.1.
|
|
1
|
+
export declare const VERSION = "0.1.45";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "0.1.
|
|
1
|
+
export const VERSION = "0.1.45";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@miadi/connector",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.45",
|
|
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, registered screenwalks, episodes and circles and records observations, inquiries, handoffs and proposals with their name on each record.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Miadi",
|