@withpica/mcp-sdk 1.25.0 → 1.25.1

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,17 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
11
11
 
12
12
  ## [Unreleased]
13
13
 
14
+ ### Added
15
+
16
+ - **`FilesResource` on `PicaClient` — first-class outbound file delivery (PR #385, shipped 2026-05-12).**
17
+ New `client.files.deliver({ fileId, recipientEmail, expiresIn? })` returns a
18
+ `FileDeliveryLink` (token + expiry + revocation flag), and
19
+ `client.files.revokeDelivery(deliveryId)` kills an issued link. Wraps the
20
+ `/admin/files/deliver` + `/admin/files/deliver/[id]/revoke` routes. The
21
+ exported `FileDeliveryLink` interface is the wire shape. Symmetric
22
+ counterpart to the existing upload-side `StorageResource.presignedUpload`
23
+ — the SDK now covers both directions of the file-flow story.
24
+
14
25
  ## [1.22.0] - 2026-05-06
15
26
 
16
27
  ### Removed
package/dist/index.d.ts CHANGED
@@ -646,6 +646,7 @@ declare class WorksResource extends BaseResource {
646
646
  delete(id: string): Promise<void>;
647
647
  verify(id: string): Promise<Work>;
648
648
  bulkDelete(ids: string[]): Promise<void>;
649
+ bulkMoveToPerformances(ids: string[]): Promise<unknown>;
649
650
  /**
650
651
  * List physical production assets linked to a work.
651
652
  * Closes ADR-156 op #3 Session B Task 5 — surfaces work→asset edges
@@ -678,6 +679,7 @@ declare class PeopleResource extends BaseResource {
678
679
  delete(id: string): Promise<void>;
679
680
  enrichFromISNI(id: string, isni: string): Promise<Person>;
680
681
  enrichFromMusicBrainz(id: string, musicbrainz_id: string): Promise<Person>;
682
+ bulkDelete(ids: string[]): Promise<unknown>;
681
683
  }
682
684
  declare class LicensingResource extends BaseResource {
683
685
  /**
@@ -708,11 +710,35 @@ declare class LicensingResource extends BaseResource {
708
710
  */
709
711
  updateEnquiryStatus(id: string, status: string, notes?: string): Promise<LicenseEnquiry>;
710
712
  }
713
+ export interface WorkCreditAtomicAddInput {
714
+ person_id: string;
715
+ credit_type?: "writer" | "composer" | "arranger" | "lyricist" | "producer" | "performer" | "engineer" | "mixer" | "mastering" | "owner" | "vocalist" | "instrumentalist" | "conductor" | "programmer" | "remixer";
716
+ share_pct?: number;
717
+ notes?: string;
718
+ }
719
+ export interface AtomicCreditResult {
720
+ credit_id: string;
721
+ credit?: Record<string, unknown>;
722
+ work_id?: string;
723
+ recording_id?: string;
724
+ }
711
725
  declare class CreditsResource extends BaseResource {
712
726
  listForWork(workId: string): Promise<WorkCredit[]>;
713
727
  updateForWork(workId: string, credits: WorkCreditsInput): Promise<WorkCredit[]>;
714
728
  listCollaborators(workId: string): Promise<WorkCredit[]>;
715
729
  updateCollaborators(workId: string, collaborators: WorkCreditsInput): Promise<WorkCredit[]>;
730
+ /**
731
+ * ADR-232 atomic add — INSERT a single work credit. Race-safe under
732
+ * concurrent writes (replace_work_credits is read-modify-write and
733
+ * therefore not atomic for this verb). Returns the new credit_id.
734
+ */
735
+ atomicAdd(workId: string, input: WorkCreditAtomicAddInput): Promise<AtomicCreditResult>;
736
+ /**
737
+ * ADR-232 atomic remove — DELETE…RETURNING with 0-row → 403
738
+ * INSUFFICIENT_SCOPE. No SELECT pre-probe (constant-time existence
739
+ * semantics — never leaks 404 vs 403 via latency).
740
+ */
741
+ atomicRemove(workId: string, creditId: string): Promise<AtomicCreditResult>;
716
742
  }
717
743
  declare class CreditsBalanceResource extends BaseResource {
718
744
  getBalance(): Promise<any>;
@@ -887,6 +913,29 @@ declare class WorkspaceResource extends BaseResource {
887
913
  }>;
888
914
  }>;
889
915
  }
916
+ declare class ShareSendResource extends BaseResource {
917
+ send(args: {
918
+ entity_type: "recording" | "work" | "audio_file" | "document";
919
+ entity_id: string;
920
+ recipient: {
921
+ kind: "user_id" | "collaborator_id" | "email";
922
+ value: string;
923
+ };
924
+ note?: string;
925
+ expires_in_days?: number;
926
+ scope?: "view" | "view+download";
927
+ confirm_first_external_send?: boolean;
928
+ }): Promise<{
929
+ send_id: string;
930
+ share_link_id: string;
931
+ share_url: string;
932
+ recipient_resolution: {
933
+ classification: "internal_user" | "internal_contact" | "external";
934
+ display_name: string | null;
935
+ email_hash_prefix: string;
936
+ };
937
+ }>;
938
+ }
890
939
  /**
891
940
  * File delivery — first-class outbound-sharing record. Each delivery ties
892
941
  * a file id to a specific recipient email with a token, expiry, and
@@ -916,6 +965,12 @@ declare class AuditResource extends BaseResource {
916
965
  since?: string;
917
966
  tool_name?: string;
918
967
  risk_level?: string;
968
+ /**
969
+ * ADR-230 — filter by declared authority tier ("read" | "draft" |
970
+ * "write" | "destructive"). The 4-value tier is PICA's authority
971
+ * detail; risk_level remains the MCP-standard 3-value hint.
972
+ */
973
+ tier?: string;
919
974
  result_status?: string;
920
975
  }): Promise<any[]>;
921
976
  }
@@ -1588,6 +1643,57 @@ declare class OpsIssuesResource extends BaseResource {
1588
1643
  limit?: number;
1589
1644
  }): Promise<MyReportedIssue[]>;
1590
1645
  }
1646
+ /**
1647
+ * Reads from the Phase 4 substrate — `assistant_interactions` and
1648
+ * `mcp_sessions`. Powers `pica_my_recent_questions` (the auditability tool)
1649
+ * and the `pica_continue` prompt's open-loop offers.
1650
+ *
1651
+ * Strictly user-scoped: the API routes assert a non-null userId from the
1652
+ * auth context and rely on RLS `(user_id = auth.uid())` for defence in depth.
1653
+ */
1654
+ export interface RecentInteractionEntry {
1655
+ id: string;
1656
+ session_id: string;
1657
+ intent: string;
1658
+ tools_used: string[] | null;
1659
+ prompt_excerpt: string | null;
1660
+ result_summary: string | null;
1661
+ success: boolean;
1662
+ was_confirmed: boolean | null;
1663
+ required_confirmation: boolean | null;
1664
+ created_at: string;
1665
+ client_name: string | null;
1666
+ client_version: string | null;
1667
+ transport: string;
1668
+ }
1669
+ export interface OpenLoopEntry {
1670
+ session_id: string;
1671
+ reason: "unconfirmed_write" | "incomplete_multi_step";
1672
+ intent: string;
1673
+ result_summary: string | null;
1674
+ entity_type: string | null;
1675
+ entity_ids: string[] | null;
1676
+ created_at: string;
1677
+ }
1678
+ declare class AssistantInteractionsResource extends BaseResource {
1679
+ listRecent(params?: {
1680
+ sessionId?: string;
1681
+ since?: string;
1682
+ success?: boolean;
1683
+ intent?: string;
1684
+ limit?: number;
1685
+ }): Promise<RecentInteractionEntry[]>;
1686
+ detectOpenLoops(): Promise<OpenLoopEntry[]>;
1687
+ /**
1688
+ * ADR-226 Phase 6 — fetch the user's vocabulary context as a single
1689
+ * pre-rendered string (or null when the user has no entries). Hit by
1690
+ * the stdio MCP server during start(), before transport.connect, to
1691
+ * compose handshake-time server-instructions.
1692
+ */
1693
+ getVocabularyContext(): Promise<{
1694
+ instructions: string | null;
1695
+ }>;
1696
+ }
1591
1697
  /**
1592
1698
  * Session-auth-only surface: the three HTTP routes backing these
1593
1699
  * methods refuse `pica_grant_` callers with 403 `session_auth_required`
@@ -1654,6 +1760,14 @@ declare class AnalyticsResource extends BaseResource {
1654
1760
  declare class BulkResource extends BaseResource {
1655
1761
  updateWorks(workIds: string[], updates: Record<string, any>): Promise<any>;
1656
1762
  updatePeopleRoles(personIds: string[], roles: string[], action?: string): Promise<any>;
1763
+ addPeopleTags(personIds: string[], tags: string[]): Promise<unknown>;
1764
+ linkArtist(workIds: string[], personId: string, artistName: string): Promise<unknown>;
1765
+ addCollaborator(workIds: string[], collaborator: {
1766
+ person_id: string;
1767
+ role: string;
1768
+ share_percentage: number;
1769
+ }): Promise<unknown>;
1770
+ copyCredits(sourceWorkId: string, targetWorkIds: string[], conflictMode: "skip" | "replace"): Promise<unknown>;
1657
1771
  }
1658
1772
  declare class ExportResource extends BaseResource {
1659
1773
  catalogCsv(params?: {
@@ -1792,8 +1906,9 @@ type ImportDomain = "works" | "people" | "recordings" | "documents" | "enquiries
1792
1906
  interface ImportAnalysis {
1793
1907
  parsed: {
1794
1908
  headers: string[];
1795
- rows: Record<string, string>[];
1909
+ preview: Record<string, string>[];
1796
1910
  totalRows: number;
1911
+ delimiter: string;
1797
1912
  };
1798
1913
  analysis: {
1799
1914
  mappings: Record<string, {
@@ -2144,6 +2259,133 @@ export interface RecordingCreditCreateInput {
2144
2259
  declare class RecordingCreditsResource extends BaseResource {
2145
2260
  list(recordingId: string): Promise<RecordingCredit[]>;
2146
2261
  create(recordingId: string, input: RecordingCreditCreateInput): Promise<RecordingCredit>;
2262
+ /**
2263
+ * ADR-232 atomic add — semantically identical to `create` (a recording
2264
+ * credit INSERT is already atomic) but reads more naturally next to
2265
+ * CreditsResource.atomicAdd in the pica_credit_add tool implementation.
2266
+ */
2267
+ atomicAdd(recordingId: string, input: RecordingCreditCreateInput): Promise<AtomicCreditResult>;
2268
+ /**
2269
+ * ADR-232 atomic remove — DELETE with `?atomic=1` so the route returns 403
2270
+ * INSUFFICIENT_SCOPE on 0-row instead of the legacy lenient silent
2271
+ * success. AC-2 strict semantics for pica_credit_remove.
2272
+ */
2273
+ atomicRemove(recordingId: string, creditId: string): Promise<AtomicCreditResult>;
2274
+ }
2275
+ export type ShareTraceEntityType = "work" | "recording" | "person";
2276
+ export interface ShareTraceQuery {
2277
+ entity_type: ShareTraceEntityType;
2278
+ entity_id: string;
2279
+ viewer_user_id?: string;
2280
+ viewer_org_id?: string;
2281
+ }
2282
+ export interface ShareTraceReason {
2283
+ kind: "org_membership" | "custody_chain" | "share_link" | "cross_org_grant";
2284
+ directness: 1 | 2 | 3 | 4;
2285
+ via_org_id?: string;
2286
+ via_org_name?: string | null;
2287
+ chain_hops?: Array<{
2288
+ custodian_org_id: string;
2289
+ custodian_org_name?: string | null;
2290
+ percentage: number;
2291
+ territory: string;
2292
+ }>;
2293
+ share_link_id?: string;
2294
+ expires_at?: string | null;
2295
+ grant_id?: string;
2296
+ scope?: string[];
2297
+ granted_at?: string | null;
2298
+ }
2299
+ export interface ShareTraceResult {
2300
+ entity: {
2301
+ type: ShareTraceEntityType;
2302
+ id: string;
2303
+ name: string;
2304
+ };
2305
+ viewer: {
2306
+ type: "user" | "org";
2307
+ id: string;
2308
+ name: string | null;
2309
+ };
2310
+ has_access: boolean;
2311
+ reasons: ShareTraceReason[];
2312
+ }
2313
+ export interface CountExplainQuery {
2314
+ count_source: string;
2315
+ observed_value?: number;
2316
+ }
2317
+ export interface CountExplainResult {
2318
+ source: {
2319
+ name: string;
2320
+ query: string;
2321
+ description: string;
2322
+ };
2323
+ computed_value: number;
2324
+ observed_value: number | null;
2325
+ delta: number | null;
2326
+ delta_breakdown?: Array<{
2327
+ reason: string;
2328
+ count: number;
2329
+ sample_ids: string[];
2330
+ }>;
2331
+ }
2332
+ declare class CountExplainResource extends BaseResource {
2333
+ /**
2334
+ * GET /admin/count-explain — explains a single dashboard / briefing
2335
+ * count by reproducing the canonical query and (optionally) breaking
2336
+ * down the delta against an observed value.
2337
+ */
2338
+ explain(query: CountExplainQuery): Promise<CountExplainResult>;
2339
+ }
2340
+ export interface AudioPipelineStatusQuery {
2341
+ window_days?: number;
2342
+ }
2343
+ export interface AudioPipelineByState {
2344
+ pending: number;
2345
+ complete: number;
2346
+ failed: number;
2347
+ stuck_over_24h: number;
2348
+ }
2349
+ export interface AudioPipelineStatusResult {
2350
+ window_days: number;
2351
+ by_state: AudioPipelineByState;
2352
+ samples: {
2353
+ pending: Array<{
2354
+ audio_file_id: string;
2355
+ work_id: string | null;
2356
+ queued_at: string;
2357
+ }>;
2358
+ failed: Array<{
2359
+ audio_file_id: string;
2360
+ work_id: string | null;
2361
+ error: string | null;
2362
+ last_attempt: string | null;
2363
+ }>;
2364
+ stuck_over_24h: Array<{
2365
+ audio_file_id: string;
2366
+ work_id: string | null;
2367
+ queued_at: string;
2368
+ last_attempt: string | null;
2369
+ }>;
2370
+ };
2371
+ }
2372
+ declare class AudioPipelineStatusResource extends BaseResource {
2373
+ /**
2374
+ * GET /admin/audio-pipeline-status — operational read of the audio
2375
+ * analysis pipeline state for the calling org. AC-7: every bucket is
2376
+ * an integer (zero-org reports structured zeros, not nulls).
2377
+ */
2378
+ status(query?: AudioPipelineStatusQuery): Promise<AudioPipelineStatusResult>;
2379
+ }
2380
+ declare class ShareTraceResource extends BaseResource {
2381
+ /**
2382
+ * GET /admin/share-trace — returns the unioned chain of reasons a
2383
+ * viewer can see an entity. AC-3: 403 + INSUFFICIENT_SCOPE if the
2384
+ * caller doesn't own the entity (existence-leak protection). AC-4:
2385
+ * has_access:false with reasons:[] when the caller IS the owner but
2386
+ * the viewer can't see.
2387
+ */
2388
+ trace(query: ShareTraceQuery): Promise<ShareTraceResult>;
2147
2389
  }
2148
2390
  declare class RecordingSplitsResource extends BaseResource {
2149
2391
  list(recordingId: string): Promise<any>;
@@ -2483,6 +2725,60 @@ declare class ImportDocumentsResource extends BaseResource {
2483
2725
  get(id: string): Promise<any>;
2484
2726
  ingest(content: string): Promise<any>;
2485
2727
  }
2728
+ export type AccessSimulateEntityType = "work" | "recording" | "person" | "release";
2729
+ export type AccessSimulateAction = "view" | "share_link_preview" | "claim" | "grant";
2730
+ export type AccessSimulateRecipientType = "user" | "anonymous" | "share_link";
2731
+ export interface AccessSimulateShareLinkConfig {
2732
+ access_type: "private" | "limited" | "public";
2733
+ allow_download?: boolean;
2734
+ allow_streaming?: boolean;
2735
+ allow_comments?: boolean;
2736
+ allow_view_collaborators?: boolean;
2737
+ allow_view_financials?: boolean;
2738
+ watermark_audio?: boolean;
2739
+ notify_on_access?: boolean;
2740
+ allowed_person_ids?: string[];
2741
+ sent_to_emails?: string[];
2742
+ max_views?: number | null;
2743
+ expires_at?: string | null;
2744
+ }
2745
+ export interface AccessSimulateInput {
2746
+ entity_type: AccessSimulateEntityType;
2747
+ entity_id: string;
2748
+ action: AccessSimulateAction;
2749
+ recipient: {
2750
+ type: AccessSimulateRecipientType;
2751
+ user_id?: string;
2752
+ org_id?: string;
2753
+ share_config?: AccessSimulateShareLinkConfig;
2754
+ };
2755
+ }
2756
+ export type AccessSimulateRuleName = "rls" | "share_link" | "collaborator" | "cross_org_grant" | "identity_inheritance" | "not_yet_supported" | "entity_not_found";
2757
+ export interface AccessSimulateReason {
2758
+ rule: AccessSimulateRuleName;
2759
+ decision: "allow" | "deny" | "info";
2760
+ detail: string;
2761
+ applies_to?: string[];
2762
+ }
2763
+ export interface AccessSimulateWarning {
2764
+ severity: "info" | "warn" | "error";
2765
+ message: string;
2766
+ }
2767
+ export interface AccessSimulateResult {
2768
+ entity_type: AccessSimulateEntityType;
2769
+ entity_id: string;
2770
+ action: AccessSimulateAction;
2771
+ visible: boolean;
2772
+ visible_fields: string[];
2773
+ hidden_fields: string[];
2774
+ visible_relations: Record<string, "visible" | "hidden" | "watermarked">;
2775
+ reasons: AccessSimulateReason[];
2776
+ warnings: AccessSimulateWarning[];
2777
+ not_yet_supported?: boolean;
2778
+ }
2779
+ declare class AccessSimulateResource extends BaseResource {
2780
+ simulate(input: AccessSimulateInput): Promise<AccessSimulateResult>;
2781
+ }
2486
2782
  export declare class PicaClient {
2487
2783
  works: WorksResource;
2488
2784
  people: PeopleResource;
@@ -2529,6 +2825,9 @@ export declare class PicaClient {
2529
2825
  splitSheets: SplitSheetsResource;
2530
2826
  recordingSplits: RecordingSplitsResource;
2531
2827
  recordingCredits: RecordingCreditsResource;
2828
+ shareTrace: ShareTraceResource;
2829
+ countExplain: CountExplainResource;
2830
+ audioPipelineStatus: AudioPipelineStatusResource;
2532
2831
  publishers: PublishersResource;
2533
2832
  labels: LabelsResource;
2534
2833
  agreementTemplates: AgreementTemplatesResource;
@@ -2550,6 +2849,9 @@ export declare class PicaClient {
2550
2849
  agentIdentity: AgentIdentityResource;
2551
2850
  uploads: UploadsResource;
2552
2851
  groups: GroupsResource;
2852
+ assistantInteractions: AssistantInteractionsResource;
2853
+ shareSend: ShareSendResource;
2854
+ accessSimulate: AccessSimulateResource;
2553
2855
  /**
2554
2856
  * Get accurate catalog stats via SQL counts (no pagination limits)
2555
2857
  */