@withpica/mcp-sdk 3.12.0 → 3.14.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
  }
@@ -2023,6 +2051,28 @@ class FeedbackResource extends BaseResource {
2023
2051
  return this.request("POST", "/feedback", params);
2024
2052
  }
2025
2053
  }
2054
+ class BillingResource extends BaseResource {
2055
+ /**
2056
+ * Mint a pay link for one offer. Minting is not charging: the link is a
2057
+ * capability an agent POSTs with a Machine Payments credential, or a person
2058
+ * opens in a browser and pays by card.
2059
+ *
2060
+ * Refusals arrive as `ApiError` carrying the route's status with its JSON
2061
+ * body embedded in the message (the shape `duplicates.ts` and
2062
+ * `integrity.ts` already parse): 403 `billing not enabled`; 400
2063
+ * `nothing_held_for_entity` / `entity_id is required to unlock`; 409
2064
+ * `offer_no_longer_applies`, whose body lists the offers that DO apply.
2065
+ * A 403 can ALSO come from the auth wrapper in front of the route rather
2066
+ * than the route itself (`{ error: { code: "INSUFFICIENT_SCOPE", … } }`),
2067
+ * so status alone never identifies which refusal this is — read the body.
2068
+ * They are deliberately not caught here — the MCP tool turns each into a
2069
+ * structured refusal, and a resource that swallowed them would leave every
2070
+ * other caller unable to tell a refusal from an outage.
2071
+ */
2072
+ async mintPayLink(params) {
2073
+ return this.request("POST", "/admin/billing/pay-link", params);
2074
+ }
2075
+ }
2026
2076
  class SubscriptionResource extends BaseResource {
2027
2077
  /**
2028
2078
  * Read the org's billing posture. Wraps the same
@@ -3397,8 +3447,13 @@ class ReleasesResource extends BaseResource {
3397
3447
  }
3398
3448
  class SessionsResource extends BaseResource {
3399
3449
  async list(params) {
3400
- const qs = params?.limit ? `?limit=${params.limit}` : "";
3401
- return this.request("GET", `/admin/sessions${qs}`);
3450
+ const query = new URLSearchParams();
3451
+ if (params?.limit)
3452
+ query.set("limit", String(params.limit));
3453
+ if (params?.offset)
3454
+ query.set("offset", String(params.offset));
3455
+ const qs = query.toString();
3456
+ return this.request("GET", `/admin/sessions${qs ? `?${qs}` : ""}`);
3402
3457
  }
3403
3458
  async get(id) {
3404
3459
  return this.request("GET", `/admin/sessions/${id}`);
@@ -3922,6 +3977,8 @@ export class PicaClient {
3922
3977
  workflowOutcomes;
3923
3978
  feedback;
3924
3979
  subscription;
3980
+ /** MPP pay rail (WS-B) — mints pay links; never charges. */
3981
+ billing;
3925
3982
  opsIssues;
3926
3983
  discoveries;
3927
3984
  agentIdentity;
@@ -4034,6 +4091,7 @@ export class PicaClient {
4034
4091
  this.workflowOutcomes = new WorkflowOutcomesResource(baseUrl, config.apiKey, debug);
4035
4092
  this.feedback = new FeedbackResource(baseUrl, config.apiKey, debug);
4036
4093
  this.subscription = new SubscriptionResource(baseUrl, config.apiKey, debug);
4094
+ this.billing = new BillingResource(baseUrl, config.apiKey, debug);
4037
4095
  this.opsIssues = new OpsIssuesResource(baseUrl, config.apiKey, debug);
4038
4096
  this.discoveries = new DiscoveriesResource(baseUrl, config.apiKey, debug);
4039
4097
  this.agentIdentity = new AgentIdentityResource(baseUrl, config.apiKey, debug);