applaunchflow 0.3.6 → 0.3.7
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/build/cli-core.js +12 -0
- package/build/cli-core.test.js +29 -1
- package/build/cli.js +23 -5
- package/package.json +1 -1
package/build/cli-core.js
CHANGED
|
@@ -15,6 +15,18 @@ export function codexLoginArgs() {
|
|
|
15
15
|
export function codexStatusArgs() {
|
|
16
16
|
return ["mcp", "get", APPLAUNCHFLOW_MCP_NAME];
|
|
17
17
|
}
|
|
18
|
+
export function codexInspectArgs() {
|
|
19
|
+
return [...codexStatusArgs(), "--json"];
|
|
20
|
+
}
|
|
21
|
+
export function isHostedCodexConfig(value) {
|
|
22
|
+
if (!value || typeof value !== "object")
|
|
23
|
+
return false;
|
|
24
|
+
const transport = value.transport;
|
|
25
|
+
if (!transport || typeof transport !== "object")
|
|
26
|
+
return false;
|
|
27
|
+
const { type, url } = transport;
|
|
28
|
+
return type === "streamable_http" && url === APPLAUNCHFLOW_MCP_URL;
|
|
29
|
+
}
|
|
18
30
|
export function codexDisconnectArgs() {
|
|
19
31
|
return ["mcp", "remove", APPLAUNCHFLOW_MCP_NAME];
|
|
20
32
|
}
|
package/build/cli-core.test.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import assert from "node:assert/strict";
|
|
2
2
|
import test from "node:test";
|
|
3
|
-
import { APPLAUNCHFLOW_MCP_NAME, APPLAUNCHFLOW_MCP_URL, codexAddArgs, codexDisconnectArgs, codexLoginArgs, codexStatusArgs, } from "./cli-core.js";
|
|
3
|
+
import { APPLAUNCHFLOW_MCP_NAME, APPLAUNCHFLOW_MCP_URL, codexAddArgs, codexDisconnectArgs, codexInspectArgs, codexLoginArgs, codexStatusArgs, isHostedCodexConfig, } from "./cli-core.js";
|
|
4
4
|
test("Codex convenience commands use the hosted OAuth connector", () => {
|
|
5
5
|
assert.deepEqual(codexAddArgs(), [
|
|
6
6
|
"mcp",
|
|
@@ -11,12 +11,40 @@ test("Codex convenience commands use the hosted OAuth connector", () => {
|
|
|
11
11
|
]);
|
|
12
12
|
assert.deepEqual(codexLoginArgs(), ["mcp", "login", "applaunchflow"]);
|
|
13
13
|
assert.deepEqual(codexStatusArgs(), ["mcp", "get", "applaunchflow"]);
|
|
14
|
+
assert.deepEqual(codexInspectArgs(), [
|
|
15
|
+
"mcp",
|
|
16
|
+
"get",
|
|
17
|
+
"applaunchflow",
|
|
18
|
+
"--json",
|
|
19
|
+
]);
|
|
14
20
|
assert.deepEqual(codexDisconnectArgs(), [
|
|
15
21
|
"mcp",
|
|
16
22
|
"remove",
|
|
17
23
|
"applaunchflow",
|
|
18
24
|
]);
|
|
19
25
|
});
|
|
26
|
+
test("detects whether Codex already uses the hosted connector", () => {
|
|
27
|
+
assert.equal(isHostedCodexConfig({
|
|
28
|
+
transport: {
|
|
29
|
+
type: "streamable_http",
|
|
30
|
+
url: APPLAUNCHFLOW_MCP_URL,
|
|
31
|
+
},
|
|
32
|
+
}), true);
|
|
33
|
+
assert.equal(isHostedCodexConfig({
|
|
34
|
+
transport: {
|
|
35
|
+
type: "stdio",
|
|
36
|
+
command: "npx",
|
|
37
|
+
args: ["-y", "@applaunchflow/mcp@latest"],
|
|
38
|
+
},
|
|
39
|
+
}), false);
|
|
40
|
+
assert.equal(isHostedCodexConfig({
|
|
41
|
+
transport: {
|
|
42
|
+
type: "streamable_http",
|
|
43
|
+
url: "https://example.com/mcp",
|
|
44
|
+
},
|
|
45
|
+
}), false);
|
|
46
|
+
assert.equal(isHostedCodexConfig(null), false);
|
|
47
|
+
});
|
|
20
48
|
test("the public connector URL is a secure MCP endpoint", () => {
|
|
21
49
|
const url = new URL(APPLAUNCHFLOW_MCP_URL);
|
|
22
50
|
assert.equal(url.protocol, "https:");
|
package/build/cli.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { spawnSync } from "node:child_process";
|
|
3
|
-
import { APPLAUNCHFLOW_MCP_URL, codexAddArgs, codexDisconnectArgs, codexLoginArgs, codexStatusArgs, } from "./cli-core.js";
|
|
3
|
+
import { APPLAUNCHFLOW_MCP_URL, codexAddArgs, codexDisconnectArgs, codexInspectArgs, codexLoginArgs, codexStatusArgs, isHostedCodexConfig, } from "./cli-core.js";
|
|
4
4
|
function printHelp() {
|
|
5
5
|
console.log(`AppLaunchFlow MCP
|
|
6
6
|
|
|
@@ -20,16 +20,34 @@ function runCodex(args) {
|
|
|
20
20
|
throw new Error(`Codex exited with status ${result.status ?? "unknown"}`);
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
|
-
function
|
|
24
|
-
const result = spawnSync("codex",
|
|
23
|
+
function getCodexConfiguration() {
|
|
24
|
+
const result = spawnSync("codex", codexInspectArgs(), {
|
|
25
|
+
encoding: "utf8",
|
|
26
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
27
|
+
});
|
|
25
28
|
if (result.error) {
|
|
26
29
|
throw new Error(`Could not run Codex: ${result.error.message}`);
|
|
27
30
|
}
|
|
28
|
-
|
|
31
|
+
if (result.status !== 0)
|
|
32
|
+
return "missing";
|
|
33
|
+
try {
|
|
34
|
+
return isHostedCodexConfig(JSON.parse(result.stdout))
|
|
35
|
+
? "hosted"
|
|
36
|
+
: "legacy";
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
return "legacy";
|
|
40
|
+
}
|
|
29
41
|
}
|
|
30
42
|
function connectCodex() {
|
|
31
|
-
|
|
43
|
+
const configuration = getCodexConfiguration();
|
|
44
|
+
if (configuration === "legacy") {
|
|
45
|
+
console.log("Replacing the legacy local AppLaunchFlow MCP configuration...");
|
|
46
|
+
runCodex(codexDisconnectArgs());
|
|
47
|
+
}
|
|
48
|
+
if (configuration !== "hosted") {
|
|
32
49
|
runCodex(codexAddArgs());
|
|
50
|
+
return;
|
|
33
51
|
}
|
|
34
52
|
runCodex(codexLoginArgs());
|
|
35
53
|
}
|