@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.
- package/README.md +240 -124
- package/dist/annotations.js +45 -0
- package/dist/completions.js +90 -0
- package/dist/config.js +55 -29
- package/dist/errors.js +59 -14
- package/dist/generated/openapi-inputs.js +4324 -1429
- package/dist/generated/openapi-outputs.js +21992 -8516
- package/dist/generated/route-catalog.js +1480 -0
- package/dist/http.js +95 -103
- package/dist/index.js +16 -10
- package/dist/oauth-resolver.js +58 -36
- package/dist/observability.js +11 -3
- package/dist/openapi-zod.js +129 -65
- package/dist/operations/catalog.js +50 -0
- package/dist/operations/groups/analytics.js +122 -0
- package/dist/operations/groups/bookings.js +189 -0
- package/dist/operations/groups/broadcasts.js +106 -0
- package/dist/operations/groups/cadences.js +14 -0
- package/dist/operations/groups/callEvents.js +131 -0
- package/dist/operations/groups/campaigns.js +132 -0
- package/dist/operations/groups/capabilities.js +8 -0
- package/dist/operations/groups/coach.js +43 -0
- package/dist/operations/groups/conversations.js +48 -0
- package/dist/operations/groups/insights.js +33 -0
- package/dist/operations/groups/integrations.js +80 -0
- package/dist/operations/groups/knowledge.js +34 -0
- package/dist/operations/groups/leads.js +101 -0
- package/dist/operations/groups/learning.js +24 -0
- package/dist/operations/groups/memory.js +27 -0
- package/dist/operations/groups/reports.js +14 -0
- package/dist/operations/groups/reviewQueue.js +57 -0
- package/dist/operations/groups/safety.js +8 -0
- package/dist/operations/groups/usage.js +13 -0
- package/dist/operations/groups/voice.js +14 -0
- package/dist/operations/groups/webhooks.js +76 -0
- package/dist/operations/manifest.js +40 -0
- package/dist/operations/registry.js +331 -0
- package/dist/operations.js +11 -780
- package/dist/optional-field.js +12 -0
- package/dist/page-shape.js +47 -0
- package/dist/pagination.js +164 -0
- package/dist/prompts.js +63 -8
- package/dist/provenance.js +18 -2
- package/dist/remote.js +80 -49
- package/dist/resilience.js +117 -0
- package/dist/serialization.js +36 -0
- package/dist/server.js +256 -281
- package/dist/task-tools/analytics.js +168 -0
- package/dist/task-tools/bookings.js +154 -0
- package/dist/task-tools/cadences.js +65 -0
- package/dist/task-tools/calls.js +202 -0
- package/dist/task-tools/inbox.js +74 -0
- package/dist/task-tools/leads.js +123 -0
- package/dist/task-tools/runtime.js +92 -0
- package/dist/task-tools.js +21 -0
- package/dist/tool-cache.js +39 -0
- package/dist/tool.js +228 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/version.js +14 -0
- 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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
21
|
-
|
|
22
|
-
return
|
|
48
|
+
const scalar = z.union([z.number(), z.boolean()]).safeParse(error);
|
|
49
|
+
if (scalar.success) {
|
|
50
|
+
return String(scalar.data);
|
|
23
51
|
}
|
|
24
|
-
return
|
|
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
|
}
|