@setluca/mcp 0.1.0 → 0.2.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 (60) hide show
  1. package/README.md +240 -124
  2. package/dist/annotations.js +45 -0
  3. package/dist/completions.js +90 -0
  4. package/dist/config.js +55 -29
  5. package/dist/errors.js +59 -14
  6. package/dist/generated/openapi-inputs.js +4324 -1429
  7. package/dist/generated/openapi-outputs.js +21992 -8516
  8. package/dist/generated/route-catalog.js +1480 -0
  9. package/dist/http.js +95 -103
  10. package/dist/index.js +16 -10
  11. package/dist/oauth-resolver.js +58 -36
  12. package/dist/observability.js +11 -3
  13. package/dist/openapi-zod.js +129 -65
  14. package/dist/operations/catalog.js +50 -0
  15. package/dist/operations/groups/analytics.js +122 -0
  16. package/dist/operations/groups/bookings.js +189 -0
  17. package/dist/operations/groups/broadcasts.js +106 -0
  18. package/dist/operations/groups/cadences.js +14 -0
  19. package/dist/operations/groups/callEvents.js +131 -0
  20. package/dist/operations/groups/campaigns.js +132 -0
  21. package/dist/operations/groups/capabilities.js +8 -0
  22. package/dist/operations/groups/coach.js +43 -0
  23. package/dist/operations/groups/conversations.js +48 -0
  24. package/dist/operations/groups/insights.js +33 -0
  25. package/dist/operations/groups/integrations.js +80 -0
  26. package/dist/operations/groups/knowledge.js +34 -0
  27. package/dist/operations/groups/leads.js +101 -0
  28. package/dist/operations/groups/learning.js +24 -0
  29. package/dist/operations/groups/memory.js +27 -0
  30. package/dist/operations/groups/reports.js +14 -0
  31. package/dist/operations/groups/reviewQueue.js +57 -0
  32. package/dist/operations/groups/safety.js +8 -0
  33. package/dist/operations/groups/usage.js +13 -0
  34. package/dist/operations/groups/voice.js +14 -0
  35. package/dist/operations/groups/webhooks.js +76 -0
  36. package/dist/operations/manifest.js +40 -0
  37. package/dist/operations/registry.js +331 -0
  38. package/dist/operations.js +11 -780
  39. package/dist/optional-field.js +12 -0
  40. package/dist/page-shape.js +47 -0
  41. package/dist/pagination.js +164 -0
  42. package/dist/prompts.js +63 -8
  43. package/dist/provenance.js +18 -2
  44. package/dist/remote.js +80 -49
  45. package/dist/resilience.js +117 -0
  46. package/dist/serialization.js +36 -0
  47. package/dist/server.js +256 -281
  48. package/dist/task-tools/analytics.js +168 -0
  49. package/dist/task-tools/bookings.js +154 -0
  50. package/dist/task-tools/cadences.js +65 -0
  51. package/dist/task-tools/calls.js +202 -0
  52. package/dist/task-tools/inbox.js +74 -0
  53. package/dist/task-tools/leads.js +123 -0
  54. package/dist/task-tools/runtime.js +92 -0
  55. package/dist/task-tools.js +21 -0
  56. package/dist/tool-cache.js +39 -0
  57. package/dist/tool.js +228 -0
  58. package/dist/tsconfig.tsbuildinfo +1 -1
  59. package/dist/version.js +14 -0
  60. package/package.json +36 -32
package/dist/errors.js CHANGED
@@ -1,4 +1,6 @@
1
- import { Data } from "effect";
1
+ import { Data, Match, Option } from "effect";
2
+ import * as z from "zod/v4";
3
+ import { toJsonPayload } from "./serialization.js";
2
4
  export class LucaConfigError extends Data.TaggedError("LucaConfigError") {
3
5
  }
4
6
  export class LucaNetworkError extends Data.TaggedError("LucaNetworkError") {
@@ -7,19 +9,62 @@ export class LucaDecodeError extends Data.TaggedError("LucaDecodeError") {
7
9
  }
8
10
  export class LucaHttpError extends Data.TaggedError("LucaHttpError") {
9
11
  }
10
- export function formatError(error) {
11
- if (error instanceof LucaConfigError) {
12
- return error.message;
13
- }
14
- if (error instanceof LucaNetworkError) {
15
- return error.message;
16
- }
17
- if (error instanceof LucaDecodeError) {
18
- return `${error.message}: ${error.body.slice(0, 500)}`;
12
+ /**
13
+ * One attempt ran past the request timeout and was cancelled. It is its own
14
+ * error rather than a network error because a caller can retry it safely under
15
+ * the same rules but cannot tell from a network failure whether the request
16
+ * reached the API.
17
+ */
18
+ export class LucaTimeoutError extends Data.TaggedError("LucaTimeoutError") {
19
+ }
20
+ /**
21
+ * A tool was called with arguments that are not a JSON object. The MCP SDK
22
+ * validates against the tool's own input schema before the handler runs, so a
23
+ * real client cannot reach this. It exists so no code ahead of `runPromise` can
24
+ * throw where the error channel cannot see it.
25
+ */
26
+ export class LucaToolInputError extends Data.TaggedError("LucaToolInputError") {
27
+ }
28
+ const DECODE_BODY_EXCERPT = 500;
29
+ function formatDecodeError(error) {
30
+ return `${error.message}: ${error.body.slice(0, DECODE_BODY_EXCERPT)}`;
31
+ }
32
+ function formatHttpError(error) {
33
+ const request = Option.fromNullable(error.requestId).pipe(Option.match({
34
+ onNone: () => "",
35
+ onSome: (requestId) => ` requestId=${requestId}`,
36
+ }));
37
+ return `Luca API returned ${error.status} ${error.statusText}${request}: ${toJsonPayload(error.body)}`;
38
+ }
39
+ /**
40
+ * A value that carries no message of its own, rendered for a human. Anything
41
+ * that is not already a string comes back as JSON rather than "[object Object]".
42
+ */
43
+ function formatJsonValue(error) {
44
+ const text = z.string().safeParse(error);
45
+ if (text.success) {
46
+ return text.data;
19
47
  }
20
- if (error instanceof LucaHttpError) {
21
- const request = error.requestId ? ` requestId=${error.requestId}` : "";
22
- return `Luca API returned ${error.status} ${error.statusText}${request}: ${JSON.stringify(error.body)}`;
48
+ const scalar = z.union([z.number(), z.boolean()]).safeParse(error);
49
+ if (scalar.success) {
50
+ return String(scalar.data);
23
51
  }
24
- return error instanceof Error ? error.message : String(error);
52
+ return toJsonPayload(error);
53
+ }
54
+ /** Any failure this server can hand a client, as one line of text. */
55
+ export function formatError(error) {
56
+ return error instanceof Error ? formatThrown(error) : formatJsonValue(error);
57
+ }
58
+ /**
59
+ * A thrown value rendered for a human. The two structured errors get their own
60
+ * rendering; every other tagged error carries a `message`, and one branch
61
+ * covers all of them rather than a case per tag that would all say the same
62
+ * thing.
63
+ *
64
+ * The match is on the class, not on `_tag`. This takes any `Error`, including
65
+ * one thrown by a dependency that carries no tag at all, so there is no tagged
66
+ * union here for `Match.tag` to narrow.
67
+ */
68
+ function formatThrown(error) {
69
+ return Match.value(error).pipe(Match.when(Match.instanceOf(LucaDecodeError), formatDecodeError), Match.when(Match.instanceOf(LucaHttpError), formatHttpError), Match.orElse((thrown) => thrown.message));
25
70
  }