@papi-ai/server 0.7.53 → 0.7.55

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.
@@ -1065,7 +1065,7 @@ var init_install_id = __esm({
1065
1065
  function reportTelemetryEmitFailure(reason, ctx) {
1066
1066
  consecutiveTelemetryFailures += 1;
1067
1067
  console.error(
1068
- `[telemetry] emit failed (${reason}) tool=${ctx.toolName} event=${ctx.eventType} project=${ctx.projectId}`
1068
+ `[telemetry] emit failed (${reason}) tool=${ctx.toolName} event=${ctx.eventType} project=${ctx.projectId ?? "(none)"}`
1069
1069
  );
1070
1070
  if (consecutiveTelemetryFailures >= TELEMETRY_BLACKOUT_THRESHOLD) {
1071
1071
  console.error(
@@ -1180,21 +1180,27 @@ var init_proxy_adapter = __esm({
1180
1180
  // getToolCallCount + updatePhaseStatus are ABSENT: they now have edge handlers and
1181
1181
  // are served through the forwarder (getToolCallCount = SUP-2026-026 handler #1).
1182
1182
  "createOwnerAction",
1183
- "findPendingDocActionsForTask",
1184
1183
  "getContributorRole",
1185
- "getDecisionScorePatterns",
1186
- "getModuleEstimationStats",
1187
- "correctLatestBuildReportEffort",
1188
1184
  "recordContributorReleasePr",
1189
1185
  "setContributorReleasePrStatus",
1190
1186
  "listContributorReleasePrs",
1191
- "resolveLearningsForDoneTasks",
1192
- "markCycleLearningResolved",
1193
- "updateStageExitCriteria",
1194
- "updateDocAction",
1195
1187
  "claimReview",
1196
1188
  "getSiblingAds",
1197
1189
  "getSiblingRepoTasks"
1190
+ // task-2394 (C329) — Batch A wired: findPendingDocActionsForTask,
1191
+ // getModuleEstimationStats and getDecisionScorePatterns now have edge case handlers
1192
+ // (each backed by a SECURITY DEFINER RPC, migration 20260714140000) plus
1193
+ // ALLOWED_METHODS entries, so they forward. The two planner-context reads returned
1194
+ // EMPTY for every hosted user before this — the planner ran on worse context than
1195
+ // the owner's on the only install path external users have (AD-72).
1196
+ // task-2412 (C329) — listOwnerActionsForBlockerScan + linkOwnerActionToTask wired.
1197
+ // First USER-scoped ([C]) methods to forward: the edge binds both to the bearer's
1198
+ // user_id and discards the client-supplied one, so the typed-blocker scan (task-2343)
1199
+ // now works for hosted users without exposing one member's owner actions to another.
1200
+ // task-2393 (C329) — Batch B wired: markCycleLearningResolved (the P1 — hosted
1201
+ // discovered_issue_resolve hard-errored), correctLatestBuildReportEffort,
1202
+ // updateStageExitCriteria, updateDocAction, resolveLearningsForDoneTasks all have
1203
+ // edge case handlers + ALLOWED_METHODS/WRITE_METHODS entries now, so they forward.
1198
1204
  // task-2489 (C320): recordProgressStep is now wired to the edge data-proxy
1199
1205
  // (case handler + ALLOWED_METHODS/WRITE_METHODS entries), so it forwards for
1200
1206
  // hosted callers and persists a project-scoped cycle_progress_steps row. Removed
@@ -1555,18 +1561,19 @@ Check PAPI_PROJECT_ID in your .mcp.json config. Find your project ID in the PAPI
1555
1561
  */
1556
1562
  emitTelemetry(event) {
1557
1563
  const ctx = { projectId: event.projectId, toolName: event.toolName, eventType: event.eventType };
1564
+ const payload = {
1565
+ toolName: event.toolName,
1566
+ eventType: event.eventType,
1567
+ metadata: event.metadata ?? {}
1568
+ };
1569
+ if (event.projectId) payload["projectId"] = event.projectId;
1558
1570
  fetch(`${this.endpoint}/telemetry`, {
1559
1571
  method: "POST",
1560
1572
  headers: {
1561
1573
  "Content-Type": "application/json",
1562
1574
  "Authorization": `Bearer ${this.apiKey}`
1563
1575
  },
1564
- body: JSON.stringify({
1565
- projectId: event.projectId,
1566
- toolName: event.toolName,
1567
- eventType: event.eventType,
1568
- metadata: event.metadata ?? {}
1569
- }),
1576
+ body: JSON.stringify(payload),
1570
1577
  signal: AbortSignal.timeout(5e3)
1571
1578
  }).then((res) => {
1572
1579
  if (res.ok) noteTelemetryEmitSuccess();
@@ -4551,6 +4558,7 @@ Check PAPI_PROJECT_ID in your .mcp.json config. Find your project ID in the PAPI
4551
4558
  }
4552
4559
 
4553
4560
  // src/lib/formatters.ts
4561
+ var PLAN_FULL_NOTES_BUDGET_BYTES = Number(process.env.PAPI_PLAN_NOTES_BUDGET) || 6e4;
4554
4562
  function effortWeight(size) {
4555
4563
  switch ((size || "").toUpperCase()) {
4556
4564
  case "XS":
@@ -4570,6 +4578,29 @@ function effortWeight(size) {
4570
4578
  return 3;
4571
4579
  }
4572
4580
  }
4581
+ function computeCycleEffort(cycleTaskRows, cycleReports) {
4582
+ if (cycleTaskRows && cycleTaskRows.length > 0) {
4583
+ const done = cycleTaskRows.filter((t) => t.status === "Done");
4584
+ const reportByTask = /* @__PURE__ */ new Map();
4585
+ for (const r of cycleReports) if (r.taskId) reportByTask.set(r.taskId, r);
4586
+ return {
4587
+ completed: done.length,
4588
+ total: cycleTaskRows.length,
4589
+ plannedPoints: done.reduce((s, t) => s + effortWeight(t.complexity), 0),
4590
+ deliveredPoints: done.reduce((s, t) => {
4591
+ const actual = reportByTask.get(t.id)?.actualEffort;
4592
+ return s + effortWeight(actual || t.complexity);
4593
+ }, 0)
4594
+ };
4595
+ }
4596
+ const completed = cycleReports.filter((r) => r.completed === "Yes").length;
4597
+ return {
4598
+ completed,
4599
+ total: cycleReports.length,
4600
+ plannedPoints: cycleReports.reduce((s, r) => s + effortWeight(r.estimatedEffort || r.actualEffort), 0),
4601
+ deliveredPoints: cycleReports.reduce((s, r) => s + effortWeight(r.actualEffort || r.estimatedEffort), 0)
4602
+ };
4603
+ }
4573
4604
  function computeSnapshotsFromBuildReports(reports, tasks) {
4574
4605
  const reportsByCycle = /* @__PURE__ */ new Map();
4575
4606
  for (const r of reports) {
@@ -4593,24 +4624,19 @@ function computeSnapshotsFromBuildReports(reports, tasks) {
4593
4624
  const withEffort = cycleReports.filter((r) => r.estimatedEffort && r.actualEffort);
4594
4625
  const accurate = withEffort.filter((r) => r.estimatedEffort === r.actualEffort).length;
4595
4626
  const matchRate = withEffort.length > 0 ? Math.round(accurate / withEffort.length * 100) : 0;
4596
- let completed;
4597
- let total;
4598
- let effortPoints;
4599
- if (cycleTaskRows && cycleTaskRows.length > 0) {
4600
- const done = cycleTaskRows.filter((t) => t.status === "Done");
4601
- completed = done.length;
4602
- total = cycleTaskRows.length;
4603
- effortPoints = done.reduce((s, t) => s + effortWeight(t.complexity), 0);
4604
- } else {
4605
- completed = cycleReports.filter((r) => r.completed === "Yes").length;
4606
- total = cycleReports.length;
4607
- effortPoints = cycleReports.reduce((s, r) => s + effortWeight(r.actualEffort), 0);
4608
- }
4627
+ const { completed, total, plannedPoints, deliveredPoints } = computeCycleEffort(cycleTaskRows, cycleReports);
4609
4628
  snapshots.push({
4610
4629
  cycle: sn,
4611
4630
  date: (/* @__PURE__ */ new Date()).toISOString(),
4612
4631
  accuracy: [{ cycle: sn, reports: cycleReports.length, matchRate, mae: 0, bias: 0 }],
4613
- velocity: [{ cycle: sn, completed, partial: 0, failed: Math.max(0, total - completed), effortPoints }]
4632
+ velocity: [{
4633
+ cycle: sn,
4634
+ completed,
4635
+ partial: 0,
4636
+ failed: Math.max(0, total - completed),
4637
+ effortPoints: plannedPoints,
4638
+ deliveredPoints
4639
+ }]
4614
4640
  });
4615
4641
  }
4616
4642
  snapshots.sort((a, b) => a.cycle - b.cycle);