@withpica/mcp-server 2.5.2 → 2.6.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.
Files changed (275) hide show
  1. package/assets/fonts/GeistSans-Light.woff2 +0 -0
  2. package/assets/fonts/InstrumentSerif-Italic.woff2 +0 -0
  3. package/assets/fonts/InstrumentSerif-Regular.woff2 +0 -0
  4. package/dist/apps/download.d.ts +2 -0
  5. package/dist/apps/download.d.ts.map +1 -0
  6. package/dist/apps/download.js +125 -0
  7. package/dist/apps/download.js.map +1 -0
  8. package/dist/apps/generated/shared-bundle.d.ts +5 -0
  9. package/dist/apps/generated/shared-bundle.d.ts.map +1 -0
  10. package/dist/apps/generated/shared-bundle.js +7 -0
  11. package/dist/apps/generated/shared-bundle.js.map +1 -0
  12. package/dist/apps/shared.d.ts +15 -0
  13. package/dist/apps/shared.d.ts.map +1 -0
  14. package/dist/apps/shared.js +480 -0
  15. package/dist/apps/shared.js.map +1 -0
  16. package/dist/apps/upload.d.ts +2 -0
  17. package/dist/apps/upload.d.ts.map +1 -0
  18. package/dist/apps/upload.js +280 -0
  19. package/dist/apps/upload.js.map +1 -0
  20. package/dist/config.d.ts +4 -25
  21. package/dist/config.d.ts.map +1 -1
  22. package/dist/config.js +30 -12
  23. package/dist/config.js.map +1 -1
  24. package/dist/index.js +3 -3
  25. package/dist/index.js.map +1 -1
  26. package/dist/prompts/index.js +24 -24
  27. package/dist/prompts/index.js.map +1 -1
  28. package/dist/resources/index.d.ts +4 -2
  29. package/dist/resources/index.d.ts.map +1 -1
  30. package/dist/resources/index.js +133 -54
  31. package/dist/resources/index.js.map +1 -1
  32. package/dist/resources/llms-primer.d.ts +1 -1
  33. package/dist/resources/llms-primer.d.ts.map +1 -1
  34. package/dist/resources/llms-primer.js +4 -4
  35. package/dist/server-instructions.d.ts +9 -0
  36. package/dist/server-instructions.d.ts.map +1 -0
  37. package/dist/server-instructions.js +34 -0
  38. package/dist/server-instructions.js.map +1 -0
  39. package/dist/server.d.ts +4 -0
  40. package/dist/server.d.ts.map +1 -1
  41. package/dist/server.js +46 -12
  42. package/dist/server.js.map +1 -1
  43. package/dist/tools/agreement-types.d.ts +10 -20
  44. package/dist/tools/agreement-types.d.ts.map +1 -1
  45. package/dist/tools/agreement-types.js +203 -419
  46. package/dist/tools/agreement-types.js.map +1 -1
  47. package/dist/tools/agreements.d.ts +3 -4
  48. package/dist/tools/agreements.d.ts.map +1 -1
  49. package/dist/tools/agreements.js +72 -52
  50. package/dist/tools/agreements.js.map +1 -1
  51. package/dist/tools/analytics.d.ts +1 -1
  52. package/dist/tools/analytics.d.ts.map +1 -1
  53. package/dist/tools/analytics.js +1 -1
  54. package/dist/tools/analytics.js.map +1 -1
  55. package/dist/tools/app-tools.d.ts +21 -0
  56. package/dist/tools/app-tools.d.ts.map +1 -0
  57. package/dist/tools/app-tools.js +248 -0
  58. package/dist/tools/app-tools.js.map +1 -0
  59. package/dist/tools/assets.d.ts +2 -4
  60. package/dist/tools/assets.d.ts.map +1 -1
  61. package/dist/tools/assets.js +278 -59
  62. package/dist/tools/assets.js.map +1 -1
  63. package/dist/tools/audio-files.d.ts +3 -4
  64. package/dist/tools/audio-files.d.ts.map +1 -1
  65. package/dist/tools/audio-files.js +63 -35
  66. package/dist/tools/audio-files.js.map +1 -1
  67. package/dist/tools/auth.d.ts +20 -0
  68. package/dist/tools/auth.d.ts.map +1 -0
  69. package/dist/tools/auth.js +200 -0
  70. package/dist/tools/auth.js.map +1 -0
  71. package/dist/tools/bulk.d.ts +1 -1
  72. package/dist/tools/bulk.d.ts.map +1 -1
  73. package/dist/tools/bulk.js +1 -1
  74. package/dist/tools/bulk.js.map +1 -1
  75. package/dist/tools/calendar.d.ts +1 -1
  76. package/dist/tools/calendar.d.ts.map +1 -1
  77. package/dist/tools/calendar.js +1 -1
  78. package/dist/tools/calendar.js.map +1 -1
  79. package/dist/tools/collaborators.d.ts +1 -1
  80. package/dist/tools/collaborators.d.ts.map +1 -1
  81. package/dist/tools/collaborators.js +2 -2
  82. package/dist/tools/collaborators.js.map +1 -1
  83. package/dist/tools/comparisons.d.ts +1 -1
  84. package/dist/tools/comparisons.d.ts.map +1 -1
  85. package/dist/tools/comparisons.js +1 -1
  86. package/dist/tools/comparisons.js.map +1 -1
  87. package/dist/tools/credits.d.ts +1 -1
  88. package/dist/tools/credits.d.ts.map +1 -1
  89. package/dist/tools/credits.js +130 -20
  90. package/dist/tools/credits.js.map +1 -1
  91. package/dist/tools/dashboard.d.ts +2 -3
  92. package/dist/tools/dashboard.d.ts.map +1 -1
  93. package/dist/tools/dashboard.js +20 -28
  94. package/dist/tools/dashboard.js.map +1 -1
  95. package/dist/tools/directory.d.ts +1 -1
  96. package/dist/tools/directory.d.ts.map +1 -1
  97. package/dist/tools/directory.js +1 -1
  98. package/dist/tools/directory.js.map +1 -1
  99. package/dist/tools/discovery.d.ts +28 -0
  100. package/dist/tools/discovery.d.ts.map +1 -0
  101. package/dist/tools/discovery.js +560 -0
  102. package/dist/tools/discovery.js.map +1 -0
  103. package/dist/tools/disputes.d.ts +1 -1
  104. package/dist/tools/disputes.d.ts.map +1 -1
  105. package/dist/tools/disputes.js +1 -1
  106. package/dist/tools/disputes.js.map +1 -1
  107. package/dist/tools/documents.d.ts +1 -1
  108. package/dist/tools/documents.d.ts.map +1 -1
  109. package/dist/tools/documents.js +1 -1
  110. package/dist/tools/documents.js.map +1 -1
  111. package/dist/tools/duplicates.d.ts +1 -1
  112. package/dist/tools/duplicates.d.ts.map +1 -1
  113. package/dist/tools/duplicates.js +18 -1
  114. package/dist/tools/duplicates.js.map +1 -1
  115. package/dist/tools/enrichment.d.ts +1 -4
  116. package/dist/tools/enrichment.d.ts.map +1 -1
  117. package/dist/tools/enrichment.js +19 -122
  118. package/dist/tools/enrichment.js.map +1 -1
  119. package/dist/tools/exports.d.ts +1 -1
  120. package/dist/tools/exports.d.ts.map +1 -1
  121. package/dist/tools/exports.js +2 -2
  122. package/dist/tools/exports.js.map +1 -1
  123. package/dist/tools/import-documents.d.ts +4 -4
  124. package/dist/tools/import-documents.d.ts.map +1 -1
  125. package/dist/tools/import-documents.js +65 -51
  126. package/dist/tools/import-documents.js.map +1 -1
  127. package/dist/tools/import.d.ts +2 -1
  128. package/dist/tools/import.d.ts.map +1 -1
  129. package/dist/tools/import.js +64 -2
  130. package/dist/tools/import.js.map +1 -1
  131. package/dist/tools/index.d.ts +50 -5
  132. package/dist/tools/index.d.ts.map +1 -1
  133. package/dist/tools/index.js +440 -84
  134. package/dist/tools/index.js.map +1 -1
  135. package/dist/tools/integrations.d.ts +1 -1
  136. package/dist/tools/integrations.d.ts.map +1 -1
  137. package/dist/tools/integrations.js +1 -1
  138. package/dist/tools/integrations.js.map +1 -1
  139. package/dist/tools/licensing.d.ts +1 -1
  140. package/dist/tools/licensing.d.ts.map +1 -1
  141. package/dist/tools/licensing.js +1 -1
  142. package/dist/tools/licensing.js.map +1 -1
  143. package/dist/tools/memory.d.ts +1 -1
  144. package/dist/tools/memory.d.ts.map +1 -1
  145. package/dist/tools/memory.js +1 -1
  146. package/dist/tools/memory.js.map +1 -1
  147. package/dist/tools/metadata.d.ts +15 -0
  148. package/dist/tools/metadata.d.ts.map +1 -0
  149. package/dist/tools/metadata.js +1069 -0
  150. package/dist/tools/metadata.js.map +1 -0
  151. package/dist/tools/multimedia.d.ts +1 -1
  152. package/dist/tools/multimedia.d.ts.map +1 -1
  153. package/dist/tools/multimedia.js +1 -1
  154. package/dist/tools/multimedia.js.map +1 -1
  155. package/dist/tools/notes.d.ts +1 -1
  156. package/dist/tools/notes.d.ts.map +1 -1
  157. package/dist/tools/notes.js +1 -1
  158. package/dist/tools/notes.js.map +1 -1
  159. package/dist/tools/notifications.d.ts +1 -1
  160. package/dist/tools/notifications.d.ts.map +1 -1
  161. package/dist/tools/notifications.js +1 -1
  162. package/dist/tools/notifications.js.map +1 -1
  163. package/dist/tools/people.d.ts +5 -13
  164. package/dist/tools/people.d.ts.map +1 -1
  165. package/dist/tools/people.js +148 -109
  166. package/dist/tools/people.js.map +1 -1
  167. package/dist/tools/projects.d.ts +1 -1
  168. package/dist/tools/projects.d.ts.map +1 -1
  169. package/dist/tools/projects.js +1 -1
  170. package/dist/tools/projects.js.map +1 -1
  171. package/dist/tools/publishers.d.ts +16 -0
  172. package/dist/tools/publishers.d.ts.map +1 -0
  173. package/dist/tools/publishers.js +69 -0
  174. package/dist/tools/publishers.js.map +1 -0
  175. package/dist/tools/purchases.d.ts +1 -1
  176. package/dist/tools/purchases.d.ts.map +1 -1
  177. package/dist/tools/purchases.js +1 -1
  178. package/dist/tools/purchases.js.map +1 -1
  179. package/dist/tools/recordings.d.ts +9 -9
  180. package/dist/tools/recordings.d.ts.map +1 -1
  181. package/dist/tools/recordings.js +121 -48
  182. package/dist/tools/recordings.js.map +1 -1
  183. package/dist/tools/recovery-hints.d.ts +14 -0
  184. package/dist/tools/recovery-hints.d.ts.map +1 -0
  185. package/dist/tools/recovery-hints.js +277 -0
  186. package/dist/tools/recovery-hints.js.map +1 -0
  187. package/dist/tools/releases.d.ts +1 -1
  188. package/dist/tools/releases.d.ts.map +1 -1
  189. package/dist/tools/releases.js +1 -1
  190. package/dist/tools/releases.js.map +1 -1
  191. package/dist/tools/royalties.d.ts +1 -1
  192. package/dist/tools/royalties.d.ts.map +1 -1
  193. package/dist/tools/royalties.js +2 -2
  194. package/dist/tools/royalties.js.map +1 -1
  195. package/dist/tools/search.d.ts +1 -1
  196. package/dist/tools/search.d.ts.map +1 -1
  197. package/dist/tools/search.js +3 -3
  198. package/dist/tools/search.js.map +1 -1
  199. package/dist/tools/send.d.ts +2 -3
  200. package/dist/tools/send.d.ts.map +1 -1
  201. package/dist/tools/send.js +20 -28
  202. package/dist/tools/send.js.map +1 -1
  203. package/dist/tools/sessions.d.ts +1 -1
  204. package/dist/tools/sessions.d.ts.map +1 -1
  205. package/dist/tools/sessions.js +1 -1
  206. package/dist/tools/sessions.js.map +1 -1
  207. package/dist/tools/settings.d.ts +1 -1
  208. package/dist/tools/settings.d.ts.map +1 -1
  209. package/dist/tools/settings.js +1 -1
  210. package/dist/tools/settings.js.map +1 -1
  211. package/dist/tools/share-links.d.ts +1 -1
  212. package/dist/tools/share-links.d.ts.map +1 -1
  213. package/dist/tools/share-links.js +1 -1
  214. package/dist/tools/share-links.js.map +1 -1
  215. package/dist/tools/split-sheets.d.ts +1 -1
  216. package/dist/tools/split-sheets.d.ts.map +1 -1
  217. package/dist/tools/split-sheets.js +13 -1
  218. package/dist/tools/split-sheets.js.map +1 -1
  219. package/dist/tools/team.d.ts +1 -1
  220. package/dist/tools/team.d.ts.map +1 -1
  221. package/dist/tools/team.js +1 -1
  222. package/dist/tools/team.js.map +1 -1
  223. package/dist/tools/telegram.d.ts +1 -1
  224. package/dist/tools/telegram.d.ts.map +1 -1
  225. package/dist/tools/telegram.js +1 -1
  226. package/dist/tools/telegram.js.map +1 -1
  227. package/dist/tools/uploads.d.ts +1 -1
  228. package/dist/tools/uploads.d.ts.map +1 -1
  229. package/dist/tools/uploads.js +1 -1
  230. package/dist/tools/uploads.js.map +1 -1
  231. package/dist/tools/works.d.ts +5 -13
  232. package/dist/tools/works.d.ts.map +1 -1
  233. package/dist/tools/works.js +201 -116
  234. package/dist/tools/works.js.map +1 -1
  235. package/package.json +5 -1
  236. package/scripts/bundle-apps.ts +61 -0
  237. package/.mcpregistry_github_token +0 -1
  238. package/.mcpregistry_registry_token +0 -1
  239. package/dist/pica-sdk.d.ts +0 -1170
  240. package/dist/pica-sdk.d.ts.map +0 -1
  241. package/dist/pica-sdk.js +0 -1403
  242. package/dist/pica-sdk.js.map +0 -1
  243. package/dist/tools/health.d.ts +0 -17
  244. package/dist/tools/health.d.ts.map +0 -1
  245. package/dist/tools/health.js +0 -67
  246. package/dist/tools/health.js.map +0 -1
  247. package/dist/tools/pica-score.d.ts +0 -15
  248. package/dist/tools/pica-score.d.ts.map +0 -1
  249. package/dist/tools/pica-score.js +0 -28
  250. package/dist/tools/pica-score.js.map +0 -1
  251. package/dist/tools/registration.d.ts +0 -16
  252. package/dist/tools/registration.d.ts.map +0 -1
  253. package/dist/tools/registration.js +0 -50
  254. package/dist/tools/registration.js.map +0 -1
  255. package/dist/utils/credit-gate.d.ts +0 -17
  256. package/dist/utils/credit-gate.d.ts.map +0 -1
  257. package/dist/utils/credit-gate.js +0 -100
  258. package/dist/utils/credit-gate.js.map +0 -1
  259. package/dist/utils/errors.d.ts +0 -29
  260. package/dist/utils/errors.d.ts.map +0 -1
  261. package/dist/utils/errors.js +0 -115
  262. package/dist/utils/errors.js.map +0 -1
  263. package/dist/utils/formatting.d.ts +0 -63
  264. package/dist/utils/formatting.d.ts.map +0 -1
  265. package/dist/utils/formatting.js +0 -125
  266. package/dist/utils/formatting.js.map +0 -1
  267. package/dist/utils/mpp.d.ts +0 -63
  268. package/dist/utils/mpp.d.ts.map +0 -1
  269. package/dist/utils/mpp.js +0 -137
  270. package/dist/utils/mpp.js.map +0 -1
  271. package/dist/utils/notify-parties.d.ts +0 -35
  272. package/dist/utils/notify-parties.d.ts.map +0 -1
  273. package/dist/utils/notify-parties.js +0 -59
  274. package/dist/utils/notify-parties.js.map +0 -1
  275. package/server.json +0 -30
@@ -1,517 +1,375 @@
1
1
  // Copyright (c) 2024-2026 Withpica Ltd. All rights reserved.
2
- import { formatAsText, formatList, formatSuccess, } from "../utils/formatting.js";
3
- import { notifyParties, summarizeNotifications, } from "../utils/notify-parties.js";
2
+ import { formatAsText, formatList, formatSuccess } from "@withpica/mcp-utils";
3
+ import { notifyParties, summarizeNotifications } from "@withpica/mcp-utils";
4
4
  export class AgreementTypesTools {
5
5
  pica;
6
6
  constructor(pica) {
7
7
  this.pica = pica;
8
8
  }
9
+ getResource(type) {
10
+ switch (type) {
11
+ case "template":
12
+ return this.pica.agreementTemplates;
13
+ case "producer":
14
+ return this.pica.producerAgreements;
15
+ case "work_for_hire":
16
+ return this.pica.workForHire;
17
+ default:
18
+ throw new Error(`Unknown agreement type: ${type}`);
19
+ }
20
+ }
21
+ labelFor(type) {
22
+ switch (type) {
23
+ case "template":
24
+ return "Agreement template";
25
+ case "producer":
26
+ return "Producer agreement";
27
+ case "work_for_hire":
28
+ return "Work-for-hire agreement";
29
+ }
30
+ }
9
31
  getTools() {
10
32
  return [
11
- // ── Agreement Templates ──────────────────────────────────────────
33
+ // ── Unified CRUD ────────────────────────────────────────────────
12
34
  {
13
35
  definition: {
14
- name: "pica_agreement_templates_list",
15
- description: "List reusable agreement templatespublishing, split sheet, production deals. Returns all templates for the organisation.",
16
- inputSchema: {
17
- type: "object",
18
- properties: {},
19
- },
20
- },
21
- executor: this.listTemplates.bind(this),
22
- },
23
- {
24
- definition: {
25
- name: "pica_agreement_templates_get",
26
- description: "Get a specific agreement template with its full body, placeholders, and metadata.",
36
+ name: "pica_agreement_types_query",
37
+ description: "List agreements by typetemplates, producer agreements, or work-for-hire contracts.",
27
38
  inputSchema: {
28
39
  type: "object",
29
40
  properties: {
30
- id: {
41
+ type: {
31
42
  type: "string",
32
- description: "Template ID",
43
+ enum: ["template", "producer", "work_for_hire"],
44
+ description: "Agreement sub-type to query",
45
+ },
46
+ limit: {
47
+ type: "number",
48
+ description: "Max results",
33
49
  },
34
50
  },
35
- required: ["id"],
51
+ required: ["type"],
36
52
  },
37
53
  },
38
- executor: this.getTemplate.bind(this),
54
+ executor: this.query.bind(this),
39
55
  },
40
56
  {
41
57
  definition: {
42
- name: "pica_agreement_templates_create",
43
- description: "Create a new agreement template. Define the template body with placeholders like {{work_title}}, {{artist_name}}, {{split_percentage}} that get filled when rendering.",
58
+ name: "pica_agreement_types_inspect",
59
+ description: "Get a specific agreement by type and ID full details including body, terms, and metadata.",
44
60
  inputSchema: {
45
61
  type: "object",
46
62
  properties: {
47
- name: {
48
- type: "string",
49
- description: "Template name (e.g. 'Standard Publishing Deal')",
50
- },
51
- template_type: {
63
+ type: {
52
64
  type: "string",
53
- description: "Type of agreement this template produces (e.g. publishing_admin, production, split_sheet)",
65
+ enum: ["template", "producer", "work_for_hire"],
66
+ description: "Agreement sub-type",
54
67
  },
55
- body: {
56
- type: "string",
57
- description: "Template body with placeholders — use {{placeholder_name}} syntax",
58
- },
59
- description: {
68
+ id: {
60
69
  type: "string",
61
- description: "Short description of when to use this template",
62
- },
63
- is_default: {
64
- type: "boolean",
65
- description: "Whether this is the default template for its type",
70
+ description: "Agreement ID",
66
71
  },
67
72
  },
68
- required: ["name", "template_type", "body"],
73
+ required: ["type", "id"],
69
74
  },
70
75
  },
71
- executor: this.createTemplate.bind(this),
76
+ executor: this.inspect.bind(this),
72
77
  },
73
78
  {
74
79
  definition: {
75
- name: "pica_agreement_templates_update",
76
- description: "Update an existing agreement template.",
80
+ name: "pica_agreement_types_create",
81
+ description: "Create a new agreement of the specified type. Templates need name + template_type + body. " +
82
+ "Producer agreements need title (plus optional advance, points, recoupment). " +
83
+ "Work-for-hire needs title (plus optional fee, contractor, rights).",
77
84
  inputSchema: {
78
85
  type: "object",
79
86
  properties: {
80
- id: {
87
+ type: {
81
88
  type: "string",
82
- description: "Template ID",
89
+ enum: ["template", "producer", "work_for_hire"],
90
+ description: "Agreement sub-type to create",
83
91
  },
92
+ // Template fields
84
93
  name: {
85
94
  type: "string",
86
- description: "Updated template name",
95
+ description: "Template name (templates only)",
87
96
  },
88
97
  template_type: {
89
98
  type: "string",
90
- description: "Updated template type",
99
+ description: "Type of agreement this template produces (templates only)",
91
100
  },
92
101
  body: {
93
102
  type: "string",
94
- description: "Updated template body",
103
+ description: "Template body with {{placeholders}} (templates only)",
95
104
  },
96
105
  description: {
97
106
  type: "string",
98
- description: "Updated description",
107
+ description: "Short description",
99
108
  },
100
109
  is_default: {
101
110
  type: "boolean",
102
- description: "Set as default for its type",
103
- },
104
- },
105
- required: ["id"],
106
- },
107
- },
108
- executor: this.updateTemplate.bind(this),
109
- },
110
- {
111
- definition: {
112
- name: "pica_agreement_templates_delete",
113
- description: "Delete an agreement template.",
114
- inputSchema: {
115
- type: "object",
116
- properties: {
117
- id: {
118
- type: "string",
119
- description: "Template ID",
111
+ description: "Set as default for its type (templates only)",
120
112
  },
121
- },
122
- required: ["id"],
123
- },
124
- },
125
- executor: this.deleteTemplate.bind(this),
126
- },
127
- {
128
- definition: {
129
- name: "pica_agreement_templates_render",
130
- description: "Fill an agreement template with work and people data — generates a ready-to-send agreement. Pass the template ID plus work_id and/or people_ids to populate the placeholders with real catalog data.",
131
- inputSchema: {
132
- type: "object",
133
- properties: {
134
- id: {
113
+ // Producer + work-for-hire shared
114
+ title: {
135
115
  type: "string",
136
- description: "Template ID to render",
116
+ description: "Agreement title (producer / work-for-hire)",
137
117
  },
138
118
  work_id: {
139
119
  type: "string",
140
- description: "Work ID to pull title, credits, and metadata from",
141
- },
142
- people_ids: {
143
- type: "array",
144
- items: { type: "string" },
145
- description: "People IDs to include as parties in the agreement",
146
- },
147
- variables: {
148
- type: "object",
149
- description: "Additional variables to substitute — keys match placeholder names in the template body",
150
- },
151
- },
152
- required: ["id"],
153
- },
154
- },
155
- executor: this.renderTemplate.bind(this),
156
- },
157
- {
158
- definition: {
159
- name: "pica_agreement_templates_duplicate",
160
- description: "Duplicate an agreement template — creates a copy you can customise without changing the original.",
161
- inputSchema: {
162
- type: "object",
163
- properties: {
164
- id: {
165
- type: "string",
166
- description: "Template ID to duplicate",
167
- },
168
- },
169
- required: ["id"],
170
- },
171
- },
172
- executor: this.duplicateTemplate.bind(this),
173
- },
174
- {
175
- definition: {
176
- name: "pica_agreement_templates_set_default",
177
- description: "Set a template as the default for its type — when creating agreements of that type, this template will be suggested first.",
178
- inputSchema: {
179
- type: "object",
180
- properties: {
181
- id: {
182
- type: "string",
183
- description: "Template ID to set as default",
120
+ description: "Work this agreement covers",
184
121
  },
185
- },
186
- required: ["id"],
187
- },
188
- },
189
- executor: this.setDefaultTemplate.bind(this),
190
- },
191
- // ── Producer Agreements ──────────────────────────────────────────
192
- {
193
- definition: {
194
- name: "pica_producer_agreements_list",
195
- description: "List producer agreements — advance + points deals with recoupment tracking. Shows all producer deals for the catalogue.",
196
- inputSchema: {
197
- type: "object",
198
- properties: {},
199
- },
200
- },
201
- executor: this.listProducerAgreements.bind(this),
202
- },
203
- {
204
- definition: {
205
- name: "pica_producer_agreements_get",
206
- description: "Get a producer agreement with full details including advance amount, points percentage, and recoupment status.",
207
- inputSchema: {
208
- type: "object",
209
- properties: {
210
- id: {
122
+ status: {
211
123
  type: "string",
212
- description: "Producer agreement ID",
124
+ enum: ["draft", "active", "completed", "terminated"],
125
+ description: "Agreement status",
213
126
  },
214
- },
215
- required: ["id"],
216
- },
217
- },
218
- executor: this.getProducerAgreement.bind(this),
219
- },
220
- {
221
- definition: {
222
- name: "pica_producer_agreements_create",
223
- description: "Create a producer agreement — set advance, points percentage, and recoupment terms. Links a producer to a work or recording with specific commercial terms.",
224
- inputSchema: {
225
- type: "object",
226
- properties: {
227
- title: {
127
+ notes: {
228
128
  type: "string",
229
- description: "Agreement title",
129
+ description: "Internal notes",
230
130
  },
131
+ // Producer-specific
231
132
  producer_id: {
232
133
  type: "string",
233
- description: "Person ID of the producer",
234
- },
235
- work_id: {
236
- type: "string",
237
- description: "Work this agreement covers",
134
+ description: "Person ID of the producer (producer only)",
238
135
  },
239
136
  recording_id: {
240
137
  type: "string",
241
- description: "Recording this agreement covers (if specific)",
138
+ description: "Recording this agreement covers (producer only)",
242
139
  },
243
140
  advance_amount: {
244
141
  type: "number",
245
- description: "Advance amount in the agreement currency",
142
+ description: "Advance amount (producer only)",
246
143
  },
247
144
  advance_currency: {
248
145
  type: "string",
249
- description: "Currency code (e.g. GBP, USD, EUR)",
146
+ description: "Currency code (producer only)",
250
147
  },
251
148
  points_percentage: {
252
149
  type: "number",
253
- description: "Producer points as a percentage of revenue (e.g. 3.5 for 3.5%)",
150
+ description: "Producer points percentage (producer only)",
254
151
  },
255
152
  recoupment_terms: {
256
153
  type: "string",
257
- description: "Description of recoupment terms (e.g. 'Advance recouped from producer share before royalty payments begin')",
154
+ description: "Recoupment terms (producer only)",
258
155
  },
259
- status: {
156
+ // Work-for-hire-specific
157
+ contractor_id: {
260
158
  type: "string",
261
- description: "Agreement status",
262
- enum: ["draft", "active", "completed", "terminated"],
159
+ description: "Person ID of the contractor (work-for-hire only)",
263
160
  },
264
- notes: {
161
+ fee_amount: {
162
+ type: "number",
163
+ description: "Flat fee amount (work-for-hire only)",
164
+ },
165
+ fee_currency: {
265
166
  type: "string",
266
- description: "Internal notes",
167
+ description: "Currency code (work-for-hire only)",
168
+ },
169
+ rights_assigned: {
170
+ type: "string",
171
+ description: "Rights being assigned (work-for-hire only)",
267
172
  },
268
173
  },
269
- required: ["title"],
174
+ required: ["type"],
270
175
  },
271
176
  },
272
- executor: this.createProducerAgreement.bind(this),
177
+ executor: this.create.bind(this),
273
178
  },
274
179
  {
275
180
  definition: {
276
- name: "pica_producer_agreements_update",
277
- description: "Update a producer agreement change advance, points, recoupment terms, or status.",
181
+ name: "pica_agreement_types_update",
182
+ description: "Update an existing agreement by type and ID.",
278
183
  inputSchema: {
279
184
  type: "object",
280
185
  properties: {
281
- id: {
282
- type: "string",
283
- description: "Producer agreement ID",
284
- },
285
- title: {
286
- type: "string",
287
- description: "Updated title",
288
- },
289
- producer_id: {
290
- type: "string",
291
- description: "Updated producer person ID",
292
- },
293
- work_id: {
294
- type: "string",
295
- description: "Updated work ID",
296
- },
297
- recording_id: {
298
- type: "string",
299
- description: "Updated recording ID",
300
- },
301
- advance_amount: {
302
- type: "number",
303
- description: "Updated advance amount",
304
- },
305
- advance_currency: {
186
+ type: {
306
187
  type: "string",
307
- description: "Updated currency code",
308
- },
309
- points_percentage: {
310
- type: "number",
311
- description: "Updated points percentage",
188
+ enum: ["template", "producer", "work_for_hire"],
189
+ description: "Agreement sub-type",
312
190
  },
313
- recoupment_terms: {
191
+ id: {
314
192
  type: "string",
315
- description: "Updated recoupment terms",
193
+ description: "Agreement ID",
316
194
  },
195
+ // All possible update fields (same as create minus type/id)
196
+ name: { type: "string" },
197
+ template_type: { type: "string" },
198
+ body: { type: "string" },
199
+ description: { type: "string" },
200
+ is_default: { type: "boolean" },
201
+ title: { type: "string" },
202
+ work_id: { type: "string" },
317
203
  status: {
318
204
  type: "string",
319
- description: "Updated status",
320
205
  enum: ["draft", "active", "completed", "terminated"],
321
206
  },
322
- notes: {
323
- type: "string",
324
- description: "Updated notes",
325
- },
207
+ notes: { type: "string" },
208
+ producer_id: { type: "string" },
209
+ recording_id: { type: "string" },
210
+ advance_amount: { type: "number" },
211
+ advance_currency: { type: "string" },
212
+ points_percentage: { type: "number" },
213
+ recoupment_terms: { type: "string" },
214
+ contractor_id: { type: "string" },
215
+ fee_amount: { type: "number" },
216
+ fee_currency: { type: "string" },
217
+ rights_assigned: { type: "string" },
326
218
  },
327
- required: ["id"],
219
+ required: ["type", "id"],
328
220
  },
329
221
  },
330
- executor: this.updateProducerAgreement.bind(this),
222
+ executor: this.update.bind(this),
331
223
  },
332
224
  {
333
225
  definition: {
334
- name: "pica_producer_agreements_delete",
335
- description: "Delete a producer agreement.",
226
+ name: "pica_agreement_types_delete",
227
+ description: "Delete an agreement by type and ID.",
336
228
  inputSchema: {
337
229
  type: "object",
338
230
  properties: {
339
- id: {
231
+ type: {
340
232
  type: "string",
341
- description: "Producer agreement ID",
233
+ enum: ["template", "producer", "work_for_hire"],
234
+ description: "Agreement sub-type",
342
235
  },
343
- },
344
- required: ["id"],
345
- },
346
- },
347
- executor: this.deleteProducerAgreement.bind(this),
348
- },
349
- // ── Work-for-Hire ────────────────────────────────────────────────
350
- {
351
- definition: {
352
- name: "pica_work_for_hire_list",
353
- description: "List work-for-hire agreements — flat-fee contracts where all rights are assigned to the commissioning party.",
354
- inputSchema: {
355
- type: "object",
356
- properties: {},
357
- },
358
- },
359
- executor: this.listWorkForHire.bind(this),
360
- },
361
- {
362
- definition: {
363
- name: "pica_work_for_hire_get",
364
- description: "Get a work-for-hire agreement with full details — fee, contractor, rights assignment, and linked works.",
365
- inputSchema: {
366
- type: "object",
367
- properties: {
368
236
  id: {
369
237
  type: "string",
370
- description: "Work-for-hire agreement ID",
238
+ description: "Agreement ID",
371
239
  },
372
240
  },
373
- required: ["id"],
241
+ required: ["type", "id"],
374
242
  },
375
243
  },
376
- executor: this.getWorkForHire.bind(this),
244
+ executor: this.delete.bind(this),
377
245
  },
246
+ // ── Template-specific operations ────────────────────────────────
378
247
  {
379
248
  definition: {
380
- name: "pica_work_for_hire_create",
381
- description: "Create a work-for-hire agreement flat fee, contractor assigns all rights. Used when commissioning music where the creator doesn't retain ownership.",
249
+ name: "pica_agreement_templates_render",
250
+ description: "Fill an agreement template with work and people data — generates a ready-to-send agreement. Pass the template ID plus work_id and/or people_ids to populate the placeholders with real catalog data.",
382
251
  inputSchema: {
383
252
  type: "object",
384
253
  properties: {
385
- title: {
386
- type: "string",
387
- description: "Agreement title",
388
- },
389
- contractor_id: {
254
+ id: {
390
255
  type: "string",
391
- description: "Person ID of the contractor (the one doing the work)",
256
+ description: "Template ID to render",
392
257
  },
393
258
  work_id: {
394
259
  type: "string",
395
- description: "Work being created under this agreement",
396
- },
397
- fee_amount: {
398
- type: "number",
399
- description: "Flat fee amount",
400
- },
401
- fee_currency: {
402
- type: "string",
403
- description: "Currency code (e.g. GBP, USD, EUR)",
404
- },
405
- rights_assigned: {
406
- type: "string",
407
- description: "Description of rights being assigned (e.g. 'All publishing and master rights')",
260
+ description: "Work ID to pull title, credits, and metadata from",
408
261
  },
409
- status: {
410
- type: "string",
411
- description: "Agreement status",
412
- enum: ["draft", "active", "completed", "terminated"],
262
+ people_ids: {
263
+ type: "array",
264
+ items: { type: "string" },
265
+ description: "People IDs to include as parties in the agreement",
413
266
  },
414
- notes: {
415
- type: "string",
416
- description: "Internal notes",
267
+ variables: {
268
+ type: "object",
269
+ description: "Additional variables to substitute — keys match placeholder names in the template body",
417
270
  },
418
271
  },
419
- required: ["title"],
272
+ required: ["id"],
420
273
  },
421
274
  },
422
- executor: this.createWorkForHire.bind(this),
275
+ executor: this.renderTemplate.bind(this),
423
276
  },
424
277
  {
425
278
  definition: {
426
- name: "pica_work_for_hire_update",
427
- description: "Update a work-for-hire agreement — change fee, contractor, rights, or status.",
279
+ name: "pica_agreement_templates_duplicate",
280
+ description: "Duplicate an agreement template creates a copy you can customise without changing the original.",
428
281
  inputSchema: {
429
282
  type: "object",
430
283
  properties: {
431
284
  id: {
432
285
  type: "string",
433
- description: "Work-for-hire agreement ID",
434
- },
435
- title: {
436
- type: "string",
437
- description: "Updated title",
438
- },
439
- contractor_id: {
440
- type: "string",
441
- description: "Updated contractor person ID",
442
- },
443
- work_id: {
444
- type: "string",
445
- description: "Updated work ID",
446
- },
447
- fee_amount: {
448
- type: "number",
449
- description: "Updated fee amount",
450
- },
451
- fee_currency: {
452
- type: "string",
453
- description: "Updated currency code",
454
- },
455
- rights_assigned: {
456
- type: "string",
457
- description: "Updated rights description",
458
- },
459
- status: {
460
- type: "string",
461
- description: "Updated status",
462
- enum: ["draft", "active", "completed", "terminated"],
463
- },
464
- notes: {
465
- type: "string",
466
- description: "Updated notes",
286
+ description: "Template ID to duplicate",
467
287
  },
468
288
  },
469
289
  required: ["id"],
470
290
  },
471
291
  },
472
- executor: this.updateWorkForHire.bind(this),
292
+ executor: this.duplicateTemplate.bind(this),
473
293
  },
474
294
  {
475
295
  definition: {
476
- name: "pica_work_for_hire_delete",
477
- description: "Delete a work-for-hire agreement.",
296
+ name: "pica_agreement_templates_set_default",
297
+ description: "Set a template as the default for its type — when creating agreements of that type, this template will be suggested first.",
478
298
  inputSchema: {
479
299
  type: "object",
480
300
  properties: {
481
301
  id: {
482
302
  type: "string",
483
- description: "Work-for-hire agreement ID",
303
+ description: "Template ID to set as default",
484
304
  },
485
305
  },
486
306
  required: ["id"],
487
307
  },
488
308
  },
489
- executor: this.deleteWorkForHire.bind(this),
309
+ executor: this.setDefaultTemplate.bind(this),
490
310
  },
491
311
  ];
492
312
  }
493
- // ── Template executors ─────────────────────────────────────────────
494
- async listTemplates() {
495
- const templates = await this.pica.agreementTemplates.list();
496
- return formatList(templates, { total: templates.length });
313
+ // ── Unified CRUD executors ──────────────────────────────────────────
314
+ async query(args) {
315
+ const resource = this.getResource(args.type);
316
+ const items = await resource.list();
317
+ return formatList(items, { total: items.length });
497
318
  }
498
- async getTemplate(args) {
499
- const template = await this.pica.agreementTemplates.get(args.id);
500
- return formatAsText(template);
319
+ async inspect(args) {
320
+ const resource = this.getResource(args.type);
321
+ const item = await resource.get(args.id);
322
+ return formatAsText(item);
501
323
  }
502
- async createTemplate(args) {
503
- const template = await this.pica.agreementTemplates.create(args);
504
- return formatSuccess("Agreement template created", template);
324
+ async create(args) {
325
+ const { type, ...fields } = args;
326
+ const resource = this.getResource(type);
327
+ const item = await resource.create(fields);
328
+ // Notification for producer agreements
329
+ if (type === "producer" && fields.producer_id) {
330
+ const results = await notifyParties(this.pica, [
331
+ {
332
+ person_id: fields.producer_id,
333
+ message: `a producer agreement has been created for "${fields.title || "untitled"}" — please review the terms`,
334
+ work_id: fields.work_id,
335
+ notification_type: "agreement_created",
336
+ },
337
+ ]);
338
+ const notifySummary = summarizeNotifications(results);
339
+ if (notifySummary) {
340
+ return formatSuccess(`Producer agreement created. ${notifySummary}`, item);
341
+ }
342
+ }
343
+ // Notification for work-for-hire
344
+ if (type === "work_for_hire" && fields.contractor_id) {
345
+ const results = await notifyParties(this.pica, [
346
+ {
347
+ person_id: fields.contractor_id,
348
+ message: `a work-for-hire agreement has been created: "${fields.title || "untitled"}" — please review`,
349
+ work_id: fields.work_id,
350
+ notification_type: "agreement_created",
351
+ },
352
+ ]);
353
+ const notifySummary = summarizeNotifications(results);
354
+ if (notifySummary) {
355
+ return formatSuccess(`Work-for-hire agreement created. ${notifySummary}`, item);
356
+ }
357
+ }
358
+ return formatSuccess(`${this.labelFor(type)} created`, item);
505
359
  }
506
- async updateTemplate(args) {
507
- const { id, ...updates } = args;
508
- const template = await this.pica.agreementTemplates.update(id, updates);
509
- return formatSuccess("Agreement template updated", template);
360
+ async update(args) {
361
+ const { type, id, ...updates } = args;
362
+ const resource = this.getResource(type);
363
+ const item = await resource.update(id, updates);
364
+ return formatSuccess(`${this.labelFor(type)} updated`, item);
510
365
  }
511
- async deleteTemplate(args) {
512
- await this.pica.agreementTemplates.delete(args.id);
513
- return formatSuccess(`Agreement template ${args.id} deleted`);
366
+ async delete(args) {
367
+ const { type, id } = args;
368
+ const resource = this.getResource(type);
369
+ await resource.delete(id);
370
+ return formatSuccess(`${this.labelFor(type)} ${id} deleted`);
514
371
  }
372
+ // ── Template-specific executors ─────────────────────────────────────
515
373
  async renderTemplate(args) {
516
374
  const { id, ...renderData } = args;
517
375
  const rendered = await this.pica.agreementTemplates.render(id, renderData);
@@ -525,79 +383,5 @@ export class AgreementTypesTools {
525
383
  const result = await this.pica.agreementTemplates.setDefault(args.id);
526
384
  return formatSuccess("Template set as default for its type", result);
527
385
  }
528
- // ── Producer agreement executors ───────────────────────────────────
529
- async listProducerAgreements() {
530
- const agreements = await this.pica.producerAgreements.list();
531
- return formatList(agreements, { total: agreements.length });
532
- }
533
- async getProducerAgreement(args) {
534
- const agreement = await this.pica.producerAgreements.get(args.id);
535
- return formatAsText(agreement);
536
- }
537
- async createProducerAgreement(args) {
538
- const agreement = await this.pica.producerAgreements.create(args);
539
- let notifySummary = "";
540
- if (args.producer_id) {
541
- const results = await notifyParties(this.pica, [
542
- {
543
- person_id: args.producer_id,
544
- message: `a producer agreement has been created for "${args.title || "untitled"}" — please review the terms`,
545
- work_id: args.work_id,
546
- notification_type: "agreement_created",
547
- },
548
- ]);
549
- notifySummary = summarizeNotifications(results);
550
- }
551
- const msg = notifySummary
552
- ? `Producer agreement created. ${notifySummary}`
553
- : "Producer agreement created";
554
- return formatSuccess(msg, agreement);
555
- }
556
- async updateProducerAgreement(args) {
557
- const { id, ...updates } = args;
558
- const agreement = await this.pica.producerAgreements.update(id, updates);
559
- return formatSuccess("Producer agreement updated", agreement);
560
- }
561
- async deleteProducerAgreement(args) {
562
- await this.pica.producerAgreements.delete(args.id);
563
- return formatSuccess(`Producer agreement ${args.id} deleted`);
564
- }
565
- // ── Work-for-hire executors ────────────────────────────────────────
566
- async listWorkForHire() {
567
- const agreements = await this.pica.workForHire.list();
568
- return formatList(agreements, { total: agreements.length });
569
- }
570
- async getWorkForHire(args) {
571
- const agreement = await this.pica.workForHire.get(args.id);
572
- return formatAsText(agreement);
573
- }
574
- async createWorkForHire(args) {
575
- const agreement = await this.pica.workForHire.create(args);
576
- let notifySummary = "";
577
- if (args.contractor_id) {
578
- const results = await notifyParties(this.pica, [
579
- {
580
- person_id: args.contractor_id,
581
- message: `a work-for-hire agreement has been created: "${args.title || "untitled"}" — please review`,
582
- work_id: args.work_id,
583
- notification_type: "agreement_created",
584
- },
585
- ]);
586
- notifySummary = summarizeNotifications(results);
587
- }
588
- const msg = notifySummary
589
- ? `Work-for-hire agreement created. ${notifySummary}`
590
- : "Work-for-hire agreement created";
591
- return formatSuccess(msg, agreement);
592
- }
593
- async updateWorkForHire(args) {
594
- const { id, ...updates } = args;
595
- const agreement = await this.pica.workForHire.update(id, updates);
596
- return formatSuccess("Work-for-hire agreement updated", agreement);
597
- }
598
- async deleteWorkForHire(args) {
599
- await this.pica.workForHire.delete(args.id);
600
- return formatSuccess(`Work-for-hire agreement ${args.id} deleted`);
601
- }
602
386
  }
603
387
  //# sourceMappingURL=agreement-types.js.map