gemini-cli-leo 0.1.19-fix.11 → 0.1.20
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/docs/cli/settings.md +13 -12
- package/docs/reference/configuration.md +10 -0
- package/gemini.mjs +235 -69
- package/package.json +1 -1
package/docs/cli/settings.md
CHANGED
|
@@ -141,18 +141,19 @@ they appear in the UI.
|
|
|
141
141
|
|
|
142
142
|
### Security
|
|
143
143
|
|
|
144
|
-
| UI Label | Setting | Description
|
|
145
|
-
| ------------------------------------- | ----------------------------------------------- |
|
|
146
|
-
| Tool Sandboxing | `security.toolSandboxing` | Tool-level sandboxing. Isolates individual tools instead of the entire CLI process.
|
|
147
|
-
| Disable YOLO Mode | `security.disableYoloMode` | Disable YOLO mode, even if enabled by a flag.
|
|
148
|
-
| Disable Always Allow | `security.disableAlwaysAllow` | Disable "Always allow" options in tool confirmation dialogs.
|
|
149
|
-
| Allow Permanent Tool Approval | `security.enablePermanentToolApproval` | Enable the "Allow for all future sessions" option in tool confirmation dialogs.
|
|
150
|
-
| Auto-add to Policy by Default | `security.autoAddToPolicyByDefault` | When enabled, the "Allow for all future sessions" option becomes the default choice for low-risk tools in trusted workspaces.
|
|
151
|
-
| Blocks extensions from Git | `security.blockGitExtensions` | Blocks installing and loading extensions from Git.
|
|
152
|
-
| Extension Source Regex Allowlist | `security.allowedExtensions` | List of Regex patterns for allowed extensions. If nonempty, only extensions that match the patterns in this list are allowed. Overrides the blockGitExtensions setting.
|
|
153
|
-
| Folder Trust | `security.folderTrust.enabled` | Setting to track whether Folder trust is enabled.
|
|
154
|
-
| Enable Environment Variable Redaction | `security.environmentVariableRedaction.enabled` | Enable redaction of environment variables that may contain secrets.
|
|
155
|
-
|
|
|
144
|
+
| UI Label | Setting | Description | Default |
|
|
145
|
+
| ------------------------------------- | ----------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- |
|
|
146
|
+
| Tool Sandboxing | `security.toolSandboxing` | Tool-level sandboxing. Isolates individual tools instead of the entire CLI process. | `false` |
|
|
147
|
+
| Disable YOLO Mode | `security.disableYoloMode` | Disable YOLO mode, even if enabled by a flag. | `false` |
|
|
148
|
+
| Disable Always Allow | `security.disableAlwaysAllow` | Disable "Always allow" options in tool confirmation dialogs. | `false` |
|
|
149
|
+
| Allow Permanent Tool Approval | `security.enablePermanentToolApproval` | Enable the "Allow for all future sessions" option in tool confirmation dialogs. | `false` |
|
|
150
|
+
| Auto-add to Policy by Default | `security.autoAddToPolicyByDefault` | When enabled, the "Allow for all future sessions" option becomes the default choice for low-risk tools in trusted workspaces. | `false` |
|
|
151
|
+
| Blocks extensions from Git | `security.blockGitExtensions` | Blocks installing and loading extensions from Git. | `false` |
|
|
152
|
+
| Extension Source Regex Allowlist | `security.allowedExtensions` | List of Regex patterns for allowed extensions. If nonempty, only extensions that match the patterns in this list are allowed. Overrides the blockGitExtensions setting. | `[]` |
|
|
153
|
+
| Folder Trust | `security.folderTrust.enabled` | Setting to track whether Folder trust is enabled. | `true` |
|
|
154
|
+
| Enable Environment Variable Redaction | `security.environmentVariableRedaction.enabled` | Enable redaction of environment variables that may contain secrets. | `false` |
|
|
155
|
+
| OpenCode Request Headers | `security.auth.openAiOpencodeHeaders` | Adapt OpenAI-compatible requests to look like they came from the OpenCode CLI: client-identity headers plus the tool names some free endpoints require. Only enable this when the endpoint rejects requests that do not look like they came from the OpenCode CLI; some providers issue a key that is only accepted with the disguise in place. Requires a restart. | `false` |
|
|
156
|
+
| Enable Context-Aware Security | `security.enableConseca` | Enable the context-aware security checker. This feature uses an LLM to dynamically generate and enforce security policies for tool use based on your prompt, providing an additional layer of protection against unintended actions. | `false` |
|
|
156
157
|
|
|
157
158
|
### Advanced
|
|
158
159
|
|
|
@@ -2016,6 +2016,16 @@ their corresponding top-level category object in your `settings.json` file.
|
|
|
2016
2016
|
the file's first entry.
|
|
2017
2017
|
- **Default:** `undefined`
|
|
2018
2018
|
|
|
2019
|
+
- **`security.auth.openAiOpencodeHeaders`** (boolean):
|
|
2020
|
+
|
|
2021
|
+
- **Description:** Adapt OpenAI-compatible requests to look like they came
|
|
2022
|
+
from the OpenCode CLI: client-identity headers plus the tool names some free
|
|
2023
|
+
endpoints require. Only enable this when the endpoint rejects requests that
|
|
2024
|
+
do not look like they came from the OpenCode CLI; some providers issue a key
|
|
2025
|
+
that is only accepted with the disguise in place. Requires a restart.
|
|
2026
|
+
- **Default:** `false`
|
|
2027
|
+
- **Requires restart:** Yes
|
|
2028
|
+
|
|
2019
2029
|
- **`security.auth.enforcedType`** (string):
|
|
2020
2030
|
|
|
2021
2031
|
- **Description:** The required auth type. If this does not match the selected
|
package/gemini.mjs
CHANGED
|
@@ -41486,7 +41486,7 @@ var require_websocket = __commonJS({
|
|
|
41486
41486
|
var http9 = __require("http");
|
|
41487
41487
|
var net3 = __require("net");
|
|
41488
41488
|
var tls = __require("tls");
|
|
41489
|
-
var { randomBytes:
|
|
41489
|
+
var { randomBytes: randomBytes9, createHash: createHash21 } = __require("crypto");
|
|
41490
41490
|
var { Duplex: Duplex4, Readable: Readable9 } = __require("stream");
|
|
41491
41491
|
var { URL: URL8 } = __require("url");
|
|
41492
41492
|
var PerMessageDeflate = require_permessage_deflate();
|
|
@@ -42013,7 +42013,7 @@ var require_websocket = __commonJS({
|
|
|
42013
42013
|
}
|
|
42014
42014
|
}
|
|
42015
42015
|
const defaultPort = isSecure ? 443 : 80;
|
|
42016
|
-
const key =
|
|
42016
|
+
const key = randomBytes9(16).toString("base64");
|
|
42017
42017
|
const request = isSecure ? https6.request : http9.request;
|
|
42018
42018
|
const protocolSet = /* @__PURE__ */ new Set();
|
|
42019
42019
|
let perMessageDeflate;
|
|
@@ -42143,7 +42143,7 @@ var require_websocket = __commonJS({
|
|
|
42143
42143
|
abortHandshake(websocket, socket, "Invalid Upgrade header");
|
|
42144
42144
|
return;
|
|
42145
42145
|
}
|
|
42146
|
-
const digest =
|
|
42146
|
+
const digest = createHash21("sha1").update(key + GUID).digest("base64");
|
|
42147
42147
|
if (res.headers["sec-websocket-accept"] !== digest) {
|
|
42148
42148
|
abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
|
|
42149
42149
|
return;
|
|
@@ -42510,7 +42510,7 @@ var require_websocket_server = __commonJS({
|
|
|
42510
42510
|
var EventEmitter21 = __require("events");
|
|
42511
42511
|
var http9 = __require("http");
|
|
42512
42512
|
var { Duplex: Duplex4 } = __require("stream");
|
|
42513
|
-
var { createHash:
|
|
42513
|
+
var { createHash: createHash21 } = __require("crypto");
|
|
42514
42514
|
var extension = require_extension();
|
|
42515
42515
|
var PerMessageDeflate = require_permessage_deflate();
|
|
42516
42516
|
var subprotocol = require_subprotocol();
|
|
@@ -42807,7 +42807,7 @@ var require_websocket_server = __commonJS({
|
|
|
42807
42807
|
);
|
|
42808
42808
|
}
|
|
42809
42809
|
if (this._state > RUNNING) return abortHandshake(socket, 503);
|
|
42810
|
-
const digest =
|
|
42810
|
+
const digest = createHash21("sha1").update(key + GUID).digest("base64");
|
|
42811
42811
|
const headers = [
|
|
42812
42812
|
"HTTP/1.1 101 Switching Protocols",
|
|
42813
42813
|
"Upgrade: websocket",
|
|
@@ -173107,8 +173107,8 @@ var GIT_COMMIT_INFO, CLI_VERSION;
|
|
|
173107
173107
|
var init_git_commit = __esm({
|
|
173108
173108
|
"packages/core/dist/src/generated/git-commit.js"() {
|
|
173109
173109
|
"use strict";
|
|
173110
|
-
GIT_COMMIT_INFO = "
|
|
173111
|
-
CLI_VERSION = "0.1.
|
|
173110
|
+
GIT_COMMIT_INFO = "aa945fc";
|
|
173111
|
+
CLI_VERSION = "0.1.20";
|
|
173112
173112
|
}
|
|
173113
173113
|
});
|
|
173114
173114
|
|
|
@@ -218502,8 +218502,8 @@ var require_context = __commonJS({
|
|
|
218502
218502
|
var SPAN_ID_RANDOM_BYTES = 8;
|
|
218503
218503
|
var spanIdBuffer = Buffer.alloc(SPAN_ID_RANDOM_BYTES);
|
|
218504
218504
|
var randomFillSync2 = crypto27.randomFillSync;
|
|
218505
|
-
var
|
|
218506
|
-
var spanRandomBuffer = randomFillSync2 ? () => randomFillSync2(spanIdBuffer) : () =>
|
|
218505
|
+
var randomBytes9 = crypto27.randomBytes;
|
|
218506
|
+
var spanRandomBuffer = randomFillSync2 ? () => randomFillSync2(spanIdBuffer) : () => randomBytes9(SPAN_ID_RANDOM_BYTES);
|
|
218507
218507
|
exports2.W3C_TRACE_PARENT_HEADER = "traceparent";
|
|
218508
218508
|
function makeHeaderWrapper(req) {
|
|
218509
218509
|
if (!req.headers)
|
|
@@ -316255,7 +316255,7 @@ function getVersion() {
|
|
|
316255
316255
|
}
|
|
316256
316256
|
versionPromise = (async () => {
|
|
316257
316257
|
const pkgJson = await getPackageJson(__dirname4);
|
|
316258
|
-
return "0.1.
|
|
316258
|
+
return "0.1.20";
|
|
316259
316259
|
})();
|
|
316260
316260
|
return versionPromise;
|
|
316261
316261
|
}
|
|
@@ -323274,10 +323274,11 @@ async function* parseSseStream(body2) {
|
|
|
323274
323274
|
});
|
|
323275
323275
|
}
|
|
323276
323276
|
}
|
|
323277
|
-
var HEADERS_TIMEOUT_MS, STREAM_IDLE_TIMEOUT_MS, OpenAIHttpError, MAX_ERROR_BODY_CHARS, OpenAICompatibleClient;
|
|
323277
|
+
var import_undici2, HEADERS_TIMEOUT_MS, STREAM_IDLE_TIMEOUT_MS, OpenAIHttpError, MAX_ERROR_BODY_CHARS, OpenAICompatibleClient;
|
|
323278
323278
|
var init_openaiClient = __esm({
|
|
323279
323279
|
"packages/core/dist/src/core/openai/openaiClient.js"() {
|
|
323280
323280
|
"use strict";
|
|
323281
|
+
import_undici2 = __toESM(require_undici(), 1);
|
|
323281
323282
|
init_fetch();
|
|
323282
323283
|
init_debugLogger();
|
|
323283
323284
|
HEADERS_TIMEOUT_MS = 6e4;
|
|
@@ -323299,6 +323300,19 @@ var init_openaiClient = __esm({
|
|
|
323299
323300
|
apiKey;
|
|
323300
323301
|
extraHeaders;
|
|
323301
323302
|
dispatcher;
|
|
323303
|
+
/**
|
|
323304
|
+
* `fetch` from the same undici instance that created `dispatcher`.
|
|
323305
|
+
*
|
|
323306
|
+
* A dispatcher cannot be handed to the platform `fetch`: the two undici
|
|
323307
|
+
* copies do not share the private symbols that carry a request through the
|
|
323308
|
+
* dispatcher, so the platform `fetch` treats the proxied hop's raw bytes as
|
|
323309
|
+
* the response body — a 200 with TLS-looking garbage that later fails JSON
|
|
323310
|
+
* parsing — or throws a bare `TypeError: fetch failed`. Both were reproduced
|
|
323311
|
+
* on Node 26 with the packaged undici 7.10 through ClashX. Keeping `fetch`
|
|
323312
|
+
* and the agent in one instance is the pattern `createProxyAwareFetch` in
|
|
323313
|
+
* `ide-connection-utils.ts` already uses.
|
|
323314
|
+
*/
|
|
323315
|
+
fetchImpl;
|
|
323302
323316
|
constructor(options) {
|
|
323303
323317
|
if (!options.baseUrl) {
|
|
323304
323318
|
throw new Error("OpenAI-compatible mode requires GEMINI_OPENAI_BASE_URL to be set.");
|
|
@@ -323307,6 +323321,10 @@ var init_openaiClient = __esm({
|
|
|
323307
323321
|
this.apiKey = options.apiKey;
|
|
323308
323322
|
this.extraHeaders = options.headers ?? {};
|
|
323309
323323
|
this.dispatcher = this.resolveDispatcher(options.proxy);
|
|
323324
|
+
this.fetchImpl = this.dispatcher ? (
|
|
323325
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-type-assertion
|
|
323326
|
+
import_undici2.fetch
|
|
323327
|
+
) : fetch;
|
|
323310
323328
|
}
|
|
323311
323329
|
/**
|
|
323312
323330
|
* Builds the proxy dispatcher for the request, if one is needed.
|
|
@@ -323361,7 +323379,7 @@ var init_openaiClient = __esm({
|
|
|
323361
323379
|
options.dispatcher = this.dispatcher;
|
|
323362
323380
|
}
|
|
323363
323381
|
try {
|
|
323364
|
-
const response = await
|
|
323382
|
+
const response = await this.fetchImpl(url4, options);
|
|
323365
323383
|
if (!response.ok) {
|
|
323366
323384
|
bounded.clear();
|
|
323367
323385
|
throw await toHttpError(response);
|
|
@@ -323438,7 +323456,7 @@ var init_openaiClient = __esm({
|
|
|
323438
323456
|
}
|
|
323439
323457
|
let response;
|
|
323440
323458
|
try {
|
|
323441
|
-
response = await
|
|
323459
|
+
response = await this.fetchImpl(url4, options);
|
|
323442
323460
|
if (!response.ok)
|
|
323443
323461
|
throw await toHttpError(response);
|
|
323444
323462
|
} catch (error40) {
|
|
@@ -323938,6 +323956,33 @@ var init_constants4 = __esm({
|
|
|
323938
323956
|
}
|
|
323939
323957
|
});
|
|
323940
323958
|
|
|
323959
|
+
// packages/core/dist/src/core/openai/opencode/body.js
|
|
323960
|
+
function freeLaneTool(name3) {
|
|
323961
|
+
return {
|
|
323962
|
+
type: "function",
|
|
323963
|
+
function: {
|
|
323964
|
+
name: name3,
|
|
323965
|
+
description: "Reserved for the host runtime; do not call it.",
|
|
323966
|
+
parameters: { type: "object", properties: {} }
|
|
323967
|
+
}
|
|
323968
|
+
};
|
|
323969
|
+
}
|
|
323970
|
+
function ensureOpencodeFreeLaneShape(body2) {
|
|
323971
|
+
const declared = new Set((body2.tools ?? []).map((tool) => tool.function.name));
|
|
323972
|
+
const missing = FREE_LANE_TOOL_NAMES.filter((name3) => !declared.has(name3));
|
|
323973
|
+
if (missing.length === 0) {
|
|
323974
|
+
return;
|
|
323975
|
+
}
|
|
323976
|
+
body2.tools = [...body2.tools ?? [], ...missing.map(freeLaneTool)];
|
|
323977
|
+
}
|
|
323978
|
+
var FREE_LANE_TOOL_NAMES;
|
|
323979
|
+
var init_body3 = __esm({
|
|
323980
|
+
"packages/core/dist/src/core/openai/opencode/body.js"() {
|
|
323981
|
+
"use strict";
|
|
323982
|
+
FREE_LANE_TOOL_NAMES = ["bash", "read"];
|
|
323983
|
+
}
|
|
323984
|
+
});
|
|
323985
|
+
|
|
323941
323986
|
// packages/core/dist/src/core/openai/openaiContentGenerator.js
|
|
323942
323987
|
function isGeminiModelName(model) {
|
|
323943
323988
|
if (isAutoModel(model))
|
|
@@ -323979,6 +324024,7 @@ var init_openaiContentGenerator = __esm({
|
|
|
323979
324024
|
init_converters();
|
|
323980
324025
|
init_constants4();
|
|
323981
324026
|
init_models();
|
|
324027
|
+
init_body3();
|
|
323982
324028
|
OpenAIContentGenerator = class {
|
|
323983
324029
|
client;
|
|
323984
324030
|
configuredModelId;
|
|
@@ -324035,6 +324081,9 @@ var init_openaiContentGenerator = __esm({
|
|
|
324035
324081
|
async generateContent(request, _userPromptId, _role) {
|
|
324036
324082
|
const modelId = this.resolveModelId();
|
|
324037
324083
|
const body2 = toOpenAIRequest(request, modelId, false);
|
|
324084
|
+
if (this.gcConfig.getOpenAiOpencodeHeaders?.()) {
|
|
324085
|
+
ensureOpencodeFreeLaneShape(body2);
|
|
324086
|
+
}
|
|
324038
324087
|
const completion3 = await this.client.chatCompletion(body2, request.config?.abortSignal);
|
|
324039
324088
|
if (completion3.error) {
|
|
324040
324089
|
throw new OpenAIHttpError(`OpenAI-compatible endpoint returned an error: ${completion3.error.message ?? "unknown error"}`, 502);
|
|
@@ -324044,6 +324093,9 @@ var init_openaiContentGenerator = __esm({
|
|
|
324044
324093
|
async generateContentStream(request, _userPromptId, _role) {
|
|
324045
324094
|
const modelId = this.resolveModelId();
|
|
324046
324095
|
const body2 = toOpenAIRequest(request, modelId, true);
|
|
324096
|
+
if (this.gcConfig.getOpenAiOpencodeHeaders?.()) {
|
|
324097
|
+
ensureOpencodeFreeLaneShape(body2);
|
|
324098
|
+
}
|
|
324047
324099
|
const pending = await this.client.startChatCompletionStream(body2, request.config?.abortSignal);
|
|
324048
324100
|
return this.consumeStream(pending.response.body, pending.release, modelId);
|
|
324049
324101
|
}
|
|
@@ -324392,6 +324444,77 @@ var init_providers = __esm({
|
|
|
324392
324444
|
}
|
|
324393
324445
|
});
|
|
324394
324446
|
|
|
324447
|
+
// packages/core/dist/src/core/openai/opencode/headers.js
|
|
324448
|
+
import { createHash as createHash7, randomBytes as randomBytes3 } from "node:crypto";
|
|
324449
|
+
function base62Fixed(value, width) {
|
|
324450
|
+
const base = 62n;
|
|
324451
|
+
let n3 = value;
|
|
324452
|
+
const out2 = new Array(width);
|
|
324453
|
+
for (let i4 = width - 1; i4 >= 0; i4--) {
|
|
324454
|
+
out2[i4] = BASE62_ALPHABET.charAt(Number(n3 % base));
|
|
324455
|
+
n3 /= base;
|
|
324456
|
+
}
|
|
324457
|
+
return out2.join("");
|
|
324458
|
+
}
|
|
324459
|
+
function invertedTimestampHex(now = Date.now()) {
|
|
324460
|
+
const current = BigInt(now) * 0x1000n + 1n;
|
|
324461
|
+
const inverted = ~current & 0xffffffffffffn;
|
|
324462
|
+
return inverted.toString(16).padStart(12, "0");
|
|
324463
|
+
}
|
|
324464
|
+
function opencodeUserAgent() {
|
|
324465
|
+
return `opencode/${OPENCODE_USER_AGENT_VERSION} (${process.platform} ${process.arch}; node${process.versions.node})`;
|
|
324466
|
+
}
|
|
324467
|
+
function canonicalOpencodeSessionId(signal, now = Date.now()) {
|
|
324468
|
+
if (SESSION_ID_PATTERN.test(signal)) {
|
|
324469
|
+
return signal;
|
|
324470
|
+
}
|
|
324471
|
+
const memoized = sessionMemo.get(signal);
|
|
324472
|
+
if (memoized !== void 0) {
|
|
324473
|
+
return memoized;
|
|
324474
|
+
}
|
|
324475
|
+
const digest = createHash7("sha256").update("ses\0" + signal).digest();
|
|
324476
|
+
const tail = base62Fixed(BigInt("0x" + digest.subarray(6, 16).toString("hex")), 14);
|
|
324477
|
+
const session = `ses_${invertedTimestampHex(now)}${tail}`;
|
|
324478
|
+
if (sessionMemo.size >= SESSION_MEMO_LIMIT) {
|
|
324479
|
+
const oldest = sessionMemo.keys().next();
|
|
324480
|
+
if (!oldest.done) {
|
|
324481
|
+
sessionMemo.delete(oldest.value);
|
|
324482
|
+
}
|
|
324483
|
+
}
|
|
324484
|
+
sessionMemo.set(signal, session);
|
|
324485
|
+
return session;
|
|
324486
|
+
}
|
|
324487
|
+
function opencodeRequestId() {
|
|
324488
|
+
return `req_${randomBytes3(16).toString("hex")}`;
|
|
324489
|
+
}
|
|
324490
|
+
function opencodeProjectId(seed = "gemini-cli:default-project") {
|
|
324491
|
+
const digest = createHash7("sha256").update("prj\0" + seed).digest();
|
|
324492
|
+
return `prj_${digest.subarray(0, 12).toString("hex")}`;
|
|
324493
|
+
}
|
|
324494
|
+
function buildOpencodeDisguiseHeaders(options) {
|
|
324495
|
+
const session = canonicalOpencodeSessionId(options.sessionSignal, options.now);
|
|
324496
|
+
return {
|
|
324497
|
+
"user-agent": opencodeUserAgent(),
|
|
324498
|
+
"x-opencode-client": "cli",
|
|
324499
|
+
"x-opencode-session": session,
|
|
324500
|
+
"x-session-affinity": session,
|
|
324501
|
+
"X-Session-Id": session,
|
|
324502
|
+
"x-opencode-request": opencodeRequestId(),
|
|
324503
|
+
"x-opencode-project": opencodeProjectId()
|
|
324504
|
+
};
|
|
324505
|
+
}
|
|
324506
|
+
var OPENCODE_USER_AGENT_VERSION, SESSION_ID_PATTERN, BASE62_ALPHABET, SESSION_MEMO_LIMIT, sessionMemo;
|
|
324507
|
+
var init_headers3 = __esm({
|
|
324508
|
+
"packages/core/dist/src/core/openai/opencode/headers.js"() {
|
|
324509
|
+
"use strict";
|
|
324510
|
+
OPENCODE_USER_AGENT_VERSION = "1.18.31";
|
|
324511
|
+
SESSION_ID_PATTERN = /^ses_[0-9a-f]{12}[0-9A-Za-z]{14}$/;
|
|
324512
|
+
BASE62_ALPHABET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
|
324513
|
+
SESSION_MEMO_LIMIT = 1024;
|
|
324514
|
+
sessionMemo = /* @__PURE__ */ new Map();
|
|
324515
|
+
}
|
|
324516
|
+
});
|
|
324517
|
+
|
|
324395
324518
|
// packages/core/dist/src/core/openai/integration.js
|
|
324396
324519
|
import * as fs42 from "node:fs";
|
|
324397
324520
|
function applyProviderToContentGeneratorConfig(options) {
|
|
@@ -324413,6 +324536,17 @@ function applyProviderToContentGeneratorConfig(options) {
|
|
|
324413
324536
|
...customHeaders
|
|
324414
324537
|
};
|
|
324415
324538
|
}
|
|
324539
|
+
const opencodeSessionId = config2?.getSessionId?.();
|
|
324540
|
+
if (config2?.getOpenAiOpencodeHeaders?.() && opencodeSessionId) {
|
|
324541
|
+
contentGeneratorConfig.customHeaders = {
|
|
324542
|
+
...buildOpencodeDisguiseHeaders({ sessionSignal: opencodeSessionId }),
|
|
324543
|
+
// The caller's headers (session-scoped override) still win, including the
|
|
324544
|
+
// case where no provider profile was resolved and the block above did not
|
|
324545
|
+
// merge them in.
|
|
324546
|
+
...customHeaders,
|
|
324547
|
+
...contentGeneratorConfig.customHeaders
|
|
324548
|
+
};
|
|
324549
|
+
}
|
|
324416
324550
|
contentGeneratorConfig.modelId = provider?.modelId;
|
|
324417
324551
|
}
|
|
324418
324552
|
function resolveActiveProvider(options) {
|
|
@@ -324498,6 +324632,7 @@ var init_integration = __esm({
|
|
|
324498
324632
|
init_events();
|
|
324499
324633
|
init_errors2();
|
|
324500
324634
|
init_providers();
|
|
324635
|
+
init_headers3();
|
|
324501
324636
|
init_constants4();
|
|
324502
324637
|
}
|
|
324503
324638
|
});
|
|
@@ -364721,7 +364856,7 @@ var init_nextSpeakerChecker = __esm({
|
|
|
364721
364856
|
});
|
|
364722
364857
|
|
|
364723
364858
|
// packages/core/dist/src/services/loopDetectionService.js
|
|
364724
|
-
import { createHash as
|
|
364859
|
+
import { createHash as createHash11 } from "node:crypto";
|
|
364725
364860
|
var TOOL_CALL_LOOP_THRESHOLD, CONTENT_LOOP_THRESHOLD, CONTENT_CHUNK_SIZE, MAX_HISTORY_LENGTH, LLM_LOOP_CHECK_HISTORY_COUNT, LLM_CHECK_AFTER_TURNS, DEFAULT_LLM_CHECK_INTERVAL, MIN_LLM_CHECK_INTERVAL, MAX_LLM_CHECK_INTERVAL, LLM_CONFIDENCE_THRESHOLD, DOUBLE_CHECK_MODEL_ALIAS, LOOP_DETECTION_SYSTEM_PROMPT, LOOP_DETECTION_SCHEMA, LoopDetectionService;
|
|
364726
364861
|
var init_loopDetectionService = __esm({
|
|
364727
364862
|
"packages/core/dist/src/services/loopDetectionService.js"() {
|
|
@@ -364824,7 +364959,7 @@ If the original user request is provided, use it to contextualize the assistant'
|
|
|
364824
364959
|
getToolCallKey(toolCall) {
|
|
364825
364960
|
const argsString = JSON.stringify(toolCall.args);
|
|
364826
364961
|
const keyString = `${toolCall.name}:${argsString}`;
|
|
364827
|
-
return
|
|
364962
|
+
return createHash11("sha256").update(keyString).digest("hex");
|
|
364828
364963
|
}
|
|
364829
364964
|
/**
|
|
364830
364965
|
* Processes a stream event and checks for loop conditions.
|
|
@@ -365007,7 +365142,7 @@ If the original user request is provided, use it to contextualize the assistant'
|
|
|
365007
365142
|
analyzeContentChunksForLoop() {
|
|
365008
365143
|
while (this.hasMoreChunksToProcess()) {
|
|
365009
365144
|
const currentChunk = this.streamContentHistory.substring(this.lastContentIndex, this.lastContentIndex + CONTENT_CHUNK_SIZE);
|
|
365010
|
-
const chunkHash =
|
|
365145
|
+
const chunkHash = createHash11("sha256").update(currentChunk).digest("hex");
|
|
365011
365146
|
if (this.isLoopDetectedForChunk(currentChunk, chunkHash)) {
|
|
365012
365147
|
return true;
|
|
365013
365148
|
}
|
|
@@ -367361,7 +367496,7 @@ var init_inbox = __esm({
|
|
|
367361
367496
|
});
|
|
367362
367497
|
|
|
367363
367498
|
// packages/core/dist/src/context/graph/toGraph.js
|
|
367364
|
-
import { createHash as
|
|
367499
|
+
import { createHash as createHash12 } from "node:crypto";
|
|
367365
367500
|
function isTextPart3(part) {
|
|
367366
367501
|
return typeof part.text === "string";
|
|
367367
367502
|
}
|
|
@@ -367396,33 +367531,33 @@ function getStableId(obj, idService, turnSalt = "", partIdx = 0) {
|
|
|
367396
367531
|
const part = obj;
|
|
367397
367532
|
let contentHash;
|
|
367398
367533
|
if (isTextPart3(part)) {
|
|
367399
|
-
contentHash =
|
|
367534
|
+
contentHash = createHash12("sha256").update(part.text).digest("hex");
|
|
367400
367535
|
id = `text_${contentHash}_${turnSalt}_${partIdx}`;
|
|
367401
367536
|
} else if (isInlineDataPart(part)) {
|
|
367402
|
-
contentHash =
|
|
367537
|
+
contentHash = createHash12("sha256").update(part.inlineData.data).digest("hex");
|
|
367403
367538
|
id = `media_${contentHash}_${turnSalt}_${partIdx}`;
|
|
367404
367539
|
} else if (isFileDataPart(part)) {
|
|
367405
|
-
contentHash =
|
|
367540
|
+
contentHash = createHash12("sha256").update(part.fileData.fileUri).digest("hex");
|
|
367406
367541
|
id = `file_${contentHash}_${turnSalt}_${partIdx}`;
|
|
367407
367542
|
} else if (isFunctionCallPart(part)) {
|
|
367408
367543
|
if (part.functionCall.id) {
|
|
367409
367544
|
id = `call_${part.functionCall.id}`;
|
|
367410
367545
|
} else {
|
|
367411
|
-
contentHash =
|
|
367546
|
+
contentHash = createHash12("sha256").update(`call:${part.functionCall.name}:${JSON.stringify(part.functionCall.args)}`).digest("hex");
|
|
367412
367547
|
id = `call_h_${contentHash}_${turnSalt}_${partIdx}`;
|
|
367413
367548
|
}
|
|
367414
367549
|
} else if (isFunctionResponsePart(part)) {
|
|
367415
367550
|
if (part.functionResponse.id) {
|
|
367416
367551
|
id = `resp_${part.functionResponse.id}`;
|
|
367417
367552
|
} else {
|
|
367418
|
-
contentHash =
|
|
367553
|
+
contentHash = createHash12("sha256").update(`resp:${part.functionResponse.name}:${JSON.stringify(part.functionResponse.response)}`).digest("hex");
|
|
367419
367554
|
id = `resp_h_${contentHash}_${turnSalt}_${partIdx}`;
|
|
367420
367555
|
}
|
|
367421
367556
|
} else if (isExecutableCodePart(part)) {
|
|
367422
|
-
contentHash =
|
|
367557
|
+
contentHash = createHash12("sha256").update(`exec:${part.executableCode.language}:${part.executableCode.code}`).digest("hex");
|
|
367423
367558
|
id = `exec_${contentHash}_${turnSalt}_${partIdx}`;
|
|
367424
367559
|
} else if (isCodeExecutionResultPart(part)) {
|
|
367425
|
-
contentHash =
|
|
367560
|
+
contentHash = createHash12("sha256").update(`result:${part.codeExecutionResult.outcome}:${part.codeExecutionResult.output}`).digest("hex");
|
|
367426
367561
|
id = `result_${contentHash}_${turnSalt}_${partIdx}`;
|
|
367427
367562
|
}
|
|
367428
367563
|
if (contentHash) {
|
|
@@ -385694,7 +385829,7 @@ var init_memoryContextManager = __esm({
|
|
|
385694
385829
|
// packages/core/dist/src/services/trackerService.js
|
|
385695
385830
|
import fs74 from "node:fs/promises";
|
|
385696
385831
|
import path84 from "node:path";
|
|
385697
|
-
import { randomBytes as
|
|
385832
|
+
import { randomBytes as randomBytes5 } from "node:crypto";
|
|
385698
385833
|
var TrackerService;
|
|
385699
385834
|
var init_trackerService = __esm({
|
|
385700
385835
|
"packages/core/dist/src/services/trackerService.js"() {
|
|
@@ -385720,7 +385855,7 @@ var init_trackerService = __esm({
|
|
|
385720
385855
|
* Generates a 6-character hex ID.
|
|
385721
385856
|
*/
|
|
385722
385857
|
generateId() {
|
|
385723
|
-
return
|
|
385858
|
+
return randomBytes5(3).toString("hex");
|
|
385724
385859
|
}
|
|
385725
385860
|
/**
|
|
385726
385861
|
* Creates a new task and saves it to disk.
|
|
@@ -393309,7 +393444,7 @@ async function connectToMcpServer(clientVersion, mcpServerName, mcpServerConfig,
|
|
|
393309
393444
|
}
|
|
393310
393445
|
function createUrlTransport(mcpServerName, mcpServerConfig, transportOptions) {
|
|
393311
393446
|
const noProxy = process.env["NO_PROXY"] || process.env["no_proxy"];
|
|
393312
|
-
const agent = new
|
|
393447
|
+
const agent = new import_undici3.EnvHttpProxyAgent({ noProxy });
|
|
393313
393448
|
const baseFetch = transportOptions.fetch ?? globalThis.fetch;
|
|
393314
393449
|
const httpOptions = {
|
|
393315
393450
|
...transportOptions,
|
|
@@ -393447,7 +393582,7 @@ function isEnabled(funcDecl, mcpServerName, mcpServerConfig) {
|
|
|
393447
393582
|
}
|
|
393448
393583
|
return !includeTools || includeTools.some((tool) => tool === funcDecl.name || tool.startsWith(`${funcDecl.name}(`));
|
|
393449
393584
|
}
|
|
393450
|
-
var
|
|
393585
|
+
var import_undici3, import_shell_quote8, MCP_DEFAULT_TIMEOUT_MSEC, MCPServerStatus, MCPDiscoveryState, McpClient, serverStatuses, mcpDiscoveryState, mcpServerRequiresOAuth, statusChangeListeners, LenientJsonSchemaValidator, McpCallableTool2;
|
|
393451
393586
|
var init_mcp_client = __esm({
|
|
393452
393587
|
"packages/core/dist/src/tools/mcp-client.js"() {
|
|
393453
393588
|
"use strict";
|
|
@@ -393456,7 +393591,7 @@ var init_mcp_client = __esm({
|
|
|
393456
393591
|
init_sse();
|
|
393457
393592
|
init_stdio3();
|
|
393458
393593
|
init_streamableHttp();
|
|
393459
|
-
|
|
393594
|
+
import_undici3 = __toESM(require_undici(), 1);
|
|
393460
393595
|
init_types12();
|
|
393461
393596
|
import_shell_quote8 = __toESM(require_shell_quote(), 1);
|
|
393462
393597
|
init_config4();
|
|
@@ -393999,7 +394134,7 @@ var init_mcp_client = __esm({
|
|
|
393999
394134
|
});
|
|
394000
394135
|
|
|
394001
394136
|
// packages/core/dist/src/tools/mcp-client-manager.js
|
|
394002
|
-
import { createHash as
|
|
394137
|
+
import { createHash as createHash14 } from "node:crypto";
|
|
394003
394138
|
var McpClientManager;
|
|
394004
394139
|
var init_mcp_client_manager = __esm({
|
|
394005
394140
|
"packages/core/dist/src/tools/mcp-client-manager.js"() {
|
|
@@ -394216,7 +394351,7 @@ var init_mcp_client_manager = __esm({
|
|
|
394216
394351
|
config: rest,
|
|
394217
394352
|
extensionId: extension?.id
|
|
394218
394353
|
};
|
|
394219
|
-
return
|
|
394354
|
+
return createHash14("sha256").update(stableStringify(keyData)).digest("hex");
|
|
394220
394355
|
}
|
|
394221
394356
|
/**
|
|
394222
394357
|
* Merges two MCP configurations. The second configuration (override)
|
|
@@ -398945,7 +399080,7 @@ var init_dist_node = __esm({
|
|
|
398945
399080
|
});
|
|
398946
399081
|
|
|
398947
399082
|
// packages/core/dist/src/agents/a2a-client-manager.js
|
|
398948
|
-
var grpc2,
|
|
399083
|
+
var grpc2, import_undici4, A2A_TIMEOUT, A2AClientManager;
|
|
398949
399084
|
var init_a2a_client_manager = __esm({
|
|
398950
399085
|
"packages/core/dist/src/agents/a2a-client-manager.js"() {
|
|
398951
399086
|
"use strict";
|
|
@@ -398953,7 +399088,7 @@ var init_a2a_client_manager = __esm({
|
|
|
398953
399088
|
init_grpc();
|
|
398954
399089
|
grpc2 = __toESM(require_src15(), 1);
|
|
398955
399090
|
init_dist_node();
|
|
398956
|
-
|
|
399091
|
+
import_undici4 = __toESM(require_undici(), 1);
|
|
398957
399092
|
init_a2aUtils();
|
|
398958
399093
|
init_debugLogger();
|
|
398959
399094
|
init_a2a_errors();
|
|
@@ -398973,12 +399108,12 @@ var init_a2a_client_manager = __esm({
|
|
|
398973
399108
|
bodyTimeout: A2A_TIMEOUT
|
|
398974
399109
|
};
|
|
398975
399110
|
if (proxyUrl) {
|
|
398976
|
-
this.a2aDispatcher = new
|
|
399111
|
+
this.a2aDispatcher = new import_undici4.ProxyAgent({
|
|
398977
399112
|
uri: proxyUrl,
|
|
398978
399113
|
...agentOptions
|
|
398979
399114
|
});
|
|
398980
399115
|
} else {
|
|
398981
|
-
this.a2aDispatcher = new
|
|
399116
|
+
this.a2aDispatcher = new import_undici4.Agent(agentOptions);
|
|
398982
399117
|
}
|
|
398983
399118
|
this.a2aFetch = (input, init2) => fetch(input, { ...init2, dispatcher: this.a2aDispatcher });
|
|
398984
399119
|
}
|
|
@@ -399344,6 +399479,8 @@ var init_config4 = __esm({
|
|
|
399344
399479
|
contentGenerator;
|
|
399345
399480
|
/** Set by `/provider`; read when building the OpenAI content generator. */
|
|
399346
399481
|
activeOpenAiProviderId;
|
|
399482
|
+
/** Opt-in OpenCode request headers; read by the OpenAI content generator. */
|
|
399483
|
+
openAiOpencodeHeaders;
|
|
399347
399484
|
modelConfigService;
|
|
399348
399485
|
embeddingModel;
|
|
399349
399486
|
sandbox;
|
|
@@ -399836,6 +399973,7 @@ var init_config4 = __esm({
|
|
|
399836
399973
|
this.a2aClientManager = new A2AClientManager(this);
|
|
399837
399974
|
this.modelRouterService = new ModelRouterService(this);
|
|
399838
399975
|
this.setActiveOpenAiProvider(params.openAiProviderId);
|
|
399976
|
+
this.openAiOpencodeHeaders = params.openAiOpencodeHeaders === true;
|
|
399839
399977
|
}
|
|
399840
399978
|
isInitialized() {
|
|
399841
399979
|
return this.initialized;
|
|
@@ -400176,6 +400314,17 @@ var init_config4 = __esm({
|
|
|
400176
400314
|
getActiveOpenAiProviderId() {
|
|
400177
400315
|
return this.activeOpenAiProviderId;
|
|
400178
400316
|
}
|
|
400317
|
+
/**
|
|
400318
|
+
* Whether OpenAI-compatible requests should carry OpenCode's client headers.
|
|
400319
|
+
*
|
|
400320
|
+
* Set once at construction from `security.auth.openAiOpencodeHeaders`. The
|
|
400321
|
+
* request layer is built when the content generator is created and rebuilt on
|
|
400322
|
+
* `refreshAuth`, so toggling the setting takes effect on the next start —
|
|
400323
|
+
* which is what the setting's `requiresRestart` promises.
|
|
400324
|
+
*/
|
|
400325
|
+
getOpenAiOpencodeHeaders() {
|
|
400326
|
+
return this.openAiOpencodeHeaders;
|
|
400327
|
+
}
|
|
400179
400328
|
setActiveOpenAiProvider(providerId) {
|
|
400180
400329
|
this.activeOpenAiProviderId = providerId && providerId.trim().length > 0 ? providerId : void 0;
|
|
400181
400330
|
}
|
|
@@ -402908,7 +403057,7 @@ var init_integrityTypes = __esm({
|
|
|
402908
403057
|
// packages/core/dist/src/config/extensions/integrity.js
|
|
402909
403058
|
import * as fs84 from "node:fs";
|
|
402910
403059
|
import * as path96 from "node:path";
|
|
402911
|
-
import { createHash as
|
|
403060
|
+
import { createHash as createHash16, createHmac, randomBytes as randomBytes7, timingSafeEqual } from "node:crypto";
|
|
402912
403061
|
var import_json_stable_stringify, IntegrityKeyManager, ExtensionIntegrityStore, ExtensionIntegrityManager;
|
|
402913
403062
|
var init_integrity2 = __esm({
|
|
402914
403063
|
"packages/core/dist/src/config/extensions/integrity.js"() {
|
|
@@ -402952,7 +403101,7 @@ var init_integrity2 = __esm({
|
|
|
402952
403101
|
async getSecretKeyFromKeychain() {
|
|
402953
403102
|
let key = await this.keychainService.getPassword(SECRET_KEY_ACCOUNT);
|
|
402954
403103
|
if (!key) {
|
|
402955
|
-
key =
|
|
403104
|
+
key = randomBytes7(32).toString("hex");
|
|
402956
403105
|
await this.keychainService.setPassword(SECRET_KEY_ACCOUNT, key);
|
|
402957
403106
|
}
|
|
402958
403107
|
return key;
|
|
@@ -402965,7 +403114,7 @@ var init_integrity2 = __esm({
|
|
|
402965
403114
|
if (isNodeError(e3) && e3.code === "ENOENT") {
|
|
402966
403115
|
const configDir = path96.dirname(this.fallbackKeyPath);
|
|
402967
403116
|
await fs84.promises.mkdir(configDir, { recursive: true });
|
|
402968
|
-
const key =
|
|
403117
|
+
const key = randomBytes7(32).toString("hex");
|
|
402969
403118
|
await fs84.promises.writeFile(this.fallbackKeyPath, key, { mode: 384 });
|
|
402970
403119
|
return key;
|
|
402971
403120
|
}
|
|
@@ -403032,7 +403181,7 @@ var init_integrity2 = __esm({
|
|
|
403032
403181
|
*/
|
|
403033
403182
|
generateHash(metadata2) {
|
|
403034
403183
|
const content = (0, import_json_stable_stringify.default)(metadata2) ?? "";
|
|
403035
|
-
return
|
|
403184
|
+
return createHash16("sha256").update(content).digest("hex");
|
|
403036
403185
|
}
|
|
403037
403186
|
/**
|
|
403038
403187
|
* Generates an HMAC-SHA256 signature using the master secret key.
|
|
@@ -437205,6 +437354,19 @@ var init_settingsSchema = __esm({
|
|
|
437205
437354
|
description: "The OpenAI-compatible provider this session should use, as configured by `/provider`. Values are the provider ids from `~/.gemini/openai-providers.json`; an id that no longer exists falls back to the file's first entry.",
|
|
437206
437355
|
showInDialog: false
|
|
437207
437356
|
},
|
|
437357
|
+
// Fork-owned key: opt-in OpenCode-compatible request headers for
|
|
437358
|
+
// OpenAI-compatible endpoints that accept a credential but still gate
|
|
437359
|
+
// on client identity. Off by default; see
|
|
437360
|
+
// `core/openai/opencode/headers.ts` for what is sent and why.
|
|
437361
|
+
openAiOpencodeHeaders: {
|
|
437362
|
+
type: "boolean",
|
|
437363
|
+
label: "OpenCode Request Headers",
|
|
437364
|
+
category: "Security",
|
|
437365
|
+
requiresRestart: true,
|
|
437366
|
+
default: false,
|
|
437367
|
+
description: "Adapt OpenAI-compatible requests to look like they came from the OpenCode CLI: client-identity headers plus the tool names some free endpoints require. Only enable this when the endpoint rejects requests that do not look like they came from the OpenCode CLI; some providers issue a key that is only accepted with the disguise in place. Requires a restart.",
|
|
437368
|
+
showInDialog: true
|
|
437369
|
+
},
|
|
437208
437370
|
enforcedType: {
|
|
437209
437371
|
type: "string",
|
|
437210
437372
|
label: "Enforced Auth Type",
|
|
@@ -464549,7 +464711,7 @@ var init_retry2 = __esm({
|
|
|
464549
464711
|
import * as fs113 from "node:fs";
|
|
464550
464712
|
import * as path132 from "node:path";
|
|
464551
464713
|
import { stat as stat17 } from "node:fs/promises";
|
|
464552
|
-
import { createHash as
|
|
464714
|
+
import { createHash as createHash18, randomUUID as randomUUID25 } from "node:crypto";
|
|
464553
464715
|
function filterMcpConfig(original) {
|
|
464554
464716
|
const { trust, ...rest } = original;
|
|
464555
464717
|
return Object.freeze(rest);
|
|
@@ -464685,7 +464847,7 @@ function getExtensionId(config2, installMetadata) {
|
|
|
464685
464847
|
return hashValue(idValue);
|
|
464686
464848
|
}
|
|
464687
464849
|
function hashValue(value) {
|
|
464688
|
-
return
|
|
464850
|
+
return createHash18("sha256").update(value).digest("hex");
|
|
464689
464851
|
}
|
|
464690
464852
|
var import_chalk2, ExtensionManager;
|
|
464691
464853
|
var init_extension_manager = __esm({
|
|
@@ -470261,7 +470423,7 @@ var init_start2 = __esm({
|
|
|
470261
470423
|
});
|
|
470262
470424
|
|
|
470263
470425
|
// packages/cli/src/commands/gemma/setup.ts
|
|
470264
|
-
import { createHash as
|
|
470426
|
+
import { createHash as createHash19 } from "node:crypto";
|
|
470265
470427
|
import fs120 from "node:fs";
|
|
470266
470428
|
import path141 from "node:path";
|
|
470267
470429
|
import { execFileSync as execFileSync3, spawn as nodeSpawn } from "node:child_process";
|
|
@@ -470340,7 +470502,7 @@ async function downloadFile3(url4, destPath) {
|
|
|
470340
470502
|
fs120.renameSync(tmpPath, destPath);
|
|
470341
470503
|
}
|
|
470342
470504
|
async function computeFileSha256(filePath) {
|
|
470343
|
-
const hash =
|
|
470505
|
+
const hash = createHash19("sha256");
|
|
470344
470506
|
const fileStream = fs120.createReadStream(filePath);
|
|
470345
470507
|
return new Promise((resolve48, reject) => {
|
|
470346
470508
|
fileStream.on("data", (chunk) => {
|
|
@@ -472078,6 +472240,10 @@ async function loadCliConfig(settings, sessionId, argv, options = {}) {
|
|
|
472078
472240
|
// `/provider` switches. An id that no longer exists degrades to the first
|
|
472079
472241
|
// entry with a warning (see core/openai/integration.ts).
|
|
472080
472242
|
openAiProviderId: settings.security?.auth?.openAiProviderId,
|
|
472243
|
+
// Fork-owned: opt-in OpenCode-compatible request headers for
|
|
472244
|
+
// OpenAI-compatible endpoints that gate on client identity. Off by default;
|
|
472245
|
+
// see core/openai/opencode/headers.ts.
|
|
472246
|
+
openAiOpencodeHeaders: settings.security?.auth?.openAiOpencodeHeaders,
|
|
472081
472247
|
targetDir: cwd7,
|
|
472082
472248
|
includeDirectoryTree,
|
|
472083
472249
|
includeDirectories,
|
|
@@ -473656,7 +473822,7 @@ import fs124 from "node:fs";
|
|
|
473656
473822
|
import os41 from "node:os";
|
|
473657
473823
|
import { fileURLToPath as fileURLToPath21 } from "node:url";
|
|
473658
473824
|
import { promisify as promisify12 } from "node:util";
|
|
473659
|
-
import { randomBytes as
|
|
473825
|
+
import { randomBytes as randomBytes8 } from "node:crypto";
|
|
473660
473826
|
function isRecord8(value) {
|
|
473661
473827
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
473662
473828
|
}
|
|
@@ -473734,7 +473900,7 @@ async function start_sandbox(config2, nodeArgs = [], cliConfig, cliArgs = []) {
|
|
|
473734
473900
|
if (content) {
|
|
473735
473901
|
try {
|
|
473736
473902
|
const tempDir = fs124.realpathSync(os41.tmpdir());
|
|
473737
|
-
const rand =
|
|
473903
|
+
const rand = randomBytes8(8).toString("hex");
|
|
473738
473904
|
tempProfileFile = path146.join(
|
|
473739
473905
|
tempDir,
|
|
473740
473906
|
`gemini-sandbox-macos-${profile}-${rand}.sb`
|
|
@@ -474152,7 +474318,7 @@ async function start_sandbox(config2, nodeArgs = [], cliConfig, cliArgs = []) {
|
|
|
474152
474318
|
const imageName = parseImageName(image3);
|
|
474153
474319
|
const isIntegrationTest = process.env["GEMINI_CLI_INTEGRATION_TEST"] === "true";
|
|
474154
474320
|
const containerNamePrefix = isIntegrationTest ? "gemini-cli-integration-test" : imageName;
|
|
474155
|
-
const containerName = `${containerNamePrefix}-${
|
|
474321
|
+
const containerName = `${containerNamePrefix}-${randomBytes8(6).toString(
|
|
474156
474322
|
"hex"
|
|
474157
474323
|
)}`;
|
|
474158
474324
|
debugLogger.log(`ContainerName: ${containerName}`);
|
|
@@ -474451,7 +474617,7 @@ async function start_lxc_sandbox(config2, nodeArgs = [], cliArgs = []) {
|
|
|
474451
474617
|
}
|
|
474452
474618
|
};
|
|
474453
474619
|
try {
|
|
474454
|
-
const workspaceDeviceName = `gemini-workspace-${
|
|
474620
|
+
const workspaceDeviceName = `gemini-workspace-${randomBytes8(4).toString(
|
|
474455
474621
|
"hex"
|
|
474456
474622
|
)}`;
|
|
474457
474623
|
devicesToRemove.push(workspaceDeviceName);
|
|
@@ -474483,7 +474649,7 @@ async function start_lxc_sandbox(config2, nodeArgs = [], cliArgs = []) {
|
|
|
474483
474649
|
);
|
|
474484
474650
|
continue;
|
|
474485
474651
|
}
|
|
474486
|
-
const allowedDeviceName = `gemini-allowed-${
|
|
474652
|
+
const allowedDeviceName = `gemini-allowed-${randomBytes8(4).toString(
|
|
474487
474653
|
"hex"
|
|
474488
474654
|
)}`;
|
|
474489
474655
|
devicesToRemove.push(allowedDeviceName);
|
|
@@ -478901,7 +479067,7 @@ var GIT_COMMIT_INFO2;
|
|
|
478901
479067
|
var init_git_commit2 = __esm({
|
|
478902
479068
|
"packages/cli/src/generated/git-commit.ts"() {
|
|
478903
479069
|
"use strict";
|
|
478904
|
-
GIT_COMMIT_INFO2 = "
|
|
479070
|
+
GIT_COMMIT_INFO2 = "aa945fc";
|
|
478905
479071
|
}
|
|
478906
479072
|
});
|
|
478907
479073
|
|
|
@@ -574260,12 +574426,12 @@ function getGitHubRepoInfo() {
|
|
|
574260
574426
|
}
|
|
574261
574427
|
return { owner: parts2[0], repo: parts2[1].replace(/\.git$/, "") };
|
|
574262
574428
|
}
|
|
574263
|
-
var
|
|
574429
|
+
var import_undici5, isGitHubRepository, getGitRepoRoot, getLatestGitHubRelease;
|
|
574264
574430
|
var init_gitUtils2 = __esm({
|
|
574265
574431
|
"packages/cli/src/utils/gitUtils.ts"() {
|
|
574266
574432
|
"use strict";
|
|
574267
574433
|
init_dist4();
|
|
574268
|
-
|
|
574434
|
+
import_undici5 = __toESM(require_undici2(), 1);
|
|
574269
574435
|
isGitHubRepository = () => {
|
|
574270
574436
|
try {
|
|
574271
574437
|
const remotes = (execSync7("git remote -v", {
|
|
@@ -574298,7 +574464,7 @@ var init_gitUtils2 = __esm({
|
|
|
574298
574464
|
"Content-Type": "application/json",
|
|
574299
574465
|
"X-GitHub-Api-Version": "2022-11-28"
|
|
574300
574466
|
},
|
|
574301
|
-
dispatcher: proxy2 ? new
|
|
574467
|
+
dispatcher: proxy2 ? new import_undici5.ProxyAgent(proxy2) : void 0,
|
|
574302
574468
|
/* eslint-disable @typescript-eslint/no-unsafe-type-assertion */
|
|
574303
574469
|
signal: AbortSignal.any([AbortSignal.timeout(3e4), controller.signal])
|
|
574304
574470
|
/* eslint-enable @typescript-eslint/no-unsafe-type-assertion */
|
|
@@ -574383,7 +574549,7 @@ async function downloadFiles({
|
|
|
574383
574549
|
const endpoint = `${REPO_DOWNLOAD_URL}/refs/tags/${releaseTag}/${SOURCE_DIR}/${fileBasename}`;
|
|
574384
574550
|
const response = await fetch(endpoint, {
|
|
574385
574551
|
method: "GET",
|
|
574386
|
-
dispatcher: proxy2 ? new
|
|
574552
|
+
dispatcher: proxy2 ? new import_undici6.ProxyAgent(proxy2) : void 0,
|
|
574387
574553
|
/* eslint-disable @typescript-eslint/no-unsafe-type-assertion */
|
|
574388
574554
|
signal: AbortSignal.any([AbortSignal.timeout(3e4), abortController.signal])
|
|
574389
574555
|
/* eslint-enable @typescript-eslint/no-unsafe-type-assertion */
|
|
@@ -574451,11 +574617,11 @@ async function downloadSetupFiles({
|
|
|
574451
574617
|
throw error40;
|
|
574452
574618
|
}
|
|
574453
574619
|
}
|
|
574454
|
-
var
|
|
574620
|
+
var import_undici6, GITHUB_WORKFLOW_PATHS, GITHUB_COMMANDS_PATHS, REPO_DOWNLOAD_URL, SOURCE_DIR, setupGithubCommand;
|
|
574455
574621
|
var init_setupGithubCommand = __esm({
|
|
574456
574622
|
"packages/cli/src/ui/commands/setupGithubCommand.ts"() {
|
|
574457
574623
|
"use strict";
|
|
574458
|
-
|
|
574624
|
+
import_undici6 = __toESM(require_undici2(), 1);
|
|
574459
574625
|
init_gitUtils2();
|
|
574460
574626
|
init_types22();
|
|
574461
574627
|
init_commandUtils2();
|
|
@@ -578180,7 +578346,7 @@ var require_websocket4 = __commonJS({
|
|
|
578180
578346
|
var http9 = __require("http");
|
|
578181
578347
|
var net3 = __require("net");
|
|
578182
578348
|
var tls = __require("tls");
|
|
578183
|
-
var { randomBytes:
|
|
578349
|
+
var { randomBytes: randomBytes9, createHash: createHash21 } = __require("crypto");
|
|
578184
578350
|
var { Duplex: Duplex4, Readable: Readable9 } = __require("stream");
|
|
578185
578351
|
var { URL: URL8 } = __require("url");
|
|
578186
578352
|
var PerMessageDeflate = require_permessage_deflate4();
|
|
@@ -578707,7 +578873,7 @@ var require_websocket4 = __commonJS({
|
|
|
578707
578873
|
}
|
|
578708
578874
|
}
|
|
578709
578875
|
const defaultPort = isSecure ? 443 : 80;
|
|
578710
|
-
const key =
|
|
578876
|
+
const key = randomBytes9(16).toString("base64");
|
|
578711
578877
|
const request = isSecure ? https6.request : http9.request;
|
|
578712
578878
|
const protocolSet = /* @__PURE__ */ new Set();
|
|
578713
578879
|
let perMessageDeflate;
|
|
@@ -578836,7 +579002,7 @@ var require_websocket4 = __commonJS({
|
|
|
578836
579002
|
abortHandshake(websocket, socket, "Invalid Upgrade header");
|
|
578837
579003
|
return;
|
|
578838
579004
|
}
|
|
578839
|
-
const digest =
|
|
579005
|
+
const digest = createHash21("sha1").update(key + GUID).digest("base64");
|
|
578840
579006
|
if (res.headers["sec-websocket-accept"] !== digest) {
|
|
578841
579007
|
abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
|
|
578842
579008
|
return;
|
|
@@ -579082,7 +579248,7 @@ var require_websocket_server2 = __commonJS({
|
|
|
579082
579248
|
var EventEmitter21 = __require("events");
|
|
579083
579249
|
var http9 = __require("http");
|
|
579084
579250
|
var { Duplex: Duplex4 } = __require("stream");
|
|
579085
|
-
var { createHash:
|
|
579251
|
+
var { createHash: createHash21 } = __require("crypto");
|
|
579086
579252
|
var extension = require_extension2();
|
|
579087
579253
|
var PerMessageDeflate = require_permessage_deflate4();
|
|
579088
579254
|
var subprotocol = require_subprotocol2();
|
|
@@ -579376,7 +579542,7 @@ var require_websocket_server2 = __commonJS({
|
|
|
579376
579542
|
);
|
|
579377
579543
|
}
|
|
579378
579544
|
if (this._state > RUNNING) return abortHandshake(socket, 503);
|
|
579379
|
-
const digest =
|
|
579545
|
+
const digest = createHash21("sha1").update(key + GUID).digest("base64");
|
|
579380
579546
|
const headers = [
|
|
579381
579547
|
"HTTP/1.1 101 Switching Protocols",
|
|
579382
579548
|
"Upgrade: websocket",
|
|
@@ -582380,7 +582546,7 @@ var require_websocket5 = __commonJS({
|
|
|
582380
582546
|
var http9 = __require("http");
|
|
582381
582547
|
var net3 = __require("net");
|
|
582382
582548
|
var tls = __require("tls");
|
|
582383
|
-
var { randomBytes:
|
|
582549
|
+
var { randomBytes: randomBytes9, createHash: createHash21 } = __require("crypto");
|
|
582384
582550
|
var { Duplex: Duplex4, Readable: Readable9 } = __require("stream");
|
|
582385
582551
|
var { URL: URL8 } = __require("url");
|
|
582386
582552
|
var PerMessageDeflate = require_permessage_deflate5();
|
|
@@ -582907,7 +583073,7 @@ var require_websocket5 = __commonJS({
|
|
|
582907
583073
|
}
|
|
582908
583074
|
}
|
|
582909
583075
|
const defaultPort = isSecure ? 443 : 80;
|
|
582910
|
-
const key =
|
|
583076
|
+
const key = randomBytes9(16).toString("base64");
|
|
582911
583077
|
const request = isSecure ? https6.request : http9.request;
|
|
582912
583078
|
const protocolSet = /* @__PURE__ */ new Set();
|
|
582913
583079
|
let perMessageDeflate;
|
|
@@ -583036,7 +583202,7 @@ var require_websocket5 = __commonJS({
|
|
|
583036
583202
|
abortHandshake(websocket, socket, "Invalid Upgrade header");
|
|
583037
583203
|
return;
|
|
583038
583204
|
}
|
|
583039
|
-
const digest =
|
|
583205
|
+
const digest = createHash21("sha1").update(key + GUID).digest("base64");
|
|
583040
583206
|
if (res.headers["sec-websocket-accept"] !== digest) {
|
|
583041
583207
|
abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
|
|
583042
583208
|
return;
|
|
@@ -583282,7 +583448,7 @@ var require_websocket_server3 = __commonJS({
|
|
|
583282
583448
|
var EventEmitter21 = __require("events");
|
|
583283
583449
|
var http9 = __require("http");
|
|
583284
583450
|
var { Duplex: Duplex4 } = __require("stream");
|
|
583285
|
-
var { createHash:
|
|
583451
|
+
var { createHash: createHash21 } = __require("crypto");
|
|
583286
583452
|
var extension = require_extension3();
|
|
583287
583453
|
var PerMessageDeflate = require_permessage_deflate5();
|
|
583288
583454
|
var subprotocol = require_subprotocol3();
|
|
@@ -583576,7 +583742,7 @@ var require_websocket_server3 = __commonJS({
|
|
|
583576
583742
|
);
|
|
583577
583743
|
}
|
|
583578
583744
|
if (this._state > RUNNING) return abortHandshake(socket, 503);
|
|
583579
|
-
const digest =
|
|
583745
|
+
const digest = createHash21("sha1").update(key + GUID).digest("base64");
|
|
583580
583746
|
const headers = [
|
|
583581
583747
|
"HTTP/1.1 101 Switching Protocols",
|
|
583582
583748
|
"Upgrade: websocket",
|
|
@@ -620707,7 +620873,7 @@ var init_constants9 = __esm({
|
|
|
620707
620873
|
|
|
620708
620874
|
// node_modules/ky/distribution/utils/body.js
|
|
620709
620875
|
var getBodySize, withProgress, streamResponse, streamRequest;
|
|
620710
|
-
var
|
|
620876
|
+
var init_body4 = __esm({
|
|
620711
620877
|
"node_modules/ky/distribution/utils/body.js"() {
|
|
620712
620878
|
init_constants9();
|
|
620713
620879
|
getBodySize = (body2) => {
|
|
@@ -621107,7 +621273,7 @@ var init_Ky = __esm({
|
|
|
621107
621273
|
"node_modules/ky/distribution/core/Ky.js"() {
|
|
621108
621274
|
init_HTTPError();
|
|
621109
621275
|
init_NonError();
|
|
621110
|
-
|
|
621276
|
+
init_body4();
|
|
621111
621277
|
init_merge2();
|
|
621112
621278
|
init_normalize2();
|
|
621113
621279
|
init_timeout2();
|
|
@@ -628428,7 +628594,7 @@ __export(gemini_exports, {
|
|
|
628428
628594
|
startInteractiveUI: () => startInteractiveUI2,
|
|
628429
628595
|
validateDnsResolutionOrder: () => validateDnsResolutionOrder
|
|
628430
628596
|
});
|
|
628431
|
-
import { createHash as
|
|
628597
|
+
import { createHash as createHash20 } from "node:crypto";
|
|
628432
628598
|
import v83 from "node:v8";
|
|
628433
628599
|
import os51 from "node:os";
|
|
628434
628600
|
import dns from "node:dns";
|
|
@@ -628969,7 +629135,7 @@ ${finalArgs[promptIndex + 1]}`;
|
|
|
628969
629135
|
const rawStartupWarnings = await rawStartupWarningsPromise;
|
|
628970
629136
|
const startupWarnings = [
|
|
628971
629137
|
...rawStartupWarnings.map((message) => ({
|
|
628972
|
-
id: `startup-${
|
|
629138
|
+
id: `startup-${createHash20("sha256").update(message).digest("hex").substring(0, 16)}`,
|
|
628973
629139
|
message,
|
|
628974
629140
|
priority: WarningPriority.High
|
|
628975
629141
|
})),
|