@withpica/mcp-sdk 3.13.0 → 3.15.0

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/index.js CHANGED
@@ -210,6 +210,12 @@ class BaseResource {
210
210
  * carries `twin`/`twin_error` as siblings of `data` — `request()`'s
211
211
  * `return data.data || data` would otherwise silently drop them before
212
212
  * the MCP tool ever sees a twin was created.
213
+ *
214
+ * `TRest` types any FURTHER siblings a specific route puts next to
215
+ * `data` (e.g. `POST /admin/multimedia/import-from-url` returns `via`,
216
+ * `source_url`, `profile_image`, `work_link`). It defaults to `unknown`,
217
+ * which is the identity for intersection, so the existing
218
+ * `requestWithEnvelope<Work>` call sites keep exactly the type they had.
213
219
  */
214
220
  async requestWithEnvelope(method, path, body) {
215
221
  const url = `${this.baseUrl}${path}`;
@@ -862,6 +868,8 @@ class AudioFilesResource extends BaseResource {
862
868
  queryParams.set("query", params.query);
863
869
  if (params?.limit !== undefined)
864
870
  queryParams.set("limit", String(params.limit));
871
+ if (params?.offset)
872
+ queryParams.set("offset", String(params.offset));
865
873
  const query = queryParams.toString();
866
874
  return this.request("GET", `/admin/audio-files${query ? `?${query}` : ""}`);
867
875
  }
@@ -955,7 +963,25 @@ class MultimediaResource extends BaseResource {
955
963
  return this.request("POST", "/admin/multimedia", data);
956
964
  }
957
965
  async importFromUrl(params) {
958
- return this.request("POST", "/admin/multimedia/import-from-url", params);
966
+ // `request()` returns `data.data || data`, so it hands back ONLY the
967
+ // created row and drops every sibling field the route puts next to
968
+ // `data` — `via`, `source_url`, `profile_image`, `work_link`. Those
969
+ // are the receipts: without them pica_multimedia_import_url could say
970
+ // "imported" but never whether the person's profile image was set, or
971
+ // whether the URL was followed through an og:image. Read the envelope.
972
+ const envelope = await this.requestWithEnvelope("POST", "/admin/multimedia/import-from-url", params);
973
+ return {
974
+ item: envelope.data,
975
+ multimedia_id: envelope.multimedia_id,
976
+ s3_url: envelope.s3_url,
977
+ via: envelope.via,
978
+ source_url: envelope.source_url,
979
+ message: envelope.message,
980
+ ...(envelope.profile_image
981
+ ? { profile_image: envelope.profile_image }
982
+ : {}),
983
+ ...(envelope.work_link ? { work_link: envelope.work_link } : {}),
984
+ };
959
985
  }
960
986
  async linkYoutube(params) {
961
987
  return this.request("POST", "/admin/multimedia/link-youtube", params);
@@ -1208,6 +1234,8 @@ class NotesResource extends BaseResource {
1208
1234
  query.set("person", params.person);
1209
1235
  if (params?.limit)
1210
1236
  query.set("limit", String(params.limit));
1237
+ if (params?.offset)
1238
+ query.set("offset", String(params.offset));
1211
1239
  const qs = query.toString();
1212
1240
  return this.request("GET", `/admin/notes${qs ? `?${qs}` : ""}`);
1213
1241
  }
@@ -1719,6 +1747,8 @@ class HealthResource extends BaseResource {
1719
1747
  /**
1720
1748
  * ADR-273 — apply accepted fix actions from a prior plan. Requires planToken
1721
1749
  * from catalogHealthPlan; accept is a list of actionIds (or "all_safe_auto").
1750
+ * `selections` carries the human choice a resolve_person action needs
1751
+ * ({ actionId, chosenPersonId }); a selection also accepts its action.
1722
1752
  * Returns honest per-action met/unmet plus a fresh verdict.
1723
1753
  */
1724
1754
  async catalogHealthFix(body) {
@@ -3419,8 +3449,13 @@ class ReleasesResource extends BaseResource {
3419
3449
  }
3420
3450
  class SessionsResource extends BaseResource {
3421
3451
  async list(params) {
3422
- const qs = params?.limit ? `?limit=${params.limit}` : "";
3423
- return this.request("GET", `/admin/sessions${qs}`);
3452
+ const query = new URLSearchParams();
3453
+ if (params?.limit)
3454
+ query.set("limit", String(params.limit));
3455
+ if (params?.offset)
3456
+ query.set("offset", String(params.offset));
3457
+ const qs = query.toString();
3458
+ return this.request("GET", `/admin/sessions${qs ? `?${qs}` : ""}`);
3424
3459
  }
3425
3460
  async get(id) {
3426
3461
  return this.request("GET", `/admin/sessions/${id}`);
@@ -3597,6 +3632,46 @@ class StatementsResource extends BaseResource {
3597
3632
  return this.request("POST", "/admin/statements/ingest-agent", payload);
3598
3633
  }
3599
3634
  }
3635
+ class SelectionsResource extends BaseResource {
3636
+ async list(params) {
3637
+ const qp = new URLSearchParams();
3638
+ if (params?.limit !== undefined)
3639
+ qp.set("limit", String(params.limit));
3640
+ if (params?.offset !== undefined)
3641
+ qp.set("offset", String(params.offset));
3642
+ const qs = qp.toString();
3643
+ const result = await this.request("GET", `/admin/selections${qs ? `?${qs}` : ""}`);
3644
+ return result.selections;
3645
+ }
3646
+ async create(data) {
3647
+ const result = await this.request("POST", "/admin/selections", data);
3648
+ return result.selection;
3649
+ }
3650
+ /**
3651
+ * Per-id read. `resolve: true` also resolves the predicate — the route
3652
+ * returns `{ selection, resolution }` instead of `{ selection }`, and
3653
+ * `resolution` is omitted below when the caller didn't ask for it.
3654
+ */
3655
+ async inspect(id, opts) {
3656
+ const qp = new URLSearchParams();
3657
+ if (opts?.resolve)
3658
+ qp.set("resolve", "true");
3659
+ if (opts?.limit !== undefined)
3660
+ qp.set("limit", String(opts.limit));
3661
+ if (opts?.offset !== undefined)
3662
+ qp.set("offset", String(opts.offset));
3663
+ const qs = qp.toString();
3664
+ const result = await this.request("GET", `/admin/selections/${id}${qs ? `?${qs}` : ""}`);
3665
+ return { selection: result.selection, resolution: result.resolution };
3666
+ }
3667
+ async update(id, data) {
3668
+ const result = await this.request("PATCH", `/admin/selections/${id}`, data);
3669
+ return result.selection;
3670
+ }
3671
+ async delete(id) {
3672
+ await this.request("DELETE", `/admin/selections/${id}`);
3673
+ }
3674
+ }
3600
3675
  class ShareLinksResource extends BaseResource {
3601
3676
  async list(params) {
3602
3677
  const qp = new URLSearchParams();
@@ -3929,6 +4004,8 @@ export class PicaClient {
3929
4004
  workForHire;
3930
4005
  royalties;
3931
4006
  statements;
4007
+ /** ADR-319 — saved catalog selections. */
4008
+ selections;
3932
4009
  shareLinks;
3933
4010
  consent;
3934
4011
  custody;
@@ -4043,6 +4120,7 @@ export class PicaClient {
4043
4120
  this.workForHire = new WorkForHireResource(baseUrl, config.apiKey, debug);
4044
4121
  this.royalties = new RoyaltiesResource(baseUrl, config.apiKey, debug);
4045
4122
  this.statements = new StatementsResource(baseUrl, config.apiKey, debug);
4123
+ this.selections = new SelectionsResource(baseUrl, config.apiKey, debug);
4046
4124
  this.shareLinks = new ShareLinksResource(baseUrl, config.apiKey, debug);
4047
4125
  this.consent = new ConsentResource(baseUrl, config.apiKey, debug);
4048
4126
  this.custody = new CustodyResource(baseUrl, config.apiKey, debug);