@withpica/mcp-sdk 1.21.0 → 1.23.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/CHANGELOG.md CHANGED
@@ -11,6 +11,29 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
11
11
 
12
12
  ## [Unreleased]
13
13
 
14
+ ## [1.22.0] - 2026-05-06
15
+
16
+ ### Removed
17
+
18
+ - **`CreditsBalanceResource.purchase()` — credit-pack one-time purchase entry point.**
19
+ Retired with the move to capacity-tier subscriptions (ADR-205). The Stripe
20
+ Checkout endpoint, `lib/services/billing.createCreditPurchaseSession`, and
21
+ the `get_credit_packages` AI tool were removed in the same change. Any
22
+ external consumer calling `client.creditsBalance.purchase({...})` will get
23
+ a TypeScript compile error after upgrading.
24
+ - **Migration:** redirect users to the tier-subscription flow (`POST
25
+ /admin/subscription`, exposed by the `pica_subscription_*` MCP tools or
26
+ the `/pricing` page CTA).
27
+ - **Defensive note:** the Stripe webhook handler still recognises legacy
28
+ `type === "credit_purchase"` metadata and awards credits if any stale
29
+ checkout session completes after deploy.
30
+ - **Breaking** — minor bump per Keep-a-Changelog convention because the
31
+ method has been a tombstone on the MCP surface since 2026-04-22 (B-001)
32
+ and was already considered an internal-only escape hatch; downstream
33
+ `mcp-server` (workspace consumer) was the only known caller and its
34
+ `purchases.ts` tool already returned `[]`. Bump if you have an external
35
+ consumer.
36
+
14
37
  ## [1.21.0] - 2026-05-02
15
38
 
16
39
  ### Added
package/dist/index.d.ts CHANGED
@@ -708,18 +708,38 @@ declare class LicensingResource extends BaseResource {
708
708
  */
709
709
  updateEnquiryStatus(id: string, status: string, notes?: string): Promise<LicenseEnquiry>;
710
710
  }
711
+ export interface WorkCreditAtomicAddInput {
712
+ person_id: string;
713
+ credit_type?: "writer" | "composer" | "arranger" | "lyricist" | "producer" | "performer" | "engineer" | "mixer" | "mastering" | "owner" | "vocalist" | "instrumentalist" | "conductor" | "programmer" | "remixer";
714
+ share_pct?: number;
715
+ notes?: string;
716
+ }
717
+ export interface AtomicCreditResult {
718
+ credit_id: string;
719
+ credit?: Record<string, unknown>;
720
+ work_id?: string;
721
+ recording_id?: string;
722
+ }
711
723
  declare class CreditsResource extends BaseResource {
712
724
  listForWork(workId: string): Promise<WorkCredit[]>;
713
725
  updateForWork(workId: string, credits: WorkCreditsInput): Promise<WorkCredit[]>;
714
726
  listCollaborators(workId: string): Promise<WorkCredit[]>;
715
727
  updateCollaborators(workId: string, collaborators: WorkCreditsInput): Promise<WorkCredit[]>;
728
+ /**
729
+ * ADR-232 atomic add — INSERT a single work credit. Race-safe under
730
+ * concurrent writes (replace_work_credits is read-modify-write and
731
+ * therefore not atomic for this verb). Returns the new credit_id.
732
+ */
733
+ atomicAdd(workId: string, input: WorkCreditAtomicAddInput): Promise<AtomicCreditResult>;
734
+ /**
735
+ * ADR-232 atomic remove — DELETE…RETURNING with 0-row → 403
736
+ * INSUFFICIENT_SCOPE. No SELECT pre-probe (constant-time existence
737
+ * semantics — never leaks 404 vs 403 via latency).
738
+ */
739
+ atomicRemove(workId: string, creditId: string): Promise<AtomicCreditResult>;
716
740
  }
717
741
  declare class CreditsBalanceResource extends BaseResource {
718
742
  getBalance(): Promise<any>;
719
- purchase(params: {
720
- package_id: string;
721
- currency?: string;
722
- }): Promise<any>;
723
743
  }
724
744
  declare class PicaScoreResource extends BaseResource {
725
745
  get(): Promise<PicaScore>;
@@ -891,12 +911,41 @@ declare class WorkspaceResource extends BaseResource {
891
911
  }>;
892
912
  }>;
893
913
  }
914
+ declare class ShareSendResource extends BaseResource {
915
+ send(args: {
916
+ entity_type: "recording" | "work" | "audio_file" | "document";
917
+ entity_id: string;
918
+ recipient: {
919
+ kind: "user_id" | "collaborator_id" | "email";
920
+ value: string;
921
+ };
922
+ note?: string;
923
+ expires_in_days?: number;
924
+ scope?: "view" | "view+download";
925
+ confirm_first_external_send?: boolean;
926
+ }): Promise<{
927
+ send_id: string;
928
+ share_link_id: string;
929
+ share_url: string;
930
+ recipient_resolution: {
931
+ classification: "internal_user" | "internal_contact" | "external";
932
+ display_name: string | null;
933
+ email_hash_prefix: string;
934
+ };
935
+ }>;
936
+ }
894
937
  declare class AuditResource extends BaseResource {
895
938
  list(params?: {
896
939
  limit?: number;
897
940
  since?: string;
898
941
  tool_name?: string;
899
942
  risk_level?: string;
943
+ /**
944
+ * ADR-230 — filter by declared authority tier ("read" | "draft" |
945
+ * "write" | "destructive"). The 4-value tier is PICA's authority
946
+ * detail; risk_level remains the MCP-standard 3-value hint.
947
+ */
948
+ tier?: string;
900
949
  result_status?: string;
901
950
  }): Promise<any[]>;
902
951
  }
@@ -1569,6 +1618,57 @@ declare class OpsIssuesResource extends BaseResource {
1569
1618
  limit?: number;
1570
1619
  }): Promise<MyReportedIssue[]>;
1571
1620
  }
1621
+ /**
1622
+ * Reads from the Phase 4 substrate — `assistant_interactions` and
1623
+ * `mcp_sessions`. Powers `pica_my_recent_questions` (the auditability tool)
1624
+ * and the `pica_continue` prompt's open-loop offers.
1625
+ *
1626
+ * Strictly user-scoped: the API routes assert a non-null userId from the
1627
+ * auth context and rely on RLS `(user_id = auth.uid())` for defence in depth.
1628
+ */
1629
+ export interface RecentInteractionEntry {
1630
+ id: string;
1631
+ session_id: string;
1632
+ intent: string;
1633
+ tools_used: string[] | null;
1634
+ prompt_excerpt: string | null;
1635
+ result_summary: string | null;
1636
+ success: boolean;
1637
+ was_confirmed: boolean | null;
1638
+ required_confirmation: boolean | null;
1639
+ created_at: string;
1640
+ client_name: string | null;
1641
+ client_version: string | null;
1642
+ transport: string;
1643
+ }
1644
+ export interface OpenLoopEntry {
1645
+ session_id: string;
1646
+ reason: "unconfirmed_write" | "incomplete_multi_step";
1647
+ intent: string;
1648
+ result_summary: string | null;
1649
+ entity_type: string | null;
1650
+ entity_ids: string[] | null;
1651
+ created_at: string;
1652
+ }
1653
+ declare class AssistantInteractionsResource extends BaseResource {
1654
+ listRecent(params?: {
1655
+ sessionId?: string;
1656
+ since?: string;
1657
+ success?: boolean;
1658
+ intent?: string;
1659
+ limit?: number;
1660
+ }): Promise<RecentInteractionEntry[]>;
1661
+ detectOpenLoops(): Promise<OpenLoopEntry[]>;
1662
+ /**
1663
+ * ADR-226 Phase 6 — fetch the user's vocabulary context as a single
1664
+ * pre-rendered string (or null when the user has no entries). Hit by
1665
+ * the stdio MCP server during start(), before transport.connect, to
1666
+ * compose handshake-time server-instructions.
1667
+ */
1668
+ getVocabularyContext(): Promise<{
1669
+ instructions: string | null;
1670
+ }>;
1671
+ }
1572
1672
  /**
1573
1673
  * Session-auth-only surface: the three HTTP routes backing these
1574
1674
  * methods refuse `pica_grant_` callers with 403 `session_auth_required`
@@ -2125,6 +2225,133 @@ export interface RecordingCreditCreateInput {
2125
2225
  declare class RecordingCreditsResource extends BaseResource {
2126
2226
  list(recordingId: string): Promise<RecordingCredit[]>;
2127
2227
  create(recordingId: string, input: RecordingCreditCreateInput): Promise<RecordingCredit>;
2228
+ /**
2229
+ * ADR-232 atomic add — semantically identical to `create` (a recording
2230
+ * credit INSERT is already atomic) but reads more naturally next to
2231
+ * CreditsResource.atomicAdd in the pica_credit_add tool implementation.
2232
+ */
2233
+ atomicAdd(recordingId: string, input: RecordingCreditCreateInput): Promise<AtomicCreditResult>;
2234
+ /**
2235
+ * ADR-232 atomic remove — DELETE with `?atomic=1` so the route returns 403
2236
+ * INSUFFICIENT_SCOPE on 0-row instead of the legacy lenient silent
2237
+ * success. AC-2 strict semantics for pica_credit_remove.
2238
+ */
2239
+ atomicRemove(recordingId: string, creditId: string): Promise<AtomicCreditResult>;
2240
+ }
2241
+ export type ShareTraceEntityType = "work" | "recording" | "person";
2242
+ export interface ShareTraceQuery {
2243
+ entity_type: ShareTraceEntityType;
2244
+ entity_id: string;
2245
+ viewer_user_id?: string;
2246
+ viewer_org_id?: string;
2247
+ }
2248
+ export interface ShareTraceReason {
2249
+ kind: "org_membership" | "custody_chain" | "share_link" | "cross_org_grant";
2250
+ directness: 1 | 2 | 3 | 4;
2251
+ via_org_id?: string;
2252
+ via_org_name?: string | null;
2253
+ chain_hops?: Array<{
2254
+ custodian_org_id: string;
2255
+ custodian_org_name?: string | null;
2256
+ percentage: number;
2257
+ territory: string;
2258
+ }>;
2259
+ share_link_id?: string;
2260
+ expires_at?: string | null;
2261
+ grant_id?: string;
2262
+ scope?: string[];
2263
+ granted_at?: string | null;
2264
+ }
2265
+ export interface ShareTraceResult {
2266
+ entity: {
2267
+ type: ShareTraceEntityType;
2268
+ id: string;
2269
+ name: string;
2270
+ };
2271
+ viewer: {
2272
+ type: "user" | "org";
2273
+ id: string;
2274
+ name: string | null;
2275
+ };
2276
+ has_access: boolean;
2277
+ reasons: ShareTraceReason[];
2278
+ }
2279
+ export interface CountExplainQuery {
2280
+ count_source: string;
2281
+ observed_value?: number;
2282
+ }
2283
+ export interface CountExplainResult {
2284
+ source: {
2285
+ name: string;
2286
+ query: string;
2287
+ description: string;
2288
+ };
2289
+ computed_value: number;
2290
+ observed_value: number | null;
2291
+ delta: number | null;
2292
+ delta_breakdown?: Array<{
2293
+ reason: string;
2294
+ count: number;
2295
+ sample_ids: string[];
2296
+ }>;
2297
+ }
2298
+ declare class CountExplainResource extends BaseResource {
2299
+ /**
2300
+ * GET /admin/count-explain — explains a single dashboard / briefing
2301
+ * count by reproducing the canonical query and (optionally) breaking
2302
+ * down the delta against an observed value.
2303
+ */
2304
+ explain(query: CountExplainQuery): Promise<CountExplainResult>;
2305
+ }
2306
+ export interface AudioPipelineStatusQuery {
2307
+ window_days?: number;
2308
+ }
2309
+ export interface AudioPipelineByState {
2310
+ pending: number;
2311
+ complete: number;
2312
+ failed: number;
2313
+ stuck_over_24h: number;
2314
+ }
2315
+ export interface AudioPipelineStatusResult {
2316
+ window_days: number;
2317
+ by_state: AudioPipelineByState;
2318
+ samples: {
2319
+ pending: Array<{
2320
+ audio_file_id: string;
2321
+ work_id: string | null;
2322
+ queued_at: string;
2323
+ }>;
2324
+ failed: Array<{
2325
+ audio_file_id: string;
2326
+ work_id: string | null;
2327
+ error: string | null;
2328
+ last_attempt: string | null;
2329
+ }>;
2330
+ stuck_over_24h: Array<{
2331
+ audio_file_id: string;
2332
+ work_id: string | null;
2333
+ queued_at: string;
2334
+ last_attempt: string | null;
2335
+ }>;
2336
+ };
2337
+ }
2338
+ declare class AudioPipelineStatusResource extends BaseResource {
2339
+ /**
2340
+ * GET /admin/audio-pipeline-status — operational read of the audio
2341
+ * analysis pipeline state for the calling org. AC-7: every bucket is
2342
+ * an integer (zero-org reports structured zeros, not nulls).
2343
+ */
2344
+ status(query?: AudioPipelineStatusQuery): Promise<AudioPipelineStatusResult>;
2345
+ }
2346
+ declare class ShareTraceResource extends BaseResource {
2347
+ /**
2348
+ * GET /admin/share-trace — returns the unioned chain of reasons a
2349
+ * viewer can see an entity. AC-3: 403 + INSUFFICIENT_SCOPE if the
2350
+ * caller doesn't own the entity (existence-leak protection). AC-4:
2351
+ * has_access:false with reasons:[] when the caller IS the owner but
2352
+ * the viewer can't see.
2353
+ */
2354
+ trace(query: ShareTraceQuery): Promise<ShareTraceResult>;
2128
2355
  }
2129
2356
  declare class RecordingSplitsResource extends BaseResource {
2130
2357
  list(recordingId: string): Promise<any>;
@@ -2464,6 +2691,60 @@ declare class ImportDocumentsResource extends BaseResource {
2464
2691
  get(id: string): Promise<any>;
2465
2692
  ingest(content: string): Promise<any>;
2466
2693
  }
2694
+ export type AccessSimulateEntityType = "work" | "recording" | "person" | "release";
2695
+ export type AccessSimulateAction = "view" | "share_link_preview" | "claim" | "grant";
2696
+ export type AccessSimulateRecipientType = "user" | "anonymous" | "share_link";
2697
+ export interface AccessSimulateShareLinkConfig {
2698
+ access_type: "private" | "limited" | "public";
2699
+ allow_download?: boolean;
2700
+ allow_streaming?: boolean;
2701
+ allow_comments?: boolean;
2702
+ allow_view_collaborators?: boolean;
2703
+ allow_view_financials?: boolean;
2704
+ watermark_audio?: boolean;
2705
+ notify_on_access?: boolean;
2706
+ allowed_person_ids?: string[];
2707
+ sent_to_emails?: string[];
2708
+ max_views?: number | null;
2709
+ expires_at?: string | null;
2710
+ }
2711
+ export interface AccessSimulateInput {
2712
+ entity_type: AccessSimulateEntityType;
2713
+ entity_id: string;
2714
+ action: AccessSimulateAction;
2715
+ recipient: {
2716
+ type: AccessSimulateRecipientType;
2717
+ user_id?: string;
2718
+ org_id?: string;
2719
+ share_config?: AccessSimulateShareLinkConfig;
2720
+ };
2721
+ }
2722
+ export type AccessSimulateRuleName = "rls" | "share_link" | "collaborator" | "cross_org_grant" | "identity_inheritance" | "not_yet_supported" | "entity_not_found";
2723
+ export interface AccessSimulateReason {
2724
+ rule: AccessSimulateRuleName;
2725
+ decision: "allow" | "deny" | "info";
2726
+ detail: string;
2727
+ applies_to?: string[];
2728
+ }
2729
+ export interface AccessSimulateWarning {
2730
+ severity: "info" | "warn" | "error";
2731
+ message: string;
2732
+ }
2733
+ export interface AccessSimulateResult {
2734
+ entity_type: AccessSimulateEntityType;
2735
+ entity_id: string;
2736
+ action: AccessSimulateAction;
2737
+ visible: boolean;
2738
+ visible_fields: string[];
2739
+ hidden_fields: string[];
2740
+ visible_relations: Record<string, "visible" | "hidden" | "watermarked">;
2741
+ reasons: AccessSimulateReason[];
2742
+ warnings: AccessSimulateWarning[];
2743
+ not_yet_supported?: boolean;
2744
+ }
2745
+ declare class AccessSimulateResource extends BaseResource {
2746
+ simulate(input: AccessSimulateInput): Promise<AccessSimulateResult>;
2747
+ }
2467
2748
  export declare class PicaClient {
2468
2749
  works: WorksResource;
2469
2750
  people: PeopleResource;
@@ -2509,6 +2790,9 @@ export declare class PicaClient {
2509
2790
  splitSheets: SplitSheetsResource;
2510
2791
  recordingSplits: RecordingSplitsResource;
2511
2792
  recordingCredits: RecordingCreditsResource;
2793
+ shareTrace: ShareTraceResource;
2794
+ countExplain: CountExplainResource;
2795
+ audioPipelineStatus: AudioPipelineStatusResource;
2512
2796
  publishers: PublishersResource;
2513
2797
  labels: LabelsResource;
2514
2798
  agreementTemplates: AgreementTemplatesResource;
@@ -2530,6 +2814,9 @@ export declare class PicaClient {
2530
2814
  agentIdentity: AgentIdentityResource;
2531
2815
  uploads: UploadsResource;
2532
2816
  groups: GroupsResource;
2817
+ assistantInteractions: AssistantInteractionsResource;
2818
+ shareSend: ShareSendResource;
2819
+ accessSimulate: AccessSimulateResource;
2533
2820
  /**
2534
2821
  * Get accurate catalog stats via SQL counts (no pagination limits)
2535
2822
  */