open-research 0.1.4 → 0.1.6
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 +27 -16
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -270,7 +270,7 @@ import { createHash, randomBytes } from "crypto";
|
|
|
270
270
|
var OPENAI_AUTH_URL = "https://auth.openai.com/oauth/authorize";
|
|
271
271
|
var OPENAI_TOKEN_URL = "https://auth.openai.com/oauth/token";
|
|
272
272
|
var OPENAI_CLIENT_ID = "app_EMoamEEZ73f0CkXaXp7hrann";
|
|
273
|
-
var OPENAI_SCOPES = "openid profile email offline_access
|
|
273
|
+
var OPENAI_SCOPES = "openid profile email offline_access";
|
|
274
274
|
function getRedirectUri(port) {
|
|
275
275
|
return `http://localhost:${port}/auth/callback`;
|
|
276
276
|
}
|
|
@@ -294,7 +294,7 @@ function buildAuthorizationUrl(input2) {
|
|
|
294
294
|
code_challenge_method: "S256",
|
|
295
295
|
id_token_add_organizations: "true",
|
|
296
296
|
codex_cli_simplified_flow: "true",
|
|
297
|
-
originator: "
|
|
297
|
+
originator: "open-research"
|
|
298
298
|
});
|
|
299
299
|
return `${OPENAI_AUTH_URL}?${params.toString()}`;
|
|
300
300
|
}
|
|
@@ -1440,7 +1440,7 @@ function TextInput({
|
|
|
1440
1440
|
onTab?.();
|
|
1441
1441
|
return;
|
|
1442
1442
|
}
|
|
1443
|
-
if (key.return && key.shift) {
|
|
1443
|
+
if (key.return && key.shift || key.return && key.meta) {
|
|
1444
1444
|
const inserted = originalValue.slice(0, cursorOffset) + "\n" + originalValue.slice(cursorOffset);
|
|
1445
1445
|
setCursorOffset(cursorOffset + 1);
|
|
1446
1446
|
onChange(inserted);
|
|
@@ -1482,8 +1482,11 @@ function TextInput({
|
|
|
1482
1482
|
} else if (key.rightArrow) {
|
|
1483
1483
|
if (showCursor) nextCursor++;
|
|
1484
1484
|
} else if (!key.ctrl && !key.meta) {
|
|
1485
|
-
|
|
1486
|
-
|
|
1485
|
+
const clean = input2.replace(/\x1b\[[?>=!]*[0-9;]*[a-zA-Z]/g, "").replace(/[\x00-\x08\x0e-\x1f]/g, "");
|
|
1486
|
+
if (clean) {
|
|
1487
|
+
nextValue = originalValue.slice(0, cursorOffset) + clean + originalValue.slice(cursorOffset);
|
|
1488
|
+
nextCursor += clean.length;
|
|
1489
|
+
}
|
|
1487
1490
|
}
|
|
1488
1491
|
nextCursor = Math.max(0, Math.min(nextCursor, nextValue.length));
|
|
1489
1492
|
setCursorOffset(nextCursor);
|
|
@@ -1696,10 +1699,14 @@ function createOpenAIAuthProvider(credentials, onTokenRefresh, onValidationChang
|
|
|
1696
1699
|
}
|
|
1697
1700
|
return creds.accessToken;
|
|
1698
1701
|
}
|
|
1702
|
+
const sessionId = crypto.randomUUID();
|
|
1699
1703
|
function buildHeaders3(token) {
|
|
1700
1704
|
const headers = {
|
|
1701
1705
|
Authorization: `Bearer ${token}`,
|
|
1702
|
-
"Content-Type": "application/json"
|
|
1706
|
+
"Content-Type": "application/json",
|
|
1707
|
+
originator: "open-research",
|
|
1708
|
+
"User-Agent": `open-research/${process.env.npm_package_version ?? "0.1.0"} (${process.platform} ${process.arch})`,
|
|
1709
|
+
session_id: sessionId
|
|
1703
1710
|
};
|
|
1704
1711
|
if (creds.accountId) {
|
|
1705
1712
|
headers["ChatGPT-Account-Id"] = creds.accountId;
|
|
@@ -5358,12 +5365,22 @@ async function writeState(state) {
|
|
|
5358
5365
|
await fs17.writeFile(STATE_FILE, JSON.stringify(state), "utf8");
|
|
5359
5366
|
}
|
|
5360
5367
|
function getCurrentVersion() {
|
|
5368
|
+
if (process.env.npm_package_version) return process.env.npm_package_version;
|
|
5361
5369
|
try {
|
|
5362
|
-
const
|
|
5363
|
-
|
|
5370
|
+
const fs19 = __require("fs");
|
|
5371
|
+
const path20 = __require("path");
|
|
5372
|
+
let dir = __dirname || path20.dirname(new URL(import.meta.url).pathname);
|
|
5373
|
+
for (let i = 0; i < 5; i++) {
|
|
5374
|
+
const pkgFile = path20.join(dir, "package.json");
|
|
5375
|
+
if (fs19.existsSync(pkgFile)) {
|
|
5376
|
+
const pkg = JSON.parse(fs19.readFileSync(pkgFile, "utf8"));
|
|
5377
|
+
if (pkg.name === "open-research" && pkg.version) return pkg.version;
|
|
5378
|
+
}
|
|
5379
|
+
dir = path20.dirname(dir);
|
|
5380
|
+
}
|
|
5364
5381
|
} catch {
|
|
5365
|
-
return "0.0.0";
|
|
5366
5382
|
}
|
|
5383
|
+
return "0.0.0";
|
|
5367
5384
|
}
|
|
5368
5385
|
async function fetchLatestVersion() {
|
|
5369
5386
|
try {
|
|
@@ -7471,13 +7488,7 @@ program.name("open-research").description("Local-first research CLI powered by C
|
|
|
7471
7488
|
screen: "home",
|
|
7472
7489
|
pendingUpdates: []
|
|
7473
7490
|
}
|
|
7474
|
-
})
|
|
7475
|
-
{
|
|
7476
|
-
kittyKeyboard: {
|
|
7477
|
-
mode: "auto",
|
|
7478
|
-
flags: ["disambiguateEscapeCodes", "reportAlternateKeys"]
|
|
7479
|
-
}
|
|
7480
|
-
}
|
|
7491
|
+
})
|
|
7481
7492
|
);
|
|
7482
7493
|
});
|
|
7483
7494
|
program.command("init").argument("[workspacePath]").description("Initialize an Open Research workspace.").action(async (workspacePath) => {
|
package/package.json
CHANGED