@withpica/mcp-sdk 1.25.0 → 1.26.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,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?: {
@@ -2144,6 +2258,133 @@ export interface RecordingCreditCreateInput {
2144
2258
  declare class RecordingCreditsResource extends BaseResource {
2145
2259
  list(recordingId: string): Promise<RecordingCredit[]>;
2146
2260
  create(recordingId: string, input: RecordingCreditCreateInput): Promise<RecordingCredit>;
2261
+ /**
2262
+ * ADR-232 atomic add — semantically identical to `create` (a recording
2263
+ * credit INSERT is already atomic) but reads more naturally next to
2264
+ * CreditsResource.atomicAdd in the pica_credit_add tool implementation.
2265
+ */
2266
+ atomicAdd(recordingId: string, input: RecordingCreditCreateInput): Promise<AtomicCreditResult>;
2267
+ /**
2268
+ * ADR-232 atomic remove — DELETE with `?atomic=1` so the route returns 403
2269
+ * INSUFFICIENT_SCOPE on 0-row instead of the legacy lenient silent
2270
+ * success. AC-2 strict semantics for pica_credit_remove.
2271
+ */
2272
+ atomicRemove(recordingId: string, creditId: string): Promise<AtomicCreditResult>;
2273
+ }
2274
+ export type ShareTraceEntityType = "work" | "recording" | "person";
2275
+ export interface ShareTraceQuery {
2276
+ entity_type: ShareTraceEntityType;
2277
+ entity_id: string;
2278
+ viewer_user_id?: string;
2279
+ viewer_org_id?: string;
2280
+ }
2281
+ export interface ShareTraceReason {
2282
+ kind: "org_membership" | "custody_chain" | "share_link" | "cross_org_grant";
2283
+ directness: 1 | 2 | 3 | 4;
2284
+ via_org_id?: string;
2285
+ via_org_name?: string | null;
2286
+ chain_hops?: Array<{
2287
+ custodian_org_id: string;
2288
+ custodian_org_name?: string | null;
2289
+ percentage: number;
2290
+ territory: string;
2291
+ }>;
2292
+ share_link_id?: string;
2293
+ expires_at?: string | null;
2294
+ grant_id?: string;
2295
+ scope?: string[];
2296
+ granted_at?: string | null;
2297
+ }
2298
+ export interface ShareTraceResult {
2299
+ entity: {
2300
+ type: ShareTraceEntityType;
2301
+ id: string;
2302
+ name: string;
2303
+ };
2304
+ viewer: {
2305
+ type: "user" | "org";
2306
+ id: string;
2307
+ name: string | null;
2308
+ };
2309
+ has_access: boolean;
2310
+ reasons: ShareTraceReason[];
2311
+ }
2312
+ export interface CountExplainQuery {
2313
+ count_source: string;
2314
+ observed_value?: number;
2315
+ }
2316
+ export interface CountExplainResult {
2317
+ source: {
2318
+ name: string;
2319
+ query: string;
2320
+ description: string;
2321
+ };
2322
+ computed_value: number;
2323
+ observed_value: number | null;
2324
+ delta: number | null;
2325
+ delta_breakdown?: Array<{
2326
+ reason: string;
2327
+ count: number;
2328
+ sample_ids: string[];
2329
+ }>;
2330
+ }
2331
+ declare class CountExplainResource extends BaseResource {
2332
+ /**
2333
+ * GET /admin/count-explain — explains a single dashboard / briefing
2334
+ * count by reproducing the canonical query and (optionally) breaking
2335
+ * down the delta against an observed value.
2336
+ */
2337
+ explain(query: CountExplainQuery): Promise<CountExplainResult>;
2338
+ }
2339
+ export interface AudioPipelineStatusQuery {
2340
+ window_days?: number;
2341
+ }
2342
+ export interface AudioPipelineByState {
2343
+ pending: number;
2344
+ complete: number;
2345
+ failed: number;
2346
+ stuck_over_24h: number;
2347
+ }
2348
+ export interface AudioPipelineStatusResult {
2349
+ window_days: number;
2350
+ by_state: AudioPipelineByState;
2351
+ samples: {
2352
+ pending: Array<{
2353
+ audio_file_id: string;
2354
+ work_id: string | null;
2355
+ queued_at: string;
2356
+ }>;
2357
+ failed: Array<{
2358
+ audio_file_id: string;
2359
+ work_id: string | null;
2360
+ error: string | null;
2361
+ last_attempt: string | null;
2362
+ }>;
2363
+ stuck_over_24h: Array<{
2364
+ audio_file_id: string;
2365
+ work_id: string | null;
2366
+ queued_at: string;
2367
+ last_attempt: string | null;
2368
+ }>;
2369
+ };
2370
+ }
2371
+ declare class AudioPipelineStatusResource extends BaseResource {
2372
+ /**
2373
+ * GET /admin/audio-pipeline-status — operational read of the audio
2374
+ * analysis pipeline state for the calling org. AC-7: every bucket is
2375
+ * an integer (zero-org reports structured zeros, not nulls).
2376
+ */
2377
+ status(query?: AudioPipelineStatusQuery): Promise<AudioPipelineStatusResult>;
2378
+ }
2379
+ declare class ShareTraceResource extends BaseResource {
2380
+ /**
2381
+ * GET /admin/share-trace — returns the unioned chain of reasons a
2382
+ * viewer can see an entity. AC-3: 403 + INSUFFICIENT_SCOPE if the
2383
+ * caller doesn't own the entity (existence-leak protection). AC-4:
2384
+ * has_access:false with reasons:[] when the caller IS the owner but
2385
+ * the viewer can't see.
2386
+ */
2387
+ trace(query: ShareTraceQuery): Promise<ShareTraceResult>;
2147
2388
  }
2148
2389
  declare class RecordingSplitsResource extends BaseResource {
2149
2390
  list(recordingId: string): Promise<any>;
@@ -2483,6 +2724,60 @@ declare class ImportDocumentsResource extends BaseResource {
2483
2724
  get(id: string): Promise<any>;
2484
2725
  ingest(content: string): Promise<any>;
2485
2726
  }
2727
+ export type AccessSimulateEntityType = "work" | "recording" | "person" | "release";
2728
+ export type AccessSimulateAction = "view" | "share_link_preview" | "claim" | "grant";
2729
+ export type AccessSimulateRecipientType = "user" | "anonymous" | "share_link";
2730
+ export interface AccessSimulateShareLinkConfig {
2731
+ access_type: "private" | "limited" | "public";
2732
+ allow_download?: boolean;
2733
+ allow_streaming?: boolean;
2734
+ allow_comments?: boolean;
2735
+ allow_view_collaborators?: boolean;
2736
+ allow_view_financials?: boolean;
2737
+ watermark_audio?: boolean;
2738
+ notify_on_access?: boolean;
2739
+ allowed_person_ids?: string[];
2740
+ sent_to_emails?: string[];
2741
+ max_views?: number | null;
2742
+ expires_at?: string | null;
2743
+ }
2744
+ export interface AccessSimulateInput {
2745
+ entity_type: AccessSimulateEntityType;
2746
+ entity_id: string;
2747
+ action: AccessSimulateAction;
2748
+ recipient: {
2749
+ type: AccessSimulateRecipientType;
2750
+ user_id?: string;
2751
+ org_id?: string;
2752
+ share_config?: AccessSimulateShareLinkConfig;
2753
+ };
2754
+ }
2755
+ export type AccessSimulateRuleName = "rls" | "share_link" | "collaborator" | "cross_org_grant" | "identity_inheritance" | "not_yet_supported" | "entity_not_found";
2756
+ export interface AccessSimulateReason {
2757
+ rule: AccessSimulateRuleName;
2758
+ decision: "allow" | "deny" | "info";
2759
+ detail: string;
2760
+ applies_to?: string[];
2761
+ }
2762
+ export interface AccessSimulateWarning {
2763
+ severity: "info" | "warn" | "error";
2764
+ message: string;
2765
+ }
2766
+ export interface AccessSimulateResult {
2767
+ entity_type: AccessSimulateEntityType;
2768
+ entity_id: string;
2769
+ action: AccessSimulateAction;
2770
+ visible: boolean;
2771
+ visible_fields: string[];
2772
+ hidden_fields: string[];
2773
+ visible_relations: Record<string, "visible" | "hidden" | "watermarked">;
2774
+ reasons: AccessSimulateReason[];
2775
+ warnings: AccessSimulateWarning[];
2776
+ not_yet_supported?: boolean;
2777
+ }
2778
+ declare class AccessSimulateResource extends BaseResource {
2779
+ simulate(input: AccessSimulateInput): Promise<AccessSimulateResult>;
2780
+ }
2486
2781
  export declare class PicaClient {
2487
2782
  works: WorksResource;
2488
2783
  people: PeopleResource;
@@ -2529,6 +2824,9 @@ export declare class PicaClient {
2529
2824
  splitSheets: SplitSheetsResource;
2530
2825
  recordingSplits: RecordingSplitsResource;
2531
2826
  recordingCredits: RecordingCreditsResource;
2827
+ shareTrace: ShareTraceResource;
2828
+ countExplain: CountExplainResource;
2829
+ audioPipelineStatus: AudioPipelineStatusResource;
2532
2830
  publishers: PublishersResource;
2533
2831
  labels: LabelsResource;
2534
2832
  agreementTemplates: AgreementTemplatesResource;
@@ -2550,6 +2848,9 @@ export declare class PicaClient {
2550
2848
  agentIdentity: AgentIdentityResource;
2551
2849
  uploads: UploadsResource;
2552
2850
  groups: GroupsResource;
2851
+ assistantInteractions: AssistantInteractionsResource;
2852
+ shareSend: ShareSendResource;
2853
+ accessSimulate: AccessSimulateResource;
2553
2854
  /**
2554
2855
  * Get accurate catalog stats via SQL counts (no pagination limits)
2555
2856
  */