@carrierllc/mcp 0.13.48 → 0.13.56
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/{chunk-H77A3SME.js → chunk-DLEHOLDG.js} +239 -43
- package/dist/chunk-DLEHOLDG.js.map +1 -0
- package/dist/cli.js +26 -7
- package/dist/cli.js.map +1 -1
- package/dist/index.js +95 -11
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/plugin/carrier/skills/storefront/SKILL.md +2 -2
- package/templates/storefront/CLERK.md +2 -0
- package/templates/storefront/package-lock.json +41 -41
- package/templates/storefront/package.json +1 -1
- package/templates/storefront/pnpm-lock.yaml +87 -64
- package/dist/chunk-H77A3SME.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
configureClerkInstance,
|
|
17
17
|
daysUntil,
|
|
18
18
|
deploySite,
|
|
19
|
+
discoverSecrets,
|
|
19
20
|
esimStatusPerAccountParams,
|
|
20
21
|
extractDailyUsage,
|
|
21
22
|
extractEsimStatusByAccount,
|
|
@@ -81,7 +82,7 @@ import {
|
|
|
81
82
|
verifyStorefront,
|
|
82
83
|
withOcsListSummary,
|
|
83
84
|
withTemplateResellerId
|
|
84
|
-
} from "./chunk-
|
|
85
|
+
} from "./chunk-DLEHOLDG.js";
|
|
85
86
|
import "./chunk-SHKKVIIA.js";
|
|
86
87
|
|
|
87
88
|
// src/index.ts
|
|
@@ -103,22 +104,40 @@ async function issueInventory(ctx, args, extra) {
|
|
|
103
104
|
...Object.fromEntries(["startDate", "endDate", "validityPeriod"].filter((k) => args[k] !== void 0).map((k) => [k, args[k]])),
|
|
104
105
|
...args.business_reference !== void 0 ? { businessReference: args.business_reference } : {}
|
|
105
106
|
};
|
|
107
|
+
const unknown = "Issuance outcome is unknown. Preserve this request_key for reconciliation; do not issue with a new key.";
|
|
108
|
+
let response;
|
|
106
109
|
try {
|
|
107
|
-
|
|
110
|
+
response = await fetch(`${ctx.env.CARRIER_API_BASE_URL ?? "https://api.carrier.llc"}/v1/subscribers/issue-from-inventory`, {
|
|
108
111
|
method: "POST",
|
|
109
112
|
redirect: "error",
|
|
110
113
|
headers: { "Authorization": `Bearer ${token2}`, "Content-Type": "application/json", "X-Idempotency-Key": String(key) },
|
|
111
114
|
body: JSON.stringify(body2)
|
|
112
115
|
});
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
116
|
+
} catch (err9) {
|
|
117
|
+
return error("OUTCOME_UNKNOWN", unknown, { transport_error: err9 instanceof Error ? err9.message : String(err9) });
|
|
118
|
+
}
|
|
119
|
+
let text;
|
|
120
|
+
try {
|
|
121
|
+
text = await response.text();
|
|
122
|
+
} catch (err9) {
|
|
123
|
+
return error("OUTCOME_UNKNOWN", unknown, { http_status: response.status, transport_error: err9 instanceof Error ? err9.message : String(err9) });
|
|
124
|
+
}
|
|
125
|
+
let parsed;
|
|
126
|
+
try {
|
|
127
|
+
parsed = JSON.parse(text);
|
|
119
128
|
} catch {
|
|
120
|
-
|
|
129
|
+
parsed = void 0;
|
|
130
|
+
}
|
|
131
|
+
const payload = parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : void 0;
|
|
132
|
+
const http = { http_status: response.status };
|
|
133
|
+
if (!payload) {
|
|
134
|
+
return error("OUTCOME_UNKNOWN", unknown, { ...http, body_excerpt: text.slice(0, 200) });
|
|
121
135
|
}
|
|
136
|
+
if (response.ok && !payload.data) return error("OUTCOME_UNKNOWN", unknown, { ...http, api_response: payload });
|
|
137
|
+
if (response.status >= 500 && payload.code !== "OUTCOME_UNKNOWN" && payload.upstream_dispatched !== false && payload.outcome !== "rejected") {
|
|
138
|
+
return error("OUTCOME_UNKNOWN", unknown, { ...http, api_error: payload });
|
|
139
|
+
}
|
|
140
|
+
return { ...!response.ok ? { isError: true } : {}, content: [{ type: "text", text: JSON.stringify({ ...payload, request_key: key }) }] };
|
|
122
141
|
}
|
|
123
142
|
|
|
124
143
|
// src/tools.ts
|
|
@@ -7730,18 +7749,66 @@ function registerStorefrontDeployTools(server2, props2) {
|
|
|
7730
7749
|
),
|
|
7731
7750
|
skip_build: z10.boolean().optional().describe("Deploy the existing build without rebuilding"),
|
|
7732
7751
|
push_secrets: z10.boolean().optional().describe("Stage runtime secrets on the host before deploy (default true)"),
|
|
7752
|
+
provision_clerk: z10.boolean().optional().default(true).describe("Provision and configure Clerk automatically (default true)"),
|
|
7733
7753
|
verify: z10.boolean().optional().describe("Probe the deployed URL and report whether it actually serves (default true)"),
|
|
7734
7754
|
domain: z10.boolean().optional().describe("Route the brand domain to the deployment (Cloudflare provisions DNS + cert)")
|
|
7735
7755
|
},
|
|
7736
7756
|
annotations: annotationsFor("deploy_storefront", "write")
|
|
7737
7757
|
},
|
|
7738
|
-
async ({
|
|
7758
|
+
async ({
|
|
7759
|
+
dir,
|
|
7760
|
+
target,
|
|
7761
|
+
name,
|
|
7762
|
+
force,
|
|
7763
|
+
skip_build,
|
|
7764
|
+
push_secrets,
|
|
7765
|
+
provision_clerk,
|
|
7766
|
+
verify,
|
|
7767
|
+
domain
|
|
7768
|
+
}) => {
|
|
7739
7769
|
const denied = denyUnlessScoped(props2, "deploy_storefront", STOREFRONT_DEPLOY_TOOL_SCOPES);
|
|
7740
7770
|
if (denied) return denied;
|
|
7741
7771
|
try {
|
|
7742
7772
|
if (target && !isTargetId(target)) return err4(`Unknown target "${target}".`);
|
|
7743
7773
|
const brand = await loadStorefrontBrand(dir, name ? { name } : void 0);
|
|
7744
7774
|
const preferred = target;
|
|
7775
|
+
let clerkProvisioned = false;
|
|
7776
|
+
let clerkTier = null;
|
|
7777
|
+
let clerkProvisionError;
|
|
7778
|
+
let clerkCredentials;
|
|
7779
|
+
let clerkEnvWritten = [];
|
|
7780
|
+
let clerkConfigured = [];
|
|
7781
|
+
let clerkConfigureFailures = [];
|
|
7782
|
+
if (provision_clerk !== false && !skip_build) {
|
|
7783
|
+
try {
|
|
7784
|
+
const provisioned = await provisionClerk({
|
|
7785
|
+
name: brand.name,
|
|
7786
|
+
domain: brand.domain,
|
|
7787
|
+
// A live deploy is a production deploy: when the platform tier
|
|
7788
|
+
// creates an application, request a production instance for it.
|
|
7789
|
+
production: true,
|
|
7790
|
+
// .env.local is not auto-loaded into process.env, so merge it in
|
|
7791
|
+
// explicitly: the discovered tier must see keys a previous
|
|
7792
|
+
// deploy wrote, or every redeploy would mint a fresh instance.
|
|
7793
|
+
env: { ...process.env, ...await discoverSecrets(dir, process.env) },
|
|
7794
|
+
storefront: dir,
|
|
7795
|
+
cli: clerkCliDeps()
|
|
7796
|
+
});
|
|
7797
|
+
clerkTier = provisioned.tier;
|
|
7798
|
+
if (provisioned.ok && provisioned.credentials) {
|
|
7799
|
+
clerkProvisioned = true;
|
|
7800
|
+
clerkCredentials = provisioned.credentials;
|
|
7801
|
+
clerkEnvWritten = await mergeEnvLocal(dir, {
|
|
7802
|
+
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY: provisioned.credentials.publishableKey,
|
|
7803
|
+
CLERK_SECRET_KEY: provisioned.credentials.secretKey
|
|
7804
|
+
});
|
|
7805
|
+
} else {
|
|
7806
|
+
clerkProvisionError = provisioned.reason ?? "Clerk provisioning did not return credentials.";
|
|
7807
|
+
}
|
|
7808
|
+
} catch (e) {
|
|
7809
|
+
clerkProvisionError = e instanceof Error ? e.message : String(e);
|
|
7810
|
+
}
|
|
7811
|
+
}
|
|
7745
7812
|
if (!skip_build) {
|
|
7746
7813
|
const ranked = rankTargets(await probeAll(dir));
|
|
7747
7814
|
const buildFor = preferred ?? ranked[0]?.id ?? "cloudflare";
|
|
@@ -7762,7 +7829,19 @@ function registerStorefrontDeployTools(server2, props2) {
|
|
|
7762
7829
|
if (!result2.ok) {
|
|
7763
7830
|
return err4(result2.reason ?? "Deploy failed.");
|
|
7764
7831
|
}
|
|
7832
|
+
if (provision_clerk !== false && result2.url) {
|
|
7833
|
+
const secretKey = clerkCredentials?.secretKey ?? (await discoverSecrets(dir, process.env)).CLERK_SECRET_KEY;
|
|
7834
|
+
if (secretKey) {
|
|
7835
|
+
const configured = await configureClerkInstance(
|
|
7836
|
+
secretKey,
|
|
7837
|
+
storefrontClerkUrls(result2.url, brand.domain)
|
|
7838
|
+
);
|
|
7839
|
+
clerkConfigured = configured.applied;
|
|
7840
|
+
clerkConfigureFailures = configured.failed;
|
|
7841
|
+
}
|
|
7842
|
+
}
|
|
7765
7843
|
const verification = verify !== false && result2.url ? await verifyStorefront(result2.url, dir, process.env) : void 0;
|
|
7844
|
+
const repairHint = skip_build && clerkEnvWritten.includes("NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY") ? "Clerk keys were written to .env.local, but the publishable key is only inlined at build time; rebuild and redeploy to apply it." : verification && !verification.ok ? repairPlanFor(verification.diagnosis)?.note ?? verification.summary : void 0;
|
|
7766
7845
|
return ok3({
|
|
7767
7846
|
deployed: true,
|
|
7768
7847
|
target: result2.target,
|
|
@@ -7770,10 +7849,15 @@ function registerStorefrontDeployTools(server2, props2) {
|
|
|
7770
7849
|
url: result2.url ?? null,
|
|
7771
7850
|
secrets_staged: result2.secrets?.pushed ?? [],
|
|
7772
7851
|
secrets_failed: result2.secrets?.failed ?? [],
|
|
7852
|
+
clerk_provisioned: clerkProvisioned,
|
|
7853
|
+
clerk_tier: clerkTier,
|
|
7854
|
+
clerk_configured: clerkConfigured.length,
|
|
7855
|
+
clerk_configure_failures: clerkConfigureFailures,
|
|
7856
|
+
clerk_provision_error: clerkProvisionError,
|
|
7773
7857
|
verified: verification ? verification.ok : null,
|
|
7774
7858
|
diagnosis: verification?.ok === false ? verification.diagnosis : void 0,
|
|
7775
7859
|
probes: verification ? formatProbes(verification.probes) : void 0,
|
|
7776
|
-
repair_hint:
|
|
7860
|
+
repair_hint: repairHint,
|
|
7777
7861
|
warning: result2.secrets?.pushed.includes("CARRIER_API_KEY") ? void 0 : "CARRIER_API_KEY was not staged \u2014 / and /shop will return 500 until it is set."
|
|
7778
7862
|
});
|
|
7779
7863
|
} catch (e) {
|