dsh-remote-control 1.0.0 → 1.2.0
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/cordis.patch.yml +4 -0
- package/dist/bundle/client.cjs +484 -0
- package/dist/bundle/index.js +577 -433
- package/package.json +14 -6
- package/dist/src/core/clock.d.ts +0 -45
- package/dist/src/core/clock.js +0 -83
- package/dist/src/core/clock.js.map +0 -1
- package/dist/src/core/keys.d.ts +0 -98
- package/dist/src/core/keys.js +0 -176
- package/dist/src/core/keys.js.map +0 -1
- package/dist/src/core/pairing-window.d.ts +0 -95
- package/dist/src/core/pairing-window.js +0 -92
- package/dist/src/core/pairing-window.js.map +0 -1
- package/dist/src/core/runtime.d.ts +0 -104
- package/dist/src/core/runtime.js +0 -491
- package/dist/src/core/runtime.js.map +0 -1
- package/dist/src/core/sleep-policy.d.ts +0 -81
- package/dist/src/core/sleep-policy.js +0 -134
- package/dist/src/core/sleep-policy.js.map +0 -1
- package/dist/src/core/window.d.ts +0 -88
- package/dist/src/core/window.js +0 -185
- package/dist/src/core/window.js.map +0 -1
- package/dist/src/index.d.ts +0 -70
- package/dist/src/index.js +0 -882
- package/dist/src/index.js.map +0 -1
- package/dist/src/platform/carrier-services.d.ts +0 -96
- package/dist/src/platform/carrier-services.js +0 -982
- package/dist/src/platform/carrier-services.js.map +0 -1
- package/dist/src/platform/guard.d.ts +0 -60
- package/dist/src/platform/guard.js +0 -124
- package/dist/src/platform/guard.js.map +0 -1
- package/dist/src/platform/mock-kernel.d.ts +0 -95
- package/dist/src/platform/mock-kernel.js +0 -180
- package/dist/src/platform/mock-kernel.js.map +0 -1
- package/dist/src/platform/qr.d.ts +0 -28
- package/dist/src/platform/qr.js +0 -80
- package/dist/src/platform/qr.js.map +0 -1
- package/dist/src/platform/sleep-posix.d.ts +0 -17
- package/dist/src/platform/sleep-posix.js +0 -91
- package/dist/src/platform/sleep-posix.js.map +0 -1
- package/dist/src/ports/index.d.ts +0 -246
- package/dist/src/ports/index.js +0 -2
- package/dist/src/ports/index.js.map +0 -1
- package/dist/src/shell/config.d.ts +0 -56
- package/dist/src/shell/config.js +0 -212
- package/dist/src/shell/config.js.map +0 -1
- package/dist/src/shell/pairing-text.d.ts +0 -38
- package/dist/src/shell/pairing-text.js +0 -22
- package/dist/src/shell/pairing-text.js.map +0 -1
- package/dist/src/shell/status.d.ts +0 -39
- package/dist/src/shell/status.js +0 -119
- package/dist/src/shell/status.js.map +0 -1
- package/dist/src/transport/relay.d.ts +0 -107
- package/dist/src/transport/relay.js +0 -359
- package/dist/src/transport/relay.js.map +0 -1
- package/dist/tests/carrier-events.test.d.ts +0 -1
- package/dist/tests/carrier-events.test.js +0 -88
- package/dist/tests/carrier-events.test.js.map +0 -1
- package/dist/tests/carrier-services.test.d.ts +0 -1
- package/dist/tests/carrier-services.test.js +0 -562
- package/dist/tests/carrier-services.test.js.map +0 -1
- package/dist/tests/carrier-vocabulary.test.d.ts +0 -1
- package/dist/tests/carrier-vocabulary.test.js +0 -149
- package/dist/tests/carrier-vocabulary.test.js.map +0 -1
- package/dist/tests/clock-probe-timers.test.d.ts +0 -1
- package/dist/tests/clock-probe-timers.test.js +0 -73
- package/dist/tests/clock-probe-timers.test.js.map +0 -1
- package/dist/tests/command-result.test.d.ts +0 -1
- package/dist/tests/command-result.test.js +0 -185
- package/dist/tests/command-result.test.js.map +0 -1
- package/dist/tests/config.test.d.ts +0 -1
- package/dist/tests/config.test.js +0 -223
- package/dist/tests/config.test.js.map +0 -1
- package/dist/tests/guard.test.d.ts +0 -1
- package/dist/tests/guard.test.js +0 -175
- package/dist/tests/guard.test.js.map +0 -1
- package/dist/tests/ids-and-keys.test.d.ts +0 -1
- package/dist/tests/ids-and-keys.test.js +0 -211
- package/dist/tests/ids-and-keys.test.js.map +0 -1
- package/dist/tests/pairing-text.test.d.ts +0 -1
- package/dist/tests/pairing-text.test.js +0 -62
- package/dist/tests/pairing-text.test.js.map +0 -1
- package/dist/tests/pairing-window.test.d.ts +0 -1
- package/dist/tests/pairing-window.test.js +0 -165
- package/dist/tests/pairing-window.test.js.map +0 -1
- package/dist/tests/relay-client.test.d.ts +0 -1
- package/dist/tests/relay-client.test.js +0 -557
- package/dist/tests/relay-client.test.js.map +0 -1
- package/dist/tests/runtime.test.d.ts +0 -1
- package/dist/tests/runtime.test.js +0 -963
- package/dist/tests/runtime.test.js.map +0 -1
- package/dist/tests/sleep.test.d.ts +0 -1
- package/dist/tests/sleep.test.js +0 -264
- package/dist/tests/sleep.test.js.map +0 -1
- package/dist/tests/status.test.d.ts +0 -1
- package/dist/tests/status.test.js +0 -238
- package/dist/tests/status.test.js.map +0 -1
- package/dist/tests/window.test.d.ts +0 -1
- package/dist/tests/window.test.js +0 -210
- package/dist/tests/window.test.js.map +0 -1
package/dist/bundle/index.js
CHANGED
|
@@ -4501,7 +4501,7 @@ var require_websocket = __commonJS({
|
|
|
4501
4501
|
var http = __require("http");
|
|
4502
4502
|
var net = __require("net");
|
|
4503
4503
|
var tls = __require("tls");
|
|
4504
|
-
var { randomBytes: randomBytes5, createHash:
|
|
4504
|
+
var { randomBytes: randomBytes5, createHash: createHash3 } = __require("crypto");
|
|
4505
4505
|
var { Duplex, Readable } = __require("stream");
|
|
4506
4506
|
var { URL: URL2 } = __require("url");
|
|
4507
4507
|
var PerMessageDeflate2 = require_permessage_deflate();
|
|
@@ -5182,7 +5182,7 @@ var require_websocket = __commonJS({
|
|
|
5182
5182
|
abortHandshake(websocket, socket, "Invalid Upgrade header");
|
|
5183
5183
|
return;
|
|
5184
5184
|
}
|
|
5185
|
-
const digest =
|
|
5185
|
+
const digest = createHash3("sha1").update(key + GUID).digest("base64");
|
|
5186
5186
|
if (res.headers["sec-websocket-accept"] !== digest) {
|
|
5187
5187
|
abortHandshake(websocket, socket, "Invalid Sec-WebSocket-Accept header");
|
|
5188
5188
|
return;
|
|
@@ -5551,7 +5551,7 @@ var require_websocket_server = __commonJS({
|
|
|
5551
5551
|
var EventEmitter = __require("events");
|
|
5552
5552
|
var http = __require("http");
|
|
5553
5553
|
var { Duplex } = __require("stream");
|
|
5554
|
-
var { createHash:
|
|
5554
|
+
var { createHash: createHash3 } = __require("crypto");
|
|
5555
5555
|
var extension2 = require_extension();
|
|
5556
5556
|
var PerMessageDeflate2 = require_permessage_deflate();
|
|
5557
5557
|
var subprotocol2 = require_subprotocol();
|
|
@@ -5858,7 +5858,7 @@ var require_websocket_server = __commonJS({
|
|
|
5858
5858
|
);
|
|
5859
5859
|
}
|
|
5860
5860
|
if (this._state > RUNNING) return abortHandshake(socket, 503);
|
|
5861
|
-
const digest =
|
|
5861
|
+
const digest = createHash3("sha1").update(key + GUID).digest("base64");
|
|
5862
5862
|
const headers = [
|
|
5863
5863
|
"HTTP/1.1 101 Switching Protocols",
|
|
5864
5864
|
"Upgrade: websocket",
|
|
@@ -10655,7 +10655,6 @@ var init_mock_kernel = __esm({
|
|
|
10655
10655
|
});
|
|
10656
10656
|
|
|
10657
10657
|
// src/index.ts
|
|
10658
|
-
import { execFile } from "node:child_process";
|
|
10659
10658
|
import { randomBytes as randomBytes4 } from "node:crypto";
|
|
10660
10659
|
|
|
10661
10660
|
// ../../node_modules/.pnpm/dsh-remote-wire@1.0.0/node_modules/dsh-remote-wire/dist/src/crypto/bytes.js
|
|
@@ -26376,13 +26375,13 @@ function initializeContext(params) {
|
|
|
26376
26375
|
external: params?.external ?? void 0
|
|
26377
26376
|
};
|
|
26378
26377
|
}
|
|
26379
|
-
function handleUnrepresentable(schema, ctx,
|
|
26378
|
+
function handleUnrepresentable(schema, ctx, json3, params, message) {
|
|
26380
26379
|
const result2 = typeof ctx.unrepresentable === "function" ? ctx.unrepresentable({ zodSchema: schema, path: params.path, message }) : ctx.unrepresentable;
|
|
26381
26380
|
if (result2 === "any")
|
|
26382
26381
|
return false;
|
|
26383
26382
|
if (result2 === void 0 || result2 === "throw")
|
|
26384
26383
|
throw new Error(message);
|
|
26385
|
-
Object.assign(
|
|
26384
|
+
Object.assign(json3, result2);
|
|
26386
26385
|
return true;
|
|
26387
26386
|
}
|
|
26388
26387
|
function processSchema(schema, ctx, _params = { path: [], schemaPath: [] }) {
|
|
@@ -26618,12 +26617,12 @@ function foldObjects(members2) {
|
|
|
26618
26617
|
}
|
|
26619
26618
|
return folded;
|
|
26620
26619
|
}
|
|
26621
|
-
function foldIntersection(
|
|
26622
|
-
const allOf =
|
|
26620
|
+
function foldIntersection(json3) {
|
|
26621
|
+
const allOf = json3.allOf;
|
|
26623
26622
|
if (!Array.isArray(allOf) || allOf.length < 2)
|
|
26624
26623
|
return;
|
|
26625
26624
|
for (const key of FOLDABLE_KEYS)
|
|
26626
|
-
if (key in
|
|
26625
|
+
if (key in json3)
|
|
26627
26626
|
return;
|
|
26628
26627
|
const unions = allOf.filter((m) => UNION_KEYS.some((k) => Array.isArray(m[k])));
|
|
26629
26628
|
let folded = null;
|
|
@@ -26642,8 +26641,8 @@ function foldIntersection(json2) {
|
|
|
26642
26641
|
}
|
|
26643
26642
|
if (!folded)
|
|
26644
26643
|
return;
|
|
26645
|
-
delete
|
|
26646
|
-
assignProps(
|
|
26644
|
+
delete json3.allOf;
|
|
26645
|
+
assignProps(json3, folded);
|
|
26647
26646
|
}
|
|
26648
26647
|
function finalize(ctx, schema) {
|
|
26649
26648
|
const root = ctx.seen.get(schema);
|
|
@@ -26725,20 +26724,20 @@ function finalize(ctx, schema) {
|
|
|
26725
26724
|
if (ctx.intersections.length) {
|
|
26726
26725
|
const carriers = /* @__PURE__ */ new Map();
|
|
26727
26726
|
for (const seen of ctx.seen.values()) {
|
|
26728
|
-
for (const
|
|
26729
|
-
const allOf =
|
|
26727
|
+
for (const json3 of [seen.schema, seen.def]) {
|
|
26728
|
+
const allOf = json3?.allOf;
|
|
26730
26729
|
if (!Array.isArray(allOf))
|
|
26731
26730
|
continue;
|
|
26732
26731
|
const existing = carriers.get(allOf);
|
|
26733
26732
|
if (existing)
|
|
26734
|
-
existing.push(
|
|
26733
|
+
existing.push(json3);
|
|
26735
26734
|
else
|
|
26736
|
-
carriers.set(allOf, [
|
|
26735
|
+
carriers.set(allOf, [json3]);
|
|
26737
26736
|
}
|
|
26738
26737
|
}
|
|
26739
26738
|
for (const allOf of ctx.intersections) {
|
|
26740
|
-
for (const
|
|
26741
|
-
foldIntersection(
|
|
26739
|
+
for (const json3 of carriers.get(allOf) ?? [])
|
|
26740
|
+
foldIntersection(json3);
|
|
26742
26741
|
}
|
|
26743
26742
|
}
|
|
26744
26743
|
}
|
|
@@ -26973,29 +26972,29 @@ var exactPatterns = /* @__PURE__ */ new Map([
|
|
|
26973
26972
|
]);
|
|
26974
26973
|
var exactPattern = (p) => exactPatterns.get(p) ?? p;
|
|
26975
26974
|
var stringProcessor = (schema, ctx, _json, _params) => {
|
|
26976
|
-
const
|
|
26977
|
-
|
|
26975
|
+
const json3 = _json;
|
|
26976
|
+
json3.type = "string";
|
|
26978
26977
|
const { minimum, maximum, format, patterns, contentEncoding, laxFormat } = aggregateChecks(schema);
|
|
26979
26978
|
if (typeof minimum === "number")
|
|
26980
|
-
|
|
26979
|
+
json3.minLength = minimum;
|
|
26981
26980
|
if (typeof maximum === "number")
|
|
26982
|
-
|
|
26981
|
+
json3.maxLength = maximum;
|
|
26983
26982
|
if (format) {
|
|
26984
|
-
|
|
26985
|
-
if (
|
|
26986
|
-
delete
|
|
26983
|
+
json3.format = formatMap[format] ?? format;
|
|
26984
|
+
if (json3.format === "")
|
|
26985
|
+
delete json3.format;
|
|
26987
26986
|
if (format === "time" || laxFormat) {
|
|
26988
|
-
delete
|
|
26987
|
+
delete json3.format;
|
|
26989
26988
|
}
|
|
26990
26989
|
}
|
|
26991
26990
|
if (contentEncoding)
|
|
26992
|
-
|
|
26991
|
+
json3.contentEncoding = contentEncoding;
|
|
26993
26992
|
if (patterns && patterns.size > 0) {
|
|
26994
26993
|
const patternList = [...patterns].map(exactPattern);
|
|
26995
26994
|
if (patternList.length === 1)
|
|
26996
|
-
|
|
26995
|
+
json3.pattern = patternList[0].source;
|
|
26997
26996
|
else if (patternList.length > 1) {
|
|
26998
|
-
|
|
26997
|
+
json3.allOf = [
|
|
26999
26998
|
...patternList.map((regex) => ({
|
|
27000
26999
|
...ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0" ? { type: "string" } : {},
|
|
27001
27000
|
pattern: regex.source
|
|
@@ -27005,31 +27004,31 @@ var stringProcessor = (schema, ctx, _json, _params) => {
|
|
|
27005
27004
|
}
|
|
27006
27005
|
};
|
|
27007
27006
|
var numberProcessor = (schema, ctx, _json, params) => {
|
|
27008
|
-
const
|
|
27007
|
+
const json3 = _json;
|
|
27009
27008
|
const { minimum, maximum, multipleOf, exclusiveMaximum, exclusiveMinimum, isInt } = aggregateChecks(schema);
|
|
27010
|
-
|
|
27009
|
+
json3.type = isInt ? "integer" : "number";
|
|
27011
27010
|
const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
|
|
27012
27011
|
const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
|
|
27013
27012
|
const legacy = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
|
|
27014
27013
|
if (exMin) {
|
|
27015
27014
|
if (legacy) {
|
|
27016
|
-
|
|
27017
|
-
|
|
27015
|
+
json3.minimum = exclusiveMinimum;
|
|
27016
|
+
json3.exclusiveMinimum = true;
|
|
27018
27017
|
} else {
|
|
27019
|
-
|
|
27018
|
+
json3.exclusiveMinimum = exclusiveMinimum;
|
|
27020
27019
|
}
|
|
27021
27020
|
} else if (typeof minimum === "number") {
|
|
27022
|
-
|
|
27021
|
+
json3.minimum = minimum;
|
|
27023
27022
|
}
|
|
27024
27023
|
if (exMax) {
|
|
27025
27024
|
if (legacy) {
|
|
27026
|
-
|
|
27027
|
-
|
|
27025
|
+
json3.maximum = exclusiveMaximum;
|
|
27026
|
+
json3.exclusiveMaximum = true;
|
|
27028
27027
|
} else {
|
|
27029
|
-
|
|
27028
|
+
json3.exclusiveMaximum = exclusiveMaximum;
|
|
27030
27029
|
}
|
|
27031
27030
|
} else if (typeof maximum === "number") {
|
|
27032
|
-
|
|
27031
|
+
json3.maximum = maximum;
|
|
27033
27032
|
}
|
|
27034
27033
|
if (multipleOf) {
|
|
27035
27034
|
const divisors = /* @__PURE__ */ new Set();
|
|
@@ -27037,75 +27036,75 @@ var numberProcessor = (schema, ctx, _json, params) => {
|
|
|
27037
27036
|
if (Number.isFinite(divisor) && divisor !== 0)
|
|
27038
27037
|
divisors.add(Math.abs(divisor));
|
|
27039
27038
|
else
|
|
27040
|
-
handleUnrepresentable(schema, ctx,
|
|
27039
|
+
handleUnrepresentable(schema, ctx, json3, params, `A multipleOf divisor of ${divisor} cannot be represented in JSON Schema`);
|
|
27041
27040
|
}
|
|
27042
27041
|
const [first, ...rest] = divisors;
|
|
27043
27042
|
if (first !== void 0)
|
|
27044
|
-
|
|
27043
|
+
json3.multipleOf = first;
|
|
27045
27044
|
if (rest.length)
|
|
27046
|
-
|
|
27045
|
+
json3.allOf = [...json3.allOf ?? [], ...rest.map((m) => ({ multipleOf: m }))];
|
|
27047
27046
|
}
|
|
27048
27047
|
};
|
|
27049
|
-
var booleanProcessor = (_schema, _ctx,
|
|
27050
|
-
|
|
27048
|
+
var booleanProcessor = (_schema, _ctx, json3, _params) => {
|
|
27049
|
+
json3.type = "boolean";
|
|
27051
27050
|
};
|
|
27052
|
-
var bigintProcessor = (schema, ctx,
|
|
27053
|
-
handleUnrepresentable(schema, ctx,
|
|
27051
|
+
var bigintProcessor = (schema, ctx, json3, params) => {
|
|
27052
|
+
handleUnrepresentable(schema, ctx, json3, params, "BigInt cannot be represented in JSON Schema");
|
|
27054
27053
|
};
|
|
27055
|
-
var symbolProcessor = (schema, ctx,
|
|
27056
|
-
handleUnrepresentable(schema, ctx,
|
|
27054
|
+
var symbolProcessor = (schema, ctx, json3, params) => {
|
|
27055
|
+
handleUnrepresentable(schema, ctx, json3, params, "Symbols cannot be represented in JSON Schema");
|
|
27057
27056
|
};
|
|
27058
|
-
var nullProcessor = (_schema, ctx,
|
|
27057
|
+
var nullProcessor = (_schema, ctx, json3, _params) => {
|
|
27059
27058
|
if (ctx.target === "openapi-3.0") {
|
|
27060
|
-
|
|
27061
|
-
|
|
27062
|
-
|
|
27059
|
+
json3.type = "string";
|
|
27060
|
+
json3.nullable = true;
|
|
27061
|
+
json3.enum = [null];
|
|
27063
27062
|
} else {
|
|
27064
|
-
|
|
27063
|
+
json3.type = "null";
|
|
27065
27064
|
}
|
|
27066
27065
|
};
|
|
27067
|
-
var undefinedProcessor = (schema, ctx,
|
|
27068
|
-
handleUnrepresentable(schema, ctx,
|
|
27066
|
+
var undefinedProcessor = (schema, ctx, json3, params) => {
|
|
27067
|
+
handleUnrepresentable(schema, ctx, json3, params, "Undefined cannot be represented in JSON Schema");
|
|
27069
27068
|
};
|
|
27070
|
-
var voidProcessor = (schema, ctx,
|
|
27071
|
-
handleUnrepresentable(schema, ctx,
|
|
27069
|
+
var voidProcessor = (schema, ctx, json3, params) => {
|
|
27070
|
+
handleUnrepresentable(schema, ctx, json3, params, "Void cannot be represented in JSON Schema");
|
|
27072
27071
|
};
|
|
27073
|
-
var neverProcessor = (_schema, _ctx,
|
|
27074
|
-
|
|
27072
|
+
var neverProcessor = (_schema, _ctx, json3, _params) => {
|
|
27073
|
+
json3.not = {};
|
|
27075
27074
|
};
|
|
27076
27075
|
var anyProcessor = (_schema, _ctx, _json, _params) => {
|
|
27077
27076
|
};
|
|
27078
27077
|
var unknownProcessor = (_schema, _ctx, _json, _params) => {
|
|
27079
27078
|
};
|
|
27080
|
-
var dateProcessor = (schema, ctx,
|
|
27081
|
-
handleUnrepresentable(schema, ctx,
|
|
27079
|
+
var dateProcessor = (schema, ctx, json3, params) => {
|
|
27080
|
+
handleUnrepresentable(schema, ctx, json3, params, "Date cannot be represented in JSON Schema");
|
|
27082
27081
|
};
|
|
27083
|
-
var enumProcessor = (schema, _ctx,
|
|
27082
|
+
var enumProcessor = (schema, _ctx, json3, _params) => {
|
|
27084
27083
|
const def = schema._zod.def;
|
|
27085
27084
|
const values = getEnumValues(def.entries);
|
|
27086
27085
|
if (values.length === 0) {
|
|
27087
|
-
|
|
27086
|
+
json3.not = {};
|
|
27088
27087
|
return;
|
|
27089
27088
|
}
|
|
27090
27089
|
if (values.every((v) => typeof v === "number"))
|
|
27091
|
-
|
|
27090
|
+
json3.type = "number";
|
|
27092
27091
|
if (values.every((v) => typeof v === "string"))
|
|
27093
|
-
|
|
27094
|
-
|
|
27092
|
+
json3.type = "string";
|
|
27093
|
+
json3.enum = values;
|
|
27095
27094
|
};
|
|
27096
|
-
var literalProcessor = (schema, ctx,
|
|
27095
|
+
var literalProcessor = (schema, ctx, json3, params) => {
|
|
27097
27096
|
const def = schema._zod.def;
|
|
27098
27097
|
if (def.values.length === 0) {
|
|
27099
|
-
|
|
27098
|
+
json3.not = {};
|
|
27100
27099
|
return;
|
|
27101
27100
|
}
|
|
27102
27101
|
const vals = [];
|
|
27103
27102
|
for (const val of def.values) {
|
|
27104
27103
|
if (val === void 0) {
|
|
27105
|
-
if (handleUnrepresentable(schema, ctx,
|
|
27104
|
+
if (handleUnrepresentable(schema, ctx, json3, params, "Literal `undefined` cannot be represented in JSON Schema"))
|
|
27106
27105
|
return;
|
|
27107
27106
|
} else if (typeof val === "bigint") {
|
|
27108
|
-
if (handleUnrepresentable(schema, ctx,
|
|
27107
|
+
if (handleUnrepresentable(schema, ctx, json3, params, "BigInt literals cannot be represented in JSON Schema"))
|
|
27109
27108
|
return;
|
|
27110
27109
|
vals.push(Number(val));
|
|
27111
27110
|
} else {
|
|
@@ -27115,37 +27114,37 @@ var literalProcessor = (schema, ctx, json2, params) => {
|
|
|
27115
27114
|
if (vals.length === 0) {
|
|
27116
27115
|
} else if (vals.length === 1) {
|
|
27117
27116
|
const val = vals[0];
|
|
27118
|
-
|
|
27117
|
+
json3.type = val === null ? "null" : typeof val;
|
|
27119
27118
|
if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
|
|
27120
|
-
|
|
27119
|
+
json3.enum = [val];
|
|
27121
27120
|
} else {
|
|
27122
|
-
|
|
27121
|
+
json3.const = val;
|
|
27123
27122
|
}
|
|
27124
27123
|
} else {
|
|
27125
27124
|
if (vals.every((v) => typeof v === "number"))
|
|
27126
|
-
|
|
27125
|
+
json3.type = "number";
|
|
27127
27126
|
if (vals.every((v) => typeof v === "string"))
|
|
27128
|
-
|
|
27127
|
+
json3.type = "string";
|
|
27129
27128
|
if (vals.every((v) => typeof v === "boolean"))
|
|
27130
|
-
|
|
27129
|
+
json3.type = "boolean";
|
|
27131
27130
|
if (vals.every((v) => v === null))
|
|
27132
|
-
|
|
27133
|
-
|
|
27131
|
+
json3.type = "null";
|
|
27132
|
+
json3.enum = vals;
|
|
27134
27133
|
}
|
|
27135
27134
|
};
|
|
27136
|
-
var nanProcessor = (schema, ctx,
|
|
27137
|
-
handleUnrepresentable(schema, ctx,
|
|
27135
|
+
var nanProcessor = (schema, ctx, json3, params) => {
|
|
27136
|
+
handleUnrepresentable(schema, ctx, json3, params, "NaN cannot be represented in JSON Schema");
|
|
27138
27137
|
};
|
|
27139
|
-
var templateLiteralProcessor = (schema, _ctx,
|
|
27140
|
-
const _json =
|
|
27138
|
+
var templateLiteralProcessor = (schema, _ctx, json3, _params) => {
|
|
27139
|
+
const _json = json3;
|
|
27141
27140
|
const pattern = schema._zod.pattern;
|
|
27142
27141
|
if (!pattern)
|
|
27143
27142
|
throw new Error("Pattern not found in template literal");
|
|
27144
27143
|
_json.type = "string";
|
|
27145
27144
|
_json.pattern = pattern.source;
|
|
27146
27145
|
};
|
|
27147
|
-
var fileProcessor = (schema, _ctx,
|
|
27148
|
-
const _json =
|
|
27146
|
+
var fileProcessor = (schema, _ctx, json3, _params) => {
|
|
27147
|
+
const _json = json3;
|
|
27149
27148
|
_json.type = "string";
|
|
27150
27149
|
_json.format = "binary";
|
|
27151
27150
|
_json.contentEncoding = "binary";
|
|
@@ -27163,34 +27162,34 @@ var fileProcessor = (schema, _ctx, json2, _params) => {
|
|
|
27163
27162
|
else
|
|
27164
27163
|
_json.anyOf = mime.map((m) => ({ contentMediaType: m }));
|
|
27165
27164
|
};
|
|
27166
|
-
var successProcessor = (_schema, _ctx,
|
|
27167
|
-
|
|
27165
|
+
var successProcessor = (_schema, _ctx, json3, _params) => {
|
|
27166
|
+
json3.type = "boolean";
|
|
27168
27167
|
};
|
|
27169
|
-
var customProcessor = (schema, ctx,
|
|
27170
|
-
handleUnrepresentable(schema, ctx,
|
|
27168
|
+
var customProcessor = (schema, ctx, json3, params) => {
|
|
27169
|
+
handleUnrepresentable(schema, ctx, json3, params, "Custom types cannot be represented in JSON Schema");
|
|
27171
27170
|
};
|
|
27172
|
-
var functionProcessor = (schema, ctx,
|
|
27173
|
-
handleUnrepresentable(schema, ctx,
|
|
27171
|
+
var functionProcessor = (schema, ctx, json3, params) => {
|
|
27172
|
+
handleUnrepresentable(schema, ctx, json3, params, "Function types cannot be represented in JSON Schema");
|
|
27174
27173
|
};
|
|
27175
|
-
var transformProcessor = (schema, ctx,
|
|
27176
|
-
handleUnrepresentable(schema, ctx,
|
|
27174
|
+
var transformProcessor = (schema, ctx, json3, params) => {
|
|
27175
|
+
handleUnrepresentable(schema, ctx, json3, params, "Transforms cannot be represented in JSON Schema");
|
|
27177
27176
|
};
|
|
27178
|
-
var mapProcessor = (schema, ctx,
|
|
27179
|
-
handleUnrepresentable(schema, ctx,
|
|
27177
|
+
var mapProcessor = (schema, ctx, json3, params) => {
|
|
27178
|
+
handleUnrepresentable(schema, ctx, json3, params, "Map cannot be represented in JSON Schema");
|
|
27180
27179
|
};
|
|
27181
|
-
var setProcessor = (schema, ctx,
|
|
27182
|
-
handleUnrepresentable(schema, ctx,
|
|
27180
|
+
var setProcessor = (schema, ctx, json3, params) => {
|
|
27181
|
+
handleUnrepresentable(schema, ctx, json3, params, "Set cannot be represented in JSON Schema");
|
|
27183
27182
|
};
|
|
27184
27183
|
var arrayProcessor = (schema, ctx, _json, params) => {
|
|
27185
|
-
const
|
|
27184
|
+
const json3 = _json;
|
|
27186
27185
|
const def = schema._zod.def;
|
|
27187
27186
|
const { minimum, maximum } = aggregateChecks(schema);
|
|
27188
27187
|
if (typeof minimum === "number")
|
|
27189
|
-
|
|
27188
|
+
json3.minItems = minimum;
|
|
27190
27189
|
if (typeof maximum === "number")
|
|
27191
|
-
|
|
27192
|
-
|
|
27193
|
-
|
|
27190
|
+
json3.maxItems = maximum;
|
|
27191
|
+
json3.type = "array";
|
|
27192
|
+
json3.items = processSchema(def.element, ctx, {
|
|
27194
27193
|
...params,
|
|
27195
27194
|
path: [...params.path, "items"]
|
|
27196
27195
|
});
|
|
@@ -27206,17 +27205,17 @@ function inputOptin(schema) {
|
|
|
27206
27205
|
return schema._zod.optin;
|
|
27207
27206
|
}
|
|
27208
27207
|
var objectProcessor = (schema, ctx, _json, params) => {
|
|
27209
|
-
const
|
|
27208
|
+
const json3 = _json;
|
|
27210
27209
|
const def = schema._zod.def;
|
|
27211
27210
|
const shape = def.shape;
|
|
27212
27211
|
const symbolKeys = Object.getOwnPropertySymbols(shape);
|
|
27213
|
-
if (symbolKeys.length && handleUnrepresentable(schema, ctx,
|
|
27212
|
+
if (symbolKeys.length && handleUnrepresentable(schema, ctx, json3, params, "Symbol keys cannot be represented in JSON Schema")) {
|
|
27214
27213
|
return;
|
|
27215
27214
|
}
|
|
27216
|
-
|
|
27217
|
-
|
|
27215
|
+
json3.type = "object";
|
|
27216
|
+
json3.properties = {};
|
|
27218
27217
|
for (const key in shape) {
|
|
27219
|
-
assignProp(
|
|
27218
|
+
assignProp(json3.properties, key, processSchema(shape[key], ctx, {
|
|
27220
27219
|
...params,
|
|
27221
27220
|
path: [...params.path, "properties", key]
|
|
27222
27221
|
}));
|
|
@@ -27229,21 +27228,21 @@ var objectProcessor = (schema, ctx, _json, params) => {
|
|
|
27229
27228
|
}
|
|
27230
27229
|
}
|
|
27231
27230
|
if (requiredKeys.length > 0) {
|
|
27232
|
-
|
|
27231
|
+
json3.required = requiredKeys;
|
|
27233
27232
|
}
|
|
27234
27233
|
if (def.catchall?._zod.def.type === "never") {
|
|
27235
|
-
|
|
27234
|
+
json3.additionalProperties = false;
|
|
27236
27235
|
} else if (!def.catchall) {
|
|
27237
27236
|
if (ctx.io === "output")
|
|
27238
|
-
|
|
27237
|
+
json3.additionalProperties = false;
|
|
27239
27238
|
} else if (def.catchall) {
|
|
27240
|
-
|
|
27239
|
+
json3.additionalProperties = processSchema(def.catchall, ctx, {
|
|
27241
27240
|
...params,
|
|
27242
27241
|
path: [...params.path, "additionalProperties"]
|
|
27243
27242
|
});
|
|
27244
27243
|
}
|
|
27245
27244
|
};
|
|
27246
|
-
var unionProcessor = (schema, ctx,
|
|
27245
|
+
var unionProcessor = (schema, ctx, json3, params) => {
|
|
27247
27246
|
const def = schema._zod.def;
|
|
27248
27247
|
const isExclusive = def.inclusive === false;
|
|
27249
27248
|
const options = def.options.map((x, i) => processSchema(x, ctx, {
|
|
@@ -27251,12 +27250,12 @@ var unionProcessor = (schema, ctx, json2, params) => {
|
|
|
27251
27250
|
path: [...params.path, isExclusive ? "oneOf" : "anyOf", i]
|
|
27252
27251
|
}));
|
|
27253
27252
|
if (isExclusive) {
|
|
27254
|
-
|
|
27253
|
+
json3.oneOf = options;
|
|
27255
27254
|
} else {
|
|
27256
|
-
|
|
27255
|
+
json3.anyOf = options;
|
|
27257
27256
|
}
|
|
27258
27257
|
};
|
|
27259
|
-
var intersectionProcessor = (schema, ctx,
|
|
27258
|
+
var intersectionProcessor = (schema, ctx, json3, params) => {
|
|
27260
27259
|
const def = schema._zod.def;
|
|
27261
27260
|
const a = processSchema(def.left, ctx, {
|
|
27262
27261
|
...params,
|
|
@@ -27271,13 +27270,13 @@ var intersectionProcessor = (schema, ctx, json2, params) => {
|
|
|
27271
27270
|
...isSimpleIntersection(a) ? a.allOf : [a],
|
|
27272
27271
|
...isSimpleIntersection(b) ? b.allOf : [b]
|
|
27273
27272
|
];
|
|
27274
|
-
|
|
27273
|
+
json3.allOf = allOf;
|
|
27275
27274
|
ctx.intersections.push(allOf);
|
|
27276
27275
|
};
|
|
27277
27276
|
var tupleProcessor = (schema, ctx, _json, params) => {
|
|
27278
|
-
const
|
|
27277
|
+
const json3 = _json;
|
|
27279
27278
|
const def = schema._zod.def;
|
|
27280
|
-
|
|
27279
|
+
json3.type = "array";
|
|
27281
27280
|
const prefixPath = ctx.target === "draft-2020-12" ? "prefixItems" : "items";
|
|
27282
27281
|
const restPath = ctx.target === "draft-2020-12" ? "items" : ctx.target === "openapi-3.0" ? "items" : "additionalItems";
|
|
27283
27282
|
const prefixItems = def.items.map((x, i) => processSchema(x, ctx, {
|
|
@@ -27299,70 +27298,70 @@ var tupleProcessor = (schema, ctx, _json, params) => {
|
|
|
27299
27298
|
const maxItems = def.items.length;
|
|
27300
27299
|
const isClosed = !def.rest;
|
|
27301
27300
|
if (ctx.target === "draft-2020-12") {
|
|
27302
|
-
|
|
27301
|
+
json3.prefixItems = prefixItems;
|
|
27303
27302
|
if (isClosed) {
|
|
27304
|
-
|
|
27303
|
+
json3.items = false;
|
|
27305
27304
|
} else if (rest) {
|
|
27306
|
-
|
|
27305
|
+
json3.items = rest;
|
|
27307
27306
|
}
|
|
27308
27307
|
if (minItems > 0)
|
|
27309
|
-
|
|
27308
|
+
json3.minItems = minItems;
|
|
27310
27309
|
if (isClosed)
|
|
27311
|
-
|
|
27310
|
+
json3.maxItems = maxItems;
|
|
27312
27311
|
} else if (ctx.target === "openapi-3.0") {
|
|
27313
|
-
|
|
27312
|
+
json3.items = {
|
|
27314
27313
|
anyOf: prefixItems
|
|
27315
27314
|
};
|
|
27316
27315
|
if (rest) {
|
|
27317
|
-
|
|
27316
|
+
json3.items.anyOf.push(rest);
|
|
27318
27317
|
}
|
|
27319
27318
|
if (minItems > 0)
|
|
27320
|
-
|
|
27319
|
+
json3.minItems = minItems;
|
|
27321
27320
|
if (isClosed)
|
|
27322
|
-
|
|
27321
|
+
json3.maxItems = maxItems;
|
|
27323
27322
|
} else {
|
|
27324
|
-
|
|
27323
|
+
json3.items = prefixItems;
|
|
27325
27324
|
if (isClosed) {
|
|
27326
|
-
|
|
27325
|
+
json3.additionalItems = false;
|
|
27327
27326
|
} else if (rest) {
|
|
27328
|
-
|
|
27327
|
+
json3.additionalItems = rest;
|
|
27329
27328
|
}
|
|
27330
27329
|
if (minItems > 0)
|
|
27331
|
-
|
|
27330
|
+
json3.minItems = minItems;
|
|
27332
27331
|
if (isClosed)
|
|
27333
|
-
|
|
27332
|
+
json3.maxItems = maxItems;
|
|
27334
27333
|
}
|
|
27335
27334
|
const { minimum, maximum } = aggregateChecks(schema);
|
|
27336
27335
|
if (typeof minimum === "number")
|
|
27337
|
-
|
|
27336
|
+
json3.minItems = minimum;
|
|
27338
27337
|
if (typeof maximum === "number")
|
|
27339
|
-
|
|
27338
|
+
json3.maxItems = maximum;
|
|
27340
27339
|
};
|
|
27341
|
-
function stringifyKeyNames(bySchema,
|
|
27342
|
-
if (
|
|
27343
|
-
if (visited.has(
|
|
27344
|
-
return
|
|
27345
|
-
visited.add(
|
|
27346
|
-
const def = bySchema.get(
|
|
27340
|
+
function stringifyKeyNames(bySchema, json3, visited) {
|
|
27341
|
+
if (json3.$ref) {
|
|
27342
|
+
if (visited.has(json3))
|
|
27343
|
+
return json3;
|
|
27344
|
+
visited.add(json3);
|
|
27345
|
+
const def = bySchema.get(json3)?.def;
|
|
27347
27346
|
if (!def)
|
|
27348
|
-
return
|
|
27347
|
+
return json3;
|
|
27349
27348
|
const inlined = stringifyKeyNames(bySchema, def, visited);
|
|
27350
|
-
return inlined === def ?
|
|
27349
|
+
return inlined === def ? json3 : inlined;
|
|
27351
27350
|
}
|
|
27352
27351
|
for (const keyword of ["anyOf", "oneOf"]) {
|
|
27353
|
-
const branches =
|
|
27352
|
+
const branches = json3[keyword];
|
|
27354
27353
|
if (!Array.isArray(branches))
|
|
27355
27354
|
continue;
|
|
27356
27355
|
const mapped = branches.map((branch) => stringifyKeyNames(bySchema, branch, visited));
|
|
27357
27356
|
if (mapped.some((branch, i) => branch !== branches[i]))
|
|
27358
|
-
|
|
27357
|
+
json3 = { ...json3, [keyword]: mapped };
|
|
27359
27358
|
}
|
|
27360
|
-
const types = Array.isArray(
|
|
27359
|
+
const types = Array.isArray(json3.type) ? json3.type : [json3.type];
|
|
27361
27360
|
const numericType = !types.includes("string") && types.some((t) => t === "number" || t === "integer");
|
|
27362
|
-
const values =
|
|
27361
|
+
const values = json3.enum ?? (json3.const !== void 0 ? [json3.const] : void 0);
|
|
27363
27362
|
if (!numericType && !values?.some((v) => typeof v === "number"))
|
|
27364
|
-
return
|
|
27365
|
-
const { minimum, maximum, exclusiveMinimum, exclusiveMaximum, multipleOf, format, id, ...rest } =
|
|
27363
|
+
return json3;
|
|
27364
|
+
const { minimum, maximum, exclusiveMinimum, exclusiveMaximum, multipleOf, format, id, ...rest } = json3;
|
|
27366
27365
|
if (rest.enum)
|
|
27367
27366
|
rest.enum = rest.enum.map((v) => typeof v === "number" ? String(v) : v);
|
|
27368
27367
|
else if (typeof rest.const === "number")
|
|
@@ -27402,9 +27401,9 @@ function rewriteKeyNames(ctx) {
|
|
|
27402
27401
|
}
|
|
27403
27402
|
}
|
|
27404
27403
|
var recordProcessor = (schema, ctx, _json, params) => {
|
|
27405
|
-
const
|
|
27404
|
+
const json3 = _json;
|
|
27406
27405
|
const def = schema._zod.def;
|
|
27407
|
-
|
|
27406
|
+
json3.type = "object";
|
|
27408
27407
|
const keyType = def.keyType;
|
|
27409
27408
|
const patterns = aggregateChecks(keyType).patterns;
|
|
27410
27409
|
if (def.mode === "loose" && patterns && patterns.size > 0) {
|
|
@@ -27412,13 +27411,13 @@ var recordProcessor = (schema, ctx, _json, params) => {
|
|
|
27412
27411
|
...params,
|
|
27413
27412
|
path: [...params.path, "patternProperties", "*"]
|
|
27414
27413
|
});
|
|
27415
|
-
|
|
27414
|
+
json3.patternProperties = {};
|
|
27416
27415
|
for (const pattern of patterns) {
|
|
27417
|
-
assignProp(
|
|
27416
|
+
assignProp(json3.patternProperties, exactPattern(pattern).source, valueSchema);
|
|
27418
27417
|
}
|
|
27419
27418
|
} else {
|
|
27420
27419
|
if (ctx.target === "draft-07" || ctx.target === "draft-2020-12") {
|
|
27421
|
-
|
|
27420
|
+
json3.propertyNames = processSchema(def.keyType, ctx, {
|
|
27422
27421
|
...params,
|
|
27423
27422
|
path: [...params.path, "propertyNames"]
|
|
27424
27423
|
});
|
|
@@ -27430,7 +27429,7 @@ var recordProcessor = (schema, ctx, _json, params) => {
|
|
|
27430
27429
|
}
|
|
27431
27430
|
pending.push(schema);
|
|
27432
27431
|
}
|
|
27433
|
-
|
|
27432
|
+
json3.additionalProperties = processSchema(def.valueType, ctx, {
|
|
27434
27433
|
...params,
|
|
27435
27434
|
path: [...params.path, "additionalProperties"]
|
|
27436
27435
|
});
|
|
@@ -27440,19 +27439,19 @@ var recordProcessor = (schema, ctx, _json, params) => {
|
|
|
27440
27439
|
if (keyValues && !def.partial && !omittableOnInput) {
|
|
27441
27440
|
const validKeyValues = [...keyValues].filter((v) => typeof v === "string" || typeof v === "number");
|
|
27442
27441
|
if (validKeyValues.length > 0) {
|
|
27443
|
-
|
|
27442
|
+
json3.required = validKeyValues.map(String);
|
|
27444
27443
|
}
|
|
27445
27444
|
}
|
|
27446
27445
|
};
|
|
27447
|
-
var nullableProcessor = (schema, ctx,
|
|
27446
|
+
var nullableProcessor = (schema, ctx, json3, params) => {
|
|
27448
27447
|
const def = schema._zod.def;
|
|
27449
27448
|
const inner = processSchema(def.innerType, ctx, params);
|
|
27450
27449
|
const seen = ctx.seen.get(schema);
|
|
27451
27450
|
if (ctx.target === "openapi-3.0") {
|
|
27452
27451
|
seen.ref = def.innerType;
|
|
27453
|
-
|
|
27452
|
+
json3.nullable = true;
|
|
27454
27453
|
} else {
|
|
27455
|
-
|
|
27454
|
+
json3.anyOf = [inner, { type: "null" }];
|
|
27456
27455
|
}
|
|
27457
27456
|
};
|
|
27458
27457
|
var nonoptionalProcessor = (schema, ctx, _json, params) => {
|
|
@@ -27462,7 +27461,7 @@ var nonoptionalProcessor = (schema, ctx, _json, params) => {
|
|
|
27462
27461
|
seen.ref = def.innerType;
|
|
27463
27462
|
};
|
|
27464
27463
|
var UNREPRESENTABLE_DEFAULT = /* @__PURE__ */ Symbol();
|
|
27465
|
-
function serializeDefaultValue(value, schema, ctx,
|
|
27464
|
+
function serializeDefaultValue(value, schema, ctx, json3, params) {
|
|
27466
27465
|
let unrepresentable = false;
|
|
27467
27466
|
const serialized = JSON.stringify(value, (_, val) => {
|
|
27468
27467
|
if (typeof val !== "bigint")
|
|
@@ -27472,30 +27471,30 @@ function serializeDefaultValue(value, schema, ctx, json2, params) {
|
|
|
27472
27471
|
});
|
|
27473
27472
|
if (!unrepresentable)
|
|
27474
27473
|
return JSON.parse(serialized);
|
|
27475
|
-
handleUnrepresentable(schema, ctx,
|
|
27474
|
+
handleUnrepresentable(schema, ctx, json3, params, "BigInt defaults cannot be represented in JSON Schema");
|
|
27476
27475
|
return UNREPRESENTABLE_DEFAULT;
|
|
27477
27476
|
}
|
|
27478
|
-
var defaultProcessor = (schema, ctx,
|
|
27477
|
+
var defaultProcessor = (schema, ctx, json3, params) => {
|
|
27479
27478
|
const def = schema._zod.def;
|
|
27480
27479
|
processSchema(def.innerType, ctx, params);
|
|
27481
27480
|
const seen = ctx.seen.get(schema);
|
|
27482
27481
|
seen.ref = def.innerType;
|
|
27483
|
-
const value = serializeDefaultValue(def.defaultValue, schema, ctx,
|
|
27482
|
+
const value = serializeDefaultValue(def.defaultValue, schema, ctx, json3, params);
|
|
27484
27483
|
if (value !== UNREPRESENTABLE_DEFAULT)
|
|
27485
|
-
|
|
27484
|
+
json3.default = value;
|
|
27486
27485
|
};
|
|
27487
|
-
var prefaultProcessor = (schema, ctx,
|
|
27486
|
+
var prefaultProcessor = (schema, ctx, json3, params) => {
|
|
27488
27487
|
const def = schema._zod.def;
|
|
27489
27488
|
processSchema(def.innerType, ctx, params);
|
|
27490
27489
|
const seen = ctx.seen.get(schema);
|
|
27491
27490
|
seen.ref = def.innerType;
|
|
27492
27491
|
if (ctx.io !== "input")
|
|
27493
27492
|
return;
|
|
27494
|
-
const value = serializeDefaultValue(def.defaultValue, schema, ctx,
|
|
27493
|
+
const value = serializeDefaultValue(def.defaultValue, schema, ctx, json3, params);
|
|
27495
27494
|
if (value !== UNREPRESENTABLE_DEFAULT)
|
|
27496
|
-
|
|
27495
|
+
json3._prefault = value;
|
|
27497
27496
|
};
|
|
27498
|
-
var catchProcessor = (schema, ctx,
|
|
27497
|
+
var catchProcessor = (schema, ctx, json3, params) => {
|
|
27499
27498
|
const def = schema._zod.def;
|
|
27500
27499
|
processSchema(def.innerType, ctx, params);
|
|
27501
27500
|
const seen = ctx.seen.get(schema);
|
|
@@ -27504,10 +27503,10 @@ var catchProcessor = (schema, ctx, json2, params) => {
|
|
|
27504
27503
|
try {
|
|
27505
27504
|
catchValue = def.catchValue(void 0);
|
|
27506
27505
|
} catch {
|
|
27507
|
-
handleUnrepresentable(schema, ctx,
|
|
27506
|
+
handleUnrepresentable(schema, ctx, json3, params, "Dynamic catch values are not supported in JSON Schema");
|
|
27508
27507
|
return;
|
|
27509
27508
|
}
|
|
27510
|
-
|
|
27509
|
+
json3.default = catchValue;
|
|
27511
27510
|
};
|
|
27512
27511
|
var pipeProcessor = (schema, ctx, _json, params) => {
|
|
27513
27512
|
const def = schema._zod.def;
|
|
@@ -27517,12 +27516,12 @@ var pipeProcessor = (schema, ctx, _json, params) => {
|
|
|
27517
27516
|
const seen = ctx.seen.get(schema);
|
|
27518
27517
|
seen.ref = innerType;
|
|
27519
27518
|
};
|
|
27520
|
-
var readonlyProcessor = (schema, ctx,
|
|
27519
|
+
var readonlyProcessor = (schema, ctx, json3, params) => {
|
|
27521
27520
|
const def = schema._zod.def;
|
|
27522
27521
|
processSchema(def.innerType, ctx, params);
|
|
27523
27522
|
const seen = ctx.seen.get(schema);
|
|
27524
27523
|
seen.ref = def.innerType;
|
|
27525
|
-
|
|
27524
|
+
json3.readOnly = true;
|
|
27526
27525
|
};
|
|
27527
27526
|
var promiseProcessor = (schema, ctx, _json, params) => {
|
|
27528
27527
|
const def = schema._zod.def;
|
|
@@ -28164,7 +28163,7 @@ var _ZodString = /* @__PURE__ */ $constructor(
|
|
|
28164
28163
|
(inst, def) => {
|
|
28165
28164
|
$ZodString.init(inst, def);
|
|
28166
28165
|
ZodType.init(inst, def);
|
|
28167
|
-
inst._zod.processJSONSchema = (ctx,
|
|
28166
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => stringProcessor(inst, ctx, json3, params);
|
|
28168
28167
|
},
|
|
28169
28168
|
/* @__PURE__ */ util_exports.derived({
|
|
28170
28169
|
format: (inst) => aggregateChecks(inst).format ?? null,
|
|
@@ -28523,7 +28522,7 @@ var ZodNumber = /* @__PURE__ */ $constructor(
|
|
|
28523
28522
|
(inst, def) => {
|
|
28524
28523
|
$ZodNumber.init(inst, def);
|
|
28525
28524
|
ZodType.init(inst, def);
|
|
28526
|
-
inst._zod.processJSONSchema = (ctx,
|
|
28525
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => numberProcessor(inst, ctx, json3, params);
|
|
28527
28526
|
inst.isFinite = true;
|
|
28528
28527
|
},
|
|
28529
28528
|
/* @__PURE__ */ util_exports.derived({
|
|
@@ -28613,7 +28612,7 @@ function uint32(params) {
|
|
|
28613
28612
|
var ZodBoolean = /* @__PURE__ */ $constructor("ZodBoolean", (inst, def) => {
|
|
28614
28613
|
$ZodBoolean.init(inst, def);
|
|
28615
28614
|
ZodType.init(inst, def);
|
|
28616
|
-
inst._zod.processJSONSchema = (ctx,
|
|
28615
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => booleanProcessor(inst, ctx, json3, params);
|
|
28617
28616
|
});
|
|
28618
28617
|
function boolean2(params) {
|
|
28619
28618
|
return _boolean(ZodBoolean, params);
|
|
@@ -28623,7 +28622,7 @@ var ZodBigInt = /* @__PURE__ */ $constructor(
|
|
|
28623
28622
|
(inst, def) => {
|
|
28624
28623
|
$ZodBigInt.init(inst, def);
|
|
28625
28624
|
ZodType.init(inst, def);
|
|
28626
|
-
inst._zod.processJSONSchema = (ctx,
|
|
28625
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => bigintProcessor(inst, ctx, json3, params);
|
|
28627
28626
|
},
|
|
28628
28627
|
/* @__PURE__ */ util_exports.derived({
|
|
28629
28628
|
minValue: (inst) => aggregateChecks(inst).minimum ?? null,
|
|
@@ -28681,7 +28680,7 @@ function uint64(params) {
|
|
|
28681
28680
|
var ZodSymbol = /* @__PURE__ */ $constructor("ZodSymbol", (inst, def) => {
|
|
28682
28681
|
$ZodSymbol.init(inst, def);
|
|
28683
28682
|
ZodType.init(inst, def);
|
|
28684
|
-
inst._zod.processJSONSchema = (ctx,
|
|
28683
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => symbolProcessor(inst, ctx, json3, params);
|
|
28685
28684
|
});
|
|
28686
28685
|
function symbol(params) {
|
|
28687
28686
|
return _symbol(ZodSymbol, params);
|
|
@@ -28689,7 +28688,7 @@ function symbol(params) {
|
|
|
28689
28688
|
var ZodUndefined = /* @__PURE__ */ $constructor("ZodUndefined", (inst, def) => {
|
|
28690
28689
|
$ZodUndefined.init(inst, def);
|
|
28691
28690
|
ZodType.init(inst, def);
|
|
28692
|
-
inst._zod.processJSONSchema = (ctx,
|
|
28691
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => undefinedProcessor(inst, ctx, json3, params);
|
|
28693
28692
|
});
|
|
28694
28693
|
function _undefined3(params) {
|
|
28695
28694
|
return _undefined2(ZodUndefined, params);
|
|
@@ -28697,7 +28696,7 @@ function _undefined3(params) {
|
|
|
28697
28696
|
var ZodNull = /* @__PURE__ */ $constructor("ZodNull", (inst, def) => {
|
|
28698
28697
|
$ZodNull.init(inst, def);
|
|
28699
28698
|
ZodType.init(inst, def);
|
|
28700
|
-
inst._zod.processJSONSchema = (ctx,
|
|
28699
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => nullProcessor(inst, ctx, json3, params);
|
|
28701
28700
|
});
|
|
28702
28701
|
function _null3(params) {
|
|
28703
28702
|
return _null2(ZodNull, params);
|
|
@@ -28705,7 +28704,7 @@ function _null3(params) {
|
|
|
28705
28704
|
var ZodAny = /* @__PURE__ */ $constructor("ZodAny", (inst, def) => {
|
|
28706
28705
|
$ZodAny.init(inst, def);
|
|
28707
28706
|
ZodType.init(inst, def);
|
|
28708
|
-
inst._zod.processJSONSchema = (ctx,
|
|
28707
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => anyProcessor(inst, ctx, json3, params);
|
|
28709
28708
|
});
|
|
28710
28709
|
function any() {
|
|
28711
28710
|
return _any(ZodAny);
|
|
@@ -28713,7 +28712,7 @@ function any() {
|
|
|
28713
28712
|
var ZodUnknown = /* @__PURE__ */ $constructor("ZodUnknown", (inst, def) => {
|
|
28714
28713
|
$ZodUnknown.init(inst, def);
|
|
28715
28714
|
ZodType.init(inst, def);
|
|
28716
|
-
inst._zod.processJSONSchema = (ctx,
|
|
28715
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => unknownProcessor(inst, ctx, json3, params);
|
|
28717
28716
|
});
|
|
28718
28717
|
function unknown() {
|
|
28719
28718
|
return _unknown(ZodUnknown);
|
|
@@ -28721,7 +28720,7 @@ function unknown() {
|
|
|
28721
28720
|
var ZodNever = /* @__PURE__ */ $constructor("ZodNever", (inst, def) => {
|
|
28722
28721
|
$ZodNever.init(inst, def);
|
|
28723
28722
|
ZodType.init(inst, def);
|
|
28724
|
-
inst._zod.processJSONSchema = (ctx,
|
|
28723
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => neverProcessor(inst, ctx, json3, params);
|
|
28725
28724
|
});
|
|
28726
28725
|
function never(params) {
|
|
28727
28726
|
return _never(ZodNever, params);
|
|
@@ -28729,7 +28728,7 @@ function never(params) {
|
|
|
28729
28728
|
var ZodVoid = /* @__PURE__ */ $constructor("ZodVoid", (inst, def) => {
|
|
28730
28729
|
$ZodVoid.init(inst, def);
|
|
28731
28730
|
ZodType.init(inst, def);
|
|
28732
|
-
inst._zod.processJSONSchema = (ctx,
|
|
28731
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => voidProcessor(inst, ctx, json3, params);
|
|
28733
28732
|
});
|
|
28734
28733
|
function _void2(params) {
|
|
28735
28734
|
return _void(ZodVoid, params);
|
|
@@ -28739,7 +28738,7 @@ var ZodDate = /* @__PURE__ */ $constructor(
|
|
|
28739
28738
|
(inst, def) => {
|
|
28740
28739
|
$ZodDate.init(inst, def);
|
|
28741
28740
|
ZodType.init(inst, def);
|
|
28742
|
-
inst._zod.processJSONSchema = (ctx,
|
|
28741
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => dateProcessor(inst, ctx, json3, params);
|
|
28743
28742
|
inst.min = (value, params) => inst.check(_gte(value, params));
|
|
28744
28743
|
inst.max = (value, params) => inst.check(_lte(value, params));
|
|
28745
28744
|
},
|
|
@@ -28761,7 +28760,7 @@ var ZodArray = /* @__PURE__ */ $constructor("ZodArray", (inst, def) => {
|
|
|
28761
28760
|
_ensureDefaultMemoizer();
|
|
28762
28761
|
$ZodArray.init(inst, def);
|
|
28763
28762
|
ZodType.init(inst, def);
|
|
28764
|
-
inst._zod.processJSONSchema = (ctx,
|
|
28763
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => arrayProcessor(inst, ctx, json3, params);
|
|
28765
28764
|
inst.element = def.element;
|
|
28766
28765
|
}, {
|
|
28767
28766
|
min(n, params) {
|
|
@@ -28791,7 +28790,7 @@ var ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
|
|
|
28791
28790
|
_ensureDefaultMemoizer();
|
|
28792
28791
|
$ZodObjectJIT.init(inst, def);
|
|
28793
28792
|
ZodType.init(inst, def);
|
|
28794
|
-
inst._zod.processJSONSchema = (ctx,
|
|
28793
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => objectProcessor(inst, ctx, json3, params);
|
|
28795
28794
|
util_exports.installLazyProp(inst, "shape", (self2) => self2._zod.def.shape, false);
|
|
28796
28795
|
}, {
|
|
28797
28796
|
keyof() {
|
|
@@ -28864,7 +28863,7 @@ function looseObject(shape, params) {
|
|
|
28864
28863
|
var ZodUnion = /* @__PURE__ */ $constructor("ZodUnion", (inst, def) => {
|
|
28865
28864
|
$ZodUnion.init(inst, def);
|
|
28866
28865
|
ZodType.init(inst, def);
|
|
28867
|
-
inst._zod.processJSONSchema = (ctx,
|
|
28866
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => unionProcessor(inst, ctx, json3, params);
|
|
28868
28867
|
inst.options = def.options;
|
|
28869
28868
|
});
|
|
28870
28869
|
function union(options, params) {
|
|
@@ -28877,7 +28876,7 @@ function union(options, params) {
|
|
|
28877
28876
|
var ZodXor = /* @__PURE__ */ $constructor("ZodXor", (inst, def) => {
|
|
28878
28877
|
ZodUnion.init(inst, def);
|
|
28879
28878
|
$ZodXor.init(inst, def);
|
|
28880
|
-
inst._zod.processJSONSchema = (ctx,
|
|
28879
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => unionProcessor(inst, ctx, json3, params);
|
|
28881
28880
|
inst.options = def.options;
|
|
28882
28881
|
});
|
|
28883
28882
|
function xor(options, params) {
|
|
@@ -28903,7 +28902,7 @@ function discriminatedUnion(discriminator, options, params) {
|
|
|
28903
28902
|
var ZodIntersection = /* @__PURE__ */ $constructor("ZodIntersection", (inst, def) => {
|
|
28904
28903
|
$ZodIntersection.init(inst, def);
|
|
28905
28904
|
ZodType.init(inst, def);
|
|
28906
|
-
inst._zod.processJSONSchema = (ctx,
|
|
28905
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => intersectionProcessor(inst, ctx, json3, params);
|
|
28907
28906
|
});
|
|
28908
28907
|
function intersection(left, right) {
|
|
28909
28908
|
return new ZodIntersection({
|
|
@@ -28916,7 +28915,7 @@ var ZodTuple = /* @__PURE__ */ $constructor("ZodTuple", (inst, def) => {
|
|
|
28916
28915
|
_ensureDefaultMemoizer();
|
|
28917
28916
|
$ZodTuple.init(inst, def);
|
|
28918
28917
|
ZodType.init(inst, def);
|
|
28919
|
-
inst._zod.processJSONSchema = (ctx,
|
|
28918
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => tupleProcessor(inst, ctx, json3, params);
|
|
28920
28919
|
}, {
|
|
28921
28920
|
rest(rest) {
|
|
28922
28921
|
return this.clone({
|
|
@@ -28949,7 +28948,7 @@ var ZodRecord = /* @__PURE__ */ $constructor("ZodRecord", (inst, def) => {
|
|
|
28949
28948
|
_ensureDefaultMemoizer();
|
|
28950
28949
|
$ZodRecord.init(inst, def);
|
|
28951
28950
|
ZodType.init(inst, def);
|
|
28952
|
-
inst._zod.processJSONSchema = (ctx,
|
|
28951
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => recordProcessor(inst, ctx, json3, params);
|
|
28953
28952
|
inst.keyType = def.keyType;
|
|
28954
28953
|
inst.valueType = def.valueType;
|
|
28955
28954
|
});
|
|
@@ -28991,7 +28990,7 @@ var ZodMap = /* @__PURE__ */ $constructor("ZodMap", (inst, def) => {
|
|
|
28991
28990
|
_ensureDefaultMemoizer();
|
|
28992
28991
|
$ZodMap.init(inst, def);
|
|
28993
28992
|
ZodType.init(inst, def);
|
|
28994
|
-
inst._zod.processJSONSchema = (ctx,
|
|
28993
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => mapProcessor(inst, ctx, json3, params);
|
|
28995
28994
|
inst.keyType = def.keyType;
|
|
28996
28995
|
inst.valueType = def.valueType;
|
|
28997
28996
|
inst.min = (...args) => inst.check(_minSize(...args));
|
|
@@ -29011,7 +29010,7 @@ var ZodSet = /* @__PURE__ */ $constructor("ZodSet", (inst, def) => {
|
|
|
29011
29010
|
_ensureDefaultMemoizer();
|
|
29012
29011
|
$ZodSet.init(inst, def);
|
|
29013
29012
|
ZodType.init(inst, def);
|
|
29014
|
-
inst._zod.processJSONSchema = (ctx,
|
|
29013
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => setProcessor(inst, ctx, json3, params);
|
|
29015
29014
|
inst.min = (...args) => inst.check(_minSize(...args));
|
|
29016
29015
|
inst.nonempty = (params) => inst.check(_minSize(1, params));
|
|
29017
29016
|
inst.max = (...args) => inst.check(_maxSize(...args));
|
|
@@ -29027,7 +29026,7 @@ function set(valueType, params) {
|
|
|
29027
29026
|
var ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
|
|
29028
29027
|
$ZodEnum.init(inst, def);
|
|
29029
29028
|
ZodType.init(inst, def);
|
|
29030
|
-
inst._zod.processJSONSchema = (ctx,
|
|
29029
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => enumProcessor(inst, ctx, json3, params);
|
|
29031
29030
|
inst.enum = def.entries;
|
|
29032
29031
|
inst.options = [...inst._zod.values];
|
|
29033
29032
|
const keys = new Set(Object.keys(def.entries));
|
|
@@ -29080,7 +29079,7 @@ function nativeEnum(entries, params) {
|
|
|
29080
29079
|
var ZodLiteral = /* @__PURE__ */ $constructor("ZodLiteral", (inst, def) => {
|
|
29081
29080
|
$ZodLiteral.init(inst, def);
|
|
29082
29081
|
ZodType.init(inst, def);
|
|
29083
|
-
inst._zod.processJSONSchema = (ctx,
|
|
29082
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => literalProcessor(inst, ctx, json3, params);
|
|
29084
29083
|
inst.values = new Set(def.values);
|
|
29085
29084
|
Object.defineProperty(inst, "value", {
|
|
29086
29085
|
get() {
|
|
@@ -29101,7 +29100,7 @@ function literal(value, params) {
|
|
|
29101
29100
|
var ZodFile = /* @__PURE__ */ $constructor("ZodFile", (inst, def) => {
|
|
29102
29101
|
$ZodFile.init(inst, def);
|
|
29103
29102
|
ZodType.init(inst, def);
|
|
29104
|
-
inst._zod.processJSONSchema = (ctx,
|
|
29103
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => fileProcessor(inst, ctx, json3, params);
|
|
29105
29104
|
inst.min = (size, params) => inst.check(_minSize(size, params));
|
|
29106
29105
|
inst.max = (size, params) => inst.check(_maxSize(size, params));
|
|
29107
29106
|
inst.mime = (types, params) => inst.check(_mime(Array.isArray(types) ? types : [types], params));
|
|
@@ -29113,7 +29112,7 @@ var ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) => {
|
|
|
29113
29112
|
_ensureDefaultMemoizer();
|
|
29114
29113
|
$ZodTransform.init(inst, def);
|
|
29115
29114
|
ZodType.init(inst, def);
|
|
29116
|
-
inst._zod.processJSONSchema = (ctx,
|
|
29115
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => transformProcessor(inst, ctx, json3, params);
|
|
29117
29116
|
inst._zod.parse = (payload, _ctx) => {
|
|
29118
29117
|
if (_ctx.direction === "backward") {
|
|
29119
29118
|
throw new $ZodEncodeError(inst.constructor.name);
|
|
@@ -29152,7 +29151,7 @@ function transform(fn) {
|
|
|
29152
29151
|
var ZodOptional = /* @__PURE__ */ $constructor("ZodOptional", (inst, def) => {
|
|
29153
29152
|
$ZodOptional.init(inst, def);
|
|
29154
29153
|
ZodType.init(inst, def);
|
|
29155
|
-
inst._zod.processJSONSchema = (ctx,
|
|
29154
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => optionalProcessor(inst, ctx, json3, params);
|
|
29156
29155
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
29157
29156
|
});
|
|
29158
29157
|
function optional(innerType) {
|
|
@@ -29164,7 +29163,7 @@ function optional(innerType) {
|
|
|
29164
29163
|
var ZodExactOptional = /* @__PURE__ */ $constructor("ZodExactOptional", (inst, def) => {
|
|
29165
29164
|
$ZodExactOptional.init(inst, def);
|
|
29166
29165
|
ZodType.init(inst, def);
|
|
29167
|
-
inst._zod.processJSONSchema = (ctx,
|
|
29166
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => optionalProcessor(inst, ctx, json3, params);
|
|
29168
29167
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
29169
29168
|
});
|
|
29170
29169
|
function exactOptional(innerType) {
|
|
@@ -29176,7 +29175,7 @@ function exactOptional(innerType) {
|
|
|
29176
29175
|
var ZodNullable = /* @__PURE__ */ $constructor("ZodNullable", (inst, def) => {
|
|
29177
29176
|
$ZodNullable.init(inst, def);
|
|
29178
29177
|
ZodType.init(inst, def);
|
|
29179
|
-
inst._zod.processJSONSchema = (ctx,
|
|
29178
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => nullableProcessor(inst, ctx, json3, params);
|
|
29180
29179
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
29181
29180
|
});
|
|
29182
29181
|
function nullable(innerType) {
|
|
@@ -29191,7 +29190,7 @@ function nullish2(innerType) {
|
|
|
29191
29190
|
var ZodDefault = /* @__PURE__ */ $constructor("ZodDefault", (inst, def) => {
|
|
29192
29191
|
$ZodDefault.init(inst, def);
|
|
29193
29192
|
ZodType.init(inst, def);
|
|
29194
|
-
inst._zod.processJSONSchema = (ctx,
|
|
29193
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => defaultProcessor(inst, ctx, json3, params);
|
|
29195
29194
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
29196
29195
|
inst.removeDefault = inst.unwrap;
|
|
29197
29196
|
});
|
|
@@ -29207,7 +29206,7 @@ function _default2(innerType, defaultValue) {
|
|
|
29207
29206
|
var ZodPrefault = /* @__PURE__ */ $constructor("ZodPrefault", (inst, def) => {
|
|
29208
29207
|
$ZodPrefault.init(inst, def);
|
|
29209
29208
|
ZodType.init(inst, def);
|
|
29210
|
-
inst._zod.processJSONSchema = (ctx,
|
|
29209
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => prefaultProcessor(inst, ctx, json3, params);
|
|
29211
29210
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
29212
29211
|
});
|
|
29213
29212
|
function prefault(innerType, defaultValue) {
|
|
@@ -29222,7 +29221,7 @@ function prefault(innerType, defaultValue) {
|
|
|
29222
29221
|
var ZodNonOptional = /* @__PURE__ */ $constructor("ZodNonOptional", (inst, def) => {
|
|
29223
29222
|
$ZodNonOptional.init(inst, def);
|
|
29224
29223
|
ZodType.init(inst, def);
|
|
29225
|
-
inst._zod.processJSONSchema = (ctx,
|
|
29224
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => nonoptionalProcessor(inst, ctx, json3, params);
|
|
29226
29225
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
29227
29226
|
});
|
|
29228
29227
|
function nonoptional(innerType, params) {
|
|
@@ -29235,7 +29234,7 @@ function nonoptional(innerType, params) {
|
|
|
29235
29234
|
var ZodSuccess = /* @__PURE__ */ $constructor("ZodSuccess", (inst, def) => {
|
|
29236
29235
|
$ZodSuccess.init(inst, def);
|
|
29237
29236
|
ZodType.init(inst, def);
|
|
29238
|
-
inst._zod.processJSONSchema = (ctx,
|
|
29237
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => successProcessor(inst, ctx, json3, params);
|
|
29239
29238
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
29240
29239
|
});
|
|
29241
29240
|
function success(innerType) {
|
|
@@ -29247,7 +29246,7 @@ function success(innerType) {
|
|
|
29247
29246
|
var ZodCatch = /* @__PURE__ */ $constructor("ZodCatch", (inst, def) => {
|
|
29248
29247
|
$ZodCatch.init(inst, def);
|
|
29249
29248
|
ZodType.init(inst, def);
|
|
29250
|
-
inst._zod.processJSONSchema = (ctx,
|
|
29249
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => catchProcessor(inst, ctx, json3, params);
|
|
29251
29250
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
29252
29251
|
inst.removeCatch = inst.unwrap;
|
|
29253
29252
|
});
|
|
@@ -29261,7 +29260,7 @@ function _catch2(innerType, catchValue) {
|
|
|
29261
29260
|
var ZodNaN = /* @__PURE__ */ $constructor("ZodNaN", (inst, def) => {
|
|
29262
29261
|
$ZodNaN.init(inst, def);
|
|
29263
29262
|
ZodType.init(inst, def);
|
|
29264
|
-
inst._zod.processJSONSchema = (ctx,
|
|
29263
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => nanProcessor(inst, ctx, json3, params);
|
|
29265
29264
|
});
|
|
29266
29265
|
function nan(params) {
|
|
29267
29266
|
return _nan(ZodNaN, params);
|
|
@@ -29269,7 +29268,7 @@ function nan(params) {
|
|
|
29269
29268
|
var ZodPipe = /* @__PURE__ */ $constructor("ZodPipe", (inst, def) => {
|
|
29270
29269
|
$ZodPipe.init(inst, def);
|
|
29271
29270
|
ZodType.init(inst, def);
|
|
29272
|
-
inst._zod.processJSONSchema = (ctx,
|
|
29271
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => pipeProcessor(inst, ctx, json3, params);
|
|
29273
29272
|
inst.in = def.in;
|
|
29274
29273
|
inst.out = def.out;
|
|
29275
29274
|
});
|
|
@@ -29311,7 +29310,7 @@ var ZodPreprocess = /* @__PURE__ */ $constructor("ZodPreprocess", (inst, def) =>
|
|
|
29311
29310
|
var ZodReadonly = /* @__PURE__ */ $constructor("ZodReadonly", (inst, def) => {
|
|
29312
29311
|
$ZodReadonly.init(inst, def);
|
|
29313
29312
|
ZodType.init(inst, def);
|
|
29314
|
-
inst._zod.processJSONSchema = (ctx,
|
|
29313
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => readonlyProcessor(inst, ctx, json3, params);
|
|
29315
29314
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
29316
29315
|
});
|
|
29317
29316
|
function readonly(innerType) {
|
|
@@ -29323,7 +29322,7 @@ function readonly(innerType) {
|
|
|
29323
29322
|
var ZodTemplateLiteral = /* @__PURE__ */ $constructor("ZodTemplateLiteral", (inst, def) => {
|
|
29324
29323
|
$ZodTemplateLiteral.init(inst, def);
|
|
29325
29324
|
ZodType.init(inst, def);
|
|
29326
|
-
inst._zod.processJSONSchema = (ctx,
|
|
29325
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => templateLiteralProcessor(inst, ctx, json3, params);
|
|
29327
29326
|
});
|
|
29328
29327
|
function templateLiteral(parts, params) {
|
|
29329
29328
|
return new ZodTemplateLiteral({
|
|
@@ -29335,7 +29334,7 @@ function templateLiteral(parts, params) {
|
|
|
29335
29334
|
var ZodLazy = /* @__PURE__ */ $constructor("ZodLazy", (inst, def) => {
|
|
29336
29335
|
$ZodLazy.init(inst, def);
|
|
29337
29336
|
ZodType.init(inst, def);
|
|
29338
|
-
inst._zod.processJSONSchema = (ctx,
|
|
29337
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => lazyProcessor(inst, ctx, json3, params);
|
|
29339
29338
|
inst.unwrap = () => inst._zod.def.getter();
|
|
29340
29339
|
});
|
|
29341
29340
|
function lazy(getter) {
|
|
@@ -29347,7 +29346,7 @@ function lazy(getter) {
|
|
|
29347
29346
|
var ZodPromise = /* @__PURE__ */ $constructor("ZodPromise", (inst, def) => {
|
|
29348
29347
|
$ZodPromise.init(inst, def);
|
|
29349
29348
|
ZodType.init(inst, def);
|
|
29350
|
-
inst._zod.processJSONSchema = (ctx,
|
|
29349
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => promiseProcessor(inst, ctx, json3, params);
|
|
29351
29350
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
29352
29351
|
});
|
|
29353
29352
|
function promise(innerType) {
|
|
@@ -29359,7 +29358,7 @@ function promise(innerType) {
|
|
|
29359
29358
|
var ZodFunction = /* @__PURE__ */ $constructor("ZodFunction", (inst, def) => {
|
|
29360
29359
|
$ZodFunction.init(inst, def);
|
|
29361
29360
|
ZodType.init(inst, def);
|
|
29362
|
-
inst._zod.processJSONSchema = (ctx,
|
|
29361
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => functionProcessor(inst, ctx, json3, params);
|
|
29363
29362
|
});
|
|
29364
29363
|
function _function(params) {
|
|
29365
29364
|
return new ZodFunction({
|
|
@@ -29371,7 +29370,7 @@ function _function(params) {
|
|
|
29371
29370
|
var ZodCustom = /* @__PURE__ */ $constructor("ZodCustom", (inst, def) => {
|
|
29372
29371
|
$ZodCustom.init(inst, def);
|
|
29373
29372
|
ZodType.init(inst, def);
|
|
29374
|
-
inst._zod.processJSONSchema = (ctx,
|
|
29373
|
+
inst._zod.processJSONSchema = (ctx, json3, params) => customProcessor(inst, ctx, json3, params);
|
|
29375
29374
|
});
|
|
29376
29375
|
function check(fn) {
|
|
29377
29376
|
const ch = new $ZodCheck({
|
|
@@ -31135,7 +31134,7 @@ var HostRuntime = class {
|
|
|
31135
31134
|
this.clock.clearTimeout(this.mergeTimer);
|
|
31136
31135
|
this.mergeTimer = void 0;
|
|
31137
31136
|
}
|
|
31138
|
-
for (const [id
|
|
31137
|
+
for (const [id] of [...this.pending]) this.settle(id, void 0);
|
|
31139
31138
|
}
|
|
31140
31139
|
/** 手机发来的命令。`conversationId` 是配对通道 id,与载荷里的 sessionId 不是一回事(F3)。 */
|
|
31141
31140
|
async handleCommand(cmd, conversationId) {
|
|
@@ -32277,6 +32276,7 @@ function createServicesKernel(services, options) {
|
|
|
32277
32276
|
const freshSessions = /* @__PURE__ */ new Map();
|
|
32278
32277
|
const seenEventTypes = /* @__PURE__ */ new Set();
|
|
32279
32278
|
const unmappedEventTypes = /* @__PURE__ */ new Set();
|
|
32279
|
+
const injectedUserMessages = /* @__PURE__ */ new Map();
|
|
32280
32280
|
const listenerErrors = /* @__PURE__ */ new Map();
|
|
32281
32281
|
let approvalFace = "not-attached";
|
|
32282
32282
|
let questionsFace = "pending";
|
|
@@ -32308,17 +32308,6 @@ function createServicesKernel(services, options) {
|
|
|
32308
32308
|
const status = agent?.status;
|
|
32309
32309
|
return typeof status === "string" ? status : "idle";
|
|
32310
32310
|
}
|
|
32311
|
-
function sessionWorkspace(sessionId) {
|
|
32312
|
-
const get = fn(services.sessions, "get");
|
|
32313
|
-
if (!get || sessionId === "") return void 0;
|
|
32314
|
-
try {
|
|
32315
|
-
const session = get.call(services.sessions, sessionId);
|
|
32316
|
-
const cwd = session?.header?.cwd ?? session?.cwd;
|
|
32317
|
-
return typeof cwd === "string" && cwd !== "" ? cwd : void 0;
|
|
32318
|
-
} catch {
|
|
32319
|
-
return void 0;
|
|
32320
|
-
}
|
|
32321
|
-
}
|
|
32322
32311
|
function toSummary(record2, archived) {
|
|
32323
32312
|
const cached2 = titleCache.get(record2.id);
|
|
32324
32313
|
const running = agentStatus(record2.id) === "running";
|
|
@@ -32612,6 +32601,10 @@ function createServicesKernel(services, options) {
|
|
|
32612
32601
|
log("unmapped session event type", { type, keys: shapeOf(data) });
|
|
32613
32602
|
}
|
|
32614
32603
|
}
|
|
32604
|
+
if (type === "user/message" && !isHumanUserMessage(data)) {
|
|
32605
|
+
const kind = String(data.source?.kind ?? "?");
|
|
32606
|
+
injectedUserMessages.set(kind, (injectedUserMessages.get(kind) ?? 0) + 1);
|
|
32607
|
+
}
|
|
32615
32608
|
}
|
|
32616
32609
|
function translateAgentStatus(onEvent, args) {
|
|
32617
32610
|
const payload = args.find((arg) => arg && typeof arg === "object");
|
|
@@ -32741,7 +32734,6 @@ function createServicesKernel(services, options) {
|
|
|
32741
32734
|
subscribe,
|
|
32742
32735
|
attachInteractionSink,
|
|
32743
32736
|
ensureRunnable,
|
|
32744
|
-
sessionWorkspace,
|
|
32745
32737
|
// 与发指令/续跑走同一条读取路径:这里原来还有一份实现,而且是 `current()` 裸调用
|
|
32746
32738
|
// (不带 receiver;真要用 this 的服务方法会当场抛),两份迟早分叉。
|
|
32747
32739
|
modelSelection: currentSelection,
|
|
@@ -32756,9 +32748,6 @@ function createServicesKernel(services, options) {
|
|
|
32756
32748
|
// 新建会话只依赖这一条。和 historyFace 同理:真机上"新建没反应"第一件要分清的事
|
|
32757
32749
|
// 是宿主没有这个能力,还是我们没调对。
|
|
32758
32750
|
createFace: typeof fn(services.sessionController?.commands, "create") === "function" ? "commands.create" : `absent (keys=${shapeOf(services.sessionController)})`.slice(0, 120),
|
|
32759
|
-
// 二维码落点依赖这一条。它缺席时 PNG 会退回 ~/.dsh/,卡片上的路径会跟着变——
|
|
32760
|
-
// 用户看到"图不在工作区"时,第一件事就是看这个字段是不是 absent。
|
|
32761
|
-
workspaceFace: typeof fn(services.sessions, "get") === "function" ? "sessions.get" : `absent (keys=${shapeOf(services.sessions)})`.slice(0, 120),
|
|
32762
32751
|
agents: typeof services.agents === "object",
|
|
32763
32752
|
agentDefaultModel: typeof services.agentDefaultModel === "object",
|
|
32764
32753
|
workspaceRegistry: typeof services.workspaceRegistry === "object",
|
|
@@ -32769,6 +32758,7 @@ function createServicesKernel(services, options) {
|
|
|
32769
32758
|
// 真机排错的第一现场:内核到底发了哪些事件类型、其中哪些我们没认。
|
|
32770
32759
|
eventTypes: [...seenEventTypes].slice(-24).join("|"),
|
|
32771
32760
|
unmappedEventTypes: [...unmappedEventTypes].join("|"),
|
|
32761
|
+
injectedUserMessages: [...injectedUserMessages].map(([kind, count]) => `${count}\xD7${kind}`).join("|") || "none",
|
|
32772
32762
|
approvalFace,
|
|
32773
32763
|
questionsFace,
|
|
32774
32764
|
listenerErrors: [...listenerErrors].slice(0, 4).map(([key, count]) => `${count}\xD7${key}`).join(" | ") || "none"
|
|
@@ -32793,17 +32783,29 @@ function sessionEventKernelEvents(input2) {
|
|
|
32793
32783
|
case "turn/start":
|
|
32794
32784
|
return [{ kind: "run-state", sessionId, state: "running" }];
|
|
32795
32785
|
case "assistant/message":
|
|
32796
|
-
case "user/message":
|
|
32797
32786
|
return [
|
|
32798
32787
|
{
|
|
32799
32788
|
kind: "delta",
|
|
32800
32789
|
sessionId,
|
|
32801
32790
|
messageId: messageIdOf(data, input2.seq),
|
|
32802
32791
|
text: textOf(data),
|
|
32803
|
-
role:
|
|
32792
|
+
role: "assistant",
|
|
32804
32793
|
done: true
|
|
32805
32794
|
}
|
|
32806
32795
|
];
|
|
32796
|
+
case "user/message": {
|
|
32797
|
+
if (!isHumanUserMessage(data)) return [];
|
|
32798
|
+
return [
|
|
32799
|
+
{
|
|
32800
|
+
kind: "delta",
|
|
32801
|
+
sessionId,
|
|
32802
|
+
messageId: messageIdOf(data, input2.seq),
|
|
32803
|
+
text: textOf(data),
|
|
32804
|
+
role: "user",
|
|
32805
|
+
done: true
|
|
32806
|
+
}
|
|
32807
|
+
];
|
|
32808
|
+
}
|
|
32807
32809
|
case "tool/call": {
|
|
32808
32810
|
const argsRaw = data.arguments ?? data.args;
|
|
32809
32811
|
return [
|
|
@@ -32941,6 +32943,14 @@ function charCountOf(event) {
|
|
|
32941
32943
|
if (event.kind === "tool") return (event.resultPreview ?? "").length + (event.argsPreview ?? "").length;
|
|
32942
32944
|
return 0;
|
|
32943
32945
|
}
|
|
32946
|
+
function isHumanUserMessage(data) {
|
|
32947
|
+
const source = data?.source;
|
|
32948
|
+
if (source === void 0 || source === null) return true;
|
|
32949
|
+
if (typeof source !== "object") return true;
|
|
32950
|
+
const kind = source.kind;
|
|
32951
|
+
if (typeof kind !== "string" || !kind) return true;
|
|
32952
|
+
return kind === "user";
|
|
32953
|
+
}
|
|
32944
32954
|
function textOf(data) {
|
|
32945
32955
|
const content = eventContent(data);
|
|
32946
32956
|
if (typeof content === "string") return content;
|
|
@@ -33023,7 +33033,6 @@ function createOneShotTimers(clock) {
|
|
|
33023
33033
|
|
|
33024
33034
|
// src/shell/status.ts
|
|
33025
33035
|
import { mkdirSync, renameSync, writeFileSync } from "node:fs";
|
|
33026
|
-
import { homedir } from "node:os";
|
|
33027
33036
|
import path from "node:path";
|
|
33028
33037
|
var StatusFile = class {
|
|
33029
33038
|
constructor(file2, clock, refreshMs = 3e3) {
|
|
@@ -33035,7 +33044,6 @@ var StatusFile = class {
|
|
|
33035
33044
|
clock;
|
|
33036
33045
|
refreshMs;
|
|
33037
33046
|
timer;
|
|
33038
|
-
lastWritten = 0;
|
|
33039
33047
|
write(snapshot) {
|
|
33040
33048
|
if (!this.file) return;
|
|
33041
33049
|
try {
|
|
@@ -33049,7 +33057,6 @@ var StatusFile = class {
|
|
|
33049
33057
|
}
|
|
33050
33058
|
);
|
|
33051
33059
|
renameSync(tmp, this.file);
|
|
33052
|
-
this.lastWritten = this.clock.now();
|
|
33053
33060
|
} catch {
|
|
33054
33061
|
}
|
|
33055
33062
|
}
|
|
@@ -33078,47 +33085,10 @@ var StatusFile = class {
|
|
|
33078
33085
|
this.timer = void 0;
|
|
33079
33086
|
}
|
|
33080
33087
|
}
|
|
33081
|
-
/** 此刻是否在按节拍刷新(测试与 status 自身的 `refreshing` 字段读它)。 */
|
|
33082
|
-
get refreshing() {
|
|
33083
|
-
return this.timer !== void 0;
|
|
33084
|
-
}
|
|
33085
|
-
get path() {
|
|
33086
|
-
return this.file;
|
|
33087
|
-
}
|
|
33088
33088
|
};
|
|
33089
|
-
function pairingImagePath(statusFile, workspaceDir) {
|
|
33090
|
-
if (!statusFile) return "";
|
|
33091
|
-
if (workspaceDir) return path.join(workspaceDir, ".dsh", "pairing-qr.png");
|
|
33092
|
-
return path.join(homedir(), ".dsh", "pairing-qr.png");
|
|
33093
|
-
}
|
|
33094
|
-
function writePrivateFile(file2, data) {
|
|
33095
|
-
if (!file2) return false;
|
|
33096
|
-
try {
|
|
33097
|
-
mkdirSync(path.dirname(file2), { recursive: true });
|
|
33098
|
-
writeFileSync(file2, data, { mode: 384 });
|
|
33099
|
-
return true;
|
|
33100
|
-
} catch {
|
|
33101
|
-
return false;
|
|
33102
|
-
}
|
|
33103
|
-
}
|
|
33104
|
-
|
|
33105
|
-
// src/shell/pairing-text.ts
|
|
33106
|
-
var PAIR_UNAVAILABLE_TEXT = "\u4E2D\u7EE7\u8FD8\u6CA1\u8FDE\u4E0A\uFF0C\u6682\u65F6\u65E0\u6CD5\u914D\u5BF9\u3002\u770B status.json \u7684 relayProblem\u3002";
|
|
33107
|
-
function pairingPairText(view) {
|
|
33108
|
-
const ttlSec = Math.max(0, Math.round((view.expiresAt - view.now) / 1e3));
|
|
33109
|
-
const lines = [`\u914D\u5BF9\u7801 ${view.token} \xB7 ${ttlSec} \u79D2\u5185\u6709\u6548 \xB7 \u4E00\u6B21\u6027`, "\u5C0F\u7A0B\u5E8F\u91CC\u626B\u7801\uFF0C\u6216\u624B\u8F93\u8FD9 6 \u4F4D\u6570\u5B57\u3002"];
|
|
33110
|
-
if (view.qrImage && view.imageFile) {
|
|
33111
|
-
lines.push("", `\u4E8C\u7EF4\u7801\u4F1A\u81EA\u52A8\u5F39\u51FA\u5230\u53F3\u680F\uFF1B\u6CA1\u5F39\u51FA\u5C31\u6253\u5F00\u8FD9\u5F20 PNG \u518D\u626B\uFF1A${view.imageFile}`);
|
|
33112
|
-
} else if (view.terminalQr) {
|
|
33113
|
-
lines.push("", view.terminalQr);
|
|
33114
|
-
}
|
|
33115
|
-
lines.push("", view.qr);
|
|
33116
|
-
if (!view.qrImage) lines.push("", "\uFF08\u5982\u9700\u56FE\u7247\u7248\uFF1A\u628A patch \u91CC\u7684 qrImage \u8BBE\u4E3A true\uFF09");
|
|
33117
|
-
return lines.join("\n");
|
|
33118
|
-
}
|
|
33119
33089
|
|
|
33120
33090
|
// src/shell/config.ts
|
|
33121
|
-
import { homedir
|
|
33091
|
+
import { homedir } from "node:os";
|
|
33122
33092
|
import path2 from "node:path";
|
|
33123
33093
|
var DEFAULT_CONFIG = {
|
|
33124
33094
|
enabled: true,
|
|
@@ -33129,30 +33099,18 @@ var DEFAULT_CONFIG = {
|
|
|
33129
33099
|
hostLabel: "dsh-host",
|
|
33130
33100
|
keepAwake: { enabled: true, idleReleaseSec: 300, keepDisplay: false },
|
|
33131
33101
|
mockBridge: false,
|
|
33132
|
-
statusFile: path2.join(
|
|
33102
|
+
statusFile: path2.join(homedir(), ".dsh", "dsh-remote-control", "status.json"),
|
|
33133
33103
|
unarchiveOnPrompt: true,
|
|
33134
33104
|
pairOnStartSec: 0,
|
|
33135
33105
|
pairTtlMs: 12e4,
|
|
33136
|
-
// **默认走图片**。2026-10-02 取证推翻了原判断(原判断:文本二维码在任何等宽渲染器下
|
|
33137
|
-
// 都能扫,图片是可有可无的旁路):
|
|
33138
|
-
// · DSH 命令卡的等宽输出块是 `white-space: pre` + `line-height: 1.6`(app bundle 里
|
|
33139
|
-
// 的那条规则,实测行间留白约占行高 37%),每两行模块之间被塞进一条整行宽的缝隙,
|
|
33140
|
-
// 半块二维码被横切成条。
|
|
33141
|
-
// · 用用户真机贴出来的那段输出做受控实验:把字号行距调到 1.0 时 zxing 解得出来,
|
|
33142
|
-
// 调到 ≥1.15 就扫不出来;而 DSH 固定 1.6。也就是说"文本码能扫"在**唯一宿主**上不成立。
|
|
33143
|
-
// · 而 ANSI 反色救不了:TerminalBlock 把每行渲染成内联 span,背景只覆盖字形盒,
|
|
33144
|
-
// 不覆盖行间留白(见 dsh-client-ui-primitives 的 parseAnsiLines/renderLine)。
|
|
33145
|
-
// 图片是自包含位图矩阵,跟宿主的行高、字体、配色都无关——这才是"扫得出来"的那条路。
|
|
33146
|
-
qrImage: true,
|
|
33147
|
-
// 写图片 ≠ 替用户打开查看器:仍然默认关(原话「不要用打开一个图片的方式」)。
|
|
33148
|
-
qrOpen: false,
|
|
33149
|
-
qrAnsi: false,
|
|
33150
|
-
qrStyle: "half",
|
|
33151
33106
|
carrierGraceMs: 5e3,
|
|
33152
33107
|
takeOverQuestions: false,
|
|
33153
33108
|
approvalTimeoutSec: 180,
|
|
33154
33109
|
listingRefreshSec: 15,
|
|
33155
|
-
conversationIdleTtlSec: 86400
|
|
33110
|
+
conversationIdleTtlSec: 86400,
|
|
33111
|
+
// 配对的唯一入口。关掉它 = 这台主机**没有**配对入口(`/drc pair` 与文本二维码都在
|
|
33112
|
+
// 2026-10-03 删掉了),所以 index.ts 会把它记成一条 warn 而不是安静地什么都不做。
|
|
33113
|
+
pill: { enabled: true }
|
|
33156
33114
|
};
|
|
33157
33115
|
var loopback = /^wss?:\/\/(localhost|127\.0\.0\.1|\[::1\])(:|\/|$)/;
|
|
33158
33116
|
var wsUrl = /^wss?:\/\/.+/;
|
|
@@ -33169,20 +33127,17 @@ function readConfig(injected, env = process.env) {
|
|
|
33169
33127
|
const merged = {
|
|
33170
33128
|
...DEFAULT_CONFIG,
|
|
33171
33129
|
...injected ?? {},
|
|
33172
|
-
keepAwake: { ...DEFAULT_CONFIG.keepAwake, ...injected?.keepAwake ?? {} }
|
|
33130
|
+
keepAwake: { ...DEFAULT_CONFIG.keepAwake, ...injected?.keepAwake ?? {} },
|
|
33131
|
+
// 逐键合并:patch 里只写 `pill.enabled` 时不能把整个对象覆盖掉(虽然它现在只有一个键,
|
|
33132
|
+
// 但"注入对象整体替换默认对象"这个形状在 keepAwake 上已经坑过一次)。
|
|
33133
|
+
pill: { ...DEFAULT_CONFIG.pill, ...injected?.pill ?? {} }
|
|
33173
33134
|
};
|
|
33174
33135
|
const fromEnv = (name) => env[name];
|
|
33175
33136
|
if (fromEnv("DRC_SERVER_URL")) merged.serverUrl = env.DRC_SERVER_URL;
|
|
33176
33137
|
if (fromEnv("DRC_HOST_LABEL")) merged.hostLabel = env.DRC_HOST_LABEL;
|
|
33177
33138
|
if (fromEnv("DRC_HOST_ID")) merged.hostId = env.DRC_HOST_ID;
|
|
33178
33139
|
if (fromEnv("DRC_PAIR_ON_START_SEC")) merged.pairOnStartSec = envSeconds(env.DRC_PAIR_ON_START_SEC);
|
|
33179
|
-
if (fromEnv("
|
|
33180
|
-
if (fromEnv("DRC_QR_OPEN")) merged.qrOpen = envFlag(env.DRC_QR_OPEN, merged.qrOpen);
|
|
33181
|
-
if (fromEnv("DRC_QR_ANSI")) merged.qrAnsi = envFlag(env.DRC_QR_ANSI, merged.qrAnsi);
|
|
33182
|
-
if (fromEnv("DRC_QR_STYLE")) {
|
|
33183
|
-
const style = env.DRC_QR_STYLE;
|
|
33184
|
-
if (["ascii", "block", "half"].includes(style)) merged.qrStyle = style;
|
|
33185
|
-
}
|
|
33140
|
+
if (fromEnv("DRC_PILL")) merged.pill.enabled = envFlag(env.DRC_PILL, merged.pill.enabled);
|
|
33186
33141
|
if (fromEnv("DRC_MOCK_BRIDGE") === "1") merged.mockBridge = true;
|
|
33187
33142
|
if (fromEnv("DRC_TAKE_OVER_QUESTIONS") === "1") merged.takeOverQuestions = true;
|
|
33188
33143
|
if (merged.hostTokenEnv) merged.hostToken = env[merged.hostTokenEnv] ?? merged.hostToken;
|
|
@@ -33233,21 +33188,6 @@ function validateConfig(config2) {
|
|
|
33233
33188
|
problems.push({ level: "warn", field: "pairOnStartSec", message: "\u5FC5\u987B\u662F\u975E\u8D1F\u7684\u6709\u9650\u79D2\u6570\uFF0C\u5DF2\u6298\u56DE 0\uFF08\u5173\u95ED\u81EA\u52A8\u53D1\u7801\uFF09" });
|
|
33234
33189
|
config2.pairOnStartSec = 0;
|
|
33235
33190
|
}
|
|
33236
|
-
if (config2.qrOpen && !config2.qrImage) {
|
|
33237
|
-
problems.push({
|
|
33238
|
-
level: "warn",
|
|
33239
|
-
field: "qrOpen",
|
|
33240
|
-
message: "qrOpen \u9700\u8981 qrImage=true \u624D\u4F1A\u5199\u56FE\u7247\u6587\u4EF6\uFF1B\u73B0\u5728\u53EA\u51FA\u6587\u672C\u4E8C\u7EF4\u7801\uFF08\u6587\u672C\u7801\u5728 DSH \u547D\u4EE4\u5361\u91CC\u626B\u4E0D\u51FA\u6765\uFF0C\u89C1 config.ts \u9ED8\u8BA4\u503C\u6CE8\u91CA\uFF09"
|
|
33241
|
-
});
|
|
33242
|
-
}
|
|
33243
|
-
if (!["ascii", "block", "half"].includes(config2.qrStyle)) {
|
|
33244
|
-
problems.push({
|
|
33245
|
-
level: "warn",
|
|
33246
|
-
field: "qrStyle",
|
|
33247
|
-
message: `qrStyle \u53EA\u8BA4 ascii/block/half\uFF0C\u6536\u5230 ${JSON.stringify(config2.qrStyle)}\uFF0C\u5DF2\u9000\u56DE half`
|
|
33248
|
-
});
|
|
33249
|
-
config2.qrStyle = "half";
|
|
33250
|
-
}
|
|
33251
33191
|
if (!secondsSchema.safeParse(config2.conversationIdleTtlSec).success || config2.conversationIdleTtlSec <= 0) {
|
|
33252
33192
|
problems.push({
|
|
33253
33193
|
level: "warn",
|
|
@@ -33275,53 +33215,16 @@ function validateConfig(config2) {
|
|
|
33275
33215
|
}
|
|
33276
33216
|
return problems;
|
|
33277
33217
|
}
|
|
33278
|
-
function
|
|
33218
|
+
function redact(value) {
|
|
33279
33219
|
if (value.length <= 8) return "****";
|
|
33280
33220
|
return `${value.slice(0, 4)}\u2026${value.slice(-2)}(${value.length})`;
|
|
33281
33221
|
}
|
|
33282
33222
|
|
|
33223
|
+
// src/pill/routes.ts
|
|
33224
|
+
import { createHash as createHash2 } from "node:crypto";
|
|
33225
|
+
|
|
33283
33226
|
// src/platform/qr.ts
|
|
33284
33227
|
var import_qrcode = __toESM(require_lib(), 1);
|
|
33285
|
-
async function qrMatrix(text, ecc = "M", quietZone = 2) {
|
|
33286
|
-
const qr = import_qrcode.default.create(text, { errorCorrectionLevel: ecc });
|
|
33287
|
-
const size = qr.modules.size;
|
|
33288
|
-
const total = size + quietZone * 2;
|
|
33289
|
-
const out = [];
|
|
33290
|
-
for (let y = 0; y < total; y++) {
|
|
33291
|
-
const row = [];
|
|
33292
|
-
for (let x = 0; x < total; x++) {
|
|
33293
|
-
const mx = x - quietZone;
|
|
33294
|
-
const my = y - quietZone;
|
|
33295
|
-
const dark = mx >= 0 && mx < size && my >= 0 && my < size && Boolean(qr.modules.get(my, mx));
|
|
33296
|
-
row.push(dark);
|
|
33297
|
-
}
|
|
33298
|
-
out.push(row);
|
|
33299
|
-
}
|
|
33300
|
-
return out;
|
|
33301
|
-
}
|
|
33302
|
-
async function renderTerminalQr(text, options = {}) {
|
|
33303
|
-
const { ecc = "M", quietZone = 2, style = "ascii", ansi = false } = options;
|
|
33304
|
-
const matrix = await qrMatrix(text, ecc, quietZone);
|
|
33305
|
-
let body;
|
|
33306
|
-
if (style === "half") {
|
|
33307
|
-
const lines = [];
|
|
33308
|
-
for (let y = 0; y < matrix.length; y += 2) {
|
|
33309
|
-
const top = matrix[y];
|
|
33310
|
-
const bottom = matrix[y + 1] ?? top.map(() => false);
|
|
33311
|
-
let line = "";
|
|
33312
|
-
for (let x = 0; x < top.length; x++) {
|
|
33313
|
-
line += top[x] && bottom[x] ? "\u2588" : top[x] ? "\u2580" : bottom[x] ? "\u2584" : " ";
|
|
33314
|
-
}
|
|
33315
|
-
lines.push(line);
|
|
33316
|
-
}
|
|
33317
|
-
body = lines.join("\n");
|
|
33318
|
-
} else {
|
|
33319
|
-
const dark = style === "ascii" ? "##" : "\u2588\u2588";
|
|
33320
|
-
const light = style === "ascii" ? ".." : " ";
|
|
33321
|
-
body = matrix.map((row) => row.map((cell) => cell ? dark : light).join("")).join("\n");
|
|
33322
|
-
}
|
|
33323
|
-
return ansi ? `\x1B[30;107m${body}\x1B[0m` : body;
|
|
33324
|
-
}
|
|
33325
33228
|
async function qrPng(text, options = {}) {
|
|
33326
33229
|
return import_qrcode.default.toBuffer(text, {
|
|
33327
33230
|
errorCorrectionLevel: options.ecc ?? "M",
|
|
@@ -33331,6 +33234,277 @@ async function qrPng(text, options = {}) {
|
|
|
33331
33234
|
});
|
|
33332
33235
|
}
|
|
33333
33236
|
|
|
33237
|
+
// src/pill/routes.ts
|
|
33238
|
+
var PAIR_NEW_ROUTE = "/plugins/dsh-remote-control/pairing/new";
|
|
33239
|
+
var PAIR_IMAGE_ROUTE = "/plugins/dsh-remote-control/pairing.png";
|
|
33240
|
+
var PAIR_STATUS_ROUTE = "/plugins/dsh-remote-control/status";
|
|
33241
|
+
var PAIR_MARKER_HEADER = "x-drc-pair";
|
|
33242
|
+
var PAIR_MARKER_VALUE = "1";
|
|
33243
|
+
function pairingEpoch(qr) {
|
|
33244
|
+
return createHash2("sha256").update(qr).digest("hex").slice(0, 16);
|
|
33245
|
+
}
|
|
33246
|
+
async function renderPairingPng(qr) {
|
|
33247
|
+
return qrPng(qr);
|
|
33248
|
+
}
|
|
33249
|
+
var LOOPBACK_HOSTS = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "::1", "[::1]"]);
|
|
33250
|
+
function hostnameOf(host) {
|
|
33251
|
+
const trimmed = host.trim().toLowerCase();
|
|
33252
|
+
if (trimmed.startsWith("[")) {
|
|
33253
|
+
const end = trimmed.indexOf("]");
|
|
33254
|
+
if (end === -1) return trimmed;
|
|
33255
|
+
const rest = trimmed.slice(end + 1);
|
|
33256
|
+
if (rest !== "" && !/^:\d+$/.test(rest)) return trimmed;
|
|
33257
|
+
return trimmed.slice(0, end + 1);
|
|
33258
|
+
}
|
|
33259
|
+
const colon = trimmed.lastIndexOf(":");
|
|
33260
|
+
if (colon !== -1 && !trimmed.slice(0, colon).includes(":") && /^\d+$/.test(trimmed.slice(colon + 1))) {
|
|
33261
|
+
return trimmed.slice(0, colon);
|
|
33262
|
+
}
|
|
33263
|
+
return trimmed;
|
|
33264
|
+
}
|
|
33265
|
+
function hostIsLoopback(host) {
|
|
33266
|
+
if (host === void 0 || host.trim() === "") return false;
|
|
33267
|
+
return LOOPBACK_HOSTS.has(hostnameOf(host));
|
|
33268
|
+
}
|
|
33269
|
+
function originIsLoopbackOrAbsent(origin) {
|
|
33270
|
+
if (origin === void 0 || origin.trim() === "") return true;
|
|
33271
|
+
return originLooksLikeTheHostItself(origin);
|
|
33272
|
+
}
|
|
33273
|
+
function originLooksLikeTheHostItself(origin) {
|
|
33274
|
+
try {
|
|
33275
|
+
const url2 = new URL(origin);
|
|
33276
|
+
if (url2.protocol !== "http:" && url2.protocol !== "https:") return origin.trim() !== "null";
|
|
33277
|
+
return LOOPBACK_HOSTS.has(url2.hostname);
|
|
33278
|
+
} catch {
|
|
33279
|
+
return false;
|
|
33280
|
+
}
|
|
33281
|
+
}
|
|
33282
|
+
function rejectedBy(request) {
|
|
33283
|
+
if (!hostIsLoopback(request.headers.host)) return "host-not-loopback";
|
|
33284
|
+
if (request.headers[PAIR_MARKER_HEADER] !== PAIR_MARKER_VALUE) return "pair-marker-missing";
|
|
33285
|
+
const origin = request.headers.origin;
|
|
33286
|
+
if (origin !== void 0 && origin.trim() !== "" && !originLooksLikeTheHostItself(origin)) return "origin-not-trusted";
|
|
33287
|
+
return void 0;
|
|
33288
|
+
}
|
|
33289
|
+
function json2(response, status, body) {
|
|
33290
|
+
const payload = JSON.stringify(body);
|
|
33291
|
+
response.writeHead(status, { "Content-Type": "application/json", "Content-Length": Buffer.byteLength(payload) });
|
|
33292
|
+
response.end(payload);
|
|
33293
|
+
}
|
|
33294
|
+
function pairNewHandler(deps) {
|
|
33295
|
+
return (request, response) => {
|
|
33296
|
+
if (request.method !== "POST") {
|
|
33297
|
+
json2(response, 405, { error: "method not allowed" });
|
|
33298
|
+
return;
|
|
33299
|
+
}
|
|
33300
|
+
const guard = rejectedBy(request);
|
|
33301
|
+
if (guard) {
|
|
33302
|
+
deps.log("\u53D1\u7801\u8BF7\u6C42\u88AB\u5B88\u536B\u62D2", { guard });
|
|
33303
|
+
json2(response, 403, { error: "request-not-trusted", guard });
|
|
33304
|
+
return;
|
|
33305
|
+
}
|
|
33306
|
+
try {
|
|
33307
|
+
const pairing = deps.ensureFresh();
|
|
33308
|
+
if (!pairing) {
|
|
33309
|
+
json2(response, 200, { state: "unavailable", reason: "relay-offline" });
|
|
33310
|
+
return;
|
|
33311
|
+
}
|
|
33312
|
+
deps.log("\u914D\u5BF9\u7801\u7ECF\u72B6\u6001\u680F\u53D1\u51FA", { token: pairing.token });
|
|
33313
|
+
json2(response, 200, {
|
|
33314
|
+
state: "ready",
|
|
33315
|
+
epoch: pairingEpoch(pairing.qr),
|
|
33316
|
+
token: pairing.token,
|
|
33317
|
+
expiresInMs: Math.max(0, pairing.expiresAt - Date.now())
|
|
33318
|
+
});
|
|
33319
|
+
} catch (error62) {
|
|
33320
|
+
json2(response, 500, { error: String(error62?.message ?? error62).slice(0, 200) });
|
|
33321
|
+
}
|
|
33322
|
+
};
|
|
33323
|
+
}
|
|
33324
|
+
function pairImageHandler(deps) {
|
|
33325
|
+
return async (request, response) => {
|
|
33326
|
+
if (request.method !== "GET" && request.method !== "HEAD") {
|
|
33327
|
+
json2(response, 405, { error: "method not allowed" });
|
|
33328
|
+
return;
|
|
33329
|
+
}
|
|
33330
|
+
if (!hostIsLoopback(request.headers.host) || !originIsLoopbackOrAbsent(request.headers.origin)) {
|
|
33331
|
+
json2(response, 403, { error: "request-not-trusted" });
|
|
33332
|
+
return;
|
|
33333
|
+
}
|
|
33334
|
+
try {
|
|
33335
|
+
const pairing = deps.current();
|
|
33336
|
+
if (!pairing) {
|
|
33337
|
+
response.writeHead(204);
|
|
33338
|
+
response.end();
|
|
33339
|
+
return;
|
|
33340
|
+
}
|
|
33341
|
+
const png = await renderPairingPng(pairing.qr);
|
|
33342
|
+
response.writeHead(200, {
|
|
33343
|
+
"Content-Type": "image/png",
|
|
33344
|
+
"Content-Length": png.length,
|
|
33345
|
+
// 一张码会被就地换掉(半程刷新、被手机用掉),所以绝不许缓存。
|
|
33346
|
+
// ETag 给的是这一版的哈希,pill 拿它判断要不要重画,省掉撕票式的刷新。
|
|
33347
|
+
"Cache-Control": "no-store",
|
|
33348
|
+
ETag: `"${pairingEpoch(pairing.qr)}"`
|
|
33349
|
+
});
|
|
33350
|
+
response.end(request.method === "HEAD" ? void 0 : png);
|
|
33351
|
+
} catch (error62) {
|
|
33352
|
+
json2(response, 500, { error: String(error62?.message ?? error62).slice(0, 200) });
|
|
33353
|
+
}
|
|
33354
|
+
};
|
|
33355
|
+
}
|
|
33356
|
+
function pillStatusHandler(deps) {
|
|
33357
|
+
return (request, response) => {
|
|
33358
|
+
if (request.method !== "GET" && request.method !== "HEAD") {
|
|
33359
|
+
json2(response, 405, { error: "method not allowed" });
|
|
33360
|
+
return;
|
|
33361
|
+
}
|
|
33362
|
+
if (!hostIsLoopback(request.headers.host) || !originIsLoopbackOrAbsent(request.headers.origin)) {
|
|
33363
|
+
json2(response, 403, { error: "request-not-trusted" });
|
|
33364
|
+
return;
|
|
33365
|
+
}
|
|
33366
|
+
try {
|
|
33367
|
+
const status = deps.status();
|
|
33368
|
+
json2(response, 200, {
|
|
33369
|
+
relay: status.relay,
|
|
33370
|
+
paired: status.paired,
|
|
33371
|
+
hostLabel: status.hostLabel,
|
|
33372
|
+
serverUrl: status.serverUrl
|
|
33373
|
+
});
|
|
33374
|
+
} catch (error62) {
|
|
33375
|
+
json2(response, 500, { error: String(error62?.message ?? error62).slice(0, 200) });
|
|
33376
|
+
}
|
|
33377
|
+
};
|
|
33378
|
+
}
|
|
33379
|
+
function registerPillRoutes(webServer, deps) {
|
|
33380
|
+
const off = [];
|
|
33381
|
+
const definitions = [
|
|
33382
|
+
{ kind: "exact", path: PAIR_NEW_ROUTE, handler: pairNewHandler(deps) },
|
|
33383
|
+
{ kind: "exact", path: PAIR_IMAGE_ROUTE, handler: pairImageHandler(deps) },
|
|
33384
|
+
{ kind: "exact", path: PAIR_STATUS_ROUTE, handler: pillStatusHandler(deps) }
|
|
33385
|
+
];
|
|
33386
|
+
try {
|
|
33387
|
+
for (const definition of definitions) off.push(webServer.register(definition));
|
|
33388
|
+
} catch (error62) {
|
|
33389
|
+
for (const unregister of off.splice(0)) {
|
|
33390
|
+
try {
|
|
33391
|
+
unregister();
|
|
33392
|
+
} catch {
|
|
33393
|
+
}
|
|
33394
|
+
}
|
|
33395
|
+
throw error62;
|
|
33396
|
+
}
|
|
33397
|
+
return () => {
|
|
33398
|
+
for (const unregister of off) {
|
|
33399
|
+
try {
|
|
33400
|
+
unregister();
|
|
33401
|
+
} catch {
|
|
33402
|
+
}
|
|
33403
|
+
}
|
|
33404
|
+
};
|
|
33405
|
+
}
|
|
33406
|
+
|
|
33407
|
+
// src/pill/start.ts
|
|
33408
|
+
function startPill(ctx, deps) {
|
|
33409
|
+
const { log } = deps;
|
|
33410
|
+
const probe = {};
|
|
33411
|
+
let web;
|
|
33412
|
+
let unregister;
|
|
33413
|
+
let started = false;
|
|
33414
|
+
let stopped = false;
|
|
33415
|
+
const tryStart = () => {
|
|
33416
|
+
if (started || stopped || !web) return;
|
|
33417
|
+
started = true;
|
|
33418
|
+
try {
|
|
33419
|
+
unregister = registerPillRoutes(web, {
|
|
33420
|
+
ensureFresh: () => deps.ensureFresh(),
|
|
33421
|
+
current: () => deps.current(),
|
|
33422
|
+
status: () => deps.status(),
|
|
33423
|
+
log
|
|
33424
|
+
});
|
|
33425
|
+
probe.routes = "registered";
|
|
33426
|
+
} catch (error62) {
|
|
33427
|
+
probe.routes = `register threw: ${String(error62?.message ?? error62).slice(0, 80)}`;
|
|
33428
|
+
started = false;
|
|
33429
|
+
log("pill \u8DEF\u7531\u6CE8\u518C\u5931\u8D25\uFF08\u914D\u5BF9\u94FE\u8DEF\u4E0D\u53D7\u5F71\u54CD\uFF09", {
|
|
33430
|
+
message: String(error62?.message ?? error62).slice(0, 200)
|
|
33431
|
+
});
|
|
33432
|
+
return;
|
|
33433
|
+
}
|
|
33434
|
+
log("pill routes started");
|
|
33435
|
+
};
|
|
33436
|
+
const acceptWebServer = (value, via) => {
|
|
33437
|
+
if (!value || typeof value !== "object") return false;
|
|
33438
|
+
if (typeof value.register !== "function") {
|
|
33439
|
+
probe.webServer = "object without register()";
|
|
33440
|
+
return false;
|
|
33441
|
+
}
|
|
33442
|
+
web = value;
|
|
33443
|
+
probe.webServer = via;
|
|
33444
|
+
tryStart();
|
|
33445
|
+
return true;
|
|
33446
|
+
};
|
|
33447
|
+
const pickFrom = (source) => {
|
|
33448
|
+
if (!source || typeof source !== "object") return void 0;
|
|
33449
|
+
const asContext = source;
|
|
33450
|
+
if (typeof asContext.get === "function") {
|
|
33451
|
+
try {
|
|
33452
|
+
const got = asContext.get("webServer", true);
|
|
33453
|
+
if (got) return got;
|
|
33454
|
+
} catch {
|
|
33455
|
+
}
|
|
33456
|
+
}
|
|
33457
|
+
try {
|
|
33458
|
+
return source["webServer"];
|
|
33459
|
+
} catch {
|
|
33460
|
+
return void 0;
|
|
33461
|
+
}
|
|
33462
|
+
};
|
|
33463
|
+
if (!deps.enabled) {
|
|
33464
|
+
probe.pill = "disabled";
|
|
33465
|
+
} else {
|
|
33466
|
+
try {
|
|
33467
|
+
const found = ctx.get?.("webServer", true);
|
|
33468
|
+
if (found) acceptWebServer(found, "via get");
|
|
33469
|
+
else probe.webServer = "none";
|
|
33470
|
+
} catch (error62) {
|
|
33471
|
+
probe.webServer = `get threw: ${String(error62?.message ?? error62).slice(0, 80)}`;
|
|
33472
|
+
}
|
|
33473
|
+
try {
|
|
33474
|
+
ctx.inject?.(["webServer"], ((...args) => {
|
|
33475
|
+
try {
|
|
33476
|
+
for (const candidate of [args[0], ...args, ctx]) {
|
|
33477
|
+
if (acceptWebServer(pickFrom(candidate), "via inject")) return;
|
|
33478
|
+
}
|
|
33479
|
+
probe.webServer = `${probe.webServer ?? "none"} (inject fired, empty)`;
|
|
33480
|
+
} catch (error62) {
|
|
33481
|
+
probe["injectThrew:webServer"] = String(error62?.message ?? error62).slice(0, 160);
|
|
33482
|
+
}
|
|
33483
|
+
}));
|
|
33484
|
+
} catch (error62) {
|
|
33485
|
+
probe["injectThrew:webServer"] = String(error62?.message ?? error62).slice(0, 160);
|
|
33486
|
+
}
|
|
33487
|
+
}
|
|
33488
|
+
const stop = () => {
|
|
33489
|
+
if (stopped) return;
|
|
33490
|
+
stopped = true;
|
|
33491
|
+
const off = unregister;
|
|
33492
|
+
unregister = void 0;
|
|
33493
|
+
try {
|
|
33494
|
+
off?.();
|
|
33495
|
+
} catch {
|
|
33496
|
+
}
|
|
33497
|
+
if (started) log("pill routes stopped");
|
|
33498
|
+
};
|
|
33499
|
+
return {
|
|
33500
|
+
stop,
|
|
33501
|
+
probe,
|
|
33502
|
+
get available() {
|
|
33503
|
+
return started && probe.routes === "registered";
|
|
33504
|
+
}
|
|
33505
|
+
};
|
|
33506
|
+
}
|
|
33507
|
+
|
|
33334
33508
|
// src/index.ts
|
|
33335
33509
|
var SERVICE_NAMES = [
|
|
33336
33510
|
"sessions",
|
|
@@ -33360,11 +33534,7 @@ function apply(ctx, injected = {}) {
|
|
|
33360
33534
|
get state() {
|
|
33361
33535
|
return handle?.state() ?? { relay: "offline", carrier: "none", reason: "not-started" };
|
|
33362
33536
|
},
|
|
33363
|
-
createPairing: () => handle?.createPairing() ?? null
|
|
33364
|
-
// presentation 那一半要按会话解析落点(右栏那张图放哪),而"会话 → 工作区"这点
|
|
33365
|
-
// 平台知识只在本插件里有。**在这里开一个口,而不是让那一半自己去探内核服务**:
|
|
33366
|
-
// 两份探测迟早分叉,而分叉的表现是"卡片说 A 地、右栏读 B 地",很难查。
|
|
33367
|
-
sessionWorkspace: (sessionId) => handle?.sessionWorkspace(sessionId)
|
|
33537
|
+
createPairing: () => handle?.createPairing() ?? null
|
|
33368
33538
|
});
|
|
33369
33539
|
} catch {
|
|
33370
33540
|
}
|
|
@@ -33427,6 +33597,7 @@ function applyInner(ctx, injected) {
|
|
|
33427
33597
|
let runtime;
|
|
33428
33598
|
let relay;
|
|
33429
33599
|
let startedCarrier = "";
|
|
33600
|
+
let pillRoutes;
|
|
33430
33601
|
let lastRelayState = "connecting";
|
|
33431
33602
|
let lastRelayProblem;
|
|
33432
33603
|
let lastRelayGeneration = 0;
|
|
@@ -33531,11 +33702,21 @@ function applyInner(ctx, injected) {
|
|
|
33531
33702
|
// 出站计数:手机上"没收到 X"的第一现场对比点(插件没发 vs 发了但路上丢了)。
|
|
33532
33703
|
outbound: runtime?.stats ?? null,
|
|
33533
33704
|
probe,
|
|
33705
|
+
// 配对入口(那颗 pill 的三条路由)为什么没起,是"配不了对"唯一的排查入口:
|
|
33706
|
+
// 这里直接把软探测的结果带出来。
|
|
33707
|
+
pill: pillRoutes?.probe ?? { webServer: "not-started" },
|
|
33534
33708
|
// token 永远不出现真值;这条有测试锁住。
|
|
33535
33709
|
hostToken: void 0,
|
|
33536
|
-
hostTokenShape: config2.hostToken ?
|
|
33710
|
+
hostTokenShape: config2.hostToken ? redact(config2.hostToken) : void 0,
|
|
33537
33711
|
mockBridgeForced: config2.mockBridge,
|
|
33538
|
-
problems:
|
|
33712
|
+
problems: [
|
|
33713
|
+
...problems.map((problem) => `${problem.level}:${problem.field}`),
|
|
33714
|
+
// **每次快照现判,不在 apply 里 push 一次**。`webServer` 可能是 `ctx.inject` 的回调
|
|
33715
|
+
// 晚到才拿到的,apply 返回那一刻 `available` 还是 false——留在 apply 里就会写出
|
|
33716
|
+
// `routes:"registered"` 与 `problems:["warn:pill"]` 并存的假警报
|
|
33717
|
+
// (2026-10-03 真机重启后实测抓到)。为什么没挂上从同一个快照的 `pill` 探针读。
|
|
33718
|
+
...pillRoutes?.available ? [] : ["warn:pill"]
|
|
33719
|
+
],
|
|
33539
33720
|
...config2.pairOnStartSec > 0 ? { pairOnStartWarn: "status.json \u91CC\u5E26\u7740\u4ECD\u7136\u6709\u6548\u7684\u914D\u5BF9\u7801\u4E0E PSK" } : {}
|
|
33540
33721
|
};
|
|
33541
33722
|
};
|
|
@@ -33568,6 +33749,25 @@ function applyInner(ctx, injected) {
|
|
|
33568
33749
|
return created;
|
|
33569
33750
|
};
|
|
33570
33751
|
const createPairing = () => wrappedPublish();
|
|
33752
|
+
function currentPairing() {
|
|
33753
|
+
const shown = active.pairing;
|
|
33754
|
+
if (!shown) return null;
|
|
33755
|
+
if (!slots.resolveFor(shown.token)) return null;
|
|
33756
|
+
return { qr: shown.qr, token: shown.token, expiresAt: shown.expiresAt };
|
|
33757
|
+
}
|
|
33758
|
+
function ensureFreshPairing() {
|
|
33759
|
+
const fresh = currentPairing() ?? createPairing();
|
|
33760
|
+
if (!fresh) return null;
|
|
33761
|
+
return { qr: fresh.qr, token: fresh.token, expiresAt: fresh.expiresAt };
|
|
33762
|
+
}
|
|
33763
|
+
function pillStatus() {
|
|
33764
|
+
return {
|
|
33765
|
+
relay: relay ? relayState() : "idle",
|
|
33766
|
+
paired: relay?.conversationCount ?? 0,
|
|
33767
|
+
hostLabel: config2.hostLabel,
|
|
33768
|
+
serverUrl: config2.serverUrl
|
|
33769
|
+
};
|
|
33770
|
+
}
|
|
33571
33771
|
const pairingWindow = new PairingWindow(
|
|
33572
33772
|
{
|
|
33573
33773
|
clock,
|
|
@@ -33584,7 +33784,6 @@ function applyInner(ctx, injected) {
|
|
|
33584
33784
|
);
|
|
33585
33785
|
const collected = {};
|
|
33586
33786
|
const hasServices = () => typeof collected.sessions === "object" && collected.sessions !== null;
|
|
33587
|
-
const apiProxyOf = () => collected.apiProxy;
|
|
33588
33787
|
const probe = {};
|
|
33589
33788
|
const injectFired = [];
|
|
33590
33789
|
let hasGet = true;
|
|
@@ -33602,9 +33801,6 @@ function applyInner(ctx, injected) {
|
|
|
33602
33801
|
start(createServicesKernel(collected, { log, takeOverQuestions: config2.takeOverQuestions, clock }));
|
|
33603
33802
|
return;
|
|
33604
33803
|
}
|
|
33605
|
-
if (typeof ctx.get?.("apiProxy", true) === "object") {
|
|
33606
|
-
log("apiProxy present but unsupported by this build", { hint: "\u53EA\u505A\u8BCA\u65AD\u8BB0\u5F55\uFF0C\u4E0D\u63A5\u8FD9\u6761\u8F7D\u4F53" });
|
|
33607
|
-
}
|
|
33608
33804
|
};
|
|
33609
33805
|
const requiredMember = { sessions: "list", sessionQuery: "listSessions", agents: "get" };
|
|
33610
33806
|
const keysOf = (value) => {
|
|
@@ -33816,23 +34012,6 @@ function applyInner(ctx, injected) {
|
|
|
33816
34012
|
} catch {
|
|
33817
34013
|
}
|
|
33818
34014
|
}
|
|
33819
|
-
try {
|
|
33820
|
-
const proxy = ctx.get?.("apiProxy", true);
|
|
33821
|
-
if (proxy) collected.apiProxy = proxy;
|
|
33822
|
-
} catch {
|
|
33823
|
-
}
|
|
33824
|
-
try {
|
|
33825
|
-
ctx.inject?.(["apiProxy"], ((scoped) => {
|
|
33826
|
-
const value = scoped?.get?.("apiProxy", true);
|
|
33827
|
-
if (!value) return;
|
|
33828
|
-
collected.apiProxy = value;
|
|
33829
|
-
if (!decided) {
|
|
33830
|
-
oneShot.schedule(tryStart, config2.carrierGraceMs);
|
|
33831
|
-
}
|
|
33832
|
-
tryStart();
|
|
33833
|
-
}));
|
|
33834
|
-
} catch {
|
|
33835
|
-
}
|
|
33836
34015
|
tryStart();
|
|
33837
34016
|
if (!runtime && config2.mockBridge) {
|
|
33838
34017
|
decided = true;
|
|
@@ -33841,44 +34020,29 @@ function applyInner(ctx, injected) {
|
|
|
33841
34020
|
}
|
|
33842
34021
|
if (!runtime) {
|
|
33843
34022
|
status.write({ ...state(), carrier: "none", reason: "no-carrier", probe });
|
|
33844
|
-
log("no kernel carrier available", { hint: "\u9700\u8981 sessions
|
|
34023
|
+
log("no kernel carrier available", { hint: "\u9700\u8981 sessions \u670D\u52A1\uFF0C\u6216\u628A mockBridge \u6253\u5F00\u505A\u5F00\u53D1" });
|
|
34024
|
+
}
|
|
34025
|
+
try {
|
|
34026
|
+
pillRoutes = startPill(ctx, {
|
|
34027
|
+
enabled: config2.pill.enabled,
|
|
34028
|
+
// 三条路由要的三件事:幂等发码、只读看当前码、读连接状态。
|
|
34029
|
+
ensureFresh: () => ensureFreshPairing(),
|
|
34030
|
+
current: () => currentPairing(),
|
|
34031
|
+
status: () => pillStatus(),
|
|
34032
|
+
log
|
|
34033
|
+
});
|
|
34034
|
+
} catch (error62) {
|
|
34035
|
+
pillRoutes = void 0;
|
|
34036
|
+
log("pill start threw\uFF08\u914D\u5BF9\u94FE\u8DEF\u4E0D\u53D7\u5F71\u54CD\uFF09", {
|
|
34037
|
+
message: String(error62?.message ?? error62).slice(0, 200)
|
|
34038
|
+
});
|
|
33845
34039
|
}
|
|
33846
|
-
const workspaceOfInvocation = (invocation) => {
|
|
33847
|
-
const agent = invocation?.agent;
|
|
33848
|
-
const sessionId = typeof agent?.session?.id === "string" ? agent.session.id : "";
|
|
33849
|
-
if (sessionId === "") return void 0;
|
|
33850
|
-
try {
|
|
33851
|
-
return kernel?.sessionWorkspace?.(sessionId);
|
|
33852
|
-
} catch {
|
|
33853
|
-
return void 0;
|
|
33854
|
-
}
|
|
33855
|
-
};
|
|
33856
34040
|
const commandDefinition = {
|
|
33857
34041
|
name: "drc",
|
|
33858
|
-
description: "DSH \u8FDC\u7A0B\u63A7\u5236\uFF1A\
|
|
33859
|
-
input: { hint: "
|
|
34042
|
+
description: "DSH \u8FDC\u7A0B\u63A7\u5236\uFF1A\u914D\u5BF9\u8BF7\u70B9\u72B6\u6001\u680F\u7684 dsh-remote-control\uFF1B/drc status \u770B\u8FDE\u63A5\u4E0E\u95EE\u9898\uFF0C/drc unpair \u89E3\u914D",
|
|
34043
|
+
input: { hint: "status | unpair" },
|
|
33860
34044
|
handler: async (invocation) => {
|
|
33861
34045
|
const argument = String(invocation.rawInput ?? "").trim().toLowerCase();
|
|
33862
|
-
if (argument.startsWith("pair")) {
|
|
33863
|
-
const pairing = createPairing();
|
|
33864
|
-
if (!pairing) return { kind: "success", text: PAIR_UNAVAILABLE_TEXT };
|
|
33865
|
-
const workspaceDir = workspaceOfInvocation(invocation);
|
|
33866
|
-
const imageFile = config2.qrImage ? pairingImagePath(config2.statusFile, workspaceDir) : "";
|
|
33867
|
-
if (imageFile) writePairingImage(imageFile, pairing.qr, config2, log);
|
|
33868
|
-
const terminal = config2.qrImage ? void 0 : await renderTerminalQr(pairing.qr, { style: config2.qrStyle, ansi: config2.qrAnsi });
|
|
33869
|
-
return {
|
|
33870
|
-
kind: "success",
|
|
33871
|
-
text: pairingPairText({
|
|
33872
|
-
token: pairing.token,
|
|
33873
|
-
qr: pairing.qr,
|
|
33874
|
-
expiresAt: pairing.expiresAt,
|
|
33875
|
-
now: clock.now(),
|
|
33876
|
-
qrImage: config2.qrImage,
|
|
33877
|
-
imageFile,
|
|
33878
|
-
terminalQr: terminal
|
|
33879
|
-
})
|
|
33880
|
-
};
|
|
33881
|
-
}
|
|
33882
34046
|
if (argument.startsWith("unpair")) {
|
|
33883
34047
|
for (const id of relay?.conversationIds() ?? []) relay?.voidConversation(id);
|
|
33884
34048
|
return { kind: "success", text: '\u5DF2\u89E3\u9664\u6240\u6709\u914D\u5BF9\uFF1B\u624B\u673A\u7AEF\u4F1A\u663E\u793A"\u4E3B\u673A\u5DF2\u65AD\u5F00\uFF0C\u8BF7\u91CD\u65B0\u914D\u5BF9"\u3002' };
|
|
@@ -33917,15 +34081,9 @@ function applyInner(ctx, injected) {
|
|
|
33917
34081
|
config: config2,
|
|
33918
34082
|
state,
|
|
33919
34083
|
createPairing,
|
|
33920
|
-
sessionWorkspace(sessionId) {
|
|
33921
|
-
try {
|
|
33922
|
-
return kernel?.sessionWorkspace?.(sessionId);
|
|
33923
|
-
} catch {
|
|
33924
|
-
return void 0;
|
|
33925
|
-
}
|
|
33926
|
-
},
|
|
33927
34084
|
stop() {
|
|
33928
34085
|
oneShot.cancelAll();
|
|
34086
|
+
pillRoutes?.stop();
|
|
33929
34087
|
status.stop();
|
|
33930
34088
|
runtime?.stop();
|
|
33931
34089
|
relay?.stop();
|
|
@@ -33933,20 +34091,6 @@ function applyInner(ctx, injected) {
|
|
|
33933
34091
|
}
|
|
33934
34092
|
};
|
|
33935
34093
|
}
|
|
33936
|
-
function writePairingImage(file2, qrText, config2, log) {
|
|
33937
|
-
if (!config2.qrImage || !file2) return;
|
|
33938
|
-
qrPng(qrText).then((buffer) => {
|
|
33939
|
-
if (!writePrivateFile(file2, buffer)) {
|
|
33940
|
-
log("qr png write failed", { file: file2 });
|
|
33941
|
-
return;
|
|
33942
|
-
}
|
|
33943
|
-
if (!config2.qrOpen) return;
|
|
33944
|
-
const opener = process.platform === "darwin" ? "open" : process.platform === "win32" ? "cmd" : "xdg-open";
|
|
33945
|
-
const args = process.platform === "win32" ? ["/c", "start", "", file2] : [file2];
|
|
33946
|
-
execFile(opener, args, () => {
|
|
33947
|
-
});
|
|
33948
|
-
}).catch((error62) => log("qr png render failed", { message: String(error62?.message ?? error62) }));
|
|
33949
|
-
}
|
|
33950
34094
|
export {
|
|
33951
34095
|
DEFAULT_CONFIG,
|
|
33952
34096
|
apply,
|