@agentconnect.md/computer 2.12.0-rc.11 → 2.12.0-rc.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agentconnect-computer.mjs +1794 -1529
- package/package.json +1 -1
|
@@ -23952,7 +23952,7 @@ var require_x509_cjs = __commonJS({
|
|
|
23952
23952
|
}
|
|
23953
23953
|
toJSON() {
|
|
23954
23954
|
var _a4;
|
|
23955
|
-
const
|
|
23955
|
+
const json5 = [];
|
|
23956
23956
|
for (const rdn of this.asn) {
|
|
23957
23957
|
const jsonItem = {};
|
|
23958
23958
|
for (const attr of rdn) {
|
|
@@ -23960,9 +23960,9 @@ var require_x509_cjs = __commonJS({
|
|
|
23960
23960
|
(_a4 = jsonItem[type]) !== null && _a4 !== void 0 ? _a4 : jsonItem[type] = [];
|
|
23961
23961
|
jsonItem[type].push(attr.value.anyValue ? `#${pvtsutils.Convert.ToHex(attr.value.anyValue)}` : attr.value.toString());
|
|
23962
23962
|
}
|
|
23963
|
-
|
|
23963
|
+
json5.push(jsonItem);
|
|
23964
23964
|
}
|
|
23965
|
-
return
|
|
23965
|
+
return json5;
|
|
23966
23966
|
}
|
|
23967
23967
|
fromString(data) {
|
|
23968
23968
|
const asn = new asn1X509.Name();
|
|
@@ -48370,13 +48370,13 @@ function initializeContext(params) {
|
|
|
48370
48370
|
external: params?.external ?? void 0
|
|
48371
48371
|
};
|
|
48372
48372
|
}
|
|
48373
|
-
function handleUnrepresentable(schema, ctx,
|
|
48373
|
+
function handleUnrepresentable(schema, ctx, json5, params, message) {
|
|
48374
48374
|
const result = typeof ctx.unrepresentable === "function" ? ctx.unrepresentable({ zodSchema: schema, path: params.path, message }) : ctx.unrepresentable;
|
|
48375
48375
|
if (result === "any")
|
|
48376
48376
|
return false;
|
|
48377
48377
|
if (result === void 0 || result === "throw")
|
|
48378
48378
|
throw new Error(message);
|
|
48379
|
-
Object.assign(
|
|
48379
|
+
Object.assign(json5, result);
|
|
48380
48380
|
return true;
|
|
48381
48381
|
}
|
|
48382
48382
|
function processSchema(schema, ctx, _params = { path: [], schemaPath: [] }) {
|
|
@@ -48612,12 +48612,12 @@ function foldObjects(members2) {
|
|
|
48612
48612
|
}
|
|
48613
48613
|
return folded;
|
|
48614
48614
|
}
|
|
48615
|
-
function foldIntersection(
|
|
48616
|
-
const allOf =
|
|
48615
|
+
function foldIntersection(json5) {
|
|
48616
|
+
const allOf = json5.allOf;
|
|
48617
48617
|
if (!Array.isArray(allOf) || allOf.length < 2)
|
|
48618
48618
|
return;
|
|
48619
48619
|
for (const key of FOLDABLE_KEYS)
|
|
48620
|
-
if (key in
|
|
48620
|
+
if (key in json5)
|
|
48621
48621
|
return;
|
|
48622
48622
|
const unions = allOf.filter((m) => UNION_KEYS.some((k) => Array.isArray(m[k])));
|
|
48623
48623
|
let folded = null;
|
|
@@ -48636,8 +48636,8 @@ function foldIntersection(json4) {
|
|
|
48636
48636
|
}
|
|
48637
48637
|
if (!folded)
|
|
48638
48638
|
return;
|
|
48639
|
-
delete
|
|
48640
|
-
assignProps(
|
|
48639
|
+
delete json5.allOf;
|
|
48640
|
+
assignProps(json5, folded);
|
|
48641
48641
|
}
|
|
48642
48642
|
function finalize(ctx, schema) {
|
|
48643
48643
|
const root = ctx.seen.get(schema);
|
|
@@ -48719,20 +48719,20 @@ function finalize(ctx, schema) {
|
|
|
48719
48719
|
if (ctx.intersections.length) {
|
|
48720
48720
|
const carriers = /* @__PURE__ */ new Map();
|
|
48721
48721
|
for (const seen of ctx.seen.values()) {
|
|
48722
|
-
for (const
|
|
48723
|
-
const allOf =
|
|
48722
|
+
for (const json5 of [seen.schema, seen.def]) {
|
|
48723
|
+
const allOf = json5?.allOf;
|
|
48724
48724
|
if (!Array.isArray(allOf))
|
|
48725
48725
|
continue;
|
|
48726
48726
|
const existing = carriers.get(allOf);
|
|
48727
48727
|
if (existing)
|
|
48728
|
-
existing.push(
|
|
48728
|
+
existing.push(json5);
|
|
48729
48729
|
else
|
|
48730
|
-
carriers.set(allOf, [
|
|
48730
|
+
carriers.set(allOf, [json5]);
|
|
48731
48731
|
}
|
|
48732
48732
|
}
|
|
48733
48733
|
for (const allOf of ctx.intersections) {
|
|
48734
|
-
for (const
|
|
48735
|
-
foldIntersection(
|
|
48734
|
+
for (const json5 of carriers.get(allOf) ?? [])
|
|
48735
|
+
foldIntersection(json5);
|
|
48736
48736
|
}
|
|
48737
48737
|
}
|
|
48738
48738
|
}
|
|
@@ -48968,29 +48968,29 @@ var exactPatterns = /* @__PURE__ */ new Map([
|
|
|
48968
48968
|
]);
|
|
48969
48969
|
var exactPattern = (p) => exactPatterns.get(p) ?? p;
|
|
48970
48970
|
var stringProcessor = (schema, ctx, _json, _params) => {
|
|
48971
|
-
const
|
|
48972
|
-
|
|
48971
|
+
const json5 = _json;
|
|
48972
|
+
json5.type = "string";
|
|
48973
48973
|
const { minimum, maximum, format, patterns, contentEncoding, laxFormat } = aggregateChecks(schema);
|
|
48974
48974
|
if (typeof minimum === "number")
|
|
48975
|
-
|
|
48975
|
+
json5.minLength = minimum;
|
|
48976
48976
|
if (typeof maximum === "number")
|
|
48977
|
-
|
|
48977
|
+
json5.maxLength = maximum;
|
|
48978
48978
|
if (format) {
|
|
48979
|
-
|
|
48980
|
-
if (
|
|
48981
|
-
delete
|
|
48979
|
+
json5.format = formatMap[format] ?? format;
|
|
48980
|
+
if (json5.format === "")
|
|
48981
|
+
delete json5.format;
|
|
48982
48982
|
if (format === "time" || laxFormat) {
|
|
48983
|
-
delete
|
|
48983
|
+
delete json5.format;
|
|
48984
48984
|
}
|
|
48985
48985
|
}
|
|
48986
48986
|
if (contentEncoding)
|
|
48987
|
-
|
|
48987
|
+
json5.contentEncoding = contentEncoding;
|
|
48988
48988
|
if (patterns && patterns.size > 0) {
|
|
48989
48989
|
const patternList = [...patterns].map(exactPattern);
|
|
48990
48990
|
if (patternList.length === 1)
|
|
48991
|
-
|
|
48991
|
+
json5.pattern = patternList[0].source;
|
|
48992
48992
|
else if (patternList.length > 1) {
|
|
48993
|
-
|
|
48993
|
+
json5.allOf = [
|
|
48994
48994
|
...patternList.map((regex) => ({
|
|
48995
48995
|
...ctx.target === "draft-07" || ctx.target === "draft-04" || ctx.target === "openapi-3.0" ? { type: "string" } : {},
|
|
48996
48996
|
pattern: regex.source
|
|
@@ -49000,31 +49000,31 @@ var stringProcessor = (schema, ctx, _json, _params) => {
|
|
|
49000
49000
|
}
|
|
49001
49001
|
};
|
|
49002
49002
|
var numberProcessor = (schema, ctx, _json, params) => {
|
|
49003
|
-
const
|
|
49003
|
+
const json5 = _json;
|
|
49004
49004
|
const { minimum, maximum, multipleOf, exclusiveMaximum, exclusiveMinimum, isInt } = aggregateChecks(schema);
|
|
49005
|
-
|
|
49005
|
+
json5.type = isInt ? "integer" : "number";
|
|
49006
49006
|
const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
|
|
49007
49007
|
const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
|
|
49008
49008
|
const legacy = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
|
|
49009
49009
|
if (exMin) {
|
|
49010
49010
|
if (legacy) {
|
|
49011
|
-
|
|
49012
|
-
|
|
49011
|
+
json5.minimum = exclusiveMinimum;
|
|
49012
|
+
json5.exclusiveMinimum = true;
|
|
49013
49013
|
} else {
|
|
49014
|
-
|
|
49014
|
+
json5.exclusiveMinimum = exclusiveMinimum;
|
|
49015
49015
|
}
|
|
49016
49016
|
} else if (typeof minimum === "number") {
|
|
49017
|
-
|
|
49017
|
+
json5.minimum = minimum;
|
|
49018
49018
|
}
|
|
49019
49019
|
if (exMax) {
|
|
49020
49020
|
if (legacy) {
|
|
49021
|
-
|
|
49022
|
-
|
|
49021
|
+
json5.maximum = exclusiveMaximum;
|
|
49022
|
+
json5.exclusiveMaximum = true;
|
|
49023
49023
|
} else {
|
|
49024
|
-
|
|
49024
|
+
json5.exclusiveMaximum = exclusiveMaximum;
|
|
49025
49025
|
}
|
|
49026
49026
|
} else if (typeof maximum === "number") {
|
|
49027
|
-
|
|
49027
|
+
json5.maximum = maximum;
|
|
49028
49028
|
}
|
|
49029
49029
|
if (multipleOf) {
|
|
49030
49030
|
const divisors = /* @__PURE__ */ new Set();
|
|
@@ -49032,75 +49032,75 @@ var numberProcessor = (schema, ctx, _json, params) => {
|
|
|
49032
49032
|
if (Number.isFinite(divisor) && divisor !== 0)
|
|
49033
49033
|
divisors.add(Math.abs(divisor));
|
|
49034
49034
|
else
|
|
49035
|
-
handleUnrepresentable(schema, ctx,
|
|
49035
|
+
handleUnrepresentable(schema, ctx, json5, params, `A multipleOf divisor of ${divisor} cannot be represented in JSON Schema`);
|
|
49036
49036
|
}
|
|
49037
49037
|
const [first, ...rest] = divisors;
|
|
49038
49038
|
if (first !== void 0)
|
|
49039
|
-
|
|
49039
|
+
json5.multipleOf = first;
|
|
49040
49040
|
if (rest.length)
|
|
49041
|
-
|
|
49041
|
+
json5.allOf = [...json5.allOf ?? [], ...rest.map((m) => ({ multipleOf: m }))];
|
|
49042
49042
|
}
|
|
49043
49043
|
};
|
|
49044
|
-
var booleanProcessor = (_schema, _ctx,
|
|
49045
|
-
|
|
49044
|
+
var booleanProcessor = (_schema, _ctx, json5, _params) => {
|
|
49045
|
+
json5.type = "boolean";
|
|
49046
49046
|
};
|
|
49047
|
-
var bigintProcessor = (schema, ctx,
|
|
49048
|
-
handleUnrepresentable(schema, ctx,
|
|
49047
|
+
var bigintProcessor = (schema, ctx, json5, params) => {
|
|
49048
|
+
handleUnrepresentable(schema, ctx, json5, params, "BigInt cannot be represented in JSON Schema");
|
|
49049
49049
|
};
|
|
49050
|
-
var symbolProcessor = (schema, ctx,
|
|
49051
|
-
handleUnrepresentable(schema, ctx,
|
|
49050
|
+
var symbolProcessor = (schema, ctx, json5, params) => {
|
|
49051
|
+
handleUnrepresentable(schema, ctx, json5, params, "Symbols cannot be represented in JSON Schema");
|
|
49052
49052
|
};
|
|
49053
|
-
var nullProcessor = (_schema, ctx,
|
|
49053
|
+
var nullProcessor = (_schema, ctx, json5, _params) => {
|
|
49054
49054
|
if (ctx.target === "openapi-3.0") {
|
|
49055
|
-
|
|
49056
|
-
|
|
49057
|
-
|
|
49055
|
+
json5.type = "string";
|
|
49056
|
+
json5.nullable = true;
|
|
49057
|
+
json5.enum = [null];
|
|
49058
49058
|
} else {
|
|
49059
|
-
|
|
49059
|
+
json5.type = "null";
|
|
49060
49060
|
}
|
|
49061
49061
|
};
|
|
49062
|
-
var undefinedProcessor = (schema, ctx,
|
|
49063
|
-
handleUnrepresentable(schema, ctx,
|
|
49062
|
+
var undefinedProcessor = (schema, ctx, json5, params) => {
|
|
49063
|
+
handleUnrepresentable(schema, ctx, json5, params, "Undefined cannot be represented in JSON Schema");
|
|
49064
49064
|
};
|
|
49065
|
-
var voidProcessor = (schema, ctx,
|
|
49066
|
-
handleUnrepresentable(schema, ctx,
|
|
49065
|
+
var voidProcessor = (schema, ctx, json5, params) => {
|
|
49066
|
+
handleUnrepresentable(schema, ctx, json5, params, "Void cannot be represented in JSON Schema");
|
|
49067
49067
|
};
|
|
49068
|
-
var neverProcessor = (_schema, _ctx,
|
|
49069
|
-
|
|
49068
|
+
var neverProcessor = (_schema, _ctx, json5, _params) => {
|
|
49069
|
+
json5.not = {};
|
|
49070
49070
|
};
|
|
49071
49071
|
var anyProcessor = (_schema, _ctx, _json, _params) => {
|
|
49072
49072
|
};
|
|
49073
49073
|
var unknownProcessor = (_schema, _ctx, _json, _params) => {
|
|
49074
49074
|
};
|
|
49075
|
-
var dateProcessor = (schema, ctx,
|
|
49076
|
-
handleUnrepresentable(schema, ctx,
|
|
49075
|
+
var dateProcessor = (schema, ctx, json5, params) => {
|
|
49076
|
+
handleUnrepresentable(schema, ctx, json5, params, "Date cannot be represented in JSON Schema");
|
|
49077
49077
|
};
|
|
49078
|
-
var enumProcessor = (schema, _ctx,
|
|
49078
|
+
var enumProcessor = (schema, _ctx, json5, _params) => {
|
|
49079
49079
|
const def = schema._zod.def;
|
|
49080
49080
|
const values = getEnumValues(def.entries);
|
|
49081
49081
|
if (values.length === 0) {
|
|
49082
|
-
|
|
49082
|
+
json5.not = {};
|
|
49083
49083
|
return;
|
|
49084
49084
|
}
|
|
49085
49085
|
if (values.every((v) => typeof v === "number"))
|
|
49086
|
-
|
|
49086
|
+
json5.type = "number";
|
|
49087
49087
|
if (values.every((v) => typeof v === "string"))
|
|
49088
|
-
|
|
49089
|
-
|
|
49088
|
+
json5.type = "string";
|
|
49089
|
+
json5.enum = values;
|
|
49090
49090
|
};
|
|
49091
|
-
var literalProcessor = (schema, ctx,
|
|
49091
|
+
var literalProcessor = (schema, ctx, json5, params) => {
|
|
49092
49092
|
const def = schema._zod.def;
|
|
49093
49093
|
if (def.values.length === 0) {
|
|
49094
|
-
|
|
49094
|
+
json5.not = {};
|
|
49095
49095
|
return;
|
|
49096
49096
|
}
|
|
49097
49097
|
const vals = [];
|
|
49098
49098
|
for (const val of def.values) {
|
|
49099
49099
|
if (val === void 0) {
|
|
49100
|
-
if (handleUnrepresentable(schema, ctx,
|
|
49100
|
+
if (handleUnrepresentable(schema, ctx, json5, params, "Literal `undefined` cannot be represented in JSON Schema"))
|
|
49101
49101
|
return;
|
|
49102
49102
|
} else if (typeof val === "bigint") {
|
|
49103
|
-
if (handleUnrepresentable(schema, ctx,
|
|
49103
|
+
if (handleUnrepresentable(schema, ctx, json5, params, "BigInt literals cannot be represented in JSON Schema"))
|
|
49104
49104
|
return;
|
|
49105
49105
|
vals.push(Number(val));
|
|
49106
49106
|
} else {
|
|
@@ -49110,37 +49110,37 @@ var literalProcessor = (schema, ctx, json4, params) => {
|
|
|
49110
49110
|
if (vals.length === 0) {
|
|
49111
49111
|
} else if (vals.length === 1) {
|
|
49112
49112
|
const val = vals[0];
|
|
49113
|
-
|
|
49113
|
+
json5.type = val === null ? "null" : typeof val;
|
|
49114
49114
|
if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
|
|
49115
|
-
|
|
49115
|
+
json5.enum = [val];
|
|
49116
49116
|
} else {
|
|
49117
|
-
|
|
49117
|
+
json5.const = val;
|
|
49118
49118
|
}
|
|
49119
49119
|
} else {
|
|
49120
49120
|
if (vals.every((v) => typeof v === "number"))
|
|
49121
|
-
|
|
49121
|
+
json5.type = "number";
|
|
49122
49122
|
if (vals.every((v) => typeof v === "string"))
|
|
49123
|
-
|
|
49123
|
+
json5.type = "string";
|
|
49124
49124
|
if (vals.every((v) => typeof v === "boolean"))
|
|
49125
|
-
|
|
49125
|
+
json5.type = "boolean";
|
|
49126
49126
|
if (vals.every((v) => v === null))
|
|
49127
|
-
|
|
49128
|
-
|
|
49127
|
+
json5.type = "null";
|
|
49128
|
+
json5.enum = vals;
|
|
49129
49129
|
}
|
|
49130
49130
|
};
|
|
49131
|
-
var nanProcessor = (schema, ctx,
|
|
49132
|
-
handleUnrepresentable(schema, ctx,
|
|
49131
|
+
var nanProcessor = (schema, ctx, json5, params) => {
|
|
49132
|
+
handleUnrepresentable(schema, ctx, json5, params, "NaN cannot be represented in JSON Schema");
|
|
49133
49133
|
};
|
|
49134
|
-
var templateLiteralProcessor = (schema, _ctx,
|
|
49135
|
-
const _json =
|
|
49134
|
+
var templateLiteralProcessor = (schema, _ctx, json5, _params) => {
|
|
49135
|
+
const _json = json5;
|
|
49136
49136
|
const pattern = schema._zod.pattern;
|
|
49137
49137
|
if (!pattern)
|
|
49138
49138
|
throw new Error("Pattern not found in template literal");
|
|
49139
49139
|
_json.type = "string";
|
|
49140
49140
|
_json.pattern = pattern.source;
|
|
49141
49141
|
};
|
|
49142
|
-
var fileProcessor = (schema, _ctx,
|
|
49143
|
-
const _json =
|
|
49142
|
+
var fileProcessor = (schema, _ctx, json5, _params) => {
|
|
49143
|
+
const _json = json5;
|
|
49144
49144
|
_json.type = "string";
|
|
49145
49145
|
_json.format = "binary";
|
|
49146
49146
|
_json.contentEncoding = "binary";
|
|
@@ -49158,34 +49158,34 @@ var fileProcessor = (schema, _ctx, json4, _params) => {
|
|
|
49158
49158
|
else
|
|
49159
49159
|
_json.anyOf = mime.map((m) => ({ contentMediaType: m }));
|
|
49160
49160
|
};
|
|
49161
|
-
var successProcessor = (_schema, _ctx,
|
|
49162
|
-
|
|
49161
|
+
var successProcessor = (_schema, _ctx, json5, _params) => {
|
|
49162
|
+
json5.type = "boolean";
|
|
49163
49163
|
};
|
|
49164
|
-
var customProcessor = (schema, ctx,
|
|
49165
|
-
handleUnrepresentable(schema, ctx,
|
|
49164
|
+
var customProcessor = (schema, ctx, json5, params) => {
|
|
49165
|
+
handleUnrepresentable(schema, ctx, json5, params, "Custom types cannot be represented in JSON Schema");
|
|
49166
49166
|
};
|
|
49167
|
-
var functionProcessor = (schema, ctx,
|
|
49168
|
-
handleUnrepresentable(schema, ctx,
|
|
49167
|
+
var functionProcessor = (schema, ctx, json5, params) => {
|
|
49168
|
+
handleUnrepresentable(schema, ctx, json5, params, "Function types cannot be represented in JSON Schema");
|
|
49169
49169
|
};
|
|
49170
|
-
var transformProcessor = (schema, ctx,
|
|
49171
|
-
handleUnrepresentable(schema, ctx,
|
|
49170
|
+
var transformProcessor = (schema, ctx, json5, params) => {
|
|
49171
|
+
handleUnrepresentable(schema, ctx, json5, params, "Transforms cannot be represented in JSON Schema");
|
|
49172
49172
|
};
|
|
49173
|
-
var mapProcessor = (schema, ctx,
|
|
49174
|
-
handleUnrepresentable(schema, ctx,
|
|
49173
|
+
var mapProcessor = (schema, ctx, json5, params) => {
|
|
49174
|
+
handleUnrepresentable(schema, ctx, json5, params, "Map cannot be represented in JSON Schema");
|
|
49175
49175
|
};
|
|
49176
|
-
var setProcessor = (schema, ctx,
|
|
49177
|
-
handleUnrepresentable(schema, ctx,
|
|
49176
|
+
var setProcessor = (schema, ctx, json5, params) => {
|
|
49177
|
+
handleUnrepresentable(schema, ctx, json5, params, "Set cannot be represented in JSON Schema");
|
|
49178
49178
|
};
|
|
49179
49179
|
var arrayProcessor = (schema, ctx, _json, params) => {
|
|
49180
|
-
const
|
|
49180
|
+
const json5 = _json;
|
|
49181
49181
|
const def = schema._zod.def;
|
|
49182
49182
|
const { minimum, maximum } = aggregateChecks(schema);
|
|
49183
49183
|
if (typeof minimum === "number")
|
|
49184
|
-
|
|
49184
|
+
json5.minItems = minimum;
|
|
49185
49185
|
if (typeof maximum === "number")
|
|
49186
|
-
|
|
49187
|
-
|
|
49188
|
-
|
|
49186
|
+
json5.maxItems = maximum;
|
|
49187
|
+
json5.type = "array";
|
|
49188
|
+
json5.items = processSchema(def.element, ctx, {
|
|
49189
49189
|
...params,
|
|
49190
49190
|
path: [...params.path, "items"]
|
|
49191
49191
|
});
|
|
@@ -49201,17 +49201,17 @@ function inputOptin(schema) {
|
|
|
49201
49201
|
return schema._zod.optin;
|
|
49202
49202
|
}
|
|
49203
49203
|
var objectProcessor = (schema, ctx, _json, params) => {
|
|
49204
|
-
const
|
|
49204
|
+
const json5 = _json;
|
|
49205
49205
|
const def = schema._zod.def;
|
|
49206
49206
|
const shape = def.shape;
|
|
49207
49207
|
const symbolKeys = Object.getOwnPropertySymbols(shape);
|
|
49208
|
-
if (symbolKeys.length && handleUnrepresentable(schema, ctx,
|
|
49208
|
+
if (symbolKeys.length && handleUnrepresentable(schema, ctx, json5, params, "Symbol keys cannot be represented in JSON Schema")) {
|
|
49209
49209
|
return;
|
|
49210
49210
|
}
|
|
49211
|
-
|
|
49212
|
-
|
|
49211
|
+
json5.type = "object";
|
|
49212
|
+
json5.properties = {};
|
|
49213
49213
|
for (const key in shape) {
|
|
49214
|
-
assignProp(
|
|
49214
|
+
assignProp(json5.properties, key, processSchema(shape[key], ctx, {
|
|
49215
49215
|
...params,
|
|
49216
49216
|
path: [...params.path, "properties", key]
|
|
49217
49217
|
}));
|
|
@@ -49224,21 +49224,21 @@ var objectProcessor = (schema, ctx, _json, params) => {
|
|
|
49224
49224
|
}
|
|
49225
49225
|
}
|
|
49226
49226
|
if (requiredKeys.length > 0) {
|
|
49227
|
-
|
|
49227
|
+
json5.required = requiredKeys;
|
|
49228
49228
|
}
|
|
49229
49229
|
if (def.catchall?._zod.def.type === "never") {
|
|
49230
|
-
|
|
49230
|
+
json5.additionalProperties = false;
|
|
49231
49231
|
} else if (!def.catchall) {
|
|
49232
49232
|
if (ctx.io === "output")
|
|
49233
|
-
|
|
49233
|
+
json5.additionalProperties = false;
|
|
49234
49234
|
} else if (def.catchall) {
|
|
49235
|
-
|
|
49235
|
+
json5.additionalProperties = processSchema(def.catchall, ctx, {
|
|
49236
49236
|
...params,
|
|
49237
49237
|
path: [...params.path, "additionalProperties"]
|
|
49238
49238
|
});
|
|
49239
49239
|
}
|
|
49240
49240
|
};
|
|
49241
|
-
var unionProcessor = (schema, ctx,
|
|
49241
|
+
var unionProcessor = (schema, ctx, json5, params) => {
|
|
49242
49242
|
const def = schema._zod.def;
|
|
49243
49243
|
const isExclusive = def.inclusive === false;
|
|
49244
49244
|
const options = def.options.map((x, i) => processSchema(x, ctx, {
|
|
@@ -49246,12 +49246,12 @@ var unionProcessor = (schema, ctx, json4, params) => {
|
|
|
49246
49246
|
path: [...params.path, isExclusive ? "oneOf" : "anyOf", i]
|
|
49247
49247
|
}));
|
|
49248
49248
|
if (isExclusive) {
|
|
49249
|
-
|
|
49249
|
+
json5.oneOf = options;
|
|
49250
49250
|
} else {
|
|
49251
|
-
|
|
49251
|
+
json5.anyOf = options;
|
|
49252
49252
|
}
|
|
49253
49253
|
};
|
|
49254
|
-
var intersectionProcessor = (schema, ctx,
|
|
49254
|
+
var intersectionProcessor = (schema, ctx, json5, params) => {
|
|
49255
49255
|
const def = schema._zod.def;
|
|
49256
49256
|
const a = processSchema(def.left, ctx, {
|
|
49257
49257
|
...params,
|
|
@@ -49266,13 +49266,13 @@ var intersectionProcessor = (schema, ctx, json4, params) => {
|
|
|
49266
49266
|
...isSimpleIntersection(a) ? a.allOf : [a],
|
|
49267
49267
|
...isSimpleIntersection(b) ? b.allOf : [b]
|
|
49268
49268
|
];
|
|
49269
|
-
|
|
49269
|
+
json5.allOf = allOf;
|
|
49270
49270
|
ctx.intersections.push(allOf);
|
|
49271
49271
|
};
|
|
49272
49272
|
var tupleProcessor = (schema, ctx, _json, params) => {
|
|
49273
|
-
const
|
|
49273
|
+
const json5 = _json;
|
|
49274
49274
|
const def = schema._zod.def;
|
|
49275
|
-
|
|
49275
|
+
json5.type = "array";
|
|
49276
49276
|
const prefixPath = ctx.target === "draft-2020-12" ? "prefixItems" : "items";
|
|
49277
49277
|
const restPath = ctx.target === "draft-2020-12" ? "items" : ctx.target === "openapi-3.0" ? "items" : "additionalItems";
|
|
49278
49278
|
const prefixItems = def.items.map((x, i) => processSchema(x, ctx, {
|
|
@@ -49294,70 +49294,70 @@ var tupleProcessor = (schema, ctx, _json, params) => {
|
|
|
49294
49294
|
const maxItems = def.items.length;
|
|
49295
49295
|
const isClosed = !def.rest;
|
|
49296
49296
|
if (ctx.target === "draft-2020-12") {
|
|
49297
|
-
|
|
49297
|
+
json5.prefixItems = prefixItems;
|
|
49298
49298
|
if (isClosed) {
|
|
49299
|
-
|
|
49299
|
+
json5.items = false;
|
|
49300
49300
|
} else if (rest) {
|
|
49301
|
-
|
|
49301
|
+
json5.items = rest;
|
|
49302
49302
|
}
|
|
49303
49303
|
if (minItems > 0)
|
|
49304
|
-
|
|
49304
|
+
json5.minItems = minItems;
|
|
49305
49305
|
if (isClosed)
|
|
49306
|
-
|
|
49306
|
+
json5.maxItems = maxItems;
|
|
49307
49307
|
} else if (ctx.target === "openapi-3.0") {
|
|
49308
|
-
|
|
49308
|
+
json5.items = {
|
|
49309
49309
|
anyOf: prefixItems
|
|
49310
49310
|
};
|
|
49311
49311
|
if (rest) {
|
|
49312
|
-
|
|
49312
|
+
json5.items.anyOf.push(rest);
|
|
49313
49313
|
}
|
|
49314
49314
|
if (minItems > 0)
|
|
49315
|
-
|
|
49315
|
+
json5.minItems = minItems;
|
|
49316
49316
|
if (isClosed)
|
|
49317
|
-
|
|
49317
|
+
json5.maxItems = maxItems;
|
|
49318
49318
|
} else {
|
|
49319
|
-
|
|
49319
|
+
json5.items = prefixItems;
|
|
49320
49320
|
if (isClosed) {
|
|
49321
|
-
|
|
49321
|
+
json5.additionalItems = false;
|
|
49322
49322
|
} else if (rest) {
|
|
49323
|
-
|
|
49323
|
+
json5.additionalItems = rest;
|
|
49324
49324
|
}
|
|
49325
49325
|
if (minItems > 0)
|
|
49326
|
-
|
|
49326
|
+
json5.minItems = minItems;
|
|
49327
49327
|
if (isClosed)
|
|
49328
|
-
|
|
49328
|
+
json5.maxItems = maxItems;
|
|
49329
49329
|
}
|
|
49330
49330
|
const { minimum, maximum } = aggregateChecks(schema);
|
|
49331
49331
|
if (typeof minimum === "number")
|
|
49332
|
-
|
|
49332
|
+
json5.minItems = minimum;
|
|
49333
49333
|
if (typeof maximum === "number")
|
|
49334
|
-
|
|
49335
|
-
};
|
|
49336
|
-
function stringifyKeyNames(bySchema,
|
|
49337
|
-
if (
|
|
49338
|
-
if (visited.has(
|
|
49339
|
-
return
|
|
49340
|
-
visited.add(
|
|
49341
|
-
const def = bySchema.get(
|
|
49334
|
+
json5.maxItems = maximum;
|
|
49335
|
+
};
|
|
49336
|
+
function stringifyKeyNames(bySchema, json5, visited) {
|
|
49337
|
+
if (json5.$ref) {
|
|
49338
|
+
if (visited.has(json5))
|
|
49339
|
+
return json5;
|
|
49340
|
+
visited.add(json5);
|
|
49341
|
+
const def = bySchema.get(json5)?.def;
|
|
49342
49342
|
if (!def)
|
|
49343
|
-
return
|
|
49343
|
+
return json5;
|
|
49344
49344
|
const inlined = stringifyKeyNames(bySchema, def, visited);
|
|
49345
|
-
return inlined === def ?
|
|
49345
|
+
return inlined === def ? json5 : inlined;
|
|
49346
49346
|
}
|
|
49347
49347
|
for (const keyword of ["anyOf", "oneOf"]) {
|
|
49348
|
-
const branches =
|
|
49348
|
+
const branches = json5[keyword];
|
|
49349
49349
|
if (!Array.isArray(branches))
|
|
49350
49350
|
continue;
|
|
49351
49351
|
const mapped = branches.map((branch) => stringifyKeyNames(bySchema, branch, visited));
|
|
49352
49352
|
if (mapped.some((branch, i) => branch !== branches[i]))
|
|
49353
|
-
|
|
49353
|
+
json5 = { ...json5, [keyword]: mapped };
|
|
49354
49354
|
}
|
|
49355
|
-
const types22 = Array.isArray(
|
|
49355
|
+
const types22 = Array.isArray(json5.type) ? json5.type : [json5.type];
|
|
49356
49356
|
const numericType = !types22.includes("string") && types22.some((t) => t === "number" || t === "integer");
|
|
49357
|
-
const values =
|
|
49357
|
+
const values = json5.enum ?? (json5.const !== void 0 ? [json5.const] : void 0);
|
|
49358
49358
|
if (!numericType && !values?.some((v) => typeof v === "number"))
|
|
49359
|
-
return
|
|
49360
|
-
const { minimum, maximum, exclusiveMinimum, exclusiveMaximum, multipleOf, format, id, ...rest } =
|
|
49359
|
+
return json5;
|
|
49360
|
+
const { minimum, maximum, exclusiveMinimum, exclusiveMaximum, multipleOf, format, id, ...rest } = json5;
|
|
49361
49361
|
if (rest.enum)
|
|
49362
49362
|
rest.enum = rest.enum.map((v) => typeof v === "number" ? String(v) : v);
|
|
49363
49363
|
else if (typeof rest.const === "number")
|
|
@@ -49397,9 +49397,9 @@ function rewriteKeyNames(ctx) {
|
|
|
49397
49397
|
}
|
|
49398
49398
|
}
|
|
49399
49399
|
var recordProcessor = (schema, ctx, _json, params) => {
|
|
49400
|
-
const
|
|
49400
|
+
const json5 = _json;
|
|
49401
49401
|
const def = schema._zod.def;
|
|
49402
|
-
|
|
49402
|
+
json5.type = "object";
|
|
49403
49403
|
const keyType = def.keyType;
|
|
49404
49404
|
const patterns = aggregateChecks(keyType).patterns;
|
|
49405
49405
|
if (def.mode === "loose" && patterns && patterns.size > 0) {
|
|
@@ -49407,13 +49407,13 @@ var recordProcessor = (schema, ctx, _json, params) => {
|
|
|
49407
49407
|
...params,
|
|
49408
49408
|
path: [...params.path, "patternProperties", "*"]
|
|
49409
49409
|
});
|
|
49410
|
-
|
|
49410
|
+
json5.patternProperties = {};
|
|
49411
49411
|
for (const pattern of patterns) {
|
|
49412
|
-
assignProp(
|
|
49412
|
+
assignProp(json5.patternProperties, exactPattern(pattern).source, valueSchema);
|
|
49413
49413
|
}
|
|
49414
49414
|
} else {
|
|
49415
49415
|
if (ctx.target === "draft-07" || ctx.target === "draft-2020-12") {
|
|
49416
|
-
|
|
49416
|
+
json5.propertyNames = processSchema(def.keyType, ctx, {
|
|
49417
49417
|
...params,
|
|
49418
49418
|
path: [...params.path, "propertyNames"]
|
|
49419
49419
|
});
|
|
@@ -49425,7 +49425,7 @@ var recordProcessor = (schema, ctx, _json, params) => {
|
|
|
49425
49425
|
}
|
|
49426
49426
|
pending.push(schema);
|
|
49427
49427
|
}
|
|
49428
|
-
|
|
49428
|
+
json5.additionalProperties = processSchema(def.valueType, ctx, {
|
|
49429
49429
|
...params,
|
|
49430
49430
|
path: [...params.path, "additionalProperties"]
|
|
49431
49431
|
});
|
|
@@ -49435,19 +49435,19 @@ var recordProcessor = (schema, ctx, _json, params) => {
|
|
|
49435
49435
|
if (keyValues && !def.partial && !omittableOnInput) {
|
|
49436
49436
|
const validKeyValues = [...keyValues].filter((v) => typeof v === "string" || typeof v === "number");
|
|
49437
49437
|
if (validKeyValues.length > 0) {
|
|
49438
|
-
|
|
49438
|
+
json5.required = validKeyValues.map(String);
|
|
49439
49439
|
}
|
|
49440
49440
|
}
|
|
49441
49441
|
};
|
|
49442
|
-
var nullableProcessor = (schema, ctx,
|
|
49442
|
+
var nullableProcessor = (schema, ctx, json5, params) => {
|
|
49443
49443
|
const def = schema._zod.def;
|
|
49444
49444
|
const inner = processSchema(def.innerType, ctx, params);
|
|
49445
49445
|
const seen = ctx.seen.get(schema);
|
|
49446
49446
|
if (ctx.target === "openapi-3.0") {
|
|
49447
49447
|
seen.ref = def.innerType;
|
|
49448
|
-
|
|
49448
|
+
json5.nullable = true;
|
|
49449
49449
|
} else {
|
|
49450
|
-
|
|
49450
|
+
json5.anyOf = [inner, { type: "null" }];
|
|
49451
49451
|
}
|
|
49452
49452
|
};
|
|
49453
49453
|
var nonoptionalProcessor = (schema, ctx, _json, params) => {
|
|
@@ -49457,7 +49457,7 @@ var nonoptionalProcessor = (schema, ctx, _json, params) => {
|
|
|
49457
49457
|
seen.ref = def.innerType;
|
|
49458
49458
|
};
|
|
49459
49459
|
var UNREPRESENTABLE_DEFAULT = /* @__PURE__ */ Symbol();
|
|
49460
|
-
function serializeDefaultValue(value, schema, ctx,
|
|
49460
|
+
function serializeDefaultValue(value, schema, ctx, json5, params) {
|
|
49461
49461
|
let unrepresentable = false;
|
|
49462
49462
|
const serialized = JSON.stringify(value, (_, val) => {
|
|
49463
49463
|
if (typeof val !== "bigint")
|
|
@@ -49467,30 +49467,30 @@ function serializeDefaultValue(value, schema, ctx, json4, params) {
|
|
|
49467
49467
|
});
|
|
49468
49468
|
if (!unrepresentable)
|
|
49469
49469
|
return JSON.parse(serialized);
|
|
49470
|
-
handleUnrepresentable(schema, ctx,
|
|
49470
|
+
handleUnrepresentable(schema, ctx, json5, params, "BigInt defaults cannot be represented in JSON Schema");
|
|
49471
49471
|
return UNREPRESENTABLE_DEFAULT;
|
|
49472
49472
|
}
|
|
49473
|
-
var defaultProcessor = (schema, ctx,
|
|
49473
|
+
var defaultProcessor = (schema, ctx, json5, params) => {
|
|
49474
49474
|
const def = schema._zod.def;
|
|
49475
49475
|
processSchema(def.innerType, ctx, params);
|
|
49476
49476
|
const seen = ctx.seen.get(schema);
|
|
49477
49477
|
seen.ref = def.innerType;
|
|
49478
|
-
const value = serializeDefaultValue(def.defaultValue, schema, ctx,
|
|
49478
|
+
const value = serializeDefaultValue(def.defaultValue, schema, ctx, json5, params);
|
|
49479
49479
|
if (value !== UNREPRESENTABLE_DEFAULT)
|
|
49480
|
-
|
|
49480
|
+
json5.default = value;
|
|
49481
49481
|
};
|
|
49482
|
-
var prefaultProcessor = (schema, ctx,
|
|
49482
|
+
var prefaultProcessor = (schema, ctx, json5, params) => {
|
|
49483
49483
|
const def = schema._zod.def;
|
|
49484
49484
|
processSchema(def.innerType, ctx, params);
|
|
49485
49485
|
const seen = ctx.seen.get(schema);
|
|
49486
49486
|
seen.ref = def.innerType;
|
|
49487
49487
|
if (ctx.io !== "input")
|
|
49488
49488
|
return;
|
|
49489
|
-
const value = serializeDefaultValue(def.defaultValue, schema, ctx,
|
|
49489
|
+
const value = serializeDefaultValue(def.defaultValue, schema, ctx, json5, params);
|
|
49490
49490
|
if (value !== UNREPRESENTABLE_DEFAULT)
|
|
49491
|
-
|
|
49491
|
+
json5._prefault = value;
|
|
49492
49492
|
};
|
|
49493
|
-
var catchProcessor = (schema, ctx,
|
|
49493
|
+
var catchProcessor = (schema, ctx, json5, params) => {
|
|
49494
49494
|
const def = schema._zod.def;
|
|
49495
49495
|
processSchema(def.innerType, ctx, params);
|
|
49496
49496
|
const seen = ctx.seen.get(schema);
|
|
@@ -49499,10 +49499,10 @@ var catchProcessor = (schema, ctx, json4, params) => {
|
|
|
49499
49499
|
try {
|
|
49500
49500
|
catchValue = def.catchValue(void 0);
|
|
49501
49501
|
} catch {
|
|
49502
|
-
handleUnrepresentable(schema, ctx,
|
|
49502
|
+
handleUnrepresentable(schema, ctx, json5, params, "Dynamic catch values are not supported in JSON Schema");
|
|
49503
49503
|
return;
|
|
49504
49504
|
}
|
|
49505
|
-
|
|
49505
|
+
json5.default = catchValue;
|
|
49506
49506
|
};
|
|
49507
49507
|
var pipeProcessor = (schema, ctx, _json, params) => {
|
|
49508
49508
|
const def = schema._zod.def;
|
|
@@ -49512,12 +49512,12 @@ var pipeProcessor = (schema, ctx, _json, params) => {
|
|
|
49512
49512
|
const seen = ctx.seen.get(schema);
|
|
49513
49513
|
seen.ref = innerType;
|
|
49514
49514
|
};
|
|
49515
|
-
var readonlyProcessor = (schema, ctx,
|
|
49515
|
+
var readonlyProcessor = (schema, ctx, json5, params) => {
|
|
49516
49516
|
const def = schema._zod.def;
|
|
49517
49517
|
processSchema(def.innerType, ctx, params);
|
|
49518
49518
|
const seen = ctx.seen.get(schema);
|
|
49519
49519
|
seen.ref = def.innerType;
|
|
49520
|
-
|
|
49520
|
+
json5.readOnly = true;
|
|
49521
49521
|
};
|
|
49522
49522
|
var promiseProcessor = (schema, ctx, _json, params) => {
|
|
49523
49523
|
const def = schema._zod.def;
|
|
@@ -50167,7 +50167,7 @@ var _ZodString = /* @__PURE__ */ $constructor(
|
|
|
50167
50167
|
(inst, def) => {
|
|
50168
50168
|
$ZodString.init(inst, def);
|
|
50169
50169
|
ZodType.init(inst, def);
|
|
50170
|
-
inst._zod.processJSONSchema = (ctx,
|
|
50170
|
+
inst._zod.processJSONSchema = (ctx, json5, params) => stringProcessor(inst, ctx, json5, params);
|
|
50171
50171
|
},
|
|
50172
50172
|
/* @__PURE__ */ util_exports.derived({
|
|
50173
50173
|
format: (inst) => aggregateChecks(inst).format ?? null,
|
|
@@ -50526,7 +50526,7 @@ var ZodNumber = /* @__PURE__ */ $constructor(
|
|
|
50526
50526
|
(inst, def) => {
|
|
50527
50527
|
$ZodNumber.init(inst, def);
|
|
50528
50528
|
ZodType.init(inst, def);
|
|
50529
|
-
inst._zod.processJSONSchema = (ctx,
|
|
50529
|
+
inst._zod.processJSONSchema = (ctx, json5, params) => numberProcessor(inst, ctx, json5, params);
|
|
50530
50530
|
inst.isFinite = true;
|
|
50531
50531
|
},
|
|
50532
50532
|
/* @__PURE__ */ util_exports.derived({
|
|
@@ -50616,7 +50616,7 @@ function uint32(params) {
|
|
|
50616
50616
|
var ZodBoolean = /* @__PURE__ */ $constructor("ZodBoolean", (inst, def) => {
|
|
50617
50617
|
$ZodBoolean.init(inst, def);
|
|
50618
50618
|
ZodType.init(inst, def);
|
|
50619
|
-
inst._zod.processJSONSchema = (ctx,
|
|
50619
|
+
inst._zod.processJSONSchema = (ctx, json5, params) => booleanProcessor(inst, ctx, json5, params);
|
|
50620
50620
|
});
|
|
50621
50621
|
function boolean2(params) {
|
|
50622
50622
|
return _boolean(ZodBoolean, params);
|
|
@@ -50626,7 +50626,7 @@ var ZodBigInt = /* @__PURE__ */ $constructor(
|
|
|
50626
50626
|
(inst, def) => {
|
|
50627
50627
|
$ZodBigInt.init(inst, def);
|
|
50628
50628
|
ZodType.init(inst, def);
|
|
50629
|
-
inst._zod.processJSONSchema = (ctx,
|
|
50629
|
+
inst._zod.processJSONSchema = (ctx, json5, params) => bigintProcessor(inst, ctx, json5, params);
|
|
50630
50630
|
},
|
|
50631
50631
|
/* @__PURE__ */ util_exports.derived({
|
|
50632
50632
|
minValue: (inst) => aggregateChecks(inst).minimum ?? null,
|
|
@@ -50684,7 +50684,7 @@ function uint64(params) {
|
|
|
50684
50684
|
var ZodSymbol = /* @__PURE__ */ $constructor("ZodSymbol", (inst, def) => {
|
|
50685
50685
|
$ZodSymbol.init(inst, def);
|
|
50686
50686
|
ZodType.init(inst, def);
|
|
50687
|
-
inst._zod.processJSONSchema = (ctx,
|
|
50687
|
+
inst._zod.processJSONSchema = (ctx, json5, params) => symbolProcessor(inst, ctx, json5, params);
|
|
50688
50688
|
});
|
|
50689
50689
|
function symbol(params) {
|
|
50690
50690
|
return _symbol(ZodSymbol, params);
|
|
@@ -50692,7 +50692,7 @@ function symbol(params) {
|
|
|
50692
50692
|
var ZodUndefined = /* @__PURE__ */ $constructor("ZodUndefined", (inst, def) => {
|
|
50693
50693
|
$ZodUndefined.init(inst, def);
|
|
50694
50694
|
ZodType.init(inst, def);
|
|
50695
|
-
inst._zod.processJSONSchema = (ctx,
|
|
50695
|
+
inst._zod.processJSONSchema = (ctx, json5, params) => undefinedProcessor(inst, ctx, json5, params);
|
|
50696
50696
|
});
|
|
50697
50697
|
function _undefined3(params) {
|
|
50698
50698
|
return _undefined2(ZodUndefined, params);
|
|
@@ -50700,7 +50700,7 @@ function _undefined3(params) {
|
|
|
50700
50700
|
var ZodNull = /* @__PURE__ */ $constructor("ZodNull", (inst, def) => {
|
|
50701
50701
|
$ZodNull.init(inst, def);
|
|
50702
50702
|
ZodType.init(inst, def);
|
|
50703
|
-
inst._zod.processJSONSchema = (ctx,
|
|
50703
|
+
inst._zod.processJSONSchema = (ctx, json5, params) => nullProcessor(inst, ctx, json5, params);
|
|
50704
50704
|
});
|
|
50705
50705
|
function _null3(params) {
|
|
50706
50706
|
return _null2(ZodNull, params);
|
|
@@ -50708,7 +50708,7 @@ function _null3(params) {
|
|
|
50708
50708
|
var ZodAny = /* @__PURE__ */ $constructor("ZodAny", (inst, def) => {
|
|
50709
50709
|
$ZodAny.init(inst, def);
|
|
50710
50710
|
ZodType.init(inst, def);
|
|
50711
|
-
inst._zod.processJSONSchema = (ctx,
|
|
50711
|
+
inst._zod.processJSONSchema = (ctx, json5, params) => anyProcessor(inst, ctx, json5, params);
|
|
50712
50712
|
});
|
|
50713
50713
|
function any() {
|
|
50714
50714
|
return _any(ZodAny);
|
|
@@ -50716,7 +50716,7 @@ function any() {
|
|
|
50716
50716
|
var ZodUnknown = /* @__PURE__ */ $constructor("ZodUnknown", (inst, def) => {
|
|
50717
50717
|
$ZodUnknown.init(inst, def);
|
|
50718
50718
|
ZodType.init(inst, def);
|
|
50719
|
-
inst._zod.processJSONSchema = (ctx,
|
|
50719
|
+
inst._zod.processJSONSchema = (ctx, json5, params) => unknownProcessor(inst, ctx, json5, params);
|
|
50720
50720
|
});
|
|
50721
50721
|
function unknown() {
|
|
50722
50722
|
return _unknown(ZodUnknown);
|
|
@@ -50724,7 +50724,7 @@ function unknown() {
|
|
|
50724
50724
|
var ZodNever = /* @__PURE__ */ $constructor("ZodNever", (inst, def) => {
|
|
50725
50725
|
$ZodNever.init(inst, def);
|
|
50726
50726
|
ZodType.init(inst, def);
|
|
50727
|
-
inst._zod.processJSONSchema = (ctx,
|
|
50727
|
+
inst._zod.processJSONSchema = (ctx, json5, params) => neverProcessor(inst, ctx, json5, params);
|
|
50728
50728
|
});
|
|
50729
50729
|
function never(params) {
|
|
50730
50730
|
return _never(ZodNever, params);
|
|
@@ -50732,7 +50732,7 @@ function never(params) {
|
|
|
50732
50732
|
var ZodVoid = /* @__PURE__ */ $constructor("ZodVoid", (inst, def) => {
|
|
50733
50733
|
$ZodVoid.init(inst, def);
|
|
50734
50734
|
ZodType.init(inst, def);
|
|
50735
|
-
inst._zod.processJSONSchema = (ctx,
|
|
50735
|
+
inst._zod.processJSONSchema = (ctx, json5, params) => voidProcessor(inst, ctx, json5, params);
|
|
50736
50736
|
});
|
|
50737
50737
|
function _void2(params) {
|
|
50738
50738
|
return _void(ZodVoid, params);
|
|
@@ -50742,7 +50742,7 @@ var ZodDate = /* @__PURE__ */ $constructor(
|
|
|
50742
50742
|
(inst, def) => {
|
|
50743
50743
|
$ZodDate.init(inst, def);
|
|
50744
50744
|
ZodType.init(inst, def);
|
|
50745
|
-
inst._zod.processJSONSchema = (ctx,
|
|
50745
|
+
inst._zod.processJSONSchema = (ctx, json5, params) => dateProcessor(inst, ctx, json5, params);
|
|
50746
50746
|
inst.min = (value, params) => inst.check(_gte(value, params));
|
|
50747
50747
|
inst.max = (value, params) => inst.check(_lte(value, params));
|
|
50748
50748
|
},
|
|
@@ -50764,7 +50764,7 @@ var ZodArray = /* @__PURE__ */ $constructor("ZodArray", (inst, def) => {
|
|
|
50764
50764
|
_ensureDefaultMemoizer();
|
|
50765
50765
|
$ZodArray.init(inst, def);
|
|
50766
50766
|
ZodType.init(inst, def);
|
|
50767
|
-
inst._zod.processJSONSchema = (ctx,
|
|
50767
|
+
inst._zod.processJSONSchema = (ctx, json5, params) => arrayProcessor(inst, ctx, json5, params);
|
|
50768
50768
|
inst.element = def.element;
|
|
50769
50769
|
}, {
|
|
50770
50770
|
min(n, params) {
|
|
@@ -50794,7 +50794,7 @@ var ZodObject = /* @__PURE__ */ $constructor("ZodObject", (inst, def) => {
|
|
|
50794
50794
|
_ensureDefaultMemoizer();
|
|
50795
50795
|
$ZodObjectJIT.init(inst, def);
|
|
50796
50796
|
ZodType.init(inst, def);
|
|
50797
|
-
inst._zod.processJSONSchema = (ctx,
|
|
50797
|
+
inst._zod.processJSONSchema = (ctx, json5, params) => objectProcessor(inst, ctx, json5, params);
|
|
50798
50798
|
util_exports.installLazyProp(inst, "shape", (self2) => self2._zod.def.shape, false);
|
|
50799
50799
|
}, {
|
|
50800
50800
|
keyof() {
|
|
@@ -50867,7 +50867,7 @@ function looseObject(shape, params) {
|
|
|
50867
50867
|
var ZodUnion = /* @__PURE__ */ $constructor("ZodUnion", (inst, def) => {
|
|
50868
50868
|
$ZodUnion.init(inst, def);
|
|
50869
50869
|
ZodType.init(inst, def);
|
|
50870
|
-
inst._zod.processJSONSchema = (ctx,
|
|
50870
|
+
inst._zod.processJSONSchema = (ctx, json5, params) => unionProcessor(inst, ctx, json5, params);
|
|
50871
50871
|
inst.options = def.options;
|
|
50872
50872
|
});
|
|
50873
50873
|
function union(options, params) {
|
|
@@ -50880,7 +50880,7 @@ function union(options, params) {
|
|
|
50880
50880
|
var ZodXor = /* @__PURE__ */ $constructor("ZodXor", (inst, def) => {
|
|
50881
50881
|
ZodUnion.init(inst, def);
|
|
50882
50882
|
$ZodXor.init(inst, def);
|
|
50883
|
-
inst._zod.processJSONSchema = (ctx,
|
|
50883
|
+
inst._zod.processJSONSchema = (ctx, json5, params) => unionProcessor(inst, ctx, json5, params);
|
|
50884
50884
|
inst.options = def.options;
|
|
50885
50885
|
});
|
|
50886
50886
|
function xor(options, params) {
|
|
@@ -50906,7 +50906,7 @@ function discriminatedUnion(discriminator, options, params) {
|
|
|
50906
50906
|
var ZodIntersection = /* @__PURE__ */ $constructor("ZodIntersection", (inst, def) => {
|
|
50907
50907
|
$ZodIntersection.init(inst, def);
|
|
50908
50908
|
ZodType.init(inst, def);
|
|
50909
|
-
inst._zod.processJSONSchema = (ctx,
|
|
50909
|
+
inst._zod.processJSONSchema = (ctx, json5, params) => intersectionProcessor(inst, ctx, json5, params);
|
|
50910
50910
|
});
|
|
50911
50911
|
function intersection(left, right) {
|
|
50912
50912
|
return new ZodIntersection({
|
|
@@ -50919,7 +50919,7 @@ var ZodTuple = /* @__PURE__ */ $constructor("ZodTuple", (inst, def) => {
|
|
|
50919
50919
|
_ensureDefaultMemoizer();
|
|
50920
50920
|
$ZodTuple.init(inst, def);
|
|
50921
50921
|
ZodType.init(inst, def);
|
|
50922
|
-
inst._zod.processJSONSchema = (ctx,
|
|
50922
|
+
inst._zod.processJSONSchema = (ctx, json5, params) => tupleProcessor(inst, ctx, json5, params);
|
|
50923
50923
|
}, {
|
|
50924
50924
|
rest(rest) {
|
|
50925
50925
|
return this.clone({
|
|
@@ -50952,7 +50952,7 @@ var ZodRecord = /* @__PURE__ */ $constructor("ZodRecord", (inst, def) => {
|
|
|
50952
50952
|
_ensureDefaultMemoizer();
|
|
50953
50953
|
$ZodRecord.init(inst, def);
|
|
50954
50954
|
ZodType.init(inst, def);
|
|
50955
|
-
inst._zod.processJSONSchema = (ctx,
|
|
50955
|
+
inst._zod.processJSONSchema = (ctx, json5, params) => recordProcessor(inst, ctx, json5, params);
|
|
50956
50956
|
inst.keyType = def.keyType;
|
|
50957
50957
|
inst.valueType = def.valueType;
|
|
50958
50958
|
});
|
|
@@ -50994,7 +50994,7 @@ var ZodMap = /* @__PURE__ */ $constructor("ZodMap", (inst, def) => {
|
|
|
50994
50994
|
_ensureDefaultMemoizer();
|
|
50995
50995
|
$ZodMap.init(inst, def);
|
|
50996
50996
|
ZodType.init(inst, def);
|
|
50997
|
-
inst._zod.processJSONSchema = (ctx,
|
|
50997
|
+
inst._zod.processJSONSchema = (ctx, json5, params) => mapProcessor(inst, ctx, json5, params);
|
|
50998
50998
|
inst.keyType = def.keyType;
|
|
50999
50999
|
inst.valueType = def.valueType;
|
|
51000
51000
|
inst.min = (...args) => inst.check(_minSize(...args));
|
|
@@ -51014,7 +51014,7 @@ var ZodSet = /* @__PURE__ */ $constructor("ZodSet", (inst, def) => {
|
|
|
51014
51014
|
_ensureDefaultMemoizer();
|
|
51015
51015
|
$ZodSet.init(inst, def);
|
|
51016
51016
|
ZodType.init(inst, def);
|
|
51017
|
-
inst._zod.processJSONSchema = (ctx,
|
|
51017
|
+
inst._zod.processJSONSchema = (ctx, json5, params) => setProcessor(inst, ctx, json5, params);
|
|
51018
51018
|
inst.min = (...args) => inst.check(_minSize(...args));
|
|
51019
51019
|
inst.nonempty = (params) => inst.check(_minSize(1, params));
|
|
51020
51020
|
inst.max = (...args) => inst.check(_maxSize(...args));
|
|
@@ -51030,7 +51030,7 @@ function set(valueType, params) {
|
|
|
51030
51030
|
var ZodEnum = /* @__PURE__ */ $constructor("ZodEnum", (inst, def) => {
|
|
51031
51031
|
$ZodEnum.init(inst, def);
|
|
51032
51032
|
ZodType.init(inst, def);
|
|
51033
|
-
inst._zod.processJSONSchema = (ctx,
|
|
51033
|
+
inst._zod.processJSONSchema = (ctx, json5, params) => enumProcessor(inst, ctx, json5, params);
|
|
51034
51034
|
inst.enum = def.entries;
|
|
51035
51035
|
inst.options = [...inst._zod.values];
|
|
51036
51036
|
const keys = new Set(Object.keys(def.entries));
|
|
@@ -51083,7 +51083,7 @@ function nativeEnum(entries2, params) {
|
|
|
51083
51083
|
var ZodLiteral = /* @__PURE__ */ $constructor("ZodLiteral", (inst, def) => {
|
|
51084
51084
|
$ZodLiteral.init(inst, def);
|
|
51085
51085
|
ZodType.init(inst, def);
|
|
51086
|
-
inst._zod.processJSONSchema = (ctx,
|
|
51086
|
+
inst._zod.processJSONSchema = (ctx, json5, params) => literalProcessor(inst, ctx, json5, params);
|
|
51087
51087
|
inst.values = new Set(def.values);
|
|
51088
51088
|
Object.defineProperty(inst, "value", {
|
|
51089
51089
|
get() {
|
|
@@ -51104,7 +51104,7 @@ function literal(value, params) {
|
|
|
51104
51104
|
var ZodFile = /* @__PURE__ */ $constructor("ZodFile", (inst, def) => {
|
|
51105
51105
|
$ZodFile.init(inst, def);
|
|
51106
51106
|
ZodType.init(inst, def);
|
|
51107
|
-
inst._zod.processJSONSchema = (ctx,
|
|
51107
|
+
inst._zod.processJSONSchema = (ctx, json5, params) => fileProcessor(inst, ctx, json5, params);
|
|
51108
51108
|
inst.min = (size, params) => inst.check(_minSize(size, params));
|
|
51109
51109
|
inst.max = (size, params) => inst.check(_maxSize(size, params));
|
|
51110
51110
|
inst.mime = (types22, params) => inst.check(_mime(Array.isArray(types22) ? types22 : [types22], params));
|
|
@@ -51116,7 +51116,7 @@ var ZodTransform = /* @__PURE__ */ $constructor("ZodTransform", (inst, def) => {
|
|
|
51116
51116
|
_ensureDefaultMemoizer();
|
|
51117
51117
|
$ZodTransform.init(inst, def);
|
|
51118
51118
|
ZodType.init(inst, def);
|
|
51119
|
-
inst._zod.processJSONSchema = (ctx,
|
|
51119
|
+
inst._zod.processJSONSchema = (ctx, json5, params) => transformProcessor(inst, ctx, json5, params);
|
|
51120
51120
|
inst._zod.parse = (payload, _ctx) => {
|
|
51121
51121
|
if (_ctx.direction === "backward") {
|
|
51122
51122
|
throw new $ZodEncodeError(inst.constructor.name);
|
|
@@ -51155,7 +51155,7 @@ function transform(fn) {
|
|
|
51155
51155
|
var ZodOptional = /* @__PURE__ */ $constructor("ZodOptional", (inst, def) => {
|
|
51156
51156
|
$ZodOptional.init(inst, def);
|
|
51157
51157
|
ZodType.init(inst, def);
|
|
51158
|
-
inst._zod.processJSONSchema = (ctx,
|
|
51158
|
+
inst._zod.processJSONSchema = (ctx, json5, params) => optionalProcessor(inst, ctx, json5, params);
|
|
51159
51159
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
51160
51160
|
});
|
|
51161
51161
|
function optional(innerType) {
|
|
@@ -51167,7 +51167,7 @@ function optional(innerType) {
|
|
|
51167
51167
|
var ZodExactOptional = /* @__PURE__ */ $constructor("ZodExactOptional", (inst, def) => {
|
|
51168
51168
|
$ZodExactOptional.init(inst, def);
|
|
51169
51169
|
ZodType.init(inst, def);
|
|
51170
|
-
inst._zod.processJSONSchema = (ctx,
|
|
51170
|
+
inst._zod.processJSONSchema = (ctx, json5, params) => optionalProcessor(inst, ctx, json5, params);
|
|
51171
51171
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
51172
51172
|
});
|
|
51173
51173
|
function exactOptional(innerType) {
|
|
@@ -51179,7 +51179,7 @@ function exactOptional(innerType) {
|
|
|
51179
51179
|
var ZodNullable = /* @__PURE__ */ $constructor("ZodNullable", (inst, def) => {
|
|
51180
51180
|
$ZodNullable.init(inst, def);
|
|
51181
51181
|
ZodType.init(inst, def);
|
|
51182
|
-
inst._zod.processJSONSchema = (ctx,
|
|
51182
|
+
inst._zod.processJSONSchema = (ctx, json5, params) => nullableProcessor(inst, ctx, json5, params);
|
|
51183
51183
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
51184
51184
|
});
|
|
51185
51185
|
function nullable(innerType) {
|
|
@@ -51194,7 +51194,7 @@ function nullish2(innerType) {
|
|
|
51194
51194
|
var ZodDefault = /* @__PURE__ */ $constructor("ZodDefault", (inst, def) => {
|
|
51195
51195
|
$ZodDefault.init(inst, def);
|
|
51196
51196
|
ZodType.init(inst, def);
|
|
51197
|
-
inst._zod.processJSONSchema = (ctx,
|
|
51197
|
+
inst._zod.processJSONSchema = (ctx, json5, params) => defaultProcessor(inst, ctx, json5, params);
|
|
51198
51198
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
51199
51199
|
inst.removeDefault = inst.unwrap;
|
|
51200
51200
|
});
|
|
@@ -51210,7 +51210,7 @@ function _default2(innerType, defaultValue) {
|
|
|
51210
51210
|
var ZodPrefault = /* @__PURE__ */ $constructor("ZodPrefault", (inst, def) => {
|
|
51211
51211
|
$ZodPrefault.init(inst, def);
|
|
51212
51212
|
ZodType.init(inst, def);
|
|
51213
|
-
inst._zod.processJSONSchema = (ctx,
|
|
51213
|
+
inst._zod.processJSONSchema = (ctx, json5, params) => prefaultProcessor(inst, ctx, json5, params);
|
|
51214
51214
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
51215
51215
|
});
|
|
51216
51216
|
function prefault(innerType, defaultValue) {
|
|
@@ -51225,7 +51225,7 @@ function prefault(innerType, defaultValue) {
|
|
|
51225
51225
|
var ZodNonOptional = /* @__PURE__ */ $constructor("ZodNonOptional", (inst, def) => {
|
|
51226
51226
|
$ZodNonOptional.init(inst, def);
|
|
51227
51227
|
ZodType.init(inst, def);
|
|
51228
|
-
inst._zod.processJSONSchema = (ctx,
|
|
51228
|
+
inst._zod.processJSONSchema = (ctx, json5, params) => nonoptionalProcessor(inst, ctx, json5, params);
|
|
51229
51229
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
51230
51230
|
});
|
|
51231
51231
|
function nonoptional(innerType, params) {
|
|
@@ -51238,7 +51238,7 @@ function nonoptional(innerType, params) {
|
|
|
51238
51238
|
var ZodSuccess = /* @__PURE__ */ $constructor("ZodSuccess", (inst, def) => {
|
|
51239
51239
|
$ZodSuccess.init(inst, def);
|
|
51240
51240
|
ZodType.init(inst, def);
|
|
51241
|
-
inst._zod.processJSONSchema = (ctx,
|
|
51241
|
+
inst._zod.processJSONSchema = (ctx, json5, params) => successProcessor(inst, ctx, json5, params);
|
|
51242
51242
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
51243
51243
|
});
|
|
51244
51244
|
function success(innerType) {
|
|
@@ -51250,7 +51250,7 @@ function success(innerType) {
|
|
|
51250
51250
|
var ZodCatch = /* @__PURE__ */ $constructor("ZodCatch", (inst, def) => {
|
|
51251
51251
|
$ZodCatch.init(inst, def);
|
|
51252
51252
|
ZodType.init(inst, def);
|
|
51253
|
-
inst._zod.processJSONSchema = (ctx,
|
|
51253
|
+
inst._zod.processJSONSchema = (ctx, json5, params) => catchProcessor(inst, ctx, json5, params);
|
|
51254
51254
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
51255
51255
|
inst.removeCatch = inst.unwrap;
|
|
51256
51256
|
});
|
|
@@ -51264,7 +51264,7 @@ function _catch2(innerType, catchValue) {
|
|
|
51264
51264
|
var ZodNaN = /* @__PURE__ */ $constructor("ZodNaN", (inst, def) => {
|
|
51265
51265
|
$ZodNaN.init(inst, def);
|
|
51266
51266
|
ZodType.init(inst, def);
|
|
51267
|
-
inst._zod.processJSONSchema = (ctx,
|
|
51267
|
+
inst._zod.processJSONSchema = (ctx, json5, params) => nanProcessor(inst, ctx, json5, params);
|
|
51268
51268
|
});
|
|
51269
51269
|
function nan(params) {
|
|
51270
51270
|
return _nan(ZodNaN, params);
|
|
@@ -51272,7 +51272,7 @@ function nan(params) {
|
|
|
51272
51272
|
var ZodPipe = /* @__PURE__ */ $constructor("ZodPipe", (inst, def) => {
|
|
51273
51273
|
$ZodPipe.init(inst, def);
|
|
51274
51274
|
ZodType.init(inst, def);
|
|
51275
|
-
inst._zod.processJSONSchema = (ctx,
|
|
51275
|
+
inst._zod.processJSONSchema = (ctx, json5, params) => pipeProcessor(inst, ctx, json5, params);
|
|
51276
51276
|
inst.in = def.in;
|
|
51277
51277
|
inst.out = def.out;
|
|
51278
51278
|
});
|
|
@@ -51314,7 +51314,7 @@ var ZodPreprocess = /* @__PURE__ */ $constructor("ZodPreprocess", (inst, def) =>
|
|
|
51314
51314
|
var ZodReadonly = /* @__PURE__ */ $constructor("ZodReadonly", (inst, def) => {
|
|
51315
51315
|
$ZodReadonly.init(inst, def);
|
|
51316
51316
|
ZodType.init(inst, def);
|
|
51317
|
-
inst._zod.processJSONSchema = (ctx,
|
|
51317
|
+
inst._zod.processJSONSchema = (ctx, json5, params) => readonlyProcessor(inst, ctx, json5, params);
|
|
51318
51318
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
51319
51319
|
});
|
|
51320
51320
|
function readonly(innerType) {
|
|
@@ -51326,7 +51326,7 @@ function readonly(innerType) {
|
|
|
51326
51326
|
var ZodTemplateLiteral = /* @__PURE__ */ $constructor("ZodTemplateLiteral", (inst, def) => {
|
|
51327
51327
|
$ZodTemplateLiteral.init(inst, def);
|
|
51328
51328
|
ZodType.init(inst, def);
|
|
51329
|
-
inst._zod.processJSONSchema = (ctx,
|
|
51329
|
+
inst._zod.processJSONSchema = (ctx, json5, params) => templateLiteralProcessor(inst, ctx, json5, params);
|
|
51330
51330
|
});
|
|
51331
51331
|
function templateLiteral(parts, params) {
|
|
51332
51332
|
return new ZodTemplateLiteral({
|
|
@@ -51338,7 +51338,7 @@ function templateLiteral(parts, params) {
|
|
|
51338
51338
|
var ZodLazy = /* @__PURE__ */ $constructor("ZodLazy", (inst, def) => {
|
|
51339
51339
|
$ZodLazy.init(inst, def);
|
|
51340
51340
|
ZodType.init(inst, def);
|
|
51341
|
-
inst._zod.processJSONSchema = (ctx,
|
|
51341
|
+
inst._zod.processJSONSchema = (ctx, json5, params) => lazyProcessor(inst, ctx, json5, params);
|
|
51342
51342
|
inst.unwrap = () => inst._zod.def.getter();
|
|
51343
51343
|
});
|
|
51344
51344
|
function lazy(getter) {
|
|
@@ -51350,7 +51350,7 @@ function lazy(getter) {
|
|
|
51350
51350
|
var ZodPromise = /* @__PURE__ */ $constructor("ZodPromise", (inst, def) => {
|
|
51351
51351
|
$ZodPromise.init(inst, def);
|
|
51352
51352
|
ZodType.init(inst, def);
|
|
51353
|
-
inst._zod.processJSONSchema = (ctx,
|
|
51353
|
+
inst._zod.processJSONSchema = (ctx, json5, params) => promiseProcessor(inst, ctx, json5, params);
|
|
51354
51354
|
inst.unwrap = () => inst._zod.def.innerType;
|
|
51355
51355
|
});
|
|
51356
51356
|
function promise(innerType) {
|
|
@@ -51362,7 +51362,7 @@ function promise(innerType) {
|
|
|
51362
51362
|
var ZodFunction = /* @__PURE__ */ $constructor("ZodFunction", (inst, def) => {
|
|
51363
51363
|
$ZodFunction.init(inst, def);
|
|
51364
51364
|
ZodType.init(inst, def);
|
|
51365
|
-
inst._zod.processJSONSchema = (ctx,
|
|
51365
|
+
inst._zod.processJSONSchema = (ctx, json5, params) => functionProcessor(inst, ctx, json5, params);
|
|
51366
51366
|
});
|
|
51367
51367
|
function _function(params) {
|
|
51368
51368
|
return new ZodFunction({
|
|
@@ -51374,7 +51374,7 @@ function _function(params) {
|
|
|
51374
51374
|
var ZodCustom = /* @__PURE__ */ $constructor("ZodCustom", (inst, def) => {
|
|
51375
51375
|
$ZodCustom.init(inst, def);
|
|
51376
51376
|
ZodType.init(inst, def);
|
|
51377
|
-
inst._zod.processJSONSchema = (ctx,
|
|
51377
|
+
inst._zod.processJSONSchema = (ctx, json5, params) => customProcessor(inst, ctx, json5, params);
|
|
51378
51378
|
});
|
|
51379
51379
|
function check(fn) {
|
|
51380
51380
|
const ch = new $ZodCheck({
|
|
@@ -54531,8 +54531,8 @@ var memo$1;
|
|
|
54531
54531
|
function buildSchemas2025() {
|
|
54532
54532
|
return memo$1 ??= build$1();
|
|
54533
54533
|
}
|
|
54534
|
-
function isNonObjectJsonSchemaRoot(
|
|
54535
|
-
return
|
|
54534
|
+
function isNonObjectJsonSchemaRoot(json5) {
|
|
54535
|
+
return json5["type"] !== "object";
|
|
54536
54536
|
}
|
|
54537
54537
|
var REF_REWRITE_DATA_POSITION_KEYS = /* @__PURE__ */ new Set([
|
|
54538
54538
|
"const",
|
|
@@ -66570,9 +66570,9 @@ var McpServer = class {
|
|
|
66570
66570
|
if (Object.hasOwn(this._toolInputSchemaJson, name)) return this._toolInputSchemaJson[name];
|
|
66571
66571
|
if (tool.inputSchema === void 0) return EMPTY_OBJECT_JSON_SCHEMA;
|
|
66572
66572
|
try {
|
|
66573
|
-
const
|
|
66574
|
-
this._toolInputSchemaJson[name] =
|
|
66575
|
-
return
|
|
66573
|
+
const json5 = standardSchemaToJsonSchema(tool.inputSchema, "input");
|
|
66574
|
+
this._toolInputSchemaJson[name] = json5;
|
|
66575
|
+
return json5;
|
|
66576
66576
|
} catch {
|
|
66577
66577
|
return;
|
|
66578
66578
|
}
|
|
@@ -67124,10 +67124,10 @@ var EMPTY_OBJECT_JSON_SCHEMA = {
|
|
|
67124
67124
|
properties: {}
|
|
67125
67125
|
};
|
|
67126
67126
|
function convertListedInputSchema(name, inputSchema) {
|
|
67127
|
-
const
|
|
67128
|
-
const scan = scanXMcpHeaderDeclarations(
|
|
67127
|
+
const json5 = standardSchemaToJsonSchema(inputSchema, "input");
|
|
67128
|
+
const scan = scanXMcpHeaderDeclarations(json5);
|
|
67129
67129
|
if (!scan.valid) console.warn(`[mcp-sdk] tool '${name}' carries an invalid x-mcp-header declaration and will be excluded by conforming Streamable HTTP clients: ${scan.reason}`);
|
|
67130
|
-
return
|
|
67130
|
+
return json5;
|
|
67131
67131
|
}
|
|
67132
67132
|
function convertOutputSchemaJson(outputSchema) {
|
|
67133
67133
|
if (outputSchema === void 0) return void 0;
|
|
@@ -67253,7 +67253,7 @@ var StdioServerTransport = class {
|
|
|
67253
67253
|
send(message) {
|
|
67254
67254
|
if (this._closed) return Promise.reject(/* @__PURE__ */ new Error("StdioServerTransport is closed"));
|
|
67255
67255
|
return new Promise((resolve5, reject) => {
|
|
67256
|
-
const
|
|
67256
|
+
const json5 = serializeMessage(message);
|
|
67257
67257
|
let settled = false;
|
|
67258
67258
|
const onError = (error63) => {
|
|
67259
67259
|
if (settled) return;
|
|
@@ -67270,7 +67270,7 @@ var StdioServerTransport = class {
|
|
|
67270
67270
|
resolve5();
|
|
67271
67271
|
};
|
|
67272
67272
|
this._stdout.once("error", onError);
|
|
67273
|
-
if (this._stdout.write(
|
|
67273
|
+
if (this._stdout.write(json5)) {
|
|
67274
67274
|
if (settled) return;
|
|
67275
67275
|
settled = true;
|
|
67276
67276
|
this._stdout.off("error", onError);
|
|
@@ -67280,6 +67280,875 @@ var StdioServerTransport = class {
|
|
|
67280
67280
|
}
|
|
67281
67281
|
};
|
|
67282
67282
|
|
|
67283
|
+
// ../protocol/src/frames/computer.ts
|
|
67284
|
+
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
67285
|
+
|
|
67286
|
+
// ../../node_modules/.pnpm/zod@4.6.7/node_modules/zod/index.js
|
|
67287
|
+
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
67288
|
+
|
|
67289
|
+
// ../protocol/src/envelope.ts
|
|
67290
|
+
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
67291
|
+
var Envelope = external_exports.object({
|
|
67292
|
+
v: external_exports.literal(1),
|
|
67293
|
+
// protocol major; bump = breaking
|
|
67294
|
+
id: external_exports.string().uuid(),
|
|
67295
|
+
// unique per frame (sender-generated)
|
|
67296
|
+
ts: external_exports.string().datetime(),
|
|
67297
|
+
// RFC3339, sender clock (advisory only)
|
|
67298
|
+
type: external_exports.string(),
|
|
67299
|
+
// frame discriminator, e.g. "register"
|
|
67300
|
+
corr: external_exports.string().uuid().optional(),
|
|
67301
|
+
// correlation: set on a reply to the request's `id`
|
|
67302
|
+
orgId: external_exports.string().min(1).max(64).optional(),
|
|
67303
|
+
// tenant context on an install-wide daemon connection
|
|
67304
|
+
payload: external_exports.unknown()
|
|
67305
|
+
// validated by the per-type schema
|
|
67306
|
+
});
|
|
67307
|
+
var ControlExt = external_exports.object({
|
|
67308
|
+
epoch: external_exports.number().int(),
|
|
67309
|
+
// sessionEpoch this frame was issued under (§3.1 fencing)
|
|
67310
|
+
agentId: external_exports.string().uuid().optional(),
|
|
67311
|
+
// present on agent-scoped frames
|
|
67312
|
+
launchId: external_exports.string().uuid().optional()
|
|
67313
|
+
// per-launch fence, §4.4
|
|
67314
|
+
});
|
|
67315
|
+
var NIL_UUID = "00000000-0000-0000-0000-000000000000";
|
|
67316
|
+
function frameSchema(type, payload) {
|
|
67317
|
+
return external_exports.object({
|
|
67318
|
+
v: external_exports.literal(1),
|
|
67319
|
+
id: external_exports.string().uuid(),
|
|
67320
|
+
ts: external_exports.string().datetime(),
|
|
67321
|
+
type: external_exports.literal(type),
|
|
67322
|
+
corr: external_exports.string().uuid().optional(),
|
|
67323
|
+
orgId: external_exports.string().min(1).max(64).optional(),
|
|
67324
|
+
payload
|
|
67325
|
+
});
|
|
67326
|
+
}
|
|
67327
|
+
|
|
67328
|
+
// ../protocol/src/tolerant.ts
|
|
67329
|
+
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
67330
|
+
var memo3 = /* @__PURE__ */ new WeakMap();
|
|
67331
|
+
function tolerantReader(schema) {
|
|
67332
|
+
const hit = memo3.get(schema);
|
|
67333
|
+
if (hit) return hit;
|
|
67334
|
+
const built = rebuild(schema);
|
|
67335
|
+
memo3.set(schema, built);
|
|
67336
|
+
return built;
|
|
67337
|
+
}
|
|
67338
|
+
function tolerantSchemas(schemas) {
|
|
67339
|
+
return Object.fromEntries(Object.entries(schemas).map(([type, schema]) => [type, tolerantReader(schema)]));
|
|
67340
|
+
}
|
|
67341
|
+
function isSchema(value) {
|
|
67342
|
+
return typeof value === "object" && value !== null && "_zod" in value;
|
|
67343
|
+
}
|
|
67344
|
+
function defOf(schema) {
|
|
67345
|
+
return schema._zod.def;
|
|
67346
|
+
}
|
|
67347
|
+
function child(value) {
|
|
67348
|
+
return tolerantReader(value);
|
|
67349
|
+
}
|
|
67350
|
+
function withDef(schema, def) {
|
|
67351
|
+
return external_exports.clone(schema, def);
|
|
67352
|
+
}
|
|
67353
|
+
function rebuild(schema) {
|
|
67354
|
+
const def = defOf(schema);
|
|
67355
|
+
switch (def.type) {
|
|
67356
|
+
case "object": {
|
|
67357
|
+
const shape = Object.fromEntries(
|
|
67358
|
+
Object.entries(def.shape).map(([key, value]) => [key, child(value)])
|
|
67359
|
+
);
|
|
67360
|
+
const catchall = isNeverSchema(def.catchall) ? void 0 : def.catchall ? child(def.catchall) : void 0;
|
|
67361
|
+
return withDef(schema, { ...def, shape, catchall });
|
|
67362
|
+
}
|
|
67363
|
+
case "array":
|
|
67364
|
+
return withDef(schema, { ...def, element: child(def.element) });
|
|
67365
|
+
// Both plain and discriminated unions; the discriminator rides along in the spread def.
|
|
67366
|
+
case "union":
|
|
67367
|
+
return withDef(schema, { ...def, options: def.options.map(child) });
|
|
67368
|
+
case "intersection":
|
|
67369
|
+
return withDef(schema, { ...def, left: child(def.left), right: child(def.right) });
|
|
67370
|
+
case "tuple":
|
|
67371
|
+
return withDef(schema, {
|
|
67372
|
+
...def,
|
|
67373
|
+
items: def.items.map(child),
|
|
67374
|
+
...isSchema(def.rest) ? { rest: child(def.rest) } : {}
|
|
67375
|
+
});
|
|
67376
|
+
case "record":
|
|
67377
|
+
case "map":
|
|
67378
|
+
return withDef(schema, { ...def, keyType: child(def.keyType), valueType: child(def.valueType) });
|
|
67379
|
+
case "set":
|
|
67380
|
+
return withDef(schema, { ...def, valueType: child(def.valueType) });
|
|
67381
|
+
case "optional":
|
|
67382
|
+
case "nullable":
|
|
67383
|
+
case "nonoptional":
|
|
67384
|
+
case "default":
|
|
67385
|
+
case "prefault":
|
|
67386
|
+
case "catch":
|
|
67387
|
+
case "readonly":
|
|
67388
|
+
case "promise":
|
|
67389
|
+
return withDef(schema, { ...def, innerType: child(def.innerType) });
|
|
67390
|
+
case "pipe":
|
|
67391
|
+
return withDef(schema, { ...def, in: child(def.in), out: child(def.out) });
|
|
67392
|
+
case "lazy":
|
|
67393
|
+
return external_exports.lazy(() => child(def.getter()));
|
|
67394
|
+
default:
|
|
67395
|
+
return schema;
|
|
67396
|
+
}
|
|
67397
|
+
}
|
|
67398
|
+
function isNeverSchema(value) {
|
|
67399
|
+
return isSchema(value) && defOf(value).type === "never";
|
|
67400
|
+
}
|
|
67401
|
+
|
|
67402
|
+
// ../protocol/src/wire.ts
|
|
67403
|
+
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
67404
|
+
import { randomUUID } from "node:crypto";
|
|
67405
|
+
var MAX_FRAME_BYTES = 256 * 1024;
|
|
67406
|
+
var REPLY_BUDGET = MAX_FRAME_BYTES - 4096;
|
|
67407
|
+
var textEncoder = new TextEncoder();
|
|
67408
|
+
function byteLength(text) {
|
|
67409
|
+
return textEncoder.encode(text).length;
|
|
67410
|
+
}
|
|
67411
|
+
function extractControlExt(json5) {
|
|
67412
|
+
if (typeof json5 !== "object" || json5 === null) return void 0;
|
|
67413
|
+
const o = json5;
|
|
67414
|
+
const ext = {};
|
|
67415
|
+
if (typeof o.epoch === "number") ext.epoch = o.epoch;
|
|
67416
|
+
if (typeof o.agentId === "string") ext.agentId = o.agentId;
|
|
67417
|
+
if (typeof o.launchId === "string") ext.launchId = o.launchId;
|
|
67418
|
+
return Object.keys(ext).length > 0 ? ext : void 0;
|
|
67419
|
+
}
|
|
67420
|
+
function decodeEnvelopeWith(schemas, text, opts = {}) {
|
|
67421
|
+
if (byteLength(text) > (opts.maxBytes ?? MAX_FRAME_BYTES)) {
|
|
67422
|
+
return { ok: false, id: NIL_UUID, msg: "FRAME_TOO_LARGE" };
|
|
67423
|
+
}
|
|
67424
|
+
let json5;
|
|
67425
|
+
try {
|
|
67426
|
+
json5 = JSON.parse(text);
|
|
67427
|
+
} catch {
|
|
67428
|
+
return { ok: false, id: NIL_UUID, msg: "invalid json" };
|
|
67429
|
+
}
|
|
67430
|
+
const env = Envelope.safeParse(json5);
|
|
67431
|
+
if (!env.success) {
|
|
67432
|
+
const id = typeof json5 === "object" && json5 !== null && typeof json5.id === "string" ? json5.id : NIL_UUID;
|
|
67433
|
+
return { ok: false, id, msg: env.error.message };
|
|
67434
|
+
}
|
|
67435
|
+
const schema = Object.hasOwn(schemas, env.data.type) ? schemas[env.data.type] : void 0;
|
|
67436
|
+
if (!schema) {
|
|
67437
|
+
return {
|
|
67438
|
+
ok: false,
|
|
67439
|
+
id: env.data.id,
|
|
67440
|
+
msg: "UNKNOWN_FRAME",
|
|
67441
|
+
...env.data.corr ? { corr: env.data.corr } : {}
|
|
67442
|
+
};
|
|
67443
|
+
}
|
|
67444
|
+
const payload = schema.safeParse(env.data.payload);
|
|
67445
|
+
if (!payload.success) {
|
|
67446
|
+
return {
|
|
67447
|
+
ok: false,
|
|
67448
|
+
id: env.data.id,
|
|
67449
|
+
msg: payload.error.message,
|
|
67450
|
+
...env.data.corr ? { corr: env.data.corr } : {}
|
|
67451
|
+
};
|
|
67452
|
+
}
|
|
67453
|
+
const ext = extractControlExt(json5);
|
|
67454
|
+
return {
|
|
67455
|
+
ok: true,
|
|
67456
|
+
frame: { ...env.data, payload: payload.data },
|
|
67457
|
+
...ext ? { ext } : {}
|
|
67458
|
+
};
|
|
67459
|
+
}
|
|
67460
|
+
function buildEnvelopeRaw(type, payload, opts = {}) {
|
|
67461
|
+
return {
|
|
67462
|
+
v: 1,
|
|
67463
|
+
id: opts.id ?? randomUUID(),
|
|
67464
|
+
ts: opts.ts ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
67465
|
+
type,
|
|
67466
|
+
payload,
|
|
67467
|
+
...opts.corr ? { corr: opts.corr } : {},
|
|
67468
|
+
...opts.orgId ? { orgId: opts.orgId } : {},
|
|
67469
|
+
...opts.ext ?? {}
|
|
67470
|
+
};
|
|
67471
|
+
}
|
|
67472
|
+
|
|
67473
|
+
// ../protocol/src/frames/error.ts
|
|
67474
|
+
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
67475
|
+
var ErrorCode = external_exports.enum([
|
|
67476
|
+
// protocol / framing
|
|
67477
|
+
"UNKNOWN_FRAME",
|
|
67478
|
+
"FRAME_TOO_LARGE",
|
|
67479
|
+
"PROTOCOL_STATE",
|
|
67480
|
+
"BAD_PAYLOAD",
|
|
67481
|
+
// auth / identity
|
|
67482
|
+
"AUTH_FAILED",
|
|
67483
|
+
"ATTESTATION_INVALID",
|
|
67484
|
+
// fencing / ordering
|
|
67485
|
+
"STALE_EPOCH",
|
|
67486
|
+
"STALE_LAUNCH",
|
|
67487
|
+
// delivery
|
|
67488
|
+
"NO_SESSION",
|
|
67489
|
+
"SCOPE_DENIED",
|
|
67490
|
+
// delegated MCP authority / invocation binding
|
|
67491
|
+
"DELEGATION_DENIED",
|
|
67492
|
+
"INVOCATION_CONFLICT",
|
|
67493
|
+
// secrets
|
|
67494
|
+
"LEASE_EXPIRED",
|
|
67495
|
+
"LEASE_DENIED",
|
|
67496
|
+
// generic
|
|
67497
|
+
"RATE_LIMITED",
|
|
67498
|
+
"CONFLICT",
|
|
67499
|
+
"INTERNAL"
|
|
67500
|
+
]);
|
|
67501
|
+
var ErrorFrame = external_exports.object({
|
|
67502
|
+
code: ErrorCode,
|
|
67503
|
+
message: external_exports.string(),
|
|
67504
|
+
// human-readable, redacted of secrets
|
|
67505
|
+
retryable: external_exports.boolean(),
|
|
67506
|
+
details: external_exports.record(external_exports.string(), external_exports.unknown()).optional()
|
|
67507
|
+
});
|
|
67508
|
+
|
|
67509
|
+
// ../protocol/src/frames/computer-lease.ts
|
|
67510
|
+
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
67511
|
+
var ComputerDesktopId = external_exports.string().regex(/^[A-Za-z0-9_-]{1,32}$/);
|
|
67512
|
+
var COMPUTER_LEASE_AGENT_NAME_MAX = 200;
|
|
67513
|
+
var ComputerLeaseHolder = external_exports.object({
|
|
67514
|
+
sessionId: external_exports.string().min(1).max(256),
|
|
67515
|
+
agentId: external_exports.string().uuid(),
|
|
67516
|
+
agentName: external_exports.string().min(1).max(COMPUTER_LEASE_AGENT_NAME_MAX).optional()
|
|
67517
|
+
});
|
|
67518
|
+
var computerLeaseHolderName = (holder) => `${holder.agentId}/${holder.sessionId}`;
|
|
67519
|
+
var ComputerControlLease = external_exports.object({
|
|
67520
|
+
leaseId: external_exports.string().uuid(),
|
|
67521
|
+
computerId: external_exports.string().uuid(),
|
|
67522
|
+
holder: ComputerLeaseHolder,
|
|
67523
|
+
acquiredAt: external_exports.string().datetime(),
|
|
67524
|
+
expiresAt: external_exports.string().datetime(),
|
|
67525
|
+
// Behind `computer-desktops-v1`: the agent desktop it covers, keyed by that agent's id; absent, the main desktop.
|
|
67526
|
+
desktop: external_exports.string().uuid().optional()
|
|
67527
|
+
});
|
|
67528
|
+
var COMPUTER_LEASE_REFUSALS = ["computer_busy", "human_in_control", "unavailable", "denied"];
|
|
67529
|
+
var COMPUTER_LEASE_POLL_MAX_MS = 1e4;
|
|
67530
|
+
var COMPUTER_LEASE_WAIT_MAX_SECONDS = 600;
|
|
67531
|
+
var ComputerLeaseAcquire = external_exports.object({
|
|
67532
|
+
computerId: external_exports.string().uuid(),
|
|
67533
|
+
agentId: external_exports.string().uuid(),
|
|
67534
|
+
sessionId: external_exports.string().min(1).max(256),
|
|
67535
|
+
// The daemon-clock time of the request, compared with the `event/session` turn end on the same clock.
|
|
67536
|
+
requestedAt: external_exports.string().datetime(),
|
|
67537
|
+
// Behind COMPUTER_LEASE_QUEUE_FEATURE: wait in the Computer's FIFO queue, holding the reply up to this long.
|
|
67538
|
+
waitMs: external_exports.number().int().min(0).max(COMPUTER_LEASE_POLL_MAX_MS).optional()
|
|
67539
|
+
});
|
|
67540
|
+
var ComputerLeaseQueued = external_exports.object({
|
|
67541
|
+
position: external_exports.number().int().min(1),
|
|
67542
|
+
waitedMs: external_exports.number().int().min(0),
|
|
67543
|
+
// Time left before the wait ends in `computer_busy`.
|
|
67544
|
+
leftMs: external_exports.number().int().min(0)
|
|
67545
|
+
});
|
|
67546
|
+
var ComputerLeaseAcquireResult = external_exports.discriminatedUnion("granted", [
|
|
67547
|
+
external_exports.object({ granted: external_exports.literal(true), lease: ComputerControlLease }),
|
|
67548
|
+
external_exports.object({
|
|
67549
|
+
granted: external_exports.literal(false),
|
|
67550
|
+
code: external_exports.enum(COMPUTER_LEASE_REFUSALS),
|
|
67551
|
+
message: external_exports.string().max(500),
|
|
67552
|
+
holder: ComputerLeaseHolder.optional(),
|
|
67553
|
+
queued: ComputerLeaseQueued.optional()
|
|
67554
|
+
})
|
|
67555
|
+
]);
|
|
67556
|
+
var ComputerLeaseRelease = external_exports.object({
|
|
67557
|
+
computerId: external_exports.string().uuid(),
|
|
67558
|
+
agentId: external_exports.string().uuid(),
|
|
67559
|
+
sessionId: external_exports.string().min(1).max(256)
|
|
67560
|
+
});
|
|
67561
|
+
|
|
67562
|
+
// ../protocol/src/frames/computer-channel.ts
|
|
67563
|
+
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
67564
|
+
|
|
67565
|
+
// ../protocol/src/computer-channel-token.ts
|
|
67566
|
+
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
67567
|
+
import { createHmac, timingSafeEqual } from "node:crypto";
|
|
67568
|
+
|
|
67569
|
+
// ../protocol/src/computer-viewer.ts
|
|
67570
|
+
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
67571
|
+
var COMPUTER_VIEWER_API_PREFIX = "/view/api/";
|
|
67572
|
+
var COMPUTER_VIEWER_MAX_REQUEST_BYTES = 64 * 1024;
|
|
67573
|
+
var COMPUTER_VIEWER_TRANSPORTS = ["direct", "stun", "turn"];
|
|
67574
|
+
var ComputerIceServer = external_exports.object({
|
|
67575
|
+
urls: external_exports.array(
|
|
67576
|
+
external_exports.string().regex(/^turns?:/).max(256)
|
|
67577
|
+
).min(1).max(4),
|
|
67578
|
+
username: external_exports.string().min(1).max(256),
|
|
67579
|
+
credential: external_exports.string().min(1).max(256)
|
|
67580
|
+
}).strict();
|
|
67581
|
+
var COMPUTER_ICE_SERVERS_MAX = 2;
|
|
67582
|
+
var ComputerStunUrl = external_exports.string().max(256).regex(/^stun:(\[[0-9a-fA-F:.]+\]|[A-Za-z0-9.-]+)(:\d{1,5})?$/, "expected stun:<host>[:<port>]");
|
|
67583
|
+
var ComputerTurnUrl = external_exports.string().max(256).regex(
|
|
67584
|
+
/^turns?:(\[[0-9a-fA-F:.]+\]|[A-Za-z0-9.-]+)(:\d{1,5})?(\?transport=(udp|tcp))?$/,
|
|
67585
|
+
"expected turn:<host>[:<port>][?transport=udp|tcp] or turns:"
|
|
67586
|
+
);
|
|
67587
|
+
var COMPUTER_STUN_URLS_MAX = 2;
|
|
67588
|
+
var ComputerViewerCandidate = external_exports.object({
|
|
67589
|
+
id: external_exports.string().min(1).max(64),
|
|
67590
|
+
candidate: external_exports.object({
|
|
67591
|
+
candidate: external_exports.string().max(1024),
|
|
67592
|
+
sdpMid: external_exports.string().max(64).nullish(),
|
|
67593
|
+
sdpMLineIndex: external_exports.number().int().min(0).max(64).nullish()
|
|
67594
|
+
}).nullable()
|
|
67595
|
+
});
|
|
67596
|
+
var ComputerViewerCandidatesRequest = external_exports.object({
|
|
67597
|
+
id: external_exports.string().min(1).max(64),
|
|
67598
|
+
after: external_exports.number().int().min(0).max(1e3).default(0)
|
|
67599
|
+
});
|
|
67600
|
+
var ComputerViewerOfferRequest = external_exports.object({ transport: external_exports.enum(COMPUTER_VIEWER_TRANSPORTS).optional() });
|
|
67601
|
+
var ComputerViewerRenewal = external_exports.object({ type: external_exports.literal("auth"), token: external_exports.string().min(1).max(4096) });
|
|
67602
|
+
|
|
67603
|
+
// ../protocol/src/computer-command-line.ts
|
|
67604
|
+
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
67605
|
+
var COMPUTER_SHELL_MODES = ["off", "ask", "on"];
|
|
67606
|
+
var COMPUTER_FILES_MODES = ["off", "read", "read-write"];
|
|
67607
|
+
var COMPUTER_FILE_ROOTS_MAX = 32;
|
|
67608
|
+
var ComputerFileRoot = external_exports.string().trim().min(1).max(1024).refine((p) => /^(\/|~(\/|$)|[A-Za-z]:[\\/])/.test(p) && !p.includes("\0"), "expected an absolute path");
|
|
67609
|
+
var COMPUTER_EXEC_TIMEOUT_DEFAULT_MS = 3e4;
|
|
67610
|
+
var COMPUTER_EXEC_TIMEOUT_MAX_MS = 9e4;
|
|
67611
|
+
var COMPUTER_EXEC_COMMAND_MAX_CHARS = 16384;
|
|
67612
|
+
var COMPUTER_EXEC_OUTPUT_TAIL_BYTES = 32 * 1024;
|
|
67613
|
+
var COMPUTER_EXEC_PER_SESSION_MAX = 4;
|
|
67614
|
+
var COMPUTER_EXEC_TOTAL_MAX = 8;
|
|
67615
|
+
var COMPUTER_READ_TEXT_MAX_BYTES = 256 * 1024;
|
|
67616
|
+
var COMPUTER_READ_IMAGE_MAX_BYTES = 5 * 1024 * 1024;
|
|
67617
|
+
var COMPUTER_WRITE_MAX_BYTES = 1024 * 1024;
|
|
67618
|
+
var COMPUTER_LIST_DIR_MAX = 1e3;
|
|
67619
|
+
var SHELL_RANK = { off: 0, ask: 1, on: 2 };
|
|
67620
|
+
var FILES_RANK = { off: 0, read: 1, "read-write": 2 };
|
|
67621
|
+
var narrowerShell = (a, b) => SHELL_RANK[a] <= SHELL_RANK[b] ? a : b;
|
|
67622
|
+
var narrowerFiles = (a, b) => FILES_RANK[a] <= FILES_RANK[b] ? a : b;
|
|
67623
|
+
|
|
67624
|
+
// ../protocol/src/computer-channel-token.ts
|
|
67625
|
+
var COMPUTER_CHANNEL_TOKEN_PREFIX = "actk1";
|
|
67626
|
+
var COMPUTER_CHANNEL_TOKEN_AUDIENCES = ["mcp", "relay", "view"];
|
|
67627
|
+
var COMPUTER_CHANNEL_TOKEN_MAX_TTL_MS = 5 * 6e4;
|
|
67628
|
+
var COMPUTER_AGENT_MODES = ["view", "control"];
|
|
67629
|
+
var ComputerChannelTokenClaims = external_exports.object({
|
|
67630
|
+
aud: external_exports.enum(COMPUTER_CHANNEL_TOKEN_AUDIENCES),
|
|
67631
|
+
// The Computer the token is for, and the id of the channel key that signed it.
|
|
67632
|
+
cmp: external_exports.string().uuid(),
|
|
67633
|
+
kid: external_exports.string().min(1).max(64),
|
|
67634
|
+
// Issue and expiry times, epoch milliseconds on the issuer's clock.
|
|
67635
|
+
iat: external_exports.number().int().nonnegative(),
|
|
67636
|
+
exp: external_exports.number().int().positive(),
|
|
67637
|
+
// `mcp` only: the agent session the calls belong to, its agent and daemon, and what the policy lets it do.
|
|
67638
|
+
ses: external_exports.string().min(1).max(256).optional(),
|
|
67639
|
+
agt: external_exports.string().uuid().optional(),
|
|
67640
|
+
dmn: external_exports.string().uuid().optional(),
|
|
67641
|
+
mode: external_exports.enum(COMPUTER_AGENT_MODES).optional(),
|
|
67642
|
+
// `mcp` only: the command-line tier the policy allows (§5.7); absent, as from an older CP, means none.
|
|
67643
|
+
sh: external_exports.enum(COMPUTER_SHELL_MODES).optional(),
|
|
67644
|
+
fs: external_exports.enum(COMPUTER_FILES_MODES).optional(),
|
|
67645
|
+
// `view` only: the member watching, the TURN servers the desktop may relay media through, and the STUN servers it may punch with.
|
|
67646
|
+
usr: external_exports.string().min(1).max(128).optional(),
|
|
67647
|
+
ice: external_exports.array(ComputerIceServer).max(COMPUTER_ICE_SERVERS_MAX).optional(),
|
|
67648
|
+
stun: external_exports.array(ComputerStunUrl).max(COMPUTER_STUN_URLS_MAX).optional(),
|
|
67649
|
+
// `view` only, behind `computer-desktops-v1`: the one desktop it may watch (§3.9); absent, the main desktop.
|
|
67650
|
+
dsk: ComputerDesktopId.optional()
|
|
67651
|
+
}).strip().refine((c) => c.aud !== "mcp" || c.ses !== void 0 && c.agt !== void 0 && c.mode !== void 0, {
|
|
67652
|
+
message: "an mcp token names its session, agent and mode"
|
|
67653
|
+
}).refine((c) => c.aud !== "view" || c.usr !== void 0 && c.mode !== void 0, {
|
|
67654
|
+
message: "a view token names its member and mode"
|
|
67655
|
+
}).refine((c) => c.exp > c.iat && c.exp - c.iat <= COMPUTER_CHANNEL_TOKEN_MAX_TTL_MS, {
|
|
67656
|
+
message: "token lifetime out of range"
|
|
67657
|
+
});
|
|
67658
|
+
var MAC_DOMAIN = "agentconnect/computer-channel-token/v1\n";
|
|
67659
|
+
var MAX_TOKEN_CHARS = 4096;
|
|
67660
|
+
function mac3(key, signed) {
|
|
67661
|
+
return createHmac("sha256", key).update(MAC_DOMAIN + signed).digest();
|
|
67662
|
+
}
|
|
67663
|
+
function signComputerChannelToken(claims, key) {
|
|
67664
|
+
const parsed = ComputerChannelTokenClaims.parse(claims);
|
|
67665
|
+
const signed = `${COMPUTER_CHANNEL_TOKEN_PREFIX}.${Buffer.from(JSON.stringify(parsed)).toString("base64url")}`;
|
|
67666
|
+
return `${signed}.${mac3(key, signed).toString("base64url")}`;
|
|
67667
|
+
}
|
|
67668
|
+
function readComputerChannelToken(token) {
|
|
67669
|
+
if (token.length > MAX_TOKEN_CHARS) return null;
|
|
67670
|
+
const parts = token.split(".");
|
|
67671
|
+
if (parts.length !== 3 || parts[0] !== COMPUTER_CHANNEL_TOKEN_PREFIX) return null;
|
|
67672
|
+
try {
|
|
67673
|
+
const parsed = ComputerChannelTokenClaims.safeParse(JSON.parse(Buffer.from(parts[1], "base64url").toString()));
|
|
67674
|
+
return parsed.success ? parsed.data : null;
|
|
67675
|
+
} catch {
|
|
67676
|
+
return null;
|
|
67677
|
+
}
|
|
67678
|
+
}
|
|
67679
|
+
function verifyComputerChannelToken(token, opts) {
|
|
67680
|
+
const claims = readComputerChannelToken(token);
|
|
67681
|
+
if (!claims || claims.aud !== opts.aud || claims.cmp !== opts.computerId) return null;
|
|
67682
|
+
if (!(claims.exp > opts.now)) return null;
|
|
67683
|
+
const key = opts.key(claims.kid);
|
|
67684
|
+
if (!key) return null;
|
|
67685
|
+
const at = token.lastIndexOf(".");
|
|
67686
|
+
const presented = Buffer.from(token.slice(at + 1), "base64url");
|
|
67687
|
+
const expected = mac3(key, token.slice(0, at));
|
|
67688
|
+
if (presented.length !== expected.length || !timingSafeEqual(presented, expected)) return null;
|
|
67689
|
+
return claims;
|
|
67690
|
+
}
|
|
67691
|
+
|
|
67692
|
+
// ../protocol/src/frames/computer-channel.ts
|
|
67693
|
+
var ComputerRelayEntry = external_exports.object({
|
|
67694
|
+
relayId: external_exports.string().uuid(),
|
|
67695
|
+
url: external_exports.string().min(1).max(2048)
|
|
67696
|
+
});
|
|
67697
|
+
var COMPUTER_RELAYS_MAX = 64;
|
|
67698
|
+
var COMPUTER_ADMIN_PROMPT_MODES = ["agent", "people", "approve", "deny"];
|
|
67699
|
+
var DEFAULT_COMPUTER_ADMIN_PROMPT_MODE = "people";
|
|
67700
|
+
var ComputerApprovalsSchema = external_exports.object({
|
|
67701
|
+
// Ask before a session's first click, drag, type, key or launch; an allow covers the rest of the session.
|
|
67702
|
+
firstInputPerSession: external_exports.boolean().default(true),
|
|
67703
|
+
// Windows only; absent means the default, so policies stored before it keep their meaning.
|
|
67704
|
+
adminPrompts: external_exports.enum(COMPUTER_ADMIN_PROMPT_MODES).optional()
|
|
67705
|
+
});
|
|
67706
|
+
var ComputerGrantApprovalsSchema = ComputerApprovalsSchema.extend({
|
|
67707
|
+
launchApp: external_exports.enum(["always", "session", "never-ask"]).optional(),
|
|
67708
|
+
submitLikeKeys: external_exports.boolean().optional()
|
|
67709
|
+
});
|
|
67710
|
+
var COMPUTER_CHANNEL_REFUSALS = ["denied", "unavailable"];
|
|
67711
|
+
var ComputerChannelGrantRequest = external_exports.object({
|
|
67712
|
+
computerId: external_exports.string().uuid(),
|
|
67713
|
+
agentId: external_exports.string().uuid(),
|
|
67714
|
+
sessionId: external_exports.string().min(1).max(256)
|
|
67715
|
+
});
|
|
67716
|
+
var ComputerChannelGrantResult = external_exports.discriminatedUnion("granted", [
|
|
67717
|
+
external_exports.object({
|
|
67718
|
+
granted: external_exports.literal(true),
|
|
67719
|
+
token: external_exports.string().min(1).max(2048),
|
|
67720
|
+
expiresAt: external_exports.string().datetime(),
|
|
67721
|
+
mode: external_exports.enum(COMPUTER_AGENT_MODES),
|
|
67722
|
+
relays: external_exports.array(ComputerRelayEntry).max(COMPUTER_RELAYS_MAX),
|
|
67723
|
+
// What the approval cards name and whom they also reach (§4.2); an older CP sends none, and every approval is asked.
|
|
67724
|
+
name: external_exports.string().min(1).max(200).optional(),
|
|
67725
|
+
ownerUserId: external_exports.string().min(1).max(128).optional(),
|
|
67726
|
+
approvals: ComputerGrantApprovalsSchema.optional(),
|
|
67727
|
+
// The console users who may answer its approvals: the Computer's allowed members; an older CP sends none.
|
|
67728
|
+
approvers: external_exports.array(external_exports.string().min(1).max(128)).max(500).optional(),
|
|
67729
|
+
// The command-line tier the token allows (§5.7); an older CP sends none, which allows none.
|
|
67730
|
+
shell: external_exports.enum(COMPUTER_SHELL_MODES).optional(),
|
|
67731
|
+
files: external_exports.enum(COMPUTER_FILES_MODES).optional()
|
|
67732
|
+
}),
|
|
67733
|
+
external_exports.object({
|
|
67734
|
+
granted: external_exports.literal(false),
|
|
67735
|
+
code: external_exports.enum(COMPUTER_CHANNEL_REFUSALS),
|
|
67736
|
+
message: external_exports.string().max(500)
|
|
67737
|
+
})
|
|
67738
|
+
]);
|
|
67739
|
+
|
|
67740
|
+
// ../protocol/src/frames/computer-audit.ts
|
|
67741
|
+
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
67742
|
+
var COMPUTER_AUDIT_FEATURE = "computer-audit-v1";
|
|
67743
|
+
var COMPUTER_APPROVAL_META_KEY = "md.agentconnect/approval";
|
|
67744
|
+
var COMPUTER_APPROVAL_RESULTS = ["not_required", "allowed", "allowed_session"];
|
|
67745
|
+
var COMPUTER_AUDIT_BATCH_MAX = 100;
|
|
67746
|
+
var COMPUTER_AUDIT_BATCH_BYTES = REPLY_BUDGET;
|
|
67747
|
+
var COMPUTER_AUDIT_ARGS_MAX_CHARS = 2048;
|
|
67748
|
+
var AUDIT_STRING_MAX = 256;
|
|
67749
|
+
var AUDIT_COMMAND_MAX = 1536;
|
|
67750
|
+
var AUDIT_DEPTH_MAX = 6;
|
|
67751
|
+
var TEXT_KEYS = /* @__PURE__ */ new Set(["text", "value", "content"]);
|
|
67752
|
+
var CONTROL_CHARS = /[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/g;
|
|
67753
|
+
var LONE_SURROGATE = /[\ud800-\udbff](?![\udc00-\udfff])|(?<![\ud800-\udbff])[\udc00-\udfff]/g;
|
|
67754
|
+
function computerAuditText(value) {
|
|
67755
|
+
return value.replace(CONTROL_CHARS, "").replace(LONE_SURROGATE, "\uFFFD");
|
|
67756
|
+
}
|
|
67757
|
+
function auditValue(value, depth) {
|
|
67758
|
+
if (typeof value === "string") return computerAuditText(value.slice(0, AUDIT_STRING_MAX));
|
|
67759
|
+
if (value === null || typeof value !== "object") return value;
|
|
67760
|
+
if (depth >= AUDIT_DEPTH_MAX) return "[nested]";
|
|
67761
|
+
if (Array.isArray(value)) return value.map((item) => auditValue(item, depth + 1));
|
|
67762
|
+
const out = {};
|
|
67763
|
+
for (const [key, item] of Object.entries(value))
|
|
67764
|
+
out[computerAuditText(key.slice(0, 64))] = auditValue(item, depth + 1);
|
|
67765
|
+
return out;
|
|
67766
|
+
}
|
|
67767
|
+
function computerAuditArgs(args) {
|
|
67768
|
+
let textLength;
|
|
67769
|
+
const out = {};
|
|
67770
|
+
for (const [key, value] of Object.entries(args)) {
|
|
67771
|
+
if (TEXT_KEYS.has(key) && typeof value === "string") {
|
|
67772
|
+
textLength = (textLength ?? 0) + [...value].length;
|
|
67773
|
+
continue;
|
|
67774
|
+
}
|
|
67775
|
+
out[computerAuditText(key.slice(0, 64))] = key === "command" && typeof value === "string" ? computerAuditText(value.slice(0, AUDIT_COMMAND_MAX)) : auditValue(value, 1);
|
|
67776
|
+
}
|
|
67777
|
+
const bounded = JSON.stringify(out).length <= COMPUTER_AUDIT_ARGS_MAX_CHARS ? out : { truncated: true };
|
|
67778
|
+
return { args: bounded, ...textLength !== void 0 ? { textLength } : {} };
|
|
67779
|
+
}
|
|
67780
|
+
var ComputerAuditEntry = external_exports.object({
|
|
67781
|
+
// Idempotency: a batch resent after a lost ack does not duplicate rows.
|
|
67782
|
+
id: external_exports.string().uuid(),
|
|
67783
|
+
at: external_exports.string().datetime(),
|
|
67784
|
+
tool: external_exports.string().min(1).max(128),
|
|
67785
|
+
// The lease holder name: `agentId/sessionId` for an agent session, else a local client or viewer name.
|
|
67786
|
+
client: external_exports.string().min(1).max(512),
|
|
67787
|
+
agentId: external_exports.string().uuid().optional(),
|
|
67788
|
+
sessionId: external_exports.string().min(1).max(256).optional(),
|
|
67789
|
+
outcome: external_exports.enum(["ok", "error"]),
|
|
67790
|
+
code: external_exports.string().min(1).max(64).optional(),
|
|
67791
|
+
approval: external_exports.enum(COMPUTER_APPROVAL_RESULTS).optional(),
|
|
67792
|
+
args: external_exports.record(external_exports.string().max(64), external_exports.unknown()).refine((args) => JSON.stringify(args).length <= COMPUTER_AUDIT_ARGS_MAX_CHARS, "audit args too large").optional(),
|
|
67793
|
+
textLength: external_exports.number().int().min(0).max(1e6).optional(),
|
|
67794
|
+
ms: external_exports.number().int().min(0),
|
|
67795
|
+
// The stored screenshot this call returned (§9), as `sha256:<hex>`.
|
|
67796
|
+
screenshotRef: external_exports.string().min(1).max(1024).optional(),
|
|
67797
|
+
// Behind `computer-desktops-v1`: the agent desktop that served it (§3.9); absent, the main desktop.
|
|
67798
|
+
desktop: ComputerDesktopId.optional()
|
|
67799
|
+
}).strict();
|
|
67800
|
+
var ComputerAuditReport = external_exports.object({
|
|
67801
|
+
entries: external_exports.array(ComputerAuditEntry).min(1).max(COMPUTER_AUDIT_BATCH_MAX)
|
|
67802
|
+
});
|
|
67803
|
+
var ComputerAuditAck = external_exports.object({ stored: external_exports.number().int().min(0) });
|
|
67804
|
+
|
|
67805
|
+
// ../protocol/src/frames/computer-screenshot.ts
|
|
67806
|
+
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
67807
|
+
var COMPUTER_SCREENSHOT_FEATURE = "computer-screenshot-v1";
|
|
67808
|
+
var COMPUTER_SCREENSHOT_RETENTION_MAX_DAYS = 3650;
|
|
67809
|
+
var COMPUTER_SCREENSHOT_MAX_BYTES = 32 * 1024 * 1024;
|
|
67810
|
+
var COMPUTER_SCREENSHOT_CONTENT_TYPES = ["image/png", "image/jpeg", "image/webp"];
|
|
67811
|
+
var REF_PREFIX = "sha256:";
|
|
67812
|
+
var SHA256_HEX_RE = /^[0-9a-f]{64}$/;
|
|
67813
|
+
var ComputerScreenshotSha256 = external_exports.string().regex(SHA256_HEX_RE, "expected a lower-case hex SHA-256");
|
|
67814
|
+
function computerScreenshotRef(sha2563) {
|
|
67815
|
+
return `${REF_PREFIX}${sha2563}`;
|
|
67816
|
+
}
|
|
67817
|
+
var ComputerScreenshotPut = external_exports.object({
|
|
67818
|
+
sessionId: external_exports.string().min(1).max(256),
|
|
67819
|
+
agentId: external_exports.string().uuid(),
|
|
67820
|
+
sha256: ComputerScreenshotSha256,
|
|
67821
|
+
bytes: external_exports.number().int().positive().max(COMPUTER_SCREENSHOT_MAX_BYTES),
|
|
67822
|
+
contentType: external_exports.enum(COMPUTER_SCREENSHOT_CONTENT_TYPES),
|
|
67823
|
+
takenAt: external_exports.string().datetime()
|
|
67824
|
+
}).strict();
|
|
67825
|
+
var ComputerScreenshotPutOk = external_exports.object({
|
|
67826
|
+
status: external_exports.enum(["upload", "stored", "skipped"]),
|
|
67827
|
+
url: external_exports.string().url().optional(),
|
|
67828
|
+
headers: external_exports.record(external_exports.string(), external_exports.string()).optional(),
|
|
67829
|
+
expiresAt: external_exports.string().datetime().optional(),
|
|
67830
|
+
reason: external_exports.string().max(200).optional()
|
|
67831
|
+
});
|
|
67832
|
+
var ComputerScreenshotCommit = external_exports.object({ sessionId: external_exports.string().min(1).max(256), sha256: ComputerScreenshotSha256 }).strict();
|
|
67833
|
+
var ComputerScreenshotCommitOk = external_exports.object({ stored: external_exports.boolean() });
|
|
67834
|
+
|
|
67835
|
+
// ../protocol/src/frames/relay-computer.ts
|
|
67836
|
+
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
67837
|
+
var RELAY_COMPUTER_SUBPROTOCOL = "agentconnect.cr.v1";
|
|
67838
|
+
var RELAY_COMPUTER_WS_PATH = "/cr/ws";
|
|
67839
|
+
var RELAY_COMPUTER_MAX_BODY_BYTES = 8 * 1024 * 1024;
|
|
67840
|
+
var RELAY_COMPUTER_MAX_FRAME_BYTES = 12 * 1024 * 1024;
|
|
67841
|
+
var RELAY_DAEMON_PATH_SUFFIX = "/rd/ws";
|
|
67842
|
+
function relayUrlAt(relayUrl, path, scheme) {
|
|
67843
|
+
const url2 = new URL(relayUrl);
|
|
67844
|
+
const prefix = url2.pathname.endsWith(RELAY_DAEMON_PATH_SUFFIX) ? url2.pathname.slice(0, -RELAY_DAEMON_PATH_SUFFIX.length) : url2.pathname.replace(/\/+$/, "");
|
|
67845
|
+
for (const { from, to } of scheme) if (url2.protocol === from) url2.protocol = to;
|
|
67846
|
+
url2.pathname = `${prefix}${path}`;
|
|
67847
|
+
url2.search = "";
|
|
67848
|
+
url2.hash = "";
|
|
67849
|
+
return url2.toString();
|
|
67850
|
+
}
|
|
67851
|
+
function relayComputerWsUrl(relayUrl) {
|
|
67852
|
+
return relayUrlAt(relayUrl, RELAY_COMPUTER_WS_PATH, [
|
|
67853
|
+
{ from: "http:", to: "ws:" },
|
|
67854
|
+
{ from: "https:", to: "wss:" }
|
|
67855
|
+
]);
|
|
67856
|
+
}
|
|
67857
|
+
var Base64 = external_exports.string().regex(/^[A-Za-z0-9+/]*={0,2}$/);
|
|
67858
|
+
var Headers2 = external_exports.record(external_exports.string().min(1).max(256), external_exports.string().max(8192));
|
|
67859
|
+
var CrHello = external_exports.object({
|
|
67860
|
+
computerId: external_exports.string().uuid(),
|
|
67861
|
+
token: external_exports.string().min(1).max(2048),
|
|
67862
|
+
desktopDaemonVersion: external_exports.string().trim().min(1).max(64)
|
|
67863
|
+
}).strict();
|
|
67864
|
+
var CrHelloOk = external_exports.object({ relayId: external_exports.string().min(1).max(64) });
|
|
67865
|
+
var CrHttpRequest = external_exports.object({
|
|
67866
|
+
method: external_exports.enum(["GET", "POST", "DELETE"]),
|
|
67867
|
+
path: external_exports.string().min(1).max(2048),
|
|
67868
|
+
headers: Headers2,
|
|
67869
|
+
body: Base64.optional()
|
|
67870
|
+
});
|
|
67871
|
+
var CrHttpResponse = external_exports.object({
|
|
67872
|
+
status: external_exports.number().int().min(100).max(599),
|
|
67873
|
+
headers: Headers2,
|
|
67874
|
+
body: Base64.optional()
|
|
67875
|
+
});
|
|
67876
|
+
var RELAY_COMPUTER_SCHEMAS = {
|
|
67877
|
+
"cr/hello": CrHello,
|
|
67878
|
+
"cr/hello/ok": CrHelloOk,
|
|
67879
|
+
"cr/http": CrHttpRequest,
|
|
67880
|
+
"cr/http/result": CrHttpResponse,
|
|
67881
|
+
error: ErrorFrame
|
|
67882
|
+
};
|
|
67883
|
+
var RelayComputerFrame = external_exports.discriminatedUnion("type", [
|
|
67884
|
+
frameSchema("cr/hello", RELAY_COMPUTER_SCHEMAS["cr/hello"]),
|
|
67885
|
+
frameSchema("cr/hello/ok", RELAY_COMPUTER_SCHEMAS["cr/hello/ok"]),
|
|
67886
|
+
frameSchema("cr/http", RELAY_COMPUTER_SCHEMAS["cr/http"]),
|
|
67887
|
+
frameSchema("cr/http/result", RELAY_COMPUTER_SCHEMAS["cr/http/result"]),
|
|
67888
|
+
frameSchema("error", RELAY_COMPUTER_SCHEMAS["error"])
|
|
67889
|
+
]);
|
|
67890
|
+
function decodeRelayComputerFrame(text) {
|
|
67891
|
+
return decodeEnvelopeWith(RELAY_COMPUTER_SCHEMAS, text, {
|
|
67892
|
+
maxBytes: RELAY_COMPUTER_MAX_FRAME_BYTES
|
|
67893
|
+
});
|
|
67894
|
+
}
|
|
67895
|
+
function buildRelayComputerFrame(type, payload, opts = {}) {
|
|
67896
|
+
return buildEnvelopeRaw(type, payload, opts);
|
|
67897
|
+
}
|
|
67898
|
+
|
|
67899
|
+
// ../protocol/src/frames/computer-keys.ts
|
|
67900
|
+
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
67901
|
+
var COMPUTER_KEY_ALIASES = {
|
|
67902
|
+
enter: "return",
|
|
67903
|
+
esc: "escape",
|
|
67904
|
+
control: "ctrl",
|
|
67905
|
+
option: "alt"
|
|
67906
|
+
};
|
|
67907
|
+
function normalizeComputerKey(key) {
|
|
67908
|
+
const lowered = key.trim().toLowerCase();
|
|
67909
|
+
return COMPUTER_KEY_ALIASES[lowered] ?? lowered;
|
|
67910
|
+
}
|
|
67911
|
+
|
|
67912
|
+
// ../protocol/src/frames/computer.ts
|
|
67913
|
+
var COMPUTER_CP_SUBPROTOCOL = "agentconnect.computer.v1";
|
|
67914
|
+
var COMPUTER_WS_PUBLIC_PATH = "/v1/computers/ws";
|
|
67915
|
+
var COMPUTER_REGISTER_PUBLIC_PATH = "/v1/computers/register";
|
|
67916
|
+
var COMPUTER_SESSIONS = ["aqua", "console", "rdp", "x11", "xvfb", "wayland-gnome"];
|
|
67917
|
+
var COMPUTER_LIVE_STATUSES = ["online", "locked", "paused", "human_in_control", "busy"];
|
|
67918
|
+
var HHMM = "(?:[01]\\d|2[0-3]):[0-5]\\d";
|
|
67919
|
+
var QUIET_RANGE_RE = new RegExp(`^${HHMM}-${HHMM}$`);
|
|
67920
|
+
function isTimeZone(tz) {
|
|
67921
|
+
try {
|
|
67922
|
+
new Intl.DateTimeFormat("en-US", { timeZone: tz });
|
|
67923
|
+
return true;
|
|
67924
|
+
} catch {
|
|
67925
|
+
return false;
|
|
67926
|
+
}
|
|
67927
|
+
}
|
|
67928
|
+
var AppId = external_exports.string().trim().min(1).max(256);
|
|
67929
|
+
var COMPUTER_ACCESS_AGENTS_MAX = 200;
|
|
67930
|
+
var COMPUTER_AGENT_ACCESS_MODES = ["none", "selected", "all"];
|
|
67931
|
+
var ComputerAgentAccess = external_exports.object({
|
|
67932
|
+
mode: external_exports.enum(COMPUTER_AGENT_ACCESS_MODES),
|
|
67933
|
+
agents: external_exports.array(external_exports.uuid()).max(COMPUTER_ACCESS_AGENTS_MAX).default([])
|
|
67934
|
+
});
|
|
67935
|
+
var ComputerPolicySchema = external_exports.object({
|
|
67936
|
+
allowedMembers: external_exports.array(external_exports.string().min(1).max(128)).max(500).default([]),
|
|
67937
|
+
agentMode: external_exports.enum(["view", "control"]).default("control"),
|
|
67938
|
+
approvals: ComputerApprovalsSchema.default({ firstInputPerSession: true }),
|
|
67939
|
+
appAllowlist: external_exports.array(AppId).max(200).optional(),
|
|
67940
|
+
redactApps: external_exports.array(AppId).max(200).default([]),
|
|
67941
|
+
exposeDriverTools: external_exports.boolean().default(false),
|
|
67942
|
+
quietHours: external_exports.object({
|
|
67943
|
+
tz: external_exports.string().min(1).max(64).refine(isTimeZone, "unknown IANA time zone"),
|
|
67944
|
+
ranges: external_exports.array(external_exports.string().regex(QUIET_RANGE_RE, "expected HH:MM-HH:MM")).min(1).max(24)
|
|
67945
|
+
}).optional(),
|
|
67946
|
+
leaseIdleSeconds: external_exports.number().int().min(10).max(3600).default(120),
|
|
67947
|
+
leaseMaxSeconds: external_exports.number().int().min(60).max(86400).default(1800),
|
|
67948
|
+
// Seconds an acquire waits in the FIFO lease queue before `computer_busy` (§4.4); 0 never waits.
|
|
67949
|
+
leaseWaitSeconds: external_exports.number().int().min(0).max(COMPUTER_LEASE_WAIT_MAX_SECONDS).default(45),
|
|
67950
|
+
// Days stored screenshots are kept (§9); 0 means never written, absent means the deployment's default.
|
|
67951
|
+
screenshotRetentionDays: external_exports.number().int().min(0).max(COMPUTER_SCREENSHOT_RETENTION_MAX_DAYS).optional(),
|
|
67952
|
+
// Whether viewers may hole-punch peer to peer, which shows them the desktop's public IP (§7.2); absent means on only for owner-only viewing.
|
|
67953
|
+
viewerPeerToPeer: external_exports.boolean().optional(),
|
|
67954
|
+
// The command-line tier (§5.7); absent means the Computer's default, on for a managed one and off otherwise.
|
|
67955
|
+
shell: external_exports.enum(COMPUTER_SHELL_MODES).optional(),
|
|
67956
|
+
files: external_exports.enum(COMPUTER_FILES_MODES).optional(),
|
|
67957
|
+
// Prefixes the file tools may touch; absent means the user's home directory.
|
|
67958
|
+
fileRoots: external_exports.array(ComputerFileRoot).max(COMPUTER_FILE_ROOTS_MAX).optional(),
|
|
67959
|
+
// Per-agent desktops fork and merge the registrant's browser logins (§3.9); absent means on.
|
|
67960
|
+
shareBrowserLogins: external_exports.boolean().optional()
|
|
67961
|
+
}).refine((p) => p.leaseIdleSeconds <= p.leaseMaxSeconds, {
|
|
67962
|
+
message: "leaseIdleSeconds must not exceed leaseMaxSeconds",
|
|
67963
|
+
path: ["leaseIdleSeconds"]
|
|
67964
|
+
}).refine((p) => p.agentMode === "control" || p.shell === void 0 || p.shell === "off", {
|
|
67965
|
+
message: "a shell needs agentMode control",
|
|
67966
|
+
path: ["shell"]
|
|
67967
|
+
});
|
|
67968
|
+
var ComputerCapabilitiesSchema = external_exports.object({
|
|
67969
|
+
screenshot: external_exports.boolean().default(false),
|
|
67970
|
+
input: external_exports.boolean().default(false),
|
|
67971
|
+
textInput: external_exports.enum(["full", "keymap-only"]).default("full"),
|
|
67972
|
+
// Which human input pauses agents (§6); absent reads as pointer only, what older desktops detect.
|
|
67973
|
+
humanActivity: external_exports.enum(["pointer", "pointer+keyboard"]).optional(),
|
|
67974
|
+
backgroundInput: external_exports.boolean().default(false),
|
|
67975
|
+
accessibilityTree: external_exports.boolean().default(false),
|
|
67976
|
+
viewer: external_exports.boolean().default(false),
|
|
67977
|
+
// The viewer accepts a view token's `stun` claim; desktops before relay STUN refuse such a token.
|
|
67978
|
+
viewerStun: external_exports.boolean().optional(),
|
|
67979
|
+
// The browser's traffic leaves through the desktop's egress forwarder, which applies `computer/egress` (§15.4).
|
|
67980
|
+
egress: external_exports.boolean().optional(),
|
|
67981
|
+
// The command-line tier can run here (§5.7): computer_exec, and the file tools.
|
|
67982
|
+
exec: external_exports.boolean().optional(),
|
|
67983
|
+
files: external_exports.boolean().optional(),
|
|
67984
|
+
displays: external_exports.array(
|
|
67985
|
+
external_exports.object({
|
|
67986
|
+
id: external_exports.string().min(1).max(128),
|
|
67987
|
+
width: external_exports.number().int().positive().max(1e5),
|
|
67988
|
+
height: external_exports.number().int().positive().max(1e5),
|
|
67989
|
+
scale: external_exports.number().positive().max(16)
|
|
67990
|
+
})
|
|
67991
|
+
).max(16).default([]),
|
|
67992
|
+
permissions: external_exports.object({
|
|
67993
|
+
accessibility: external_exports.boolean().optional(),
|
|
67994
|
+
screenRecording: external_exports.boolean().optional(),
|
|
67995
|
+
portal: external_exports.boolean().optional(),
|
|
67996
|
+
firewall: external_exports.boolean().optional()
|
|
67997
|
+
}).default({})
|
|
67998
|
+
});
|
|
67999
|
+
var ComputerDoctorCheck = external_exports.object({
|
|
68000
|
+
name: external_exports.string().min(1).max(64),
|
|
68001
|
+
status: external_exports.enum(["ok", "info", "warn", "fail"]),
|
|
68002
|
+
detail: external_exports.string().max(1e3),
|
|
68003
|
+
fix: external_exports.string().max(1e3).optional()
|
|
68004
|
+
});
|
|
68005
|
+
var ComputerDoctorReport = external_exports.object({
|
|
68006
|
+
checkedAt: external_exports.string().datetime(),
|
|
68007
|
+
checks: external_exports.array(ComputerDoctorCheck).max(64)
|
|
68008
|
+
});
|
|
68009
|
+
var ComputerChannelCredential = external_exports.object({
|
|
68010
|
+
keyId: external_exports.string().min(1).max(64),
|
|
68011
|
+
// 32 random-looking bytes, base64url without padding; secret material, never logged.
|
|
68012
|
+
key: external_exports.string().regex(/^[A-Za-z0-9_-]{43}$/),
|
|
68013
|
+
issuedAt: external_exports.string().datetime(),
|
|
68014
|
+
expiresAt: external_exports.string().datetime()
|
|
68015
|
+
});
|
|
68016
|
+
var ComputerEgressProxyUrl = external_exports.string().max(512).refine((raw) => {
|
|
68017
|
+
try {
|
|
68018
|
+
const u = new URL(raw);
|
|
68019
|
+
return (u.protocol === "http:" || u.protocol === "https:") && u.hostname !== "" && u.username === "" && u.password === "" && (u.pathname === "" || u.pathname === "/") && u.search === "" && u.hash === "";
|
|
68020
|
+
} catch {
|
|
68021
|
+
return false;
|
|
68022
|
+
}
|
|
68023
|
+
}, "expected http://host:port or https://host:port without credentials or a path");
|
|
68024
|
+
var ComputerEgress = external_exports.discriminatedUnion("mode", [
|
|
68025
|
+
external_exports.object({ mode: external_exports.literal("direct") }),
|
|
68026
|
+
external_exports.object({
|
|
68027
|
+
mode: external_exports.literal("proxy"),
|
|
68028
|
+
url: ComputerEgressProxyUrl,
|
|
68029
|
+
username: external_exports.string().min(1).max(256).optional(),
|
|
68030
|
+
password: external_exports.string().min(1).max(512).optional()
|
|
68031
|
+
})
|
|
68032
|
+
]);
|
|
68033
|
+
var COMPUTER_EGRESS_FEATURE = "computer-egress-v1";
|
|
68034
|
+
var ComputerAuth = external_exports.object({
|
|
68035
|
+
apiKey: external_exports.string().min(1).max(256),
|
|
68036
|
+
desktopDaemonVersion: external_exports.string().trim().min(1).max(64)
|
|
68037
|
+
}).strict();
|
|
68038
|
+
var ComputerAuthOk = external_exports.object({
|
|
68039
|
+
computerId: external_exports.string().uuid(),
|
|
68040
|
+
orgId: external_exports.string().min(1).max(64),
|
|
68041
|
+
name: external_exports.string().min(1).max(200),
|
|
68042
|
+
heartbeatSec: external_exports.number().int().positive(),
|
|
68043
|
+
serverTime: external_exports.string().datetime(),
|
|
68044
|
+
credential: ComputerChannelCredential,
|
|
68045
|
+
policy: ComputerPolicySchema,
|
|
68046
|
+
// What this CP accepts on the channel beyond the base frames, such as `computer-audit-v1`.
|
|
68047
|
+
features: external_exports.array(external_exports.string().min(1).max(64)).max(32).optional(),
|
|
68048
|
+
// The retention in effect for this Computer's screenshots (§9); 0 or absent means none are stored.
|
|
68049
|
+
screenshotRetentionDays: external_exports.number().int().min(0).max(COMPUTER_SCREENSHOT_RETENTION_MAX_DAYS).optional(),
|
|
68050
|
+
// A managed desktop's egress (§15.4); absent means direct unless `computer-egress-v1` is advertised. Secret, never logged.
|
|
68051
|
+
egress: ComputerEgress.optional()
|
|
68052
|
+
});
|
|
68053
|
+
var COMPUTER_DESKTOPS_FEATURE = "computer-desktops-v1";
|
|
68054
|
+
var COMPUTER_DESKTOPS_MAX = 64;
|
|
68055
|
+
var ComputerDesktopReport = external_exports.object({
|
|
68056
|
+
id: ComputerDesktopId,
|
|
68057
|
+
agentId: external_exports.string().uuid(),
|
|
68058
|
+
status: external_exports.enum(COMPUTER_LIVE_STATUSES),
|
|
68059
|
+
lease: external_exports.object({
|
|
68060
|
+
holder: external_exports.string().min(1).max(512),
|
|
68061
|
+
idleMs: external_exports.number().int().min(0),
|
|
68062
|
+
heldMs: external_exports.number().int().min(0).optional()
|
|
68063
|
+
}).strict().optional()
|
|
68064
|
+
}).strict();
|
|
68065
|
+
var ComputerHeartbeat = external_exports.object({
|
|
68066
|
+
status: external_exports.enum(COMPUTER_LIVE_STATUSES),
|
|
68067
|
+
osVersion: external_exports.string().trim().min(1).max(120).optional(),
|
|
68068
|
+
session: external_exports.enum(COMPUTER_SESSIONS).optional(),
|
|
68069
|
+
desktopDaemonVersion: external_exports.string().trim().min(1).max(64).optional(),
|
|
68070
|
+
driverVersion: external_exports.string().trim().min(1).max(64).optional(),
|
|
68071
|
+
capabilities: ComputerCapabilitiesSchema.optional(),
|
|
68072
|
+
doctor: ComputerDoctorReport.optional(),
|
|
68073
|
+
// The local lease, how long since its last input, and how long it has been held without idling out.
|
|
68074
|
+
lease: external_exports.object({
|
|
68075
|
+
holder: external_exports.string().min(1).max(512),
|
|
68076
|
+
idleMs: external_exports.number().int().min(0),
|
|
68077
|
+
heldMs: external_exports.number().int().min(0).optional()
|
|
68078
|
+
}).strict().optional(),
|
|
68079
|
+
// Behind `computer-desktops-v1`: present (even empty) while each agent gets a desktop of its own; `status` is the main one's.
|
|
68080
|
+
desktops: external_exports.array(ComputerDesktopReport).max(COMPUTER_DESKTOPS_MAX).optional()
|
|
68081
|
+
}).strict();
|
|
68082
|
+
var ComputerCredentialRenewal = external_exports.object({ credential: ComputerChannelCredential });
|
|
68083
|
+
var ComputerPolicyPush = external_exports.object({
|
|
68084
|
+
policy: ComputerPolicySchema,
|
|
68085
|
+
screenshotRetentionDays: external_exports.number().int().min(0).max(COMPUTER_SCREENSHOT_RETENTION_MAX_DAYS).optional()
|
|
68086
|
+
});
|
|
68087
|
+
var ComputerRevoke = external_exports.object({
|
|
68088
|
+
reason: external_exports.enum(["revoked", "deleted", "owner_removed"]),
|
|
68089
|
+
message: external_exports.string().max(500).optional()
|
|
68090
|
+
});
|
|
68091
|
+
var ComputerLeasePush = external_exports.object({
|
|
68092
|
+
lease: ComputerControlLease.nullable(),
|
|
68093
|
+
desktops: external_exports.array(ComputerControlLease).max(COMPUTER_DESKTOPS_MAX).optional()
|
|
68094
|
+
});
|
|
68095
|
+
var ComputerRelaysPush = external_exports.object({ relays: external_exports.array(ComputerRelayEntry).max(COMPUTER_RELAYS_MAX) });
|
|
68096
|
+
var ComputerStopPush = external_exports.object({ stop: external_exports.object({ at: external_exports.string().datetime() }).nullable() });
|
|
68097
|
+
var ComputerEgressPush = external_exports.object({ egress: ComputerEgress });
|
|
68098
|
+
var COMPUTER_ADMIN_PROMPTS_FEATURE = "computer-admin-prompts-v1";
|
|
68099
|
+
var ComputerAdminPromptsSet = external_exports.object({ mode: external_exports.enum(COMPUTER_ADMIN_PROMPT_MODES) }).strict();
|
|
68100
|
+
var ComputerAdminPromptsSetOk = external_exports.object({ mode: external_exports.enum(COMPUTER_ADMIN_PROMPT_MODES) });
|
|
68101
|
+
var COMPUTER_CP_SCHEMAS = {
|
|
68102
|
+
"computer/auth": ComputerAuth,
|
|
68103
|
+
"computer/auth/ok": ComputerAuthOk,
|
|
68104
|
+
"computer/heartbeat": ComputerHeartbeat,
|
|
68105
|
+
"computer/credential": ComputerCredentialRenewal,
|
|
68106
|
+
"computer/policy": ComputerPolicyPush,
|
|
68107
|
+
"computer/revoke": ComputerRevoke,
|
|
68108
|
+
"computer/lease": ComputerLeasePush,
|
|
68109
|
+
"computer/relays": ComputerRelaysPush,
|
|
68110
|
+
"computer/stop": ComputerStopPush,
|
|
68111
|
+
"computer/egress": ComputerEgressPush,
|
|
68112
|
+
"computer/admin-prompts": ComputerAdminPromptsSet,
|
|
68113
|
+
"computer/admin-prompts/ok": ComputerAdminPromptsSetOk,
|
|
68114
|
+
"computer/audit": ComputerAuditReport,
|
|
68115
|
+
"computer/audit/ok": ComputerAuditAck,
|
|
68116
|
+
"computer/screenshot/put": ComputerScreenshotPut,
|
|
68117
|
+
"computer/screenshot/put/ok": ComputerScreenshotPutOk,
|
|
68118
|
+
"computer/screenshot/commit": ComputerScreenshotCommit,
|
|
68119
|
+
"computer/screenshot/commit/ok": ComputerScreenshotCommitOk,
|
|
68120
|
+
error: ErrorFrame
|
|
68121
|
+
};
|
|
68122
|
+
var COMPUTER_CP_FRAME_TYPES = Object.keys(COMPUTER_CP_SCHEMAS);
|
|
68123
|
+
var ComputerCpFrame = external_exports.discriminatedUnion("type", [
|
|
68124
|
+
frameSchema("computer/auth", COMPUTER_CP_SCHEMAS["computer/auth"]),
|
|
68125
|
+
frameSchema("computer/auth/ok", COMPUTER_CP_SCHEMAS["computer/auth/ok"]),
|
|
68126
|
+
frameSchema("computer/heartbeat", COMPUTER_CP_SCHEMAS["computer/heartbeat"]),
|
|
68127
|
+
frameSchema("computer/credential", COMPUTER_CP_SCHEMAS["computer/credential"]),
|
|
68128
|
+
frameSchema("computer/policy", COMPUTER_CP_SCHEMAS["computer/policy"]),
|
|
68129
|
+
frameSchema("computer/revoke", COMPUTER_CP_SCHEMAS["computer/revoke"]),
|
|
68130
|
+
frameSchema("computer/lease", COMPUTER_CP_SCHEMAS["computer/lease"]),
|
|
68131
|
+
frameSchema("computer/relays", COMPUTER_CP_SCHEMAS["computer/relays"]),
|
|
68132
|
+
frameSchema("computer/stop", COMPUTER_CP_SCHEMAS["computer/stop"]),
|
|
68133
|
+
frameSchema("computer/egress", COMPUTER_CP_SCHEMAS["computer/egress"]),
|
|
68134
|
+
frameSchema("computer/admin-prompts", COMPUTER_CP_SCHEMAS["computer/admin-prompts"]),
|
|
68135
|
+
frameSchema("computer/admin-prompts/ok", COMPUTER_CP_SCHEMAS["computer/admin-prompts/ok"]),
|
|
68136
|
+
frameSchema("computer/audit", COMPUTER_CP_SCHEMAS["computer/audit"]),
|
|
68137
|
+
frameSchema("computer/audit/ok", COMPUTER_CP_SCHEMAS["computer/audit/ok"]),
|
|
68138
|
+
frameSchema("computer/screenshot/put", COMPUTER_CP_SCHEMAS["computer/screenshot/put"]),
|
|
68139
|
+
frameSchema("computer/screenshot/put/ok", COMPUTER_CP_SCHEMAS["computer/screenshot/put/ok"]),
|
|
68140
|
+
frameSchema("computer/screenshot/commit", COMPUTER_CP_SCHEMAS["computer/screenshot/commit"]),
|
|
68141
|
+
frameSchema("computer/screenshot/commit/ok", COMPUTER_CP_SCHEMAS["computer/screenshot/commit/ok"]),
|
|
68142
|
+
frameSchema("error", COMPUTER_CP_SCHEMAS["error"])
|
|
68143
|
+
]);
|
|
68144
|
+
var TOLERANT_COMPUTER_CP_SCHEMAS = tolerantSchemas(COMPUTER_CP_SCHEMAS);
|
|
68145
|
+
function decodeComputerCpFrameTolerant(text) {
|
|
68146
|
+
return decodeEnvelopeWith(TOLERANT_COMPUTER_CP_SCHEMAS, text);
|
|
68147
|
+
}
|
|
68148
|
+
function buildComputerCpFrame(type, payload, opts = {}) {
|
|
68149
|
+
return buildEnvelopeRaw(type, payload, opts);
|
|
68150
|
+
}
|
|
68151
|
+
|
|
67283
68152
|
// src/admin-prompts.ts
|
|
67284
68153
|
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
67285
68154
|
import { spawn } from "node:child_process";
|
|
@@ -68203,1208 +69072,365 @@ function mergeCookies(snapshot, target, previous, next, counts, now) {
|
|
|
68203
69072
|
const expires = row.expires_utc;
|
|
68204
69073
|
if (Number(row.is_persistent) === 1 && expires > 0n && expires < nowUs) {
|
|
68205
69074
|
counts.expired++;
|
|
68206
|
-
continue;
|
|
68207
|
-
}
|
|
68208
|
-
const current = mine.get(id);
|
|
68209
|
-
const changed = previous === void 0 || previous[id] !== updated.toString();
|
|
68210
|
-
if (!changed || current?.stamp === updated) {
|
|
68211
|
-
counts.kept++;
|
|
68212
|
-
continue;
|
|
68213
|
-
}
|
|
68214
|
-
insert.run(...columns.map((column) => bindable(row[column])));
|
|
68215
|
-
counts[current ? "updated" : "inserted"]++;
|
|
68216
|
-
}
|
|
68217
|
-
if (previous) {
|
|
68218
|
-
for (const id of Object.keys(previous)) {
|
|
68219
|
-
if (id in next) continue;
|
|
68220
|
-
const current = mine.get(id);
|
|
68221
|
-
if (current) {
|
|
68222
|
-
remove.run(current.rowid);
|
|
68223
|
-
counts.deleted++;
|
|
68224
|
-
}
|
|
68225
|
-
}
|
|
68226
|
-
}
|
|
68227
|
-
db.exec("COMMIT");
|
|
68228
|
-
} catch (error63) {
|
|
68229
|
-
db.exec("ROLLBACK");
|
|
68230
|
-
throw error63;
|
|
68231
|
-
}
|
|
68232
|
-
} finally {
|
|
68233
|
-
source.close();
|
|
68234
|
-
db.close();
|
|
68235
|
-
}
|
|
68236
|
-
}
|
|
68237
|
-
function lastModified(meta3) {
|
|
68238
|
-
let pos = 0;
|
|
68239
|
-
while (pos < meta3.length) {
|
|
68240
|
-
const tag = meta3[pos++];
|
|
68241
|
-
let value = 0n;
|
|
68242
|
-
let shift = 0n;
|
|
68243
|
-
for (; ; ) {
|
|
68244
|
-
const byte = meta3[pos++];
|
|
68245
|
-
if (byte === void 0) return value.toString();
|
|
68246
|
-
value |= BigInt(byte & 127) << shift;
|
|
68247
|
-
shift += 7n;
|
|
68248
|
-
if (!(byte & 128)) break;
|
|
68249
|
-
}
|
|
68250
|
-
if (tag === 8) return value.toString();
|
|
68251
|
-
}
|
|
68252
|
-
return "0";
|
|
68253
|
-
}
|
|
68254
|
-
function mergeLocalStorage(source, target, previous, next, report) {
|
|
68255
|
-
const merged = readLevelDb(target);
|
|
68256
|
-
let changed = false;
|
|
68257
|
-
if (!merged.has("VERSION") && source.has("VERSION")) {
|
|
68258
|
-
merged.set("VERSION", source.get("VERSION"));
|
|
68259
|
-
changed = true;
|
|
68260
|
-
}
|
|
68261
|
-
for (const [key, meta3] of source) {
|
|
68262
|
-
if (!key.startsWith("META:")) continue;
|
|
68263
|
-
const origin = key.slice("META:".length);
|
|
68264
|
-
const modified = lastModified(meta3);
|
|
68265
|
-
next[origin] = modified;
|
|
68266
|
-
const mine = merged.get(key);
|
|
68267
|
-
if (previous !== void 0 && previous[origin] === modified || mine && mine.equals(meta3)) {
|
|
68268
|
-
report.kept++;
|
|
68269
|
-
continue;
|
|
68270
|
-
}
|
|
68271
|
-
const prefix = `_${origin}\0`;
|
|
68272
|
-
for (const existing of [...merged.keys()]) if (existing.startsWith(prefix)) merged.delete(existing);
|
|
68273
|
-
for (const [entry, value] of source) if (entry.startsWith(prefix)) merged.set(entry, value);
|
|
68274
|
-
merged.set(key, meta3);
|
|
68275
|
-
const access = source.get(`METAACCESS:${origin}`);
|
|
68276
|
-
if (access) merged.set(`METAACCESS:${origin}`, access);
|
|
68277
|
-
report.taken.push(origin);
|
|
68278
|
-
changed = true;
|
|
68279
|
-
}
|
|
68280
|
-
if (changed) writeLevelDb(target, merged);
|
|
68281
|
-
}
|
|
68282
|
-
function newestMtime(dir) {
|
|
68283
|
-
let newest = 0;
|
|
68284
|
-
for (const entry of readdirSync2(dir, { withFileTypes: true, recursive: true })) {
|
|
68285
|
-
if (entry.isFile()) newest = Math.max(newest, statSync(join3(entry.parentPath, entry.name)).mtimeMs);
|
|
68286
|
-
}
|
|
68287
|
-
return newest;
|
|
68288
|
-
}
|
|
68289
|
-
function mergeIndexedDb(snapshot, target, previous, next, report) {
|
|
68290
|
-
for (const name of readdirSync2(snapshot)) {
|
|
68291
|
-
if (!name.endsWith(".indexeddb.leveldb")) continue;
|
|
68292
|
-
const origin = name.slice(0, -".indexeddb.leveldb".length);
|
|
68293
|
-
const modified = newestMtime(join3(snapshot, name));
|
|
68294
|
-
next[origin] = modified;
|
|
68295
|
-
const mine = join3(target, name);
|
|
68296
|
-
if (previous !== void 0 && previous[origin] === modified || existsSync2(mine) && newestMtime(mine) === modified) {
|
|
68297
|
-
report.kept++;
|
|
68298
|
-
continue;
|
|
68299
|
-
}
|
|
68300
|
-
for (const suffix of [".indexeddb.leveldb", ".indexeddb.blob"]) {
|
|
68301
|
-
const to = join3(target, origin + suffix);
|
|
68302
|
-
rmSync2(to, { recursive: true, force: true });
|
|
68303
|
-
const from = join3(snapshot, origin + suffix);
|
|
68304
|
-
if (existsSync2(from)) cpSync(from, to, { recursive: true, preserveTimestamps: true });
|
|
68305
|
-
}
|
|
68306
|
-
report.taken.push(origin);
|
|
68307
|
-
}
|
|
68308
|
-
}
|
|
68309
|
-
|
|
68310
|
-
// src/browser/launcher.ts
|
|
68311
|
-
var BROWSER_NAMES = ["chromium", "chromium-browser", "google-chrome-stable", "google-chrome"];
|
|
68312
|
-
var BASE_FLAGS = ["--no-first-run", "--no-default-browser-check", "--hide-crash-restore-bubble"];
|
|
68313
|
-
var LOCK_STALE_MS = 6e4;
|
|
68314
|
-
var LOCK_WAIT_MS = 3e4;
|
|
68315
|
-
var OWN_WAIT_MS = 2e4;
|
|
68316
|
-
function profileOwner(profile, host = hostname4()) {
|
|
68317
|
-
let target;
|
|
68318
|
-
try {
|
|
68319
|
-
target = readlinkSync(join4(profile, "SingletonLock"));
|
|
68320
|
-
} catch {
|
|
68321
|
-
return void 0;
|
|
68322
|
-
}
|
|
68323
|
-
const match = /^(.*)-(\d+)$/.exec(target);
|
|
68324
|
-
if (!match || match[1] !== host) return void 0;
|
|
68325
|
-
const pid = Number(match[2]);
|
|
68326
|
-
try {
|
|
68327
|
-
process.kill(pid, 0);
|
|
68328
|
-
return pid;
|
|
68329
|
-
} catch (error63) {
|
|
68330
|
-
return error63.code === "EPERM" ? pid : void 0;
|
|
68331
|
-
}
|
|
68332
|
-
}
|
|
68333
|
-
function seedable(path) {
|
|
68334
|
-
const name = basename2(path);
|
|
68335
|
-
return !(name.startsWith("Singleton") || /cache$/i.test(name) || name === "Crash Reports" || name === "Sessions" || name === "Session Storage" || name === BASELINE_FILE);
|
|
68336
|
-
}
|
|
68337
|
-
function seedProfile(master, profile) {
|
|
68338
|
-
mkdirSync3(dirname2(profile), { recursive: true });
|
|
68339
|
-
cpSync2(master, profile, { recursive: true, preserveTimestamps: true, filter: seedable });
|
|
68340
|
-
}
|
|
68341
|
-
function findBrowser(path = process.env.PATH ?? "", skip = []) {
|
|
68342
|
-
const skipped = new Set(skip.map((dir) => resolve(dir)));
|
|
68343
|
-
for (const name of BROWSER_NAMES) {
|
|
68344
|
-
for (const dir of path.split(delimiter)) {
|
|
68345
|
-
if (!dir || skipped.has(resolve(dir))) continue;
|
|
68346
|
-
const candidate = join4(dir, name);
|
|
68347
|
-
try {
|
|
68348
|
-
accessSync(candidate, constants.X_OK);
|
|
68349
|
-
if (statSync2(candidate).isFile()) return candidate;
|
|
68350
|
-
} catch {
|
|
68351
|
-
}
|
|
68352
|
-
}
|
|
68353
|
-
}
|
|
68354
|
-
return void 0;
|
|
68355
|
-
}
|
|
68356
|
-
async function launchBrowser(options) {
|
|
68357
|
-
const log40 = options.log ?? (() => void 0);
|
|
68358
|
-
const release3 = await lockProfile(options.profile);
|
|
68359
|
-
try {
|
|
68360
|
-
if (profileOwner(options.profile) !== void 0) {
|
|
68361
|
-
start(options).unref();
|
|
68362
|
-
return { handedOff: true, reports: [] };
|
|
68363
|
-
}
|
|
68364
|
-
if (!existsSync3(options.profile)) {
|
|
68365
|
-
if (options.master && existsSync3(options.master)) {
|
|
68366
|
-
seedProfile(options.master, options.profile);
|
|
68367
|
-
log40(`browser profile ${options.profile} created from ${options.master}`);
|
|
68368
|
-
} else mkdirSync3(options.profile, { recursive: true });
|
|
68369
|
-
}
|
|
68370
|
-
for (const name of ["SingletonLock", "SingletonCookie", "SingletonSocket"]) {
|
|
68371
|
-
rmSync3(join4(options.profile, name), { force: true });
|
|
68372
|
-
}
|
|
68373
|
-
const self2 = realpathSync2(options.profile);
|
|
68374
|
-
const sources = options.sources.filter(
|
|
68375
|
-
(source) => existsSync3(join4(source, "Default")) && realpathSync2(source) !== self2
|
|
68376
|
-
);
|
|
68377
|
-
const reports = await forkMerge(options.profile, sources);
|
|
68378
|
-
for (const report of reports) log40(`browser fork-merge from ${report.source}: ${summarize(report)}`);
|
|
68379
|
-
const child2 = start(options);
|
|
68380
|
-
if (!await owned(options.profile, child2)) log40(`browser for ${options.profile} did not take its profile`);
|
|
68381
|
-
return { handedOff: false, reports, ...child2.pid !== void 0 ? { pid: child2.pid } : {} };
|
|
68382
|
-
} finally {
|
|
68383
|
-
release3();
|
|
68384
|
-
}
|
|
68385
|
-
}
|
|
68386
|
-
function start(options) {
|
|
68387
|
-
const child2 = spawn2(options.browser, [`--user-data-dir=${options.profile}`, ...BASE_FLAGS, ...options.args ?? []], {
|
|
68388
|
-
detached: true,
|
|
68389
|
-
stdio: "ignore",
|
|
68390
|
-
env: options.env ?? process.env
|
|
68391
|
-
});
|
|
68392
|
-
child2.on("error", () => void 0);
|
|
68393
|
-
return child2;
|
|
68394
|
-
}
|
|
68395
|
-
async function owned(profile, child2) {
|
|
68396
|
-
let ended = false;
|
|
68397
|
-
const end = () => void (ended = true);
|
|
68398
|
-
child2.once("error", end).once("exit", end);
|
|
68399
|
-
try {
|
|
68400
|
-
const deadline = Date.now() + OWN_WAIT_MS;
|
|
68401
|
-
for (; ; ) {
|
|
68402
|
-
if (profileOwner(profile) !== void 0) return true;
|
|
68403
|
-
if (ended || Date.now() > deadline) return false;
|
|
68404
|
-
await new Promise((resolveWait) => setTimeout(resolveWait, 100));
|
|
68405
|
-
}
|
|
68406
|
-
} finally {
|
|
68407
|
-
child2.off("error", end).off("exit", end);
|
|
68408
|
-
child2.unref();
|
|
68409
|
-
}
|
|
68410
|
-
}
|
|
68411
|
-
function summarize(report) {
|
|
68412
|
-
const c = report.cookies;
|
|
68413
|
-
return [
|
|
68414
|
-
report.firstFork ? "first fork" : "since last fork",
|
|
68415
|
-
`cookies +${c.inserted} ~${c.updated} -${c.deleted} (kept ${c.kept}, expired ${c.expired})`,
|
|
68416
|
-
`localStorage ${report.localStorage.taken.length} origin(s)`,
|
|
68417
|
-
`IndexedDB ${report.indexedDb.taken.length} origin(s)`
|
|
68418
|
-
].join(", ");
|
|
68419
|
-
}
|
|
68420
|
-
async function lockProfile(profile) {
|
|
68421
|
-
const path = `${profile}.launch-lock`;
|
|
68422
|
-
mkdirSync3(dirname2(path), { recursive: true });
|
|
68423
|
-
const deadline = Date.now() + LOCK_WAIT_MS;
|
|
68424
|
-
for (; ; ) {
|
|
68425
|
-
try {
|
|
68426
|
-
closeSync(openSync(path, "wx"));
|
|
68427
|
-
return () => rmSync3(path, { force: true });
|
|
68428
|
-
} catch (error63) {
|
|
68429
|
-
if (error63.code !== "EEXIST") throw error63;
|
|
68430
|
-
try {
|
|
68431
|
-
if (Date.now() - statSync2(path).mtimeMs > LOCK_STALE_MS) rmSync3(path, { force: true });
|
|
68432
|
-
} catch {
|
|
68433
|
-
}
|
|
68434
|
-
if (Date.now() > deadline) throw new Error(`another browser launch for ${profile} is still running`);
|
|
68435
|
-
await new Promise((resolveWait) => setTimeout(resolveWait, 200));
|
|
68436
|
-
}
|
|
68437
|
-
}
|
|
68438
|
-
}
|
|
68439
|
-
|
|
68440
|
-
// src/browser/close.ts
|
|
68441
|
-
var OP_QUERY_TREE = 15;
|
|
68442
|
-
var OP_INTERN_ATOM = 16;
|
|
68443
|
-
var OP_GET_PROPERTY = 20;
|
|
68444
|
-
var OP_SEND_EVENT = 25;
|
|
68445
|
-
var CLIENT_MESSAGE = 33;
|
|
68446
|
-
async function closeBrowser(options) {
|
|
68447
|
-
const log40 = options.log ?? (() => void 0);
|
|
68448
|
-
const pid = profileOwner(options.profile);
|
|
68449
|
-
if (pid === void 0) return "not-running";
|
|
68450
|
-
try {
|
|
68451
|
-
const x = await X11Connection.connect({
|
|
68452
|
-
display: options.display,
|
|
68453
|
-
...options.xauthority ? { xauthority: options.xauthority } : {}
|
|
68454
|
-
});
|
|
68455
|
-
try {
|
|
68456
|
-
const windows = await windowsOf(x, pid);
|
|
68457
|
-
const protocols = await internAtom(x, "WM_PROTOCOLS");
|
|
68458
|
-
const remove = await internAtom(x, "WM_DELETE_WINDOW");
|
|
68459
|
-
for (const window2 of windows) await sendClientMessage(x, window2, protocols, [remove, 0, 0, 0, 0]);
|
|
68460
|
-
log40(`asked ${windows.length} browser window(s) of ${options.profile} to close`);
|
|
68461
|
-
} finally {
|
|
68462
|
-
x.close();
|
|
68463
|
-
}
|
|
68464
|
-
} catch (error63) {
|
|
68465
|
-
log40(`could not ask the browser of ${options.profile} to close: ${error63.message}`);
|
|
68466
|
-
}
|
|
68467
|
-
if (await exited(pid, options.timeoutMs ?? 15e3)) return "closed";
|
|
68468
|
-
log40(`browser ${pid} did not exit after its windows closed; sending SIGTERM (unflushed cookies may be lost)`);
|
|
68469
|
-
process.kill(pid, "SIGTERM");
|
|
68470
|
-
if (await exited(pid, 5e3)) return "terminated";
|
|
68471
|
-
process.kill(pid, "SIGKILL");
|
|
68472
|
-
return "killed";
|
|
68473
|
-
}
|
|
68474
|
-
async function waitForWindowManager(display, timeoutMs) {
|
|
68475
|
-
const deadline = Date.now() + timeoutMs;
|
|
68476
|
-
while (Date.now() < deadline) {
|
|
68477
|
-
try {
|
|
68478
|
-
const x = await X11Connection.connect({ display });
|
|
68479
|
-
try {
|
|
68480
|
-
const check2 = await internAtom(x, "_NET_SUPPORTING_WM_CHECK");
|
|
68481
|
-
if (await cardinal(x, x.setup.root, check2, 33) !== void 0) return true;
|
|
68482
|
-
} finally {
|
|
68483
|
-
x.close();
|
|
68484
|
-
}
|
|
68485
|
-
} catch {
|
|
68486
|
-
}
|
|
68487
|
-
await new Promise((resolve5) => setTimeout(resolve5, 200));
|
|
68488
|
-
}
|
|
68489
|
-
return false;
|
|
68490
|
-
}
|
|
68491
|
-
async function exited(pid, timeoutMs) {
|
|
68492
|
-
const deadline = Date.now() + timeoutMs;
|
|
68493
|
-
for (; ; ) {
|
|
68494
|
-
try {
|
|
68495
|
-
process.kill(pid, 0);
|
|
68496
|
-
} catch {
|
|
68497
|
-
return true;
|
|
68498
|
-
}
|
|
68499
|
-
if (Date.now() > deadline) return false;
|
|
68500
|
-
await new Promise((resolve5) => setTimeout(resolve5, 200));
|
|
68501
|
-
}
|
|
68502
|
-
}
|
|
68503
|
-
async function windowsOf(x, pid) {
|
|
68504
|
-
const pidAtom = await internAtom(x, "_NET_WM_PID");
|
|
68505
|
-
const found = [];
|
|
68506
|
-
for (const frame of await queryTree(x, x.setup.root)) {
|
|
68507
|
-
for (const window2 of [frame, ...await queryTree(x, frame)]) {
|
|
68508
|
-
const value = await cardinal(x, window2, pidAtom);
|
|
68509
|
-
if (value === pid) found.push(window2);
|
|
68510
|
-
}
|
|
68511
|
-
}
|
|
68512
|
-
return found;
|
|
68513
|
-
}
|
|
68514
|
-
async function internAtom(x, name) {
|
|
68515
|
-
const bytes = Buffer.from(name, "latin1");
|
|
68516
|
-
const body = Buffer.alloc(4 + bytes.length);
|
|
68517
|
-
body.writeUInt16LE(bytes.length, 0);
|
|
68518
|
-
bytes.copy(body, 4);
|
|
68519
|
-
return (await x.request(request(OP_INTERN_ATOM, 0, body))).readUInt32LE(8);
|
|
68520
|
-
}
|
|
68521
|
-
async function queryTree(x, window2) {
|
|
68522
|
-
const body = Buffer.alloc(4);
|
|
68523
|
-
body.writeUInt32LE(window2, 0);
|
|
68524
|
-
const reply2 = await x.request(request(OP_QUERY_TREE, 0, body)).catch(() => void 0);
|
|
68525
|
-
if (!reply2) return [];
|
|
68526
|
-
const count = reply2.readUInt16LE(16);
|
|
68527
|
-
return Array.from({ length: count }, (_, i) => reply2.readUInt32LE(32 + i * 4));
|
|
68528
|
-
}
|
|
68529
|
-
async function cardinal(x, window2, property, type = 0) {
|
|
68530
|
-
const body = Buffer.alloc(20);
|
|
68531
|
-
body.writeUInt32LE(window2, 0);
|
|
68532
|
-
body.writeUInt32LE(property, 4);
|
|
68533
|
-
body.writeUInt32LE(type, 8);
|
|
68534
|
-
body.writeUInt32LE(0, 12);
|
|
68535
|
-
body.writeUInt32LE(1, 16);
|
|
68536
|
-
const reply2 = await x.request(request(OP_GET_PROPERTY, 0, body)).catch(() => void 0);
|
|
68537
|
-
if (!reply2 || reply2[1] !== 32 || reply2.readUInt32LE(16) < 1) return void 0;
|
|
68538
|
-
return reply2.readUInt32LE(32);
|
|
68539
|
-
}
|
|
68540
|
-
async function sendClientMessage(x, window2, type, data) {
|
|
68541
|
-
const event = Buffer.alloc(32);
|
|
68542
|
-
event[0] = CLIENT_MESSAGE;
|
|
68543
|
-
event[1] = 32;
|
|
68544
|
-
event.writeUInt32LE(window2, 4);
|
|
68545
|
-
event.writeUInt32LE(type, 8);
|
|
68546
|
-
data.forEach((value, i) => event.writeUInt32LE(value >>> 0, 12 + i * 4));
|
|
68547
|
-
const body = Buffer.alloc(40);
|
|
68548
|
-
body.writeUInt32LE(window2, 0);
|
|
68549
|
-
body.writeUInt32LE(0, 4);
|
|
68550
|
-
event.copy(body, 8);
|
|
68551
|
-
await x.checked(request(OP_SEND_EVENT, 0, body));
|
|
68552
|
-
}
|
|
68553
|
-
|
|
68554
|
-
// src/linux/desktops.ts
|
|
68555
|
-
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
68556
|
-
import { spawn as spawn5, spawnSync } from "node:child_process";
|
|
68557
|
-
import { chmodSync, existsSync as existsSync4, mkdirSync as mkdirSync4, readFileSync as readFileSync4, writeFileSync as writeFileSync3 } from "node:fs";
|
|
68558
|
-
import { homedir as homedir2 } from "node:os";
|
|
68559
|
-
import { join as join6 } from "node:path";
|
|
68560
|
-
|
|
68561
|
-
// src/computer.ts
|
|
68562
|
-
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
68563
|
-
import { hostname as hostname5, release } from "node:os";
|
|
68564
|
-
|
|
68565
|
-
// ../protocol/src/frames/computer.ts
|
|
68566
|
-
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
68567
|
-
|
|
68568
|
-
// ../../node_modules/.pnpm/zod@4.6.7/node_modules/zod/index.js
|
|
68569
|
-
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
68570
|
-
|
|
68571
|
-
// ../protocol/src/envelope.ts
|
|
68572
|
-
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
68573
|
-
var Envelope = external_exports.object({
|
|
68574
|
-
v: external_exports.literal(1),
|
|
68575
|
-
// protocol major; bump = breaking
|
|
68576
|
-
id: external_exports.string().uuid(),
|
|
68577
|
-
// unique per frame (sender-generated)
|
|
68578
|
-
ts: external_exports.string().datetime(),
|
|
68579
|
-
// RFC3339, sender clock (advisory only)
|
|
68580
|
-
type: external_exports.string(),
|
|
68581
|
-
// frame discriminator, e.g. "register"
|
|
68582
|
-
corr: external_exports.string().uuid().optional(),
|
|
68583
|
-
// correlation: set on a reply to the request's `id`
|
|
68584
|
-
orgId: external_exports.string().min(1).max(64).optional(),
|
|
68585
|
-
// tenant context on an install-wide daemon connection
|
|
68586
|
-
payload: external_exports.unknown()
|
|
68587
|
-
// validated by the per-type schema
|
|
68588
|
-
});
|
|
68589
|
-
var ControlExt = external_exports.object({
|
|
68590
|
-
epoch: external_exports.number().int(),
|
|
68591
|
-
// sessionEpoch this frame was issued under (§3.1 fencing)
|
|
68592
|
-
agentId: external_exports.string().uuid().optional(),
|
|
68593
|
-
// present on agent-scoped frames
|
|
68594
|
-
launchId: external_exports.string().uuid().optional()
|
|
68595
|
-
// per-launch fence, §4.4
|
|
68596
|
-
});
|
|
68597
|
-
var NIL_UUID = "00000000-0000-0000-0000-000000000000";
|
|
68598
|
-
function frameSchema(type, payload) {
|
|
68599
|
-
return external_exports.object({
|
|
68600
|
-
v: external_exports.literal(1),
|
|
68601
|
-
id: external_exports.string().uuid(),
|
|
68602
|
-
ts: external_exports.string().datetime(),
|
|
68603
|
-
type: external_exports.literal(type),
|
|
68604
|
-
corr: external_exports.string().uuid().optional(),
|
|
68605
|
-
orgId: external_exports.string().min(1).max(64).optional(),
|
|
68606
|
-
payload
|
|
68607
|
-
});
|
|
68608
|
-
}
|
|
68609
|
-
|
|
68610
|
-
// ../protocol/src/tolerant.ts
|
|
68611
|
-
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
68612
|
-
var memo3 = /* @__PURE__ */ new WeakMap();
|
|
68613
|
-
function tolerantReader(schema) {
|
|
68614
|
-
const hit = memo3.get(schema);
|
|
68615
|
-
if (hit) return hit;
|
|
68616
|
-
const built = rebuild(schema);
|
|
68617
|
-
memo3.set(schema, built);
|
|
68618
|
-
return built;
|
|
68619
|
-
}
|
|
68620
|
-
function tolerantSchemas(schemas) {
|
|
68621
|
-
return Object.fromEntries(Object.entries(schemas).map(([type, schema]) => [type, tolerantReader(schema)]));
|
|
68622
|
-
}
|
|
68623
|
-
function isSchema(value) {
|
|
68624
|
-
return typeof value === "object" && value !== null && "_zod" in value;
|
|
68625
|
-
}
|
|
68626
|
-
function defOf(schema) {
|
|
68627
|
-
return schema._zod.def;
|
|
68628
|
-
}
|
|
68629
|
-
function child(value) {
|
|
68630
|
-
return tolerantReader(value);
|
|
68631
|
-
}
|
|
68632
|
-
function withDef(schema, def) {
|
|
68633
|
-
return external_exports.clone(schema, def);
|
|
68634
|
-
}
|
|
68635
|
-
function rebuild(schema) {
|
|
68636
|
-
const def = defOf(schema);
|
|
68637
|
-
switch (def.type) {
|
|
68638
|
-
case "object": {
|
|
68639
|
-
const shape = Object.fromEntries(
|
|
68640
|
-
Object.entries(def.shape).map(([key, value]) => [key, child(value)])
|
|
68641
|
-
);
|
|
68642
|
-
const catchall = isNeverSchema(def.catchall) ? void 0 : def.catchall ? child(def.catchall) : void 0;
|
|
68643
|
-
return withDef(schema, { ...def, shape, catchall });
|
|
68644
|
-
}
|
|
68645
|
-
case "array":
|
|
68646
|
-
return withDef(schema, { ...def, element: child(def.element) });
|
|
68647
|
-
// Both plain and discriminated unions; the discriminator rides along in the spread def.
|
|
68648
|
-
case "union":
|
|
68649
|
-
return withDef(schema, { ...def, options: def.options.map(child) });
|
|
68650
|
-
case "intersection":
|
|
68651
|
-
return withDef(schema, { ...def, left: child(def.left), right: child(def.right) });
|
|
68652
|
-
case "tuple":
|
|
68653
|
-
return withDef(schema, {
|
|
68654
|
-
...def,
|
|
68655
|
-
items: def.items.map(child),
|
|
68656
|
-
...isSchema(def.rest) ? { rest: child(def.rest) } : {}
|
|
68657
|
-
});
|
|
68658
|
-
case "record":
|
|
68659
|
-
case "map":
|
|
68660
|
-
return withDef(schema, { ...def, keyType: child(def.keyType), valueType: child(def.valueType) });
|
|
68661
|
-
case "set":
|
|
68662
|
-
return withDef(schema, { ...def, valueType: child(def.valueType) });
|
|
68663
|
-
case "optional":
|
|
68664
|
-
case "nullable":
|
|
68665
|
-
case "nonoptional":
|
|
68666
|
-
case "default":
|
|
68667
|
-
case "prefault":
|
|
68668
|
-
case "catch":
|
|
68669
|
-
case "readonly":
|
|
68670
|
-
case "promise":
|
|
68671
|
-
return withDef(schema, { ...def, innerType: child(def.innerType) });
|
|
68672
|
-
case "pipe":
|
|
68673
|
-
return withDef(schema, { ...def, in: child(def.in), out: child(def.out) });
|
|
68674
|
-
case "lazy":
|
|
68675
|
-
return external_exports.lazy(() => child(def.getter()));
|
|
68676
|
-
default:
|
|
68677
|
-
return schema;
|
|
69075
|
+
continue;
|
|
69076
|
+
}
|
|
69077
|
+
const current = mine.get(id);
|
|
69078
|
+
const changed = previous === void 0 || previous[id] !== updated.toString();
|
|
69079
|
+
if (!changed || current?.stamp === updated) {
|
|
69080
|
+
counts.kept++;
|
|
69081
|
+
continue;
|
|
69082
|
+
}
|
|
69083
|
+
insert.run(...columns.map((column) => bindable(row[column])));
|
|
69084
|
+
counts[current ? "updated" : "inserted"]++;
|
|
69085
|
+
}
|
|
69086
|
+
if (previous) {
|
|
69087
|
+
for (const id of Object.keys(previous)) {
|
|
69088
|
+
if (id in next) continue;
|
|
69089
|
+
const current = mine.get(id);
|
|
69090
|
+
if (current) {
|
|
69091
|
+
remove.run(current.rowid);
|
|
69092
|
+
counts.deleted++;
|
|
69093
|
+
}
|
|
69094
|
+
}
|
|
69095
|
+
}
|
|
69096
|
+
db.exec("COMMIT");
|
|
69097
|
+
} catch (error63) {
|
|
69098
|
+
db.exec("ROLLBACK");
|
|
69099
|
+
throw error63;
|
|
69100
|
+
}
|
|
69101
|
+
} finally {
|
|
69102
|
+
source.close();
|
|
69103
|
+
db.close();
|
|
68678
69104
|
}
|
|
68679
69105
|
}
|
|
68680
|
-
function
|
|
68681
|
-
|
|
69106
|
+
function lastModified(meta3) {
|
|
69107
|
+
let pos = 0;
|
|
69108
|
+
while (pos < meta3.length) {
|
|
69109
|
+
const tag = meta3[pos++];
|
|
69110
|
+
let value = 0n;
|
|
69111
|
+
let shift = 0n;
|
|
69112
|
+
for (; ; ) {
|
|
69113
|
+
const byte = meta3[pos++];
|
|
69114
|
+
if (byte === void 0) return value.toString();
|
|
69115
|
+
value |= BigInt(byte & 127) << shift;
|
|
69116
|
+
shift += 7n;
|
|
69117
|
+
if (!(byte & 128)) break;
|
|
69118
|
+
}
|
|
69119
|
+
if (tag === 8) return value.toString();
|
|
69120
|
+
}
|
|
69121
|
+
return "0";
|
|
68682
69122
|
}
|
|
68683
|
-
|
|
68684
|
-
|
|
68685
|
-
|
|
68686
|
-
|
|
68687
|
-
|
|
68688
|
-
|
|
68689
|
-
|
|
68690
|
-
|
|
68691
|
-
|
|
69123
|
+
function mergeLocalStorage(source, target, previous, next, report) {
|
|
69124
|
+
const merged = readLevelDb(target);
|
|
69125
|
+
let changed = false;
|
|
69126
|
+
if (!merged.has("VERSION") && source.has("VERSION")) {
|
|
69127
|
+
merged.set("VERSION", source.get("VERSION"));
|
|
69128
|
+
changed = true;
|
|
69129
|
+
}
|
|
69130
|
+
for (const [key, meta3] of source) {
|
|
69131
|
+
if (!key.startsWith("META:")) continue;
|
|
69132
|
+
const origin = key.slice("META:".length);
|
|
69133
|
+
const modified = lastModified(meta3);
|
|
69134
|
+
next[origin] = modified;
|
|
69135
|
+
const mine = merged.get(key);
|
|
69136
|
+
if (previous !== void 0 && previous[origin] === modified || mine && mine.equals(meta3)) {
|
|
69137
|
+
report.kept++;
|
|
69138
|
+
continue;
|
|
69139
|
+
}
|
|
69140
|
+
const prefix = `_${origin}\0`;
|
|
69141
|
+
for (const existing of [...merged.keys()]) if (existing.startsWith(prefix)) merged.delete(existing);
|
|
69142
|
+
for (const [entry, value] of source) if (entry.startsWith(prefix)) merged.set(entry, value);
|
|
69143
|
+
merged.set(key, meta3);
|
|
69144
|
+
const access = source.get(`METAACCESS:${origin}`);
|
|
69145
|
+
if (access) merged.set(`METAACCESS:${origin}`, access);
|
|
69146
|
+
report.taken.push(origin);
|
|
69147
|
+
changed = true;
|
|
69148
|
+
}
|
|
69149
|
+
if (changed) writeLevelDb(target, merged);
|
|
68692
69150
|
}
|
|
68693
|
-
function
|
|
68694
|
-
|
|
68695
|
-
const
|
|
68696
|
-
|
|
68697
|
-
|
|
68698
|
-
|
|
68699
|
-
if (typeof o.launchId === "string") ext.launchId = o.launchId;
|
|
68700
|
-
return Object.keys(ext).length > 0 ? ext : void 0;
|
|
69151
|
+
function newestMtime(dir) {
|
|
69152
|
+
let newest = 0;
|
|
69153
|
+
for (const entry of readdirSync2(dir, { withFileTypes: true, recursive: true })) {
|
|
69154
|
+
if (entry.isFile()) newest = Math.max(newest, statSync(join3(entry.parentPath, entry.name)).mtimeMs);
|
|
69155
|
+
}
|
|
69156
|
+
return newest;
|
|
68701
69157
|
}
|
|
68702
|
-
function
|
|
68703
|
-
|
|
68704
|
-
|
|
69158
|
+
function mergeIndexedDb(snapshot, target, previous, next, report) {
|
|
69159
|
+
for (const name of readdirSync2(snapshot)) {
|
|
69160
|
+
if (!name.endsWith(".indexeddb.leveldb")) continue;
|
|
69161
|
+
const origin = name.slice(0, -".indexeddb.leveldb".length);
|
|
69162
|
+
const modified = newestMtime(join3(snapshot, name));
|
|
69163
|
+
next[origin] = modified;
|
|
69164
|
+
const mine = join3(target, name);
|
|
69165
|
+
if (previous !== void 0 && previous[origin] === modified || existsSync2(mine) && newestMtime(mine) === modified) {
|
|
69166
|
+
report.kept++;
|
|
69167
|
+
continue;
|
|
69168
|
+
}
|
|
69169
|
+
for (const suffix of [".indexeddb.leveldb", ".indexeddb.blob"]) {
|
|
69170
|
+
const to = join3(target, origin + suffix);
|
|
69171
|
+
rmSync2(to, { recursive: true, force: true });
|
|
69172
|
+
const from = join3(snapshot, origin + suffix);
|
|
69173
|
+
if (existsSync2(from)) cpSync(from, to, { recursive: true, preserveTimestamps: true });
|
|
69174
|
+
}
|
|
69175
|
+
report.taken.push(origin);
|
|
68705
69176
|
}
|
|
68706
|
-
|
|
69177
|
+
}
|
|
69178
|
+
|
|
69179
|
+
// src/browser/launcher.ts
|
|
69180
|
+
var BROWSER_NAMES = ["chromium", "chromium-browser", "google-chrome-stable", "google-chrome"];
|
|
69181
|
+
var BASE_FLAGS = ["--no-first-run", "--no-default-browser-check", "--hide-crash-restore-bubble"];
|
|
69182
|
+
var LOCK_STALE_MS = 6e4;
|
|
69183
|
+
var LOCK_WAIT_MS = 3e4;
|
|
69184
|
+
var OWN_WAIT_MS = 2e4;
|
|
69185
|
+
function profileOwner(profile, host = hostname4()) {
|
|
69186
|
+
let target;
|
|
68707
69187
|
try {
|
|
68708
|
-
|
|
69188
|
+
target = readlinkSync(join4(profile, "SingletonLock"));
|
|
68709
69189
|
} catch {
|
|
68710
|
-
return
|
|
68711
|
-
}
|
|
68712
|
-
const env = Envelope.safeParse(json4);
|
|
68713
|
-
if (!env.success) {
|
|
68714
|
-
const id = typeof json4 === "object" && json4 !== null && typeof json4.id === "string" ? json4.id : NIL_UUID;
|
|
68715
|
-
return { ok: false, id, msg: env.error.message };
|
|
68716
|
-
}
|
|
68717
|
-
const schema = Object.hasOwn(schemas, env.data.type) ? schemas[env.data.type] : void 0;
|
|
68718
|
-
if (!schema) {
|
|
68719
|
-
return {
|
|
68720
|
-
ok: false,
|
|
68721
|
-
id: env.data.id,
|
|
68722
|
-
msg: "UNKNOWN_FRAME",
|
|
68723
|
-
...env.data.corr ? { corr: env.data.corr } : {}
|
|
68724
|
-
};
|
|
69190
|
+
return void 0;
|
|
68725
69191
|
}
|
|
68726
|
-
const
|
|
68727
|
-
if (!
|
|
68728
|
-
|
|
68729
|
-
|
|
68730
|
-
|
|
68731
|
-
|
|
68732
|
-
|
|
68733
|
-
|
|
69192
|
+
const match = /^(.*)-(\d+)$/.exec(target);
|
|
69193
|
+
if (!match || match[1] !== host) return void 0;
|
|
69194
|
+
const pid = Number(match[2]);
|
|
69195
|
+
try {
|
|
69196
|
+
process.kill(pid, 0);
|
|
69197
|
+
return pid;
|
|
69198
|
+
} catch (error63) {
|
|
69199
|
+
return error63.code === "EPERM" ? pid : void 0;
|
|
68734
69200
|
}
|
|
68735
|
-
const ext = extractControlExt(json4);
|
|
68736
|
-
return {
|
|
68737
|
-
ok: true,
|
|
68738
|
-
frame: { ...env.data, payload: payload.data },
|
|
68739
|
-
...ext ? { ext } : {}
|
|
68740
|
-
};
|
|
68741
69201
|
}
|
|
68742
|
-
function
|
|
68743
|
-
|
|
68744
|
-
|
|
68745
|
-
id: opts.id ?? randomUUID(),
|
|
68746
|
-
ts: opts.ts ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
68747
|
-
type,
|
|
68748
|
-
payload,
|
|
68749
|
-
...opts.corr ? { corr: opts.corr } : {},
|
|
68750
|
-
...opts.orgId ? { orgId: opts.orgId } : {},
|
|
68751
|
-
...opts.ext ?? {}
|
|
68752
|
-
};
|
|
69202
|
+
function seedable(path) {
|
|
69203
|
+
const name = basename2(path);
|
|
69204
|
+
return !(name.startsWith("Singleton") || /cache$/i.test(name) || name === "Crash Reports" || name === "Sessions" || name === "Session Storage" || name === BASELINE_FILE);
|
|
68753
69205
|
}
|
|
68754
|
-
|
|
68755
|
-
|
|
68756
|
-
|
|
68757
|
-
var ErrorCode = external_exports.enum([
|
|
68758
|
-
// protocol / framing
|
|
68759
|
-
"UNKNOWN_FRAME",
|
|
68760
|
-
"FRAME_TOO_LARGE",
|
|
68761
|
-
"PROTOCOL_STATE",
|
|
68762
|
-
"BAD_PAYLOAD",
|
|
68763
|
-
// auth / identity
|
|
68764
|
-
"AUTH_FAILED",
|
|
68765
|
-
"ATTESTATION_INVALID",
|
|
68766
|
-
// fencing / ordering
|
|
68767
|
-
"STALE_EPOCH",
|
|
68768
|
-
"STALE_LAUNCH",
|
|
68769
|
-
// delivery
|
|
68770
|
-
"NO_SESSION",
|
|
68771
|
-
"SCOPE_DENIED",
|
|
68772
|
-
// delegated MCP authority / invocation binding
|
|
68773
|
-
"DELEGATION_DENIED",
|
|
68774
|
-
"INVOCATION_CONFLICT",
|
|
68775
|
-
// secrets
|
|
68776
|
-
"LEASE_EXPIRED",
|
|
68777
|
-
"LEASE_DENIED",
|
|
68778
|
-
// generic
|
|
68779
|
-
"RATE_LIMITED",
|
|
68780
|
-
"CONFLICT",
|
|
68781
|
-
"INTERNAL"
|
|
68782
|
-
]);
|
|
68783
|
-
var ErrorFrame = external_exports.object({
|
|
68784
|
-
code: ErrorCode,
|
|
68785
|
-
message: external_exports.string(),
|
|
68786
|
-
// human-readable, redacted of secrets
|
|
68787
|
-
retryable: external_exports.boolean(),
|
|
68788
|
-
details: external_exports.record(external_exports.string(), external_exports.unknown()).optional()
|
|
68789
|
-
});
|
|
68790
|
-
|
|
68791
|
-
// ../protocol/src/frames/computer-lease.ts
|
|
68792
|
-
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
68793
|
-
var COMPUTER_LEASE_AGENT_NAME_MAX = 200;
|
|
68794
|
-
var ComputerLeaseHolder = external_exports.object({
|
|
68795
|
-
sessionId: external_exports.string().min(1).max(256),
|
|
68796
|
-
agentId: external_exports.string().uuid(),
|
|
68797
|
-
agentName: external_exports.string().min(1).max(COMPUTER_LEASE_AGENT_NAME_MAX).optional()
|
|
68798
|
-
});
|
|
68799
|
-
var computerLeaseHolderName = (holder) => `${holder.agentId}/${holder.sessionId}`;
|
|
68800
|
-
var ComputerControlLease = external_exports.object({
|
|
68801
|
-
leaseId: external_exports.string().uuid(),
|
|
68802
|
-
computerId: external_exports.string().uuid(),
|
|
68803
|
-
holder: ComputerLeaseHolder,
|
|
68804
|
-
acquiredAt: external_exports.string().datetime(),
|
|
68805
|
-
expiresAt: external_exports.string().datetime()
|
|
68806
|
-
});
|
|
68807
|
-
var COMPUTER_LEASE_REFUSALS = ["computer_busy", "human_in_control", "unavailable", "denied"];
|
|
68808
|
-
var COMPUTER_LEASE_POLL_MAX_MS = 1e4;
|
|
68809
|
-
var COMPUTER_LEASE_WAIT_MAX_SECONDS = 600;
|
|
68810
|
-
var ComputerLeaseAcquire = external_exports.object({
|
|
68811
|
-
computerId: external_exports.string().uuid(),
|
|
68812
|
-
agentId: external_exports.string().uuid(),
|
|
68813
|
-
sessionId: external_exports.string().min(1).max(256),
|
|
68814
|
-
// The daemon-clock time of the request, compared with the `event/session` turn end on the same clock.
|
|
68815
|
-
requestedAt: external_exports.string().datetime(),
|
|
68816
|
-
// Behind COMPUTER_LEASE_QUEUE_FEATURE: wait in the Computer's FIFO queue, holding the reply up to this long.
|
|
68817
|
-
waitMs: external_exports.number().int().min(0).max(COMPUTER_LEASE_POLL_MAX_MS).optional()
|
|
68818
|
-
});
|
|
68819
|
-
var ComputerLeaseQueued = external_exports.object({
|
|
68820
|
-
position: external_exports.number().int().min(1),
|
|
68821
|
-
waitedMs: external_exports.number().int().min(0),
|
|
68822
|
-
// Time left before the wait ends in `computer_busy`.
|
|
68823
|
-
leftMs: external_exports.number().int().min(0)
|
|
68824
|
-
});
|
|
68825
|
-
var ComputerLeaseAcquireResult = external_exports.discriminatedUnion("granted", [
|
|
68826
|
-
external_exports.object({ granted: external_exports.literal(true), lease: ComputerControlLease }),
|
|
68827
|
-
external_exports.object({
|
|
68828
|
-
granted: external_exports.literal(false),
|
|
68829
|
-
code: external_exports.enum(COMPUTER_LEASE_REFUSALS),
|
|
68830
|
-
message: external_exports.string().max(500),
|
|
68831
|
-
holder: ComputerLeaseHolder.optional(),
|
|
68832
|
-
queued: ComputerLeaseQueued.optional()
|
|
68833
|
-
})
|
|
68834
|
-
]);
|
|
68835
|
-
var ComputerLeaseRelease = external_exports.object({
|
|
68836
|
-
computerId: external_exports.string().uuid(),
|
|
68837
|
-
agentId: external_exports.string().uuid(),
|
|
68838
|
-
sessionId: external_exports.string().min(1).max(256)
|
|
68839
|
-
});
|
|
68840
|
-
|
|
68841
|
-
// ../protocol/src/frames/computer-channel.ts
|
|
68842
|
-
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
68843
|
-
|
|
68844
|
-
// ../protocol/src/computer-channel-token.ts
|
|
68845
|
-
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
68846
|
-
import { createHmac, timingSafeEqual } from "node:crypto";
|
|
68847
|
-
|
|
68848
|
-
// ../protocol/src/computer-viewer.ts
|
|
68849
|
-
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
68850
|
-
var COMPUTER_VIEWER_API_PREFIX = "/view/api/";
|
|
68851
|
-
var COMPUTER_VIEWER_MAX_REQUEST_BYTES = 64 * 1024;
|
|
68852
|
-
var COMPUTER_VIEWER_TRANSPORTS = ["direct", "stun", "turn"];
|
|
68853
|
-
var ComputerIceServer = external_exports.object({
|
|
68854
|
-
urls: external_exports.array(
|
|
68855
|
-
external_exports.string().regex(/^turns?:/).max(256)
|
|
68856
|
-
).min(1).max(4),
|
|
68857
|
-
username: external_exports.string().min(1).max(256),
|
|
68858
|
-
credential: external_exports.string().min(1).max(256)
|
|
68859
|
-
}).strict();
|
|
68860
|
-
var COMPUTER_ICE_SERVERS_MAX = 2;
|
|
68861
|
-
var ComputerStunUrl = external_exports.string().max(256).regex(/^stun:(\[[0-9a-fA-F:.]+\]|[A-Za-z0-9.-]+)(:\d{1,5})?$/, "expected stun:<host>[:<port>]");
|
|
68862
|
-
var ComputerTurnUrl = external_exports.string().max(256).regex(
|
|
68863
|
-
/^turns?:(\[[0-9a-fA-F:.]+\]|[A-Za-z0-9.-]+)(:\d{1,5})?(\?transport=(udp|tcp))?$/,
|
|
68864
|
-
"expected turn:<host>[:<port>][?transport=udp|tcp] or turns:"
|
|
68865
|
-
);
|
|
68866
|
-
var COMPUTER_STUN_URLS_MAX = 2;
|
|
68867
|
-
var ComputerViewerCandidate = external_exports.object({
|
|
68868
|
-
id: external_exports.string().min(1).max(64),
|
|
68869
|
-
candidate: external_exports.object({
|
|
68870
|
-
candidate: external_exports.string().max(1024),
|
|
68871
|
-
sdpMid: external_exports.string().max(64).nullish(),
|
|
68872
|
-
sdpMLineIndex: external_exports.number().int().min(0).max(64).nullish()
|
|
68873
|
-
}).nullable()
|
|
68874
|
-
});
|
|
68875
|
-
var ComputerViewerCandidatesRequest = external_exports.object({
|
|
68876
|
-
id: external_exports.string().min(1).max(64),
|
|
68877
|
-
after: external_exports.number().int().min(0).max(1e3).default(0)
|
|
68878
|
-
});
|
|
68879
|
-
var ComputerViewerOfferRequest = external_exports.object({ transport: external_exports.enum(COMPUTER_VIEWER_TRANSPORTS).optional() });
|
|
68880
|
-
var ComputerViewerRenewal = external_exports.object({ type: external_exports.literal("auth"), token: external_exports.string().min(1).max(4096) });
|
|
68881
|
-
|
|
68882
|
-
// ../protocol/src/computer-command-line.ts
|
|
68883
|
-
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
68884
|
-
var COMPUTER_SHELL_MODES = ["off", "ask", "on"];
|
|
68885
|
-
var COMPUTER_FILES_MODES = ["off", "read", "read-write"];
|
|
68886
|
-
var COMPUTER_FILE_ROOTS_MAX = 32;
|
|
68887
|
-
var ComputerFileRoot = external_exports.string().trim().min(1).max(1024).refine((p) => /^(\/|~(\/|$)|[A-Za-z]:[\\/])/.test(p) && !p.includes("\0"), "expected an absolute path");
|
|
68888
|
-
var COMPUTER_EXEC_TIMEOUT_DEFAULT_MS = 3e4;
|
|
68889
|
-
var COMPUTER_EXEC_TIMEOUT_MAX_MS = 9e4;
|
|
68890
|
-
var COMPUTER_EXEC_COMMAND_MAX_CHARS = 16384;
|
|
68891
|
-
var COMPUTER_EXEC_OUTPUT_TAIL_BYTES = 32 * 1024;
|
|
68892
|
-
var COMPUTER_EXEC_PER_SESSION_MAX = 4;
|
|
68893
|
-
var COMPUTER_EXEC_TOTAL_MAX = 8;
|
|
68894
|
-
var COMPUTER_READ_TEXT_MAX_BYTES = 256 * 1024;
|
|
68895
|
-
var COMPUTER_READ_IMAGE_MAX_BYTES = 5 * 1024 * 1024;
|
|
68896
|
-
var COMPUTER_WRITE_MAX_BYTES = 1024 * 1024;
|
|
68897
|
-
var COMPUTER_LIST_DIR_MAX = 1e3;
|
|
68898
|
-
var SHELL_RANK = { off: 0, ask: 1, on: 2 };
|
|
68899
|
-
var FILES_RANK = { off: 0, read: 1, "read-write": 2 };
|
|
68900
|
-
var narrowerShell = (a, b) => SHELL_RANK[a] <= SHELL_RANK[b] ? a : b;
|
|
68901
|
-
var narrowerFiles = (a, b) => FILES_RANK[a] <= FILES_RANK[b] ? a : b;
|
|
68902
|
-
|
|
68903
|
-
// ../protocol/src/computer-channel-token.ts
|
|
68904
|
-
var COMPUTER_CHANNEL_TOKEN_PREFIX = "actk1";
|
|
68905
|
-
var COMPUTER_CHANNEL_TOKEN_AUDIENCES = ["mcp", "relay", "view"];
|
|
68906
|
-
var COMPUTER_CHANNEL_TOKEN_MAX_TTL_MS = 5 * 6e4;
|
|
68907
|
-
var COMPUTER_AGENT_MODES = ["view", "control"];
|
|
68908
|
-
var ComputerChannelTokenClaims = external_exports.object({
|
|
68909
|
-
aud: external_exports.enum(COMPUTER_CHANNEL_TOKEN_AUDIENCES),
|
|
68910
|
-
// The Computer the token is for, and the id of the channel key that signed it.
|
|
68911
|
-
cmp: external_exports.string().uuid(),
|
|
68912
|
-
kid: external_exports.string().min(1).max(64),
|
|
68913
|
-
// Issue and expiry times, epoch milliseconds on the issuer's clock.
|
|
68914
|
-
iat: external_exports.number().int().nonnegative(),
|
|
68915
|
-
exp: external_exports.number().int().positive(),
|
|
68916
|
-
// `mcp` only: the agent session the calls belong to, its agent and daemon, and what the policy lets it do.
|
|
68917
|
-
ses: external_exports.string().min(1).max(256).optional(),
|
|
68918
|
-
agt: external_exports.string().uuid().optional(),
|
|
68919
|
-
dmn: external_exports.string().uuid().optional(),
|
|
68920
|
-
mode: external_exports.enum(COMPUTER_AGENT_MODES).optional(),
|
|
68921
|
-
// `mcp` only: the command-line tier the policy allows (§5.7); absent, as from an older CP, means none.
|
|
68922
|
-
sh: external_exports.enum(COMPUTER_SHELL_MODES).optional(),
|
|
68923
|
-
fs: external_exports.enum(COMPUTER_FILES_MODES).optional(),
|
|
68924
|
-
// `view` only: the member watching, the TURN servers the desktop may relay media through, and the STUN servers it may punch with.
|
|
68925
|
-
usr: external_exports.string().min(1).max(128).optional(),
|
|
68926
|
-
ice: external_exports.array(ComputerIceServer).max(COMPUTER_ICE_SERVERS_MAX).optional(),
|
|
68927
|
-
stun: external_exports.array(ComputerStunUrl).max(COMPUTER_STUN_URLS_MAX).optional()
|
|
68928
|
-
}).strip().refine((c) => c.aud !== "mcp" || c.ses !== void 0 && c.agt !== void 0 && c.mode !== void 0, {
|
|
68929
|
-
message: "an mcp token names its session, agent and mode"
|
|
68930
|
-
}).refine((c) => c.aud !== "view" || c.usr !== void 0 && c.mode !== void 0, {
|
|
68931
|
-
message: "a view token names its member and mode"
|
|
68932
|
-
}).refine((c) => c.exp > c.iat && c.exp - c.iat <= COMPUTER_CHANNEL_TOKEN_MAX_TTL_MS, {
|
|
68933
|
-
message: "token lifetime out of range"
|
|
68934
|
-
});
|
|
68935
|
-
var MAC_DOMAIN = "agentconnect/computer-channel-token/v1\n";
|
|
68936
|
-
var MAX_TOKEN_CHARS = 4096;
|
|
68937
|
-
function mac3(key, signed) {
|
|
68938
|
-
return createHmac("sha256", key).update(MAC_DOMAIN + signed).digest();
|
|
69206
|
+
function seedProfile(master, profile) {
|
|
69207
|
+
mkdirSync3(dirname2(profile), { recursive: true });
|
|
69208
|
+
cpSync2(master, profile, { recursive: true, preserveTimestamps: true, filter: seedable });
|
|
68939
69209
|
}
|
|
68940
|
-
function
|
|
68941
|
-
const
|
|
68942
|
-
const
|
|
68943
|
-
|
|
69210
|
+
function findBrowser(path = process.env.PATH ?? "", skip = []) {
|
|
69211
|
+
const skipped = new Set(skip.map((dir) => resolve(dir)));
|
|
69212
|
+
for (const name of BROWSER_NAMES) {
|
|
69213
|
+
for (const dir of path.split(delimiter)) {
|
|
69214
|
+
if (!dir || skipped.has(resolve(dir))) continue;
|
|
69215
|
+
const candidate = join4(dir, name);
|
|
69216
|
+
try {
|
|
69217
|
+
accessSync(candidate, constants.X_OK);
|
|
69218
|
+
if (statSync2(candidate).isFile()) return candidate;
|
|
69219
|
+
} catch {
|
|
69220
|
+
}
|
|
69221
|
+
}
|
|
69222
|
+
}
|
|
69223
|
+
return void 0;
|
|
68944
69224
|
}
|
|
68945
|
-
function
|
|
68946
|
-
|
|
68947
|
-
const
|
|
68948
|
-
if (parts.length !== 3 || parts[0] !== COMPUTER_CHANNEL_TOKEN_PREFIX) return null;
|
|
69225
|
+
async function launchBrowser(options) {
|
|
69226
|
+
const log40 = options.log ?? (() => void 0);
|
|
69227
|
+
const release3 = await lockProfile(options.profile);
|
|
68949
69228
|
try {
|
|
68950
|
-
|
|
68951
|
-
|
|
68952
|
-
|
|
68953
|
-
|
|
69229
|
+
if (profileOwner(options.profile) !== void 0) {
|
|
69230
|
+
start(options).unref();
|
|
69231
|
+
return { handedOff: true, reports: [] };
|
|
69232
|
+
}
|
|
69233
|
+
if (!existsSync3(options.profile)) {
|
|
69234
|
+
if (options.master && existsSync3(options.master)) {
|
|
69235
|
+
seedProfile(options.master, options.profile);
|
|
69236
|
+
log40(`browser profile ${options.profile} created from ${options.master}`);
|
|
69237
|
+
} else mkdirSync3(options.profile, { recursive: true });
|
|
69238
|
+
}
|
|
69239
|
+
for (const name of ["SingletonLock", "SingletonCookie", "SingletonSocket"]) {
|
|
69240
|
+
rmSync3(join4(options.profile, name), { force: true });
|
|
69241
|
+
}
|
|
69242
|
+
const self2 = realpathSync2(options.profile);
|
|
69243
|
+
const sources = options.sources.filter(
|
|
69244
|
+
(source) => existsSync3(join4(source, "Default")) && realpathSync2(source) !== self2
|
|
69245
|
+
);
|
|
69246
|
+
const reports = await forkMerge(options.profile, sources);
|
|
69247
|
+
for (const report of reports) log40(`browser fork-merge from ${report.source}: ${summarize(report)}`);
|
|
69248
|
+
const child2 = start(options);
|
|
69249
|
+
if (!await owned(options.profile, child2)) log40(`browser for ${options.profile} did not take its profile`);
|
|
69250
|
+
return { handedOff: false, reports, ...child2.pid !== void 0 ? { pid: child2.pid } : {} };
|
|
69251
|
+
} finally {
|
|
69252
|
+
release3();
|
|
68954
69253
|
}
|
|
68955
69254
|
}
|
|
68956
|
-
function
|
|
68957
|
-
const
|
|
68958
|
-
|
|
68959
|
-
|
|
68960
|
-
|
|
68961
|
-
|
|
68962
|
-
|
|
68963
|
-
|
|
68964
|
-
const expected = mac3(key, token.slice(0, at));
|
|
68965
|
-
if (presented.length !== expected.length || !timingSafeEqual(presented, expected)) return null;
|
|
68966
|
-
return claims;
|
|
69255
|
+
function start(options) {
|
|
69256
|
+
const child2 = spawn2(options.browser, [`--user-data-dir=${options.profile}`, ...BASE_FLAGS, ...options.args ?? []], {
|
|
69257
|
+
detached: true,
|
|
69258
|
+
stdio: "ignore",
|
|
69259
|
+
env: options.env ?? process.env
|
|
69260
|
+
});
|
|
69261
|
+
child2.on("error", () => void 0);
|
|
69262
|
+
return child2;
|
|
68967
69263
|
}
|
|
68968
|
-
|
|
68969
|
-
|
|
68970
|
-
|
|
68971
|
-
|
|
68972
|
-
|
|
68973
|
-
|
|
68974
|
-
|
|
68975
|
-
|
|
68976
|
-
|
|
68977
|
-
|
|
68978
|
-
|
|
68979
|
-
|
|
68980
|
-
|
|
68981
|
-
|
|
68982
|
-
}
|
|
68983
|
-
var ComputerGrantApprovalsSchema = ComputerApprovalsSchema.extend({
|
|
68984
|
-
launchApp: external_exports.enum(["always", "session", "never-ask"]).optional(),
|
|
68985
|
-
submitLikeKeys: external_exports.boolean().optional()
|
|
68986
|
-
});
|
|
68987
|
-
var COMPUTER_CHANNEL_REFUSALS = ["denied", "unavailable"];
|
|
68988
|
-
var ComputerChannelGrantRequest = external_exports.object({
|
|
68989
|
-
computerId: external_exports.string().uuid(),
|
|
68990
|
-
agentId: external_exports.string().uuid(),
|
|
68991
|
-
sessionId: external_exports.string().min(1).max(256)
|
|
68992
|
-
});
|
|
68993
|
-
var ComputerChannelGrantResult = external_exports.discriminatedUnion("granted", [
|
|
68994
|
-
external_exports.object({
|
|
68995
|
-
granted: external_exports.literal(true),
|
|
68996
|
-
token: external_exports.string().min(1).max(2048),
|
|
68997
|
-
expiresAt: external_exports.string().datetime(),
|
|
68998
|
-
mode: external_exports.enum(COMPUTER_AGENT_MODES),
|
|
68999
|
-
relays: external_exports.array(ComputerRelayEntry).max(COMPUTER_RELAYS_MAX),
|
|
69000
|
-
// What the approval cards name and whom they also reach (§4.2); an older CP sends none, and every approval is asked.
|
|
69001
|
-
name: external_exports.string().min(1).max(200).optional(),
|
|
69002
|
-
ownerUserId: external_exports.string().min(1).max(128).optional(),
|
|
69003
|
-
approvals: ComputerGrantApprovalsSchema.optional(),
|
|
69004
|
-
// The console users who may answer its approvals: the Computer's allowed members; an older CP sends none.
|
|
69005
|
-
approvers: external_exports.array(external_exports.string().min(1).max(128)).max(500).optional(),
|
|
69006
|
-
// The command-line tier the token allows (§5.7); an older CP sends none, which allows none.
|
|
69007
|
-
shell: external_exports.enum(COMPUTER_SHELL_MODES).optional(),
|
|
69008
|
-
files: external_exports.enum(COMPUTER_FILES_MODES).optional()
|
|
69009
|
-
}),
|
|
69010
|
-
external_exports.object({
|
|
69011
|
-
granted: external_exports.literal(false),
|
|
69012
|
-
code: external_exports.enum(COMPUTER_CHANNEL_REFUSALS),
|
|
69013
|
-
message: external_exports.string().max(500)
|
|
69014
|
-
})
|
|
69015
|
-
]);
|
|
69016
|
-
|
|
69017
|
-
// ../protocol/src/frames/computer-audit.ts
|
|
69018
|
-
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
69019
|
-
var COMPUTER_AUDIT_FEATURE = "computer-audit-v1";
|
|
69020
|
-
var COMPUTER_APPROVAL_META_KEY = "md.agentconnect/approval";
|
|
69021
|
-
var COMPUTER_APPROVAL_RESULTS = ["not_required", "allowed", "allowed_session"];
|
|
69022
|
-
var COMPUTER_AUDIT_BATCH_MAX = 100;
|
|
69023
|
-
var COMPUTER_AUDIT_BATCH_BYTES = REPLY_BUDGET;
|
|
69024
|
-
var COMPUTER_AUDIT_ARGS_MAX_CHARS = 2048;
|
|
69025
|
-
var AUDIT_STRING_MAX = 256;
|
|
69026
|
-
var AUDIT_COMMAND_MAX = 1536;
|
|
69027
|
-
var AUDIT_DEPTH_MAX = 6;
|
|
69028
|
-
var TEXT_KEYS = /* @__PURE__ */ new Set(["text", "value", "content"]);
|
|
69029
|
-
var CONTROL_CHARS = /[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/g;
|
|
69030
|
-
var LONE_SURROGATE = /[\ud800-\udbff](?![\udc00-\udfff])|(?<![\ud800-\udbff])[\udc00-\udfff]/g;
|
|
69031
|
-
function computerAuditText(value) {
|
|
69032
|
-
return value.replace(CONTROL_CHARS, "").replace(LONE_SURROGATE, "\uFFFD");
|
|
69264
|
+
async function owned(profile, child2) {
|
|
69265
|
+
let ended = false;
|
|
69266
|
+
const end = () => void (ended = true);
|
|
69267
|
+
child2.once("error", end).once("exit", end);
|
|
69268
|
+
try {
|
|
69269
|
+
const deadline = Date.now() + OWN_WAIT_MS;
|
|
69270
|
+
for (; ; ) {
|
|
69271
|
+
if (profileOwner(profile) !== void 0) return true;
|
|
69272
|
+
if (ended || Date.now() > deadline) return false;
|
|
69273
|
+
await new Promise((resolveWait) => setTimeout(resolveWait, 100));
|
|
69274
|
+
}
|
|
69275
|
+
} finally {
|
|
69276
|
+
child2.off("error", end).off("exit", end);
|
|
69277
|
+
child2.unref();
|
|
69278
|
+
}
|
|
69033
69279
|
}
|
|
69034
|
-
function
|
|
69035
|
-
|
|
69036
|
-
|
|
69037
|
-
|
|
69038
|
-
|
|
69039
|
-
|
|
69040
|
-
|
|
69041
|
-
|
|
69042
|
-
return out;
|
|
69280
|
+
function summarize(report) {
|
|
69281
|
+
const c = report.cookies;
|
|
69282
|
+
return [
|
|
69283
|
+
report.firstFork ? "first fork" : "since last fork",
|
|
69284
|
+
`cookies +${c.inserted} ~${c.updated} -${c.deleted} (kept ${c.kept}, expired ${c.expired})`,
|
|
69285
|
+
`localStorage ${report.localStorage.taken.length} origin(s)`,
|
|
69286
|
+
`IndexedDB ${report.indexedDb.taken.length} origin(s)`
|
|
69287
|
+
].join(", ");
|
|
69043
69288
|
}
|
|
69044
|
-
function
|
|
69045
|
-
|
|
69046
|
-
|
|
69047
|
-
|
|
69048
|
-
|
|
69049
|
-
|
|
69050
|
-
|
|
69289
|
+
async function lockProfile(profile) {
|
|
69290
|
+
const path = `${profile}.launch-lock`;
|
|
69291
|
+
mkdirSync3(dirname2(path), { recursive: true });
|
|
69292
|
+
const deadline = Date.now() + LOCK_WAIT_MS;
|
|
69293
|
+
for (; ; ) {
|
|
69294
|
+
try {
|
|
69295
|
+
closeSync(openSync(path, "wx"));
|
|
69296
|
+
return () => rmSync3(path, { force: true });
|
|
69297
|
+
} catch (error63) {
|
|
69298
|
+
if (error63.code !== "EEXIST") throw error63;
|
|
69299
|
+
try {
|
|
69300
|
+
if (Date.now() - statSync2(path).mtimeMs > LOCK_STALE_MS) rmSync3(path, { force: true });
|
|
69301
|
+
} catch {
|
|
69302
|
+
}
|
|
69303
|
+
if (Date.now() > deadline) throw new Error(`another browser launch for ${profile} is still running`);
|
|
69304
|
+
await new Promise((resolveWait) => setTimeout(resolveWait, 200));
|
|
69051
69305
|
}
|
|
69052
|
-
out[computerAuditText(key.slice(0, 64))] = key === "command" && typeof value === "string" ? computerAuditText(value.slice(0, AUDIT_COMMAND_MAX)) : auditValue(value, 1);
|
|
69053
69306
|
}
|
|
69054
|
-
const bounded = JSON.stringify(out).length <= COMPUTER_AUDIT_ARGS_MAX_CHARS ? out : { truncated: true };
|
|
69055
|
-
return { args: bounded, ...textLength !== void 0 ? { textLength } : {} };
|
|
69056
|
-
}
|
|
69057
|
-
var ComputerAuditEntry = external_exports.object({
|
|
69058
|
-
// Idempotency: a batch resent after a lost ack does not duplicate rows.
|
|
69059
|
-
id: external_exports.string().uuid(),
|
|
69060
|
-
at: external_exports.string().datetime(),
|
|
69061
|
-
tool: external_exports.string().min(1).max(128),
|
|
69062
|
-
// The lease holder name: `agentId/sessionId` for an agent session, else a local client or viewer name.
|
|
69063
|
-
client: external_exports.string().min(1).max(512),
|
|
69064
|
-
agentId: external_exports.string().uuid().optional(),
|
|
69065
|
-
sessionId: external_exports.string().min(1).max(256).optional(),
|
|
69066
|
-
outcome: external_exports.enum(["ok", "error"]),
|
|
69067
|
-
code: external_exports.string().min(1).max(64).optional(),
|
|
69068
|
-
approval: external_exports.enum(COMPUTER_APPROVAL_RESULTS).optional(),
|
|
69069
|
-
args: external_exports.record(external_exports.string().max(64), external_exports.unknown()).refine((args) => JSON.stringify(args).length <= COMPUTER_AUDIT_ARGS_MAX_CHARS, "audit args too large").optional(),
|
|
69070
|
-
textLength: external_exports.number().int().min(0).max(1e6).optional(),
|
|
69071
|
-
ms: external_exports.number().int().min(0),
|
|
69072
|
-
// The stored screenshot this call returned (§9), as `sha256:<hex>`.
|
|
69073
|
-
screenshotRef: external_exports.string().min(1).max(1024).optional()
|
|
69074
|
-
}).strict();
|
|
69075
|
-
var ComputerAuditReport = external_exports.object({
|
|
69076
|
-
entries: external_exports.array(ComputerAuditEntry).min(1).max(COMPUTER_AUDIT_BATCH_MAX)
|
|
69077
|
-
});
|
|
69078
|
-
var ComputerAuditAck = external_exports.object({ stored: external_exports.number().int().min(0) });
|
|
69079
|
-
|
|
69080
|
-
// ../protocol/src/frames/computer-screenshot.ts
|
|
69081
|
-
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
69082
|
-
var COMPUTER_SCREENSHOT_FEATURE = "computer-screenshot-v1";
|
|
69083
|
-
var COMPUTER_SCREENSHOT_RETENTION_MAX_DAYS = 3650;
|
|
69084
|
-
var COMPUTER_SCREENSHOT_MAX_BYTES = 32 * 1024 * 1024;
|
|
69085
|
-
var COMPUTER_SCREENSHOT_CONTENT_TYPES = ["image/png", "image/jpeg", "image/webp"];
|
|
69086
|
-
var REF_PREFIX = "sha256:";
|
|
69087
|
-
var SHA256_HEX_RE = /^[0-9a-f]{64}$/;
|
|
69088
|
-
var ComputerScreenshotSha256 = external_exports.string().regex(SHA256_HEX_RE, "expected a lower-case hex SHA-256");
|
|
69089
|
-
function computerScreenshotRef(sha2563) {
|
|
69090
|
-
return `${REF_PREFIX}${sha2563}`;
|
|
69091
69307
|
}
|
|
69092
|
-
var ComputerScreenshotPut = external_exports.object({
|
|
69093
|
-
sessionId: external_exports.string().min(1).max(256),
|
|
69094
|
-
agentId: external_exports.string().uuid(),
|
|
69095
|
-
sha256: ComputerScreenshotSha256,
|
|
69096
|
-
bytes: external_exports.number().int().positive().max(COMPUTER_SCREENSHOT_MAX_BYTES),
|
|
69097
|
-
contentType: external_exports.enum(COMPUTER_SCREENSHOT_CONTENT_TYPES),
|
|
69098
|
-
takenAt: external_exports.string().datetime()
|
|
69099
|
-
}).strict();
|
|
69100
|
-
var ComputerScreenshotPutOk = external_exports.object({
|
|
69101
|
-
status: external_exports.enum(["upload", "stored", "skipped"]),
|
|
69102
|
-
url: external_exports.string().url().optional(),
|
|
69103
|
-
headers: external_exports.record(external_exports.string(), external_exports.string()).optional(),
|
|
69104
|
-
expiresAt: external_exports.string().datetime().optional(),
|
|
69105
|
-
reason: external_exports.string().max(200).optional()
|
|
69106
|
-
});
|
|
69107
|
-
var ComputerScreenshotCommit = external_exports.object({ sessionId: external_exports.string().min(1).max(256), sha256: ComputerScreenshotSha256 }).strict();
|
|
69108
|
-
var ComputerScreenshotCommitOk = external_exports.object({ stored: external_exports.boolean() });
|
|
69109
69308
|
|
|
69110
|
-
//
|
|
69111
|
-
|
|
69112
|
-
var
|
|
69113
|
-
var
|
|
69114
|
-
var
|
|
69115
|
-
var
|
|
69116
|
-
|
|
69117
|
-
|
|
69118
|
-
const
|
|
69119
|
-
|
|
69120
|
-
|
|
69121
|
-
|
|
69122
|
-
|
|
69123
|
-
|
|
69124
|
-
|
|
69309
|
+
// src/browser/close.ts
|
|
69310
|
+
var OP_QUERY_TREE = 15;
|
|
69311
|
+
var OP_INTERN_ATOM = 16;
|
|
69312
|
+
var OP_GET_PROPERTY = 20;
|
|
69313
|
+
var OP_SEND_EVENT = 25;
|
|
69314
|
+
var CLIENT_MESSAGE = 33;
|
|
69315
|
+
async function closeBrowser(options) {
|
|
69316
|
+
const log40 = options.log ?? (() => void 0);
|
|
69317
|
+
const pid = profileOwner(options.profile);
|
|
69318
|
+
if (pid === void 0) return "not-running";
|
|
69319
|
+
try {
|
|
69320
|
+
const x = await X11Connection.connect({
|
|
69321
|
+
display: options.display,
|
|
69322
|
+
...options.xauthority ? { xauthority: options.xauthority } : {}
|
|
69323
|
+
});
|
|
69324
|
+
try {
|
|
69325
|
+
const windows = await windowsOf(x, pid);
|
|
69326
|
+
const protocols = await internAtom(x, "WM_PROTOCOLS");
|
|
69327
|
+
const remove = await internAtom(x, "WM_DELETE_WINDOW");
|
|
69328
|
+
for (const window2 of windows) await sendClientMessage(x, window2, protocols, [remove, 0, 0, 0, 0]);
|
|
69329
|
+
log40(`asked ${windows.length} browser window(s) of ${options.profile} to close`);
|
|
69330
|
+
} finally {
|
|
69331
|
+
x.close();
|
|
69332
|
+
}
|
|
69333
|
+
} catch (error63) {
|
|
69334
|
+
log40(`could not ask the browser of ${options.profile} to close: ${error63.message}`);
|
|
69335
|
+
}
|
|
69336
|
+
if (await exited(pid, options.timeoutMs ?? 15e3)) return "closed";
|
|
69337
|
+
log40(`browser ${pid} did not exit after its windows closed; sending SIGTERM (unflushed cookies may be lost)`);
|
|
69338
|
+
process.kill(pid, "SIGTERM");
|
|
69339
|
+
if (await exited(pid, 5e3)) return "terminated";
|
|
69340
|
+
process.kill(pid, "SIGKILL");
|
|
69341
|
+
return "killed";
|
|
69125
69342
|
}
|
|
69126
|
-
function
|
|
69127
|
-
|
|
69128
|
-
|
|
69129
|
-
{
|
|
69130
|
-
|
|
69343
|
+
async function waitForWindowManager(display, timeoutMs) {
|
|
69344
|
+
const deadline = Date.now() + timeoutMs;
|
|
69345
|
+
while (Date.now() < deadline) {
|
|
69346
|
+
try {
|
|
69347
|
+
const x = await X11Connection.connect({ display });
|
|
69348
|
+
try {
|
|
69349
|
+
const check2 = await internAtom(x, "_NET_SUPPORTING_WM_CHECK");
|
|
69350
|
+
if (await cardinal(x, x.setup.root, check2, 33) !== void 0) return true;
|
|
69351
|
+
} finally {
|
|
69352
|
+
x.close();
|
|
69353
|
+
}
|
|
69354
|
+
} catch {
|
|
69355
|
+
}
|
|
69356
|
+
await new Promise((resolve5) => setTimeout(resolve5, 200));
|
|
69357
|
+
}
|
|
69358
|
+
return false;
|
|
69131
69359
|
}
|
|
69132
|
-
|
|
69133
|
-
|
|
69134
|
-
|
|
69135
|
-
|
|
69136
|
-
|
|
69137
|
-
|
|
69138
|
-
|
|
69139
|
-
|
|
69140
|
-
|
|
69141
|
-
|
|
69142
|
-
|
|
69143
|
-
headers: Headers2,
|
|
69144
|
-
body: Base64.optional()
|
|
69145
|
-
});
|
|
69146
|
-
var CrHttpResponse = external_exports.object({
|
|
69147
|
-
status: external_exports.number().int().min(100).max(599),
|
|
69148
|
-
headers: Headers2,
|
|
69149
|
-
body: Base64.optional()
|
|
69150
|
-
});
|
|
69151
|
-
var RELAY_COMPUTER_SCHEMAS = {
|
|
69152
|
-
"cr/hello": CrHello,
|
|
69153
|
-
"cr/hello/ok": CrHelloOk,
|
|
69154
|
-
"cr/http": CrHttpRequest,
|
|
69155
|
-
"cr/http/result": CrHttpResponse,
|
|
69156
|
-
error: ErrorFrame
|
|
69157
|
-
};
|
|
69158
|
-
var RelayComputerFrame = external_exports.discriminatedUnion("type", [
|
|
69159
|
-
frameSchema("cr/hello", RELAY_COMPUTER_SCHEMAS["cr/hello"]),
|
|
69160
|
-
frameSchema("cr/hello/ok", RELAY_COMPUTER_SCHEMAS["cr/hello/ok"]),
|
|
69161
|
-
frameSchema("cr/http", RELAY_COMPUTER_SCHEMAS["cr/http"]),
|
|
69162
|
-
frameSchema("cr/http/result", RELAY_COMPUTER_SCHEMAS["cr/http/result"]),
|
|
69163
|
-
frameSchema("error", RELAY_COMPUTER_SCHEMAS["error"])
|
|
69164
|
-
]);
|
|
69165
|
-
function decodeRelayComputerFrame(text) {
|
|
69166
|
-
return decodeEnvelopeWith(RELAY_COMPUTER_SCHEMAS, text, {
|
|
69167
|
-
maxBytes: RELAY_COMPUTER_MAX_FRAME_BYTES
|
|
69168
|
-
});
|
|
69360
|
+
async function exited(pid, timeoutMs) {
|
|
69361
|
+
const deadline = Date.now() + timeoutMs;
|
|
69362
|
+
for (; ; ) {
|
|
69363
|
+
try {
|
|
69364
|
+
process.kill(pid, 0);
|
|
69365
|
+
} catch {
|
|
69366
|
+
return true;
|
|
69367
|
+
}
|
|
69368
|
+
if (Date.now() > deadline) return false;
|
|
69369
|
+
await new Promise((resolve5) => setTimeout(resolve5, 200));
|
|
69370
|
+
}
|
|
69169
69371
|
}
|
|
69170
|
-
function
|
|
69171
|
-
|
|
69372
|
+
async function windowsOf(x, pid) {
|
|
69373
|
+
const pidAtom = await internAtom(x, "_NET_WM_PID");
|
|
69374
|
+
const found = [];
|
|
69375
|
+
for (const frame of await queryTree(x, x.setup.root)) {
|
|
69376
|
+
for (const window2 of [frame, ...await queryTree(x, frame)]) {
|
|
69377
|
+
const value = await cardinal(x, window2, pidAtom);
|
|
69378
|
+
if (value === pid) found.push(window2);
|
|
69379
|
+
}
|
|
69380
|
+
}
|
|
69381
|
+
return found;
|
|
69172
69382
|
}
|
|
69173
|
-
|
|
69174
|
-
|
|
69175
|
-
|
|
69176
|
-
|
|
69177
|
-
|
|
69178
|
-
|
|
69179
|
-
control: "ctrl",
|
|
69180
|
-
option: "alt"
|
|
69181
|
-
};
|
|
69182
|
-
function normalizeComputerKey(key) {
|
|
69183
|
-
const lowered = key.trim().toLowerCase();
|
|
69184
|
-
return COMPUTER_KEY_ALIASES[lowered] ?? lowered;
|
|
69383
|
+
async function internAtom(x, name) {
|
|
69384
|
+
const bytes = Buffer.from(name, "latin1");
|
|
69385
|
+
const body = Buffer.alloc(4 + bytes.length);
|
|
69386
|
+
body.writeUInt16LE(bytes.length, 0);
|
|
69387
|
+
bytes.copy(body, 4);
|
|
69388
|
+
return (await x.request(request(OP_INTERN_ATOM, 0, body))).readUInt32LE(8);
|
|
69185
69389
|
}
|
|
69186
|
-
|
|
69187
|
-
|
|
69188
|
-
|
|
69189
|
-
|
|
69190
|
-
|
|
69191
|
-
|
|
69192
|
-
|
|
69193
|
-
var HHMM = "(?:[01]\\d|2[0-3]):[0-5]\\d";
|
|
69194
|
-
var QUIET_RANGE_RE = new RegExp(`^${HHMM}-${HHMM}$`);
|
|
69195
|
-
function isTimeZone(tz) {
|
|
69196
|
-
try {
|
|
69197
|
-
new Intl.DateTimeFormat("en-US", { timeZone: tz });
|
|
69198
|
-
return true;
|
|
69199
|
-
} catch {
|
|
69200
|
-
return false;
|
|
69201
|
-
}
|
|
69390
|
+
async function queryTree(x, window2) {
|
|
69391
|
+
const body = Buffer.alloc(4);
|
|
69392
|
+
body.writeUInt32LE(window2, 0);
|
|
69393
|
+
const reply2 = await x.request(request(OP_QUERY_TREE, 0, body)).catch(() => void 0);
|
|
69394
|
+
if (!reply2) return [];
|
|
69395
|
+
const count = reply2.readUInt16LE(16);
|
|
69396
|
+
return Array.from({ length: count }, (_, i) => reply2.readUInt32LE(32 + i * 4));
|
|
69202
69397
|
}
|
|
69203
|
-
|
|
69204
|
-
|
|
69205
|
-
|
|
69206
|
-
|
|
69207
|
-
|
|
69208
|
-
|
|
69209
|
-
|
|
69210
|
-
|
|
69211
|
-
|
|
69212
|
-
|
|
69213
|
-
approvals: ComputerApprovalsSchema.default({ firstInputPerSession: true }),
|
|
69214
|
-
appAllowlist: external_exports.array(AppId).max(200).optional(),
|
|
69215
|
-
redactApps: external_exports.array(AppId).max(200).default([]),
|
|
69216
|
-
exposeDriverTools: external_exports.boolean().default(false),
|
|
69217
|
-
quietHours: external_exports.object({
|
|
69218
|
-
tz: external_exports.string().min(1).max(64).refine(isTimeZone, "unknown IANA time zone"),
|
|
69219
|
-
ranges: external_exports.array(external_exports.string().regex(QUIET_RANGE_RE, "expected HH:MM-HH:MM")).min(1).max(24)
|
|
69220
|
-
}).optional(),
|
|
69221
|
-
leaseIdleSeconds: external_exports.number().int().min(10).max(3600).default(120),
|
|
69222
|
-
leaseMaxSeconds: external_exports.number().int().min(60).max(86400).default(1800),
|
|
69223
|
-
// Seconds an acquire waits in the FIFO lease queue before `computer_busy` (§4.4); 0 never waits.
|
|
69224
|
-
leaseWaitSeconds: external_exports.number().int().min(0).max(COMPUTER_LEASE_WAIT_MAX_SECONDS).default(45),
|
|
69225
|
-
// Days stored screenshots are kept (§9); 0 means never written, absent means the deployment's default.
|
|
69226
|
-
screenshotRetentionDays: external_exports.number().int().min(0).max(COMPUTER_SCREENSHOT_RETENTION_MAX_DAYS).optional(),
|
|
69227
|
-
// Whether viewers may hole-punch peer to peer, which shows them the desktop's public IP (§7.2); absent means on only for owner-only viewing.
|
|
69228
|
-
viewerPeerToPeer: external_exports.boolean().optional(),
|
|
69229
|
-
// The command-line tier (§5.7); absent means the Computer's default, on for a managed one and off otherwise.
|
|
69230
|
-
shell: external_exports.enum(COMPUTER_SHELL_MODES).optional(),
|
|
69231
|
-
files: external_exports.enum(COMPUTER_FILES_MODES).optional(),
|
|
69232
|
-
// Prefixes the file tools may touch; absent means the user's home directory.
|
|
69233
|
-
fileRoots: external_exports.array(ComputerFileRoot).max(COMPUTER_FILE_ROOTS_MAX).optional()
|
|
69234
|
-
}).refine((p) => p.leaseIdleSeconds <= p.leaseMaxSeconds, {
|
|
69235
|
-
message: "leaseIdleSeconds must not exceed leaseMaxSeconds",
|
|
69236
|
-
path: ["leaseIdleSeconds"]
|
|
69237
|
-
}).refine((p) => p.agentMode === "control" || p.shell === void 0 || p.shell === "off", {
|
|
69238
|
-
message: "a shell needs agentMode control",
|
|
69239
|
-
path: ["shell"]
|
|
69240
|
-
});
|
|
69241
|
-
var ComputerCapabilitiesSchema = external_exports.object({
|
|
69242
|
-
screenshot: external_exports.boolean().default(false),
|
|
69243
|
-
input: external_exports.boolean().default(false),
|
|
69244
|
-
textInput: external_exports.enum(["full", "keymap-only"]).default("full"),
|
|
69245
|
-
// Which human input pauses agents (§6); absent reads as pointer only, what older desktops detect.
|
|
69246
|
-
humanActivity: external_exports.enum(["pointer", "pointer+keyboard"]).optional(),
|
|
69247
|
-
backgroundInput: external_exports.boolean().default(false),
|
|
69248
|
-
accessibilityTree: external_exports.boolean().default(false),
|
|
69249
|
-
viewer: external_exports.boolean().default(false),
|
|
69250
|
-
// The viewer accepts a view token's `stun` claim; desktops before relay STUN refuse such a token.
|
|
69251
|
-
viewerStun: external_exports.boolean().optional(),
|
|
69252
|
-
// The browser's traffic leaves through the desktop's egress forwarder, which applies `computer/egress` (§15.4).
|
|
69253
|
-
egress: external_exports.boolean().optional(),
|
|
69254
|
-
// The command-line tier can run here (§5.7): computer_exec, and the file tools.
|
|
69255
|
-
exec: external_exports.boolean().optional(),
|
|
69256
|
-
files: external_exports.boolean().optional(),
|
|
69257
|
-
displays: external_exports.array(
|
|
69258
|
-
external_exports.object({
|
|
69259
|
-
id: external_exports.string().min(1).max(128),
|
|
69260
|
-
width: external_exports.number().int().positive().max(1e5),
|
|
69261
|
-
height: external_exports.number().int().positive().max(1e5),
|
|
69262
|
-
scale: external_exports.number().positive().max(16)
|
|
69263
|
-
})
|
|
69264
|
-
).max(16).default([]),
|
|
69265
|
-
permissions: external_exports.object({
|
|
69266
|
-
accessibility: external_exports.boolean().optional(),
|
|
69267
|
-
screenRecording: external_exports.boolean().optional(),
|
|
69268
|
-
portal: external_exports.boolean().optional(),
|
|
69269
|
-
firewall: external_exports.boolean().optional()
|
|
69270
|
-
}).default({})
|
|
69271
|
-
});
|
|
69272
|
-
var ComputerDoctorCheck = external_exports.object({
|
|
69273
|
-
name: external_exports.string().min(1).max(64),
|
|
69274
|
-
status: external_exports.enum(["ok", "info", "warn", "fail"]),
|
|
69275
|
-
detail: external_exports.string().max(1e3),
|
|
69276
|
-
fix: external_exports.string().max(1e3).optional()
|
|
69277
|
-
});
|
|
69278
|
-
var ComputerDoctorReport = external_exports.object({
|
|
69279
|
-
checkedAt: external_exports.string().datetime(),
|
|
69280
|
-
checks: external_exports.array(ComputerDoctorCheck).max(64)
|
|
69281
|
-
});
|
|
69282
|
-
var ComputerChannelCredential = external_exports.object({
|
|
69283
|
-
keyId: external_exports.string().min(1).max(64),
|
|
69284
|
-
// 32 random-looking bytes, base64url without padding; secret material, never logged.
|
|
69285
|
-
key: external_exports.string().regex(/^[A-Za-z0-9_-]{43}$/),
|
|
69286
|
-
issuedAt: external_exports.string().datetime(),
|
|
69287
|
-
expiresAt: external_exports.string().datetime()
|
|
69288
|
-
});
|
|
69289
|
-
var ComputerEgressProxyUrl = external_exports.string().max(512).refine((raw) => {
|
|
69290
|
-
try {
|
|
69291
|
-
const u = new URL(raw);
|
|
69292
|
-
return (u.protocol === "http:" || u.protocol === "https:") && u.hostname !== "" && u.username === "" && u.password === "" && (u.pathname === "" || u.pathname === "/") && u.search === "" && u.hash === "";
|
|
69293
|
-
} catch {
|
|
69294
|
-
return false;
|
|
69295
|
-
}
|
|
69296
|
-
}, "expected http://host:port or https://host:port without credentials or a path");
|
|
69297
|
-
var ComputerEgress = external_exports.discriminatedUnion("mode", [
|
|
69298
|
-
external_exports.object({ mode: external_exports.literal("direct") }),
|
|
69299
|
-
external_exports.object({
|
|
69300
|
-
mode: external_exports.literal("proxy"),
|
|
69301
|
-
url: ComputerEgressProxyUrl,
|
|
69302
|
-
username: external_exports.string().min(1).max(256).optional(),
|
|
69303
|
-
password: external_exports.string().min(1).max(512).optional()
|
|
69304
|
-
})
|
|
69305
|
-
]);
|
|
69306
|
-
var COMPUTER_EGRESS_FEATURE = "computer-egress-v1";
|
|
69307
|
-
var ComputerAuth = external_exports.object({
|
|
69308
|
-
apiKey: external_exports.string().min(1).max(256),
|
|
69309
|
-
desktopDaemonVersion: external_exports.string().trim().min(1).max(64)
|
|
69310
|
-
}).strict();
|
|
69311
|
-
var ComputerAuthOk = external_exports.object({
|
|
69312
|
-
computerId: external_exports.string().uuid(),
|
|
69313
|
-
orgId: external_exports.string().min(1).max(64),
|
|
69314
|
-
name: external_exports.string().min(1).max(200),
|
|
69315
|
-
heartbeatSec: external_exports.number().int().positive(),
|
|
69316
|
-
serverTime: external_exports.string().datetime(),
|
|
69317
|
-
credential: ComputerChannelCredential,
|
|
69318
|
-
policy: ComputerPolicySchema,
|
|
69319
|
-
// What this CP accepts on the channel beyond the base frames, such as `computer-audit-v1`.
|
|
69320
|
-
features: external_exports.array(external_exports.string().min(1).max(64)).max(32).optional(),
|
|
69321
|
-
// The retention in effect for this Computer's screenshots (§9); 0 or absent means none are stored.
|
|
69322
|
-
screenshotRetentionDays: external_exports.number().int().min(0).max(COMPUTER_SCREENSHOT_RETENTION_MAX_DAYS).optional(),
|
|
69323
|
-
// A managed desktop's egress (§15.4); absent means direct unless `computer-egress-v1` is advertised. Secret, never logged.
|
|
69324
|
-
egress: ComputerEgress.optional()
|
|
69325
|
-
});
|
|
69326
|
-
var ComputerHeartbeat = external_exports.object({
|
|
69327
|
-
status: external_exports.enum(COMPUTER_LIVE_STATUSES),
|
|
69328
|
-
osVersion: external_exports.string().trim().min(1).max(120).optional(),
|
|
69329
|
-
session: external_exports.enum(COMPUTER_SESSIONS).optional(),
|
|
69330
|
-
desktopDaemonVersion: external_exports.string().trim().min(1).max(64).optional(),
|
|
69331
|
-
driverVersion: external_exports.string().trim().min(1).max(64).optional(),
|
|
69332
|
-
capabilities: ComputerCapabilitiesSchema.optional(),
|
|
69333
|
-
doctor: ComputerDoctorReport.optional(),
|
|
69334
|
-
// The local lease, how long since its last input, and how long it has been held without idling out.
|
|
69335
|
-
lease: external_exports.object({
|
|
69336
|
-
holder: external_exports.string().min(1).max(512),
|
|
69337
|
-
idleMs: external_exports.number().int().min(0),
|
|
69338
|
-
heldMs: external_exports.number().int().min(0).optional()
|
|
69339
|
-
}).strict().optional()
|
|
69340
|
-
}).strict();
|
|
69341
|
-
var ComputerCredentialRenewal = external_exports.object({ credential: ComputerChannelCredential });
|
|
69342
|
-
var ComputerPolicyPush = external_exports.object({
|
|
69343
|
-
policy: ComputerPolicySchema,
|
|
69344
|
-
screenshotRetentionDays: external_exports.number().int().min(0).max(COMPUTER_SCREENSHOT_RETENTION_MAX_DAYS).optional()
|
|
69345
|
-
});
|
|
69346
|
-
var ComputerRevoke = external_exports.object({
|
|
69347
|
-
reason: external_exports.enum(["revoked", "deleted", "owner_removed"]),
|
|
69348
|
-
message: external_exports.string().max(500).optional()
|
|
69349
|
-
});
|
|
69350
|
-
var ComputerLeasePush = external_exports.object({ lease: ComputerControlLease.nullable() });
|
|
69351
|
-
var ComputerRelaysPush = external_exports.object({ relays: external_exports.array(ComputerRelayEntry).max(COMPUTER_RELAYS_MAX) });
|
|
69352
|
-
var ComputerStopPush = external_exports.object({ stop: external_exports.object({ at: external_exports.string().datetime() }).nullable() });
|
|
69353
|
-
var ComputerEgressPush = external_exports.object({ egress: ComputerEgress });
|
|
69354
|
-
var COMPUTER_ADMIN_PROMPTS_FEATURE = "computer-admin-prompts-v1";
|
|
69355
|
-
var ComputerAdminPromptsSet = external_exports.object({ mode: external_exports.enum(COMPUTER_ADMIN_PROMPT_MODES) }).strict();
|
|
69356
|
-
var ComputerAdminPromptsSetOk = external_exports.object({ mode: external_exports.enum(COMPUTER_ADMIN_PROMPT_MODES) });
|
|
69357
|
-
var COMPUTER_CP_SCHEMAS = {
|
|
69358
|
-
"computer/auth": ComputerAuth,
|
|
69359
|
-
"computer/auth/ok": ComputerAuthOk,
|
|
69360
|
-
"computer/heartbeat": ComputerHeartbeat,
|
|
69361
|
-
"computer/credential": ComputerCredentialRenewal,
|
|
69362
|
-
"computer/policy": ComputerPolicyPush,
|
|
69363
|
-
"computer/revoke": ComputerRevoke,
|
|
69364
|
-
"computer/lease": ComputerLeasePush,
|
|
69365
|
-
"computer/relays": ComputerRelaysPush,
|
|
69366
|
-
"computer/stop": ComputerStopPush,
|
|
69367
|
-
"computer/egress": ComputerEgressPush,
|
|
69368
|
-
"computer/admin-prompts": ComputerAdminPromptsSet,
|
|
69369
|
-
"computer/admin-prompts/ok": ComputerAdminPromptsSetOk,
|
|
69370
|
-
"computer/audit": ComputerAuditReport,
|
|
69371
|
-
"computer/audit/ok": ComputerAuditAck,
|
|
69372
|
-
"computer/screenshot/put": ComputerScreenshotPut,
|
|
69373
|
-
"computer/screenshot/put/ok": ComputerScreenshotPutOk,
|
|
69374
|
-
"computer/screenshot/commit": ComputerScreenshotCommit,
|
|
69375
|
-
"computer/screenshot/commit/ok": ComputerScreenshotCommitOk,
|
|
69376
|
-
error: ErrorFrame
|
|
69377
|
-
};
|
|
69378
|
-
var COMPUTER_CP_FRAME_TYPES = Object.keys(COMPUTER_CP_SCHEMAS);
|
|
69379
|
-
var ComputerCpFrame = external_exports.discriminatedUnion("type", [
|
|
69380
|
-
frameSchema("computer/auth", COMPUTER_CP_SCHEMAS["computer/auth"]),
|
|
69381
|
-
frameSchema("computer/auth/ok", COMPUTER_CP_SCHEMAS["computer/auth/ok"]),
|
|
69382
|
-
frameSchema("computer/heartbeat", COMPUTER_CP_SCHEMAS["computer/heartbeat"]),
|
|
69383
|
-
frameSchema("computer/credential", COMPUTER_CP_SCHEMAS["computer/credential"]),
|
|
69384
|
-
frameSchema("computer/policy", COMPUTER_CP_SCHEMAS["computer/policy"]),
|
|
69385
|
-
frameSchema("computer/revoke", COMPUTER_CP_SCHEMAS["computer/revoke"]),
|
|
69386
|
-
frameSchema("computer/lease", COMPUTER_CP_SCHEMAS["computer/lease"]),
|
|
69387
|
-
frameSchema("computer/relays", COMPUTER_CP_SCHEMAS["computer/relays"]),
|
|
69388
|
-
frameSchema("computer/stop", COMPUTER_CP_SCHEMAS["computer/stop"]),
|
|
69389
|
-
frameSchema("computer/egress", COMPUTER_CP_SCHEMAS["computer/egress"]),
|
|
69390
|
-
frameSchema("computer/admin-prompts", COMPUTER_CP_SCHEMAS["computer/admin-prompts"]),
|
|
69391
|
-
frameSchema("computer/admin-prompts/ok", COMPUTER_CP_SCHEMAS["computer/admin-prompts/ok"]),
|
|
69392
|
-
frameSchema("computer/audit", COMPUTER_CP_SCHEMAS["computer/audit"]),
|
|
69393
|
-
frameSchema("computer/audit/ok", COMPUTER_CP_SCHEMAS["computer/audit/ok"]),
|
|
69394
|
-
frameSchema("computer/screenshot/put", COMPUTER_CP_SCHEMAS["computer/screenshot/put"]),
|
|
69395
|
-
frameSchema("computer/screenshot/put/ok", COMPUTER_CP_SCHEMAS["computer/screenshot/put/ok"]),
|
|
69396
|
-
frameSchema("computer/screenshot/commit", COMPUTER_CP_SCHEMAS["computer/screenshot/commit"]),
|
|
69397
|
-
frameSchema("computer/screenshot/commit/ok", COMPUTER_CP_SCHEMAS["computer/screenshot/commit/ok"]),
|
|
69398
|
-
frameSchema("error", COMPUTER_CP_SCHEMAS["error"])
|
|
69399
|
-
]);
|
|
69400
|
-
var TOLERANT_COMPUTER_CP_SCHEMAS = tolerantSchemas(COMPUTER_CP_SCHEMAS);
|
|
69401
|
-
function decodeComputerCpFrameTolerant(text) {
|
|
69402
|
-
return decodeEnvelopeWith(TOLERANT_COMPUTER_CP_SCHEMAS, text);
|
|
69398
|
+
async function cardinal(x, window2, property, type = 0) {
|
|
69399
|
+
const body = Buffer.alloc(20);
|
|
69400
|
+
body.writeUInt32LE(window2, 0);
|
|
69401
|
+
body.writeUInt32LE(property, 4);
|
|
69402
|
+
body.writeUInt32LE(type, 8);
|
|
69403
|
+
body.writeUInt32LE(0, 12);
|
|
69404
|
+
body.writeUInt32LE(1, 16);
|
|
69405
|
+
const reply2 = await x.request(request(OP_GET_PROPERTY, 0, body)).catch(() => void 0);
|
|
69406
|
+
if (!reply2 || reply2[1] !== 32 || reply2.readUInt32LE(16) < 1) return void 0;
|
|
69407
|
+
return reply2.readUInt32LE(32);
|
|
69403
69408
|
}
|
|
69404
|
-
function
|
|
69405
|
-
|
|
69409
|
+
async function sendClientMessage(x, window2, type, data) {
|
|
69410
|
+
const event = Buffer.alloc(32);
|
|
69411
|
+
event[0] = CLIENT_MESSAGE;
|
|
69412
|
+
event[1] = 32;
|
|
69413
|
+
event.writeUInt32LE(window2, 4);
|
|
69414
|
+
event.writeUInt32LE(type, 8);
|
|
69415
|
+
data.forEach((value, i) => event.writeUInt32LE(value >>> 0, 12 + i * 4));
|
|
69416
|
+
const body = Buffer.alloc(40);
|
|
69417
|
+
body.writeUInt32LE(window2, 0);
|
|
69418
|
+
body.writeUInt32LE(0, 4);
|
|
69419
|
+
event.copy(body, 8);
|
|
69420
|
+
await x.checked(request(OP_SEND_EVENT, 0, body));
|
|
69406
69421
|
}
|
|
69407
69422
|
|
|
69423
|
+
// src/linux/desktops.ts
|
|
69424
|
+
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
69425
|
+
import { spawn as spawn5, spawnSync } from "node:child_process";
|
|
69426
|
+
import { chmodSync, existsSync as existsSync4, mkdirSync as mkdirSync4, readFileSync as readFileSync4, writeFileSync as writeFileSync3 } from "node:fs";
|
|
69427
|
+
import { homedir as homedir2 } from "node:os";
|
|
69428
|
+
import { join as join6 } from "node:path";
|
|
69429
|
+
|
|
69430
|
+
// src/computer.ts
|
|
69431
|
+
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
69432
|
+
import { hostname as hostname5, release } from "node:os";
|
|
69433
|
+
|
|
69408
69434
|
// src/driver/client.ts
|
|
69409
69435
|
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
69410
69436
|
|
|
@@ -70537,8 +70563,8 @@ var memo$12;
|
|
|
70537
70563
|
function buildSchemas20252() {
|
|
70538
70564
|
return memo$12 ??= build$12();
|
|
70539
70565
|
}
|
|
70540
|
-
function isNonObjectJsonSchemaRoot2(
|
|
70541
|
-
return
|
|
70566
|
+
function isNonObjectJsonSchemaRoot2(json5) {
|
|
70567
|
+
return json5["type"] !== "object";
|
|
70542
70568
|
}
|
|
70543
70569
|
var REF_REWRITE_DATA_POSITION_KEYS2 = /* @__PURE__ */ new Set([
|
|
70544
70570
|
"const",
|
|
@@ -82090,14 +82116,14 @@ var ClientResponseCache = class {
|
|
|
82090
82116
|
}
|
|
82091
82117
|
};
|
|
82092
82118
|
function encodeCacheValue(value) {
|
|
82093
|
-
let
|
|
82119
|
+
let json5;
|
|
82094
82120
|
try {
|
|
82095
|
-
|
|
82121
|
+
json5 = JSON.stringify(value);
|
|
82096
82122
|
} catch (error63) {
|
|
82097
82123
|
throw new TypeError(`cache value is not JSON-serializable: ${error63 instanceof Error ? error63.message : String(error63)}`);
|
|
82098
82124
|
}
|
|
82099
|
-
if (typeof
|
|
82100
|
-
return
|
|
82125
|
+
if (typeof json5 !== "string") throw new TypeError("cache value is not JSON-serializable: it has no JSON representation");
|
|
82126
|
+
return json5;
|
|
82101
82127
|
}
|
|
82102
82128
|
var AUTH_SEAM = /* @__PURE__ */ Symbol.for("mcp.authSeamEscape");
|
|
82103
82129
|
function isAuthSeamEscape(error63) {
|
|
@@ -84227,8 +84253,8 @@ var StdioClientTransport = class {
|
|
|
84227
84253
|
send(message) {
|
|
84228
84254
|
return new Promise((resolve5) => {
|
|
84229
84255
|
if (!this._process?.stdin) throw new SdkError2(SdkErrorCode2.NotConnected, "Not connected");
|
|
84230
|
-
const
|
|
84231
|
-
if (this._process.stdin.write(
|
|
84256
|
+
const json5 = serializeMessage2(message);
|
|
84257
|
+
if (this._process.stdin.write(json5)) resolve5();
|
|
84232
84258
|
else this._process.stdin.once("drain", resolve5);
|
|
84233
84259
|
});
|
|
84234
84260
|
}
|
|
@@ -85390,10 +85416,11 @@ function desktopBrowserPlan(dataDir2, id) {
|
|
|
85390
85416
|
const state = loadDesktopState(dataDir2);
|
|
85391
85417
|
const ids = Object.values(state.desktops).map((record2) => record2.id);
|
|
85392
85418
|
if (!ids.includes(id)) throw new Error(`no desktop ${id}`);
|
|
85419
|
+
const share = state.shareBrowserLogins !== false;
|
|
85393
85420
|
return {
|
|
85394
85421
|
profile: desktopProfile(dataDir2, id),
|
|
85395
|
-
master: state.master,
|
|
85396
|
-
sources: [state.master, ...ids.filter((other) => other !== id).map((other) => desktopProfile(dataDir2, other))],
|
|
85422
|
+
...share ? { master: state.master } : {},
|
|
85423
|
+
sources: share ? [state.master, ...ids.filter((other) => other !== id).map((other) => desktopProfile(dataDir2, other))] : [],
|
|
85397
85424
|
skip: ids.map((other) => wrapperDir(dataDir2, other)),
|
|
85398
85425
|
...state.mainBus ? { mainBus: state.mainBus } : {}
|
|
85399
85426
|
};
|
|
@@ -85451,6 +85478,13 @@ var DesktopManager = class {
|
|
|
85451
85478
|
closed = false;
|
|
85452
85479
|
// The owner's pause, applied to every desktop, including ones started while it stands.
|
|
85453
85480
|
paused;
|
|
85481
|
+
/** The registrant's `shareBrowserLogins` (§3.9), kept with the state the browser wrappers read. */
|
|
85482
|
+
setShareBrowserLogins(on) {
|
|
85483
|
+
if (this.state.shareBrowserLogins !== false === on) return;
|
|
85484
|
+
this.state.shareBrowserLogins = on;
|
|
85485
|
+
saveDesktopState(this.deps.dataDir, this.state);
|
|
85486
|
+
this.deps.log(`per-agent desktops: browser logins ${on ? "shared between desktops" : "kept apart per desktop"}`);
|
|
85487
|
+
}
|
|
85454
85488
|
/** On when the owner's switch is on and the machine supports it. */
|
|
85455
85489
|
enabled() {
|
|
85456
85490
|
return this.deps.config.perAgentDesktops && this.deps.support().supported;
|
|
@@ -85577,6 +85611,7 @@ var DesktopManager = class {
|
|
|
85577
85611
|
XFCE_SHELL.forEach(run4);
|
|
85578
85612
|
const { driver, computer } = this.deps.build({
|
|
85579
85613
|
id: record2.id,
|
|
85614
|
+
key: record2.key,
|
|
85580
85615
|
label: record2.label,
|
|
85581
85616
|
env,
|
|
85582
85617
|
launchBrowser: (app) => isBrowserName(app) ? async () => {
|
|
@@ -85619,7 +85654,7 @@ var DesktopManager = class {
|
|
|
85619
85654
|
// At the limit, the least recently used desktop nobody holds makes room; a full machine has no holder or queue (§4.4).
|
|
85620
85655
|
async makeRoom() {
|
|
85621
85656
|
if (this.running.size < this.max()) return;
|
|
85622
|
-
const idle = [...this.running.values()].filter((desktop) => !desktop
|
|
85657
|
+
const idle = [...this.running.values()].filter((desktop) => !inUse(desktop)).sort((a, b) => a.lastActivity - b.lastActivity)[0];
|
|
85623
85658
|
if (!idle) {
|
|
85624
85659
|
throw new ComputerError("unavailable", `all ${this.max()} desktops of this computer are in use`, {
|
|
85625
85660
|
reason: "desktops_full"
|
|
@@ -85659,7 +85694,7 @@ var DesktopManager = class {
|
|
|
85659
85694
|
const now = this.now();
|
|
85660
85695
|
for (const desktop of [...this.running.values()]) {
|
|
85661
85696
|
if (desktop.stopping) continue;
|
|
85662
|
-
if (desktop
|
|
85697
|
+
if (inUse(desktop)) desktop.lastActivity = now;
|
|
85663
85698
|
const idle = now - desktop.lastActivity;
|
|
85664
85699
|
if (idle > this.deps.config.desktopIdleMinutes * 6e4) {
|
|
85665
85700
|
await this.stop(desktop.record.id, `idle for ${this.deps.config.desktopIdleMinutes} min`);
|
|
@@ -85673,6 +85708,7 @@ var DesktopManager = class {
|
|
|
85673
85708
|
}
|
|
85674
85709
|
}
|
|
85675
85710
|
};
|
|
85711
|
+
var inUse = (desktop) => desktop.computer.leaseActivity() !== void 0 || desktop.computer.liveStatus() === "human_in_control";
|
|
85676
85712
|
var MAIN_SESSION_VARS = /^(WAYLAND_DISPLAY|DBUS_SESSION_BUS_ADDRESS|SESSION_MANAGER|DESKTOP_STARTUP_ID|XDG_ACTIVATION_TOKEN|DESKTOP_SESSION|GDMSESSION|XDG_SESSION_(DESKTOP|ID|CLASS)|XDG_SEAT|XDG_VTNR|XDG_MENU_PREFIX|XMODIFIERS|(GTK|QT|CLUTTER|SDL)_IM_MODULE|IM_CONFIG_\w+|GNOME_\w+|KDE_\w+|PLASMA_\w+|GIO_LAUNCHED_DESKTOP_FILE\w*|XAUTHORITY)$/;
|
|
85677
85713
|
function desktopEnv(base) {
|
|
85678
85714
|
const env = {};
|
|
@@ -85748,7 +85784,7 @@ async function desktopBrowser(id, args, log40, dataDir2) {
|
|
|
85748
85784
|
if (plan.mainBus) env.DBUS_SESSION_BUS_ADDRESS = plan.mainBus;
|
|
85749
85785
|
const result = await launchBrowser({
|
|
85750
85786
|
profile: plan.profile,
|
|
85751
|
-
master: plan.master,
|
|
85787
|
+
...plan.master ? { master: plan.master } : {},
|
|
85752
85788
|
sources: plan.sources,
|
|
85753
85789
|
browser,
|
|
85754
85790
|
// The desktop's tabs come back after its browser was closed for idleness (computer-use.md §3.10).
|
|
@@ -86263,7 +86299,8 @@ function auditEntry(record2, at, id = randomUUID2()) {
|
|
|
86263
86299
|
args: summary.args,
|
|
86264
86300
|
...summary.textLength !== void 0 ? { textLength: summary.textLength } : {},
|
|
86265
86301
|
ms: Math.max(0, Math.round(record2.ms)),
|
|
86266
|
-
...record2.screenshotRef ? { screenshotRef: record2.screenshotRef } : {}
|
|
86302
|
+
...record2.screenshotRef ? { screenshotRef: record2.screenshotRef } : {},
|
|
86303
|
+
...record2.desktop ? { desktop: record2.desktop } : {}
|
|
86267
86304
|
};
|
|
86268
86305
|
}
|
|
86269
86306
|
var AuditReporter = class {
|
|
@@ -90294,7 +90331,7 @@ var serviceEntry = () => managedEntry() ?? resolve3(process.argv[1]);
|
|
|
90294
90331
|
|
|
90295
90332
|
// src/version.ts
|
|
90296
90333
|
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
90297
|
-
var COMPUTER_DAEMON_VERSION = true ? "2.12.0-rc.
|
|
90334
|
+
var COMPUTER_DAEMON_VERSION = true ? "2.12.0-rc.15" : JSON.parse(readFileSync(new URL("../package.json", import.meta.url), "utf8")).version;
|
|
90298
90335
|
|
|
90299
90336
|
// src/http-server.ts
|
|
90300
90337
|
var CONTROL_HEADER = "x-agentconnect-computer";
|
|
@@ -90616,8 +90653,17 @@ async function downloadFfmpeg(dataDir2, target, log40) {
|
|
|
90616
90653
|
log40(`Installed ffmpeg ${build3.version} at ${target}`);
|
|
90617
90654
|
return target;
|
|
90618
90655
|
}
|
|
90619
|
-
function captureInputs(fps, dataDir2, frames = 0, cursor = true) {
|
|
90656
|
+
function captureInputs(fps, dataDir2, frames = 0, cursor = true, display) {
|
|
90620
90657
|
const mouse = cursor ? "1" : "0";
|
|
90658
|
+
if (display) {
|
|
90659
|
+
return [
|
|
90660
|
+
{
|
|
90661
|
+
name: "x11grab",
|
|
90662
|
+
args: ["-f", "x11grab", "-draw_mouse", mouse, "-framerate", String(fps), "-i", display],
|
|
90663
|
+
filters: []
|
|
90664
|
+
}
|
|
90665
|
+
];
|
|
90666
|
+
}
|
|
90621
90667
|
const override = process.env.AGENTCONNECT_COMPUTER_CAPTURE;
|
|
90622
90668
|
if (override) return [{ name: "override", args: override.split(" ").filter(Boolean), filters: [] }];
|
|
90623
90669
|
if (process.platform === "win32") {
|
|
@@ -113408,7 +113454,7 @@ var ScreenStream = class {
|
|
|
113408
113454
|
spawn() {
|
|
113409
113455
|
if (!this.running || !this.socket) return;
|
|
113410
113456
|
this.cursor = this.options.cursor?.() ?? true;
|
|
113411
|
-
const inputs = captureInputs(this.options.fps, this.options.dataDir, 0, this.cursor);
|
|
113457
|
+
const inputs = captureInputs(this.options.fps, this.options.dataDir, 0, this.cursor, this.options.display);
|
|
113412
113458
|
const input2 = inputs[Math.min(this.inputIndex, inputs.length - 1)];
|
|
113413
113459
|
const args = [
|
|
113414
113460
|
"-hide_banner",
|
|
@@ -113873,7 +113919,7 @@ var VIEWER_PAGE = `<!doctype html>
|
|
|
113873
113919
|
body { margin: 0; background: #111; color: #ddd; display: flex; flex-direction: column; height: 100vh; }
|
|
113874
113920
|
header { display: flex; gap: 8px; align-items: center; padding: 6px 10px; background: #1c1c1c; border-bottom: 1px solid #333; flex-wrap: wrap; }
|
|
113875
113921
|
header .grow { flex: 1; }
|
|
113876
|
-
button, input { font: inherit; color: inherit; background: #2a2a2a; border: 1px solid #444; border-radius: 4px; padding: 4px 10px; }
|
|
113922
|
+
button, input, select { font: inherit; color: inherit; background: #2a2a2a; border: 1px solid #444; border-radius: 4px; padding: 4px 10px; }
|
|
113877
113923
|
button:hover { background: #333; }
|
|
113878
113924
|
button.primary { background: #2563eb; border-color: #2563eb; color: #fff; }
|
|
113879
113925
|
button.danger { background: #b91c1c; border-color: #b91c1c; color: #fff; }
|
|
@@ -113893,6 +113939,7 @@ var VIEWER_PAGE = `<!doctype html>
|
|
|
113893
113939
|
</head>
|
|
113894
113940
|
<body>
|
|
113895
113941
|
<header>
|
|
113942
|
+
<select id="desktop" title="Which desktop to watch" hidden></select>
|
|
113896
113943
|
<span id="state">connecting\u2026</span>
|
|
113897
113944
|
<span id="meta"></span>
|
|
113898
113945
|
<span id="error"></span>
|
|
@@ -113914,7 +113961,11 @@ var VIEWER_PAGE = `<!doctype html>
|
|
|
113914
113961
|
(() => {
|
|
113915
113962
|
const $ = (id) => document.getElementById(id)
|
|
113916
113963
|
const video = $('video'), image = $('image'), surface = $('surface'), screenBox = $('screen')
|
|
113917
|
-
|
|
113964
|
+
const hash = new URLSearchParams(location.hash.slice(1))
|
|
113965
|
+
let token = hash.get('token') || localStorage.getItem('acd-viewer-token') || ''
|
|
113966
|
+
// Per-agent desktops (computer-use.md \xA73.9): the main one, or an agent's under /view/api/d/<id>.
|
|
113967
|
+
const desktop = hash.get('desktop') || sessionStorage.getItem('acd-viewer-desktop') || 'main'
|
|
113968
|
+
const base = desktop === 'main' ? '/view/api' : '/view/api/d/' + encodeURIComponent(desktop)
|
|
113918
113969
|
if (location.hash) history.replaceState(null, '', location.pathname)
|
|
113919
113970
|
let status = null, channel = null, mode = 'none', seq = 0
|
|
113920
113971
|
const pending = new Map()
|
|
@@ -113931,7 +113982,7 @@ var VIEWER_PAGE = `<!doctype html>
|
|
|
113931
113982
|
|
|
113932
113983
|
async function refresh() {
|
|
113933
113984
|
try {
|
|
113934
|
-
const res = await api('GET', '/
|
|
113985
|
+
const res = await api('GET', base + '/status')
|
|
113935
113986
|
status = await res.json()
|
|
113936
113987
|
const ctl = status.inControl
|
|
113937
113988
|
$('state').textContent = ctl ? 'You are in control \u2014 agents are blocked' : status.paused ? 'Paused: ' + status.paused.reason : status.lease ? 'Agent ' + status.lease.holder + ' is working' : 'Watching (agents allowed)'
|
|
@@ -113951,7 +114002,7 @@ var VIEWER_PAGE = `<!doctype html>
|
|
|
113951
114002
|
let lastRtcTry = 0
|
|
113952
114003
|
|
|
113953
114004
|
async function control(action) {
|
|
113954
|
-
const res = await api('POST', '/
|
|
114005
|
+
const res = await api('POST', base + '/control', { action })
|
|
113955
114006
|
const body = await res.json()
|
|
113956
114007
|
showError(res.ok ? '' : body.message)
|
|
113957
114008
|
await refresh()
|
|
@@ -113962,7 +114013,7 @@ var VIEWER_PAGE = `<!doctype html>
|
|
|
113962
114013
|
|
|
113963
114014
|
// ---- video: WebRTC first, screenshot polling if it cannot start ----
|
|
113964
114015
|
async function startWebRtc() {
|
|
113965
|
-
const offerRes = await api('POST', '/
|
|
114016
|
+
const offerRes = await api('POST', base + '/rtc/offer')
|
|
113966
114017
|
if (!offerRes.ok) throw new Error((await offerRes.json()).message || 'webrtc unavailable')
|
|
113967
114018
|
const offer = await offerRes.json()
|
|
113968
114019
|
const pc = new RTCPeerConnection()
|
|
@@ -113981,7 +114032,7 @@ var VIEWER_PAGE = `<!doctype html>
|
|
|
113981
114032
|
pc.onconnectionstatechange = () => { if (['failed', 'closed', 'disconnected'].includes(pc.connectionState)) { pc.close(); fallback('WebRTC ' + pc.connectionState) } }
|
|
113982
114033
|
await pc.setRemoteDescription({ type: 'offer', sdp: offer.sdp })
|
|
113983
114034
|
await pc.setLocalDescription(await pc.createAnswer())
|
|
113984
|
-
await api('POST', '/
|
|
114035
|
+
await api('POST', base + '/rtc/answer', { id: offer.id, sdp: pc.localDescription.sdp })
|
|
113985
114036
|
try {
|
|
113986
114037
|
await new Promise((resolve, reject) => {
|
|
113987
114038
|
const timer = setTimeout(() => reject(new Error('no video within 10s')), 10000)
|
|
@@ -114004,7 +114055,7 @@ var VIEWER_PAGE = `<!doctype html>
|
|
|
114004
114055
|
if (document.hidden) { await sleep(500); continue }
|
|
114005
114056
|
const started = performance.now()
|
|
114006
114057
|
try {
|
|
114007
|
-
const res = await api('GET', '/
|
|
114058
|
+
const res = await api('GET', base + '/frame')
|
|
114008
114059
|
if (res.ok) {
|
|
114009
114060
|
const url = URL.createObjectURL(await res.blob())
|
|
114010
114061
|
const old = image.src
|
|
@@ -114033,7 +114084,7 @@ var VIEWER_PAGE = `<!doctype html>
|
|
|
114033
114084
|
if (!reply.ok) { showError(reply.error); if (/take control/.test(reply.error)) refresh() } else showError('')
|
|
114034
114085
|
return
|
|
114035
114086
|
}
|
|
114036
|
-
const res = await api('POST', '/
|
|
114087
|
+
const res = await api('POST', base + '/input', input)
|
|
114037
114088
|
if (!res.ok) showError((await res.json()).message); else showError('')
|
|
114038
114089
|
}
|
|
114039
114090
|
|
|
@@ -114117,8 +114168,28 @@ var VIEWER_PAGE = `<!doctype html>
|
|
|
114117
114168
|
$('send').onclick = sendText
|
|
114118
114169
|
$('text').addEventListener('keydown', (event) => { if (event.key === 'Enter' && !event.isComposing) { event.preventDefault(); sendText() } })
|
|
114119
114170
|
|
|
114171
|
+
async function desktops() {
|
|
114172
|
+
try {
|
|
114173
|
+
const res = await api('GET', '/view/api/desktops')
|
|
114174
|
+
if (!res.ok) return
|
|
114175
|
+
const list = await res.json()
|
|
114176
|
+
const select = $('desktop')
|
|
114177
|
+
select.hidden = !list.perAgent && list.desktops.length < 2
|
|
114178
|
+
select.replaceChildren(...list.desktops.map((d) => {
|
|
114179
|
+
const option = document.createElement('option')
|
|
114180
|
+
option.value = d.id
|
|
114181
|
+
option.textContent = (d.id === 'main' ? d.label : d.label + ' (' + d.id + ')') + ' \xB7 ' + (d.holder ? 'working' : d.status)
|
|
114182
|
+
option.selected = d.id === desktop
|
|
114183
|
+
return option
|
|
114184
|
+
}))
|
|
114185
|
+
} catch (error) { /* an older daemon has no desktops */ }
|
|
114186
|
+
}
|
|
114187
|
+
$('desktop').onchange = (event) => { sessionStorage.setItem('acd-viewer-desktop', event.target.value); location.reload() }
|
|
114188
|
+
|
|
114120
114189
|
async function start() {
|
|
114121
114190
|
if (!token) return showLogin()
|
|
114191
|
+
await desktops()
|
|
114192
|
+
setInterval(desktops, 5000)
|
|
114122
114193
|
await refresh()
|
|
114123
114194
|
if (!status) return
|
|
114124
114195
|
setInterval(refresh, 2000)
|
|
@@ -114343,6 +114414,231 @@ function createViewer(options) {
|
|
|
114343
114414
|
};
|
|
114344
114415
|
}
|
|
114345
114416
|
|
|
114417
|
+
// src/viewer-router.ts
|
|
114418
|
+
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
114419
|
+
|
|
114420
|
+
// src/mcp-access.ts
|
|
114421
|
+
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
114422
|
+
var bearer = (authorization) => /^Bearer\s+(\S+)$/i.exec(authorization ?? "")?.[1];
|
|
114423
|
+
function channelPrincipal(authorization, authority, computerId) {
|
|
114424
|
+
const token = bearer(authorization);
|
|
114425
|
+
const id = computerId();
|
|
114426
|
+
if (!token?.startsWith(`${COMPUTER_CHANNEL_TOKEN_PREFIX}.`) || !id) return void 0;
|
|
114427
|
+
const claims = authority.verify(token, "mcp", id);
|
|
114428
|
+
if (!claims?.ses || !claims.agt) return void 0;
|
|
114429
|
+
return {
|
|
114430
|
+
client: computerLeaseHolderName({ agentId: claims.agt, sessionId: claims.ses }),
|
|
114431
|
+
viewOnly: claims.mode === "view",
|
|
114432
|
+
agent: { agentId: claims.agt, sessionId: claims.ses },
|
|
114433
|
+
...claims.sh || claims.fs ? { commandLineGrant: { shell: claims.sh ?? "off", files: claims.fs ?? "off" } } : {}
|
|
114434
|
+
};
|
|
114435
|
+
}
|
|
114436
|
+
var RESPONSE_HEADERS = ["allow", "content-type", "mcp-protocol-version", "mcp-session-id", "www-authenticate"];
|
|
114437
|
+
function reply(status, body, headers = {}) {
|
|
114438
|
+
return {
|
|
114439
|
+
status,
|
|
114440
|
+
headers: { "content-type": "application/json", ...headers },
|
|
114441
|
+
body: Buffer.from(JSON.stringify(body)).toString("base64")
|
|
114442
|
+
};
|
|
114443
|
+
}
|
|
114444
|
+
function viewerPrincipal(authorization, authority, computerId) {
|
|
114445
|
+
const token = bearer(authorization);
|
|
114446
|
+
const id = computerId();
|
|
114447
|
+
if (!token?.startsWith(`${COMPUTER_CHANNEL_TOKEN_PREFIX}.`) || !id) return void 0;
|
|
114448
|
+
const claims = authority.verify(token, "view", id);
|
|
114449
|
+
if (!claims?.usr) return void 0;
|
|
114450
|
+
return {
|
|
114451
|
+
client: `console:${claims.usr}`,
|
|
114452
|
+
control: claims.mode === "control",
|
|
114453
|
+
iceServers: claims.ice ?? [],
|
|
114454
|
+
stunUrls: claims.stun ?? [],
|
|
114455
|
+
desktop: claims.dsk ?? "main",
|
|
114456
|
+
valid: () => authority.verify(token, "view", id) !== void 0
|
|
114457
|
+
};
|
|
114458
|
+
}
|
|
114459
|
+
var mayWatch = (principal, desktop) => desktop === null || principal.desktop === void 0 || principal.desktop === desktop;
|
|
114460
|
+
function viewerAuthenticator(member, localClient, desktop = "main") {
|
|
114461
|
+
return (authorization, via) => {
|
|
114462
|
+
const principal = member(authorization);
|
|
114463
|
+
if (principal) return mayWatch(principal, desktop) ? principal : void 0;
|
|
114464
|
+
if (via !== "local") return void 0;
|
|
114465
|
+
const client = localClient(authorization);
|
|
114466
|
+
return client ? { client, control: true } : void 0;
|
|
114467
|
+
};
|
|
114468
|
+
}
|
|
114469
|
+
function createRelayedMcpHandler(deps) {
|
|
114470
|
+
return async (request2) => {
|
|
114471
|
+
const pathname = new URL(request2.path, "http://desktop.invalid").pathname;
|
|
114472
|
+
if (deps.viewer && pathname.startsWith(COMPUTER_VIEWER_API_PREFIX)) {
|
|
114473
|
+
const out = await deps.viewer({
|
|
114474
|
+
method: request2.method,
|
|
114475
|
+
path: pathname,
|
|
114476
|
+
authorization: request2.headers.authorization,
|
|
114477
|
+
via: "relay",
|
|
114478
|
+
...request2.body ? { body: Buffer.from(request2.body, "base64") } : {}
|
|
114479
|
+
});
|
|
114480
|
+
if (out.body.length > RELAY_COMPUTER_MAX_BODY_BYTES) return reply(500, { error: "response too large" });
|
|
114481
|
+
return {
|
|
114482
|
+
status: out.status,
|
|
114483
|
+
headers: out.headers,
|
|
114484
|
+
...out.body.length > 0 ? { body: out.body.toString("base64") } : {}
|
|
114485
|
+
};
|
|
114486
|
+
}
|
|
114487
|
+
if (pathname !== "/mcp") return reply(404, { error: "not found" });
|
|
114488
|
+
const principal = deps.authenticate(request2.headers.authorization);
|
|
114489
|
+
if (!principal) return reply(401, { error: "unauthorized" }, { "www-authenticate": "Bearer" });
|
|
114490
|
+
if (request2.method !== "POST" && request2.method !== "DELETE") {
|
|
114491
|
+
return reply(405, { error: "method not allowed" }, { allow: "POST, DELETE" });
|
|
114492
|
+
}
|
|
114493
|
+
const mcp = deps.createMcpServer(principal);
|
|
114494
|
+
const transport = new WebStandardStreamableHTTPServerTransport({
|
|
114495
|
+
sessionIdGenerator: void 0,
|
|
114496
|
+
enableJsonResponse: true
|
|
114497
|
+
});
|
|
114498
|
+
try {
|
|
114499
|
+
await mcp.connect(transport);
|
|
114500
|
+
const response = await transport.handleRequest(
|
|
114501
|
+
new Request("http://desktop.invalid/mcp", {
|
|
114502
|
+
method: request2.method,
|
|
114503
|
+
headers: request2.headers,
|
|
114504
|
+
...request2.body ? { body: Buffer.from(request2.body, "base64") } : {}
|
|
114505
|
+
})
|
|
114506
|
+
);
|
|
114507
|
+
const body = Buffer.from(await response.arrayBuffer());
|
|
114508
|
+
if (body.length > RELAY_COMPUTER_MAX_BODY_BYTES) return reply(500, { error: "response too large" });
|
|
114509
|
+
const headers = {};
|
|
114510
|
+
for (const name of RESPONSE_HEADERS) {
|
|
114511
|
+
const value = response.headers.get(name);
|
|
114512
|
+
if (value !== null) headers[name] = value;
|
|
114513
|
+
}
|
|
114514
|
+
return { status: response.status, headers, ...body.length > 0 ? { body: body.toString("base64") } : {} };
|
|
114515
|
+
} catch (error63) {
|
|
114516
|
+
deps.log(`relayed request failed: ${error63.message}`);
|
|
114517
|
+
return reply(500, { error: "failed" });
|
|
114518
|
+
} finally {
|
|
114519
|
+
void mcp.close().catch(() => void 0);
|
|
114520
|
+
}
|
|
114521
|
+
};
|
|
114522
|
+
}
|
|
114523
|
+
|
|
114524
|
+
// src/viewer-router.ts
|
|
114525
|
+
var DESKTOP_PATH = /^\/view\/api\/d\/([A-Za-z0-9_-]{1,32})(\/.*)$/;
|
|
114526
|
+
var MAX_BODY_BYTES2 = 64 * 1024;
|
|
114527
|
+
var json4 = (status, body) => ({
|
|
114528
|
+
status,
|
|
114529
|
+
headers: { "content-type": "application/json", "cache-control": "no-store" },
|
|
114530
|
+
body: Buffer.from(JSON.stringify(body))
|
|
114531
|
+
});
|
|
114532
|
+
function createViewerRouter(options) {
|
|
114533
|
+
const viewers = /* @__PURE__ */ new Map();
|
|
114534
|
+
const list2 = () => {
|
|
114535
|
+
const main2 = options.mainInfo();
|
|
114536
|
+
const manager = options.desktops();
|
|
114537
|
+
return {
|
|
114538
|
+
perAgent: Boolean(manager?.enabled()),
|
|
114539
|
+
desktops: [
|
|
114540
|
+
{
|
|
114541
|
+
id: "main",
|
|
114542
|
+
label: "Main desktop",
|
|
114543
|
+
name: main2.name,
|
|
114544
|
+
running: true,
|
|
114545
|
+
status: main2.status,
|
|
114546
|
+
holder: main2.lease?.holder ?? null
|
|
114547
|
+
},
|
|
114548
|
+
...(manager?.list() ?? []).map((desktop) => {
|
|
114549
|
+
const running = manager?.runningDesktops().find((candidate) => candidate.record.id === desktop.id);
|
|
114550
|
+
return {
|
|
114551
|
+
id: desktop.id,
|
|
114552
|
+
label: desktop.label,
|
|
114553
|
+
running: desktop.running,
|
|
114554
|
+
status: desktop.status ?? "stopped",
|
|
114555
|
+
holder: running?.computer.leaseActivity()?.holder ?? null
|
|
114556
|
+
};
|
|
114557
|
+
})
|
|
114558
|
+
]
|
|
114559
|
+
};
|
|
114560
|
+
};
|
|
114561
|
+
async function api(request2) {
|
|
114562
|
+
if (request2.path === "/view/api/desktops") {
|
|
114563
|
+
if (!options.authenticate(request2.authorization, request2.via)) return json4(401, { error: "unauthorized" });
|
|
114564
|
+
return json4(200, list2());
|
|
114565
|
+
}
|
|
114566
|
+
const match = DESKTOP_PATH.exec(request2.path);
|
|
114567
|
+
if (!match || match[1] === "main") {
|
|
114568
|
+
return options.main.api(match ? { ...request2, path: `/view/api${match[2]}` } : request2);
|
|
114569
|
+
}
|
|
114570
|
+
const id = match[1];
|
|
114571
|
+
const principal = options.authenticate(request2.authorization, request2.via);
|
|
114572
|
+
if (!principal || !mayWatch(principal, id)) return json4(401, { error: "unauthorized" });
|
|
114573
|
+
const manager = options.desktops();
|
|
114574
|
+
if (!manager?.enabled()) return json4(404, { error: "not_found", message: "per-agent desktops are off" });
|
|
114575
|
+
let desktop;
|
|
114576
|
+
try {
|
|
114577
|
+
desktop = await manager.byId(id);
|
|
114578
|
+
} catch (error63) {
|
|
114579
|
+
return json4(503, { error: "unavailable", message: error63.message });
|
|
114580
|
+
}
|
|
114581
|
+
if (!desktop) return json4(404, { error: "not_found", message: `no desktop ${id}` });
|
|
114582
|
+
if (desktop.stopping) return json4(503, { error: "unavailable", message: `desktop ${id} is stopping` });
|
|
114583
|
+
manager.touch(id);
|
|
114584
|
+
let viewer = viewers.get(id);
|
|
114585
|
+
if (!viewer) {
|
|
114586
|
+
viewer = options.forDesktop(desktop);
|
|
114587
|
+
viewers.set(id, viewer);
|
|
114588
|
+
}
|
|
114589
|
+
return viewer.api({ ...request2, path: `/view/api${match[2]}` });
|
|
114590
|
+
}
|
|
114591
|
+
return {
|
|
114592
|
+
api,
|
|
114593
|
+
channelMessage: (principal, message) => options.main.channelMessage(principal, message),
|
|
114594
|
+
async handle(req, res, path) {
|
|
114595
|
+
if (!(path === "/view/api/desktops" || DESKTOP_PATH.test(path))) return options.main.handle(req, res, path);
|
|
114596
|
+
const chunks = [];
|
|
114597
|
+
let size = 0;
|
|
114598
|
+
if (req.method === "POST") {
|
|
114599
|
+
for await (const chunk of req) {
|
|
114600
|
+
size += chunk.length;
|
|
114601
|
+
if (size > MAX_BODY_BYTES2) {
|
|
114602
|
+
res.writeHead(400, { "content-type": "application/json" });
|
|
114603
|
+
return void res.end(JSON.stringify({ error: "invalid_argument", message: "request body too large" }));
|
|
114604
|
+
}
|
|
114605
|
+
chunks.push(chunk);
|
|
114606
|
+
}
|
|
114607
|
+
}
|
|
114608
|
+
const out = await api({
|
|
114609
|
+
method: req.method ?? "GET",
|
|
114610
|
+
path,
|
|
114611
|
+
authorization: req.headers.authorization,
|
|
114612
|
+
via: "local",
|
|
114613
|
+
...req.method === "POST" ? { body: Buffer.concat(chunks) } : {},
|
|
114614
|
+
...req.socket.localAddress ? { hostAddress: req.socket.localAddress } : {}
|
|
114615
|
+
});
|
|
114616
|
+
res.writeHead(out.status, out.headers);
|
|
114617
|
+
res.end(out.body);
|
|
114618
|
+
},
|
|
114619
|
+
disconnectAll(reason) {
|
|
114620
|
+
options.main.disconnectAll(reason);
|
|
114621
|
+
for (const viewer of viewers.values()) viewer.disconnectAll(reason);
|
|
114622
|
+
},
|
|
114623
|
+
close() {
|
|
114624
|
+
options.main.close();
|
|
114625
|
+
for (const viewer of viewers.values()) viewer.close();
|
|
114626
|
+
viewers.clear();
|
|
114627
|
+
},
|
|
114628
|
+
statusChanged() {
|
|
114629
|
+
options.main.statusChanged();
|
|
114630
|
+
for (const viewer of viewers.values()) viewer.statusChanged();
|
|
114631
|
+
},
|
|
114632
|
+
dropDesktop(id) {
|
|
114633
|
+
const viewer = viewers.get(id);
|
|
114634
|
+
if (!viewer) return;
|
|
114635
|
+
viewers.delete(id);
|
|
114636
|
+
viewer.disconnectAll("the desktop stopped");
|
|
114637
|
+
viewer.close();
|
|
114638
|
+
}
|
|
114639
|
+
};
|
|
114640
|
+
}
|
|
114641
|
+
|
|
114346
114642
|
// src/keep-awake.ts
|
|
114347
114643
|
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
114348
114644
|
import { spawn as spawn10, spawnSync as spawnSync6 } from "node:child_process";
|
|
@@ -114894,6 +115190,7 @@ var ComputerCpClient = class {
|
|
|
114894
115190
|
const payload = {
|
|
114895
115191
|
status: report.status,
|
|
114896
115192
|
...report.lease ? { lease: report.lease } : {},
|
|
115193
|
+
...report.desktops && this.features.has(COMPUTER_DESKTOPS_FEATURE) ? { desktops: report.desktops } : {},
|
|
114897
115194
|
...fresh ? report.facts : {}
|
|
114898
115195
|
};
|
|
114899
115196
|
try {
|
|
@@ -114907,9 +115204,10 @@ var ComputerCpClient = class {
|
|
|
114907
115204
|
async reportAudit(entries2) {
|
|
114908
115205
|
const transport = this.transport;
|
|
114909
115206
|
if (this.state !== "READY" || !transport || !this.features.has(COMPUTER_AUDIT_FEATURE)) return "retry";
|
|
115207
|
+
const sent = this.features.has(COMPUTER_DESKTOPS_FEATURE) ? entries2 : entries2.map(({ desktop: _desktop, ...entry }) => entry);
|
|
114910
115208
|
try {
|
|
114911
115209
|
const reply2 = await this.correlator.request(
|
|
114912
|
-
buildComputerCpFrame("computer/audit", { entries:
|
|
115210
|
+
buildComputerCpFrame("computer/audit", { entries: sent }),
|
|
114913
115211
|
(encoded2) => transport.send(encoded2)
|
|
114914
115212
|
);
|
|
114915
115213
|
return reply2.type === "computer/audit/ok" ? "stored" : "retry";
|
|
@@ -114918,6 +115216,10 @@ var ComputerCpClient = class {
|
|
|
114918
115216
|
return error63 instanceof WireError && !error63.retryable ? "rejected" : "retry";
|
|
114919
115217
|
}
|
|
114920
115218
|
}
|
|
115219
|
+
/** Whether the CP keys leases, status and audit per agent desktop (computer-use.md §3.9). */
|
|
115220
|
+
desktopsSupported() {
|
|
115221
|
+
return this.state === "READY" && this.features.has(COMPUTER_DESKTOPS_FEATURE);
|
|
115222
|
+
}
|
|
114921
115223
|
/** Whether the CP stores the administrator-prompt mode the menu sets (computer-use.md §4.2.1). */
|
|
114922
115224
|
servesAdminPrompts() {
|
|
114923
115225
|
return this.state === "READY" && this.features.has(COMPUTER_ADMIN_PROMPTS_FEATURE);
|
|
@@ -115044,7 +115346,7 @@ var ComputerCpClient = class {
|
|
|
115044
115346
|
this.deps.onPolicy?.(frame.payload.policy);
|
|
115045
115347
|
return;
|
|
115046
115348
|
case "computer/lease":
|
|
115047
|
-
this.deps.onLease?.(frame.payload.lease);
|
|
115349
|
+
this.deps.onLease?.(frame.payload.lease, frame.payload.desktops);
|
|
115048
115350
|
return;
|
|
115049
115351
|
case "computer/relays":
|
|
115050
115352
|
this.deps.onRelays?.(frame.payload.relays);
|
|
@@ -116590,108 +116892,6 @@ var RelayLinks = class {
|
|
|
116590
116892
|
}
|
|
116591
116893
|
};
|
|
116592
116894
|
|
|
116593
|
-
// src/mcp-access.ts
|
|
116594
|
-
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
116595
|
-
var bearer = (authorization) => /^Bearer\s+(\S+)$/i.exec(authorization ?? "")?.[1];
|
|
116596
|
-
function channelPrincipal(authorization, authority, computerId) {
|
|
116597
|
-
const token = bearer(authorization);
|
|
116598
|
-
const id = computerId();
|
|
116599
|
-
if (!token?.startsWith(`${COMPUTER_CHANNEL_TOKEN_PREFIX}.`) || !id) return void 0;
|
|
116600
|
-
const claims = authority.verify(token, "mcp", id);
|
|
116601
|
-
if (!claims?.ses || !claims.agt) return void 0;
|
|
116602
|
-
return {
|
|
116603
|
-
client: computerLeaseHolderName({ agentId: claims.agt, sessionId: claims.ses }),
|
|
116604
|
-
viewOnly: claims.mode === "view",
|
|
116605
|
-
agent: { agentId: claims.agt, sessionId: claims.ses },
|
|
116606
|
-
...claims.sh || claims.fs ? { commandLineGrant: { shell: claims.sh ?? "off", files: claims.fs ?? "off" } } : {}
|
|
116607
|
-
};
|
|
116608
|
-
}
|
|
116609
|
-
var RESPONSE_HEADERS = ["allow", "content-type", "mcp-protocol-version", "mcp-session-id", "www-authenticate"];
|
|
116610
|
-
function reply(status, body, headers = {}) {
|
|
116611
|
-
return {
|
|
116612
|
-
status,
|
|
116613
|
-
headers: { "content-type": "application/json", ...headers },
|
|
116614
|
-
body: Buffer.from(JSON.stringify(body)).toString("base64")
|
|
116615
|
-
};
|
|
116616
|
-
}
|
|
116617
|
-
function viewerPrincipal(authorization, authority, computerId) {
|
|
116618
|
-
const token = bearer(authorization);
|
|
116619
|
-
const id = computerId();
|
|
116620
|
-
if (!token?.startsWith(`${COMPUTER_CHANNEL_TOKEN_PREFIX}.`) || !id) return void 0;
|
|
116621
|
-
const claims = authority.verify(token, "view", id);
|
|
116622
|
-
if (!claims?.usr) return void 0;
|
|
116623
|
-
return {
|
|
116624
|
-
client: `console:${claims.usr}`,
|
|
116625
|
-
control: claims.mode === "control",
|
|
116626
|
-
iceServers: claims.ice ?? [],
|
|
116627
|
-
stunUrls: claims.stun ?? [],
|
|
116628
|
-
valid: () => authority.verify(token, "view", id) !== void 0
|
|
116629
|
-
};
|
|
116630
|
-
}
|
|
116631
|
-
function viewerAuthenticator(member, localClient) {
|
|
116632
|
-
return (authorization, via) => {
|
|
116633
|
-
const principal = member(authorization);
|
|
116634
|
-
if (principal) return principal;
|
|
116635
|
-
if (via !== "local") return void 0;
|
|
116636
|
-
const client = localClient(authorization);
|
|
116637
|
-
return client ? { client, control: true } : void 0;
|
|
116638
|
-
};
|
|
116639
|
-
}
|
|
116640
|
-
function createRelayedMcpHandler(deps) {
|
|
116641
|
-
return async (request2) => {
|
|
116642
|
-
const pathname = new URL(request2.path, "http://desktop.invalid").pathname;
|
|
116643
|
-
if (deps.viewer && pathname.startsWith(COMPUTER_VIEWER_API_PREFIX)) {
|
|
116644
|
-
const out = await deps.viewer({
|
|
116645
|
-
method: request2.method,
|
|
116646
|
-
path: pathname,
|
|
116647
|
-
authorization: request2.headers.authorization,
|
|
116648
|
-
via: "relay",
|
|
116649
|
-
...request2.body ? { body: Buffer.from(request2.body, "base64") } : {}
|
|
116650
|
-
});
|
|
116651
|
-
if (out.body.length > RELAY_COMPUTER_MAX_BODY_BYTES) return reply(500, { error: "response too large" });
|
|
116652
|
-
return {
|
|
116653
|
-
status: out.status,
|
|
116654
|
-
headers: out.headers,
|
|
116655
|
-
...out.body.length > 0 ? { body: out.body.toString("base64") } : {}
|
|
116656
|
-
};
|
|
116657
|
-
}
|
|
116658
|
-
if (pathname !== "/mcp") return reply(404, { error: "not found" });
|
|
116659
|
-
const principal = deps.authenticate(request2.headers.authorization);
|
|
116660
|
-
if (!principal) return reply(401, { error: "unauthorized" }, { "www-authenticate": "Bearer" });
|
|
116661
|
-
if (request2.method !== "POST" && request2.method !== "DELETE") {
|
|
116662
|
-
return reply(405, { error: "method not allowed" }, { allow: "POST, DELETE" });
|
|
116663
|
-
}
|
|
116664
|
-
const mcp = deps.createMcpServer(principal);
|
|
116665
|
-
const transport = new WebStandardStreamableHTTPServerTransport({
|
|
116666
|
-
sessionIdGenerator: void 0,
|
|
116667
|
-
enableJsonResponse: true
|
|
116668
|
-
});
|
|
116669
|
-
try {
|
|
116670
|
-
await mcp.connect(transport);
|
|
116671
|
-
const response = await transport.handleRequest(
|
|
116672
|
-
new Request("http://desktop.invalid/mcp", {
|
|
116673
|
-
method: request2.method,
|
|
116674
|
-
headers: request2.headers,
|
|
116675
|
-
...request2.body ? { body: Buffer.from(request2.body, "base64") } : {}
|
|
116676
|
-
})
|
|
116677
|
-
);
|
|
116678
|
-
const body = Buffer.from(await response.arrayBuffer());
|
|
116679
|
-
if (body.length > RELAY_COMPUTER_MAX_BODY_BYTES) return reply(500, { error: "response too large" });
|
|
116680
|
-
const headers = {};
|
|
116681
|
-
for (const name of RESPONSE_HEADERS) {
|
|
116682
|
-
const value = response.headers.get(name);
|
|
116683
|
-
if (value !== null) headers[name] = value;
|
|
116684
|
-
}
|
|
116685
|
-
return { status: response.status, headers, ...body.length > 0 ? { body: body.toString("base64") } : {} };
|
|
116686
|
-
} catch (error63) {
|
|
116687
|
-
deps.log(`relayed request failed: ${error63.message}`);
|
|
116688
|
-
return reply(500, { error: "failed" });
|
|
116689
|
-
} finally {
|
|
116690
|
-
void mcp.close().catch(() => void 0);
|
|
116691
|
-
}
|
|
116692
|
-
};
|
|
116693
|
-
}
|
|
116694
|
-
|
|
116695
116895
|
// src/cp/report.ts
|
|
116696
116896
|
init_define_AGENTCONNECT_COMPUTER_WINDOWS_SOURCES();
|
|
116697
116897
|
import { spawnSync as spawnSync11 } from "node:child_process";
|
|
@@ -117698,6 +117898,19 @@ async function registerComputer(dir, token, cpUrl, name) {
|
|
|
117698
117898
|
return registration;
|
|
117699
117899
|
}
|
|
117700
117900
|
var DOCTOR_INTERVAL_MS = 30 * 6e4;
|
|
117901
|
+
function desktopReports(manager) {
|
|
117902
|
+
if (!manager?.enabled()) return void 0;
|
|
117903
|
+
return manager.runningDesktops().filter((desktop) => UUID.test(desktop.record.key)).slice(0, COMPUTER_DESKTOPS_MAX).map((desktop) => {
|
|
117904
|
+
const lease = desktop.computer.leaseActivity();
|
|
117905
|
+
return {
|
|
117906
|
+
id: desktop.record.id,
|
|
117907
|
+
agentId: desktop.record.key,
|
|
117908
|
+
status: desktop.computer.liveStatus(),
|
|
117909
|
+
...lease ? { lease } : {}
|
|
117910
|
+
};
|
|
117911
|
+
});
|
|
117912
|
+
}
|
|
117913
|
+
var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
117701
117914
|
function startCpChannel(options) {
|
|
117702
117915
|
const { dir, config: config2, registration, authority, computer, driver, screenSize } = options;
|
|
117703
117916
|
const num = (value) => typeof value === "number" && Number.isFinite(value) ? value : 0;
|
|
@@ -117734,9 +117947,11 @@ function startCpChannel(options) {
|
|
|
117734
117947
|
const display = computer.info().display;
|
|
117735
117948
|
const lease = computer.leaseActivity();
|
|
117736
117949
|
const local = options.local();
|
|
117950
|
+
const desktops = desktopReports(options.desktops?.());
|
|
117737
117951
|
return {
|
|
117738
117952
|
status: computer.liveStatus(),
|
|
117739
117953
|
...lease ? { lease } : {},
|
|
117954
|
+
...desktops ? { desktops } : {},
|
|
117740
117955
|
facts: {
|
|
117741
117956
|
...profile,
|
|
117742
117957
|
driverVersion: driver.version ?? CUA_DRIVER_VERSION,
|
|
@@ -117759,7 +117974,10 @@ function startCpChannel(options) {
|
|
|
117759
117974
|
config2.leaseMaxSeconds = policy.leaseMaxSeconds;
|
|
117760
117975
|
options.onPolicy?.(policy);
|
|
117761
117976
|
},
|
|
117762
|
-
onLease: (lease) =>
|
|
117977
|
+
onLease: (lease, desktops) => {
|
|
117978
|
+
computer.applyControlLease(lease);
|
|
117979
|
+
options.onDesktopLeases?.(desktops ?? []);
|
|
117980
|
+
},
|
|
117763
117981
|
onReady: (ok) => computer.rename(ok.name),
|
|
117764
117982
|
onRelays: (relays) => relayLinks.converge(relays),
|
|
117765
117983
|
onStop: (stop) => applyConsoleStop(stop),
|
|
@@ -117796,12 +118014,12 @@ function startCpChannel(options) {
|
|
|
117796
118014
|
}
|
|
117797
118015
|
};
|
|
117798
118016
|
}
|
|
117799
|
-
function buildViewer(dir, config2, computer, refusal, consoleViewer, advertiseAddress, onFfmpegInstalled) {
|
|
118017
|
+
function buildViewer(dir, config2, computer, refusal, consoleViewer, advertiseAddress, onFfmpegInstalled, display, desktopId = "main") {
|
|
117800
118018
|
const ffmpeg = () => resolveFfmpegPath(dir, config2.ffmpegPath);
|
|
117801
118019
|
let ffmpegState = "missing";
|
|
117802
118020
|
if (config2.webrtc) {
|
|
117803
118021
|
ffmpegState = ffmpegAvailable(ffmpeg()) ? "ok" : "missing";
|
|
117804
|
-
if (ffmpegState === "missing" && canInstallFfmpeg() && !config2.ffmpegPath) {
|
|
118022
|
+
if (ffmpegState === "missing" && canInstallFfmpeg() && !config2.ffmpegPath && !display) {
|
|
117805
118023
|
ffmpegState = "downloading";
|
|
117806
118024
|
installFfmpeg(dir, log39).then(() => {
|
|
117807
118025
|
ffmpegState = ffmpegAvailable(ffmpeg()) ? "ok" : "missing";
|
|
@@ -117821,13 +118039,17 @@ function buildViewer(dir, config2, computer, refusal, consoleViewer, advertiseAd
|
|
|
117821
118039
|
bitrateKbps: config2.streamBitrateKbps,
|
|
117822
118040
|
// A person driving sees their browser's pointer at once, so the delayed one in the frames would be a second cursor.
|
|
117823
118041
|
cursor: () => computer.liveStatus() !== "human_in_control",
|
|
118042
|
+
...display ? { display } : {},
|
|
117824
118043
|
log: log39
|
|
117825
118044
|
});
|
|
117826
118045
|
const rtc = config2.webrtc ? new RtcSessions({
|
|
117827
118046
|
stream,
|
|
117828
118047
|
log: log39,
|
|
117829
118048
|
onMessage: (principal, message) => viewer.channelMessage(principal, message),
|
|
117830
|
-
reauthorize: (token) =>
|
|
118049
|
+
reauthorize: (token) => {
|
|
118050
|
+
const principal = consoleViewer?.(`Bearer ${token}`);
|
|
118051
|
+
return principal && mayWatch(principal, desktopId) ? principal : void 0;
|
|
118052
|
+
},
|
|
117831
118053
|
...advertiseAddress ? { advertiseAddress } : {},
|
|
117832
118054
|
...config2.rtcPortRange ? { portRange: config2.rtcPortRange } : {}
|
|
117833
118055
|
}) : void 0;
|
|
@@ -117835,7 +118057,8 @@ function buildViewer(dir, config2, computer, refusal, consoleViewer, advertiseAd
|
|
|
117835
118057
|
computer,
|
|
117836
118058
|
authenticate: viewerAuthenticator(
|
|
117837
118059
|
(header) => consoleViewer?.(header),
|
|
117838
|
-
(header) => authenticate(config2, header)
|
|
118060
|
+
(header) => authenticate(config2, header),
|
|
118061
|
+
desktopId
|
|
117839
118062
|
),
|
|
117840
118063
|
log: log39,
|
|
117841
118064
|
...rtc ? { rtc } : {},
|
|
@@ -117983,7 +118206,11 @@ async function run3(dir, initial, clientName) {
|
|
|
117983
118206
|
config: config2,
|
|
117984
118207
|
support: () => desktopSupport.current,
|
|
117985
118208
|
self: [process.execPath, resolve4(process.argv[1])],
|
|
117986
|
-
build: ({ id, label, env, launchBrowser: launchBrowser2 }) => {
|
|
118209
|
+
build: ({ id, key, label, env, launchBrowser: launchBrowser2 }) => {
|
|
118210
|
+
const desktopAudit = auditSinks(
|
|
118211
|
+
fileAuditSink(join21(dir, "audit.log")),
|
|
118212
|
+
...auditReport ? [auditReport.sink] : []
|
|
118213
|
+
);
|
|
117987
118214
|
const prefixed = (line) => log39(`desktop ${id}: ${line}`);
|
|
117988
118215
|
const desktopDriver = new CuaDriver({
|
|
117989
118216
|
command: resolveDriverPath(dir, config2.driverPath),
|
|
@@ -117994,7 +118221,8 @@ async function run3(dir, initial, clientName) {
|
|
|
117994
118221
|
const desktop = new Computer({
|
|
117995
118222
|
driver: desktopDriver,
|
|
117996
118223
|
config: config2,
|
|
117997
|
-
|
|
118224
|
+
// Each entry names the desktop that served it (§3.9).
|
|
118225
|
+
audit: (record2) => desktopAudit({ ...record2, desktop: id }),
|
|
117998
118226
|
log: prefixed,
|
|
117999
118227
|
onStatus: () => live2.local?.update(),
|
|
118000
118228
|
refusal: () => authority.refusal(),
|
|
@@ -118007,10 +118235,12 @@ async function run3(dir, initial, clientName) {
|
|
|
118007
118235
|
isolation: isolationKind()
|
|
118008
118236
|
}
|
|
118009
118237
|
});
|
|
118238
|
+
desktop.applyControlLease(live2.desktopLeases?.get(key) ?? null);
|
|
118010
118239
|
return { driver: desktopDriver, computer: desktop };
|
|
118011
118240
|
},
|
|
118012
118241
|
log: log39,
|
|
118013
|
-
onChange: () => live2.local?.update()
|
|
118242
|
+
onChange: () => live2.local?.update(),
|
|
118243
|
+
onStopped: (id) => live2.viewerRouter?.dropDesktop(id)
|
|
118014
118244
|
});
|
|
118015
118245
|
}
|
|
118016
118246
|
const setDesktops = async (on) => {
|
|
@@ -118042,16 +118272,44 @@ async function run3(dir, initial, clientName) {
|
|
|
118042
118272
|
}
|
|
118043
118273
|
const releaseDisplay = config2.keepAwake ? keepDisplayAwake(log39) : () => void 0;
|
|
118044
118274
|
const driverTools = await loadDriverTools(driver, config2);
|
|
118045
|
-
const
|
|
118275
|
+
const consoleViewer = registration ? (header) => viewerPrincipal(header, authority, () => registration.computerId) : void 0;
|
|
118276
|
+
const advertiseAddress = config2.webrtc ? await rtcAdvertiseAddress(config2, void 0, log39) : void 0;
|
|
118277
|
+
const mainViewer = buildViewer(
|
|
118046
118278
|
dir,
|
|
118047
118279
|
config2,
|
|
118048
118280
|
computer,
|
|
118049
118281
|
() => authority.refusal(),
|
|
118050
|
-
|
|
118051
|
-
|
|
118282
|
+
consoleViewer,
|
|
118283
|
+
advertiseAddress,
|
|
118052
118284
|
// A first start downloads ffmpeg, so report the viewer then instead of at the next 30-minute doctor run.
|
|
118053
118285
|
() => live2.channel?.refreshDoctor()
|
|
118054
118286
|
);
|
|
118287
|
+
live2.viewerRouter = live2.desktops ? createViewerRouter({
|
|
118288
|
+
main: mainViewer,
|
|
118289
|
+
desktops: () => live2.desktops,
|
|
118290
|
+
forDesktop: (desktop) => buildViewer(
|
|
118291
|
+
dir,
|
|
118292
|
+
config2,
|
|
118293
|
+
desktop.computer,
|
|
118294
|
+
() => authority.refusal(),
|
|
118295
|
+
consoleViewer,
|
|
118296
|
+
advertiseAddress,
|
|
118297
|
+
void 0,
|
|
118298
|
+
desktop.display,
|
|
118299
|
+
desktop.record.id
|
|
118300
|
+
),
|
|
118301
|
+
authenticate: viewerAuthenticator(
|
|
118302
|
+
(header) => consoleViewer?.(header),
|
|
118303
|
+
(header) => authenticate(config2, header),
|
|
118304
|
+
null
|
|
118305
|
+
),
|
|
118306
|
+
mainInfo: () => ({
|
|
118307
|
+
name: String(computer.info().name),
|
|
118308
|
+
status: computer.liveStatus(),
|
|
118309
|
+
lease: computer.leaseActivity() ?? null
|
|
118310
|
+
})
|
|
118311
|
+
}) : void 0;
|
|
118312
|
+
const viewer = live2.viewerRouter ?? mainViewer;
|
|
118055
118313
|
live2.viewer = viewer;
|
|
118056
118314
|
const adminPromptsLocked = () => !registration || registration.revokedAt || live2.channel?.client.servesAdminPrompts() ? void 0 : "Connect to the Control Plane to change this";
|
|
118057
118315
|
const keepAdminPrompts = (mode) => {
|
|
@@ -118224,6 +118482,13 @@ async function run3(dir, initial, clientName) {
|
|
|
118224
118482
|
onPolicy: (policy) => {
|
|
118225
118483
|
live2.policy = policy;
|
|
118226
118484
|
keepAdminPrompts(policy.approvals.adminPrompts);
|
|
118485
|
+
live2.desktops?.setShareBrowserLogins(policy.shareBrowserLogins !== false);
|
|
118486
|
+
},
|
|
118487
|
+
desktops: () => live2.desktops,
|
|
118488
|
+
onDesktopLeases: (leases) => {
|
|
118489
|
+
live2.desktopLeases = new Map(leases.flatMap((lease) => lease.desktop ? [[lease.desktop, lease]] : []));
|
|
118490
|
+
for (const desktop of live2.desktops?.runningDesktops() ?? [])
|
|
118491
|
+
desktop.computer.applyControlLease(live2.desktopLeases.get(desktop.record.key) ?? null);
|
|
118227
118492
|
}
|
|
118228
118493
|
});
|
|
118229
118494
|
const publicBase = publicBaseUrl(config2);
|