@miadi/connector 0.1.21 → 0.1.23

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/dist/tools.js CHANGED
@@ -37,6 +37,18 @@ import { canReadReading, readingOwner } from "./reading/privacy.js";
37
37
  import { artefactVisibility, readArtefactWeave, saveResearchArtefact } from "@miadi/inquiry-weave";
38
38
  import { ResearchUploads, UploadRefusal } from "./uploads.js";
39
39
  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";
40
+ /** Which standard judges a mission now, and whether Jev takes part; no key value is read into it. */
41
+ async function standardStatus(service) {
42
+ const standard = await service.standard();
43
+ return {
44
+ name: standard.name,
45
+ version: standard.version,
46
+ source: standard.source,
47
+ ...(standard.note ? { note: standard.note } : {}),
48
+ aspects: standard.aspects.map((a) => ({ code: a.code, name: a.name, requires: a.requires, settled_by: a.settled_by })),
49
+ jev: service.jevConfigured ? "configured" : "unconfigured",
50
+ };
51
+ }
40
52
  class ToolRefusal extends Error {
41
53
  code;
42
54
  detail;
@@ -101,6 +113,8 @@ const primaryIssue = z
101
113
  .regex(/^[\w.-]+\/[\w.-]+#\d+$/)
102
114
  .optional()
103
115
  .describe("owner/repo#n: the one issue this mission implements. Other refs stay related. Without it, mission_status can only infer the mission from the first issue in refs (jgwill/Miadi#913).");
116
+ const deliveryField = z.string().min(1).max(500).optional().describe("The one exact place the result lands: a path, a branch, a pull request, an issue, a review or an episode. Not a kind of place or a choice among places (jgwill/Miadi#939).");
117
+ const personWordsField = z.string().min(1).max(4000).optional().describe("The person's own words, verbatim from your conversation, for any rule, correction or decision the mission credits to them. The person reads them on the card and the worker reads them in the brief.");
104
118
  /** Refs with the declared primary issue first, never duplicated. */
105
119
  function withPrimary(refs, primary) {
106
120
  return primary ? [primary, ...refs.filter((r) => r !== primary)] : refs;
@@ -255,6 +269,10 @@ export function registerTools(server, ctx) {
255
269
  ...fields,
256
270
  });
257
271
  };
272
+ /** A person's standing preferences are read by that person and by the write tier. */
273
+ const reviewShownTo = (review, r, reader) => review ? (reader.api_tier === "write" || r.actor.person_id === reader.id ? review : { ...review, preferences: [] }) : null;
274
+ /** The report for a mission's current version; a failure here never refuses the request (jgwill/Miadi#939). */
275
+ const draftReviewOf = async (r) => ctx.draftReview ? ctx.draftReview.review(all().find((x) => x.id === r.id) ?? r, all()) : { state: "unavailable", message: "This connector runs no draft review." };
258
276
  /**
259
277
  * A forwarded steer's record moves when the runtime's evidence moves: done once the model has it,
260
278
  * stopped once it never will. The ledger then agrees with its delivery on every surface that reads it
@@ -371,6 +389,7 @@ export function registerTools(server, ctx) {
371
389
  ledger: "connector ledger (append-only, /srv/miadi/connector)",
372
390
  },
373
391
  tools: TOOL_STATUS,
392
+ mission_standard: ctx.draftReview ? await standardStatus(ctx.draftReview) : { state: "unavailable" },
374
393
  // Registered is not operational: whether a steer can reach a pane on this host now (jgwill/Miadi#909).
375
394
  steering: { ...steeringTransport(ctx.tmux), runtime_route: ctx.steeringRuntime ? "configured" : "not_configured", contract: STEERING_CONTRACT },
376
395
  foundation_read: {
@@ -828,6 +847,7 @@ export function registerTools(server, ctx) {
828
847
  ...(r.kind === "session_steer_request" && ctx.steeringRuntime && person.api_tier === "write" ? { delivery: readSteerDelivery(ctx.steeringRuntime, all().find((x) => x.id === r.id) ?? r) ?? undefined } : {}),
829
848
  // Where the request stands, in the words every surface uses (jgwill/Miadi#889).
830
849
  projection: requestProjection(r, { reviewBase: ctx.approval?.config.reviewUrl, factoryDir: ctx.factoryDir }),
850
+ ...(r.kind === "run_request" || r.kind === "work_proposal" ? { draft_review: reviewShownTo(ctx.draftReview?.stored(r), r, person) } : {}),
831
851
  ...(r.approval_state === "revision_requested"
832
852
  ? { revision: { instructions: r.completion_receipt?.instructions, next: `Revise it in place: revise_pending_request with request_id ${r.id} and expected_version ${versionOf(r)}.` } }
833
853
  : {}),
@@ -1291,6 +1311,8 @@ export function registerTools(server, ctx) {
1291
1311
  refs,
1292
1312
  primary_issue: primaryIssue,
1293
1313
  repo: z.string().max(120).optional(),
1314
+ delivery: deliveryField,
1315
+ person_words: personWordsField,
1294
1316
  ...base,
1295
1317
  },
1296
1318
  annotations: WRITE,
@@ -1305,9 +1327,16 @@ export function registerTools(server, ctx) {
1305
1327
  idempotency_key: a.idempotency_key,
1306
1328
  state: "pending",
1307
1329
  approval_state: "awaiting_approval",
1308
- body: { title: a.title, desired_outcome: a.desired_outcome, repo: a.repo, ...(a.primary_issue ? { primary_issue: a.primary_issue } : {}) },
1330
+ body: {
1331
+ title: a.title,
1332
+ desired_outcome: a.desired_outcome,
1333
+ repo: a.repo,
1334
+ ...(a.primary_issue ? { primary_issue: a.primary_issue } : {}),
1335
+ ...(a.delivery ? { delivery: a.delivery } : {}),
1336
+ ...(a.person_words ? { person_words: a.person_words } : {}),
1337
+ },
1309
1338
  });
1310
- return { ...r, approval_url: approvalUrl(r.id) };
1339
+ return { ...r, approval_url: approvalUrl(r.id), draft_review: await draftReviewOf(r) };
1311
1340
  }));
1312
1341
  server.registerTool("prepare_calendar_event", {
1313
1342
  title: "Draft a calendar event",
@@ -1474,10 +1503,12 @@ export function registerTools(server, ctx) {
1474
1503
  title: "Request a bounded agent run",
1475
1504
  description: "Ask for an agent session to do one bounded task. The request waits for a person with Miadi's write tier to approve it on the returned approval_url; once approved, a brief is queued for the factory intake, which opens or reaches the session within minutes. Read it back with get_run_result. This is for a new mission only: to change a request that still awaits a decision, call revise_pending_request with its id, so the person keeps one card to decide.",
1476
1505
  inputSchema: {
1477
- task: z.string().min(1).max(12000).describe("What the session does and what it returns."),
1506
+ task: z.string().min(1).max(12000).describe("What the session does and what it returns. State the result that will exist rather than the mechanism, unless the person asked for the mechanism."),
1478
1507
  circle,
1479
1508
  refs,
1480
1509
  primary_issue: primaryIssue,
1510
+ delivery: deliveryField,
1511
+ person_words: personWordsField,
1481
1512
  session: z.string().regex(/^[A-Za-z0-9._-]{3,80}$/).optional().describe("An existing tmux session to hand it to, or a name for a new one."),
1482
1513
  cwd: z.string().max(300).optional().describe("Working folder for a new session (default: the factory runner's defaultCwd on the host)."),
1483
1514
  provider: z
@@ -1520,12 +1551,15 @@ export function registerTools(server, ctx) {
1520
1551
  provider: a.provider,
1521
1552
  resolved_provider: resolution.provider.id,
1522
1553
  ...(a.primary_issue ? { primary_issue: a.primary_issue } : {}),
1554
+ ...(a.delivery ? { delivery: a.delivery } : {}),
1555
+ ...(a.person_words ? { person_words: a.person_words } : {}),
1523
1556
  ...(a.steering ? { steering: a.steering } : {}),
1524
1557
  },
1525
1558
  });
1526
1559
  const authorization = providerAuthorizationOf(all().find((x) => x.id === r.id) ?? r);
1527
1560
  return {
1528
1561
  ...r,
1562
+ draft_review: await draftReviewOf(r),
1529
1563
  provider: {
1530
1564
  requested: a.provider ?? null,
1531
1565
  resolved: resolution.provider.id,
@@ -1571,6 +1605,8 @@ export function registerTools(server, ctx) {
1571
1605
  circle: circle.optional(),
1572
1606
  refs: z.array(z.string()).max(50).optional().describe("The whole new list of refs, replacing the old one."),
1573
1607
  primary_issue: primaryIssue,
1608
+ delivery: deliveryField,
1609
+ person_words: personWordsField,
1574
1610
  session: z.string().regex(/^[A-Za-z0-9._-]{3,80}$/).optional(),
1575
1611
  cwd: z.string().max(300).optional(),
1576
1612
  provider: z.enum(["codex", "pi", "copilot", "claude"]).optional().describe("Verified installed on the connector host again, as request_authorized_run does."),
@@ -1619,6 +1655,9 @@ export function registerTools(server, ctx) {
1619
1655
  }
1620
1656
  if (c.primary_issue !== undefined)
1621
1657
  body.primary_issue = c.primary_issue;
1658
+ for (const k of ["delivery", "person_words"])
1659
+ if (c[k] !== undefined)
1660
+ body[k] = c[k];
1622
1661
  const nextRefs = withPrimary(c.refs ?? live?.refs ?? [], c.primary_issue ?? body.primary_issue);
1623
1662
  let record;
1624
1663
  try {
@@ -1643,6 +1682,7 @@ export function registerTools(server, ctx) {
1643
1682
  const revisedAuthorization = providerAuthorizationOf(all().find((x) => x.id === (record.supersedes ?? record.id)));
1644
1683
  return {
1645
1684
  ...revisionOut(record.supersedes ? { ...record, id: record.supersedes } : record),
1685
+ draft_review: await draftReviewOf(all().find((x) => x.id === (record.supersedes ?? record.id)) ?? record),
1646
1686
  revised: record.revision,
1647
1687
  ...(provider ? { provider } : {}),
1648
1688
  ...(revisedAuthorization ? { provider_authorization: authorizationOut(revisedAuthorization) } : {}),
@@ -2252,6 +2292,13 @@ export function registerTools(server, ctx) {
2252
2292
  intention: r.intention,
2253
2293
  consequence: consequenceOf(r, providerAuthorizationOf(r)),
2254
2294
  detail: detailOf(r),
2295
+ ...(r.kind === "run_request" || r.kind === "work_proposal"
2296
+ ? {
2297
+ delivery: r.body.delivery,
2298
+ person_words: r.body.person_words,
2299
+ draft_review: ctx.draftReview?.stored(r) ?? null,
2300
+ }
2301
+ : {}),
2255
2302
  ...(r.kind === "run_request" ? { provider_authorization: authorizationOut(providerAuthorizationOf(r)) } : {}),
2256
2303
  approval_url: approvalUrl(r.id),
2257
2304
  projection: requestProjection(r, { reviewBase: ctx.approval?.config.reviewUrl, factoryDir: ctx.factoryDir }),
@@ -2457,11 +2504,11 @@ export const TOOL_STATUS = {
2457
2504
  register_source_intent: "live, contribute",
2458
2505
  record_handoff: "live, contribute",
2459
2506
  update_handoff: "live, contribute",
2460
- propose_work: "live, contribute, needs_approval (approving starts the work as a factory run)",
2507
+ propose_work: "live, contribute, needs_approval (approving starts the work as a factory run; answers with draft_review)",
2461
2508
  prepare_calendar_event: "live, contribute (draft and .ics only)",
2462
2509
  propose_session_completion: "live, contribute, needs_approval (decision recorded, nothing closed)",
2463
- request_authorized_run: "live, contribute, needs_approval (queues a factory brief once approved; may name a verified provider and a bounded steering grant)",
2464
- revise_pending_request: "live, contribute (a waiting or sent-back run or proposal gets its next version; same id, same card)",
2510
+ request_authorized_run: "live, contribute, needs_approval (queues a factory brief once approved; may name a verified provider and a bounded steering grant; answers with draft_review)",
2511
+ revise_pending_request: "live, contribute (a waiting or sent-back run or proposal gets its next version; same id, same card; answers with draft_review)",
2465
2512
  get_request_history: "live (every version of a request, oldest first; whoever asked, or the write tier)",
2466
2513
  supersede_pending_requests: "live, contribute (retires named earlier requests still waiting and joins them as earlier versions of the one that stands)",
2467
2514
  request_session_steer: "live, contribute, write tier (one correction to a working agent, forwarded to its runtime; runs inside an approved run's steering grant, else one scoped human decision; get_capabilities.steering says whether the transport works now and which providers have an adapter)",
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const VERSION = "0.1.21";
1
+ export declare const VERSION = "0.1.23";
package/dist/version.js CHANGED
@@ -1 +1 @@
1
- export const VERSION = "0.1.21";
1
+ export const VERSION = "0.1.23";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@miadi/connector",
3
- "version": "0.1.21",
3
+ "version": "0.1.23",
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",
@@ -38,7 +38,7 @@
38
38
  "README.md"
39
39
  ],
40
40
  "dependencies": {
41
- "@miadi/inquiry-weave": "0.18.8",
41
+ "@miadi/inquiry-weave": "0.18.10",
42
42
  "@miadi/node-service-kit": "0.1.2",
43
43
  "@modelcontextprotocol/sdk": "^1.30.0",
44
44
  "express": "^5.2.1",