@postonus/cli 0.1.13 → 0.1.15
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/index.js +35 -23
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -11896,19 +11896,28 @@ function configDir() {
|
|
|
11896
11896
|
function configPath() {
|
|
11897
11897
|
return join(configDir(), "config.json");
|
|
11898
11898
|
}
|
|
11899
|
+
function isString(val) {
|
|
11900
|
+
return typeof val === "string";
|
|
11901
|
+
}
|
|
11902
|
+
function isNumber(val) {
|
|
11903
|
+
return typeof val === "number";
|
|
11904
|
+
}
|
|
11905
|
+
function isRecord(val) {
|
|
11906
|
+
return typeof val === "object" && val !== null && !Array.isArray(val);
|
|
11907
|
+
}
|
|
11899
11908
|
async function readConfig() {
|
|
11900
11909
|
try {
|
|
11901
11910
|
const raw = await readFile(configPath(), "utf8");
|
|
11902
11911
|
const parsed = JSON.parse(raw);
|
|
11903
|
-
if (
|
|
11912
|
+
if (!isRecord(parsed)) return {};
|
|
11904
11913
|
const { accessToken, refreshToken, clientId, accessTokenExpiresAt, apiUrl, email: email2 } = parsed;
|
|
11905
11914
|
return {
|
|
11906
|
-
accessToken:
|
|
11907
|
-
refreshToken:
|
|
11908
|
-
clientId:
|
|
11909
|
-
accessTokenExpiresAt:
|
|
11910
|
-
apiUrl:
|
|
11911
|
-
email:
|
|
11915
|
+
accessToken: isString(accessToken) ? accessToken : void 0,
|
|
11916
|
+
refreshToken: isString(refreshToken) ? refreshToken : void 0,
|
|
11917
|
+
clientId: isString(clientId) ? clientId : void 0,
|
|
11918
|
+
accessTokenExpiresAt: isNumber(accessTokenExpiresAt) ? accessTokenExpiresAt : void 0,
|
|
11919
|
+
apiUrl: isString(apiUrl) ? apiUrl : void 0,
|
|
11920
|
+
email: isString(email2) ? email2 : void 0
|
|
11912
11921
|
};
|
|
11913
11922
|
} catch {
|
|
11914
11923
|
return {};
|
|
@@ -11983,7 +11992,7 @@ function formatTable(headers, rows) {
|
|
|
11983
11992
|
}
|
|
11984
11993
|
|
|
11985
11994
|
// src/version.ts
|
|
11986
|
-
var CLI_VERSION = "0.1.
|
|
11995
|
+
var CLI_VERSION = "0.1.15";
|
|
11987
11996
|
|
|
11988
11997
|
// src/client.ts
|
|
11989
11998
|
var DEVICE_CODE_GRANT_TYPE = "urn:ietf:params:oauth:grant-type:device_code";
|
|
@@ -12087,23 +12096,23 @@ async function getApi() {
|
|
|
12087
12096
|
const auth = { kind: "oauth", accessToken, refreshToken, clientId };
|
|
12088
12097
|
return { api: buildClient(apiUrl, auth), apiUrl, auth, config: config2 };
|
|
12089
12098
|
}
|
|
12090
|
-
function describeError(
|
|
12091
|
-
if (
|
|
12092
|
-
if (
|
|
12093
|
-
return
|
|
12099
|
+
function describeError(cause) {
|
|
12100
|
+
if (cause instanceof ORPCError3) {
|
|
12101
|
+
if (cause.code === "UNAUTHORIZED") {
|
|
12102
|
+
return cause.message || "Sign-in expired or not valid. Run `postonus login` again.";
|
|
12094
12103
|
}
|
|
12095
|
-
if (
|
|
12096
|
-
return `Rate limit reached. ${
|
|
12104
|
+
if (cause.code === "RATE_LIMITED") {
|
|
12105
|
+
return `Rate limit reached. ${cause.message}`;
|
|
12097
12106
|
}
|
|
12098
|
-
return
|
|
12107
|
+
return cause.message;
|
|
12099
12108
|
}
|
|
12100
|
-
if (
|
|
12101
|
-
if (
|
|
12109
|
+
if (cause instanceof Error) {
|
|
12110
|
+
if (cause.message === "fetch failed") {
|
|
12102
12111
|
return "Could not reach Postonus. Check your connection, or POSTONUS_API_URL if you set it.";
|
|
12103
12112
|
}
|
|
12104
|
-
return
|
|
12113
|
+
return cause.message;
|
|
12105
12114
|
}
|
|
12106
|
-
return String(
|
|
12115
|
+
return String(cause);
|
|
12107
12116
|
}
|
|
12108
12117
|
|
|
12109
12118
|
// src/ui.tsx
|
|
@@ -12292,7 +12301,7 @@ function LoginPrompt({ device, run }) {
|
|
|
12292
12301
|
React2.useEffect(() => {
|
|
12293
12302
|
run().then(
|
|
12294
12303
|
() => exit(),
|
|
12295
|
-
(
|
|
12304
|
+
(cause) => exit(cause instanceof Error ? cause : new Error(String(cause)))
|
|
12296
12305
|
);
|
|
12297
12306
|
}, []);
|
|
12298
12307
|
return /* @__PURE__ */ jsxs2(Box2, { flexDirection: "column", gap: 1, paddingY: 1, children: [
|
|
@@ -12541,6 +12550,9 @@ async function connectChannel(options) {
|
|
|
12541
12550
|
|
|
12542
12551
|
// src/commands/mcp.ts
|
|
12543
12552
|
import { createInterface } from "readline";
|
|
12553
|
+
function isString2(val) {
|
|
12554
|
+
return typeof val === "string";
|
|
12555
|
+
}
|
|
12544
12556
|
function decodeMessages(contentType, body) {
|
|
12545
12557
|
if (!contentType?.includes("text/event-stream")) {
|
|
12546
12558
|
const trimmed = body.trim();
|
|
@@ -12613,7 +12625,7 @@ async function mcpServe() {
|
|
|
12613
12625
|
write(frame);
|
|
12614
12626
|
try {
|
|
12615
12627
|
const parsed = JSON.parse(frame);
|
|
12616
|
-
if (
|
|
12628
|
+
if (isString2(parsed.result?.protocolVersion)) protocolVersion = parsed.result.protocolVersion;
|
|
12617
12629
|
} catch {
|
|
12618
12630
|
}
|
|
12619
12631
|
}
|
|
@@ -12623,9 +12635,9 @@ async function mcpServe() {
|
|
|
12623
12635
|
for await (const line of lines) {
|
|
12624
12636
|
if (line.trim().length === 0) continue;
|
|
12625
12637
|
const incoming = parseIncoming(line);
|
|
12626
|
-
const pending = forward(line).catch((
|
|
12638
|
+
const pending = forward(line).catch((cause) => {
|
|
12627
12639
|
const id = incoming.id ?? null;
|
|
12628
|
-
const detail =
|
|
12640
|
+
const detail = cause instanceof Error ? cause.message : String(cause);
|
|
12629
12641
|
if (id === null) {
|
|
12630
12642
|
process.stderr.write(`postonus mcp: ${detail}
|
|
12631
12643
|
`);
|