portable-agent-layer 0.103.0 → 0.103.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/package.json +1 -1
- package/src/hooks/lib/inference.ts +31 -7
package/package.json
CHANGED
|
@@ -294,13 +294,7 @@ async function routeInference(opts: InferenceOptions): Promise<InferenceResult>
|
|
|
294
294
|
const bin = getCopilotBinary();
|
|
295
295
|
if (bin) {
|
|
296
296
|
logDebug("inference", `${tag} route=copilot-spawn agent=${agent}`);
|
|
297
|
-
return
|
|
298
|
-
bin,
|
|
299
|
-
buildCopilotArgs(opts),
|
|
300
|
-
buildCliPrompt(opts),
|
|
301
|
-
opts,
|
|
302
|
-
COPILOT_REPLY
|
|
303
|
-
);
|
|
297
|
+
return inferenceViaCopilotSpawn(bin, opts);
|
|
304
298
|
}
|
|
305
299
|
}
|
|
306
300
|
if (isCursor()) {
|
|
@@ -709,6 +703,36 @@ const COPILOT_REPLY: CliReply = {
|
|
|
709
703
|
usage: copilotSpawnUsage,
|
|
710
704
|
};
|
|
711
705
|
|
|
706
|
+
const COPILOT_TOKEN_ENV = ["COPILOT_GITHUB_TOKEN", "GH_TOKEN", "GITHUB_TOKEN"];
|
|
707
|
+
|
|
708
|
+
/** A /login account lives in COPILOT_HOME's config.json; only a token variable logs in without it. */
|
|
709
|
+
function copilotLogsInWithoutHome(env: NodeJS.ProcessEnv): boolean {
|
|
710
|
+
return COPILOT_TOKEN_ENV.some((name) => Boolean(env[name]));
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
/** --no-custom-instructions still loads COPILOT_HOME/instructions, where PAL's identity lives. */
|
|
714
|
+
async function inferenceViaCopilotSpawn(
|
|
715
|
+
bin: string,
|
|
716
|
+
opts: InferenceOptions
|
|
717
|
+
): Promise<InferenceResult> {
|
|
718
|
+
const spawn = (place?: SpawnPlace) =>
|
|
719
|
+
inferenceViaCliSpawn(
|
|
720
|
+
bin,
|
|
721
|
+
buildCopilotArgs(opts),
|
|
722
|
+
buildCliPrompt(opts),
|
|
723
|
+
opts,
|
|
724
|
+
COPILOT_REPLY,
|
|
725
|
+
place
|
|
726
|
+
);
|
|
727
|
+
if (!copilotLogsInWithoutHome(withPalEnv(process.env))) return spawn();
|
|
728
|
+
const dir = await mkdtemp(join(tmpdir(), "pal-copilot-"));
|
|
729
|
+
try {
|
|
730
|
+
return await spawn({ cwd: dir, env: { COPILOT_HOME: dir } });
|
|
731
|
+
} finally {
|
|
732
|
+
await rm(dir, { recursive: true, force: true });
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
|
|
712
736
|
function copilotTools(opts: InferenceOptions): string[] {
|
|
713
737
|
return opts.web
|
|
714
738
|
? ["--available-tools=web_fetch", "--allow-tool=web_fetch", "--allow-all-urls"]
|