@cyanheads/git-mcp-server 2.11.1 → 2.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -35
- package/dist/index.js +1020 -461
- package/package.json +11 -11
package/dist/index.js
CHANGED
|
@@ -15284,7 +15284,7 @@ var package_default;
|
|
|
15284
15284
|
var init_package = __esm(() => {
|
|
15285
15285
|
package_default = {
|
|
15286
15286
|
name: "@cyanheads/git-mcp-server",
|
|
15287
|
-
version: "2.
|
|
15287
|
+
version: "2.13.0",
|
|
15288
15288
|
mcpName: "io.github.cyanheads/git-mcp-server",
|
|
15289
15289
|
description: "A secure and scalable Git MCP server enabling AI agents to perform comprehensive Git version control operations via STDIO and Streamable HTTP.",
|
|
15290
15290
|
main: "dist/index.js",
|
|
@@ -15343,10 +15343,10 @@ var init_package = __esm(() => {
|
|
|
15343
15343
|
"publish-mcp": "bun scripts/validate-mcp-publish-schema.ts"
|
|
15344
15344
|
},
|
|
15345
15345
|
devDependencies: {
|
|
15346
|
-
"@cloudflare/workers-types": "^4.
|
|
15346
|
+
"@cloudflare/workers-types": "^4.20260423.1",
|
|
15347
15347
|
"@eslint/js": "^10.0.1",
|
|
15348
15348
|
"@hono/mcp": "^0.2.5",
|
|
15349
|
-
"@hono/node-server": "^
|
|
15349
|
+
"@hono/node-server": "^2.0.0",
|
|
15350
15350
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
15351
15351
|
"@opentelemetry/api": "^1.9.1",
|
|
15352
15352
|
"@opentelemetry/auto-instrumentations-node": "^0.73.0",
|
|
@@ -15358,13 +15358,13 @@ var init_package = __esm(() => {
|
|
|
15358
15358
|
"@opentelemetry/sdk-node": "^0.215.0",
|
|
15359
15359
|
"@opentelemetry/sdk-trace-node": "^2.7.0",
|
|
15360
15360
|
"@opentelemetry/semantic-conventions": "^1.40.0",
|
|
15361
|
-
"@supabase/supabase-js": "^2.
|
|
15362
|
-
"@types/bun": "^1.3.
|
|
15361
|
+
"@supabase/supabase-js": "^2.104.1",
|
|
15362
|
+
"@types/bun": "^1.3.13",
|
|
15363
15363
|
"@types/cross-spawn": "^6.0.6",
|
|
15364
15364
|
"@types/node": "^25.6.0",
|
|
15365
15365
|
"@types/validator": "^13.15.10",
|
|
15366
|
-
"@vitest/coverage-v8": "^4.1.
|
|
15367
|
-
"bun-types": "^1.3.
|
|
15366
|
+
"@vitest/coverage-v8": "^4.1.5",
|
|
15367
|
+
"bun-types": "^1.3.13",
|
|
15368
15368
|
depcheck: "^1.4.7",
|
|
15369
15369
|
dotenv: "^17.4.2",
|
|
15370
15370
|
eslint: "^10.2.1",
|
|
@@ -15374,7 +15374,7 @@ var init_package = __esm(() => {
|
|
|
15374
15374
|
husky: "^9.1.7",
|
|
15375
15375
|
ignore: "^7.0.5",
|
|
15376
15376
|
jose: "^6.2.2",
|
|
15377
|
-
msw: "^2.13.
|
|
15377
|
+
msw: "^2.13.5",
|
|
15378
15378
|
prettier: "^3.8.3",
|
|
15379
15379
|
"reflect-metadata": "^0.2.2",
|
|
15380
15380
|
repomix: "^1.13.1",
|
|
@@ -15382,11 +15382,11 @@ var init_package = __esm(() => {
|
|
|
15382
15382
|
tsyringe: "^4.10.0",
|
|
15383
15383
|
typedoc: "^0.28.19",
|
|
15384
15384
|
typescript: "^6.0.3",
|
|
15385
|
-
"typescript-eslint": "^8.
|
|
15385
|
+
"typescript-eslint": "^8.59.0",
|
|
15386
15386
|
validator: "^13.15.35",
|
|
15387
|
-
vite: "^8.0.
|
|
15387
|
+
vite: "^8.0.10",
|
|
15388
15388
|
"vite-tsconfig-paths": "^6.1.1",
|
|
15389
|
-
vitest: "^4.1.
|
|
15389
|
+
vitest: "^4.1.5",
|
|
15390
15390
|
zod: "^4.3.6"
|
|
15391
15391
|
},
|
|
15392
15392
|
keywords: [
|
|
@@ -15517,6 +15517,17 @@ var import_dotenv, packageManifest, emptyStringAsUndefined = (val) => {
|
|
|
15517
15517
|
return;
|
|
15518
15518
|
}
|
|
15519
15519
|
return val;
|
|
15520
|
+
}, parseBoolEnv = (defaultValue) => (val) => {
|
|
15521
|
+
if (typeof val === "boolean")
|
|
15522
|
+
return val;
|
|
15523
|
+
if (typeof val === "string") {
|
|
15524
|
+
const lower = val.trim().toLowerCase();
|
|
15525
|
+
if (["true", "1", "yes", "on"].includes(lower))
|
|
15526
|
+
return true;
|
|
15527
|
+
if (["false", "0", "no", "off", ""].includes(lower))
|
|
15528
|
+
return false;
|
|
15529
|
+
}
|
|
15530
|
+
return defaultValue;
|
|
15520
15531
|
}, expandTildePath = (path2) => {
|
|
15521
15532
|
if (typeof path2 !== "string" || path2.trim() === "") {
|
|
15522
15533
|
return;
|
|
@@ -15737,7 +15748,7 @@ var init_config = __esm(() => {
|
|
|
15737
15748
|
}),
|
|
15738
15749
|
git: exports_external.object({
|
|
15739
15750
|
provider: exports_external.preprocess(emptyStringAsUndefined, exports_external.enum(["auto", "cli", "isomorphic"]).default("auto")),
|
|
15740
|
-
signCommits: exports_external.
|
|
15751
|
+
signCommits: exports_external.preprocess(parseBoolEnv(true), exports_external.boolean()),
|
|
15741
15752
|
authorName: exports_external.string().regex(/^[^\n\r\0]*$/, "Git author name must not contain newlines or null bytes").optional(),
|
|
15742
15753
|
authorEmail: exports_external.string().email().optional(),
|
|
15743
15754
|
committerName: exports_external.string().regex(/^[^\n\r\0]*$/, "Git committer name must not contain newlines or null bytes").optional(),
|
|
@@ -60779,7 +60790,7 @@ var require_root = __commonJS((exports, module) => {
|
|
|
60779
60790
|
return values;
|
|
60780
60791
|
}();
|
|
60781
60792
|
Span.Event = function() {
|
|
60782
|
-
function
|
|
60793
|
+
function Event2(properties) {
|
|
60783
60794
|
this.attributes = [];
|
|
60784
60795
|
if (properties) {
|
|
60785
60796
|
for (var keys = Object.keys(properties), i2 = 0;i2 < keys.length; ++i2)
|
|
@@ -60787,14 +60798,14 @@ var require_root = __commonJS((exports, module) => {
|
|
|
60787
60798
|
this[keys[i2]] = properties[keys[i2]];
|
|
60788
60799
|
}
|
|
60789
60800
|
}
|
|
60790
|
-
|
|
60791
|
-
|
|
60792
|
-
|
|
60793
|
-
|
|
60794
|
-
|
|
60795
|
-
return new
|
|
60801
|
+
Event2.prototype.timeUnixNano = null;
|
|
60802
|
+
Event2.prototype.name = null;
|
|
60803
|
+
Event2.prototype.attributes = $util.emptyArray;
|
|
60804
|
+
Event2.prototype.droppedAttributesCount = null;
|
|
60805
|
+
Event2.create = function create(properties) {
|
|
60806
|
+
return new Event2(properties);
|
|
60796
60807
|
};
|
|
60797
|
-
|
|
60808
|
+
Event2.encode = function encode3(message, writer) {
|
|
60798
60809
|
if (!writer)
|
|
60799
60810
|
writer = $Writer.create();
|
|
60800
60811
|
if (message.timeUnixNano != null && Object.hasOwnProperty.call(message, "timeUnixNano"))
|
|
@@ -60808,10 +60819,10 @@ var require_root = __commonJS((exports, module) => {
|
|
|
60808
60819
|
writer.uint32(32).uint32(message.droppedAttributesCount);
|
|
60809
60820
|
return writer;
|
|
60810
60821
|
};
|
|
60811
|
-
|
|
60822
|
+
Event2.encodeDelimited = function encodeDelimited(message, writer) {
|
|
60812
60823
|
return this.encode(message, writer).ldelim();
|
|
60813
60824
|
};
|
|
60814
|
-
|
|
60825
|
+
Event2.decode = function decode3(reader, length, error48) {
|
|
60815
60826
|
if (!(reader instanceof $Reader))
|
|
60816
60827
|
reader = $Reader.create(reader);
|
|
60817
60828
|
var end = length === undefined ? reader.len : reader.pos + length, message = new $root.opentelemetry.proto.trace.v1.Span.Event;
|
|
@@ -60845,12 +60856,12 @@ var require_root = __commonJS((exports, module) => {
|
|
|
60845
60856
|
}
|
|
60846
60857
|
return message;
|
|
60847
60858
|
};
|
|
60848
|
-
|
|
60859
|
+
Event2.decodeDelimited = function decodeDelimited(reader) {
|
|
60849
60860
|
if (!(reader instanceof $Reader))
|
|
60850
60861
|
reader = new $Reader(reader);
|
|
60851
60862
|
return this.decode(reader, reader.uint32());
|
|
60852
60863
|
};
|
|
60853
|
-
|
|
60864
|
+
Event2.verify = function verify(message) {
|
|
60854
60865
|
if (typeof message !== "object" || message === null)
|
|
60855
60866
|
return "object expected";
|
|
60856
60867
|
if (message.timeUnixNano != null && message.hasOwnProperty("timeUnixNano")) {
|
|
@@ -60876,7 +60887,7 @@ var require_root = __commonJS((exports, module) => {
|
|
|
60876
60887
|
}
|
|
60877
60888
|
return null;
|
|
60878
60889
|
};
|
|
60879
|
-
|
|
60890
|
+
Event2.fromObject = function fromObject(object2) {
|
|
60880
60891
|
if (object2 instanceof $root.opentelemetry.proto.trace.v1.Span.Event)
|
|
60881
60892
|
return object2;
|
|
60882
60893
|
var message = new $root.opentelemetry.proto.trace.v1.Span.Event;
|
|
@@ -60906,7 +60917,7 @@ var require_root = __commonJS((exports, module) => {
|
|
|
60906
60917
|
message.droppedAttributesCount = object2.droppedAttributesCount >>> 0;
|
|
60907
60918
|
return message;
|
|
60908
60919
|
};
|
|
60909
|
-
|
|
60920
|
+
Event2.toObject = function toObject(message, options) {
|
|
60910
60921
|
if (!options)
|
|
60911
60922
|
options = {};
|
|
60912
60923
|
var object2 = {};
|
|
@@ -60937,16 +60948,16 @@ var require_root = __commonJS((exports, module) => {
|
|
|
60937
60948
|
object2.droppedAttributesCount = message.droppedAttributesCount;
|
|
60938
60949
|
return object2;
|
|
60939
60950
|
};
|
|
60940
|
-
|
|
60951
|
+
Event2.prototype.toJSON = function toJSON() {
|
|
60941
60952
|
return this.constructor.toObject(this, $protobuf.util.toJSONOptions);
|
|
60942
60953
|
};
|
|
60943
|
-
|
|
60954
|
+
Event2.getTypeUrl = function getTypeUrl(typeUrlPrefix) {
|
|
60944
60955
|
if (typeUrlPrefix === undefined) {
|
|
60945
60956
|
typeUrlPrefix = "type.googleapis.com";
|
|
60946
60957
|
}
|
|
60947
60958
|
return typeUrlPrefix + "/opentelemetry.proto.trace.v1.Span.Event";
|
|
60948
60959
|
};
|
|
60949
|
-
return
|
|
60960
|
+
return Event2;
|
|
60950
60961
|
}();
|
|
60951
60962
|
Span.Link = function() {
|
|
60952
60963
|
function Link(properties) {
|
|
@@ -105608,7 +105619,8 @@ var init_requestContext = __esm(() => {
|
|
|
105608
105619
|
}
|
|
105609
105620
|
const authStore = authContext.getStore();
|
|
105610
105621
|
const tenantIdFromAuth = authStore?.authInfo?.tenantId;
|
|
105611
|
-
const
|
|
105622
|
+
const inheritedRequestId = inheritedContext.requestId;
|
|
105623
|
+
const requestId = typeof inheritedRequestId === "string" && inheritedRequestId ? inheritedRequestId : generateRequestContextId();
|
|
105612
105624
|
const timestamp = new Date().toISOString();
|
|
105613
105625
|
const restTenantId = typeof rest.tenantId === "string" ? rest.tenantId : undefined;
|
|
105614
105626
|
const additionalTenantId = additionalContext && typeof additionalContext === "object" && typeof additionalContext.tenantId === "string" ? additionalContext.tenantId : undefined;
|
|
@@ -115934,7 +115946,7 @@ Suggested solution: ${env.workaround}`;
|
|
|
115934
115946
|
var require_version48 = __commonJS((exports) => {
|
|
115935
115947
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
115936
115948
|
exports.version = undefined;
|
|
115937
|
-
exports.version = "2.
|
|
115949
|
+
exports.version = "2.104.1";
|
|
115938
115950
|
});
|
|
115939
115951
|
|
|
115940
115952
|
// node_modules/@supabase/realtime-js/dist/main/lib/constants.js
|
|
@@ -118798,7 +118810,7 @@ var require_main3 = __commonJS((exports) => {
|
|
|
118798
118810
|
var require_version49 = __commonJS((exports) => {
|
|
118799
118811
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
118800
118812
|
exports.version = undefined;
|
|
118801
|
-
exports.version = "2.
|
|
118813
|
+
exports.version = "2.104.1";
|
|
118802
118814
|
});
|
|
118803
118815
|
|
|
118804
118816
|
// node_modules/@supabase/auth-js/dist/main/lib/constants.js
|
|
@@ -119380,7 +119392,7 @@ var require_helpers2 = __commonJS((exports) => {
|
|
|
119380
119392
|
const codeVerifier = generatePKCEVerifier();
|
|
119381
119393
|
let storedCodeVerifier = codeVerifier;
|
|
119382
119394
|
if (isPasswordRecovery) {
|
|
119383
|
-
storedCodeVerifier += "/
|
|
119395
|
+
storedCodeVerifier += "/recovery";
|
|
119384
119396
|
}
|
|
119385
119397
|
await (0, exports.setItemAsync)(storage, `${storageKey}-code-verifier`, storedCodeVerifier);
|
|
119386
119398
|
const codeChallenge = await generatePKCEChallenge(codeVerifier);
|
|
@@ -121615,7 +121627,7 @@ var require_GoTrueClient = __commonJS((exports) => {
|
|
|
121615
121627
|
}
|
|
121616
121628
|
if (data.session) {
|
|
121617
121629
|
await this._saveSession(data.session);
|
|
121618
|
-
await this._notifyAllSubscribers("SIGNED_IN", data.session);
|
|
121630
|
+
await this._notifyAllSubscribers(redirectType === "recovery" ? "PASSWORD_RECOVERY" : "SIGNED_IN", data.session);
|
|
121619
121631
|
}
|
|
121620
121632
|
return this._returnResult({ data: Object.assign(Object.assign({}, data), { redirectType: redirectType !== null && redirectType !== undefined ? redirectType : null }), error: error48 });
|
|
121621
121633
|
} catch (error48) {
|
|
@@ -122130,6 +122142,7 @@ var require_GoTrueClient = __commonJS((exports) => {
|
|
|
122130
122142
|
}
|
|
122131
122143
|
}
|
|
122132
122144
|
async _getSessionFromURL(params, callbackUrlType) {
|
|
122145
|
+
var _a2;
|
|
122133
122146
|
try {
|
|
122134
122147
|
if (!(0, helpers_1.isBrowser)())
|
|
122135
122148
|
throw new errors_1.AuthImplicitGrantRedirectError("No browser detected.");
|
|
@@ -122162,7 +122175,10 @@ var require_GoTrueClient = __commonJS((exports) => {
|
|
|
122162
122175
|
const url2 = new URL(window.location.href);
|
|
122163
122176
|
url2.searchParams.delete("code");
|
|
122164
122177
|
window.history.replaceState(window.history.state, "", url2.toString());
|
|
122165
|
-
return {
|
|
122178
|
+
return {
|
|
122179
|
+
data: { session: data2.session, redirectType: (_a2 = data2.redirectType) !== null && _a2 !== undefined ? _a2 : null },
|
|
122180
|
+
error: null
|
|
122181
|
+
};
|
|
122166
122182
|
}
|
|
122167
122183
|
const { provider_token, provider_refresh_token, access_token, refresh_token, expires_in, expires_at, token_type } = params;
|
|
122168
122184
|
if (!access_token || !expires_in || !refresh_token || !token_type) {
|
|
@@ -131567,6 +131583,21 @@ var StorageVectorsErrorCode = /* @__PURE__ */ function(StorageVectorsErrorCode$1
|
|
|
131567
131583
|
StorageVectorsErrorCode$1["S3VectorMaxIndexesExceeded"] = "S3VectorMaxIndexesExceeded";
|
|
131568
131584
|
return StorageVectorsErrorCode$1;
|
|
131569
131585
|
}({});
|
|
131586
|
+
function setHeader(headers, name, value) {
|
|
131587
|
+
const result = _objectSpread22({}, headers);
|
|
131588
|
+
const nameLower = name.toLowerCase();
|
|
131589
|
+
for (const key of Object.keys(result))
|
|
131590
|
+
if (key.toLowerCase() === nameLower)
|
|
131591
|
+
delete result[key];
|
|
131592
|
+
result[nameLower] = value;
|
|
131593
|
+
return result;
|
|
131594
|
+
}
|
|
131595
|
+
function normalizeHeaders(headers) {
|
|
131596
|
+
const result = {};
|
|
131597
|
+
for (const [key, value] of Object.entries(headers))
|
|
131598
|
+
result[key.toLowerCase()] = value;
|
|
131599
|
+
return result;
|
|
131600
|
+
}
|
|
131570
131601
|
var resolveFetch = (customFetch) => {
|
|
131571
131602
|
if (customFetch)
|
|
131572
131603
|
return (...args) => customFetch(...args);
|
|
@@ -131635,7 +131666,7 @@ var _getRequestParams = (method, options, parameters, body) => {
|
|
|
131635
131666
|
for (const [key, value] of Object.entries(headers))
|
|
131636
131667
|
if (key.toLowerCase() === "content-type")
|
|
131637
131668
|
contentType = value;
|
|
131638
|
-
params.headers =
|
|
131669
|
+
params.headers = setHeader(headers, "Content-Type", (_contentType = contentType) !== null && _contentType !== undefined ? _contentType : "application/json");
|
|
131639
131670
|
params.body = JSON.stringify(body);
|
|
131640
131671
|
} else
|
|
131641
131672
|
params.body = body;
|
|
@@ -131643,14 +131674,6 @@ var _getRequestParams = (method, options, parameters, body) => {
|
|
|
131643
131674
|
params.duplex = options.duplex;
|
|
131644
131675
|
return _objectSpread22(_objectSpread22({}, params), parameters);
|
|
131645
131676
|
};
|
|
131646
|
-
function setRequestHeader(headers, name, value) {
|
|
131647
|
-
const nextHeaders = _objectSpread22({}, headers);
|
|
131648
|
-
for (const key of Object.keys(nextHeaders))
|
|
131649
|
-
if (key.toLowerCase() === name.toLowerCase())
|
|
131650
|
-
delete nextHeaders[key];
|
|
131651
|
-
nextHeaders[name] = value;
|
|
131652
|
-
return nextHeaders;
|
|
131653
|
-
}
|
|
131654
131677
|
async function _handleRequest(fetcher, method, url2, options, parameters, body, namespace) {
|
|
131655
131678
|
return new Promise((resolve, reject) => {
|
|
131656
131679
|
fetcher(url2, _getRequestParams(method, options, parameters, body)).then((result) => {
|
|
@@ -131695,7 +131718,7 @@ var BaseApiClient = class {
|
|
|
131695
131718
|
constructor(url2, headers = {}, fetch$1, namespace = "storage") {
|
|
131696
131719
|
this.shouldThrowOnError = false;
|
|
131697
131720
|
this.url = url2;
|
|
131698
|
-
this.headers =
|
|
131721
|
+
this.headers = normalizeHeaders(headers);
|
|
131699
131722
|
this.fetch = resolveFetch(fetch$1);
|
|
131700
131723
|
this.namespace = namespace;
|
|
131701
131724
|
}
|
|
@@ -131704,7 +131727,7 @@ var BaseApiClient = class {
|
|
|
131704
131727
|
return this;
|
|
131705
131728
|
}
|
|
131706
131729
|
setHeader(name, value) {
|
|
131707
|
-
this.headers =
|
|
131730
|
+
this.headers = setHeader(this.headers, name, value);
|
|
131708
131731
|
return this;
|
|
131709
131732
|
}
|
|
131710
131733
|
async handleOperation(operation) {
|
|
@@ -131845,7 +131868,8 @@ var StorageFileApi = class extends BaseApiClient {
|
|
|
131845
131868
|
options.duplex = "half";
|
|
131846
131869
|
}
|
|
131847
131870
|
if (fileOptions === null || fileOptions === undefined ? undefined : fileOptions.headers)
|
|
131848
|
-
|
|
131871
|
+
for (const [key, value] of Object.entries(fileOptions.headers))
|
|
131872
|
+
headers = setHeader(headers, key, value);
|
|
131849
131873
|
const cleanPath = _this._removeEmptyFolders(path2);
|
|
131850
131874
|
const _path = _this._getFinalPath(cleanPath);
|
|
131851
131875
|
const data = await (method == "PUT" ? put : post)(_this.fetch, `${_this.url}/object/${_path}`, body, _objectSpread22({ headers }, (options === null || options === undefined ? undefined : options.duplex) ? { duplex: options.duplex } : {}));
|
|
@@ -132069,7 +132093,7 @@ var StorageFileApi = class extends BaseApiClient {
|
|
|
132069
132093
|
return query;
|
|
132070
132094
|
}
|
|
132071
132095
|
};
|
|
132072
|
-
var version2 = "2.
|
|
132096
|
+
var version2 = "2.104.1";
|
|
132073
132097
|
var DEFAULT_HEADERS = { "X-Client-Info": `storage-js/${version2}` };
|
|
132074
132098
|
var StorageBucketApi = class extends BaseApiClient {
|
|
132075
132099
|
constructor(url2, headers = {}, fetch$1, opts) {
|
|
@@ -132452,7 +132476,7 @@ var StorageClient = class extends StorageBucketApi {
|
|
|
132452
132476
|
var import_auth_js = __toESM(require_main4(), 1);
|
|
132453
132477
|
__reExport(exports_dist3, __toESM(require_main3(), 1));
|
|
132454
132478
|
__reExport(exports_dist3, __toESM(require_main4(), 1));
|
|
132455
|
-
var version3 = "2.
|
|
132479
|
+
var version3 = "2.104.1";
|
|
132456
132480
|
var JS_ENV = "";
|
|
132457
132481
|
if (typeof Deno !== "undefined")
|
|
132458
132482
|
JS_ENV = "deno";
|
|
@@ -132620,7 +132644,8 @@ var SupabaseClient = class {
|
|
|
132620
132644
|
this.fetch = fetchWithAuth(supabaseKey, this._getAccessToken.bind(this), settings.global.fetch);
|
|
132621
132645
|
this.realtime = this._initRealtimeClient(_objectSpread23({
|
|
132622
132646
|
headers: this.headers,
|
|
132623
|
-
accessToken: this._getAccessToken.bind(this)
|
|
132647
|
+
accessToken: this._getAccessToken.bind(this),
|
|
132648
|
+
fetch: this.fetch
|
|
132624
132649
|
}, settings.realtime));
|
|
132625
132650
|
if (this.accessToken)
|
|
132626
132651
|
Promise.resolve(this.accessToken()).then((token) => this.realtime.setAuth(token)).catch((e2) => console.warn("Failed to set initial Realtime auth token:", e2));
|
|
@@ -133644,6 +133669,7 @@ async function listDirtyFiles(execGit, cwd, ctx) {
|
|
|
133644
133669
|
return files;
|
|
133645
133670
|
}
|
|
133646
133671
|
// src/services/git/providers/cli/operations/commits/commit.ts
|
|
133672
|
+
init_utils();
|
|
133647
133673
|
async function executeCommit(options, context, execGit) {
|
|
133648
133674
|
try {
|
|
133649
133675
|
if (options.filesToStage?.length) {
|
|
@@ -133663,8 +133689,10 @@ async function executeCommit(options, context, execGit) {
|
|
|
133663
133689
|
if (options.noVerify) {
|
|
133664
133690
|
args.push("--no-verify");
|
|
133665
133691
|
}
|
|
133666
|
-
const
|
|
133667
|
-
|
|
133692
|
+
const signRequested = shouldSignCommits();
|
|
133693
|
+
let signed = false;
|
|
133694
|
+
let signingWarning;
|
|
133695
|
+
if (signRequested) {
|
|
133668
133696
|
args.push("--gpg-sign");
|
|
133669
133697
|
}
|
|
133670
133698
|
if (options.author) {
|
|
@@ -133674,17 +133702,20 @@ async function executeCommit(options, context, execGit) {
|
|
|
133674
133702
|
const cmd = buildGitCommand({ command: "commit", args });
|
|
133675
133703
|
try {
|
|
133676
133704
|
await execGit(cmd, context.workingDirectory, context.requestContext);
|
|
133705
|
+
signed = signRequested;
|
|
133677
133706
|
} catch (error48) {
|
|
133678
|
-
if (
|
|
133679
|
-
const unsignedArgs = args.filter((a) => a !== "--gpg-sign");
|
|
133680
|
-
const unsignedCmd = buildGitCommand({
|
|
133681
|
-
command: "commit",
|
|
133682
|
-
args: unsignedArgs
|
|
133683
|
-
});
|
|
133684
|
-
await execGit(unsignedCmd, context.workingDirectory, context.requestContext);
|
|
133685
|
-
} else {
|
|
133707
|
+
if (!signRequested) {
|
|
133686
133708
|
throw error48;
|
|
133687
133709
|
}
|
|
133710
|
+
const errorMessage = error48 instanceof Error ? error48.message : String(error48);
|
|
133711
|
+
logger.warning("Commit signing failed; retrying unsigned. Set GIT_SIGN_COMMITS=false to suppress this attempt.", { ...context.requestContext, error: error48 });
|
|
133712
|
+
signingWarning = `GIT_SIGN_COMMITS is enabled but signing failed; commit created unsigned. Check signing key availability (gpg-agent running, SSH key accessible). Underlying error: ${errorMessage}`;
|
|
133713
|
+
const unsignedArgs = args.filter((a) => a !== "--gpg-sign");
|
|
133714
|
+
const unsignedCmd = buildGitCommand({
|
|
133715
|
+
command: "commit",
|
|
133716
|
+
args: unsignedArgs
|
|
133717
|
+
});
|
|
133718
|
+
await execGit(unsignedCmd, context.workingDirectory, context.requestContext);
|
|
133688
133719
|
}
|
|
133689
133720
|
const hashCmd = buildGitCommand({
|
|
133690
133721
|
command: "rev-parse",
|
|
@@ -133713,8 +133744,12 @@ async function executeCommit(options, context, execGit) {
|
|
|
133713
133744
|
message: options.message,
|
|
133714
133745
|
author: authorName,
|
|
133715
133746
|
timestamp,
|
|
133716
|
-
filesChanged
|
|
133747
|
+
filesChanged,
|
|
133748
|
+
signed
|
|
133717
133749
|
};
|
|
133750
|
+
if (signingWarning) {
|
|
133751
|
+
result.signingWarning = signingWarning;
|
|
133752
|
+
}
|
|
133718
133753
|
return result;
|
|
133719
133754
|
} catch (error48) {
|
|
133720
133755
|
throw mapGitError(error48, "commit");
|
|
@@ -134171,8 +134206,7 @@ async function executeMerge(options, context, execGit) {
|
|
|
134171
134206
|
if (options.message) {
|
|
134172
134207
|
args.push("-m", options.message);
|
|
134173
134208
|
}
|
|
134174
|
-
|
|
134175
|
-
if (shouldSign) {
|
|
134209
|
+
if (shouldSignCommits()) {
|
|
134176
134210
|
args.push("-S");
|
|
134177
134211
|
}
|
|
134178
134212
|
args.push(options.branch);
|
|
@@ -134269,8 +134303,7 @@ ${continueResult.stderr}`),
|
|
|
134269
134303
|
if (options.preserve) {
|
|
134270
134304
|
args.push("--preserve-merges");
|
|
134271
134305
|
}
|
|
134272
|
-
|
|
134273
|
-
if (shouldSign) {
|
|
134306
|
+
if (shouldSignCommits()) {
|
|
134274
134307
|
args.push("--gpg-sign");
|
|
134275
134308
|
}
|
|
134276
134309
|
if (options.onto) {
|
|
@@ -134352,8 +134385,7 @@ async function executeCherryPick(options, context, execGit) {
|
|
|
134352
134385
|
if (options.signoff) {
|
|
134353
134386
|
args.push("--signoff");
|
|
134354
134387
|
}
|
|
134355
|
-
|
|
134356
|
-
if (shouldSign) {
|
|
134388
|
+
if (shouldSignCommits()) {
|
|
134357
134389
|
args.push("--gpg-sign");
|
|
134358
134390
|
}
|
|
134359
134391
|
args.push(...options.commits);
|
|
@@ -134629,6 +134661,9 @@ async function executePull(options, context, execGit) {
|
|
|
134629
134661
|
if (options.fastForwardOnly) {
|
|
134630
134662
|
args.push("--ff-only");
|
|
134631
134663
|
}
|
|
134664
|
+
if (shouldSignCommits()) {
|
|
134665
|
+
args.push("-S");
|
|
134666
|
+
}
|
|
134632
134667
|
const cmd = buildGitCommand({ command: "pull", args });
|
|
134633
134668
|
const result = await execGit(cmd, context.workingDirectory, context.requestContext, { allowNonZeroExit: true });
|
|
134634
134669
|
const hasConflicts = result.stdout.includes("CONFLICT") || result.stderr.includes("CONFLICT");
|
|
@@ -134683,6 +134718,7 @@ function parseFilesChanged(stdout) {
|
|
|
134683
134718
|
return files;
|
|
134684
134719
|
}
|
|
134685
134720
|
// src/services/git/providers/cli/operations/tags/tag.ts
|
|
134721
|
+
init_utils();
|
|
134686
134722
|
async function executeTag(options, context, execGit) {
|
|
134687
134723
|
try {
|
|
134688
134724
|
const args = [];
|
|
@@ -134724,7 +134760,9 @@ async function executeTag(options, context, execGit) {
|
|
|
134724
134760
|
if (!options.tagName) {
|
|
134725
134761
|
throw new Error("Tag name is required for create operation");
|
|
134726
134762
|
}
|
|
134727
|
-
const
|
|
134763
|
+
const signRequested = shouldSignCommits();
|
|
134764
|
+
let signed = false;
|
|
134765
|
+
let signingWarning;
|
|
134728
134766
|
const buildCreateArgs = (sign) => {
|
|
134729
134767
|
const createArgs = [options.tagName];
|
|
134730
134768
|
if (sign) {
|
|
@@ -134743,31 +134781,36 @@ async function executeTag(options, context, execGit) {
|
|
|
134743
134781
|
}
|
|
134744
134782
|
return createArgs;
|
|
134745
134783
|
};
|
|
134746
|
-
const
|
|
134747
|
-
|
|
134748
|
-
|
|
134749
|
-
|
|
134750
|
-
|
|
134751
|
-
|
|
134752
|
-
|
|
134753
|
-
|
|
134784
|
+
const buildCmd = (sign) => {
|
|
134785
|
+
const configOverride = sign ? [] : ["-c", "tag.gpgSign=false"];
|
|
134786
|
+
return [
|
|
134787
|
+
...configOverride,
|
|
134788
|
+
...buildGitCommand({
|
|
134789
|
+
command: "tag",
|
|
134790
|
+
args: buildCreateArgs(sign)
|
|
134791
|
+
})
|
|
134792
|
+
];
|
|
134793
|
+
};
|
|
134754
134794
|
try {
|
|
134755
|
-
await execGit(
|
|
134795
|
+
await execGit(buildCmd(signRequested), context.workingDirectory, context.requestContext);
|
|
134796
|
+
signed = signRequested;
|
|
134756
134797
|
} catch (error48) {
|
|
134757
|
-
if (
|
|
134758
|
-
const unsignedCmd = buildGitCommand({
|
|
134759
|
-
command: "tag",
|
|
134760
|
-
args: buildCreateArgs(false)
|
|
134761
|
-
});
|
|
134762
|
-
await execGit(unsignedCmd, context.workingDirectory, context.requestContext);
|
|
134763
|
-
} else {
|
|
134798
|
+
if (!signRequested) {
|
|
134764
134799
|
throw error48;
|
|
134765
134800
|
}
|
|
134801
|
+
const errorMessage = error48 instanceof Error ? error48.message : String(error48);
|
|
134802
|
+
logger.warning("Tag signing failed; retrying unsigned. Set GIT_SIGN_COMMITS=false to suppress this attempt.", { ...context.requestContext, error: error48 });
|
|
134803
|
+
signingWarning = `GIT_SIGN_COMMITS is enabled but signing failed; tag created unsigned. Check signing key availability (gpg-agent running, SSH key accessible). Underlying error: ${errorMessage}`;
|
|
134804
|
+
await execGit(buildCmd(false), context.workingDirectory, context.requestContext);
|
|
134766
134805
|
}
|
|
134767
134806
|
const createResult = {
|
|
134768
134807
|
mode: "create",
|
|
134769
|
-
created: options.tagName
|
|
134808
|
+
created: options.tagName,
|
|
134809
|
+
signed
|
|
134770
134810
|
};
|
|
134811
|
+
if (signingWarning) {
|
|
134812
|
+
createResult.signingWarning = signingWarning;
|
|
134813
|
+
}
|
|
134771
134814
|
return createResult;
|
|
134772
134815
|
}
|
|
134773
134816
|
case "delete": {
|
|
@@ -145237,12 +145280,10 @@ var import_tsyringe7 = __toESM(require_cjs2(), 1);
|
|
|
145237
145280
|
// src/mcp-server/prompts/definitions/git-wrapup.prompt.ts
|
|
145238
145281
|
init_zod();
|
|
145239
145282
|
var PROMPT_NAME = "git_wrapup";
|
|
145240
|
-
var PROMPT_DESCRIPTION = "
|
|
145283
|
+
var PROMPT_DESCRIPTION = "Orchestrates a full git wrap-up: loads the project-aware acceptance-criteria protocol from git_wrapup_instructions, analyzes changes, satisfies each criterion per project convention, commits atomically, and (optionally) tags the release.";
|
|
145241
145284
|
var ArgumentsSchema = exports_external.object({
|
|
145242
|
-
changelogPath: exports_external.string().optional().describe("Path to the changelog file
|
|
145243
|
-
|
|
145244
|
-
createTag: exports_external.string().optional().describe("Whether to create a git tag after committing ('true' | 'false'). Defaults to 'false'."),
|
|
145245
|
-
updateAgentFiles: exports_external.string().optional().describe("Whether to update agent meta files like CLAUDE.md, AGENTS.md ('true' | 'false'). Defaults to 'false'.")
|
|
145285
|
+
changelogPath: exports_external.string().optional().describe("Path to the changelog file when the project uses a flat one (defaults to CHANGELOG.md). The protocol itself defers to project convention."),
|
|
145286
|
+
createTag: exports_external.string().optional().describe("Whether to include the tag criterion in the protocol ('true' | 'false'). Defaults to 'true' — set to 'false' when tagging is deferred to a separate release step.")
|
|
145246
145287
|
});
|
|
145247
145288
|
var gitWrapupPrompt = {
|
|
145248
145289
|
name: PROMPT_NAME,
|
|
@@ -145250,57 +145291,34 @@ var gitWrapupPrompt = {
|
|
|
145250
145291
|
argumentsSchema: ArgumentsSchema,
|
|
145251
145292
|
generate: (args) => {
|
|
145252
145293
|
const changelogPath = args.changelogPath || "CHANGELOG.md";
|
|
145253
|
-
const
|
|
145254
|
-
const createTag = args.createTag === "true";
|
|
145255
|
-
const updateAgentFiles = args.updateAgentFiles === "true";
|
|
145256
|
-
const documentationSection = skipDocumentation ? "" : `
|
|
145257
|
-
4. **Review Documentation**: Read the README.md file and verify it accurately reflects the current codebase state. Update as necessary to maintain currency and accuracy.
|
|
145258
|
-
`;
|
|
145259
|
-
const agentFilesSection = updateAgentFiles ? `
|
|
145260
|
-
5. **Update Agent Files**: If present, review and update agent-specific meta files (CLAUDE.md, AGENTS.md, .clinerules/) to reflect any architectural or protocol changes.
|
|
145261
|
-
` : "";
|
|
145262
|
-
const tagSection = createTag ? `
|
|
145263
|
-
After all commits are complete and verified via git_status, create an annotated git tag using the git_tag tool. Use semantic versioning (e.g., v1.2.3) and include a summary of key changes in the annotation message.
|
|
145264
|
-
` : "";
|
|
145294
|
+
const includeTag = args.createTag !== "false";
|
|
145265
145295
|
return [
|
|
145266
145296
|
{
|
|
145267
145297
|
role: "user",
|
|
145268
145298
|
content: {
|
|
145269
145299
|
type: "text",
|
|
145270
|
-
text: `You are an expert git workflow manager.
|
|
145300
|
+
text: `You are an expert git workflow manager. Run a complete wrap-up for the current git session.
|
|
145301
|
+
|
|
145302
|
+
## Session Flow
|
|
145271
145303
|
|
|
145272
|
-
|
|
145304
|
+
1. **Load Protocol**: Call \`git_wrapup_instructions\` with \`acknowledgement: "yes"\`${includeTag ? "" : " and `createTag: false`"}. It returns an acceptance-criteria checklist — every box must be satisfied before the wrap-up is complete — plus the current repository status.
|
|
145273
145305
|
|
|
145274
|
-
|
|
145306
|
+
2. **Set Working Directory**: If not already set, call \`git_set_working_dir\` to establish the session context. Required before any git operations.
|
|
145275
145307
|
|
|
145276
|
-
|
|
145308
|
+
3. **Analyze Changes**: Run \`git_diff\` with \`includeUntracked: true\`. Understand the "why" behind every modification end-to-end before grouping anything — the diff drives your commit plan and messages.
|
|
145277
145309
|
|
|
145278
|
-
|
|
145310
|
+
4. **Satisfy the Acceptance Criteria**: Work each checkbox from step 1. The protocol is strict on outcomes, generic on mechanism — follow this project's own conventions for where versions live, how the changelog is formatted (default path when flat: \`${changelogPath}\`), and what the verification suite looks like. If the root agent-instruction file (\`AGENTS.md\`, \`CLAUDE.md\`, or equivalent) documents a project-specific wrap-up procedure, that takes precedence over the generic checklist.
|
|
145279
145311
|
|
|
145280
|
-
|
|
145312
|
+
5. **Commit Atomically**: Use \`git_commit\` to create logical, self-contained commits in Conventional Commits form. Group related changes with the \`filesToStage\` parameter. No mixing unrelated changes in one commit.
|
|
145281
145313
|
|
|
145282
|
-
|
|
145283
|
-
- Uses past tense and concise language
|
|
145284
|
-
- Categorizes changes (Added, Changed, Fixed, Deprecated, Removed, Security)
|
|
145285
|
-
- Follows the existing changelog format
|
|
145286
|
-
- Provides enough detail for users to understand the impact
|
|
145287
|
-
${documentationSection}${agentFilesSection}
|
|
145288
|
-
5. **Commit Changes**: Use \`git_commit\` to create atomic, logical commits. For each commit:
|
|
145289
|
-
- Group related changes together using the \`filesToStage\` parameter
|
|
145290
|
-
- Write commit messages following Conventional Commits format (e.g., \`feat(auth): add password reset\`, \`fix(parser): handle edge case\`)
|
|
145291
|
-
- Ensure commits are self-contained and buildable
|
|
145292
|
-
- Do not mix unrelated changes in a single commit
|
|
145314
|
+
6. **Verify Clean**: Run \`git_status\` to confirm the working tree is clean and every change is committed.${includeTag ? "\n\n7. **Tag the Release**: Create an annotated git tag with `git_tag` using semantic versioning (e.g., `v1.2.3`). The annotation message should summarize the real changes — no filler." : ""}
|
|
145293
145315
|
|
|
145294
|
-
|
|
145295
|
-
${tagSection}
|
|
145296
|
-
## Important Guidelines
|
|
145316
|
+
## Constraints
|
|
145297
145317
|
|
|
145298
|
-
- **Do
|
|
145299
|
-
- Create a task list before starting
|
|
145300
|
-
-
|
|
145301
|
-
-
|
|
145302
|
-
- All commit messages must be clear, descriptive, and follow conventions
|
|
145303
|
-
- Preserve existing code style and documentation formatting
|
|
145318
|
+
- **Do not push** to the remote unless explicitly instructed.
|
|
145319
|
+
- Create a task list before starting so progress is trackable.
|
|
145320
|
+
- Do not bypass verification failures to land a green commit.
|
|
145321
|
+
- On merge conflicts or unexpected errors: stop and surface the blocker.
|
|
145304
145322
|
|
|
145305
145323
|
Begin by calling \`git_wrapup_instructions\` and creating your task list.`
|
|
145306
145324
|
}
|
|
@@ -145389,7 +145407,6 @@ var AllSchema = exports_external.boolean().default(false).describe("Include all
|
|
|
145389
145407
|
var MergeStrategySchema = exports_external.enum(["ort", "recursive", "octopus", "ours", "subtree"]).optional().describe("Merge strategy to use (ort, recursive, octopus, ours, subtree).");
|
|
145390
145408
|
var PruneSchema = exports_external.boolean().default(false).describe("Prune remote-tracking references that no longer exist on remote.");
|
|
145391
145409
|
var DepthSchema = exports_external.number().int().min(1).optional().describe("Create a shallow clone with history truncated to N commits.");
|
|
145392
|
-
var SignSchema = exports_external.boolean().optional().describe("Sign the commit/tag with GPG/SSH. Omit to use the server's GIT_SIGN_COMMITS default (recommended). Set true to force signing, or false to skip signing even when the default enables it.");
|
|
145393
145410
|
var NoVerifySchema = exports_external.boolean().default(false).describe("Bypass pre-commit and commit-msg hooks.");
|
|
145394
145411
|
|
|
145395
145412
|
// src/mcp-server/tools/utils/json-response-formatter.ts
|
|
@@ -146537,11 +146554,10 @@ import path4 from "path";
|
|
|
146537
146554
|
init_config();
|
|
146538
146555
|
var TOOL_NAME10 = "git_wrapup_instructions";
|
|
146539
146556
|
var TOOL_TITLE10 = "Git Wrap-up Instructions";
|
|
146540
|
-
var TOOL_DESCRIPTION10 = "
|
|
146557
|
+
var TOOL_DESCRIPTION10 = "Returns a Git wrap-up protocol: an acceptance-criteria checklist the agent must satisfy before the session is considered shipped. Uses the operator's custom instructions if configured, otherwise emits a generic goals-strict/mechanism-generic default. Includes current repository status to guide next actions.";
|
|
146541
146558
|
var InputSchema10 = exports_external.object({
|
|
146542
146559
|
acknowledgement: exports_external.enum(["Y", "y", "Yes", "yes"]).describe("Acknowledgement to initiate the wrap-up workflow."),
|
|
146543
|
-
|
|
146544
|
-
createTag: exports_external.boolean().optional().describe("If true, instructs the agent to create a Git tag after committing all changes. Only set to true if given permission to do so.")
|
|
146560
|
+
createTag: exports_external.boolean().optional().describe("Controls whether the tag criterion appears in the emitted protocol. Omit or set `true` to include the tag step. Set `false` to omit it entirely — e.g., when tagging is deferred to a separate release step.")
|
|
146545
146561
|
});
|
|
146546
146562
|
var OutputSchema11 = exports_external.object({
|
|
146547
146563
|
instructions: exports_external.string().describe("The set of instructions for the wrap-up workflow."),
|
|
@@ -146553,71 +146569,73 @@ var OutputSchema11 = exports_external.object({
|
|
|
146553
146569
|
}).optional().describe("The current structured git status."),
|
|
146554
146570
|
gitStatusError: exports_external.string().optional().describe("Any error message if getting git status failed.")
|
|
146555
146571
|
});
|
|
146556
|
-
|
|
146557
|
-
|
|
146572
|
+
function buildDefaultInstructions(input) {
|
|
146573
|
+
const tagCriterion = input.createTag === false ? "" : "\n- [ ] Annotated tag at the project's convention (typically `v<version>`) with a concise message summarizing the real changes — no filler. Flag if a tag already exists at this commit.";
|
|
146574
|
+
return `# Git Wrap-up
|
|
146575
|
+
|
|
146576
|
+
**Outcome**: a new release — version bumped, changes documented and verified, committed atomically, and tagged.
|
|
146558
146577
|
|
|
146559
|
-
**
|
|
146578
|
+
**Philosophy**: strict on goals, generic on mechanism. The acceptance checkboxes are fixed; everything beneath them is guidance that defers to project convention.
|
|
146560
146579
|
|
|
146561
|
-
|
|
146580
|
+
## Orient
|
|
146562
146581
|
|
|
146563
|
-
|
|
146582
|
+
Before touching git, read the project. Check the root agent-instruction file (\`AGENTS.md\`, \`CLAUDE.md\`, or equivalent) for wrap-up expectations, version locations, and any bespoke checklist. Identify:
|
|
146564
146583
|
|
|
146565
|
-
|
|
146566
|
-
|
|
146567
|
-
-
|
|
146568
|
-
-
|
|
146569
|
-
- [ ] Update CHANGELOG.md with all modifications
|
|
146570
|
-
- [ ] Review and update README.md for currency
|
|
146571
|
-
- [ ] Commit changes in logical, atomic units
|
|
146572
|
-
- [ ] Verify final repository status
|
|
146573
|
-
\`\`\`
|
|
146584
|
+
- how changes are recorded (flat changelog, directory-based, release-notes tooling, or none)
|
|
146585
|
+
- where versions are declared (manifest, server descriptor, \`VERSION\` file, tag-driven, or embedded in docs)
|
|
146586
|
+
- what verification looks like (the project's check-suite, which may be a single combined command or several run in sequence)
|
|
146587
|
+
- what mirrors version or structure (badges, generated docs, agent-instruction files, templated files)
|
|
146574
146588
|
|
|
146575
|
-
|
|
146589
|
+
If the project documents its own wrap-up procedure, follow it — the checklist below is the baseline, not an override.
|
|
146576
146590
|
|
|
146577
|
-
|
|
146591
|
+
## Acceptance criteria
|
|
146578
146592
|
|
|
146579
|
-
|
|
146593
|
+
A wrap-up is complete when every checkbox is satisfied. Every wrap-up is a release: minimum patch bump unless the change warrants minor or major.
|
|
146580
146594
|
|
|
146581
|
-
|
|
146595
|
+
- [ ] Full diff reviewed end-to-end before commits are planned
|
|
146596
|
+
- [ ] Version bumped per semver (default patch; minor/major when warranted) across every place the project declares it — manifest, server descriptor, badges, agent-instruction files, templated mirrors
|
|
146597
|
+
- [ ] Changelog updated under the new version in the project's existing format, or created conventionally if none exists
|
|
146598
|
+
- [ ] Documentation that references changed behaviour is current
|
|
146599
|
+
- [ ] Verification suite passes against the tree being committed
|
|
146600
|
+
- [ ] Commits are atomic and in Conventional Commits form${tagCriterion}
|
|
146582
146601
|
|
|
146583
|
-
|
|
146602
|
+
**Commonly relevant files** (check these if present; exact names vary by project):
|
|
146584
146603
|
|
|
146585
|
-
|
|
146604
|
+
- **Documentation**: \`README.md\`, generated structure docs like \`docs/tree.md\`, and any usage or reference docs affected by the change.
|
|
146605
|
+
- **Agent-instruction files**: \`AGENTS.md\`, \`CLAUDE.md\`, or equivalents — if the code changes alter anything these files describe (architecture, available tools, conventions, file layout), update them to match. If they are symlinked or mirrored, edit the source; the link or mirror reflects automatically.
|
|
146606
|
+
- **Version sources**: manifests (\`package.json\`, \`pyproject.toml\`, \`Cargo.toml\`), server descriptors (\`server.json\`), \`VERSION\` files — bump in lockstep.
|
|
146586
146607
|
|
|
146587
|
-
|
|
146588
|
-
- Commits **must be atomic** and group related changes.
|
|
146589
|
-
- Commit messages **must adhere** to the **Conventional Commits** standard (e.g., \`feat(auth): implement password reset\`).
|
|
146590
|
-
- Use the \`filesToStage\` parameter to precisely control which files are included in each commit.
|
|
146608
|
+
**Style defaults** (overridable by project convention):
|
|
146591
146609
|
|
|
146592
|
-
|
|
146610
|
+
- Cross-reference issues and PRs with full URLs — \`[#42](https://github.com/owner/repo/pull/42)\` or \`owner/repo#42\`. Bare \`#42\` breaks outside the GitHub web UI.
|
|
146611
|
+
- Commit and changelog entries lead with specifics — name the tool, service, or module affected in the first few words.
|
|
146612
|
+
|
|
146613
|
+
## Constraints
|
|
146614
|
+
|
|
146615
|
+
- Do not push to the remote unless explicitly instructed.
|
|
146616
|
+
- Do not bypass verification failures to land a green commit.
|
|
146617
|
+
- Do not rewrite published history.
|
|
146593
146618
|
`;
|
|
146594
|
-
|
|
146619
|
+
}
|
|
146620
|
+
function loadCustomInstructions(filePath) {
|
|
146595
146621
|
if (!filePath) {
|
|
146596
|
-
logger.debug("No custom instructions
|
|
146597
|
-
return
|
|
146622
|
+
logger.debug("No custom wrap-up instructions configured; using built-in default.");
|
|
146623
|
+
return null;
|
|
146598
146624
|
}
|
|
146599
146625
|
try {
|
|
146600
146626
|
const resolvedPath = path4.resolve(filePath);
|
|
146601
|
-
logger.debug(`Loading custom instructions from ${resolvedPath} at module initialization
|
|
146627
|
+
logger.debug(`Loading custom wrap-up instructions from ${resolvedPath} at module initialization.`);
|
|
146602
146628
|
return readFileSync(resolvedPath, "utf-8");
|
|
146603
146629
|
} catch (error48) {
|
|
146604
146630
|
const errorMessage = error48 instanceof Error ? error48.message : "An unknown error occurred";
|
|
146605
|
-
logger.warning(`Failed to load custom instructions from '${filePath}': ${errorMessage}. Falling back to default
|
|
146606
|
-
return
|
|
146631
|
+
logger.warning(`Failed to load custom wrap-up instructions from '${filePath}': ${errorMessage}. Falling back to built-in default.`);
|
|
146632
|
+
return null;
|
|
146607
146633
|
}
|
|
146608
146634
|
}
|
|
146609
|
-
var
|
|
146635
|
+
var customInstructions = loadCustomInstructions(config2?.git?.wrapupInstructionsPath);
|
|
146610
146636
|
async function gitWrapupInstructionsLogic(input, { provider, storage, appContext }) {
|
|
146611
146637
|
const tenantId = appContext.tenantId || "default-tenant";
|
|
146612
|
-
|
|
146613
|
-
if (input.updateAgentMetaFiles) {
|
|
146614
|
-
finalInstructions += `
|
|
146615
|
-
Extra request: review and update if needed the .cline_rules and claude.md files if present.`;
|
|
146616
|
-
}
|
|
146617
|
-
if (input.createTag) {
|
|
146618
|
-
finalInstructions += `
|
|
146619
|
-
6. After all changes are committed and confirmed via 'git_status', use the 'git_tag' tool to create a new annotated tag. The tag name should follow semantic versioning (e.g., v1.2.3), and the annotation message should summarize the key changes in this wrap-up.`;
|
|
146620
|
-
}
|
|
146638
|
+
const finalInstructions = customInstructions ?? buildDefaultInstructions(input);
|
|
146621
146639
|
let gitStatus;
|
|
146622
146640
|
let gitStatusError;
|
|
146623
146641
|
try {
|
|
@@ -146826,10 +146844,8 @@ var InputSchema12 = exports_external.object({
|
|
|
146826
146844
|
}).optional().describe("Override commit author (defaults to git config)."),
|
|
146827
146845
|
amend: exports_external.boolean().default(false).describe("Amend the previous commit instead of creating a new one. Use with caution."),
|
|
146828
146846
|
allowEmpty: exports_external.boolean().default(false).describe("Allow creating a commit with no changes."),
|
|
146829
|
-
sign: SignSchema,
|
|
146830
146847
|
noVerify: NoVerifySchema,
|
|
146831
|
-
filesToStage: exports_external.array(exports_external.string()).optional().describe("File paths to stage before committing (atomic stage+commit operation).")
|
|
146832
|
-
forceUnsignedOnFailure: exports_external.boolean().default(false).describe("If GPG/SSH signing fails, retry the commit without signing instead of failing.")
|
|
146848
|
+
filesToStage: exports_external.array(exports_external.string()).optional().describe("File paths to stage before committing (atomic stage+commit operation).")
|
|
146833
146849
|
});
|
|
146834
146850
|
var OutputSchema13 = exports_external.object({
|
|
146835
146851
|
success: exports_external.boolean().describe("Indicates if the operation was successful."),
|
|
@@ -146841,6 +146857,8 @@ var OutputSchema13 = exports_external.object({
|
|
|
146841
146857
|
committedFiles: exports_external.array(exports_external.string()).describe("List of files that were committed."),
|
|
146842
146858
|
insertions: exports_external.number().int().optional().describe("Number of line insertions."),
|
|
146843
146859
|
deletions: exports_external.number().int().optional().describe("Number of line deletions."),
|
|
146860
|
+
signed: exports_external.boolean().describe("Whether the commit was signed. False when GIT_SIGN_COMMITS=false or when signing was attempted and fell back to unsigned on failure."),
|
|
146861
|
+
signingWarning: exports_external.string().optional().describe("Populated only when signing was requested but failed, and the commit was created unsigned as a fallback."),
|
|
146844
146862
|
status: exports_external.object({
|
|
146845
146863
|
current_branch: exports_external.string().nullable().describe("Current branch name after commit."),
|
|
146846
146864
|
staged_changes: exports_external.record(exports_external.string(), exports_external.any()).describe("Remaining staged changes after commit."),
|
|
@@ -146862,15 +146880,11 @@ async function gitCommitLogic(input, { provider, targetPath, appContext }) {
|
|
|
146862
146880
|
message: input.message,
|
|
146863
146881
|
amend: input.amend,
|
|
146864
146882
|
allowEmpty: input.allowEmpty,
|
|
146865
|
-
noVerify: input.noVerify
|
|
146866
|
-
forceUnsignedOnFailure: input.forceUnsignedOnFailure
|
|
146883
|
+
noVerify: input.noVerify
|
|
146867
146884
|
};
|
|
146868
146885
|
if (input.author !== undefined) {
|
|
146869
146886
|
commitOptions.author = input.author;
|
|
146870
146887
|
}
|
|
146871
|
-
if (input.sign !== undefined) {
|
|
146872
|
-
commitOptions.sign = input.sign;
|
|
146873
|
-
}
|
|
146874
146888
|
const result = await provider.commit(commitOptions, {
|
|
146875
146889
|
workingDirectory: targetPath,
|
|
146876
146890
|
requestContext: appContext,
|
|
@@ -146881,7 +146895,7 @@ async function gitCommitLogic(input, { provider, targetPath, appContext }) {
|
|
|
146881
146895
|
requestContext: appContext,
|
|
146882
146896
|
tenantId: appContext.tenantId || "default-tenant"
|
|
146883
146897
|
});
|
|
146884
|
-
|
|
146898
|
+
const output = {
|
|
146885
146899
|
success: result.success,
|
|
146886
146900
|
commitHash: result.commitHash,
|
|
146887
146901
|
message: result.message,
|
|
@@ -146889,6 +146903,7 @@ async function gitCommitLogic(input, { provider, targetPath, appContext }) {
|
|
|
146889
146903
|
timestamp: result.timestamp,
|
|
146890
146904
|
filesChanged: result.filesChanged.length,
|
|
146891
146905
|
committedFiles: result.filesChanged,
|
|
146906
|
+
signed: result.signed,
|
|
146892
146907
|
status: {
|
|
146893
146908
|
current_branch: statusResult.currentBranch,
|
|
146894
146909
|
staged_changes: flattenChanges(statusResult.stagedChanges),
|
|
@@ -146898,6 +146913,10 @@ async function gitCommitLogic(input, { provider, targetPath, appContext }) {
|
|
|
146898
146913
|
is_clean: statusResult.isClean
|
|
146899
146914
|
}
|
|
146900
146915
|
};
|
|
146916
|
+
if (result.signingWarning) {
|
|
146917
|
+
output.signingWarning = result.signingWarning;
|
|
146918
|
+
}
|
|
146919
|
+
return output;
|
|
146901
146920
|
}
|
|
146902
146921
|
function filterGitCommitOutput(result, level) {
|
|
146903
146922
|
if (level === "minimal") {
|
|
@@ -146905,6 +146924,8 @@ function filterGitCommitOutput(result, level) {
|
|
|
146905
146924
|
success: result.success,
|
|
146906
146925
|
commitHash: result.commitHash,
|
|
146907
146926
|
message: result.message,
|
|
146927
|
+
signed: result.signed,
|
|
146928
|
+
...result.signingWarning && { signingWarning: result.signingWarning },
|
|
146908
146929
|
status: {
|
|
146909
146930
|
current_branch: result.status.current_branch,
|
|
146910
146931
|
is_clean: result.status.is_clean,
|
|
@@ -146926,6 +146947,8 @@ function filterGitCommitOutput(result, level) {
|
|
|
146926
146947
|
insertions: result.insertions,
|
|
146927
146948
|
deletions: result.deletions,
|
|
146928
146949
|
committedFiles: result.committedFiles,
|
|
146950
|
+
signed: result.signed,
|
|
146951
|
+
...result.signingWarning && { signingWarning: result.signingWarning },
|
|
146929
146952
|
status: {
|
|
146930
146953
|
current_branch: result.status.current_branch,
|
|
146931
146954
|
is_clean: result.status.is_clean,
|
|
@@ -148174,9 +148197,7 @@ var InputSchema27 = exports_external.object({
|
|
|
148174
148197
|
tagName: TagNameSchema.optional().describe("Tag name for create/delete operations."),
|
|
148175
148198
|
commit: CommitRefSchema.optional().describe("Commit to tag (default: HEAD for create operation)."),
|
|
148176
148199
|
message: exports_external.string().optional().describe("Tag message. Providing a message always produces an annotated tag (git does not support messages on lightweight tags). For release tags, summarize notable changes."),
|
|
148177
|
-
annotated: exports_external.boolean().default(false).describe('Create an annotated tag with a default "Tag <name>" message. Only effective when
|
|
148178
|
-
sign: SignSchema,
|
|
148179
|
-
forceUnsignedOnFailure: exports_external.boolean().default(false).describe("If GPG/SSH signing fails, retry the tag creation without signing instead of failing."),
|
|
148200
|
+
annotated: exports_external.boolean().default(false).describe('Create an annotated tag with a default "Tag <name>" message. Only effective when no message is provided and signing is disabled — otherwise the tag is always annotated.'),
|
|
148180
148201
|
force: ForceSchema.describe("Overwrite an existing tag (create mode only; has no effect on list or delete).")
|
|
148181
148202
|
});
|
|
148182
148203
|
var TagInfoSchema = exports_external.object({
|
|
@@ -148191,7 +148212,9 @@ var OutputSchema28 = exports_external.object({
|
|
|
148191
148212
|
mode: exports_external.string().describe("Operation mode that was performed."),
|
|
148192
148213
|
tags: exports_external.array(TagInfoSchema).optional().describe("List of tags (for list mode)."),
|
|
148193
148214
|
created: exports_external.string().optional().describe("Created tag name (for create mode)."),
|
|
148194
|
-
deleted: exports_external.string().optional().describe("Deleted tag name (for delete mode).")
|
|
148215
|
+
deleted: exports_external.string().optional().describe("Deleted tag name (for delete mode)."),
|
|
148216
|
+
signed: exports_external.boolean().optional().describe("Whether the created tag was signed. Only populated for create mode. False when GIT_SIGN_COMMITS=false or when signing failed and fell back to unsigned."),
|
|
148217
|
+
signingWarning: exports_external.string().optional().describe("Populated only when signing was requested but failed, and the tag was created unsigned as a fallback.")
|
|
148195
148218
|
});
|
|
148196
148219
|
async function gitTagLogic(input, { provider, targetPath, appContext }) {
|
|
148197
148220
|
if ((input.mode === "create" || input.mode === "delete") && !input.tagName) {
|
|
@@ -148200,8 +148223,7 @@ async function gitTagLogic(input, { provider, targetPath, appContext }) {
|
|
|
148200
148223
|
const tagOptions = {
|
|
148201
148224
|
mode: input.mode,
|
|
148202
148225
|
annotated: input.annotated,
|
|
148203
|
-
force: input.force
|
|
148204
|
-
forceUnsignedOnFailure: input.forceUnsignedOnFailure
|
|
148226
|
+
force: input.force
|
|
148205
148227
|
};
|
|
148206
148228
|
if (input.tagName !== undefined) {
|
|
148207
148229
|
tagOptions.tagName = input.tagName;
|
|
@@ -148212,27 +148234,33 @@ async function gitTagLogic(input, { provider, targetPath, appContext }) {
|
|
|
148212
148234
|
if (input.message !== undefined) {
|
|
148213
148235
|
tagOptions.message = normalizeMessage(input.message);
|
|
148214
148236
|
}
|
|
148215
|
-
if (input.sign !== undefined) {
|
|
148216
|
-
tagOptions.sign = input.sign;
|
|
148217
|
-
}
|
|
148218
148237
|
const result = await provider.tag(tagOptions, {
|
|
148219
148238
|
workingDirectory: targetPath,
|
|
148220
148239
|
requestContext: appContext,
|
|
148221
148240
|
tenantId: appContext.tenantId || "default-tenant"
|
|
148222
148241
|
});
|
|
148223
|
-
|
|
148242
|
+
const output = {
|
|
148224
148243
|
success: true,
|
|
148225
148244
|
mode: result.mode,
|
|
148226
148245
|
tags: result.tags,
|
|
148227
148246
|
created: result.created,
|
|
148228
148247
|
deleted: result.deleted
|
|
148229
148248
|
};
|
|
148249
|
+
if (result.signed !== undefined) {
|
|
148250
|
+
output.signed = result.signed;
|
|
148251
|
+
}
|
|
148252
|
+
if (result.signingWarning) {
|
|
148253
|
+
output.signingWarning = result.signingWarning;
|
|
148254
|
+
}
|
|
148255
|
+
return output;
|
|
148230
148256
|
}
|
|
148231
148257
|
function filterGitTagOutput(result, level) {
|
|
148232
148258
|
if (level === "minimal") {
|
|
148233
148259
|
return {
|
|
148234
148260
|
success: result.success,
|
|
148235
|
-
mode: result.mode
|
|
148261
|
+
mode: result.mode,
|
|
148262
|
+
...result.signed !== undefined && { signed: result.signed },
|
|
148263
|
+
...result.signingWarning && { signingWarning: result.signingWarning }
|
|
148236
148264
|
};
|
|
148237
148265
|
}
|
|
148238
148266
|
return result;
|
|
@@ -151098,44 +151126,115 @@ var RingBuffer = class {
|
|
|
151098
151126
|
}
|
|
151099
151127
|
};
|
|
151100
151128
|
|
|
151129
|
+
// node_modules/@hono/node-server/dist/constants-BLSFu_RU.mjs
|
|
151130
|
+
var X_ALREADY_SENT = "x-hono-already-sent";
|
|
151131
|
+
|
|
151132
|
+
// node_modules/@hono/node-server/dist/index.mjs
|
|
151133
|
+
import { STATUS_CODES, createServer } from "node:http";
|
|
151134
|
+
import { Http2ServerRequest, constants } from "node:http2";
|
|
151135
|
+
import { Readable } from "node:stream";
|
|
151136
|
+
|
|
151137
|
+
// node_modules/hono/dist/helper/websocket/index.js
|
|
151138
|
+
var WSContext = class {
|
|
151139
|
+
#init;
|
|
151140
|
+
constructor(init) {
|
|
151141
|
+
this.#init = init;
|
|
151142
|
+
this.raw = init.raw;
|
|
151143
|
+
this.url = init.url ? new URL(init.url) : null;
|
|
151144
|
+
this.protocol = init.protocol ?? null;
|
|
151145
|
+
}
|
|
151146
|
+
send(source, options) {
|
|
151147
|
+
this.#init.send(source, options ?? {});
|
|
151148
|
+
}
|
|
151149
|
+
raw;
|
|
151150
|
+
binaryType = "arraybuffer";
|
|
151151
|
+
get readyState() {
|
|
151152
|
+
return this.#init.readyState;
|
|
151153
|
+
}
|
|
151154
|
+
url;
|
|
151155
|
+
protocol;
|
|
151156
|
+
close(code, reason) {
|
|
151157
|
+
this.#init.close(code, reason);
|
|
151158
|
+
}
|
|
151159
|
+
};
|
|
151160
|
+
var defineWebSocketHelper = (handler) => {
|
|
151161
|
+
return (...args) => {
|
|
151162
|
+
if (typeof args[0] === "function") {
|
|
151163
|
+
const [createEvents, options] = args;
|
|
151164
|
+
return async function upgradeWebSocket(c, next) {
|
|
151165
|
+
const events = await createEvents(c);
|
|
151166
|
+
const result = await handler(c, events, options);
|
|
151167
|
+
if (result) {
|
|
151168
|
+
return result;
|
|
151169
|
+
}
|
|
151170
|
+
await next();
|
|
151171
|
+
};
|
|
151172
|
+
} else {
|
|
151173
|
+
const [c, events, options] = args;
|
|
151174
|
+
return (async () => {
|
|
151175
|
+
const upgraded = await handler(c, events, options);
|
|
151176
|
+
if (!upgraded) {
|
|
151177
|
+
throw new Error("Failed to upgrade WebSocket");
|
|
151178
|
+
}
|
|
151179
|
+
return upgraded;
|
|
151180
|
+
})();
|
|
151181
|
+
}
|
|
151182
|
+
};
|
|
151183
|
+
};
|
|
151184
|
+
|
|
151101
151185
|
// node_modules/@hono/node-server/dist/index.mjs
|
|
151102
|
-
import { createServer as createServerHTTP } from "http";
|
|
151103
|
-
import { Http2ServerRequest as Http2ServerRequest2, constants as h2constants } from "http2";
|
|
151104
|
-
import { Http2ServerRequest } from "http2";
|
|
151105
|
-
import { Readable } from "stream";
|
|
151106
|
-
import crypto3 from "crypto";
|
|
151107
151186
|
var RequestError = class extends Error {
|
|
151108
151187
|
constructor(message, options) {
|
|
151109
151188
|
super(message, options);
|
|
151110
151189
|
this.name = "RequestError";
|
|
151111
151190
|
}
|
|
151112
151191
|
};
|
|
151192
|
+
var reValidRequestUrl = /^\/[!#$&-;=?-\[\]_a-z~]*$/;
|
|
151193
|
+
var reDotSegment = /\/\.\.?(?:[/?#]|$)/;
|
|
151194
|
+
var reValidHost = /^[a-z0-9._-]+(?::(?:[1-5]\d{3,4}|[6-9]\d{3}))?$/;
|
|
151195
|
+
var buildUrl2 = (scheme, host, incomingUrl) => {
|
|
151196
|
+
const url2 = `${scheme}://${host}${incomingUrl}`;
|
|
151197
|
+
if (!reValidHost.test(host)) {
|
|
151198
|
+
const urlObj = new URL(url2);
|
|
151199
|
+
if (urlObj.hostname.length !== host.length && urlObj.hostname !== (host.includes(":") ? host.replace(/:\d+$/, "") : host).toLowerCase())
|
|
151200
|
+
throw new RequestError("Invalid host header");
|
|
151201
|
+
return urlObj.href;
|
|
151202
|
+
} else if (incomingUrl.length === 0)
|
|
151203
|
+
return url2 + "/";
|
|
151204
|
+
else {
|
|
151205
|
+
if (incomingUrl.charCodeAt(0) !== 47)
|
|
151206
|
+
throw new RequestError("Invalid URL");
|
|
151207
|
+
if (!reValidRequestUrl.test(incomingUrl) || reDotSegment.test(incomingUrl))
|
|
151208
|
+
return new URL(url2).href;
|
|
151209
|
+
return url2;
|
|
151210
|
+
}
|
|
151211
|
+
};
|
|
151113
151212
|
var toRequestError = (e2) => {
|
|
151114
|
-
if (e2 instanceof RequestError)
|
|
151213
|
+
if (e2 instanceof RequestError)
|
|
151115
151214
|
return e2;
|
|
151116
|
-
}
|
|
151117
151215
|
return new RequestError(e2.message, { cause: e2 });
|
|
151118
151216
|
};
|
|
151119
151217
|
var GlobalRequest = global.Request;
|
|
151120
|
-
var
|
|
151218
|
+
var Request$1 = class extends GlobalRequest {
|
|
151121
151219
|
constructor(input, options) {
|
|
151122
151220
|
if (typeof input === "object" && getRequestCache in input) {
|
|
151221
|
+
const hasReplacementBody = options !== undefined && "body" in options && options.body != null;
|
|
151222
|
+
if (input[bodyConsumedDirectlyKey] && !hasReplacementBody)
|
|
151223
|
+
throw new TypeError("Cannot construct a Request with a Request object that has already been used.");
|
|
151123
151224
|
input = input[getRequestCache]();
|
|
151124
151225
|
}
|
|
151125
|
-
if (typeof options?.body?.getReader !== "undefined")
|
|
151226
|
+
if (typeof options?.body?.getReader !== "undefined")
|
|
151126
151227
|
options.duplex ??= "half";
|
|
151127
|
-
}
|
|
151128
151228
|
super(input, options);
|
|
151129
151229
|
}
|
|
151130
151230
|
};
|
|
151131
151231
|
var newHeadersFromIncoming = (incoming) => {
|
|
151132
151232
|
const headerRecord = [];
|
|
151133
151233
|
const rawHeaders = incoming.rawHeaders;
|
|
151134
|
-
for (let i2 = 0
|
|
151135
|
-
const
|
|
151136
|
-
if (key.charCodeAt(0) !== 58)
|
|
151137
|
-
headerRecord.push([key,
|
|
151138
|
-
}
|
|
151234
|
+
for (let i2 = 0, len = rawHeaders.length;i2 < len; i2 += 2) {
|
|
151235
|
+
const key = rawHeaders[i2];
|
|
151236
|
+
if (key.charCodeAt(0) !== 58)
|
|
151237
|
+
headerRecord.push([key, rawHeaders[i2 + 1]]);
|
|
151139
151238
|
}
|
|
151140
151239
|
return new Headers(headerRecord);
|
|
151141
151240
|
};
|
|
@@ -151148,55 +151247,213 @@ var newRequestFromIncoming = (method, url2, headers, incoming, abortController)
|
|
|
151148
151247
|
};
|
|
151149
151248
|
if (method === "TRACE") {
|
|
151150
151249
|
init.method = "GET";
|
|
151151
|
-
const req = new
|
|
151152
|
-
Object.defineProperty(req, "method", {
|
|
151153
|
-
|
|
151154
|
-
|
|
151155
|
-
}
|
|
151156
|
-
});
|
|
151250
|
+
const req = new Request$1(url2, init);
|
|
151251
|
+
Object.defineProperty(req, "method", { get() {
|
|
151252
|
+
return "TRACE";
|
|
151253
|
+
} });
|
|
151157
151254
|
return req;
|
|
151158
151255
|
}
|
|
151159
|
-
if (!(method === "GET" || method === "HEAD"))
|
|
151160
|
-
if ("rawBody" in incoming && incoming.rawBody instanceof Buffer)
|
|
151161
|
-
init.body = new ReadableStream({
|
|
151162
|
-
|
|
151163
|
-
|
|
151164
|
-
|
|
151165
|
-
|
|
151166
|
-
});
|
|
151167
|
-
} else if (incoming[wrapBodyStream]) {
|
|
151256
|
+
if (!(method === "GET" || method === "HEAD"))
|
|
151257
|
+
if ("rawBody" in incoming && incoming.rawBody instanceof Buffer)
|
|
151258
|
+
init.body = new ReadableStream({ start(controller) {
|
|
151259
|
+
controller.enqueue(incoming.rawBody);
|
|
151260
|
+
controller.close();
|
|
151261
|
+
} });
|
|
151262
|
+
else if (incoming[wrapBodyStream]) {
|
|
151168
151263
|
let reader;
|
|
151169
|
-
init.body = new ReadableStream({
|
|
151170
|
-
|
|
151171
|
-
|
|
151172
|
-
|
|
151173
|
-
|
|
151174
|
-
|
|
151175
|
-
|
|
151176
|
-
|
|
151177
|
-
|
|
151178
|
-
|
|
151179
|
-
} catch (error48) {
|
|
151180
|
-
controller.error(error48);
|
|
151181
|
-
}
|
|
151264
|
+
init.body = new ReadableStream({ async pull(controller) {
|
|
151265
|
+
try {
|
|
151266
|
+
reader ||= Readable.toWeb(incoming).getReader();
|
|
151267
|
+
const { done, value } = await reader.read();
|
|
151268
|
+
if (done)
|
|
151269
|
+
controller.close();
|
|
151270
|
+
else
|
|
151271
|
+
controller.enqueue(value);
|
|
151272
|
+
} catch (error48) {
|
|
151273
|
+
controller.error(error48);
|
|
151182
151274
|
}
|
|
151183
|
-
});
|
|
151184
|
-
} else
|
|
151275
|
+
} });
|
|
151276
|
+
} else
|
|
151185
151277
|
init.body = Readable.toWeb(incoming);
|
|
151186
|
-
|
|
151187
|
-
}
|
|
151188
|
-
return new Request3(url2, init);
|
|
151278
|
+
return new Request$1(url2, init);
|
|
151189
151279
|
};
|
|
151190
151280
|
var getRequestCache = Symbol("getRequestCache");
|
|
151191
151281
|
var requestCache = Symbol("requestCache");
|
|
151192
151282
|
var incomingKey = Symbol("incomingKey");
|
|
151193
151283
|
var urlKey = Symbol("urlKey");
|
|
151284
|
+
var methodKey = Symbol("methodKey");
|
|
151194
151285
|
var headersKey = Symbol("headersKey");
|
|
151195
151286
|
var abortControllerKey = Symbol("abortControllerKey");
|
|
151196
151287
|
var getAbortController = Symbol("getAbortController");
|
|
151288
|
+
var abortRequest = Symbol("abortRequest");
|
|
151289
|
+
var bodyBufferKey = Symbol("bodyBuffer");
|
|
151290
|
+
var bodyReadPromiseKey = Symbol("bodyReadPromise");
|
|
151291
|
+
var bodyConsumedDirectlyKey = Symbol("bodyConsumedDirectly");
|
|
151292
|
+
var bodyLockReaderKey = Symbol("bodyLockReader");
|
|
151293
|
+
var abortReasonKey = Symbol("abortReason");
|
|
151294
|
+
var newBodyUnusableError = () => {
|
|
151295
|
+
return /* @__PURE__ */ new TypeError("Body is unusable");
|
|
151296
|
+
};
|
|
151297
|
+
var rejectBodyUnusable = () => {
|
|
151298
|
+
return Promise.reject(newBodyUnusableError());
|
|
151299
|
+
};
|
|
151300
|
+
var textDecoder = new TextDecoder;
|
|
151301
|
+
var consumeBodyDirectOnce = (request) => {
|
|
151302
|
+
if (request[bodyConsumedDirectlyKey])
|
|
151303
|
+
return rejectBodyUnusable();
|
|
151304
|
+
request[bodyConsumedDirectlyKey] = true;
|
|
151305
|
+
};
|
|
151306
|
+
var toArrayBuffer = (buf) => {
|
|
151307
|
+
return buf.buffer.slice(buf.byteOffset, buf.byteOffset + buf.byteLength);
|
|
151308
|
+
};
|
|
151309
|
+
var contentType = (request) => {
|
|
151310
|
+
return (request[headersKey] ||= newHeadersFromIncoming(request[incomingKey])).get("content-type") || "";
|
|
151311
|
+
};
|
|
151312
|
+
var methodTokenRegExp = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;
|
|
151313
|
+
var normalizeIncomingMethod = (method) => {
|
|
151314
|
+
if (typeof method !== "string" || method.length === 0)
|
|
151315
|
+
return "GET";
|
|
151316
|
+
switch (method) {
|
|
151317
|
+
case "DELETE":
|
|
151318
|
+
case "GET":
|
|
151319
|
+
case "HEAD":
|
|
151320
|
+
case "OPTIONS":
|
|
151321
|
+
case "POST":
|
|
151322
|
+
case "PUT":
|
|
151323
|
+
return method;
|
|
151324
|
+
}
|
|
151325
|
+
const upper = method.toUpperCase();
|
|
151326
|
+
switch (upper) {
|
|
151327
|
+
case "DELETE":
|
|
151328
|
+
case "GET":
|
|
151329
|
+
case "HEAD":
|
|
151330
|
+
case "OPTIONS":
|
|
151331
|
+
case "POST":
|
|
151332
|
+
case "PUT":
|
|
151333
|
+
return upper;
|
|
151334
|
+
default:
|
|
151335
|
+
return method;
|
|
151336
|
+
}
|
|
151337
|
+
};
|
|
151338
|
+
var validateDirectReadMethod = (method) => {
|
|
151339
|
+
if (!methodTokenRegExp.test(method))
|
|
151340
|
+
return /* @__PURE__ */ new TypeError(`'${method}' is not a valid HTTP method.`);
|
|
151341
|
+
const normalized = method.toUpperCase();
|
|
151342
|
+
if (normalized === "CONNECT" || normalized === "TRACK" || normalized === "TRACE" && method !== "TRACE")
|
|
151343
|
+
return /* @__PURE__ */ new TypeError(`'${method}' HTTP method is unsupported.`);
|
|
151344
|
+
};
|
|
151345
|
+
var readBodyWithFastPath = (request, method, fromBuffer) => {
|
|
151346
|
+
if (request[bodyConsumedDirectlyKey])
|
|
151347
|
+
return rejectBodyUnusable();
|
|
151348
|
+
const methodName = request.method;
|
|
151349
|
+
if (methodName === "GET" || methodName === "HEAD")
|
|
151350
|
+
return request[getRequestCache]()[method]();
|
|
151351
|
+
const methodValidationError = validateDirectReadMethod(methodName);
|
|
151352
|
+
if (methodValidationError)
|
|
151353
|
+
return Promise.reject(methodValidationError);
|
|
151354
|
+
if (request[requestCache]) {
|
|
151355
|
+
if (methodName !== "TRACE")
|
|
151356
|
+
return request[requestCache][method]();
|
|
151357
|
+
}
|
|
151358
|
+
const alreadyUsedError = consumeBodyDirectOnce(request);
|
|
151359
|
+
if (alreadyUsedError)
|
|
151360
|
+
return alreadyUsedError;
|
|
151361
|
+
const raw2 = readRawBodyIfAvailable(request);
|
|
151362
|
+
if (raw2) {
|
|
151363
|
+
const result = Promise.resolve(fromBuffer(raw2, request));
|
|
151364
|
+
request[bodyBufferKey] = undefined;
|
|
151365
|
+
return result;
|
|
151366
|
+
}
|
|
151367
|
+
return readBodyDirect(request).then((buf) => {
|
|
151368
|
+
const result = fromBuffer(buf, request);
|
|
151369
|
+
request[bodyBufferKey] = undefined;
|
|
151370
|
+
return result;
|
|
151371
|
+
});
|
|
151372
|
+
};
|
|
151373
|
+
var readRawBodyIfAvailable = (request) => {
|
|
151374
|
+
const incoming = request[incomingKey];
|
|
151375
|
+
if ("rawBody" in incoming && incoming.rawBody instanceof Buffer)
|
|
151376
|
+
return incoming.rawBody;
|
|
151377
|
+
};
|
|
151378
|
+
var readBodyDirect = (request) => {
|
|
151379
|
+
if (request[bodyBufferKey])
|
|
151380
|
+
return Promise.resolve(request[bodyBufferKey]);
|
|
151381
|
+
if (request[bodyReadPromiseKey])
|
|
151382
|
+
return request[bodyReadPromiseKey];
|
|
151383
|
+
const incoming = request[incomingKey];
|
|
151384
|
+
if (Readable.isDisturbed(incoming))
|
|
151385
|
+
return rejectBodyUnusable();
|
|
151386
|
+
const promise3 = new Promise((resolve2, reject) => {
|
|
151387
|
+
const chunks = [];
|
|
151388
|
+
let settled = false;
|
|
151389
|
+
const finish = (callback) => {
|
|
151390
|
+
if (settled)
|
|
151391
|
+
return;
|
|
151392
|
+
settled = true;
|
|
151393
|
+
cleanup();
|
|
151394
|
+
callback();
|
|
151395
|
+
};
|
|
151396
|
+
const onData = (chunk) => {
|
|
151397
|
+
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
151398
|
+
};
|
|
151399
|
+
const onEnd = () => {
|
|
151400
|
+
finish(() => {
|
|
151401
|
+
const buffer = chunks.length === 1 ? chunks[0] : Buffer.concat(chunks);
|
|
151402
|
+
request[bodyBufferKey] = buffer;
|
|
151403
|
+
resolve2(buffer);
|
|
151404
|
+
});
|
|
151405
|
+
};
|
|
151406
|
+
const onError = (error48) => {
|
|
151407
|
+
finish(() => {
|
|
151408
|
+
reject(error48);
|
|
151409
|
+
});
|
|
151410
|
+
};
|
|
151411
|
+
const onClose = () => {
|
|
151412
|
+
if (incoming.readableEnded) {
|
|
151413
|
+
onEnd();
|
|
151414
|
+
return;
|
|
151415
|
+
}
|
|
151416
|
+
finish(() => {
|
|
151417
|
+
if (incoming.errored) {
|
|
151418
|
+
reject(incoming.errored);
|
|
151419
|
+
return;
|
|
151420
|
+
}
|
|
151421
|
+
const reason = request[abortReasonKey];
|
|
151422
|
+
if (reason !== undefined) {
|
|
151423
|
+
reject(reason instanceof Error ? reason : new Error(String(reason)));
|
|
151424
|
+
return;
|
|
151425
|
+
}
|
|
151426
|
+
reject(/* @__PURE__ */ new Error("Client connection prematurely closed."));
|
|
151427
|
+
});
|
|
151428
|
+
};
|
|
151429
|
+
const cleanup = () => {
|
|
151430
|
+
incoming.off("data", onData);
|
|
151431
|
+
incoming.off("end", onEnd);
|
|
151432
|
+
incoming.off("error", onError);
|
|
151433
|
+
incoming.off("close", onClose);
|
|
151434
|
+
request[bodyReadPromiseKey] = undefined;
|
|
151435
|
+
};
|
|
151436
|
+
incoming.on("data", onData);
|
|
151437
|
+
incoming.on("end", onEnd);
|
|
151438
|
+
incoming.on("error", onError);
|
|
151439
|
+
incoming.on("close", onClose);
|
|
151440
|
+
queueMicrotask(() => {
|
|
151441
|
+
if (settled)
|
|
151442
|
+
return;
|
|
151443
|
+
if (incoming.readableEnded)
|
|
151444
|
+
onEnd();
|
|
151445
|
+
else if (incoming.errored)
|
|
151446
|
+
onError(incoming.errored);
|
|
151447
|
+
else if (incoming.destroyed)
|
|
151448
|
+
onClose();
|
|
151449
|
+
});
|
|
151450
|
+
});
|
|
151451
|
+
request[bodyReadPromiseKey] = promise3;
|
|
151452
|
+
return promise3;
|
|
151453
|
+
};
|
|
151197
151454
|
var requestPrototype = {
|
|
151198
151455
|
get method() {
|
|
151199
|
-
return this[
|
|
151456
|
+
return this[methodKey];
|
|
151200
151457
|
},
|
|
151201
151458
|
get url() {
|
|
151202
151459
|
return this[urlKey];
|
|
@@ -151204,18 +151461,66 @@ var requestPrototype = {
|
|
|
151204
151461
|
get headers() {
|
|
151205
151462
|
return this[headersKey] ||= newHeadersFromIncoming(this[incomingKey]);
|
|
151206
151463
|
},
|
|
151464
|
+
[abortRequest](reason) {
|
|
151465
|
+
if (this[abortReasonKey] === undefined)
|
|
151466
|
+
this[abortReasonKey] = reason;
|
|
151467
|
+
const abortController = this[abortControllerKey];
|
|
151468
|
+
if (abortController && !abortController.signal.aborted)
|
|
151469
|
+
abortController.abort(reason);
|
|
151470
|
+
},
|
|
151207
151471
|
[getAbortController]() {
|
|
151208
|
-
this[
|
|
151472
|
+
this[abortControllerKey] ||= new AbortController;
|
|
151473
|
+
if (this[abortReasonKey] !== undefined && !this[abortControllerKey].signal.aborted)
|
|
151474
|
+
this[abortControllerKey].abort(this[abortReasonKey]);
|
|
151209
151475
|
return this[abortControllerKey];
|
|
151210
151476
|
},
|
|
151211
151477
|
[getRequestCache]() {
|
|
151212
|
-
this[
|
|
151213
|
-
|
|
151478
|
+
const abortController = this[getAbortController]();
|
|
151479
|
+
if (this[requestCache])
|
|
151480
|
+
return this[requestCache];
|
|
151481
|
+
const method = this.method;
|
|
151482
|
+
if (this[bodyConsumedDirectlyKey] && !(method === "GET" || method === "HEAD")) {
|
|
151483
|
+
this[bodyBufferKey] = undefined;
|
|
151484
|
+
const init = {
|
|
151485
|
+
method: method === "TRACE" ? "GET" : method,
|
|
151486
|
+
headers: this.headers,
|
|
151487
|
+
signal: abortController.signal
|
|
151488
|
+
};
|
|
151489
|
+
if (method !== "TRACE") {
|
|
151490
|
+
init.body = new ReadableStream({ start(c) {
|
|
151491
|
+
c.close();
|
|
151492
|
+
} });
|
|
151493
|
+
init.duplex = "half";
|
|
151494
|
+
}
|
|
151495
|
+
const req = new Request$1(this[urlKey], init);
|
|
151496
|
+
if (method === "TRACE")
|
|
151497
|
+
Object.defineProperty(req, "method", { get() {
|
|
151498
|
+
return "TRACE";
|
|
151499
|
+
} });
|
|
151500
|
+
return this[requestCache] = req;
|
|
151501
|
+
}
|
|
151502
|
+
return this[requestCache] = newRequestFromIncoming(this.method, this[urlKey], this.headers, this[incomingKey], abortController);
|
|
151503
|
+
},
|
|
151504
|
+
get body() {
|
|
151505
|
+
if (!this[bodyConsumedDirectlyKey])
|
|
151506
|
+
return this[getRequestCache]().body;
|
|
151507
|
+
const request = this[getRequestCache]();
|
|
151508
|
+
if (!this[bodyLockReaderKey] && request.body)
|
|
151509
|
+
this[bodyLockReaderKey] = request.body.getReader();
|
|
151510
|
+
return request.body;
|
|
151511
|
+
},
|
|
151512
|
+
get bodyUsed() {
|
|
151513
|
+
if (this[bodyConsumedDirectlyKey])
|
|
151514
|
+
return true;
|
|
151515
|
+
if (this[requestCache])
|
|
151516
|
+
return this[requestCache].bodyUsed;
|
|
151517
|
+
return false;
|
|
151214
151518
|
}
|
|
151215
151519
|
};
|
|
151520
|
+
Object.defineProperty(requestPrototype, "signal", { get() {
|
|
151521
|
+
return this[getAbortController]().signal;
|
|
151522
|
+
} });
|
|
151216
151523
|
[
|
|
151217
|
-
"body",
|
|
151218
|
-
"bodyUsed",
|
|
151219
151524
|
"cache",
|
|
151220
151525
|
"credentials",
|
|
151221
151526
|
"destination",
|
|
@@ -151224,75 +151529,93 @@ var requestPrototype = {
|
|
|
151224
151529
|
"redirect",
|
|
151225
151530
|
"referrer",
|
|
151226
151531
|
"referrerPolicy",
|
|
151227
|
-
"signal",
|
|
151228
151532
|
"keepalive"
|
|
151229
151533
|
].forEach((k) => {
|
|
151230
|
-
Object.defineProperty(requestPrototype, k, {
|
|
151231
|
-
|
|
151232
|
-
|
|
151233
|
-
|
|
151234
|
-
|
|
151235
|
-
|
|
151236
|
-
[
|
|
151237
|
-
|
|
151238
|
-
|
|
151239
|
-
return
|
|
151240
|
-
}
|
|
151241
|
-
|
|
151242
|
-
});
|
|
151243
|
-
|
|
151244
|
-
|
|
151245
|
-
|
|
151246
|
-
|
|
151247
|
-
|
|
151248
|
-
|
|
151249
|
-
|
|
151250
|
-
|
|
151251
|
-
|
|
151252
|
-
|
|
151253
|
-
}
|
|
151254
|
-
|
|
151534
|
+
Object.defineProperty(requestPrototype, k, { get() {
|
|
151535
|
+
return this[getRequestCache]()[k];
|
|
151536
|
+
} });
|
|
151537
|
+
});
|
|
151538
|
+
["clone", "formData"].forEach((k) => {
|
|
151539
|
+
Object.defineProperty(requestPrototype, k, { value: function() {
|
|
151540
|
+
if (this[bodyConsumedDirectlyKey]) {
|
|
151541
|
+
if (k === "clone")
|
|
151542
|
+
throw newBodyUnusableError();
|
|
151543
|
+
return rejectBodyUnusable();
|
|
151544
|
+
}
|
|
151545
|
+
return this[getRequestCache]()[k]();
|
|
151546
|
+
} });
|
|
151547
|
+
});
|
|
151548
|
+
Object.defineProperty(requestPrototype, "text", { value: function() {
|
|
151549
|
+
return readBodyWithFastPath(this, "text", (buf) => textDecoder.decode(buf));
|
|
151550
|
+
} });
|
|
151551
|
+
Object.defineProperty(requestPrototype, "arrayBuffer", { value: function() {
|
|
151552
|
+
return readBodyWithFastPath(this, "arrayBuffer", (buf) => toArrayBuffer(buf));
|
|
151553
|
+
} });
|
|
151554
|
+
Object.defineProperty(requestPrototype, "blob", { value: function() {
|
|
151555
|
+
return readBodyWithFastPath(this, "blob", (buf, request) => {
|
|
151556
|
+
const type = contentType(request);
|
|
151557
|
+
const init = type ? { headers: { "content-type": type } } : undefined;
|
|
151558
|
+
return new Response(buf, init).blob();
|
|
151559
|
+
});
|
|
151560
|
+
} });
|
|
151561
|
+
Object.defineProperty(requestPrototype, "json", { value: function() {
|
|
151562
|
+
if (this[bodyConsumedDirectlyKey])
|
|
151563
|
+
return rejectBodyUnusable();
|
|
151564
|
+
return this.text().then(JSON.parse);
|
|
151565
|
+
} });
|
|
151566
|
+
Object.defineProperty(requestPrototype, Symbol.for("nodejs.util.inspect.custom"), { value: function(depth, options, inspectFn) {
|
|
151567
|
+
return `Request (lightweight) ${inspectFn({
|
|
151568
|
+
method: this.method,
|
|
151569
|
+
url: this.url,
|
|
151570
|
+
headers: this.headers,
|
|
151571
|
+
nativeRequest: this[requestCache]
|
|
151572
|
+
}, {
|
|
151573
|
+
...options,
|
|
151574
|
+
depth: depth == null ? null : depth - 1
|
|
151575
|
+
})}`;
|
|
151576
|
+
} });
|
|
151577
|
+
Object.setPrototypeOf(requestPrototype, Request$1.prototype);
|
|
151255
151578
|
var newRequest = (incoming, defaultHostname) => {
|
|
151256
151579
|
const req = Object.create(requestPrototype);
|
|
151257
151580
|
req[incomingKey] = incoming;
|
|
151581
|
+
req[methodKey] = normalizeIncomingMethod(incoming.method);
|
|
151258
151582
|
const incomingUrl = incoming.url || "";
|
|
151259
151583
|
if (incomingUrl[0] !== "/" && (incomingUrl.startsWith("http://") || incomingUrl.startsWith("https://"))) {
|
|
151260
|
-
if (incoming instanceof Http2ServerRequest)
|
|
151584
|
+
if (incoming instanceof Http2ServerRequest)
|
|
151261
151585
|
throw new RequestError("Absolute URL for :path is not allowed in HTTP/2");
|
|
151262
|
-
}
|
|
151263
151586
|
try {
|
|
151264
|
-
|
|
151265
|
-
req[urlKey] = url22.href;
|
|
151587
|
+
req[urlKey] = new URL(incomingUrl).href;
|
|
151266
151588
|
} catch (e2) {
|
|
151267
151589
|
throw new RequestError("Invalid absolute URL", { cause: e2 });
|
|
151268
151590
|
}
|
|
151269
151591
|
return req;
|
|
151270
151592
|
}
|
|
151271
151593
|
const host = (incoming instanceof Http2ServerRequest ? incoming.authority : incoming.headers.host) || defaultHostname;
|
|
151272
|
-
if (!host)
|
|
151594
|
+
if (!host)
|
|
151273
151595
|
throw new RequestError("Missing host header");
|
|
151274
|
-
}
|
|
151275
151596
|
let scheme;
|
|
151276
151597
|
if (incoming instanceof Http2ServerRequest) {
|
|
151277
151598
|
scheme = incoming.scheme;
|
|
151278
|
-
if (!(scheme === "http" || scheme === "https"))
|
|
151599
|
+
if (!(scheme === "http" || scheme === "https"))
|
|
151279
151600
|
throw new RequestError("Unsupported scheme");
|
|
151280
|
-
|
|
151281
|
-
} else {
|
|
151601
|
+
} else
|
|
151282
151602
|
scheme = incoming.socket && incoming.socket.encrypted ? "https" : "http";
|
|
151603
|
+
try {
|
|
151604
|
+
req[urlKey] = buildUrl2(scheme, host, incomingUrl);
|
|
151605
|
+
} catch (e2) {
|
|
151606
|
+
if (e2 instanceof RequestError)
|
|
151607
|
+
throw e2;
|
|
151608
|
+
else
|
|
151609
|
+
throw new RequestError("Invalid URL", { cause: e2 });
|
|
151283
151610
|
}
|
|
151284
|
-
const url2 = new URL(`${scheme}://${host}${incomingUrl}`);
|
|
151285
|
-
if (url2.hostname.length !== host.length && url2.hostname !== host.replace(/:\d+$/, "")) {
|
|
151286
|
-
throw new RequestError("Invalid host header");
|
|
151287
|
-
}
|
|
151288
|
-
req[urlKey] = url2.href;
|
|
151289
151611
|
return req;
|
|
151290
151612
|
};
|
|
151613
|
+
var defaultContentType = "text/plain; charset=UTF-8";
|
|
151291
151614
|
var responseCache = Symbol("responseCache");
|
|
151292
151615
|
var getResponseCache = Symbol("getResponseCache");
|
|
151293
151616
|
var cacheKey = Symbol("cache");
|
|
151294
151617
|
var GlobalResponse = global.Response;
|
|
151295
|
-
var
|
|
151618
|
+
var Response$1 = class Response$12 {
|
|
151296
151619
|
#body;
|
|
151297
151620
|
#init;
|
|
151298
151621
|
[getResponseCache]() {
|
|
@@ -151302,7 +151625,7 @@ var Response22 = class _Response {
|
|
|
151302
151625
|
constructor(body, init) {
|
|
151303
151626
|
let headers;
|
|
151304
151627
|
this.#body = body;
|
|
151305
|
-
if (init instanceof
|
|
151628
|
+
if (init instanceof Response$12) {
|
|
151306
151629
|
const cachedGlobalResponse = init[responseCache];
|
|
151307
151630
|
if (cachedGlobalResponse) {
|
|
151308
151631
|
this.#init = cachedGlobalResponse;
|
|
@@ -151312,19 +151635,20 @@ var Response22 = class _Response {
|
|
|
151312
151635
|
this.#init = init.#init;
|
|
151313
151636
|
headers = new Headers(init.#init.headers);
|
|
151314
151637
|
}
|
|
151315
|
-
} else
|
|
151638
|
+
} else
|
|
151316
151639
|
this.#init = init;
|
|
151317
|
-
|
|
151318
|
-
|
|
151319
|
-
|
|
151320
|
-
|
|
151640
|
+
if (body == null || typeof body === "string" || typeof body?.getReader !== "undefined" || body instanceof Blob || body instanceof Uint8Array)
|
|
151641
|
+
this[cacheKey] = [
|
|
151642
|
+
init?.status || 200,
|
|
151643
|
+
body ?? null,
|
|
151644
|
+
headers || init?.headers
|
|
151645
|
+
];
|
|
151321
151646
|
}
|
|
151322
151647
|
get headers() {
|
|
151323
151648
|
const cache = this[cacheKey];
|
|
151324
151649
|
if (cache) {
|
|
151325
|
-
if (!(cache[2] instanceof Headers))
|
|
151326
|
-
cache[2] = new Headers(cache[2] || { "content-type":
|
|
151327
|
-
}
|
|
151650
|
+
if (!(cache[2] instanceof Headers))
|
|
151651
|
+
cache[2] = new Headers(cache[2] || (cache[1] === null ? undefined : { "content-type": defaultContentType }));
|
|
151328
151652
|
return cache[2];
|
|
151329
151653
|
}
|
|
151330
151654
|
return this[getResponseCache]().headers;
|
|
@@ -151337,33 +151661,93 @@ var Response22 = class _Response {
|
|
|
151337
151661
|
return status >= 200 && status < 300;
|
|
151338
151662
|
}
|
|
151339
151663
|
};
|
|
151340
|
-
[
|
|
151341
|
-
|
|
151342
|
-
|
|
151343
|
-
|
|
151344
|
-
|
|
151345
|
-
|
|
151664
|
+
[
|
|
151665
|
+
"body",
|
|
151666
|
+
"bodyUsed",
|
|
151667
|
+
"redirected",
|
|
151668
|
+
"statusText",
|
|
151669
|
+
"trailers",
|
|
151670
|
+
"type",
|
|
151671
|
+
"url"
|
|
151672
|
+
].forEach((k) => {
|
|
151673
|
+
Object.defineProperty(Response$1.prototype, k, { get() {
|
|
151674
|
+
return this[getResponseCache]()[k];
|
|
151675
|
+
} });
|
|
151346
151676
|
});
|
|
151347
|
-
[
|
|
151348
|
-
|
|
151349
|
-
|
|
151350
|
-
|
|
151351
|
-
|
|
151352
|
-
|
|
151677
|
+
[
|
|
151678
|
+
"arrayBuffer",
|
|
151679
|
+
"blob",
|
|
151680
|
+
"clone",
|
|
151681
|
+
"formData",
|
|
151682
|
+
"json",
|
|
151683
|
+
"text"
|
|
151684
|
+
].forEach((k) => {
|
|
151685
|
+
Object.defineProperty(Response$1.prototype, k, { value: function() {
|
|
151686
|
+
return this[getResponseCache]()[k]();
|
|
151687
|
+
} });
|
|
151353
151688
|
});
|
|
151354
|
-
Object.defineProperty(
|
|
151355
|
-
|
|
151356
|
-
|
|
151357
|
-
|
|
151358
|
-
|
|
151359
|
-
|
|
151360
|
-
|
|
151361
|
-
|
|
151362
|
-
|
|
151363
|
-
}
|
|
151689
|
+
Object.defineProperty(Response$1.prototype, Symbol.for("nodejs.util.inspect.custom"), { value: function(depth, options, inspectFn) {
|
|
151690
|
+
return `Response (lightweight) ${inspectFn({
|
|
151691
|
+
status: this.status,
|
|
151692
|
+
headers: this.headers,
|
|
151693
|
+
ok: this.ok,
|
|
151694
|
+
nativeResponse: this[responseCache]
|
|
151695
|
+
}, {
|
|
151696
|
+
...options,
|
|
151697
|
+
depth: depth == null ? null : depth - 1
|
|
151698
|
+
})}`;
|
|
151699
|
+
} });
|
|
151700
|
+
Object.setPrototypeOf(Response$1, GlobalResponse);
|
|
151701
|
+
Object.setPrototypeOf(Response$1.prototype, GlobalResponse.prototype);
|
|
151702
|
+
var validRedirectUrl = /^https?:\/\/[!#-;=?-[\]_a-z~A-Z]+$/;
|
|
151703
|
+
var parseRedirectUrl = (url2) => {
|
|
151704
|
+
if (url2 instanceof URL)
|
|
151705
|
+
return url2.href;
|
|
151706
|
+
if (validRedirectUrl.test(url2))
|
|
151707
|
+
return url2;
|
|
151708
|
+
return new URL(url2).href;
|
|
151709
|
+
};
|
|
151710
|
+
var validRedirectStatuses = new Set([
|
|
151711
|
+
301,
|
|
151712
|
+
302,
|
|
151713
|
+
303,
|
|
151714
|
+
307,
|
|
151715
|
+
308
|
|
151716
|
+
]);
|
|
151717
|
+
Object.defineProperty(Response$1, "redirect", {
|
|
151718
|
+
value: function redirect(url2, status = 302) {
|
|
151719
|
+
if (!validRedirectStatuses.has(status))
|
|
151720
|
+
throw new RangeError("Invalid status code");
|
|
151721
|
+
return new Response$1(null, {
|
|
151722
|
+
status,
|
|
151723
|
+
headers: { location: parseRedirectUrl(url2) }
|
|
151724
|
+
});
|
|
151725
|
+
},
|
|
151726
|
+
writable: true,
|
|
151727
|
+
configurable: true
|
|
151728
|
+
});
|
|
151729
|
+
Object.defineProperty(Response$1, "json", {
|
|
151730
|
+
value: function json2(data, init) {
|
|
151731
|
+
const body = JSON.stringify(data);
|
|
151732
|
+
if (body === undefined)
|
|
151733
|
+
throw new TypeError("The data is not JSON serializable");
|
|
151734
|
+
const initHeaders = init?.headers;
|
|
151735
|
+
let headers;
|
|
151736
|
+
if (initHeaders) {
|
|
151737
|
+
headers = new Headers(initHeaders);
|
|
151738
|
+
if (!headers.has("content-type"))
|
|
151739
|
+
headers.set("content-type", "application/json");
|
|
151740
|
+
} else
|
|
151741
|
+
headers = { "content-type": "application/json" };
|
|
151742
|
+
return new Response$1(body, {
|
|
151743
|
+
status: init?.status ?? 200,
|
|
151744
|
+
statusText: init?.statusText,
|
|
151745
|
+
headers
|
|
151746
|
+
});
|
|
151747
|
+
},
|
|
151748
|
+
writable: true,
|
|
151749
|
+
configurable: true
|
|
151364
151750
|
});
|
|
151365
|
-
Object.setPrototypeOf(Response22, GlobalResponse);
|
|
151366
|
-
Object.setPrototypeOf(Response22.prototype, GlobalResponse.prototype);
|
|
151367
151751
|
async function readWithoutBlocking(readPromise) {
|
|
151368
151752
|
return Promise.race([readPromise, Promise.resolve().then(() => Promise.resolve(undefined))]);
|
|
151369
151753
|
}
|
|
@@ -151379,71 +151763,64 @@ function writeFromReadableStreamDefaultReader(reader, writable, currentReadPromi
|
|
|
151379
151763
|
writable.off("error", cancel);
|
|
151380
151764
|
});
|
|
151381
151765
|
function handleStreamError(error48) {
|
|
151382
|
-
if (error48)
|
|
151766
|
+
if (error48)
|
|
151383
151767
|
writable.destroy(error48);
|
|
151384
|
-
}
|
|
151385
151768
|
}
|
|
151386
151769
|
function onDrain() {
|
|
151387
151770
|
reader.read().then(flow, handleStreamError);
|
|
151388
151771
|
}
|
|
151389
151772
|
function flow({ done, value }) {
|
|
151390
151773
|
try {
|
|
151391
|
-
if (done)
|
|
151774
|
+
if (done)
|
|
151392
151775
|
writable.end();
|
|
151393
|
-
|
|
151776
|
+
else if (!writable.write(value))
|
|
151394
151777
|
writable.once("drain", onDrain);
|
|
151395
|
-
|
|
151778
|
+
else
|
|
151396
151779
|
return reader.read().then(flow, handleStreamError);
|
|
151397
|
-
}
|
|
151398
151780
|
} catch (e2) {
|
|
151399
151781
|
handleStreamError(e2);
|
|
151400
151782
|
}
|
|
151401
151783
|
}
|
|
151402
151784
|
}
|
|
151403
151785
|
function writeFromReadableStream(stream2, writable) {
|
|
151404
|
-
if (stream2.locked)
|
|
151786
|
+
if (stream2.locked)
|
|
151405
151787
|
throw new TypeError("ReadableStream is locked.");
|
|
151406
|
-
|
|
151788
|
+
else if (writable.destroyed)
|
|
151407
151789
|
return;
|
|
151408
|
-
}
|
|
151409
151790
|
return writeFromReadableStreamDefaultReader(stream2.getReader(), writable);
|
|
151410
151791
|
}
|
|
151411
|
-
var buildOutgoingHttpHeaders = (headers) => {
|
|
151792
|
+
var buildOutgoingHttpHeaders = (headers, defaultContentType2) => {
|
|
151412
151793
|
const res = {};
|
|
151413
|
-
if (!(headers instanceof Headers))
|
|
151794
|
+
if (!(headers instanceof Headers))
|
|
151414
151795
|
headers = new Headers(headers ?? undefined);
|
|
151415
|
-
|
|
151416
|
-
|
|
151417
|
-
|
|
151418
|
-
|
|
151419
|
-
|
|
151420
|
-
|
|
151796
|
+
if (headers.has("set-cookie")) {
|
|
151797
|
+
const cookies = [];
|
|
151798
|
+
for (const [k, v] of headers)
|
|
151799
|
+
if (k === "set-cookie")
|
|
151800
|
+
cookies.push(v);
|
|
151801
|
+
else
|
|
151802
|
+
res[k] = v;
|
|
151803
|
+
if (cookies.length > 0)
|
|
151804
|
+
res["set-cookie"] = cookies;
|
|
151805
|
+
} else
|
|
151806
|
+
for (const [k, v] of headers)
|
|
151421
151807
|
res[k] = v;
|
|
151422
|
-
|
|
151423
|
-
|
|
151424
|
-
if (cookies.length > 0) {
|
|
151425
|
-
res["set-cookie"] = cookies;
|
|
151426
|
-
}
|
|
151427
|
-
res["content-type"] ??= "text/plain; charset=UTF-8";
|
|
151808
|
+
if (defaultContentType2)
|
|
151809
|
+
res["content-type"] ??= defaultContentType2;
|
|
151428
151810
|
return res;
|
|
151429
151811
|
};
|
|
151430
|
-
var X_ALREADY_SENT = "x-hono-already-sent";
|
|
151431
|
-
if (typeof global.crypto === "undefined") {
|
|
151432
|
-
global.crypto = crypto3;
|
|
151433
|
-
}
|
|
151434
151812
|
var outgoingEnded = Symbol("outgoingEnded");
|
|
151435
151813
|
var incomingDraining = Symbol("incomingDraining");
|
|
151436
151814
|
var DRAIN_TIMEOUT_MS = 500;
|
|
151437
151815
|
var MAX_DRAIN_BYTES = 64 * 1024 * 1024;
|
|
151438
151816
|
var drainIncoming = (incoming) => {
|
|
151439
151817
|
const incomingWithDrainState = incoming;
|
|
151440
|
-
if (incoming.destroyed || incomingWithDrainState[incomingDraining])
|
|
151818
|
+
if (incoming.destroyed || incomingWithDrainState[incomingDraining])
|
|
151441
151819
|
return;
|
|
151442
|
-
}
|
|
151443
151820
|
incomingWithDrainState[incomingDraining] = true;
|
|
151444
|
-
if (incoming instanceof
|
|
151821
|
+
if (incoming instanceof Http2ServerRequest) {
|
|
151445
151822
|
try {
|
|
151446
|
-
incoming.stream?.close?.(
|
|
151823
|
+
incoming.stream?.close?.(constants.NGHTTP2_NO_ERROR);
|
|
151447
151824
|
} catch {}
|
|
151448
151825
|
return;
|
|
151449
151826
|
}
|
|
@@ -151457,82 +151834,120 @@ var drainIncoming = (incoming) => {
|
|
|
151457
151834
|
const forceClose = () => {
|
|
151458
151835
|
cleanup();
|
|
151459
151836
|
const socket = incoming.socket;
|
|
151460
|
-
if (socket && !socket.destroyed)
|
|
151837
|
+
if (socket && !socket.destroyed)
|
|
151461
151838
|
socket.destroySoon();
|
|
151462
|
-
}
|
|
151463
151839
|
};
|
|
151464
151840
|
const timer = setTimeout(forceClose, DRAIN_TIMEOUT_MS);
|
|
151465
151841
|
timer.unref?.();
|
|
151466
151842
|
const onData = (chunk) => {
|
|
151467
151843
|
bytesRead += chunk.length;
|
|
151468
|
-
if (bytesRead > MAX_DRAIN_BYTES)
|
|
151844
|
+
if (bytesRead > MAX_DRAIN_BYTES)
|
|
151469
151845
|
forceClose();
|
|
151470
|
-
}
|
|
151471
151846
|
};
|
|
151472
151847
|
incoming.on("data", onData);
|
|
151473
151848
|
incoming.on("end", cleanup);
|
|
151474
151849
|
incoming.on("error", cleanup);
|
|
151475
151850
|
incoming.resume();
|
|
151476
151851
|
};
|
|
151477
|
-
var
|
|
151478
|
-
|
|
151479
|
-
|
|
151480
|
-
|
|
151481
|
-
|
|
151482
|
-
|
|
151852
|
+
var makeCloseHandler = (req, incoming, outgoing, needsBodyCleanup) => () => {
|
|
151853
|
+
if (incoming.errored)
|
|
151854
|
+
req[abortRequest](incoming.errored.toString());
|
|
151855
|
+
else if (!outgoing.writableFinished)
|
|
151856
|
+
req[abortRequest]("Client connection prematurely closed.");
|
|
151857
|
+
if (needsBodyCleanup && !incoming.readableEnded)
|
|
151858
|
+
setTimeout(() => {
|
|
151859
|
+
if (!incoming.readableEnded)
|
|
151860
|
+
setTimeout(() => {
|
|
151861
|
+
drainIncoming(incoming);
|
|
151862
|
+
});
|
|
151863
|
+
});
|
|
151864
|
+
};
|
|
151865
|
+
var isImmediateCacheableResponse = (res) => {
|
|
151866
|
+
if (!(cacheKey in res))
|
|
151867
|
+
return false;
|
|
151868
|
+
const body = res[cacheKey][1];
|
|
151869
|
+
return body === null || typeof body === "string" || body instanceof Uint8Array;
|
|
151870
|
+
};
|
|
151871
|
+
var handleRequestError = () => new Response(null, { status: 400 });
|
|
151872
|
+
var handleFetchError = (e2) => new Response(null, { status: e2 instanceof Error && (e2.name === "TimeoutError" || e2.constructor.name === "TimeoutError") ? 504 : 500 });
|
|
151483
151873
|
var handleResponseError = (e2, outgoing) => {
|
|
151484
151874
|
const err = e2 instanceof Error ? e2 : new Error("unknown error", { cause: e2 });
|
|
151485
|
-
if (err.code === "ERR_STREAM_PREMATURE_CLOSE")
|
|
151875
|
+
if (err.code === "ERR_STREAM_PREMATURE_CLOSE")
|
|
151486
151876
|
console.info("The user aborted a request.");
|
|
151487
|
-
|
|
151877
|
+
else {
|
|
151488
151878
|
console.error(e2);
|
|
151489
|
-
if (!outgoing.headersSent)
|
|
151879
|
+
if (!outgoing.headersSent)
|
|
151490
151880
|
outgoing.writeHead(500, { "Content-Type": "text/plain" });
|
|
151491
|
-
}
|
|
151492
151881
|
outgoing.end(`Error: ${err.message}`);
|
|
151493
151882
|
outgoing.destroy(err);
|
|
151494
151883
|
}
|
|
151495
151884
|
};
|
|
151496
151885
|
var flushHeaders = (outgoing) => {
|
|
151497
|
-
if ("flushHeaders" in outgoing && outgoing.writable)
|
|
151886
|
+
if ("flushHeaders" in outgoing && outgoing.writable)
|
|
151498
151887
|
outgoing.flushHeaders();
|
|
151499
|
-
}
|
|
151500
151888
|
};
|
|
151501
151889
|
var responseViaCache = async (res, outgoing) => {
|
|
151502
151890
|
let [status, body, header] = res[cacheKey];
|
|
151503
|
-
let hasContentLength = false;
|
|
151504
151891
|
if (!header) {
|
|
151505
|
-
|
|
151506
|
-
|
|
151892
|
+
if (body === null) {
|
|
151893
|
+
outgoing.writeHead(status);
|
|
151894
|
+
outgoing.end();
|
|
151895
|
+
} else if (typeof body === "string") {
|
|
151896
|
+
outgoing.writeHead(status, {
|
|
151897
|
+
"Content-Type": defaultContentType,
|
|
151898
|
+
"Content-Length": Buffer.byteLength(body)
|
|
151899
|
+
});
|
|
151900
|
+
outgoing.end(body);
|
|
151901
|
+
} else if (body instanceof Uint8Array) {
|
|
151902
|
+
outgoing.writeHead(status, {
|
|
151903
|
+
"Content-Type": defaultContentType,
|
|
151904
|
+
"Content-Length": body.byteLength
|
|
151905
|
+
});
|
|
151906
|
+
outgoing.end(body);
|
|
151907
|
+
} else if (body instanceof Blob) {
|
|
151908
|
+
outgoing.writeHead(status, {
|
|
151909
|
+
"Content-Type": defaultContentType,
|
|
151910
|
+
"Content-Length": body.size
|
|
151911
|
+
});
|
|
151912
|
+
outgoing.end(new Uint8Array(await body.arrayBuffer()));
|
|
151913
|
+
} else {
|
|
151914
|
+
outgoing.writeHead(status, { "Content-Type": defaultContentType });
|
|
151915
|
+
flushHeaders(outgoing);
|
|
151916
|
+
await writeFromReadableStream(body, outgoing)?.catch((e2) => handleResponseError(e2, outgoing));
|
|
151917
|
+
}
|
|
151918
|
+
outgoing[outgoingEnded]?.();
|
|
151919
|
+
return;
|
|
151920
|
+
}
|
|
151921
|
+
let hasContentLength = false;
|
|
151922
|
+
if (header instanceof Headers) {
|
|
151507
151923
|
hasContentLength = header.has("content-length");
|
|
151508
|
-
header = buildOutgoingHttpHeaders(header);
|
|
151924
|
+
header = buildOutgoingHttpHeaders(header, body === null ? undefined : defaultContentType);
|
|
151509
151925
|
} else if (Array.isArray(header)) {
|
|
151510
151926
|
const headerObj = new Headers(header);
|
|
151511
151927
|
hasContentLength = headerObj.has("content-length");
|
|
151512
|
-
header = buildOutgoingHttpHeaders(headerObj);
|
|
151513
|
-
} else
|
|
151514
|
-
for (const key in header)
|
|
151928
|
+
header = buildOutgoingHttpHeaders(headerObj, body === null ? undefined : defaultContentType);
|
|
151929
|
+
} else
|
|
151930
|
+
for (const key in header)
|
|
151515
151931
|
if (key.length === 14 && key.toLowerCase() === "content-length") {
|
|
151516
151932
|
hasContentLength = true;
|
|
151517
151933
|
break;
|
|
151518
151934
|
}
|
|
151519
|
-
}
|
|
151520
|
-
}
|
|
151521
151935
|
if (!hasContentLength) {
|
|
151522
|
-
if (typeof body === "string")
|
|
151936
|
+
if (typeof body === "string")
|
|
151523
151937
|
header["Content-Length"] = Buffer.byteLength(body);
|
|
151524
|
-
|
|
151938
|
+
else if (body instanceof Uint8Array)
|
|
151525
151939
|
header["Content-Length"] = body.byteLength;
|
|
151526
|
-
|
|
151940
|
+
else if (body instanceof Blob)
|
|
151527
151941
|
header["Content-Length"] = body.size;
|
|
151528
|
-
}
|
|
151529
151942
|
}
|
|
151530
151943
|
outgoing.writeHead(status, header);
|
|
151531
|
-
if (
|
|
151944
|
+
if (body == null)
|
|
151945
|
+
outgoing.end();
|
|
151946
|
+
else if (typeof body === "string" || body instanceof Uint8Array)
|
|
151532
151947
|
outgoing.end(body);
|
|
151533
|
-
|
|
151948
|
+
else if (body instanceof Blob)
|
|
151534
151949
|
outgoing.end(new Uint8Array(await body.arrayBuffer()));
|
|
151535
|
-
|
|
151950
|
+
else {
|
|
151536
151951
|
flushHeaders(outgoing);
|
|
151537
151952
|
await writeFromReadableStream(body, outgoing)?.catch((e2) => handleResponseError(e2, outgoing));
|
|
151538
151953
|
}
|
|
@@ -151540,25 +151955,21 @@ var responseViaCache = async (res, outgoing) => {
|
|
|
151540
151955
|
};
|
|
151541
151956
|
var isPromise = (res) => typeof res.then === "function";
|
|
151542
151957
|
var responseViaResponseObject = async (res, outgoing, options = {}) => {
|
|
151543
|
-
if (isPromise(res))
|
|
151544
|
-
if (options.errorHandler)
|
|
151958
|
+
if (isPromise(res))
|
|
151959
|
+
if (options.errorHandler)
|
|
151545
151960
|
try {
|
|
151546
151961
|
res = await res;
|
|
151547
151962
|
} catch (err) {
|
|
151548
151963
|
const errRes = await options.errorHandler(err);
|
|
151549
|
-
if (!errRes)
|
|
151964
|
+
if (!errRes)
|
|
151550
151965
|
return;
|
|
151551
|
-
}
|
|
151552
151966
|
res = errRes;
|
|
151553
151967
|
}
|
|
151554
|
-
|
|
151968
|
+
else
|
|
151555
151969
|
res = await res.catch(handleFetchError);
|
|
151556
|
-
|
|
151557
|
-
}
|
|
151558
|
-
if (cacheKey in res) {
|
|
151970
|
+
if (cacheKey in res)
|
|
151559
151971
|
return responseViaCache(res, outgoing);
|
|
151560
|
-
|
|
151561
|
-
const resHeaderRecord = buildOutgoingHttpHeaders(res.headers);
|
|
151972
|
+
const resHeaderRecord = buildOutgoingHttpHeaders(res.headers, res.body === null ? undefined : defaultContentType);
|
|
151562
151973
|
if (res.body) {
|
|
151563
151974
|
const reader = res.body.getReader();
|
|
151564
151975
|
const values = [];
|
|
@@ -151581,28 +151992,25 @@ var responseViaResponseObject = async (res, outgoing, options = {}) => {
|
|
|
151581
151992
|
break;
|
|
151582
151993
|
}
|
|
151583
151994
|
currentReadPromise = undefined;
|
|
151584
|
-
if (chunk.value)
|
|
151995
|
+
if (chunk.value)
|
|
151585
151996
|
values.push(chunk.value);
|
|
151586
|
-
}
|
|
151587
151997
|
if (chunk.done) {
|
|
151588
151998
|
done = true;
|
|
151589
151999
|
break;
|
|
151590
152000
|
}
|
|
151591
152001
|
}
|
|
151592
|
-
if (done && !("content-length" in resHeaderRecord))
|
|
152002
|
+
if (done && !("content-length" in resHeaderRecord))
|
|
151593
152003
|
resHeaderRecord["content-length"] = values.reduce((acc, value) => acc + value.length, 0);
|
|
151594
|
-
}
|
|
151595
152004
|
}
|
|
151596
152005
|
outgoing.writeHead(res.status, resHeaderRecord);
|
|
151597
152006
|
values.forEach((value) => {
|
|
151598
152007
|
outgoing.write(value);
|
|
151599
152008
|
});
|
|
151600
|
-
if (done)
|
|
152009
|
+
if (done)
|
|
151601
152010
|
outgoing.end();
|
|
151602
|
-
|
|
151603
|
-
if (values.length === 0)
|
|
152011
|
+
else {
|
|
152012
|
+
if (values.length === 0)
|
|
151604
152013
|
flushHeaders(outgoing);
|
|
151605
|
-
}
|
|
151606
152014
|
await writeFromReadableStreamDefaultReader(reader, outgoing, currentReadPromise);
|
|
151607
152015
|
}
|
|
151608
152016
|
} else if (resHeaderRecord[X_ALREADY_SENT]) {} else {
|
|
@@ -151613,81 +152021,63 @@ var responseViaResponseObject = async (res, outgoing, options = {}) => {
|
|
|
151613
152021
|
};
|
|
151614
152022
|
var getRequestListener = (fetchCallback, options = {}) => {
|
|
151615
152023
|
const autoCleanupIncoming = options.autoCleanupIncoming ?? true;
|
|
151616
|
-
if (options.overrideGlobalObjects !== false && global.Request !==
|
|
151617
|
-
Object.defineProperty(global, "Request", {
|
|
151618
|
-
|
|
151619
|
-
});
|
|
151620
|
-
Object.defineProperty(global, "Response", {
|
|
151621
|
-
value: Response22
|
|
151622
|
-
});
|
|
152024
|
+
if (options.overrideGlobalObjects !== false && global.Request !== Request$1) {
|
|
152025
|
+
Object.defineProperty(global, "Request", { value: Request$1 });
|
|
152026
|
+
Object.defineProperty(global, "Response", { value: Response$1 });
|
|
151623
152027
|
}
|
|
151624
152028
|
return async (incoming, outgoing) => {
|
|
151625
152029
|
let res, req;
|
|
152030
|
+
let needsBodyCleanup = false;
|
|
152031
|
+
let closeHandlerAttached = false;
|
|
152032
|
+
const ensureCloseHandler = () => {
|
|
152033
|
+
if (!req || closeHandlerAttached)
|
|
152034
|
+
return;
|
|
152035
|
+
closeHandlerAttached = true;
|
|
152036
|
+
outgoing.on("close", makeCloseHandler(req, incoming, outgoing, needsBodyCleanup));
|
|
152037
|
+
};
|
|
151626
152038
|
try {
|
|
151627
152039
|
req = newRequest(incoming, options.hostname);
|
|
151628
|
-
|
|
151629
|
-
if (
|
|
152040
|
+
needsBodyCleanup = autoCleanupIncoming && !(incoming.method === "GET" || incoming.method === "HEAD");
|
|
152041
|
+
if (needsBodyCleanup) {
|
|
151630
152042
|
incoming[wrapBodyStream] = true;
|
|
151631
|
-
|
|
151632
|
-
incomingEnded = true;
|
|
151633
|
-
});
|
|
151634
|
-
if (incoming instanceof Http2ServerRequest2) {
|
|
152043
|
+
if (incoming instanceof Http2ServerRequest)
|
|
151635
152044
|
outgoing[outgoingEnded] = () => {
|
|
151636
|
-
if (!
|
|
152045
|
+
if (!incoming.readableEnded)
|
|
151637
152046
|
setTimeout(() => {
|
|
151638
|
-
if (!
|
|
152047
|
+
if (!incoming.readableEnded)
|
|
151639
152048
|
setTimeout(() => {
|
|
151640
|
-
|
|
152049
|
+
incoming.destroy();
|
|
152050
|
+
outgoing.destroy();
|
|
151641
152051
|
});
|
|
151642
|
-
}
|
|
151643
152052
|
});
|
|
151644
|
-
}
|
|
151645
152053
|
};
|
|
151646
|
-
}
|
|
151647
|
-
outgoing.on("finish", () => {
|
|
151648
|
-
if (!incomingEnded) {
|
|
151649
|
-
drainIncoming(incoming);
|
|
151650
|
-
}
|
|
151651
|
-
});
|
|
151652
152054
|
}
|
|
151653
|
-
|
|
151654
|
-
|
|
151655
|
-
|
|
151656
|
-
if (incoming.errored) {
|
|
151657
|
-
req[abortControllerKey].abort(incoming.errored.toString());
|
|
151658
|
-
} else if (!outgoing.writableFinished) {
|
|
151659
|
-
req[abortControllerKey].abort("Client connection prematurely closed.");
|
|
151660
|
-
}
|
|
151661
|
-
}
|
|
151662
|
-
if (!incomingEnded) {
|
|
151663
|
-
setTimeout(() => {
|
|
151664
|
-
if (!incomingEnded) {
|
|
151665
|
-
setTimeout(() => {
|
|
151666
|
-
drainIncoming(incoming);
|
|
151667
|
-
});
|
|
151668
|
-
}
|
|
151669
|
-
});
|
|
151670
|
-
}
|
|
152055
|
+
res = fetchCallback(req, {
|
|
152056
|
+
incoming,
|
|
152057
|
+
outgoing
|
|
151671
152058
|
});
|
|
151672
|
-
res
|
|
151673
|
-
|
|
152059
|
+
if (!isPromise(res) && isImmediateCacheableResponse(res)) {
|
|
152060
|
+
if (needsBodyCleanup && !incoming.readableEnded)
|
|
152061
|
+
outgoing.once("finish", () => {
|
|
152062
|
+
if (!incoming.readableEnded)
|
|
152063
|
+
drainIncoming(incoming);
|
|
152064
|
+
});
|
|
151674
152065
|
return responseViaCache(res, outgoing);
|
|
151675
152066
|
}
|
|
152067
|
+
ensureCloseHandler();
|
|
151676
152068
|
} catch (e2) {
|
|
151677
|
-
if (!res)
|
|
152069
|
+
if (!res)
|
|
151678
152070
|
if (options.errorHandler) {
|
|
152071
|
+
ensureCloseHandler();
|
|
151679
152072
|
res = await options.errorHandler(req ? e2 : toRequestError(e2));
|
|
151680
|
-
if (!res)
|
|
152073
|
+
if (!res)
|
|
151681
152074
|
return;
|
|
151682
|
-
|
|
151683
|
-
} else if (!req) {
|
|
152075
|
+
} else if (!req)
|
|
151684
152076
|
res = handleRequestError();
|
|
151685
|
-
|
|
152077
|
+
else
|
|
151686
152078
|
res = handleFetchError(e2);
|
|
151687
|
-
|
|
151688
|
-
} else {
|
|
152079
|
+
else
|
|
151689
152080
|
return handleResponseError(e2, outgoing);
|
|
151690
|
-
}
|
|
151691
152081
|
}
|
|
151692
152082
|
try {
|
|
151693
152083
|
return await responseViaResponseObject(res, outgoing, options);
|
|
@@ -151696,6 +152086,167 @@ var getRequestListener = (fetchCallback, options = {}) => {
|
|
|
151696
152086
|
}
|
|
151697
152087
|
};
|
|
151698
152088
|
};
|
|
152089
|
+
var CloseEvent2 = globalThis.CloseEvent ?? class extends Event {
|
|
152090
|
+
#eventInitDict;
|
|
152091
|
+
constructor(type, eventInitDict = {}) {
|
|
152092
|
+
super(type, eventInitDict);
|
|
152093
|
+
this.#eventInitDict = eventInitDict;
|
|
152094
|
+
}
|
|
152095
|
+
get wasClean() {
|
|
152096
|
+
return this.#eventInitDict.wasClean ?? false;
|
|
152097
|
+
}
|
|
152098
|
+
get code() {
|
|
152099
|
+
return this.#eventInitDict.code ?? 0;
|
|
152100
|
+
}
|
|
152101
|
+
get reason() {
|
|
152102
|
+
return this.#eventInitDict.reason ?? "";
|
|
152103
|
+
}
|
|
152104
|
+
};
|
|
152105
|
+
var generateConnectionSymbol = () => Symbol("connection");
|
|
152106
|
+
var CONNECTION_SYMBOL_KEY = Symbol("CONNECTION_SYMBOL_KEY");
|
|
152107
|
+
var WAIT_FOR_WEBSOCKET_SYMBOL = Symbol("WAIT_FOR_WEBSOCKET_SYMBOL");
|
|
152108
|
+
var rejectUpgradeRequest = (socket, status) => {
|
|
152109
|
+
socket.end(`HTTP/1.1 ${status.toString()} ${STATUS_CODES[status] ?? ""}\r
|
|
152110
|
+
Connection: close\r
|
|
152111
|
+
Content-Length: 0\r
|
|
152112
|
+
\r
|
|
152113
|
+
`);
|
|
152114
|
+
};
|
|
152115
|
+
var createUpgradeRequest = (request) => {
|
|
152116
|
+
const protocol = request.socket.encrypted ? "https" : "http";
|
|
152117
|
+
const url2 = new URL(request.url ?? "/", `${protocol}://${request.headers.host ?? "localhost"}`);
|
|
152118
|
+
const headers = new Headers;
|
|
152119
|
+
for (const key in request.headers) {
|
|
152120
|
+
const value = request.headers[key];
|
|
152121
|
+
if (!value)
|
|
152122
|
+
continue;
|
|
152123
|
+
headers.append(key, Array.isArray(value) ? value[0] : value);
|
|
152124
|
+
}
|
|
152125
|
+
return new Request(url2, { headers });
|
|
152126
|
+
};
|
|
152127
|
+
var setupWebSocket = (options) => {
|
|
152128
|
+
const { server, fetchCallback, wss } = options;
|
|
152129
|
+
const waiterMap = /* @__PURE__ */ new Map;
|
|
152130
|
+
wss.on("connection", (ws, request) => {
|
|
152131
|
+
const waiter = waiterMap.get(request);
|
|
152132
|
+
if (waiter) {
|
|
152133
|
+
waiter.resolve(ws);
|
|
152134
|
+
waiterMap.delete(request);
|
|
152135
|
+
}
|
|
152136
|
+
});
|
|
152137
|
+
const waitForWebSocket = (request, connectionSymbol) => {
|
|
152138
|
+
return new Promise((resolve2) => {
|
|
152139
|
+
waiterMap.set(request, {
|
|
152140
|
+
resolve: resolve2,
|
|
152141
|
+
connectionSymbol
|
|
152142
|
+
});
|
|
152143
|
+
});
|
|
152144
|
+
};
|
|
152145
|
+
server.on("upgrade", async (request, socket, head2) => {
|
|
152146
|
+
if (request.headers.upgrade?.toLowerCase() !== "websocket")
|
|
152147
|
+
return;
|
|
152148
|
+
const env = {
|
|
152149
|
+
incoming: request,
|
|
152150
|
+
outgoing: undefined,
|
|
152151
|
+
wss,
|
|
152152
|
+
[WAIT_FOR_WEBSOCKET_SYMBOL]: waitForWebSocket
|
|
152153
|
+
};
|
|
152154
|
+
let status = 400;
|
|
152155
|
+
try {
|
|
152156
|
+
const response = await fetchCallback(createUpgradeRequest(request), env);
|
|
152157
|
+
if (response instanceof Response)
|
|
152158
|
+
status = response.status;
|
|
152159
|
+
} catch {
|
|
152160
|
+
if (server.listenerCount("upgrade") === 1)
|
|
152161
|
+
rejectUpgradeRequest(socket, 500);
|
|
152162
|
+
return;
|
|
152163
|
+
}
|
|
152164
|
+
const waiter = waiterMap.get(request);
|
|
152165
|
+
if (!waiter || waiter.connectionSymbol !== env[CONNECTION_SYMBOL_KEY]) {
|
|
152166
|
+
waiterMap.delete(request);
|
|
152167
|
+
if (server.listenerCount("upgrade") === 1)
|
|
152168
|
+
rejectUpgradeRequest(socket, status);
|
|
152169
|
+
return;
|
|
152170
|
+
}
|
|
152171
|
+
wss.handleUpgrade(request, socket, head2, (ws) => {
|
|
152172
|
+
wss.emit("connection", ws, request);
|
|
152173
|
+
});
|
|
152174
|
+
});
|
|
152175
|
+
server.on("close", () => {
|
|
152176
|
+
wss.close();
|
|
152177
|
+
});
|
|
152178
|
+
};
|
|
152179
|
+
var upgradeWebSocket = defineWebSocketHelper(async (c, events, options) => {
|
|
152180
|
+
if (c.req.header("upgrade")?.toLowerCase() !== "websocket")
|
|
152181
|
+
return;
|
|
152182
|
+
const env = c.env;
|
|
152183
|
+
const waitForWebSocket = env[WAIT_FOR_WEBSOCKET_SYMBOL];
|
|
152184
|
+
if (!waitForWebSocket || !env.incoming)
|
|
152185
|
+
return new Response(null, { status: 500 });
|
|
152186
|
+
const connectionSymbol = generateConnectionSymbol();
|
|
152187
|
+
env[CONNECTION_SYMBOL_KEY] = connectionSymbol;
|
|
152188
|
+
(async () => {
|
|
152189
|
+
const ws = await waitForWebSocket(env.incoming, connectionSymbol);
|
|
152190
|
+
const messagesReceivedInStarting = [];
|
|
152191
|
+
const bufferMessage = (data, isBinary) => {
|
|
152192
|
+
messagesReceivedInStarting.push([data, isBinary]);
|
|
152193
|
+
};
|
|
152194
|
+
ws.on("message", bufferMessage);
|
|
152195
|
+
const ctx = {
|
|
152196
|
+
binaryType: "arraybuffer",
|
|
152197
|
+
close(code, reason) {
|
|
152198
|
+
ws.close(code, reason);
|
|
152199
|
+
},
|
|
152200
|
+
protocol: ws.protocol,
|
|
152201
|
+
raw: ws,
|
|
152202
|
+
get readyState() {
|
|
152203
|
+
return ws.readyState;
|
|
152204
|
+
},
|
|
152205
|
+
send(source, opts) {
|
|
152206
|
+
ws.send(source, { compress: opts?.compress });
|
|
152207
|
+
},
|
|
152208
|
+
url: new URL(c.req.url)
|
|
152209
|
+
};
|
|
152210
|
+
try {
|
|
152211
|
+
events?.onOpen?.(new Event("open"), ctx);
|
|
152212
|
+
} catch (e2) {
|
|
152213
|
+
(options?.onError ?? console.error)(e2);
|
|
152214
|
+
}
|
|
152215
|
+
const handleMessage = (data, isBinary) => {
|
|
152216
|
+
const datas = Array.isArray(data) ? data : [data];
|
|
152217
|
+
for (const data2 of datas)
|
|
152218
|
+
try {
|
|
152219
|
+
events?.onMessage?.(new MessageEvent("message", { data: isBinary ? data2 instanceof ArrayBuffer ? data2 : data2.buffer.slice(data2.byteOffset, data2.byteOffset + data2.byteLength) : data2.toString("utf-8") }), ctx);
|
|
152220
|
+
} catch (e2) {
|
|
152221
|
+
(options?.onError ?? console.error)(e2);
|
|
152222
|
+
}
|
|
152223
|
+
};
|
|
152224
|
+
ws.off("message", bufferMessage);
|
|
152225
|
+
for (const message of messagesReceivedInStarting)
|
|
152226
|
+
handleMessage(...message);
|
|
152227
|
+
ws.on("message", (data, isBinary) => {
|
|
152228
|
+
handleMessage(data, isBinary);
|
|
152229
|
+
});
|
|
152230
|
+
ws.on("close", (code, reason) => {
|
|
152231
|
+
try {
|
|
152232
|
+
events?.onClose?.(new CloseEvent2("close", {
|
|
152233
|
+
code,
|
|
152234
|
+
reason: reason.toString()
|
|
152235
|
+
}), ctx);
|
|
152236
|
+
} catch (e2) {
|
|
152237
|
+
(options?.onError ?? console.error)(e2);
|
|
152238
|
+
}
|
|
152239
|
+
});
|
|
152240
|
+
ws.on("error", (error48) => {
|
|
152241
|
+
try {
|
|
152242
|
+
events?.onError?.(new ErrorEvent("error", { error: error48 }), ctx);
|
|
152243
|
+
} catch (e2) {
|
|
152244
|
+
(options?.onError ?? console.error)(e2);
|
|
152245
|
+
}
|
|
152246
|
+
});
|
|
152247
|
+
})();
|
|
152248
|
+
return new Response;
|
|
152249
|
+
});
|
|
151699
152250
|
var createAdaptorServer = (options) => {
|
|
151700
152251
|
const fetchCallback = options.fetch;
|
|
151701
152252
|
const requestListener = getRequestListener(fetchCallback, {
|
|
@@ -151703,8 +152254,16 @@ var createAdaptorServer = (options) => {
|
|
|
151703
152254
|
overrideGlobalObjects: options.overrideGlobalObjects,
|
|
151704
152255
|
autoCleanupIncoming: options.autoCleanupIncoming
|
|
151705
152256
|
});
|
|
151706
|
-
const
|
|
151707
|
-
|
|
152257
|
+
const server = (options.createServer || createServer)(options.serverOptions || {}, requestListener);
|
|
152258
|
+
if (options.websocket && options.websocket.server) {
|
|
152259
|
+
if (options.websocket.server.options.noServer !== true)
|
|
152260
|
+
throw new Error("WebSocket server must be created with { noServer: true } option");
|
|
152261
|
+
setupWebSocket({
|
|
152262
|
+
server,
|
|
152263
|
+
fetchCallback,
|
|
152264
|
+
wss: options.websocket.server
|
|
152265
|
+
});
|
|
152266
|
+
}
|
|
151708
152267
|
return server;
|
|
151709
152268
|
};
|
|
151710
152269
|
var serve = (options, listeningListener) => {
|
|
@@ -153162,11 +153721,11 @@ class RemoteJWKSet {
|
|
|
153162
153721
|
if (this.#pendingFetch && isCloudflareWorkers()) {
|
|
153163
153722
|
this.#pendingFetch = undefined;
|
|
153164
153723
|
}
|
|
153165
|
-
this.#pendingFetch ||= fetchJwks(this.#url.href, this.#headers, AbortSignal.timeout(this.#timeoutDuration), this.#customFetch).then((
|
|
153166
|
-
this.#local = createLocalJWKSet(
|
|
153724
|
+
this.#pendingFetch ||= fetchJwks(this.#url.href, this.#headers, AbortSignal.timeout(this.#timeoutDuration), this.#customFetch).then((json3) => {
|
|
153725
|
+
this.#local = createLocalJWKSet(json3);
|
|
153167
153726
|
if (this.#cache) {
|
|
153168
153727
|
this.#cache.uat = Date.now();
|
|
153169
|
-
this.#cache.jwks =
|
|
153728
|
+
this.#cache.jwks = json3;
|
|
153170
153729
|
}
|
|
153171
153730
|
this.#jwksTimestamp = Date.now();
|
|
153172
153731
|
this.#pendingFetch = undefined;
|
|
@@ -154143,8 +154702,8 @@ class StdioServerTransport {
|
|
|
154143
154702
|
}
|
|
154144
154703
|
send(message2) {
|
|
154145
154704
|
return new Promise((resolve2) => {
|
|
154146
|
-
const
|
|
154147
|
-
if (this._stdout.write(
|
|
154705
|
+
const json3 = serializeMessage(message2);
|
|
154706
|
+
if (this._stdout.write(json3)) {
|
|
154148
154707
|
resolve2();
|
|
154149
154708
|
} else {
|
|
154150
154709
|
this._stdout.once("drain", resolve2);
|