ds-harness-remote 0.4.5 → 0.4.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/README.md +4 -4
- package/dist/harness-api-bridge.d.ts +2 -0
- package/dist/harness-api-bridge.d.ts.map +1 -1
- package/dist/harness-api-bridge.js +34 -6
- package/dist/harness-api-bridge.js.map +1 -1
- package/dist/harness-remote-bridge.d.ts +1 -0
- package/dist/harness-remote-bridge.d.ts.map +1 -1
- package/dist/harness-remote-bridge.js +48 -1
- package/dist/harness-remote-bridge.js.map +1 -1
- package/dist/index.js +121 -53
- package/dist/index.js.map +3 -3
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dsh-plugin.json +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -16825,7 +16825,7 @@ function normalizeServerUrl(value) {
|
|
|
16825
16825
|
}
|
|
16826
16826
|
|
|
16827
16827
|
// src/version.ts
|
|
16828
|
-
var PLUGIN_VERSION = "0.4.
|
|
16828
|
+
var PLUGIN_VERSION = "0.4.6";
|
|
16829
16829
|
|
|
16830
16830
|
// src/server-api.ts
|
|
16831
16831
|
var TERMINAL_CONTROL_CHARACTERS = /[\u0000-\u001f\u007f-\u009f]/u;
|
|
@@ -19431,24 +19431,24 @@ var IdentityStore = class {
|
|
|
19431
19431
|
}
|
|
19432
19432
|
if (!hasDevice) {
|
|
19433
19433
|
const keys = generateKeyPair();
|
|
19434
|
-
const
|
|
19435
|
-
await atomicJsonWrite(devicePath,
|
|
19434
|
+
const record5 = { schemaVersion: 1, deviceId: uuidV7(), name: deviceName, publicKey: keys.publicKey };
|
|
19435
|
+
await atomicJsonWrite(devicePath, record5, 384);
|
|
19436
19436
|
await atomicTextWrite(keyPath, `${keys.privateKey}
|
|
19437
19437
|
`, 384);
|
|
19438
19438
|
}
|
|
19439
19439
|
await assertPrivateMode(keyPath);
|
|
19440
19440
|
try {
|
|
19441
|
-
let
|
|
19441
|
+
let record5 = identitySchema.parse(JSON.parse(await readFile(devicePath, "utf8")));
|
|
19442
19442
|
const privateKey = (await readFile(keyPath, "utf8")).trim();
|
|
19443
19443
|
const regenerated = generateKeyPair(fromBase64Url2(privateKey));
|
|
19444
|
-
if (regenerated.publicKey !==
|
|
19444
|
+
if (regenerated.publicKey !== record5.publicKey) {
|
|
19445
19445
|
throw new IdentityInvalidError("device public and private keys do not match");
|
|
19446
19446
|
}
|
|
19447
|
-
if (
|
|
19448
|
-
|
|
19449
|
-
await atomicJsonWrite(devicePath,
|
|
19447
|
+
if (record5.name !== deviceName) {
|
|
19448
|
+
record5 = { ...record5, name: deviceName };
|
|
19449
|
+
await atomicJsonWrite(devicePath, record5, 384);
|
|
19450
19450
|
}
|
|
19451
|
-
this.identity = { ...
|
|
19451
|
+
this.identity = { ...record5, privateKey, fingerprint: fingerprint(record5.publicKey) };
|
|
19452
19452
|
await this.loadPeers();
|
|
19453
19453
|
return this.identity;
|
|
19454
19454
|
} catch (error) {
|
|
@@ -19590,10 +19590,10 @@ var ServerCredentialStore = class {
|
|
|
19590
19590
|
return parsed.serverUrl === serverUrl && parsed.deviceId === deviceId ? parsed : void 0;
|
|
19591
19591
|
}
|
|
19592
19592
|
async save(credentials) {
|
|
19593
|
-
const
|
|
19594
|
-
await atomicWrite(this.path, `${JSON.stringify(
|
|
19593
|
+
const record5 = credentialSchema.parse({ schemaVersion: 1, ...credentials });
|
|
19594
|
+
await atomicWrite(this.path, `${JSON.stringify(record5, null, 2)}
|
|
19595
19595
|
`);
|
|
19596
|
-
return
|
|
19596
|
+
return record5;
|
|
19597
19597
|
}
|
|
19598
19598
|
async clear() {
|
|
19599
19599
|
await rm2(this.path, { force: true });
|
|
@@ -21395,6 +21395,9 @@ var commandExecuteSchema = external_exports.object({
|
|
|
21395
21395
|
var commandListSchema = external_exports.object({
|
|
21396
21396
|
agentId: external_exports.string().min(1).max(128)
|
|
21397
21397
|
}).strict();
|
|
21398
|
+
var directoryListSchema = external_exports.object({
|
|
21399
|
+
path: external_exports.string().min(1).max(4096).optional()
|
|
21400
|
+
}).strict();
|
|
21398
21401
|
var credentialRefSchema = external_exports.string().regex(/^[A-Za-z_][A-Za-z0-9_]*$/, "Invalid credential reference name").max(128);
|
|
21399
21402
|
var CONFIG_PLANE_SETTINGS_BYTES = 64 * 1024;
|
|
21400
21403
|
var CONFIG_PLANE_MAX_OPS = 64;
|
|
@@ -21524,10 +21527,18 @@ var HarnessApiBridge = class {
|
|
|
21524
21527
|
answer;
|
|
21525
21528
|
async call(input2) {
|
|
21526
21529
|
const params = callSchema2.parse(input2);
|
|
21530
|
+
const signal = AbortSignal.timeout(NATIVE_CALL_TIMEOUT_MS);
|
|
21527
21531
|
const method = this.methods.get(params.method);
|
|
21528
|
-
if (method === void 0)
|
|
21532
|
+
if (method === void 0) {
|
|
21533
|
+
if (params.method === "host.listDirectory") {
|
|
21534
|
+
return this.callDirectoryFallback(params, signal);
|
|
21535
|
+
}
|
|
21536
|
+
if (params.method === "host.describe") {
|
|
21537
|
+
return this.describeFallback(params.rpcId);
|
|
21538
|
+
}
|
|
21539
|
+
throw deniedMethod(params.method);
|
|
21540
|
+
}
|
|
21529
21541
|
const startedAt = performance.now();
|
|
21530
|
-
const signal = AbortSignal.timeout(NATIVE_CALL_TIMEOUT_MS);
|
|
21531
21542
|
const request = { rpcId: params.rpcId, payload: params.payload };
|
|
21532
21543
|
try {
|
|
21533
21544
|
const callWithTimeout = (overridePayload) => withTimeout(
|
|
@@ -21542,12 +21553,10 @@ var HarnessApiBridge = class {
|
|
|
21542
21553
|
response = await callWithTimeout(request.payload);
|
|
21543
21554
|
}
|
|
21544
21555
|
if (params.method === "host.listDirectory" && needsRemoteDirectoryFallback(response)) {
|
|
21545
|
-
|
|
21546
|
-
const value = await listRemoteDirectory(typeof payload.path === "string" ? payload.path : void 0, signal);
|
|
21547
|
-
response = { rpcId: params.rpcId, result: { ok: true, value } };
|
|
21556
|
+
response = await this.callDirectoryFallback(params, signal);
|
|
21548
21557
|
}
|
|
21549
21558
|
if (params.method === "host.describe") {
|
|
21550
|
-
response = normalizeHostDescribe(response, this.harnessVersion,
|
|
21559
|
+
response = normalizeHostDescribe(response, this.harnessVersion, true);
|
|
21551
21560
|
}
|
|
21552
21561
|
this.logger?.debug("harness api call ok", {
|
|
21553
21562
|
method: params.method,
|
|
@@ -21565,6 +21574,26 @@ var HarnessApiBridge = class {
|
|
|
21565
21574
|
throw error;
|
|
21566
21575
|
}
|
|
21567
21576
|
}
|
|
21577
|
+
async callDirectoryFallback(params, signal) {
|
|
21578
|
+
const payload = directoryListSchema.parse(params.payload);
|
|
21579
|
+
const value = await listRemoteDirectory(payload.path, signal);
|
|
21580
|
+
return { rpcId: params.rpcId, result: { ok: true, value } };
|
|
21581
|
+
}
|
|
21582
|
+
describeFallback(rpcId) {
|
|
21583
|
+
return {
|
|
21584
|
+
rpcId,
|
|
21585
|
+
result: {
|
|
21586
|
+
ok: true,
|
|
21587
|
+
value: {
|
|
21588
|
+
version: this.harnessVersion ?? "0.0.1",
|
|
21589
|
+
cwd: "",
|
|
21590
|
+
home: "",
|
|
21591
|
+
attachedSessions: 0,
|
|
21592
|
+
canOpenPath: true
|
|
21593
|
+
}
|
|
21594
|
+
}
|
|
21595
|
+
};
|
|
21596
|
+
}
|
|
21568
21597
|
openTransfer(input2) {
|
|
21569
21598
|
this.pruneTransfers();
|
|
21570
21599
|
const params = transferOpenSchema.parse(input2);
|
|
@@ -22131,6 +22160,9 @@ var transferReadSchema2 = external_exports.object({
|
|
|
22131
22160
|
transferId: external_exports.string().uuid(),
|
|
22132
22161
|
index: external_exports.number().int().nonnegative()
|
|
22133
22162
|
}).strict();
|
|
22163
|
+
var directoryListSchema2 = external_exports.object({
|
|
22164
|
+
path: external_exports.string().min(1).max(4096).optional()
|
|
22165
|
+
}).strict();
|
|
22134
22166
|
var MAX_ACTIVE_STREAMS = 16;
|
|
22135
22167
|
var MAX_ACTIVE_TRANSFERS = 2;
|
|
22136
22168
|
var TRANSFER_IDLE_MS = 2 * 6e4;
|
|
@@ -22206,15 +22238,29 @@ var HarnessRemoteBridge = class {
|
|
|
22206
22238
|
async call(input2) {
|
|
22207
22239
|
const params = callSchema3.parse(input2);
|
|
22208
22240
|
this.assertAllowed(params.endpoint);
|
|
22241
|
+
if (params.endpoint === "session/canOpenWorkspacePath") {
|
|
22242
|
+
return { ok: true, value: true };
|
|
22243
|
+
}
|
|
22209
22244
|
const startedAt = performance.now();
|
|
22245
|
+
const signal = AbortSignal.timeout(6e4);
|
|
22210
22246
|
try {
|
|
22211
|
-
const
|
|
22247
|
+
const nativeResult = await this.gateway.dispatch(params.endpoint, params.payload, signal);
|
|
22248
|
+
const result = params.endpoint === "directoryPicker/list" && needsDirectoryFallback(nativeResult) ? await this.directoryList(params.payload, signal) : nativeResult;
|
|
22212
22249
|
this.logger?.debug("harness remote call ok", {
|
|
22213
22250
|
endpoint: params.endpoint,
|
|
22214
22251
|
durationMs: Math.round(performance.now() - startedAt)
|
|
22215
22252
|
});
|
|
22216
22253
|
return result;
|
|
22217
22254
|
} catch (error) {
|
|
22255
|
+
if (params.endpoint === "directoryPicker/list") {
|
|
22256
|
+
const result = await this.directoryList(params.payload, signal);
|
|
22257
|
+
this.logger?.debug("harness remote call ok", {
|
|
22258
|
+
endpoint: params.endpoint,
|
|
22259
|
+
durationMs: Math.round(performance.now() - startedAt),
|
|
22260
|
+
fallback: "directory-browser"
|
|
22261
|
+
});
|
|
22262
|
+
return result;
|
|
22263
|
+
}
|
|
22218
22264
|
this.logger?.warn("harness remote call failed", {
|
|
22219
22265
|
endpoint: params.endpoint,
|
|
22220
22266
|
durationMs: Math.round(performance.now() - startedAt),
|
|
@@ -22223,6 +22269,11 @@ var HarnessRemoteBridge = class {
|
|
|
22223
22269
|
throw error;
|
|
22224
22270
|
}
|
|
22225
22271
|
}
|
|
22272
|
+
async directoryList(payload, signal) {
|
|
22273
|
+
const args = requestArgs(payload);
|
|
22274
|
+
const params = directoryListSchema2.parse(args);
|
|
22275
|
+
return { ok: true, value: await listRemoteDirectory(params.path, signal) };
|
|
22276
|
+
}
|
|
22226
22277
|
openTransfer(input2) {
|
|
22227
22278
|
this.pruneTransfers();
|
|
22228
22279
|
const params = transferOpenSchema2.parse(input2);
|
|
@@ -22406,6 +22457,23 @@ function concatChunks2(chunks, totalBytes) {
|
|
|
22406
22457
|
}
|
|
22407
22458
|
return result;
|
|
22408
22459
|
}
|
|
22460
|
+
function needsDirectoryFallback(result) {
|
|
22461
|
+
if (result.ok) return false;
|
|
22462
|
+
const code = result.error.code.toLocaleLowerCase();
|
|
22463
|
+
const message = result.error.message.toLocaleLowerCase();
|
|
22464
|
+
return code.includes("capability") || code === "directory-picker-unavailable" || message.includes("browser capability") || message.includes("brower capability") || message.includes("directory-picker-unavailable");
|
|
22465
|
+
}
|
|
22466
|
+
function requestArgs(payload) {
|
|
22467
|
+
const root = record4(payload);
|
|
22468
|
+
const args = isRecord7(root.args) ? root.args : root;
|
|
22469
|
+
return record4(args.request ?? args._request ?? args);
|
|
22470
|
+
}
|
|
22471
|
+
function record4(value) {
|
|
22472
|
+
return isRecord7(value) ? value : {};
|
|
22473
|
+
}
|
|
22474
|
+
function isRecord7(value) {
|
|
22475
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22476
|
+
}
|
|
22409
22477
|
|
|
22410
22478
|
// src/codex/domain.ts
|
|
22411
22479
|
import { randomUUID } from "node:crypto";
|
|
@@ -22597,7 +22665,7 @@ var CodexAppServerClient = class {
|
|
|
22597
22665
|
this.handleProcessFailure("CODEX_INVALID_RESPONSE", new Error("Codex App Server emitted invalid JSON."));
|
|
22598
22666
|
return;
|
|
22599
22667
|
}
|
|
22600
|
-
if (!
|
|
22668
|
+
if (!isRecord8(value)) {
|
|
22601
22669
|
this.handleProcessFailure("CODEX_INVALID_RESPONSE", new Error("Codex App Server emitted an invalid message."));
|
|
22602
22670
|
return;
|
|
22603
22671
|
}
|
|
@@ -22642,12 +22710,12 @@ var CodexAppServerClient = class {
|
|
|
22642
22710
|
}
|
|
22643
22711
|
};
|
|
22644
22712
|
function safeUpstreamError(value) {
|
|
22645
|
-
if (!
|
|
22713
|
+
if (!isRecord8(value) || typeof value.message !== "string") return "Codex App Server rejected the request.";
|
|
22646
22714
|
const message = value.message.toLowerCase();
|
|
22647
22715
|
if (message.includes("active writer")) return "Codex thread already has an active writer.";
|
|
22648
22716
|
return message.includes("not initialized") ? "Codex App Server is not initialized." : "Codex App Server rejected the request.";
|
|
22649
22717
|
}
|
|
22650
|
-
function
|
|
22718
|
+
function isRecord8(value) {
|
|
22651
22719
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
22652
22720
|
}
|
|
22653
22721
|
|
|
@@ -23009,15 +23077,15 @@ function decodeCanonicalBase643(value) {
|
|
|
23009
23077
|
}
|
|
23010
23078
|
return decoded;
|
|
23011
23079
|
}
|
|
23012
|
-
function
|
|
23080
|
+
function isRecord9(value) {
|
|
23013
23081
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
23014
23082
|
}
|
|
23015
23083
|
function safeErrorCode2(error) {
|
|
23016
|
-
if (
|
|
23084
|
+
if (isRecord9(error) && typeof error.code === "string") return error.code;
|
|
23017
23085
|
return "UNKNOWN";
|
|
23018
23086
|
}
|
|
23019
23087
|
function safeMethod(input2) {
|
|
23020
|
-
return
|
|
23088
|
+
return isRecord9(input2) && typeof input2.method === "string" ? input2.method : "invalid";
|
|
23021
23089
|
}
|
|
23022
23090
|
function concatChunks3(chunks, totalBytes) {
|
|
23023
23091
|
const output = new Uint8Array(totalBytes);
|
|
@@ -23463,9 +23531,9 @@ var CodexRemoteDomain = class {
|
|
|
23463
23531
|
itemsView,
|
|
23464
23532
|
...cursor2 === void 0 ? {} : { cursor: cursor2 }
|
|
23465
23533
|
});
|
|
23466
|
-
const pageResult =
|
|
23534
|
+
const pageResult = isRecord10(result) ? result : {};
|
|
23467
23535
|
for (const rawTurn of array2(pageResult.data)) {
|
|
23468
|
-
if (!
|
|
23536
|
+
if (!isRecord10(rawTurn)) continue;
|
|
23469
23537
|
const turnId = typeof rawTurn.id === "string" ? rawTurn.id : void 0;
|
|
23470
23538
|
const items = rawTurn.itemsView === "full" || turnId === void 0 ? array2(rawTurn.items) : await this.readThreadItems(connectionId, threadId, turnId, array2(rawTurn.items));
|
|
23471
23539
|
turns.push({ ...rawTurn, items });
|
|
@@ -23487,9 +23555,9 @@ var CodexRemoteDomain = class {
|
|
|
23487
23555
|
sortDirection: "asc",
|
|
23488
23556
|
...cursor2 === void 0 ? {} : { cursor: cursor2 }
|
|
23489
23557
|
});
|
|
23490
|
-
const pageResult =
|
|
23558
|
+
const pageResult = isRecord10(result) ? result : {};
|
|
23491
23559
|
for (const entry of array2(pageResult.data)) {
|
|
23492
|
-
if (
|
|
23560
|
+
if (isRecord10(entry) && entry.item !== void 0) items.push(entry.item);
|
|
23493
23561
|
}
|
|
23494
23562
|
cursor2 = typeof pageResult.nextCursor === "string" && pageResult.nextCursor.length > 0 ? pageResult.nextCursor : void 0;
|
|
23495
23563
|
if (cursor2 === void 0) break;
|
|
@@ -23553,7 +23621,7 @@ var CodexRemoteDomain = class {
|
|
|
23553
23621
|
return [...this.peers.values()].some((peer) => peer.hasThreadSubscription(threadId));
|
|
23554
23622
|
}
|
|
23555
23623
|
resolveUpstreamApproval(params) {
|
|
23556
|
-
if (!
|
|
23624
|
+
if (!isRecord10(params) || typeof params.requestId !== "string" && typeof params.requestId !== "number") return;
|
|
23557
23625
|
for (const [handle, approval] of this.approvals) {
|
|
23558
23626
|
if (approval.upstreamId === params.requestId) this.approvals.delete(handle);
|
|
23559
23627
|
}
|
|
@@ -23758,24 +23826,24 @@ function codexBinaryCandidates(configured, hostPlatform = process.platform, user
|
|
|
23758
23826
|
])];
|
|
23759
23827
|
}
|
|
23760
23828
|
function parseCallEnvelope(input2) {
|
|
23761
|
-
if (!
|
|
23829
|
+
if (!isRecord10(input2) || typeof input2.method !== "string" || !("params" in input2) || Object.keys(input2).some((key) => key !== "method" && key !== "params")) {
|
|
23762
23830
|
throw new RpcError("INVALID_MESSAGE", "The Codex call envelope is invalid.");
|
|
23763
23831
|
}
|
|
23764
23832
|
return { method: input2.method, params: input2.params };
|
|
23765
23833
|
}
|
|
23766
23834
|
function parseRespond(input2) {
|
|
23767
|
-
if (!
|
|
23835
|
+
if (!isRecord10(input2) || typeof input2.requestHandle !== "string" || !["accept", "decline", "cancel"].includes(String(input2.decision)) || Object.keys(input2).some((key) => key !== "requestHandle" && key !== "decision")) {
|
|
23768
23836
|
throw new RpcError("INVALID_MESSAGE", "The Codex approval response is invalid.");
|
|
23769
23837
|
}
|
|
23770
23838
|
return input2;
|
|
23771
23839
|
}
|
|
23772
23840
|
function accountCanRun(result) {
|
|
23773
|
-
if (!
|
|
23774
|
-
return result.requiresOpenaiAuth === false ||
|
|
23841
|
+
if (!isRecord10(result) || typeof result.requiresOpenaiAuth !== "boolean") return false;
|
|
23842
|
+
return result.requiresOpenaiAuth === false || isRecord10(result.account);
|
|
23775
23843
|
}
|
|
23776
23844
|
function sanitizeAccount(result) {
|
|
23777
|
-
if (!
|
|
23778
|
-
const account =
|
|
23845
|
+
if (!isRecord10(result)) throw new RpcError("CODEX_INVALID_RESPONSE", "Codex App Server returned invalid account state.");
|
|
23846
|
+
const account = isRecord10(result.account) ? result.account : void 0;
|
|
23779
23847
|
return {
|
|
23780
23848
|
authenticated: account !== void 0 || result.requiresOpenaiAuth === false,
|
|
23781
23849
|
requiresOpenaiAuth: result.requiresOpenaiAuth === true,
|
|
@@ -23788,11 +23856,11 @@ function sanitizeAccount(result) {
|
|
|
23788
23856
|
};
|
|
23789
23857
|
}
|
|
23790
23858
|
function sanitizeThreadList(result) {
|
|
23791
|
-
if (!
|
|
23859
|
+
if (!isRecord10(result) || !Array.isArray(result.data)) {
|
|
23792
23860
|
throw new RpcError("CODEX_INVALID_RESPONSE", "Codex App Server returned an invalid thread list.");
|
|
23793
23861
|
}
|
|
23794
23862
|
const data = result.data.flatMap((value) => {
|
|
23795
|
-
if (!
|
|
23863
|
+
if (!isRecord10(value) || typeof value.id !== "string") return [];
|
|
23796
23864
|
return [{
|
|
23797
23865
|
id: value.id,
|
|
23798
23866
|
...typeof value.sessionId === "string" ? { sessionId: value.sessionId } : {},
|
|
@@ -23804,7 +23872,7 @@ function sanitizeThreadList(result) {
|
|
|
23804
23872
|
...typeof value.updatedAt === "number" && Number.isFinite(value.updatedAt) ? { updatedAt: value.updatedAt } : {},
|
|
23805
23873
|
...typeof value.archived === "boolean" ? { archived: value.archived } : {},
|
|
23806
23874
|
...typeof value.isPinned === "boolean" ? { isPinned: value.isPinned } : {},
|
|
23807
|
-
...
|
|
23875
|
+
...isRecord10(value.status) ? { status: value.status } : {}
|
|
23808
23876
|
}];
|
|
23809
23877
|
});
|
|
23810
23878
|
return {
|
|
@@ -23814,22 +23882,22 @@ function sanitizeThreadList(result) {
|
|
|
23814
23882
|
};
|
|
23815
23883
|
}
|
|
23816
23884
|
function filterThreadListByWorkspaceAuthority(result, authority) {
|
|
23817
|
-
if (!
|
|
23885
|
+
if (!isRecord10(result) || !Array.isArray(result.data)) {
|
|
23818
23886
|
throw new RpcError("CODEX_INVALID_RESPONSE", "Codex App Server returned an invalid thread list.");
|
|
23819
23887
|
}
|
|
23820
23888
|
return {
|
|
23821
23889
|
...result,
|
|
23822
|
-
data: result.data.map((
|
|
23890
|
+
data: result.data.map((record5) => isRecord10(record5) ? record5 : void 0).filter((thread) => thread !== void 0 && isThreadAllowedByWorkspaceAuthority(thread, authority))
|
|
23823
23891
|
};
|
|
23824
23892
|
}
|
|
23825
23893
|
function sanitizeProjectList(result) {
|
|
23826
|
-
if (!
|
|
23894
|
+
if (!isRecord10(result) || !Array.isArray(result.data)) {
|
|
23827
23895
|
throw new RpcError("CODEX_INVALID_RESPONSE", "Codex App Server returned an invalid project list.");
|
|
23828
23896
|
}
|
|
23829
23897
|
const data = result.data.flatMap((value) => {
|
|
23830
|
-
if (!
|
|
23898
|
+
if (!isRecord10(value) || typeof value.id !== "string" || typeof value.name !== "string") return [];
|
|
23831
23899
|
const roots = Array.isArray(value.roots) ? value.roots.flatMap((root) => {
|
|
23832
|
-
const path =
|
|
23900
|
+
const path = isRecord10(root) && typeof root.path === "string" && root.path.length > 0 ? root.path : void 0;
|
|
23833
23901
|
return path === void 0 || !isAbsolute3(path) ? [] : [{ path }];
|
|
23834
23902
|
}) : [];
|
|
23835
23903
|
if (roots.length === 0) return [];
|
|
@@ -23873,19 +23941,19 @@ function codexDirectoryCrumbs(root, path) {
|
|
|
23873
23941
|
return crumbs2;
|
|
23874
23942
|
}
|
|
23875
23943
|
function extractThread(result) {
|
|
23876
|
-
return
|
|
23944
|
+
return isRecord10(result) && isRecord10(result.thread) ? result.thread : void 0;
|
|
23877
23945
|
}
|
|
23878
23946
|
function extractTurnId(result) {
|
|
23879
|
-
if (!
|
|
23947
|
+
if (!isRecord10(result)) return void 0;
|
|
23880
23948
|
if (typeof result.turnId === "string" && result.turnId.length > 0) return result.turnId;
|
|
23881
|
-
if (
|
|
23949
|
+
if (isRecord10(result.turn) && typeof result.turn.id === "string" && result.turn.id.length > 0) return result.turn.id;
|
|
23882
23950
|
return void 0;
|
|
23883
23951
|
}
|
|
23884
23952
|
function extractThreadId(params) {
|
|
23885
|
-
if (!
|
|
23953
|
+
if (!isRecord10(params)) return void 0;
|
|
23886
23954
|
if (typeof params.threadId === "string") return params.threadId;
|
|
23887
|
-
if (
|
|
23888
|
-
if (
|
|
23955
|
+
if (isRecord10(params.thread) && typeof params.thread.id === "string") return params.thread.id;
|
|
23956
|
+
if (isRecord10(params.turn) && typeof params.turn.threadId === "string") return params.turn.threadId;
|
|
23889
23957
|
return void 0;
|
|
23890
23958
|
}
|
|
23891
23959
|
function optionalInteger2(value) {
|
|
@@ -23927,13 +23995,13 @@ function mapCodexImageInputs(params) {
|
|
|
23927
23995
|
return {
|
|
23928
23996
|
...params,
|
|
23929
23997
|
input: params.input.map((value) => {
|
|
23930
|
-
if (!
|
|
23998
|
+
if (!isRecord10(value) || value.type !== "image" || typeof value.mediaType !== "string" || typeof value.data !== "string") return value;
|
|
23931
23999
|
return { type: "image", url: `data:${value.mediaType};base64,${value.data}` };
|
|
23932
24000
|
})
|
|
23933
24001
|
};
|
|
23934
24002
|
}
|
|
23935
24003
|
function sanitizeApprovalParams(params, requestHandle) {
|
|
23936
|
-
if (!
|
|
24004
|
+
if (!isRecord10(params)) return { requestHandle };
|
|
23937
24005
|
const safe = { ...params };
|
|
23938
24006
|
delete safe.proposedExecpolicyAmendment;
|
|
23939
24007
|
delete safe.additionalPermissions;
|
|
@@ -23964,7 +24032,7 @@ function isProjectListFallbackError(error) {
|
|
|
23964
24032
|
function canTryNextBinary(error) {
|
|
23965
24033
|
return !(error instanceof RpcError) || !["CODEX_AUTH_REQUIRED", "CODEX_CLOSED"].includes(error.code);
|
|
23966
24034
|
}
|
|
23967
|
-
function
|
|
24035
|
+
function isRecord10(value) {
|
|
23968
24036
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
23969
24037
|
}
|
|
23970
24038
|
function array2(value) {
|