spacecode 2.12.7 → 2.13.1
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 +2 -2
- package/dist/index.js.map +1 -1
- package/dist/repl.mjs +31 -3
- package/package.json +1 -1
package/dist/repl.mjs
CHANGED
|
@@ -104831,6 +104831,25 @@ var init_core_turn = __esm({
|
|
|
104831
104831
|
import { execFile as execFile4 } from "node:child_process";
|
|
104832
104832
|
import { mkdir as mkdir6, writeFile as writeFile6 } from "node:fs/promises";
|
|
104833
104833
|
import { join as join15 } from "node:path";
|
|
104834
|
+
async function repoIsPublic(url, fetchFn = fetch) {
|
|
104835
|
+
const hit = visibility.get(url);
|
|
104836
|
+
if (hit !== void 0) return hit;
|
|
104837
|
+
let ok = false;
|
|
104838
|
+
try {
|
|
104839
|
+
const res = await fetchFn(url.replace("https://github.com/", "https://api.github.com/repos/"), { headers: { Accept: "application/vnd.github+json" }, signal: AbortSignal.timeout(3e3) });
|
|
104840
|
+
ok = res.ok;
|
|
104841
|
+
} catch {
|
|
104842
|
+
ok = false;
|
|
104843
|
+
}
|
|
104844
|
+
visibility.set(url, ok);
|
|
104845
|
+
return ok;
|
|
104846
|
+
}
|
|
104847
|
+
async function chooseCore(env3, repo, fetchFn) {
|
|
104848
|
+
if (!shouldUseCore(env3, repo)) return { useCore: false };
|
|
104849
|
+
if (coreSwitch(env3) === "on" || repo === null || shareableGithubToken(env3)) return { useCore: true };
|
|
104850
|
+
if (await repoIsPublic(repo.url, fetchFn)) return { useCore: true };
|
|
104851
|
+
return { useCore: false, reason: "Core runs are off for this repo: it is private (or unreachable) and task agents cannot clone it. Using the local agent. Set SPACECODE_CORE_SHARE_GITHUB_TOKEN=on with GH_TOKEN to allow it, or SPACECODE_CORE=on to force it." };
|
|
104852
|
+
}
|
|
104834
104853
|
function githubHttpsUrl(remote) {
|
|
104835
104854
|
const t = remote.trim();
|
|
104836
104855
|
const m2 = t.match(/^(?:git@github\.com:|ssh:\/\/git@github\.com\/|https:\/\/(?:[^@/]+@)?github\.com\/)([A-Za-z0-9_.-]+)\/([A-Za-z0-9_.-]+?)(?:\.git)?\/?$/);
|
|
@@ -104894,13 +104913,16 @@ async function runCoreForRepl(o) {
|
|
|
104894
104913
|
const messages = [...o.history, { role: "user", content: o.prompt }, { role: "assistant", content: [{ type: "text", text: turn.text || "(no reply)" }] }];
|
|
104895
104914
|
return { success: turn.success, messages, totalInputTokens: turn.tokens, totalOutputTokens: 0 };
|
|
104896
104915
|
}
|
|
104897
|
-
var coreModeOn, sq;
|
|
104916
|
+
var coreSwitch, coreModeOn, shouldUseCore, visibility, sq;
|
|
104898
104917
|
var init_core_mode = __esm({
|
|
104899
104918
|
"src/core/core-mode.ts"() {
|
|
104900
104919
|
"use strict";
|
|
104901
104920
|
init_core_turn();
|
|
104902
104921
|
init_profile_runtime();
|
|
104903
|
-
|
|
104922
|
+
coreSwitch = (env3) => (env3.SPACECODE_CORE ?? "").trim().toLowerCase();
|
|
104923
|
+
coreModeOn = (env3) => !["off", "0", "false", "no"].includes(coreSwitch(env3));
|
|
104924
|
+
shouldUseCore = (env3, repo) => coreModeOn(env3) && (repo !== null || coreSwitch(env3) === "on");
|
|
104925
|
+
visibility = /* @__PURE__ */ new Map();
|
|
104904
104926
|
sq = (s) => `'${s.replace(/'/g, `'\\''`)}'`;
|
|
104905
104927
|
}
|
|
104906
104928
|
});
|
|
@@ -104966,6 +104988,7 @@ function useReplController({ repoName: repoName2, yolo: yolo2, mentions: mention
|
|
|
104966
104988
|
}, []);
|
|
104967
104989
|
const [replayed, setReplayed] = (0, import_react30.useState)([]);
|
|
104968
104990
|
const [notices, setNotices] = (0, import_react30.useState)([]);
|
|
104991
|
+
const corePrivateNoticeShown = (0, import_react30.useRef)(false);
|
|
104969
104992
|
const retryRef = (0, import_react30.useRef)(null);
|
|
104970
104993
|
const [pending, setPending] = (0, import_react30.useState)(null);
|
|
104971
104994
|
const abortRef = (0, import_react30.useRef)(null);
|
|
@@ -105494,7 +105517,12 @@ ${list2.map((c) => ` /${c.name} (${c.scope})${c.description ? ` ${c.descripti
|
|
|
105494
105517
|
};
|
|
105495
105518
|
const attached = await mentions.attach(prompt);
|
|
105496
105519
|
if (attached.notices.length > 0) setNotices(attached.notices);
|
|
105497
|
-
const
|
|
105520
|
+
const coreChoice = coreModeOn(process.env) ? await chooseCore(process.env, await detectRepo(projectRoot, process.env)) : { useCore: false };
|
|
105521
|
+
if (coreChoice.reason && !corePrivateNoticeShown.current) {
|
|
105522
|
+
corePrivateNoticeShown.current = true;
|
|
105523
|
+
notice(coreChoice.reason);
|
|
105524
|
+
}
|
|
105525
|
+
const result = coreChoice.useCore ? await runCoreForRepl({
|
|
105498
105526
|
env: process.env,
|
|
105499
105527
|
apiKey,
|
|
105500
105528
|
sessionId: sessionIdRef.current ??= sessions ? sessions.newId() : crypto.randomUUID(),
|