@tonyclaw/agent-inspector 4.0.8 → 4.0.10
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/.output/backend/nitro.json +1 -1
- package/.output/cli.js +915 -25970
- package/.output/server/_chunks/ssr-renderer.mjs +1 -38
- package/.output/server/_libs/@opentelemetry/semantic-conventions+[...].mjs +1 -2658
- package/.output/server/_libs/agent-base.mjs +2 -234
- package/.output/server/_libs/ajv-formats.mjs +1 -330
- package/.output/server/_libs/ajv.mjs +8 -6080
- package/.output/server/_libs/anthropic-ai__sdk.mjs +19 -6021
- package/.output/server/_libs/atomically.mjs +1 -155
- package/.output/server/_libs/base64-js.mjs +1 -102
- package/.output/server/_libs/bignumber.js.mjs +1 -1353
- package/.output/server/_libs/buffer-equal-constant-time.mjs +1 -38
- package/.output/server/_libs/conf.mjs +1 -635
- package/.output/server/_libs/cookie-es.mjs +1 -44
- package/.output/server/_libs/core-util-is.mjs +1 -75
- package/.output/server/_libs/data-uri-to-buffer.mjs +1 -39
- package/.output/server/_libs/debounce-fn.mjs +1 -69
- package/.output/server/_libs/debug.mjs +5 -547
- package/.output/server/_libs/dot-prop.mjs +1 -265
- package/.output/server/_libs/ecdsa-sig-formatter.mjs +1 -162
- package/.output/server/_libs/env-paths.mjs +1 -57
- package/.output/server/_libs/extend.mjs +1 -94
- package/.output/server/_libs/fast-deep-equal.mjs +1 -38
- package/.output/server/_libs/fast-uri.mjs +1 -812
- package/.output/server/_libs/fetch-blob.mjs +1 -287
- package/.output/server/_libs/formdata-polyfill.mjs +9 -86
- package/.output/server/_libs/gaxios.mjs +5 -926
- package/.output/server/_libs/gcp-metadata.mjs +1 -322
- package/.output/server/_libs/google-auth-library.mjs +16 -6339
- package/.output/server/_libs/google-logging-utils.mjs +1 -385
- package/.output/server/_libs/google__genai.mjs +13 -18034
- package/.output/server/_libs/h3-v2.mjs +2 -287
- package/.output/server/_libs/h3.mjs +2 -408
- package/.output/server/_libs/has-flag.mjs +1 -16
- package/.output/server/_libs/https-proxy-agent.mjs +7 -280
- package/.output/server/_libs/immediate.mjs +1 -74
- package/.output/server/_libs/inherits.mjs +1 -50
- package/.output/server/_libs/isarray.mjs +1 -14
- package/.output/server/_libs/isbot.mjs +1 -20
- package/.output/server/_libs/json-bigint.mjs +8 -413
- package/.output/server/_libs/json-schema-traverse.mjs +1 -91
- package/.output/server/_libs/jszip.mjs +2 -3051
- package/.output/server/_libs/jwa.mjs +3 -233
- package/.output/server/_libs/jws.mjs +1 -298
- package/.output/server/_libs/lie.mjs +1 -273
- package/.output/server/_libs/mariozechner__pi-agent-core.mjs +1 -824
- package/.output/server/_libs/mariozechner__pi-ai.mjs +34 -22887
- package/.output/server/_libs/mimic-function.mjs +2 -47
- package/.output/server/_libs/mistralai__mistralai.mjs +7 -32045
- package/.output/server/_libs/modelcontextprotocol__core.mjs +1 -1121
- package/.output/server/_libs/modelcontextprotocol__server.mjs +13 -13205
- package/.output/server/_libs/ms.mjs +1 -120
- package/.output/server/_libs/node-domexception.mjs +1 -17
- package/.output/server/_libs/node-fetch.mjs +4 -1578
- package/.output/server/_libs/ohash.mjs +1 -1
- package/.output/server/_libs/openai.mjs +23 -6766
- package/.output/server/_libs/opentelemetry__api.mjs +1 -1678
- package/.output/server/_libs/p-retry.mjs +1 -87
- package/.output/server/_libs/pako.mjs +1 -4223
- package/.output/server/_libs/partial-json.mjs +2 -244
- package/.output/server/_libs/process-nextick-args.mjs +1 -48
- package/.output/server/_libs/react-dom.mjs +62 -10778
- package/.output/server/_libs/react.mjs +1 -519
- package/.output/server/_libs/readable-stream.mjs +1 -1518
- package/.output/server/_libs/retry.mjs +1 -236
- package/.output/server/_libs/rou3.mjs +1 -14
- package/.output/server/_libs/safe-buffer.mjs +1 -126
- package/.output/server/_libs/semver.mjs +1 -1938
- package/.output/server/_libs/seroval-plugins.mjs +1 -58
- package/.output/server/_libs/seroval.mjs +3 -1775
- package/.output/server/_libs/setimmediate.mjs +1 -152
- package/.output/server/_libs/srvx.mjs +4 -1390
- package/.output/server/_libs/stubborn-fs.mjs +1 -91
- package/.output/server/_libs/stubborn-utils.mjs +1 -66
- package/.output/server/_libs/supports-color.mjs +1 -108
- package/.output/server/_libs/tanstack__history.mjs +1 -230
- package/.output/server/_libs/tanstack__react-router.mjs +1 -848
- package/.output/server/_libs/tanstack__react-store.mjs +1 -1
- package/.output/server/_libs/tanstack__router-core.mjs +1 -4839
- package/.output/server/_libs/typebox.mjs +3 -6596
- package/.output/server/_libs/ufo.mjs +1 -54
- package/.output/server/_libs/uint8array-extras.mjs +1 -69
- package/.output/server/_libs/util-deprecate.mjs +1 -12
- package/.output/server/_libs/web-streams-polyfill.mjs +1 -4282
- package/.output/server/_libs/when-exit.mjs +1 -53
- package/.output/server/_libs/ws.mjs +7 -3715
- package/.output/server/_libs/zod-to-json-schema.mjs +5 -1207
- package/.output/server/_libs/zod.mjs +59 -9958
- package/.output/server/_ssr/empty-plugin-adapters-C3Q1xu4u.mjs +1 -0
- package/.output/server/_ssr/index.mjs +2 -1512
- package/.output/server/_ssr/publicBasePathContext--TAQS2_5.mjs +1 -0
- package/.output/server/_ssr/router-B3jax4sN.mjs +341 -0
- package/.output/server/_ssr/start-PDVGOqUN.mjs +1 -0
- package/.output/server/_tanstack-start-manifest_v-D7cKwKzM.mjs +1 -0
- package/.output/server/index.mjs +1 -320
- package/.output/ui/assets/{CompareDrawer-DafpfgaT.js → CompareDrawer-D8fg0prL.js} +1 -1
- package/.output/ui/assets/{InspectorPet-Brsmmfzx.js → InspectorPet-BAY7SAee.js} +1 -1
- package/.output/ui/assets/{ProxyViewerContainer-D2pq1fUr.js → ProxyViewerContainer-BPITPKYp.js} +4 -4
- package/.output/ui/assets/{ReplayDialog-D4mXXgT9.js → ReplayDialog-NLGOmBsc.js} +1 -1
- package/.output/ui/assets/{RequestAnatomy-Ccnsq12U.js → RequestAnatomy-DBhRhis7.js} +1 -1
- package/.output/ui/assets/{ResponseView-CJv3vB5X.js → ResponseView-DNXX-dzj.js} +1 -1
- package/.output/ui/assets/{StreamingChunkSequence-CEkLnOF6.js → StreamingChunkSequence-CLiT5Xun.js} +1 -1
- package/.output/ui/assets/{_sessionId-C7s68UH3.js → _sessionId-CY0Jj2Xv.js} +1 -1
- package/.output/ui/assets/{_sessionId-DlG-yHoI.js → _sessionId-Cf0So2vy.js} +1 -1
- package/.output/ui/assets/{index-ChZZrVHa.js → index-BIMJaHOR.js} +1 -1
- package/.output/ui/assets/{index-CFqnSirZ.js → index-DLG3AIXx.js} +1 -1
- package/.output/ui/assets/{index-B0NCZQ93.js → index-DTj5ErVh.js} +2 -2
- package/.output/ui/assets/{index-Cqh47jeU.js → index-ujyZ2AyC.js} +1 -1
- package/.output/ui/assets/{json-viewer-DvpI0vbY.js → json-viewer-BwPQ5x7s.js} +1 -1
- package/.output/ui/assets/{jszip.min-5AG8hW2c.js → jszip.min-CDwYiHmS.js} +1 -1
- package/.output/ui/index.html +1 -1
- package/.output/workers/logFinalizer.worker.js +41 -17739
- package/.output/workers/sessionWorkerEntry.js +41 -17735
- package/package.json +7 -7
- package/.output/server/_ssr/empty-plugin-adapters-BFgPZ6_d.mjs +0 -6
- package/.output/server/_ssr/publicBasePathContext-IH2ilOfu.mjs +0 -176
- package/.output/server/_ssr/router-BDyF-OMB.mjs +0 -27187
- package/.output/server/_ssr/start-COQu_AgD.mjs +0 -57
- package/.output/server/_tanstack-start-manifest_v-ClTaMkEj.mjs +0 -4
|
@@ -1,322 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import require$$1 from "os";
|
|
3
|
-
import { r as requireSrc$1 } from "./gaxios.mjs";
|
|
4
|
-
import { r as requireJsonBigint } from "./json-bigint.mjs";
|
|
5
|
-
import { r as requireSrc$2 } from "./google-logging-utils.mjs";
|
|
6
|
-
var src = {};
|
|
7
|
-
var gcpResidency = {};
|
|
8
|
-
var hasRequiredGcpResidency;
|
|
9
|
-
function requireGcpResidency() {
|
|
10
|
-
if (hasRequiredGcpResidency) return gcpResidency;
|
|
11
|
-
hasRequiredGcpResidency = 1;
|
|
12
|
-
(function(exports$1) {
|
|
13
|
-
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
14
|
-
exports$1.GCE_LINUX_BIOS_PATHS = void 0;
|
|
15
|
-
exports$1.isGoogleCloudServerless = isGoogleCloudServerless;
|
|
16
|
-
exports$1.isGoogleComputeEngineLinux = isGoogleComputeEngineLinux;
|
|
17
|
-
exports$1.isGoogleComputeEngineMACAddress = isGoogleComputeEngineMACAddress;
|
|
18
|
-
exports$1.isGoogleComputeEngine = isGoogleComputeEngine;
|
|
19
|
-
exports$1.detectGCPResidency = detectGCPResidency;
|
|
20
|
-
const fs_1 = require$$1$1;
|
|
21
|
-
const os_1 = require$$1;
|
|
22
|
-
exports$1.GCE_LINUX_BIOS_PATHS = {
|
|
23
|
-
BIOS_DATE: "/sys/class/dmi/id/bios_date",
|
|
24
|
-
BIOS_VENDOR: "/sys/class/dmi/id/bios_vendor"
|
|
25
|
-
};
|
|
26
|
-
const GCE_MAC_ADDRESS_REGEX = /^42:01/;
|
|
27
|
-
function isGoogleCloudServerless() {
|
|
28
|
-
const isGFEnvironment = process.env.CLOUD_RUN_JOB || process.env.FUNCTION_NAME || process.env.K_SERVICE;
|
|
29
|
-
return !!isGFEnvironment;
|
|
30
|
-
}
|
|
31
|
-
function isGoogleComputeEngineLinux() {
|
|
32
|
-
if ((0, os_1.platform)() !== "linux")
|
|
33
|
-
return false;
|
|
34
|
-
try {
|
|
35
|
-
(0, fs_1.statSync)(exports$1.GCE_LINUX_BIOS_PATHS.BIOS_DATE);
|
|
36
|
-
const biosVendor = (0, fs_1.readFileSync)(exports$1.GCE_LINUX_BIOS_PATHS.BIOS_VENDOR, "utf8");
|
|
37
|
-
return /Google/.test(biosVendor);
|
|
38
|
-
} catch {
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
function isGoogleComputeEngineMACAddress() {
|
|
43
|
-
const interfaces = (0, os_1.networkInterfaces)();
|
|
44
|
-
for (const item of Object.values(interfaces)) {
|
|
45
|
-
if (!item)
|
|
46
|
-
continue;
|
|
47
|
-
for (const { mac } of item) {
|
|
48
|
-
if (GCE_MAC_ADDRESS_REGEX.test(mac)) {
|
|
49
|
-
return true;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
return false;
|
|
54
|
-
}
|
|
55
|
-
function isGoogleComputeEngine() {
|
|
56
|
-
return isGoogleComputeEngineLinux() || isGoogleComputeEngineMACAddress();
|
|
57
|
-
}
|
|
58
|
-
function detectGCPResidency() {
|
|
59
|
-
return isGoogleCloudServerless() || isGoogleComputeEngine();
|
|
60
|
-
}
|
|
61
|
-
})(gcpResidency);
|
|
62
|
-
return gcpResidency;
|
|
63
|
-
}
|
|
64
|
-
var hasRequiredSrc;
|
|
65
|
-
function requireSrc() {
|
|
66
|
-
if (hasRequiredSrc) return src;
|
|
67
|
-
hasRequiredSrc = 1;
|
|
68
|
-
(function(exports$1) {
|
|
69
|
-
var __createBinding = src && src.__createBinding || (Object.create ? (function(o, m, k, k2) {
|
|
70
|
-
if (k2 === void 0) k2 = k;
|
|
71
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
72
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
73
|
-
desc = { enumerable: true, get: function() {
|
|
74
|
-
return m[k];
|
|
75
|
-
} };
|
|
76
|
-
}
|
|
77
|
-
Object.defineProperty(o, k2, desc);
|
|
78
|
-
}) : (function(o, m, k, k2) {
|
|
79
|
-
if (k2 === void 0) k2 = k;
|
|
80
|
-
o[k2] = m[k];
|
|
81
|
-
}));
|
|
82
|
-
var __setModuleDefault = src && src.__setModuleDefault || (Object.create ? (function(o, v) {
|
|
83
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
84
|
-
}) : function(o, v) {
|
|
85
|
-
o["default"] = v;
|
|
86
|
-
});
|
|
87
|
-
var __importStar = src && src.__importStar || /* @__PURE__ */ (function() {
|
|
88
|
-
var ownKeys = function(o) {
|
|
89
|
-
ownKeys = Object.getOwnPropertyNames || function(o2) {
|
|
90
|
-
var ar = [];
|
|
91
|
-
for (var k in o2) if (Object.prototype.hasOwnProperty.call(o2, k)) ar[ar.length] = k;
|
|
92
|
-
return ar;
|
|
93
|
-
};
|
|
94
|
-
return ownKeys(o);
|
|
95
|
-
};
|
|
96
|
-
return function(mod) {
|
|
97
|
-
if (mod && mod.__esModule) return mod;
|
|
98
|
-
var result = {};
|
|
99
|
-
if (mod != null) {
|
|
100
|
-
for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
101
|
-
}
|
|
102
|
-
__setModuleDefault(result, mod);
|
|
103
|
-
return result;
|
|
104
|
-
};
|
|
105
|
-
})();
|
|
106
|
-
var __exportStar = src && src.__exportStar || function(m, exports$12) {
|
|
107
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports$12, p)) __createBinding(exports$12, m, p);
|
|
108
|
-
};
|
|
109
|
-
Object.defineProperty(exports$1, "__esModule", { value: true });
|
|
110
|
-
exports$1.gcpResidencyCache = exports$1.METADATA_SERVER_DETECTION = exports$1.HEADERS = exports$1.HEADER_VALUE = exports$1.HEADER_NAME = exports$1.SECONDARY_HOST_ADDRESS = exports$1.HOST_ADDRESS = exports$1.BASE_PATH = void 0;
|
|
111
|
-
exports$1.instance = instance;
|
|
112
|
-
exports$1.project = project;
|
|
113
|
-
exports$1.universe = universe;
|
|
114
|
-
exports$1.bulk = bulk;
|
|
115
|
-
exports$1.isAvailable = isAvailable;
|
|
116
|
-
exports$1.resetIsAvailableCache = resetIsAvailableCache;
|
|
117
|
-
exports$1.getGCPResidency = getGCPResidency;
|
|
118
|
-
exports$1.setGCPResidency = setGCPResidency;
|
|
119
|
-
exports$1.requestTimeout = requestTimeout;
|
|
120
|
-
const gaxios_1 = requireSrc$1();
|
|
121
|
-
const jsonBigint = requireJsonBigint();
|
|
122
|
-
const gcp_residency_1 = requireGcpResidency();
|
|
123
|
-
const logger = __importStar(requireSrc$2());
|
|
124
|
-
exports$1.BASE_PATH = "/computeMetadata/v1";
|
|
125
|
-
exports$1.HOST_ADDRESS = "http://169.254.169.254";
|
|
126
|
-
exports$1.SECONDARY_HOST_ADDRESS = "http://metadata.google.internal.";
|
|
127
|
-
exports$1.HEADER_NAME = "Metadata-Flavor";
|
|
128
|
-
exports$1.HEADER_VALUE = "Google";
|
|
129
|
-
exports$1.HEADERS = Object.freeze({ [exports$1.HEADER_NAME]: exports$1.HEADER_VALUE });
|
|
130
|
-
const log = logger.log("gcp-metadata");
|
|
131
|
-
exports$1.METADATA_SERVER_DETECTION = Object.freeze({
|
|
132
|
-
"assume-present": "don't try to ping the metadata server, but assume it's present",
|
|
133
|
-
none: "don't try to ping the metadata server, but don't try to use it either",
|
|
134
|
-
"bios-only": "treat the result of a BIOS probe as canonical (don't fall back to pinging)",
|
|
135
|
-
"ping-only": "skip the BIOS probe, and go straight to pinging"
|
|
136
|
-
});
|
|
137
|
-
function getBaseUrl(baseUrl) {
|
|
138
|
-
if (!baseUrl) {
|
|
139
|
-
baseUrl = process.env.GCE_METADATA_IP || process.env.GCE_METADATA_HOST || exports$1.HOST_ADDRESS;
|
|
140
|
-
}
|
|
141
|
-
if (!/^https?:\/\//.test(baseUrl)) {
|
|
142
|
-
baseUrl = `http://${baseUrl}`;
|
|
143
|
-
}
|
|
144
|
-
return new URL(exports$1.BASE_PATH, baseUrl).href;
|
|
145
|
-
}
|
|
146
|
-
function validate(options) {
|
|
147
|
-
Object.keys(options).forEach((key) => {
|
|
148
|
-
switch (key) {
|
|
149
|
-
case "params":
|
|
150
|
-
case "property":
|
|
151
|
-
case "headers":
|
|
152
|
-
break;
|
|
153
|
-
case "qs":
|
|
154
|
-
throw new Error("'qs' is not a valid configuration option. Please use 'params' instead.");
|
|
155
|
-
default:
|
|
156
|
-
throw new Error(`'${key}' is not a valid configuration option.`);
|
|
157
|
-
}
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
async function metadataAccessor(type, options = {}, noResponseRetries = 3, fastFail = false) {
|
|
161
|
-
const headers = new Headers(exports$1.HEADERS);
|
|
162
|
-
let metadataKey = "";
|
|
163
|
-
let params = {};
|
|
164
|
-
if (typeof type === "object") {
|
|
165
|
-
const metadataAccessor2 = type;
|
|
166
|
-
new Headers(metadataAccessor2.headers).forEach((value, key) => headers.set(key, value));
|
|
167
|
-
metadataKey = metadataAccessor2.metadataKey;
|
|
168
|
-
params = metadataAccessor2.params || params;
|
|
169
|
-
noResponseRetries = metadataAccessor2.noResponseRetries || noResponseRetries;
|
|
170
|
-
fastFail = metadataAccessor2.fastFail || fastFail;
|
|
171
|
-
} else {
|
|
172
|
-
metadataKey = type;
|
|
173
|
-
}
|
|
174
|
-
if (typeof options === "string") {
|
|
175
|
-
metadataKey += `/${options}`;
|
|
176
|
-
} else {
|
|
177
|
-
validate(options);
|
|
178
|
-
if (options.property) {
|
|
179
|
-
metadataKey += `/${options.property}`;
|
|
180
|
-
}
|
|
181
|
-
new Headers(options.headers).forEach((value, key) => headers.set(key, value));
|
|
182
|
-
params = options.params || params;
|
|
183
|
-
}
|
|
184
|
-
const requestMethod = fastFail ? fastFailMetadataRequest : gaxios_1.request;
|
|
185
|
-
const req = {
|
|
186
|
-
url: `${getBaseUrl()}/${metadataKey}`,
|
|
187
|
-
headers,
|
|
188
|
-
retryConfig: { noResponseRetries },
|
|
189
|
-
params,
|
|
190
|
-
responseType: "text",
|
|
191
|
-
timeout: requestTimeout()
|
|
192
|
-
};
|
|
193
|
-
log.info("instance request %j", req);
|
|
194
|
-
const res = await requestMethod(req);
|
|
195
|
-
log.info("instance metadata is %s", res.data);
|
|
196
|
-
const metadataFlavor = res.headers.get(exports$1.HEADER_NAME);
|
|
197
|
-
if (metadataFlavor !== exports$1.HEADER_VALUE) {
|
|
198
|
-
throw new RangeError(`Invalid response from metadata service: incorrect ${exports$1.HEADER_NAME} header. Expected '${exports$1.HEADER_VALUE}', got ${metadataFlavor ? `'${metadataFlavor}'` : "no header"}`);
|
|
199
|
-
}
|
|
200
|
-
if (typeof res.data === "string") {
|
|
201
|
-
try {
|
|
202
|
-
return jsonBigint.parse(res.data);
|
|
203
|
-
} catch {
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
return res.data;
|
|
207
|
-
}
|
|
208
|
-
async function fastFailMetadataRequest(options) {
|
|
209
|
-
const secondaryOptions = {
|
|
210
|
-
...options,
|
|
211
|
-
url: options.url?.toString().replace(getBaseUrl(), getBaseUrl(exports$1.SECONDARY_HOST_ADDRESS))
|
|
212
|
-
};
|
|
213
|
-
const r1 = (0, gaxios_1.request)(options);
|
|
214
|
-
const r2 = (0, gaxios_1.request)(secondaryOptions);
|
|
215
|
-
return Promise.any([r1, r2]);
|
|
216
|
-
}
|
|
217
|
-
function instance(options) {
|
|
218
|
-
return metadataAccessor("instance", options);
|
|
219
|
-
}
|
|
220
|
-
function project(options) {
|
|
221
|
-
return metadataAccessor("project", options);
|
|
222
|
-
}
|
|
223
|
-
function universe(options) {
|
|
224
|
-
return metadataAccessor("universe", options);
|
|
225
|
-
}
|
|
226
|
-
async function bulk(properties) {
|
|
227
|
-
const r = {};
|
|
228
|
-
await Promise.all(properties.map((item) => {
|
|
229
|
-
return (async () => {
|
|
230
|
-
const res = await metadataAccessor(item);
|
|
231
|
-
const key = item.metadataKey;
|
|
232
|
-
r[key] = res;
|
|
233
|
-
})();
|
|
234
|
-
}));
|
|
235
|
-
return r;
|
|
236
|
-
}
|
|
237
|
-
function detectGCPAvailableRetries() {
|
|
238
|
-
return process.env.DETECT_GCP_RETRIES ? Number(process.env.DETECT_GCP_RETRIES) : 0;
|
|
239
|
-
}
|
|
240
|
-
let cachedIsAvailableResponse;
|
|
241
|
-
async function isAvailable() {
|
|
242
|
-
if (process.env.METADATA_SERVER_DETECTION) {
|
|
243
|
-
const value = process.env.METADATA_SERVER_DETECTION.trim().toLocaleLowerCase();
|
|
244
|
-
if (!(value in exports$1.METADATA_SERVER_DETECTION)) {
|
|
245
|
-
throw new RangeError(`Unknown \`METADATA_SERVER_DETECTION\` env variable. Got \`${value}\`, but it should be \`${Object.keys(exports$1.METADATA_SERVER_DETECTION).join("`, `")}\`, or unset`);
|
|
246
|
-
}
|
|
247
|
-
switch (value) {
|
|
248
|
-
case "assume-present":
|
|
249
|
-
return true;
|
|
250
|
-
case "none":
|
|
251
|
-
return false;
|
|
252
|
-
case "bios-only":
|
|
253
|
-
return getGCPResidency();
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
try {
|
|
257
|
-
if (cachedIsAvailableResponse === void 0) {
|
|
258
|
-
cachedIsAvailableResponse = metadataAccessor(
|
|
259
|
-
"instance",
|
|
260
|
-
void 0,
|
|
261
|
-
detectGCPAvailableRetries(),
|
|
262
|
-
// If the default HOST_ADDRESS has been overridden, we should not
|
|
263
|
-
// make an effort to try SECONDARY_HOST_ADDRESS (as we are likely in
|
|
264
|
-
// a non-GCP environment):
|
|
265
|
-
!(process.env.GCE_METADATA_IP || process.env.GCE_METADATA_HOST)
|
|
266
|
-
);
|
|
267
|
-
}
|
|
268
|
-
await cachedIsAvailableResponse;
|
|
269
|
-
return true;
|
|
270
|
-
} catch (e) {
|
|
271
|
-
const err = e;
|
|
272
|
-
if (process.env.DEBUG_AUTH) {
|
|
273
|
-
console.info(err);
|
|
274
|
-
}
|
|
275
|
-
if (err.type === "request-timeout") {
|
|
276
|
-
return false;
|
|
277
|
-
}
|
|
278
|
-
if (err.response && err.response.status === 404) {
|
|
279
|
-
return false;
|
|
280
|
-
} else {
|
|
281
|
-
if (!(err.response && err.response.status === 404) && // A warning is emitted if we see an unexpected err.code, or err.code
|
|
282
|
-
// is not populated:
|
|
283
|
-
(!err.code || ![
|
|
284
|
-
"EHOSTDOWN",
|
|
285
|
-
"EHOSTUNREACH",
|
|
286
|
-
"ENETUNREACH",
|
|
287
|
-
"ENOENT",
|
|
288
|
-
"ENOTFOUND",
|
|
289
|
-
"ECONNREFUSED"
|
|
290
|
-
].includes(err.code.toString()))) {
|
|
291
|
-
let code = "UNKNOWN";
|
|
292
|
-
if (err.code)
|
|
293
|
-
code = err.code.toString();
|
|
294
|
-
process.emitWarning(`received unexpected error = ${err.message} code = ${code}`, "MetadataLookupWarning");
|
|
295
|
-
}
|
|
296
|
-
return false;
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
function resetIsAvailableCache() {
|
|
301
|
-
cachedIsAvailableResponse = void 0;
|
|
302
|
-
}
|
|
303
|
-
exports$1.gcpResidencyCache = null;
|
|
304
|
-
function getGCPResidency() {
|
|
305
|
-
if (exports$1.gcpResidencyCache === null) {
|
|
306
|
-
setGCPResidency();
|
|
307
|
-
}
|
|
308
|
-
return exports$1.gcpResidencyCache;
|
|
309
|
-
}
|
|
310
|
-
function setGCPResidency(value = null) {
|
|
311
|
-
exports$1.gcpResidencyCache = value !== null ? value : (0, gcp_residency_1.detectGCPResidency)();
|
|
312
|
-
}
|
|
313
|
-
function requestTimeout() {
|
|
314
|
-
return getGCPResidency() ? 0 : 3e3;
|
|
315
|
-
}
|
|
316
|
-
__exportStar(requireGcpResidency(), exports$1);
|
|
317
|
-
})(src);
|
|
318
|
-
return src;
|
|
319
|
-
}
|
|
320
|
-
export {
|
|
321
|
-
requireSrc as r
|
|
322
|
-
};
|
|
1
|
+
import X from"fs";import W from"os";import{r as Y}from"./gaxios.mjs";import{r as z}from"./json-bigint.mjs";import{r as J}from"./google-logging-utils.mjs";var c={},p={},H;function I(){return H||(H=1,(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.GCE_LINUX_BIOS_PATHS=void 0,e.isGoogleCloudServerless=R,e.isGoogleComputeEngineLinux=u,e.isGoogleComputeEngineMACAddress=g,e.isGoogleComputeEngine=T,e.detectGCPResidency=v;const f=X,S=W;e.GCE_LINUX_BIOS_PATHS={BIOS_DATE:"/sys/class/dmi/id/bios_date",BIOS_VENDOR:"/sys/class/dmi/id/bios_vendor"};const O=/^42:01/;function R(){return!!(process.env.CLOUD_RUN_JOB||process.env.FUNCTION_NAME||process.env.K_SERVICE)}function u(){if((0,S.platform)()!=="linux")return!1;try{(0,f.statSync)(e.GCE_LINUX_BIOS_PATHS.BIOS_DATE);const s=(0,f.readFileSync)(e.GCE_LINUX_BIOS_PATHS.BIOS_VENDOR,"utf8");return/Google/.test(s)}catch{return!1}}function g(){const s=(0,S.networkInterfaces)();for(const E of Object.values(s))if(E){for(const{mac:y}of E)if(O.test(y))return!0}return!1}function T(){return u()||g()}function v(){return R()||T()}})(p)),p}var M;function ee(){return M||(M=1,(function(e){var f=c&&c.__createBinding||(Object.create?(function(t,n,r,a){a===void 0&&(a=r);var i=Object.getOwnPropertyDescriptor(n,r);(!i||("get"in i?!n.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return n[r]}}),Object.defineProperty(t,a,i)}):(function(t,n,r,a){a===void 0&&(a=r),t[a]=n[r]})),S=c&&c.__setModuleDefault||(Object.create?(function(t,n){Object.defineProperty(t,"default",{enumerable:!0,value:n})}):function(t,n){t.default=n}),O=c&&c.__importStar||(function(){var t=function(n){return t=Object.getOwnPropertyNames||function(r){var a=[];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(a[a.length]=i);return a},t(n)};return function(n){if(n&&n.__esModule)return n;var r={};if(n!=null)for(var a=t(n),i=0;i<a.length;i++)a[i]!=="default"&&f(r,n,a[i]);return S(r,n),r}})(),R=c&&c.__exportStar||function(t,n){for(var r in t)r!=="default"&&!Object.prototype.hasOwnProperty.call(n,r)&&f(n,t,r)};Object.defineProperty(e,"__esModule",{value:!0}),e.gcpResidencyCache=e.METADATA_SERVER_DETECTION=e.HEADERS=e.HEADER_VALUE=e.HEADER_NAME=e.SECONDARY_HOST_ADDRESS=e.HOST_ADDRESS=e.BASE_PATH=void 0,e.instance=w,e.project=j,e.universe=q,e.bulk=B,e.isAvailable=L,e.resetIsAvailableCache=V,e.getGCPResidency=C,e.setGCPResidency=N,e.requestTimeout=b;const u=Y(),g=z(),T=I(),v=O(J());e.BASE_PATH="/computeMetadata/v1",e.HOST_ADDRESS="http://169.254.169.254",e.SECONDARY_HOST_ADDRESS="http://metadata.google.internal.",e.HEADER_NAME="Metadata-Flavor",e.HEADER_VALUE="Google",e.HEADERS=Object.freeze({[e.HEADER_NAME]:e.HEADER_VALUE});const s=v.log("gcp-metadata");e.METADATA_SERVER_DETECTION=Object.freeze({"assume-present":"don't try to ping the metadata server, but assume it's present",none:"don't try to ping the metadata server, but don't try to use it either","bios-only":"treat the result of a BIOS probe as canonical (don't fall back to pinging)","ping-only":"skip the BIOS probe, and go straight to pinging"});function E(t){return t||(t=process.env.GCE_METADATA_IP||process.env.GCE_METADATA_HOST||e.HOST_ADDRESS),/^https?:\/\//.test(t)||(t=`http://${t}`),new URL(e.BASE_PATH,t).href}function y(t){Object.keys(t).forEach(n=>{switch(n){case"params":case"property":case"headers":break;case"qs":throw new Error("'qs' is not a valid configuration option. Please use 'params' instead.");default:throw new Error(`'${n}' is not a valid configuration option.`)}})}async function d(t,n={},r=3,a=!1){const i=new Headers(e.HEADERS);let l="",_={};if(typeof t=="object"){const o=t;new Headers(o.headers).forEach((h,K)=>i.set(K,h)),l=o.metadataKey,_=o.params||_,r=o.noResponseRetries||r,a=o.fastFail||a}else l=t;typeof n=="string"?l+=`/${n}`:(y(n),n.property&&(l+=`/${n.property}`),new Headers(n.headers).forEach((o,h)=>i.set(h,o)),_=n.params||_);const F=a?P:u.request,G={url:`${E()}/${l}`,headers:i,retryConfig:{noResponseRetries:r},params:_,responseType:"text",timeout:b()};s.info("instance request %j",G);const A=await F(G);s.info("instance metadata is %s",A.data);const m=A.headers.get(e.HEADER_NAME);if(m!==e.HEADER_VALUE)throw new RangeError(`Invalid response from metadata service: incorrect ${e.HEADER_NAME} header. Expected '${e.HEADER_VALUE}', got ${m?`'${m}'`:"no header"}`);if(typeof A.data=="string")try{return g.parse(A.data)}catch{}return A.data}async function P(t){const n={...t,url:t.url?.toString().replace(E(),E(e.SECONDARY_HOST_ADDRESS))},r=(0,u.request)(t),a=(0,u.request)(n);return Promise.any([r,a])}function w(t){return d("instance",t)}function j(t){return d("project",t)}function q(t){return d("universe",t)}async function B(t){const n={};return await Promise.all(t.map(r=>(async()=>{const a=await d(r),i=r.metadataKey;n[i]=a})())),n}function U(){return process.env.DETECT_GCP_RETRIES?Number(process.env.DETECT_GCP_RETRIES):0}let D;async function L(){if(process.env.METADATA_SERVER_DETECTION){const t=process.env.METADATA_SERVER_DETECTION.trim().toLocaleLowerCase();if(!(t in e.METADATA_SERVER_DETECTION))throw new RangeError(`Unknown \`METADATA_SERVER_DETECTION\` env variable. Got \`${t}\`, but it should be \`${Object.keys(e.METADATA_SERVER_DETECTION).join("`, `")}\`, or unset`);switch(t){case"assume-present":return!0;case"none":return!1;case"bios-only":return C()}}try{return D===void 0&&(D=d("instance",void 0,U(),!(process.env.GCE_METADATA_IP||process.env.GCE_METADATA_HOST))),await D,!0}catch(t){const n=t;if(process.env.DEBUG_AUTH&&console.info(n),n.type==="request-timeout"||n.response&&n.response.status===404)return!1;if(!(n.response&&n.response.status===404)&&(!n.code||!["EHOSTDOWN","EHOSTUNREACH","ENETUNREACH","ENOENT","ENOTFOUND","ECONNREFUSED"].includes(n.code.toString()))){let r="UNKNOWN";n.code&&(r=n.code.toString()),process.emitWarning(`received unexpected error = ${n.message} code = ${r}`,"MetadataLookupWarning")}return!1}}function V(){D=void 0}e.gcpResidencyCache=null;function C(){return e.gcpResidencyCache===null&&N(),e.gcpResidencyCache}function N(t=null){e.gcpResidencyCache=t!==null?t:(0,T.detectGCPResidency)()}function b(){return C()?0:3e3}R(I(),e)})(c)),c}export{ee as r};
|