@mrrlin-dev/mcp 0.4.235 → 0.4.237

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.
Files changed (2) hide show
  1. package/dist/bin.cjs +112 -18
  2. package/package.json +1 -1
package/dist/bin.cjs CHANGED
@@ -17521,6 +17521,7 @@ var init_operationIds = __esm({
17521
17521
  answerIntentClarification: "answerIntentClarification",
17522
17522
  confirmIntentProposal: "confirmIntentProposal",
17523
17523
  refreshIntentProposal: "refreshIntentProposal",
17524
+ declineIntentProposal: "declineIntentProposal",
17524
17525
  getIntentConfirmation: "getIntentConfirmation",
17525
17526
  resolveAccount: "resolveAccount",
17526
17527
  linkAccountIdentity: "linkAccountIdentity",
@@ -18378,7 +18379,7 @@ var init_task_notes = __esm({
18378
18379
  });
18379
18380
 
18380
18381
  // ../../packages/schemas/dist/intent.js
18381
- var taskImpactSchema, autonomyLevelSchema, autoDeploySchema, mrrlinOperatorTranscriptMessageSchema, mrrlinOperatorTranscriptAppendSchema, mrrlinOperatorTranscriptListSchema, operatorTranscriptMessageResponseSchema, operatorTranscriptListResponseSchema, mrrlinIntentProposalStateSchema, mrrlinIntentProposalSchema, mrrlinIntentProposalCreateSchema, intentProposalResponseSchema, intentProposalMaybeResponseSchema, mrrlinIntentClarificationStateSchema, mrrlinIntentClarificationSchema, mrrlinIntentClarificationRecordSchema, mrrlinIntentClarificationAnswerSchema, intentClarificationResponseSchema, mrrlinIntentConfirmRequestSchema, mrrlinIntentConfirmResponseSchema, intentConfirmResultResponseSchema, mrrlinIntentRefreshRequestSchema, mrrlinIntentRefreshOutcomeSchema, mrrlinIntentRefreshResponseSchema, intentRefreshResultResponseSchema, mrrlinIntentConfirmationSchema, intentConfirmationMaybeResponseSchema, intentProposalListResponseSchema;
18382
+ var taskImpactSchema, autonomyLevelSchema, autoDeploySchema, mrrlinOperatorTranscriptMessageSchema, mrrlinOperatorTranscriptAppendSchema, mrrlinOperatorTranscriptListSchema, operatorTranscriptMessageResponseSchema, operatorTranscriptListResponseSchema, mrrlinIntentProposalStateSchema, mrrlinIntentProposalSchema, mrrlinIntentProposalCreateSchema, intentProposalResponseSchema, intentProposalMaybeResponseSchema, mrrlinIntentClarificationStateSchema, mrrlinIntentClarificationSchema, mrrlinIntentClarificationRecordSchema, mrrlinIntentClarificationAnswerSchema, intentClarificationResponseSchema, mrrlinIntentConfirmRequestSchema, mrrlinIntentConfirmResponseSchema, intentConfirmResultResponseSchema, mrrlinIntentRefreshRequestSchema, mrrlinIntentRefreshOutcomeSchema, mrrlinIntentRefreshResponseSchema, intentRefreshResultResponseSchema, mrrlinIntentDeclineRequestSchema, mrrlinIntentDeclineResponseSchema, intentDeclineResultResponseSchema, mrrlinIntentConfirmationSchema, intentConfirmationMaybeResponseSchema, intentProposalListStateSchema, intentProposalListResponseSchema;
18382
18383
  var init_intent = __esm({
18383
18384
  "../../packages/schemas/dist/intent.js"() {
18384
18385
  "use strict";
@@ -18537,6 +18538,28 @@ var init_intent = __esm({
18537
18538
  intentRefreshResultResponseSchema = external_exports.object({
18538
18539
  data: mrrlinIntentRefreshResponseSchema
18539
18540
  });
18541
+ mrrlinIntentDeclineRequestSchema = external_exports.object({
18542
+ expectedVersion: external_exports.number().int().min(1)
18543
+ }).strict();
18544
+ mrrlinIntentDeclineResponseSchema = external_exports.discriminatedUnion("ok", [
18545
+ external_exports.object({
18546
+ ok: external_exports.literal(true),
18547
+ already_declined: external_exports.boolean(),
18548
+ proposal_id: external_exports.string().uuid(),
18549
+ proposal_version: external_exports.number().int(),
18550
+ state: external_exports.literal("rejected")
18551
+ }),
18552
+ external_exports.object({
18553
+ ok: external_exports.literal(false),
18554
+ code: external_exports.string(),
18555
+ message: external_exports.string(),
18556
+ current_state: external_exports.string().optional(),
18557
+ current_version: external_exports.number().int().optional()
18558
+ })
18559
+ ]);
18560
+ intentDeclineResultResponseSchema = external_exports.object({
18561
+ data: mrrlinIntentDeclineResponseSchema
18562
+ });
18540
18563
  mrrlinIntentConfirmationSchema = external_exports.object({
18541
18564
  id: external_exports.string().uuid(),
18542
18565
  projectSlug: external_exports.string().min(1),
@@ -18553,6 +18576,7 @@ var init_intent = __esm({
18553
18576
  intentConfirmationMaybeResponseSchema = external_exports.object({
18554
18577
  data: mrrlinIntentConfirmationSchema.nullable()
18555
18578
  });
18579
+ intentProposalListStateSchema = external_exports.enum(["actionable", "declined"]);
18556
18580
  intentProposalListResponseSchema = external_exports.object({
18557
18581
  data: external_exports.array(mrrlinIntentProposalSchema)
18558
18582
  });
@@ -79072,8 +79096,9 @@ function createMrrlinClient(config2) {
79072
79096
  });
79073
79097
  return intentProposalResponseSchema.parse(body).data;
79074
79098
  },
79075
- async listIntentProposals(projectSlug) {
79076
- const body = await request(`${projectPath(projectSlug)}/intent/proposals`);
79099
+ async listIntentProposals(projectSlug, options) {
79100
+ const query = options?.state ? `?state=${encodeURIComponent(options.state)}` : "";
79101
+ const body = await request(`${projectPath(projectSlug)}/intent/proposals${query}`);
79077
79102
  return intentProposalListResponseSchema.parse(body).data;
79078
79103
  },
79079
79104
  async getIntentProposal(projectSlug, proposalId, version2) {
@@ -79144,6 +79169,27 @@ function createMrrlinClient(config2) {
79144
79169
  throw error51;
79145
79170
  }
79146
79171
  },
79172
+ async declineIntentProposal(projectSlug, proposalId, input) {
79173
+ try {
79174
+ const body = await request(`${projectPath(projectSlug)}/intent/proposals/${encodeURIComponent(proposalId)}/decline`, {
79175
+ method: "POST",
79176
+ headers: { "content-type": "application/json" },
79177
+ body: JSON.stringify(input)
79178
+ });
79179
+ return intentDeclineResultResponseSchema.parse(body).data;
79180
+ } catch (error51) {
79181
+ if (error51 instanceof MrrlinApiError && (error51.status === 404 || error51.status === 409)) {
79182
+ try {
79183
+ const parsed = JSON.parse(error51.responseBody);
79184
+ const refusal = mrrlinIntentDeclineResponseSchema.safeParse(parsed?.data);
79185
+ if (refusal.success && !refusal.data.ok)
79186
+ return refusal.data;
79187
+ } catch {
79188
+ }
79189
+ }
79190
+ throw error51;
79191
+ }
79192
+ },
79147
79193
  async getIntentConfirmation(projectSlug, proposalId, version2) {
79148
79194
  try {
79149
79195
  const body = await request(`${projectPath(projectSlug)}/intent/confirmations/${encodeURIComponent(proposalId)}/${encodeURIComponent(String(version2))}`);
@@ -106502,7 +106548,7 @@ Do NOT derail the current task - if the operator has an in-flight question, answ
106502
106548
  }
106503
106549
 
106504
106550
  // src/_generated/version.ts
106505
- var PKG_VERSION = "0.4.235";
106551
+ var PKG_VERSION = "0.4.237";
106506
106552
 
106507
106553
  // src/bridge-allowed-origins.ts
106508
106554
  var DEFAULT_DIRECTOR_BRIDGE_ALLOWED_ORIGINS = [
@@ -124007,6 +124053,22 @@ async function runExternalAgentsPruneAtStartup(deps) {
124007
124053
 
124008
124054
  // src/director-bridge.ts
124009
124055
  var JSON_GPT_MODEL_REF_RE = /"(?:slug|model)"\s*:\s*"(gpt-[a-z0-9.-]+)"/gi;
124056
+ var DECLINED_PROPOSALS_MAX = 5;
124057
+ var DECLINED_PROPOSAL_TITLE_MAX = 120;
124058
+ var DECLINED_PROPOSALS_TIMEOUT_MS = 1500;
124059
+ function toDeclinedProposalContext(proposals) {
124060
+ return proposals.slice(0, DECLINED_PROPOSALS_MAX).map((proposal) => {
124061
+ const intent = proposal.resolvedIntent ?? {};
124062
+ const rawTitle = typeof intent.title === "string" && intent.title.trim() ? intent.title.trim() : "Untitled";
124063
+ const title = rawTitle.length > DECLINED_PROPOSAL_TITLE_MAX ? `${rawTitle.slice(0, DECLINED_PROPOSAL_TITLE_MAX - 1)}\u2026` : rawTitle;
124064
+ return {
124065
+ proposalId: proposal.proposalId,
124066
+ kind: intent.kind === "plan" ? "plan" : "task",
124067
+ title,
124068
+ declinedAt: proposal.updatedAt ?? ""
124069
+ };
124070
+ });
124071
+ }
124010
124072
  var COMPACT_REQUEST_HISTORY_MAX_ITEMS = 500;
124011
124073
  function isValidChatHistoryMessage(value) {
124012
124074
  if (!value || typeof value !== "object") return false;
@@ -125962,6 +126024,23 @@ function createBridgeMessageHandler(deps) {
125962
126024
  } catch {
125963
126025
  }
125964
126026
  }
126027
+ let declinedProposals;
126028
+ if (deps.listDeclinedProposals && contextProjectSlug) {
126029
+ let timer;
126030
+ try {
126031
+ const declined = await Promise.race([
126032
+ deps.listDeclinedProposals(contextProjectSlug),
126033
+ new Promise((_, reject) => {
126034
+ timer = setTimeout(() => reject(new Error("declined proposals timed out")), DECLINED_PROPOSALS_TIMEOUT_MS);
126035
+ })
126036
+ ]);
126037
+ const mapped = toDeclinedProposalContext(declined);
126038
+ declinedProposals = mapped.length ? mapped : void 0;
126039
+ } catch {
126040
+ } finally {
126041
+ if (timer) clearTimeout(timer);
126042
+ }
126043
+ }
125965
126044
  if (!contextProjectSlug) {
125966
126045
  sendForSpan({
125967
126046
  type: "error",
@@ -126033,6 +126112,7 @@ function createBridgeMessageHandler(deps) {
126033
126112
  ...msg.context,
126034
126113
  project: projectContext,
126035
126114
  answeredQuestions,
126115
+ declinedProposals,
126036
126116
  openQuestions: presentedLedger.shown.length ? presentedLedger.shown : void 0,
126037
126117
  clarifications: msg.context?.clarifications ?? (presentedLedger.shown.some((i) => i.id) ? presentedLedger.shown.map(({ id, round, ordinal, question, status, answer, actor }) => ({
126038
126118
  id,
@@ -126653,22 +126733,28 @@ async function startDirectorBridge(startupDeps = {}) {
126653
126733
  throw error51;
126654
126734
  }
126655
126735
  }
126736
+ function resolveCompactBridgeOption(name, prerequisites, env = process.env, warn = (line) => {
126737
+ process.stderr.write(line);
126738
+ }) {
126739
+ const flag2 = env[name]?.trim().toLowerCase();
126740
+ if (flag2 && !["0", "1", "false"].includes(flag2)) throw new Error(`Invalid ${name}`);
126741
+ if (flag2 === "0" || flag2 === "false") return false;
126742
+ const ready = prerequisites.agentSecret && prerequisites.scopedScheduler;
126743
+ if (flag2 === "1" && !ready) {
126744
+ const missing = [
126745
+ ...prerequisites.agentSecret ? [] : ["a durable agent credential"],
126746
+ ...prerequisites.scopedScheduler ? [] : ["MRRLIN_BRIDGE_SCOPED_SCHEDULER=1"]
126747
+ ].join(" and ");
126748
+ warn(`[mrrlin-mcp director-bridge] ${name}=1 ignored: it requires ${missing}; staying off
126749
+ `);
126750
+ }
126751
+ return ready;
126752
+ }
126656
126753
  async function startBridge(startupDeps, agentSecret, startupRollback) {
126657
126754
  const scopedScheduler = process.env.MRRLIN_BRIDGE_SCOPED_SCHEDULER === "1";
126658
- const compactTickFlag = process.env.MRRLIN_BRIDGE_COMPACT_SCHEDULER?.trim().toLowerCase();
126659
- if (compactTickFlag && !["0", "1", "false"].includes(compactTickFlag)) {
126660
- throw new Error("Invalid MRRLIN_BRIDGE_COMPACT_SCHEDULER");
126661
- }
126662
- const compactTick = compactTickFlag === "1";
126663
- if (compactTick && (!agentSecret || !scopedScheduler)) {
126664
- throw new Error("Compact scheduler requires a durable agent credential and scoped scheduler");
126665
- }
126666
- const compactFlag = process.env.MRRLIN_BRIDGE_COMPACT_HEARTBEAT?.trim().toLowerCase();
126667
- if (compactFlag && !["0", "1", "false"].includes(compactFlag)) throw new Error("Invalid MRRLIN_BRIDGE_COMPACT_HEARTBEAT");
126668
- const compactHeartbeat = compactFlag === "1";
126669
- if (compactHeartbeat && (!agentSecret || !scopedScheduler)) {
126670
- throw new Error("Compact heartbeat requires a durable agent credential and scoped scheduler");
126671
- }
126755
+ const compactPrerequisites = { agentSecret: !!agentSecret, scopedScheduler };
126756
+ const compactTick = resolveCompactBridgeOption("MRRLIN_BRIDGE_COMPACT_SCHEDULER", compactPrerequisites);
126757
+ const compactHeartbeat = resolveCompactBridgeOption("MRRLIN_BRIDGE_COMPACT_HEARTBEAT", compactPrerequisites);
126672
126758
  const signingProvider = buildBridgeSigningProvider();
126673
126759
  const config2 = parseConfig();
126674
126760
  const failureLog = createFailureLog();
@@ -127386,6 +127472,7 @@ async function startBridge(startupDeps, agentSecret, startupRollback) {
127386
127472
  }
127387
127473
  },
127388
127474
  listAnsweredQuestions: (projectSlug, taskId) => client.listInboxItems(projectSlug, { status: "acknowledged", kind: "question", taskId }),
127475
+ listDeclinedProposals: (projectSlug) => client.listIntentProposals(projectSlug, { state: "declined" }),
127389
127476
  snapshotProjectObjects: async (projectSlug, opts) => {
127390
127477
  const signal = opts?.signal;
127391
127478
  if (signal?.aborted) throw new Error("snapshot aborted");
@@ -128061,6 +128148,8 @@ function renderContextPrefix(context) {
128061
128148
  if (answeredQuestions) payload.answeredQuestions = answeredQuestions;
128062
128149
  const openQuestions = context?.openQuestions?.length ? context.openQuestions : void 0;
128063
128150
  if (openQuestions) payload.openQuestions = openQuestions;
128151
+ const declinedProposals = context?.declinedProposals?.length ? context.declinedProposals.slice(0, DECLINED_PROPOSALS_MAX) : void 0;
128152
+ if (declinedProposals) payload.declinedProposals = declinedProposals;
128064
128153
  if (context?.activeProposal) payload.activeProposal = context.activeProposal;
128065
128154
  if (context?.clarifications?.length) payload.clarifications = context.clarifications;
128066
128155
  const keys = Object.keys(payload);
@@ -128072,6 +128161,11 @@ function renderContextPrefix(context) {
128072
128161
  `[ACTIVE PROPOSAL] Proposal ID: ${context.activeProposal.id} (version ${context.activeProposal.version}). Work is created only by the operator confirming a proposal in the chat; propose new work with propose_task. create_plan, and create_task for an already-confirmed proposal, need its proposalId, proposalVersion, and proposalDigest.`
128073
128162
  );
128074
128163
  }
128164
+ if (declinedProposals) {
128165
+ parts.push(
128166
+ "[DECLINED PROPOSALS] `declinedProposals` lists proposals the operator declined (\xABNot now\xBB). Do not propose the same work again unless the operator asks for it again; if it still matters, ask what should change instead."
128167
+ );
128168
+ }
128075
128169
  if (context?.clarifications?.length) {
128076
128170
  parts.push(
128077
128171
  "[DURABLE CLARIFICATIONS] Prior clarification decisions with stable IDs and states: answered or rejected items MUST NOT be re-asked. You may ask at most 3 questions per round. After 3 unresolved clarification rounds, escalation is triggered and no work can be created."
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mrrlin-dev/mcp",
3
- "version": "0.4.235",
3
+ "version": "0.4.237",
4
4
  "type": "module",
5
5
  "bin": {
6
6
  "mrrlin-mcp": "dist/bin.cjs"