@carrierllc/mcp 0.2.18 → 0.2.19
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/dist/cli.js +58 -46
- package/dist/cli.js.map +1 -1
- package/dist/index.js +37 -15
- package/dist/index.js.map +1 -1
- package/package.json +6 -6
- package/templates/storefront/package-lock.json +12722 -0
- package/templates/storefront/package.json +3 -3
- package/templates/storefront/src/lib/checkout-order-claim.ts +16 -2
- package/templates/storefront/src/lib/verify-checkout-session.ts +19 -2
package/dist/cli.js
CHANGED
|
@@ -743,6 +743,16 @@ import * as p from "@clack/prompts";
|
|
|
743
743
|
import pc2 from "picocolors";
|
|
744
744
|
|
|
745
745
|
// src/cli/lib/ask.ts
|
|
746
|
+
function parseRpcBody(raw) {
|
|
747
|
+
const trimmed = raw.trim();
|
|
748
|
+
if (!trimmed) return {};
|
|
749
|
+
if (trimmed.startsWith("{") || trimmed.startsWith("[")) {
|
|
750
|
+
return JSON.parse(trimmed);
|
|
751
|
+
}
|
|
752
|
+
const dataLine = trimmed.split("\n").map((l) => l.trim()).find((l) => l.startsWith("data:"));
|
|
753
|
+
if (!dataLine) return {};
|
|
754
|
+
return JSON.parse(dataLine.slice(5).trim());
|
|
755
|
+
}
|
|
746
756
|
async function carrierAsk(intent) {
|
|
747
757
|
const token = resolveCliToken();
|
|
748
758
|
if (!token) {
|
|
@@ -755,35 +765,63 @@ async function carrierAsk(intent) {
|
|
|
755
765
|
])
|
|
756
766
|
};
|
|
757
767
|
}
|
|
758
|
-
const
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
params: {
|
|
763
|
-
name: "carrier_ask",
|
|
764
|
-
arguments: { intent }
|
|
765
|
-
}
|
|
768
|
+
const headers = {
|
|
769
|
+
Authorization: `Bearer ${token}`,
|
|
770
|
+
"Content-Type": "application/json",
|
|
771
|
+
Accept: "application/json, text/event-stream"
|
|
766
772
|
};
|
|
767
773
|
try {
|
|
768
|
-
const
|
|
774
|
+
const initRes = await fetch(MCP_URL, {
|
|
769
775
|
method: "POST",
|
|
770
|
-
headers
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
+
headers,
|
|
777
|
+
body: JSON.stringify({
|
|
778
|
+
jsonrpc: "2.0",
|
|
779
|
+
id: 1,
|
|
780
|
+
method: "initialize",
|
|
781
|
+
params: {
|
|
782
|
+
protocolVersion: "2024-11-05",
|
|
783
|
+
capabilities: {},
|
|
784
|
+
clientInfo: { name: "carrier-cli", version: "0.2.19" }
|
|
785
|
+
}
|
|
786
|
+
})
|
|
776
787
|
});
|
|
777
|
-
if (
|
|
788
|
+
if (initRes.status === 401 || initRes.status === 403) {
|
|
778
789
|
return {
|
|
779
790
|
ok: false,
|
|
780
|
-
text: withNextStep(`MCP returned ${
|
|
791
|
+
text: withNextStep(`MCP returned ${initRes.status} (auth rejected).`, [
|
|
781
792
|
"Confirm CARRIER_API_KEY is a valid org key (ak_\u2026) from app.carrier.llc",
|
|
782
793
|
"Or complete OCS onboarding: https://app.carrier.llc/onboarding",
|
|
783
794
|
"Interactive: use Claude + OAuth instead of a headless key"
|
|
784
795
|
])
|
|
785
796
|
};
|
|
786
797
|
}
|
|
798
|
+
const sessionId = initRes.headers.get("mcp-session-id") ?? initRes.headers.get("Mcp-Session-Id");
|
|
799
|
+
await initRes.arrayBuffer().catch(() => void 0);
|
|
800
|
+
if (!sessionId) {
|
|
801
|
+
return {
|
|
802
|
+
ok: false,
|
|
803
|
+
text: withNextStep("MCP initialize did not return a session id.", [
|
|
804
|
+
"Check network access to https://mcp.carrier.llc/mcp",
|
|
805
|
+
"Retry later, or use Claude with the registered MCP (OAuth path)"
|
|
806
|
+
])
|
|
807
|
+
};
|
|
808
|
+
}
|
|
809
|
+
const sessionHeaders = { ...headers, "Mcp-Session-Id": sessionId };
|
|
810
|
+
await fetch(MCP_URL, {
|
|
811
|
+
method: "POST",
|
|
812
|
+
headers: sessionHeaders,
|
|
813
|
+
body: JSON.stringify({ jsonrpc: "2.0", method: "notifications/initialized" })
|
|
814
|
+
}).catch(() => void 0);
|
|
815
|
+
const res = await fetch(MCP_URL, {
|
|
816
|
+
method: "POST",
|
|
817
|
+
headers: sessionHeaders,
|
|
818
|
+
body: JSON.stringify({
|
|
819
|
+
jsonrpc: "2.0",
|
|
820
|
+
id: 2,
|
|
821
|
+
method: "tools/call",
|
|
822
|
+
params: { name: "carrier_ask", arguments: { intent } }
|
|
823
|
+
})
|
|
824
|
+
});
|
|
787
825
|
if (!res.ok) {
|
|
788
826
|
const snippet = (await res.text().catch(() => "")).slice(0, 240);
|
|
789
827
|
return {
|
|
@@ -794,7 +832,7 @@ async function carrierAsk(intent) {
|
|
|
794
832
|
])
|
|
795
833
|
};
|
|
796
834
|
}
|
|
797
|
-
const json = await res.
|
|
835
|
+
const json = parseRpcBody(await res.text());
|
|
798
836
|
if (json.error?.message) {
|
|
799
837
|
return {
|
|
800
838
|
ok: false,
|
|
@@ -881,11 +919,6 @@ async function runHome(opts) {
|
|
|
881
919
|
label: "Open onboarding (link OCS / managed setup)",
|
|
882
920
|
hint: ONBOARDING_URL
|
|
883
921
|
},
|
|
884
|
-
{
|
|
885
|
-
value: "examples",
|
|
886
|
-
label: "Talk to fleet \u2014 NL examples for Claude",
|
|
887
|
-
hint: "Copy-paste prompts"
|
|
888
|
-
},
|
|
889
922
|
{
|
|
890
923
|
value: "ask",
|
|
891
924
|
label: hasToken ? "Ask the fleet (carrier ask)" : "Ask the fleet (needs CARRIER_API_KEY)",
|
|
@@ -926,27 +959,6 @@ async function runHome(opts) {
|
|
|
926
959
|
await openAndReport(ONBOARDING_URL, "Onboarding");
|
|
927
960
|
p.log.info("Link OCS credentials (BYO) or finish managed setup, then use Claude MCP.");
|
|
928
961
|
break;
|
|
929
|
-
case "examples":
|
|
930
|
-
p.note(formatNlExamples(), "Paste into Claude (with Carrier MCP connected)");
|
|
931
|
-
p.note(
|
|
932
|
-
[
|
|
933
|
-
"In Claude Code after install:",
|
|
934
|
-
' "Show my fleet health"',
|
|
935
|
-
" /carrier:fleet",
|
|
936
|
-
" /carrier:status",
|
|
937
|
-
"",
|
|
938
|
-
`MCP home: ${MCP_HOME}`
|
|
939
|
-
].join("\n"),
|
|
940
|
-
"Talk to fleet"
|
|
941
|
-
);
|
|
942
|
-
{
|
|
943
|
-
const go = await p.confirm({
|
|
944
|
-
message: "Open mcp.carrier.llc in the browser?",
|
|
945
|
-
initialValue: false
|
|
946
|
-
});
|
|
947
|
-
if (!p.isCancel(go) && go) await openAndReport(MCP_HOME, "MCP home");
|
|
948
|
-
}
|
|
949
|
-
break;
|
|
950
962
|
case "ask": {
|
|
951
963
|
if (!resolveCliToken()) {
|
|
952
964
|
p.log.warn("No CARRIER_API_KEY / OCS token in env.");
|
|
@@ -985,7 +997,7 @@ async function runHome(opts) {
|
|
|
985
997
|
}
|
|
986
998
|
|
|
987
999
|
// src/cli/index.ts
|
|
988
|
-
var VERSION = "0.2.
|
|
1000
|
+
var VERSION = "0.2.19";
|
|
989
1001
|
function header() {
|
|
990
1002
|
p2.intro(`${pc3.bold(pc3.yellow("\u25C6 carrier"))} ${pc3.dim("\xB7 the Stripe of telecom \u2014 CLI v" + VERSION)}`);
|
|
991
1003
|
}
|
|
@@ -1078,7 +1090,7 @@ async function doPluginInstall() {
|
|
|
1078
1090
|
' "Show my fleet health"',
|
|
1079
1091
|
"First call opens the browser for sign-in / sign-up. No token paste.",
|
|
1080
1092
|
"",
|
|
1081
|
-
"More prompts: carrier
|
|
1093
|
+
"More prompts: carrier examples"
|
|
1082
1094
|
].join("\n"),
|
|
1083
1095
|
"Talk to your fleet"
|
|
1084
1096
|
);
|