@miadi/connector 0.1.40 → 0.1.41
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 +3 -2
- package/dist/comments.d.ts +80 -0
- package/dist/comments.js +119 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/refs.d.ts +22 -0
- package/dist/refs.js +56 -0
- package/dist/tools.js +207 -18
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +11 -3
package/README.md
CHANGED
|
@@ -22,13 +22,14 @@ Call `get_capabilities` first. It names the signed-in person, their Miadi API ti
|
|
|
22
22
|
|
|
23
23
|
| kind | tools |
|
|
24
24
|
|---|---|
|
|
25
|
-
| reads | `get_capabilities` `get_context` `list_circles` `get_circle` `list_sessions` `search_sessions` `get_session` `get_evidence` `read_episode_file` `get_evaluations` `get_narrative_beats` `review_lookup` `review_versions` `review_transcript_status` `handoff_status` `list_records` `get_run_result` `mission_status` `provider_capabilities` `mission_model_preflight` `search` `fetch` `list_research_artifacts` `read_research_artifact` |
|
|
26
|
-
| contributions | `ensure_review_transcript` `append_observation` `open_inquiry` `link_records` `propose_narrative_beat` `record_evaluation` `register_source_intent` `record_handoff` `update_handoff` `prepare_calendar_event` `save_research` |
|
|
25
|
+
| reads | `get_capabilities` `get_context` `list_circles` `get_circle` `list_sessions` `search_sessions` `get_session` `get_evidence` `list_episode_comments` `read_episode_file` `get_evaluations` `get_narrative_beats` `review_lookup` `review_versions` `review_transcript_status` `handoff_status` `list_records` `get_run_result` `mission_status` `provider_capabilities` `mission_model_preflight` `search` `fetch` `list_research_artifacts` `read_research_artifact` |
|
|
26
|
+
| contributions | `ensure_review_transcript` `append_observation` `comment_on_episode` `open_inquiry` `link_records` `propose_narrative_beat` `record_evaluation` `register_source_intent` `record_handoff` `update_handoff` `prepare_calendar_event` `save_research` |
|
|
27
27
|
| requests (approved by a person) | `propose_work` `propose_session_completion` `request_authorized_run` `request_session_steer` `revoke_session_steering` `request_review_operation` `request_deep_diver` `link_review_to_episode` `request_inquiry_episode` |
|
|
28
28
|
| decisions in the conversation | `show_decisions` (cards), `decide_request` (called by the card only) |
|
|
29
29
|
|
|
30
30
|
- **Reads** need Miadi's read tier and stay within it. A person Miadi gives no API tier reaches only `get_capabilities`. Sessions need the write tier, because a session's name and pane are operator data. For the same reason, below the write tier a record someone else made shows no session, working folder or seat, and no long bodies.
|
|
31
31
|
- **Episode files.** `get_evidence` lists an episode's files; each text file Miadi can preview carries a `read_ref` (`miadi-chronicle://<n>/<path>`). `read_episode_file` (or `fetch` with that ref) returns the file's whole UTF-8 text, read as the person through Miadi's file door, so Miadi's audience and room rules apply. The answer names the episode, the path, the content type, the byte count and the sha256, and `verified` says whether the text received hashes to what Miadi read. Only md, txt, yaml, yml and json files up to 512 KiB are read. A traversal, absolute, hidden or encoded path is refused before any URL is built. A longer text comes in pages cut on character boundaries: pass `page.next` back, and the joined pages hash to `sha256`. Other kinds answer `unsupported`, a file over the limit `too_large`, a missing one `not_found`, a ceremony note below the write gate `forbidden`.
|
|
32
|
+
- **Comments on an episode.** `comment_on_episode` publishes what a person says about an episode, in their name, optionally at a position of one of its media files (`media`, `at_seconds`, `until_seconds`). The comment is an observation that carries an `anchor`: the episode as Miadi resolved it, the media file's path and the position. `list_episode_comments` reads an episode's comments, by media file and by span of positions. Miadi's episode page shows them to a signed-in person who may open the episode. When the commenter sits in the episode's Root Circle, the comment is also said there as a turn, with their own token, and its record keeps the turn's id. The same `idempotency_key` returns the first comment and speaks no second turn. An episode's address is read under any written form: `miadi-chronicle://92` and `miadi-chronicle://092` name one episode in `get_context`, `get_evidence`, `list_records`, `handoff_status` and the comment tools. The comments Gérico's Space « Banque d'épisodes » published with `append_observation` (key `banque-episodes-…`) stay comments, and the media file and position are read from the sentence in their `intention` (jgwill/Miadi#1093).
|
|
32
33
|
- **One narrow grant.** A person with no Miadi API tier who holds `chronicle_foundations_read` (ticked by an admin under /admin → People → Additional permissions; admins hold it through their role) reaches `read_episode_file` for foundation documents only: `foundations/<topic>/*.md`, read through Miadi's `GET /api/chronicle/episodes/<ref>/foundations/<topic>/<file>.md`, which checks the permission on every read. Naming the episode alone lists them. Every other file and every other tool stays refused, and the permission gives no API tier. Unticking it refuses the next read. `get_capabilities` reports it under `foundation_read`, from Miadi's answer at that moment.
|
|
33
34
|
- **Contributions** need Miadi's read tier and the `miadi:contribute` scope, chosen at sign-in. A record is moved on (`update_handoff`) only by its author or the write tier, and a request's receipt comes only from its decision. They append a record to the ledger and change nothing else, except `save_research`: it saves a report on the inquiry shelf as a new folder (the Markdown exactly as given, owner and visibility recorded, private by default), opens the folder's inquiry issue, and commits and pushes the folder in the shelf's repository. A long report is sent in parts (`part`, `parts`, `upload_id`) and saved when the last part arrives; the answer returns its bytes, sha256 and first and last lines.
|
|
34
35
|
- **Sharing a record.** A record's author shares it with a talking circle or one person by linking from it: `link_records` with `from` the record's id, `to` `miadi-circle:<circle id>` or the person's id, and `relation` `shared_with`. `share_withdrawn`, from the same record to the same reader, ends the share. Only the author's links count, and `link_records` refuses a share from anyone else. The record's page (`/records/<id>`) admits its author, the people and members of the circles it is shared with (their circles read from Miadi on every read), and the read tier, and it says how the reader was admitted. Miadi's `/research` lists what is shared with a person under Shared.
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The comments of an episode, read from the ledger (jgwill/Miadi#1093; P1 of
|
|
3
|
+
* rispecs/episode-participants/SPEC.md). One read model for the connector's
|
|
4
|
+
* tools and for Miadi's pages, so both answer the same comments.
|
|
5
|
+
*
|
|
6
|
+
* A comment is an observation that carries an anchor (`body.anchor`, written
|
|
7
|
+
* by comment_on_episode): the episode, and optionally a media file and a
|
|
8
|
+
* position in it. The first comments were published before the anchor existed,
|
|
9
|
+
* by Gérico's Space « Banque d'épisodes », with append_observation: their key
|
|
10
|
+
* starts with `banque-episodes-` and the media file and position are in the
|
|
11
|
+
* sentence of their `intention`. They stay comments, and that one sentence is
|
|
12
|
+
* read for them. Nothing is read from a comment's own text. The other
|
|
13
|
+
* observations that cite an episode are reports, and are not comments.
|
|
14
|
+
*/
|
|
15
|
+
import type { ConnectorRecord } from "./records.js";
|
|
16
|
+
export interface CommentAnchor {
|
|
17
|
+
/** The episode as the connector resolved it when the comment was published; null on a Space's first comments. */
|
|
18
|
+
episode: {
|
|
19
|
+
folder: string | null;
|
|
20
|
+
number: number | null;
|
|
21
|
+
} | null;
|
|
22
|
+
/** The media file: its path inside the episode, or the bare name a Space stated. Null for the whole episode. */
|
|
23
|
+
media: string | null;
|
|
24
|
+
at_seconds: number | null;
|
|
25
|
+
until_seconds: number | null;
|
|
26
|
+
/** `fields`: the record carries the anchor. `intention`: read from the sentence the Space wrote. */
|
|
27
|
+
stated_in: "fields" | "intention";
|
|
28
|
+
}
|
|
29
|
+
/** The turn a comment also became in the episode's Root Circle, when its author sat there. */
|
|
30
|
+
export interface CircleTurn {
|
|
31
|
+
ceremony_id: string;
|
|
32
|
+
beat_id: string;
|
|
33
|
+
circle_id?: string;
|
|
34
|
+
circle_name?: string;
|
|
35
|
+
at?: string;
|
|
36
|
+
}
|
|
37
|
+
export interface EpisodeComment {
|
|
38
|
+
id: string;
|
|
39
|
+
/** When it was published. */
|
|
40
|
+
at: string;
|
|
41
|
+
text: string;
|
|
42
|
+
author: {
|
|
43
|
+
person_id: string;
|
|
44
|
+
name: string;
|
|
45
|
+
};
|
|
46
|
+
/** The client it came through, when that client registered a name. */
|
|
47
|
+
client: string | null;
|
|
48
|
+
claim_category: string | null;
|
|
49
|
+
intention: string | null;
|
|
50
|
+
anchor: CommentAnchor | null;
|
|
51
|
+
circle_turn: CircleTurn | null;
|
|
52
|
+
}
|
|
53
|
+
export interface CommentEpisode {
|
|
54
|
+
number?: number | null;
|
|
55
|
+
folder?: string | null;
|
|
56
|
+
/** Another folder carries the same number: a comment that names the number alone is then shown on neither. */
|
|
57
|
+
number_shared?: boolean;
|
|
58
|
+
}
|
|
59
|
+
export interface CommentFilter {
|
|
60
|
+
media?: string;
|
|
61
|
+
from_seconds?: number;
|
|
62
|
+
to_seconds?: number;
|
|
63
|
+
person_id?: string;
|
|
64
|
+
}
|
|
65
|
+
/** The key Gérico's Space « Banque d'épisodes » gives a comment it publishes with append_observation. */
|
|
66
|
+
export declare const SPACE_COMMENT_KEY: RegExp;
|
|
67
|
+
/** Where a comment points, from its fields, else from the Space's sentence; null for the whole episode. */
|
|
68
|
+
export declare function anchorOf(r: ConnectorRecord): CommentAnchor | null;
|
|
69
|
+
export declare function isComment(r: ConnectorRecord): boolean;
|
|
70
|
+
export declare function commentOf(r: ConnectorRecord): EpisodeComment;
|
|
71
|
+
/** A listed path and a bare file name agree when the name is the path's last segment. */
|
|
72
|
+
export declare function sameMedia(a: string, b: string): boolean;
|
|
73
|
+
/**
|
|
74
|
+
* The comments on one episode, from the folded ledger (`current()`), in order
|
|
75
|
+
* of media file, then position, then time. A comment on the whole episode
|
|
76
|
+
* comes before the comments at a position.
|
|
77
|
+
*/
|
|
78
|
+
export declare function commentsOf(records: readonly ConnectorRecord[], episode: CommentEpisode, filter?: CommentFilter): EpisodeComment[];
|
|
79
|
+
/** 105 → "1:45", 3725 → "1:02:05". */
|
|
80
|
+
export declare function formatPosition(seconds: number): string;
|
package/dist/comments.js
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { parseChronicleAddress } from "./refs.js";
|
|
2
|
+
/** The key Gérico's Space « Banque d'épisodes » gives a comment it publishes with append_observation. */
|
|
3
|
+
export const SPACE_COMMENT_KEY = /^banque-episodes-/;
|
|
4
|
+
/** The sentence that Space writes in `intention`: sur « <file> », à <n> s du média. */
|
|
5
|
+
const SPACE_SENTENCE = /sur\s+«[\s\u00a0\u202f]*(.+?)[\s\u00a0\u202f]*»,?\s+à\s+(\d+(?:[.,]\d+)?)\s*s\b/;
|
|
6
|
+
const finite = (v) => (typeof v === "number" && Number.isFinite(v) && v >= 0 ? v : null);
|
|
7
|
+
const text = (v) => (typeof v === "string" && v.trim() ? v.trim() : null);
|
|
8
|
+
/** Where a comment points, from its fields, else from the Space's sentence; null for the whole episode. */
|
|
9
|
+
export function anchorOf(r) {
|
|
10
|
+
const a = r.body.anchor;
|
|
11
|
+
if (a && typeof a === "object") {
|
|
12
|
+
const anchor = a;
|
|
13
|
+
const episode = anchor.episode && typeof anchor.episode === "object" ? anchor.episode : null;
|
|
14
|
+
const at = finite(anchor.at_seconds);
|
|
15
|
+
const until = finite(anchor.until_seconds);
|
|
16
|
+
return {
|
|
17
|
+
episode: episode ? { folder: text(episode.folder), number: finite(episode.number) } : null,
|
|
18
|
+
media: text(anchor.media),
|
|
19
|
+
at_seconds: at,
|
|
20
|
+
until_seconds: at !== null && until !== null && until > at ? until : null,
|
|
21
|
+
stated_in: "fields",
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
if (!SPACE_COMMENT_KEY.test(r.idempotency_key ?? ""))
|
|
25
|
+
return null;
|
|
26
|
+
const said = SPACE_SENTENCE.exec(r.intention ?? "");
|
|
27
|
+
if (!said)
|
|
28
|
+
return null;
|
|
29
|
+
return { episode: null, media: said[1].trim(), at_seconds: Number(said[2].replace(",", ".")), until_seconds: null, stated_in: "intention" };
|
|
30
|
+
}
|
|
31
|
+
export function isComment(r) {
|
|
32
|
+
if (r.kind !== "observation" || r.state === "withdrawn")
|
|
33
|
+
return false;
|
|
34
|
+
const body = r.body;
|
|
35
|
+
if (body.reading || !text(body.text))
|
|
36
|
+
return false;
|
|
37
|
+
return Boolean(body.anchor && typeof body.anchor === "object") || SPACE_COMMENT_KEY.test(r.idempotency_key ?? "");
|
|
38
|
+
}
|
|
39
|
+
export function commentOf(r) {
|
|
40
|
+
const turn = r.completion_receipt?.circle_turn;
|
|
41
|
+
return {
|
|
42
|
+
id: r.id,
|
|
43
|
+
at: r.created_at,
|
|
44
|
+
text: String(r.body.text ?? ""),
|
|
45
|
+
author: { person_id: r.actor.person_id, name: r.actor.name },
|
|
46
|
+
client: r.actor.client_name ?? null,
|
|
47
|
+
claim_category: r.claim_category ?? null,
|
|
48
|
+
intention: r.intention ?? null,
|
|
49
|
+
anchor: anchorOf(r),
|
|
50
|
+
circle_turn: turn && typeof turn.ceremony_id === "string" && typeof turn.beat_id === "string" ? turn : null,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
/** A listed path and a bare file name agree when the name is the path's last segment. */
|
|
54
|
+
export function sameMedia(a, b) {
|
|
55
|
+
if (a === b)
|
|
56
|
+
return true;
|
|
57
|
+
const last = (p) => p.slice(p.lastIndexOf("/") + 1);
|
|
58
|
+
return (!a.includes("/") || !b.includes("/")) && last(a) === last(b);
|
|
59
|
+
}
|
|
60
|
+
function namesEpisode(r, anchor, episode) {
|
|
61
|
+
const byNumber = (n) => !episode.number_shared && n !== null && episode.number !== null && episode.number !== undefined && n === episode.number;
|
|
62
|
+
if (anchor?.episode?.folder && episode.folder)
|
|
63
|
+
return anchor.episode.folder === episode.folder;
|
|
64
|
+
if (anchor?.episode && byNumber(anchor.episode.number))
|
|
65
|
+
return true;
|
|
66
|
+
for (const ref of r.refs) {
|
|
67
|
+
const address = parseChronicleAddress(ref);
|
|
68
|
+
if (!address)
|
|
69
|
+
continue;
|
|
70
|
+
if (address.folder && episode.folder) {
|
|
71
|
+
if (address.folder === episode.folder)
|
|
72
|
+
return true;
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
if (byNumber(address.number))
|
|
76
|
+
return true;
|
|
77
|
+
}
|
|
78
|
+
return false;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* The comments on one episode, from the folded ledger (`current()`), in order
|
|
82
|
+
* of media file, then position, then time. A comment on the whole episode
|
|
83
|
+
* comes before the comments at a position.
|
|
84
|
+
*/
|
|
85
|
+
export function commentsOf(records, episode, filter = {}) {
|
|
86
|
+
const out = [];
|
|
87
|
+
for (const r of records) {
|
|
88
|
+
if (!isComment(r))
|
|
89
|
+
continue;
|
|
90
|
+
const anchor = anchorOf(r);
|
|
91
|
+
if (!namesEpisode(r, anchor, episode))
|
|
92
|
+
continue;
|
|
93
|
+
if (filter.person_id && r.actor.person_id !== filter.person_id)
|
|
94
|
+
continue;
|
|
95
|
+
if (filter.media && !(anchor?.media && sameMedia(anchor.media, filter.media)))
|
|
96
|
+
continue;
|
|
97
|
+
if (filter.from_seconds !== undefined && !(anchor?.at_seconds != null && anchor.at_seconds >= filter.from_seconds))
|
|
98
|
+
continue;
|
|
99
|
+
if (filter.to_seconds !== undefined && !(anchor?.at_seconds != null && anchor.at_seconds <= filter.to_seconds))
|
|
100
|
+
continue;
|
|
101
|
+
out.push(commentOf(r));
|
|
102
|
+
}
|
|
103
|
+
// By the file's own name, so a Space's bare name and the listed path of one file read as one sequence.
|
|
104
|
+
const name = (media) => media.slice(media.lastIndexOf("/") + 1);
|
|
105
|
+
const key = (c) => [c.anchor?.media ? name(c.anchor.media) : "", c.anchor?.at_seconds ?? -1];
|
|
106
|
+
return out.sort((a, b) => {
|
|
107
|
+
const [am, ap] = key(a);
|
|
108
|
+
const [bm, bp] = key(b);
|
|
109
|
+
return am < bm ? -1 : am > bm ? 1 : ap - bp || (a.at < b.at ? -1 : a.at > b.at ? 1 : 0);
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
/** 105 → "1:45", 3725 → "1:02:05". */
|
|
113
|
+
export function formatPosition(seconds) {
|
|
114
|
+
const whole = Math.floor(seconds);
|
|
115
|
+
const h = Math.floor(whole / 3600);
|
|
116
|
+
const m = Math.floor((whole % 3600) / 60);
|
|
117
|
+
const s = whole % 60;
|
|
118
|
+
return h > 0 ? `${h}:${String(m).padStart(2, "0")}:${String(s).padStart(2, "0")}` : `${m}:${String(s).padStart(2, "0")}`;
|
|
119
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,8 @@ export { identifyThroughMiadi, MiadiUnavailable, type MiadiPerson, type ApiTier
|
|
|
4
4
|
export { MiadiOAuthProvider, SCOPES, SCOPE_READ, SCOPE_CONTRIBUTE, type Person } from "./oauth.js";
|
|
5
5
|
export { CIRCLES, CIRCLE_IDS, CLAIM_CATEGORIES, DOMAINS, HANDOFF_STATES, RECORD_KINDS, current, type ConnectorRecord, type CircleId, type ClaimCategory, type RecordKind, } from "./records.js";
|
|
6
6
|
export { TOOL_STATUS, githubGetter, steeringTransport } from "./tools.js";
|
|
7
|
+
export { cites, parseChronicleAddress, refMatcher, sameRef, type ChronicleAddress } from "./refs.js";
|
|
8
|
+
export { SPACE_COMMENT_KEY, anchorOf, commentOf, commentsOf, formatPosition, isComment, sameMedia, type CircleTurn, type CommentAnchor, type CommentEpisode, type CommentFilter, type EpisodeComment, } from "./comments.js";
|
|
7
9
|
export { factoryLedgerPath, readFactoryReceipts, receiptsForRecord, recordsForSession, type FactoryReceipt } from "./factory-receipt.js";
|
|
8
10
|
export { classifyOutput, missionResult, type GithubAnswer, type GithubGet, type MissionOutput, type MissionResult, type OutputCheck, type ResultSubmission, } from "./mission-result.js";
|
|
9
11
|
export { runBrief, readQueueState } from "./approve.js";
|
package/dist/index.js
CHANGED
|
@@ -4,6 +4,8 @@ export { identifyThroughMiadi, MiadiUnavailable } from "./people.js";
|
|
|
4
4
|
export { MiadiOAuthProvider, SCOPES, SCOPE_READ, SCOPE_CONTRIBUTE } from "./oauth.js";
|
|
5
5
|
export { CIRCLES, CIRCLE_IDS, CLAIM_CATEGORIES, DOMAINS, HANDOFF_STATES, RECORD_KINDS, current, } from "./records.js";
|
|
6
6
|
export { TOOL_STATUS, githubGetter, steeringTransport } from "./tools.js";
|
|
7
|
+
export { cites, parseChronicleAddress, refMatcher, sameRef } from "./refs.js";
|
|
8
|
+
export { SPACE_COMMENT_KEY, anchorOf, commentOf, commentsOf, formatPosition, isComment, sameMedia, } from "./comments.js";
|
|
7
9
|
export { factoryLedgerPath, readFactoryReceipts, receiptsForRecord, recordsForSession } from "./factory-receipt.js";
|
|
8
10
|
export { classifyOutput, missionResult, } from "./mission-result.js";
|
|
9
11
|
export { runBrief, readQueueState } from "./approve.js";
|
package/dist/refs.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface ChronicleAddress {
|
|
2
|
+
/** The episode's number: from a numeric form, or from the folder's own name. */
|
|
3
|
+
number: number | null;
|
|
4
|
+
/** The folder, when the address names the episode by it. */
|
|
5
|
+
folder: string | null;
|
|
6
|
+
/** What follows the episode (a file path, a query, a fragment), as written. */
|
|
7
|
+
rest: string;
|
|
8
|
+
}
|
|
9
|
+
/** A chronicle address as the episode it names and what follows; null for any other reference. */
|
|
10
|
+
export declare function parseChronicleAddress(ref: string): ChronicleAddress | null;
|
|
11
|
+
/**
|
|
12
|
+
* A test for "this reference names the same thing as `ref`". Two folders are
|
|
13
|
+
* compared as folders, because numbers collide and the folder is the key.
|
|
14
|
+
* A number and a folder agree when the folder carries that number.
|
|
15
|
+
*/
|
|
16
|
+
export declare function refMatcher(ref: string): (other: string) => boolean;
|
|
17
|
+
export declare function sameRef(a: string, b: string): boolean;
|
|
18
|
+
/** True when a record cites `ref`, in what it is about or in its evidence. */
|
|
19
|
+
export declare function cites(record: {
|
|
20
|
+
refs: readonly string[];
|
|
21
|
+
evidence_refs: readonly string[];
|
|
22
|
+
}, ref: string | ((other: string) => boolean)): boolean;
|
package/dist/refs.js
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One comparison of references, for every read (jgwill/Miadi#1093; W1 and C1 of
|
|
3
|
+
* rispecs/episode-participants/SPEC.md).
|
|
4
|
+
*
|
|
5
|
+
* The ledger keeps a reference as its author wrote it, and one episode has
|
|
6
|
+
* several written forms: `miadi-chronicle://92`, `miadi-chronicle://092`,
|
|
7
|
+
* `miadi-chronicle:92`, `chronicle:<folder>`. Miadi reads them as one episode
|
|
8
|
+
* (`matchSegment` in @miadi/inquiry-weave's chronicle-dsl). A read here does the
|
|
9
|
+
* same: a chronicle address is compared by the episode it names and by what
|
|
10
|
+
* follows the episode, never by its spelling. Every other reference is
|
|
11
|
+
* compared as written. Nothing in the ledger is rewritten.
|
|
12
|
+
*/
|
|
13
|
+
import { episodeNumberOf } from "./episode-files.js";
|
|
14
|
+
const CHRONICLE = /^(?:miadi-chronicle|chronicle):(?:\/\/)?([^/?#\s]+)\/?(\S*)$/i;
|
|
15
|
+
/** The numeric forms Miadi's file door takes: 92, 092, ep92, episode-092. */
|
|
16
|
+
const NUMBERED = /^(?:ep(?:isode)?[-_]?)?0*(\d{1,5})$/i;
|
|
17
|
+
/** A chronicle address as the episode it names and what follows; null for any other reference. */
|
|
18
|
+
export function parseChronicleAddress(ref) {
|
|
19
|
+
const m = CHRONICLE.exec(ref.trim());
|
|
20
|
+
if (!m)
|
|
21
|
+
return null;
|
|
22
|
+
const head = m[1];
|
|
23
|
+
const rest = m[2].replace(/\/$/, "");
|
|
24
|
+
const numbered = NUMBERED.exec(head);
|
|
25
|
+
if (numbered)
|
|
26
|
+
return { number: Number.parseInt(numbered[1], 10), folder: null, rest };
|
|
27
|
+
return { number: episodeNumberOf(head), folder: head, rest };
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* A test for "this reference names the same thing as `ref`". Two folders are
|
|
31
|
+
* compared as folders, because numbers collide and the folder is the key.
|
|
32
|
+
* A number and a folder agree when the folder carries that number.
|
|
33
|
+
*/
|
|
34
|
+
export function refMatcher(ref) {
|
|
35
|
+
const wanted = parseChronicleAddress(ref);
|
|
36
|
+
if (!wanted)
|
|
37
|
+
return (other) => other === ref;
|
|
38
|
+
return (other) => {
|
|
39
|
+
if (other === ref)
|
|
40
|
+
return true;
|
|
41
|
+
const found = parseChronicleAddress(other);
|
|
42
|
+
if (!found || found.rest !== wanted.rest)
|
|
43
|
+
return false;
|
|
44
|
+
if (wanted.folder && found.folder)
|
|
45
|
+
return wanted.folder === found.folder;
|
|
46
|
+
return wanted.number !== null && wanted.number === found.number;
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
export function sameRef(a, b) {
|
|
50
|
+
return refMatcher(a)(b);
|
|
51
|
+
}
|
|
52
|
+
/** True when a record cites `ref`, in what it is about or in its evidence. */
|
|
53
|
+
export function cites(record, ref) {
|
|
54
|
+
const is = typeof ref === "string" ? refMatcher(ref) : ref;
|
|
55
|
+
return record.refs.some(is) || record.evidence_refs.some(is);
|
|
56
|
+
}
|
package/dist/tools.js
CHANGED
|
@@ -30,6 +30,8 @@ import { authorizationReceipt, authorizeProvider, CHOICE_PROVIDERS, isPersonId,
|
|
|
30
30
|
import { candidatesFor, CRITICALITIES, jevAdapter, modelPreflight, PREFLIGHT_CONTRACT, PREFLIGHT_VERSION, TASK_TYPES, } from "./model-preflight.js";
|
|
31
31
|
import { ShelfRefusal, listShelfArtefacts, readShelfArtefact } from "./research-shelf.js";
|
|
32
32
|
import { isShareRelation, shareTarget } from "./record-shares.js";
|
|
33
|
+
import { cites, parseChronicleAddress, refMatcher } from "./refs.js";
|
|
34
|
+
import { commentOf, commentsOf, formatPosition, isComment, sameMedia } from "./comments.js";
|
|
33
35
|
import { DELIVERY_STATES, readSteerDelivery, revokeInInbox, settlementOf, transcriptPathOf } from "./runtime-steer.js";
|
|
34
36
|
import { ADAPTERS, readFactoryConfig, runSteering, STEERING_CONTRACT_ID, steeringSupport } from "./steering-adapters.js";
|
|
35
37
|
import { checkGrant, isBusy, steerAttempts, steeringGrantOf, steeringRevoked, steerSession } from "./steer.js";
|
|
@@ -293,16 +295,18 @@ export function registerTools(server, ctx) {
|
|
|
293
295
|
return { person_id: person.id, name: person.name, client_id: auth.clientId, ...(client?.client_name ? { client_name: client.client_name } : {}) };
|
|
294
296
|
};
|
|
295
297
|
const approvalUrl = (id) => `${config.publicUrl}/approve/${encodeURIComponent(id)}`;
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
r.idempotency_key ===
|
|
298
|
+
/** The record this person already made with this key, which the same key hands back instead of a duplicate. */
|
|
299
|
+
const priorOf = (kind, person, key) => key
|
|
300
|
+
? // A request already decided (approved, declined, sent back) is not handed back: the same key makes a new one.
|
|
301
|
+
all().find((r) => r.kind === kind &&
|
|
302
|
+
r.idempotency_key === key &&
|
|
301
303
|
r.actor.person_id === person.id &&
|
|
302
|
-
(r.approval_state === undefined || r.approval_state === "awaiting_approval" || r.approval_state === "not_required"))
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
304
|
+
(r.approval_state === undefined || r.approval_state === "awaiting_approval" || r.approval_state === "not_required"))
|
|
305
|
+
: undefined;
|
|
306
|
+
const append = (kind, person, auth, fields) => {
|
|
307
|
+
const prior = priorOf(kind, person, fields.idempotency_key);
|
|
308
|
+
if (prior)
|
|
309
|
+
return prior;
|
|
306
310
|
return ledger.append({
|
|
307
311
|
id: newRecordId(kind),
|
|
308
312
|
kind,
|
|
@@ -393,7 +397,11 @@ export function registerTools(server, ctx) {
|
|
|
393
397
|
};
|
|
394
398
|
};
|
|
395
399
|
const uploads = new ResearchUploads(join(config.stateDir, "uploads"));
|
|
396
|
-
|
|
400
|
+
/** The records that cite a reference. An episode's address is compared by the episode it names, whatever its written form (./refs.ts, jgwill/Miadi#1093). */
|
|
401
|
+
const touching = (ref) => {
|
|
402
|
+
const is = refMatcher(ref);
|
|
403
|
+
return records().filter((r) => cites(r, is) || r.id === ref);
|
|
404
|
+
};
|
|
397
405
|
/** The factory runner's delivery receipts, read fresh: operator data, for the write tier only. */
|
|
398
406
|
const receipts = () => readFactoryReceipts(factoryLedgerPath(ctx.factoryDir ?? defaultFactoryDir()));
|
|
399
407
|
/** The Claude Code models this host permits, and the one it falls back to (jgwill/Miadi#943). */
|
|
@@ -769,6 +777,113 @@ export function registerTools(server, ctx) {
|
|
|
769
777
|
count: docs.length,
|
|
770
778
|
};
|
|
771
779
|
};
|
|
780
|
+
// ── the comments of an episode (jgwill/Miadi#1093, rispecs/episode-participants) ──
|
|
781
|
+
/** Who reads a published comment, in words (D2's recommendation: what the ledger gives today). */
|
|
782
|
+
const COMMENT_READERS = "Every person signed in to Miadi who may open this episode reads it, on the episode's page and through this connector. A visitor does not.";
|
|
783
|
+
/**
|
|
784
|
+
* One episode as Miadi resolves it for this person: its folder (the key), its number, the address
|
|
785
|
+
* this connector emits for it, its page and its media files. Any written form names the same
|
|
786
|
+
* episode, and Miadi answers its own 404 for an episode the person may not open.
|
|
787
|
+
*/
|
|
788
|
+
const episodeFor = async (person, episode) => {
|
|
789
|
+
const listing = await miadi.get(person.token, `/api/chronicle/episodes/${checkedEpisodeRef(episode)}/files`);
|
|
790
|
+
const folder = typeof listing?.episode?.path === "string" ? listing.episode.path : null;
|
|
791
|
+
if (!folder)
|
|
792
|
+
throw new ToolRefusal("not_found", `No episode answers to ${episode}.`);
|
|
793
|
+
const number = typeof listing.episode.number === "number" ? listing.episode.number : episodeNumberOf(folder);
|
|
794
|
+
return {
|
|
795
|
+
folder,
|
|
796
|
+
number,
|
|
797
|
+
title: typeof listing.episode.title === "string" ? listing.episode.title : null,
|
|
798
|
+
route: encodeURIComponent(folder),
|
|
799
|
+
ref: number === null ? `chronicle:${folder}` : `miadi-chronicle://${number}`,
|
|
800
|
+
label: number === null ? folder : `Episode ${number}`,
|
|
801
|
+
page: `${config.miadiPublicUrl}/chronicle/${encodeURIComponent(folder)}#comments`,
|
|
802
|
+
media: (Array.isArray(listing.files) ? listing.files : []).filter((f) => f?.kind === "media").map((f) => String(f.relativePath)),
|
|
803
|
+
};
|
|
804
|
+
};
|
|
805
|
+
/**
|
|
806
|
+
* A comment by a person seated in the episode's Root Circle is also a turn in its main ceremony
|
|
807
|
+
* (D12; Guillaume, 2026-11-23: "When a user comments, does that go on a talking circle for the
|
|
808
|
+
* episode? That could make sense."). It is said with the commenter's own token at the door a seated
|
|
809
|
+
* person speaks at, so Miadi applies its own seat rule, and the arrival wall shows it to the members.
|
|
810
|
+
* The comment stays the record and keeps the turn's id, so a repeated key never speaks twice.
|
|
811
|
+
* Nobody is seated and no circle is opened here. Whatever cannot happen is answered with its
|
|
812
|
+
* reason, and the comment stands.
|
|
813
|
+
*/
|
|
814
|
+
const sayInRootCircle = async (person, auth, record, episode) => {
|
|
815
|
+
try {
|
|
816
|
+
const comment = commentOf(record);
|
|
817
|
+
if (comment.circle_turn)
|
|
818
|
+
return { said: true, ...comment.circle_turn };
|
|
819
|
+
const circle = await miadi.request(person.token, "GET", `/api/chronicle/episodes/${episode.route}/circle`, undefined, 15_000);
|
|
820
|
+
const main = circle?.main;
|
|
821
|
+
const seated = Array.isArray(main?.circle?.members) && main.circle.members.some((m) => m?.person_id === person.id);
|
|
822
|
+
if (!main || !seated)
|
|
823
|
+
return { said: false, reason: `You do not sit in a Root Circle of ${episode.label}, so the comment is read on the episode's page and not in a circle.` };
|
|
824
|
+
const ceremonyId = typeof main.ceremony?.id === "string" ? main.ceremony.id : null;
|
|
825
|
+
if (!ceremonyId)
|
|
826
|
+
return { said: false, reason: `${main.circle.name ?? "The Root Circle"} has no open ceremony to speak in.` };
|
|
827
|
+
const at = comment.anchor?.at_seconds ?? null;
|
|
828
|
+
const where = [episode.ref, comment.anchor?.media ? `${comment.anchor.media}${at === null ? "" : ` at ${formatPosition(at)}`}` : null].filter(Boolean).join(" · ");
|
|
829
|
+
const answer = await miadi.post(person.token, `/api/ceremony/${encodeURIComponent(ceremonyId)}/turns`, {
|
|
830
|
+
said: [comment.text, where, record.id].join("\n\n"),
|
|
831
|
+
title: `${person.name} comments on ${episode.label}`.slice(0, 120),
|
|
832
|
+
});
|
|
833
|
+
const beatId = typeof answer?.turn?.id === "string" ? answer.turn.id : null;
|
|
834
|
+
if (!beatId)
|
|
835
|
+
return { said: false, reason: "The circle answered without a turn." };
|
|
836
|
+
const turn = {
|
|
837
|
+
ceremony_id: ceremonyId,
|
|
838
|
+
beat_id: beatId,
|
|
839
|
+
...(typeof main.circle.id === "string" ? { circle_id: main.circle.id } : {}),
|
|
840
|
+
...(typeof main.circle.name === "string" ? { circle_name: main.circle.name } : {}),
|
|
841
|
+
at: typeof answer.turn.timestamp === "string" ? answer.turn.timestamp : new Date().toISOString(),
|
|
842
|
+
};
|
|
843
|
+
ledger.append({
|
|
844
|
+
id: newRecordId("observation"),
|
|
845
|
+
kind: "observation",
|
|
846
|
+
created_at: new Date().toISOString(),
|
|
847
|
+
actor: actorOf(person, auth),
|
|
848
|
+
refs: record.refs,
|
|
849
|
+
evidence_refs: record.evidence_refs,
|
|
850
|
+
supersedes: record.id,
|
|
851
|
+
completion_receipt: { ...(record.completion_receipt ?? {}), circle_turn: turn },
|
|
852
|
+
body: {},
|
|
853
|
+
});
|
|
854
|
+
return { said: true, ...turn };
|
|
855
|
+
}
|
|
856
|
+
catch (error) {
|
|
857
|
+
const refused = error instanceof MiadiError && error.body && typeof error.body === "object" ? error.body.error : undefined;
|
|
858
|
+
return { said: false, reason: `The Root Circle did not take the turn: ${typeof refused === "string" ? refused : asState(error).state}.` };
|
|
859
|
+
}
|
|
860
|
+
};
|
|
861
|
+
server.registerTool("list_episode_comments", {
|
|
862
|
+
title: "The comments on an episode",
|
|
863
|
+
description: "The comments people published on one Chronicle episode: each with its author, its text, when it was published and where it points (the media file and the position in seconds, when it has them), and the turn it became in the episode's Root Circle when its author sits there. Narrow it to one media file, a span of positions or one author. Ordered by media file, then position, then time. A comment is published with comment_on_episode; the comments a Space published earlier with append_observation are read too.",
|
|
864
|
+
inputSchema: {
|
|
865
|
+
episode: z.string().min(1).describe("miadi-chronicle://<n>, an episode number or its folder. Every written form names the same episode."),
|
|
866
|
+
media: z.string().max(500).optional().describe("One media file, by its path inside the episode as get_evidence lists it."),
|
|
867
|
+
from_seconds: z.number().min(0).optional(),
|
|
868
|
+
to_seconds: z.number().min(0).optional(),
|
|
869
|
+
person_id: z.string().optional().describe("Only this person's comments."),
|
|
870
|
+
limit: z.number().int().min(1).max(200).optional(),
|
|
871
|
+
},
|
|
872
|
+
annotations: READ,
|
|
873
|
+
}, wrap(async (a, extra) => {
|
|
874
|
+
const { person } = who(extra);
|
|
875
|
+
const ep = await episodeFor(person, a.episode);
|
|
876
|
+
const found = commentsOf(records(), { number: ep.number, folder: ep.folder }, { media: a.media, from_seconds: a.from_seconds, to_seconds: a.to_seconds, person_id: a.person_id });
|
|
877
|
+
const comments = found.slice(0, a.limit ?? 100);
|
|
878
|
+
return {
|
|
879
|
+
episode: { ref: ep.ref, number: ep.number, folder: ep.folder, title: ep.title },
|
|
880
|
+
comments,
|
|
881
|
+
count: comments.length,
|
|
882
|
+
total: found.length,
|
|
883
|
+
shown_at: ep.page,
|
|
884
|
+
readable_by: COMMENT_READERS,
|
|
885
|
+
};
|
|
886
|
+
}));
|
|
772
887
|
const readEpisodeFile = async (person, a) => {
|
|
773
888
|
const path = a.path.trim();
|
|
774
889
|
const segments = checkRelativePath(path);
|
|
@@ -885,7 +1000,7 @@ export function registerTools(server, ctx) {
|
|
|
885
1000
|
}, wrap(async ({ episode, subject_ref }, extra) => {
|
|
886
1001
|
const { person } = who(extra);
|
|
887
1002
|
const evals = records().filter((r) => r.kind === "observation" && typeof r.body?.assessment === "string");
|
|
888
|
-
const scoped = subject_ref ? evals.filter((r) => r.refs.
|
|
1003
|
+
const scoped = subject_ref ? evals.filter((r) => r.refs.some(refMatcher(subject_ref))) : evals;
|
|
889
1004
|
return {
|
|
890
1005
|
tracing: episode ? await miadi.get(person.token, `/api/chronicle/episodes/${episodeRef(episode)}/tracing`).catch(asState) : "give an episode to read its tracing records",
|
|
891
1006
|
operational: scoped.filter((r) => r.body.assessment === "operational"),
|
|
@@ -1011,8 +1126,10 @@ export function registerTools(server, ctx) {
|
|
|
1011
1126
|
}, wrap(async ({ ref, circle: c, state }, extra) => {
|
|
1012
1127
|
who(extra);
|
|
1013
1128
|
let list = records().filter((r) => r.kind === "handoff" || r.kind === "source_intent");
|
|
1014
|
-
if (ref)
|
|
1015
|
-
|
|
1129
|
+
if (ref) {
|
|
1130
|
+
const is = refMatcher(ref);
|
|
1131
|
+
list = list.filter((r) => r.id === ref || cites(r, is));
|
|
1132
|
+
}
|
|
1016
1133
|
if (c)
|
|
1017
1134
|
list = list.filter((r) => r.to_circle === c || r.circle === c);
|
|
1018
1135
|
if (state)
|
|
@@ -1026,7 +1143,7 @@ export function registerTools(server, ctx) {
|
|
|
1026
1143
|
inputSchema: {
|
|
1027
1144
|
kind: z.string().optional(),
|
|
1028
1145
|
circle: circle.optional(),
|
|
1029
|
-
ref: z.string().optional(),
|
|
1146
|
+
ref: z.string().optional().describe("A reference the records cite. An episode's address finds them under any written form: miadi-chronicle://92 and miadi-chronicle://092 name one episode."),
|
|
1030
1147
|
person_id: z.string().optional(),
|
|
1031
1148
|
limit: z.number().int().min(1).max(200).optional(),
|
|
1032
1149
|
},
|
|
@@ -1038,8 +1155,10 @@ export function registerTools(server, ctx) {
|
|
|
1038
1155
|
list = list.filter((r) => r.kind === a.kind);
|
|
1039
1156
|
if (a.circle)
|
|
1040
1157
|
list = list.filter((r) => r.circle === a.circle || r.to_circle === a.circle);
|
|
1041
|
-
if (a.ref)
|
|
1042
|
-
|
|
1158
|
+
if (a.ref) {
|
|
1159
|
+
const is = refMatcher(a.ref);
|
|
1160
|
+
list = list.filter((r) => cites(r, is));
|
|
1161
|
+
}
|
|
1043
1162
|
if (a.person_id)
|
|
1044
1163
|
list = list.filter((r) => r.actor.person_id === a.person_id);
|
|
1045
1164
|
const out = list.reverse().slice(0, a.limit ?? 50);
|
|
@@ -1353,7 +1472,7 @@ export function registerTools(server, ctx) {
|
|
|
1353
1472
|
};
|
|
1354
1473
|
server.registerTool("append_observation", {
|
|
1355
1474
|
title: "Record an observation",
|
|
1356
|
-
description: "Record what was observed (or hypothesised, desired, imagined) about a source, in your name, with its claim category and the circle it concerns. Fiction and desired futures stay labelled as such.",
|
|
1475
|
+
description: "Record what was observed (or hypothesised, desired, imagined) about a source, in your name, with its claim category and the circle it concerns. Fiction and desired futures stay labelled as such. To comment on a Chronicle episode at a moment of its media, use comment_on_episode.",
|
|
1357
1476
|
inputSchema: {
|
|
1358
1477
|
text: z.string().min(1).max(20000),
|
|
1359
1478
|
claim_category: claim,
|
|
@@ -1368,7 +1487,7 @@ export function registerTools(server, ctx) {
|
|
|
1368
1487
|
}, wrap(async (a, extra) => {
|
|
1369
1488
|
const { person, auth } = who(extra);
|
|
1370
1489
|
requireContribute(auth);
|
|
1371
|
-
|
|
1490
|
+
const record = append("observation", person, auth, {
|
|
1372
1491
|
claim_category: a.claim_category,
|
|
1373
1492
|
circle: a.circle,
|
|
1374
1493
|
domain: a.domain,
|
|
@@ -1380,6 +1499,74 @@ export function registerTools(server, ctx) {
|
|
|
1380
1499
|
idempotency_key: a.idempotency_key,
|
|
1381
1500
|
body: { text: a.text },
|
|
1382
1501
|
});
|
|
1502
|
+
// A comment a Space publishes this way (./comments.ts) follows comment_on_episode's circle rule (jgwill/Miadi#1093).
|
|
1503
|
+
if (!isComment(record))
|
|
1504
|
+
return record;
|
|
1505
|
+
const address = record.refs.map(parseChronicleAddress).find((x) => x !== null);
|
|
1506
|
+
if (!address)
|
|
1507
|
+
return record;
|
|
1508
|
+
const head = address.folder ?? String(address.number);
|
|
1509
|
+
await sayInRootCircle(person, auth, record, {
|
|
1510
|
+
route: encodeURIComponent(head),
|
|
1511
|
+
ref: address.folder ? `chronicle:${address.folder}` : `miadi-chronicle://${address.number}`,
|
|
1512
|
+
label: address.number === null ? head : `Episode ${address.number}`,
|
|
1513
|
+
});
|
|
1514
|
+
return all().find((r) => r.id === record.id) ?? record;
|
|
1515
|
+
}));
|
|
1516
|
+
server.registerTool("comment_on_episode", {
|
|
1517
|
+
title: "Publish a comment on an episode",
|
|
1518
|
+
description: "Publishes a comment on one Chronicle episode, in your name: what you say about it, optionally at a position of one of its media files. It is read by every person signed in to Miadi who may open the episode, on the episode's page and with list_episode_comments. When you sit in the episode's Root Circle, it is also said there as a turn, in your name, and the circle's members see it on their arrival wall. Nothing is kept that is not published: a call either publishes the comment or refuses and writes nothing. Publish only on the person's own request to publish at Miadi.",
|
|
1519
|
+
inputSchema: {
|
|
1520
|
+
episode: z.string().min(1).describe("miadi-chronicle://<n>, an episode number or its folder. Every written form names the same episode."),
|
|
1521
|
+
text: z.string().min(1).max(20000),
|
|
1522
|
+
media: z.string().max(500).optional().describe("The media file the comment is about, by its path inside the episode as get_evidence lists it (audio/…mp3). Leave it out for a comment on the whole episode."),
|
|
1523
|
+
at_seconds: z.number().min(0).optional().describe("The position in that media file, in seconds."),
|
|
1524
|
+
until_seconds: z.number().min(0).optional().describe("The end of the span, when the comment is about more than a moment."),
|
|
1525
|
+
claim_category: claim.optional().describe("observed (the default), hypothesis, desired_future, fiction or verified_implementation."),
|
|
1526
|
+
...base,
|
|
1527
|
+
},
|
|
1528
|
+
annotations: WRITE,
|
|
1529
|
+
}, wrap(async (a, extra) => {
|
|
1530
|
+
const { person, auth } = who(extra);
|
|
1531
|
+
requireContribute(auth);
|
|
1532
|
+
const ep = await episodeFor(person, a.episode);
|
|
1533
|
+
let media = null;
|
|
1534
|
+
if (a.media !== undefined) {
|
|
1535
|
+
const named = String(a.media).trim();
|
|
1536
|
+
checkRelativePath(named);
|
|
1537
|
+
const found = ep.media.filter((path) => sameMedia(path, named));
|
|
1538
|
+
if (found.length !== 1) {
|
|
1539
|
+
throw new ToolRefusal("invalid_path", found.length ? `${named} names ${found.length} media files of ${ep.label}. Give the whole path of one.` : `${named} is not a media file of ${ep.label}.`, { media: ep.media });
|
|
1540
|
+
}
|
|
1541
|
+
media = found[0];
|
|
1542
|
+
}
|
|
1543
|
+
const seconds = (v) => (typeof v === "number" ? Math.round(v * 1000) / 1000 : null);
|
|
1544
|
+
const at = seconds(a.at_seconds);
|
|
1545
|
+
const until = seconds(a.until_seconds);
|
|
1546
|
+
if (at !== null && !media)
|
|
1547
|
+
throw new ToolRefusal("invalid_position", "A position is a moment of one media file: name the file in media. A comment on the whole episode has neither.", { media: ep.media });
|
|
1548
|
+
if (until !== null && (at === null || until <= at))
|
|
1549
|
+
throw new ToolRefusal("invalid_position", "until_seconds ends a span that at_seconds starts, and is greater than it.");
|
|
1550
|
+
const repeated = Boolean(priorOf("observation", person, a.idempotency_key));
|
|
1551
|
+
const record = append("observation", person, auth, {
|
|
1552
|
+
claim_category: a.claim_category ?? "observed",
|
|
1553
|
+
refs: [ep.ref],
|
|
1554
|
+
intention: a.intention,
|
|
1555
|
+
role: a.role,
|
|
1556
|
+
idempotency_key: a.idempotency_key,
|
|
1557
|
+
body: { text: a.text, anchor: { episode: { folder: ep.folder, number: ep.number }, media, at_seconds: at, until_seconds: until } },
|
|
1558
|
+
});
|
|
1559
|
+
const circle_turn = await sayInRootCircle(person, auth, record, ep);
|
|
1560
|
+
const stored = all().find((r) => r.id === record.id) ?? record;
|
|
1561
|
+
return {
|
|
1562
|
+
published: true,
|
|
1563
|
+
...(repeated ? { repeated: true, note: "This key was already published. This is that comment; nothing new was written." } : {}),
|
|
1564
|
+
record: stored,
|
|
1565
|
+
comment: commentOf(stored),
|
|
1566
|
+
shows_at: ep.page,
|
|
1567
|
+
readable_by: COMMENT_READERS,
|
|
1568
|
+
circle_turn,
|
|
1569
|
+
};
|
|
1383
1570
|
}));
|
|
1384
1571
|
server.registerTool("open_inquiry", {
|
|
1385
1572
|
title: "Open an inquiry",
|
|
@@ -2987,6 +3174,8 @@ export const TOOL_STATUS = {
|
|
|
2987
3174
|
search: "live",
|
|
2988
3175
|
fetch: "live",
|
|
2989
3176
|
append_observation: "live, contribute",
|
|
3177
|
+
list_episode_comments: "live (the comments published on one episode, by media file and position; any written form of the episode's address)",
|
|
3178
|
+
comment_on_episode: "live, contribute (publishes a comment in your name on an episode, at a position of a media file when given; when you sit in the episode's Root Circle it is also said there as a turn)",
|
|
2990
3179
|
open_inquiry: "live, contribute",
|
|
2991
3180
|
link_records: "live, contribute",
|
|
2992
3181
|
propose_narrative_beat: "live, contribute",
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const VERSION = "0.1.
|
|
1
|
+
export declare const VERSION = "0.1.41";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const VERSION = "0.1.
|
|
1
|
+
export const VERSION = "0.1.41";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@miadi/connector",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.41",
|
|
4
4
|
"description": "The Miadi connector: one remote MCP service through which a person signed in with their Miadi person token, from ChatGPT or any MCP client, reads sessions, reviews, episodes and circles and records observations, inquiries, handoffs and proposals with their name on each record.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Miadi",
|
|
@@ -40,6 +40,14 @@
|
|
|
40
40
|
"types": "./dist/record-shares.d.ts",
|
|
41
41
|
"import": "./dist/record-shares.js"
|
|
42
42
|
},
|
|
43
|
+
"./comments": {
|
|
44
|
+
"types": "./dist/comments.d.ts",
|
|
45
|
+
"import": "./dist/comments.js"
|
|
46
|
+
},
|
|
47
|
+
"./refs": {
|
|
48
|
+
"types": "./dist/refs.d.ts",
|
|
49
|
+
"import": "./dist/refs.js"
|
|
50
|
+
},
|
|
43
51
|
"./package.json": "./package.json"
|
|
44
52
|
},
|
|
45
53
|
"bin": {
|
|
@@ -53,9 +61,9 @@
|
|
|
53
61
|
"dependencies": {
|
|
54
62
|
"@miadi/hooks-core": "^0.6.2",
|
|
55
63
|
"@miadi/hooks-gateway": "^0.2.1",
|
|
56
|
-
"@miadi/inquiry-weave": "0.
|
|
64
|
+
"@miadi/inquiry-weave": "0.19.1",
|
|
57
65
|
"@miadi/node-service-kit": "0.1.2",
|
|
58
|
-
"@miadi/relational-git-repository-mapper": "^0.
|
|
66
|
+
"@miadi/relational-git-repository-mapper": "^0.8.0",
|
|
59
67
|
"@modelcontextprotocol/sdk": "^1.30.0",
|
|
60
68
|
"express": "^5.2.1",
|
|
61
69
|
"express-rate-limit": "^8.2.1",
|