firebase-tools 15.26.0 → 15.27.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/lib/appcheck/api.js +19 -0
- package/lib/appcheck/providers.js +240 -0
- package/lib/commands/appcheck-apps-list.js +78 -0
- package/lib/commands/appcheck-debugtokens-create.js +2 -2
- package/lib/commands/appcheck-debugtokens-delete.js +2 -2
- package/lib/commands/appcheck-debugtokens-list.js +2 -2
- package/lib/commands/appcheck-prompts.js +55 -0
- package/lib/commands/appcheck-providers-get.js +73 -0
- package/lib/commands/appcheck-providers-list.js +67 -0
- package/lib/commands/appcheck-providers-set.js +96 -0
- package/lib/commands/ext-export.js +75 -3
- package/lib/commands/functions-kits-install.js +294 -0
- package/lib/commands/index.js +10 -0
- package/lib/crashlytics/filters.js +12 -4
- package/lib/crashlytics/reports.js +2 -0
- package/lib/crashlytics/types.js +8 -1
- package/lib/deploy/functions/backend.js +11 -1
- package/lib/deploy/functions/build.js +1 -1
- package/lib/deploy/functions/params.js +5 -1
- package/lib/deploy/functions/prepare.js +26 -13
- package/lib/deploy/functions/prompts.js +1 -1
- package/lib/deploy/functions/release/lifecycle.js +11 -0
- package/lib/deploy/functions/release/planner.js +5 -2
- package/lib/emulator/controller.js +1 -0
- package/lib/emulator/functionsEmulator.js +3 -1
- package/lib/experiments.js +11 -5
- package/lib/extensions/export.js +47 -0
- package/lib/functions/env.js +20 -7
- package/lib/functions/projectConfig.js +19 -11
- package/lib/functions/python.js +1 -1
- package/lib/gcp/runv2.js +1 -0
- package/lib/mcp/onemcp/index.js +2 -1
- package/lib/mcp/onemcp/onemcp_server.js +38 -11
- package/lib/mcp/prompts/crashlytics/connect.js +1 -1
- package/lib/mcp/resources/guides/crashlytics_issues.js +3 -3
- package/lib/mcp/resources/guides/crashlytics_reports.js +32 -11
- package/lib/mcp/tool.js +5 -0
- package/lib/mcp/tools/crashlytics/notes.js +3 -3
- package/lib/mcp/tools/crashlytics/reports.js +2 -0
- package/lib/mcp/util/crashlytics/availability.js +54 -1
- package/lib/serve/functions.js +1 -1
- package/lib/tsconfig.compile.tsbuildinfo +1 -1
- package/lib/tsconfig.publish.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/schema/firebase-config.json +3 -3
- package/templates/init/functions/typescript/index-kit-migration.ts +49 -0
- package/templates/init/functions/typescript/index-kit.ts +35 -0
- package/lib/appcheck/prompts.js +0 -41
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.EVENTARC_SOURCE_ENV = void 0;
|
|
3
|
+
exports.DECLARATIVE_SECURITY_ETAG_LABEL = exports.EVENTARC_SOURCE_ENV = void 0;
|
|
4
4
|
exports.discoverSecurityDetails = discoverSecurityDetails;
|
|
5
5
|
exports.prepare = prepare;
|
|
6
6
|
exports.resolveDefaultRegionsForBuild = resolveDefaultRegionsForBuild;
|
|
@@ -13,6 +13,7 @@ exports.loadCodebases = loadCodebases;
|
|
|
13
13
|
exports.warnIfNewGenkitFunctionIsMissingSecrets = warnIfNewGenkitFunctionIsMissingSecrets;
|
|
14
14
|
exports.ensureAllRequiredAPIsEnabled = ensureAllRequiredAPIsEnabled;
|
|
15
15
|
exports.partitionUserEnvs = partitionUserEnvs;
|
|
16
|
+
exports.checkKitForGen1 = checkKitForGen1;
|
|
16
17
|
const clc = require("colorette");
|
|
17
18
|
const proto = require("../../gcp/proto");
|
|
18
19
|
const backend = require("./backend");
|
|
@@ -48,17 +49,11 @@ const prompt = require("../../prompt");
|
|
|
48
49
|
const iam = require("../../gcp/iam");
|
|
49
50
|
const resourcemanager = require("../../gcp/resourceManager");
|
|
50
51
|
exports.EVENTARC_SOURCE_ENV = "EVENTARC_CLOUD_EVENT_SOURCE";
|
|
52
|
+
exports.DECLARATIVE_SECURITY_ETAG_LABEL = "firebase-declarative-security-etag";
|
|
51
53
|
async function discoverSecurityDetails(codebase, want, have, projectId, filters) {
|
|
52
54
|
const requiredRoles = want.requiredRoles;
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
let haveRolesEtag;
|
|
56
|
-
if (firstHave) {
|
|
57
|
-
haveRolesEtag = firstHave.labels?.["firebase-declarative-security-etag"];
|
|
58
|
-
existingManagedSA = firstHave.serviceAccount?.startsWith("firebase-fn-")
|
|
59
|
-
? firstHave.serviceAccount
|
|
60
|
-
: undefined;
|
|
61
|
-
}
|
|
55
|
+
const existingManagedSA = backend.findEndpoint(have, (e) => typeof e.serviceAccount === "string" && e.serviceAccount.startsWith("firebase-fn-"))?.serviceAccount ?? undefined;
|
|
56
|
+
const haveRolesEtag = backend.findEndpoint(have, (e) => !!e.labels?.[exports.DECLARATIVE_SECURITY_ETAG_LABEL])?.labels?.[exports.DECLARATIVE_SECURITY_ETAG_LABEL];
|
|
62
57
|
const isPartiallyFiltered = !!(filters &&
|
|
63
58
|
filters.some((f) => (!f.codebase || f.codebase === codebase) && f.idChunks && f.idChunks.length > 0));
|
|
64
59
|
const isEnrolling = !!requiredRoles && !existingManagedSA;
|
|
@@ -67,6 +62,15 @@ async function discoverSecurityDetails(codebase, want, have, projectId, filters)
|
|
|
67
62
|
throw new error_1.FirebaseError("To ensure a whole codebase is migrated cleanly, you may not deploy only part of a " +
|
|
68
63
|
"codebase when opting into or out of declarative security (starting or no longer using `requireRoles`)");
|
|
69
64
|
}
|
|
65
|
+
if (!backend.someEndpoint(want, () => true)) {
|
|
66
|
+
if (existingManagedSA) {
|
|
67
|
+
return {
|
|
68
|
+
existingManagedSA,
|
|
69
|
+
...(haveRolesEtag ? { haveRolesEtag } : {}),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
return {};
|
|
73
|
+
}
|
|
70
74
|
if (!requiredRoles && (!existingManagedSA || !haveRolesEtag)) {
|
|
71
75
|
return {};
|
|
72
76
|
}
|
|
@@ -98,7 +102,7 @@ async function discoverSecurityDetails(codebase, want, have, projectId, filters)
|
|
|
98
102
|
for (const endpoint of backend.allEndpoints(want)) {
|
|
99
103
|
endpoint.serviceAccount = managedSA;
|
|
100
104
|
endpoint.labels = endpoint.labels || {};
|
|
101
|
-
endpoint.labels[
|
|
105
|
+
endpoint.labels[exports.DECLARATIVE_SECURITY_ETAG_LABEL] = newEtag;
|
|
102
106
|
}
|
|
103
107
|
if (haveRolesEtag && haveRolesEtag === newEtag) {
|
|
104
108
|
return {
|
|
@@ -184,12 +188,14 @@ async function prepare(context, options, payload) {
|
|
|
184
188
|
const wantBackends = {};
|
|
185
189
|
for (const [codebase, wantBuild] of Object.entries(wantBuilds)) {
|
|
186
190
|
const config = (0, projectConfig_1.configForCodebase)(context.config, codebase);
|
|
187
|
-
const firebaseEnvs = functionsEnv.loadFirebaseEnvs(firebaseConfig, projectId);
|
|
191
|
+
const firebaseEnvs = functionsEnv.loadFirebaseEnvs(firebaseConfig, projectId, (0, projectConfig_1.isKitConfig)(config) ? codebase : undefined);
|
|
188
192
|
const localCfg = (0, projectConfig_1.requireLocal)(config, "Remote sources are not supported.");
|
|
193
|
+
checkKitForGen1(localCfg, wantBuild);
|
|
189
194
|
const userEnvOpt = {
|
|
190
195
|
functionsSource: options.config.path(localCfg.source),
|
|
191
196
|
projectId: projectId,
|
|
192
197
|
projectAlias: options.projectAlias,
|
|
198
|
+
projectDir: options.config.projectDir,
|
|
193
199
|
};
|
|
194
200
|
if ((0, projectConfig_1.isKitConfig)(localCfg) && codebase in localCfg.instances) {
|
|
195
201
|
userEnvOpt.configDir = options.config.path(localCfg.instances[codebase]);
|
|
@@ -210,6 +216,7 @@ async function prepare(context, options, payload) {
|
|
|
210
216
|
build: wantBuild,
|
|
211
217
|
firebaseConfig,
|
|
212
218
|
userEnvs,
|
|
219
|
+
codebase,
|
|
213
220
|
nonInteractive: options.nonInteractive,
|
|
214
221
|
force: options.force,
|
|
215
222
|
isEmulator: false,
|
|
@@ -498,7 +505,7 @@ async function loadCodebases(config, options, firebaseConfig, runtimeConfig, fil
|
|
|
498
505
|
await runtimeDelegate.validate();
|
|
499
506
|
logger_1.logger.debug(`Building ${runtimeDelegate.language} source`);
|
|
500
507
|
await runtimeDelegate.build();
|
|
501
|
-
const firebaseEnvs = functionsEnv.loadFirebaseEnvs(firebaseConfig, projectId);
|
|
508
|
+
const firebaseEnvs = functionsEnv.loadFirebaseEnvs(firebaseConfig, projectId, (0, projectConfig_1.isKitConfig)(codebaseConfig) ? codebase : undefined);
|
|
502
509
|
(0, utils_1.logLabeledBullet)("functions", `Loading and analyzing source code for codebase ${codebase} to determine what to deploy`);
|
|
503
510
|
const codebaseRuntimeConfig = (0, projectConfig_1.shouldUseRuntimeConfig)(codebaseConfig)
|
|
504
511
|
? runtimeConfig
|
|
@@ -619,3 +626,9 @@ function partitionUserEnvs(allEnvs) {
|
|
|
619
626
|
}, [{}, {}]);
|
|
620
627
|
return { userEnvs: userEnvs, secretRefs: secretRefs };
|
|
621
628
|
}
|
|
629
|
+
function checkKitForGen1(localCfg, wantBuild) {
|
|
630
|
+
if ((0, projectConfig_1.isKitConfig)(localCfg) &&
|
|
631
|
+
Object.values(wantBuild.endpoints).some((e) => e.platform === "gcfv1")) {
|
|
632
|
+
throw new error_1.FirebaseError(`Function kit "${localCfg.kit}" contains gen1 functions, which are not supported in kits. Please remove this kit or upgrade these functions to gen2.`);
|
|
633
|
+
}
|
|
634
|
+
}
|
|
@@ -265,7 +265,7 @@ async function promptForLifecycleEvent(codebase, wantBackend, options) {
|
|
|
265
265
|
}
|
|
266
266
|
choices.push({ name: "skip (default)", value: "skip" });
|
|
267
267
|
const selection = await (0, prompt_1.select)({
|
|
268
|
-
message: `
|
|
268
|
+
message: `Cannot determine if this is a first deploy or a redeploy for codebase "${codebase}" because the last deployment was partial (either due to a failure or a filtered deploy).`,
|
|
269
269
|
choices,
|
|
270
270
|
default: "skip",
|
|
271
271
|
nonInteractive: options?.nonInteractive,
|
|
@@ -42,6 +42,17 @@ async function executeLifecycleHooks(wantBackend, haveBackend, plan, codebase, o
|
|
|
42
42
|
if (!hasLifecycleHooks(wantBackend)) {
|
|
43
43
|
return false;
|
|
44
44
|
}
|
|
45
|
+
const codebasePlan = plan && codebase ? plan[codebase] : undefined;
|
|
46
|
+
if (codebasePlan && codebase) {
|
|
47
|
+
const allWantEndpoints = backend.allEndpoints(wantBackend);
|
|
48
|
+
const isFiltered = allWantEndpoints.some(backend.missingEndpoint(codebasePlan.plannedBackend));
|
|
49
|
+
if (isFiltered) {
|
|
50
|
+
const event = determineLifecycleEvent(haveBackend);
|
|
51
|
+
(0, utils_1.logLabeledWarning)("functions", `Lifecycle hook "${event}" for codebase "${codebase}" was configured but not executed because this was a partial deployment (filtered).`);
|
|
52
|
+
(0, utils_1.logLabeledBullet)("functions", `You can run the lifecycle hook in isolation by running: firebase functions:lifecycle:run ${event} ${codebase}`);
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
45
56
|
let event;
|
|
46
57
|
if (isRecoveryDeployment(wantBackend, haveBackend)) {
|
|
47
58
|
event = await prompts.promptForLifecycleEvent(codebase ?? "default", wantBackend, options);
|
|
@@ -86,7 +86,8 @@ async function createDeploymentPlan(args) {
|
|
|
86
86
|
const isFiltered = !!(filters &&
|
|
87
87
|
filters.some((f) => f.idChunks && f.idChunks.length > 0) &&
|
|
88
88
|
!deleteAll);
|
|
89
|
-
|
|
89
|
+
const hasWantEndpoints = backend.someEndpoint(wantBackend, () => true);
|
|
90
|
+
if (requiredRoles && hasWantEndpoints) {
|
|
90
91
|
rolesToAdd = requiredRoles.filter((r) => !roles.includes(r));
|
|
91
92
|
rolesToRemove = roles.filter((r) => !requiredRoles.includes(r));
|
|
92
93
|
if (!existingManagedSA && managedSA) {
|
|
@@ -118,7 +119,7 @@ async function createDeploymentPlan(args) {
|
|
|
118
119
|
"default to 80 concurrent executions, but existing functions keep the " +
|
|
119
120
|
"old default of 1. You can change this with the 'concurrency' option.");
|
|
120
121
|
}
|
|
121
|
-
if (requiredRoles) {
|
|
122
|
+
if (requiredRoles && hasWantEndpoints) {
|
|
122
123
|
if (!managedSA) {
|
|
123
124
|
throw new error_1.FirebaseError("managedServiceAccount is required when requiredRoles is defined.", {
|
|
124
125
|
exit: 1,
|
|
@@ -126,6 +127,7 @@ async function createDeploymentPlan(args) {
|
|
|
126
127
|
}
|
|
127
128
|
return {
|
|
128
129
|
regionalChangesets,
|
|
130
|
+
plannedBackend: wantBackend,
|
|
129
131
|
rolesToAdd,
|
|
130
132
|
rolesToRemove,
|
|
131
133
|
serviceAccountToCreate,
|
|
@@ -135,6 +137,7 @@ async function createDeploymentPlan(args) {
|
|
|
135
137
|
else {
|
|
136
138
|
return {
|
|
137
139
|
regionalChangesets,
|
|
140
|
+
plannedBackend: wantBackend,
|
|
138
141
|
serviceAccountToDelete,
|
|
139
142
|
};
|
|
140
143
|
}
|
|
@@ -355,6 +355,7 @@ async function startAll(options, showUI = true, runningTestScript = false) {
|
|
|
355
355
|
configDir: path.join(projectDir, configDir),
|
|
356
356
|
env: {
|
|
357
357
|
...options.extDevEnv,
|
|
358
|
+
FIREBASE_KIT_INSTANCE_ID: instanceId,
|
|
358
359
|
},
|
|
359
360
|
secretEnv: [],
|
|
360
361
|
predefinedTriggers: options.extDevTriggers,
|
|
@@ -367,6 +367,7 @@ class FunctionsEmulator {
|
|
|
367
367
|
projectAlias: this.args.projectAlias,
|
|
368
368
|
isEmulator: true,
|
|
369
369
|
configDir: emulatableBackend.configDir,
|
|
370
|
+
projectDir: this.args.projectDir,
|
|
370
371
|
};
|
|
371
372
|
const userEnvs = functionsEnv.loadUserEnvs(userEnvOpt);
|
|
372
373
|
const discoveredBuild = await runtimeDelegate.discoverBuild(runtimeConfig, environment);
|
|
@@ -379,6 +380,7 @@ class FunctionsEmulator {
|
|
|
379
380
|
build: discoveredBuild,
|
|
380
381
|
firebaseConfig: JSON.parse(firebaseConfig),
|
|
381
382
|
userEnvs,
|
|
383
|
+
codebase: emulatableBackend.codebase,
|
|
382
384
|
nonInteractive: false,
|
|
383
385
|
isEmulator: true,
|
|
384
386
|
});
|
|
@@ -957,6 +959,7 @@ class FunctionsEmulator {
|
|
|
957
959
|
projectId: this.args.projectId,
|
|
958
960
|
projectAlias: this.args.projectAlias,
|
|
959
961
|
isEmulator: true,
|
|
962
|
+
projectDir: this.args.projectDir,
|
|
960
963
|
};
|
|
961
964
|
if (functionsEnv.hasUserEnvs(projectInfo)) {
|
|
962
965
|
try {
|
|
@@ -1134,7 +1137,6 @@ class FunctionsEmulator {
|
|
|
1134
1137
|
port: 8081 + (0, utils_1.randomInt)(0, 1000),
|
|
1135
1138
|
});
|
|
1136
1139
|
const childProcess = (0, python_1.runWithVirtualEnv)(args, backend.functionsDir, {
|
|
1137
|
-
...process.env,
|
|
1138
1140
|
...envs,
|
|
1139
1141
|
PYTHONUNBUFFERED: "1",
|
|
1140
1142
|
DEBUG: "False",
|
package/lib/experiments.js
CHANGED
|
@@ -122,11 +122,12 @@ exports.ALL_EXPERIMENTS = experiments({
|
|
|
122
122
|
"without a notice.",
|
|
123
123
|
},
|
|
124
124
|
appcheckadmin: {
|
|
125
|
-
shortDescription: "Manage App Check enforcement from the CLI.",
|
|
126
|
-
fullDescription: "Enables the `firebase appcheck:services`
|
|
127
|
-
"
|
|
128
|
-
"
|
|
129
|
-
"
|
|
125
|
+
shortDescription: "Manage App Check enforcement and attestation providers from the CLI.",
|
|
126
|
+
fullDescription: "Enables the `firebase appcheck:services`, `firebase appcheck:providers` and " +
|
|
127
|
+
"`firebase appcheck:apps` commands for reading and changing App Check enforcement per " +
|
|
128
|
+
"service and the attestation providers of each app. These commands are in preview and " +
|
|
129
|
+
"may change until the surface is API council approved. The `firebase appcheck:debugtokens` " +
|
|
130
|
+
"commands are generally available and are not affected by this experiment.",
|
|
130
131
|
},
|
|
131
132
|
ailogic: {
|
|
132
133
|
shortDescription: "Manage Firebase AI Logic from the CLI.",
|
|
@@ -215,6 +216,11 @@ exports.ALL_EXPERIMENTS = experiments({
|
|
|
215
216
|
default: true,
|
|
216
217
|
public: true,
|
|
217
218
|
},
|
|
219
|
+
extMigrationFeatures: {
|
|
220
|
+
shortDescription: "Enable features intended to assist with the migration of Extension instances to Kits.",
|
|
221
|
+
default: false,
|
|
222
|
+
public: false,
|
|
223
|
+
},
|
|
218
224
|
});
|
|
219
225
|
function isValidExperiment(name) {
|
|
220
226
|
return Object.keys(exports.ALL_EXPERIMENTS).includes(name);
|
package/lib/extensions/export.js
CHANGED
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.parameterizeProject = parameterizeProject;
|
|
4
4
|
exports.setSecretParamsToLatest = setSecretParamsToLatest;
|
|
5
5
|
exports.displayExportInfo = displayExportInfo;
|
|
6
|
+
exports.functionsEnvFromInstance = functionsEnvFromInstance;
|
|
6
7
|
const planner_1 = require("../deploy/extensions/planner");
|
|
7
8
|
const deploymentSummary_1 = require("../deploy/extensions/deploymentSummary");
|
|
8
9
|
const logger_1 = require("../logger");
|
|
@@ -60,3 +61,49 @@ function displaySpecs(specs) {
|
|
|
60
61
|
logger_1.logger.info("");
|
|
61
62
|
}
|
|
62
63
|
}
|
|
64
|
+
function functionsEnvFromInstance(instance) {
|
|
65
|
+
const liveParams = instance.config?.params || {};
|
|
66
|
+
const liveSystemParams = instance.config?.systemParams || {};
|
|
67
|
+
const specParams = instance.config?.source?.spec?.params || {};
|
|
68
|
+
const specSystemParams = instance.config?.source?.spec?.systemParams || {};
|
|
69
|
+
const envs = {};
|
|
70
|
+
specParams.forEach((specParam) => {
|
|
71
|
+
if (specParam.type === "SECRET") {
|
|
72
|
+
const renamed = "FIREBASE_SECRET_REF_" + specParam.param;
|
|
73
|
+
envs[renamed] = liveParams[specParam.param];
|
|
74
|
+
}
|
|
75
|
+
else if (specParam.param in liveParams) {
|
|
76
|
+
envs[specParam.param] = liveParams[specParam.param];
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
envs[specParam.param] = specParam.default ?? "";
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
for (const [sysParamName, sysParamValue] of Object.entries(liveSystemParams)) {
|
|
83
|
+
let renamed = sysParamName
|
|
84
|
+
.replace(/^firebaseextensions\.v1beta\.(v2)?function\//, "EXT_MIGRATED_SYSTEM_")
|
|
85
|
+
.toUpperCase();
|
|
86
|
+
if (renamed === "EXT_MIGRATED_SYSTEM_LOCATION") {
|
|
87
|
+
renamed = "DEFAULT_FUNCTION_REGION";
|
|
88
|
+
}
|
|
89
|
+
envs[renamed] = sysParamValue;
|
|
90
|
+
}
|
|
91
|
+
for (const specSystemParam of Object.values(specSystemParams)) {
|
|
92
|
+
if (specSystemParam.param in liveSystemParams) {
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
if ("default" in specSystemParam) {
|
|
96
|
+
const renamed = specSystemParam.param
|
|
97
|
+
.replace(/^firebaseextensions\.v1beta\.(v2)?function\//, "EXT_MIGRATED_SYSTEM_")
|
|
98
|
+
.toUpperCase();
|
|
99
|
+
envs[renamed] = specSystemParam.default ?? "";
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (typeof instance.config.allowedEventTypes !== "undefined") {
|
|
103
|
+
envs["EXT_SELECTED_EVENTS"] = instance.config.allowedEventTypes.toString();
|
|
104
|
+
}
|
|
105
|
+
if (typeof instance.config.eventarcChannel !== "undefined") {
|
|
106
|
+
envs["EVENTARC_CHANNEL"] = instance.config.eventarcChannel;
|
|
107
|
+
}
|
|
108
|
+
return envs;
|
|
109
|
+
}
|
package/lib/functions/env.js
CHANGED
|
@@ -19,7 +19,11 @@ const logger_1 = require("../logger");
|
|
|
19
19
|
const utils_1 = require("../utils");
|
|
20
20
|
const FUNCTIONS_EMULATOR_DOTENV = ".env.local";
|
|
21
21
|
const RESERVED_PREFIXES = ["X_GOOGLE_", "FIREBASE_", "EXT_", "KIT_"];
|
|
22
|
-
const RESERVED_PREFIX_ALLOWLIST = [
|
|
22
|
+
const RESERVED_PREFIX_ALLOWLIST = [
|
|
23
|
+
"FIREBASE_SECRET_REF_",
|
|
24
|
+
"EXT_MIGRATED_SYSTEM_",
|
|
25
|
+
"EXT_SELECTED_EVENTS",
|
|
26
|
+
];
|
|
23
27
|
const RESERVED_KEYS = [
|
|
24
28
|
"FIREBASE_CONFIG",
|
|
25
29
|
"CLOUD_RUNTIME_CONFIG",
|
|
@@ -183,10 +187,12 @@ function writeUserEnvs(toWrite, envOpts) {
|
|
|
183
187
|
? FUNCTIONS_EMULATOR_DOTENV
|
|
184
188
|
: `.env.${envOpts.projectId}`;
|
|
185
189
|
const targetEnvFileExists = allEnvFiles.includes(targetEnvFile);
|
|
190
|
+
const targetEnvFilePath = path.join(configDir, targetEnvFile);
|
|
191
|
+
const relativeTargetEnvFilePath = path.relative(envOpts.projectDir, targetEnvFilePath);
|
|
186
192
|
if (!targetEnvFileExists) {
|
|
187
|
-
fs.writeFileSync(
|
|
193
|
+
fs.writeFileSync(targetEnvFilePath, "", { flag: "wx" });
|
|
188
194
|
(0, utils_1.logBullet)(clc.yellow(clc.bold("functions: ")) +
|
|
189
|
-
`Created new local file ${
|
|
195
|
+
`Created new local file ${relativeTargetEnvFilePath} to store param values. We suggest explicitly adding or excluding this file from version control.`);
|
|
190
196
|
}
|
|
191
197
|
const fullEnvs = loadUserEnvs(envOpts);
|
|
192
198
|
const prodEnvs = isEmulator
|
|
@@ -196,7 +202,8 @@ function writeUserEnvs(toWrite, envOpts) {
|
|
|
196
202
|
for (const k of Object.keys(toWrite)) {
|
|
197
203
|
validateKey(k);
|
|
198
204
|
}
|
|
199
|
-
(0, utils_1.logBullet)(clc.cyan(clc.bold("functions: ")) +
|
|
205
|
+
(0, utils_1.logBullet)(clc.cyan(clc.bold("functions: ")) +
|
|
206
|
+
`Writing new parameter values to disk: ${relativeTargetEnvFilePath}`);
|
|
200
207
|
let lines = "";
|
|
201
208
|
for (const k of Object.keys(toWrite)) {
|
|
202
209
|
lines += formatUserEnvForWrite(k, toWrite[k]);
|
|
@@ -249,14 +256,20 @@ function loadUserEnvs(opts) {
|
|
|
249
256
|
});
|
|
250
257
|
}
|
|
251
258
|
}
|
|
252
|
-
|
|
259
|
+
const relativeEnvFiles = envFiles.map((f) => path.relative(opts.projectDir, path.join(configDir, f)));
|
|
260
|
+
(0, utils_1.logBullet)(clc.cyan(clc.bold("functions: ")) +
|
|
261
|
+
`Loaded environment variables from ${relativeEnvFiles.join(", ")}`);
|
|
253
262
|
return envs;
|
|
254
263
|
}
|
|
255
|
-
function loadFirebaseEnvs(firebaseConfig, projectId) {
|
|
256
|
-
|
|
264
|
+
function loadFirebaseEnvs(firebaseConfig, projectId, kitInstanceId) {
|
|
265
|
+
const envs = {
|
|
257
266
|
FIREBASE_CONFIG: JSON.stringify(firebaseConfig),
|
|
258
267
|
GCLOUD_PROJECT: projectId,
|
|
259
268
|
};
|
|
269
|
+
if (kitInstanceId) {
|
|
270
|
+
envs.FIREBASE_KIT_INSTANCE_ID = kitInstanceId;
|
|
271
|
+
}
|
|
272
|
+
return envs;
|
|
260
273
|
}
|
|
261
274
|
function writeResolvedParams(resolvedEnvs, userEnvs, userEnvOpt) {
|
|
262
275
|
const toWrite = {};
|
|
@@ -6,7 +6,8 @@ exports.validateCodebase = validateCodebase;
|
|
|
6
6
|
exports.validateKit = validateKit;
|
|
7
7
|
exports.validatePrefix = validatePrefix;
|
|
8
8
|
exports.assertUnique = assertUnique;
|
|
9
|
-
exports.
|
|
9
|
+
exports.validateKitInstanceId = validateKitInstanceId;
|
|
10
|
+
exports.validateAndAddKitInstances = validateAndAddKitInstances;
|
|
10
11
|
exports.validate = validate;
|
|
11
12
|
exports.normalizeAndValidate = normalizeAndValidate;
|
|
12
13
|
exports.configForCodebase = configForCodebase;
|
|
@@ -151,17 +152,24 @@ function assertUniqueSourcePrefixPair(config) {
|
|
|
151
152
|
sourcePrefixPairs.add(key);
|
|
152
153
|
}
|
|
153
154
|
}
|
|
154
|
-
function
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
155
|
+
function validateKitInstanceId(instanceId) {
|
|
156
|
+
if (instanceId.length === 0 ||
|
|
157
|
+
instanceId.length > 40 ||
|
|
158
|
+
!/^[a-z0-9_](?:[a-z0-9_-]*[a-z0-9_])?$/.test(instanceId)) {
|
|
159
|
+
throw new error_1.FirebaseError(`Invalid kit instance ID '${instanceId}'. Instance ID must be 40 characters or less, ` +
|
|
160
|
+
"can contain only lowercase letters, numeric characters, underscores, and dashes, and cannot start or end with a dash.");
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
function validateAndAddKitInstances(instanceIds, allProjectInstanceIds) {
|
|
164
|
+
const seenInBatch = new Set();
|
|
165
|
+
for (const instanceId of instanceIds) {
|
|
166
|
+
validateKitInstanceId(instanceId);
|
|
167
|
+
if (seenInBatch.has(instanceId) || allProjectInstanceIds.has(instanceId)) {
|
|
163
168
|
throw new error_1.FirebaseError(`functions kit instance ID must be unique across all kits, but '${instanceId}' was used more than once.`);
|
|
164
169
|
}
|
|
170
|
+
seenInBatch.add(instanceId);
|
|
171
|
+
}
|
|
172
|
+
for (const instanceId of seenInBatch) {
|
|
165
173
|
allProjectInstanceIds.add(instanceId);
|
|
166
174
|
}
|
|
167
175
|
}
|
|
@@ -173,7 +181,7 @@ function assertUniqueKitInstancesAndCodebases(config) {
|
|
|
173
181
|
codebases.add(c.codebase);
|
|
174
182
|
}
|
|
175
183
|
if ("instances" in c && c.instances) {
|
|
176
|
-
|
|
184
|
+
validateAndAddKitInstances(Object.keys(c.instances), instanceIds);
|
|
177
185
|
}
|
|
178
186
|
}
|
|
179
187
|
for (const instanceId of instanceIds) {
|
package/lib/functions/python.js
CHANGED
package/lib/gcp/runv2.js
CHANGED
|
@@ -154,6 +154,7 @@ function endpointFromService(service) {
|
|
|
154
154
|
? proto.secondsFromDuration(service.template.timeout)
|
|
155
155
|
: 60,
|
|
156
156
|
serviceAccount: service.template.serviceAccount || null,
|
|
157
|
+
runServiceId: svcId,
|
|
157
158
|
ingressSettings: (service.annotations?.["run.googleapis.com/ingress"] === "internal"
|
|
158
159
|
? "ALLOW_INTERNAL_ONLY"
|
|
159
160
|
: service.annotations?.["run.googleapis.com/ingress"] === "internal-and-cloud-load-balancing"
|
package/lib/mcp/onemcp/index.js
CHANGED
|
@@ -6,9 +6,10 @@ const onemcp_server_1 = require("./onemcp_server");
|
|
|
6
6
|
exports.ONEMCP_SERVERS = {
|
|
7
7
|
developerknowledge: new onemcp_server_1.OneMcpServer("developerknowledge", (0, api_1.developerKnowledgeOrigin)(), {
|
|
8
8
|
requiresAuth: true,
|
|
9
|
+
}, {
|
|
10
|
+
toolsToOptOutProjectRequirement: ["search_documents", "get_documents"],
|
|
9
11
|
}),
|
|
10
12
|
firestore: new onemcp_server_1.OneMcpServer("firestore", (0, api_1.firestoreOrigin)(), {
|
|
11
13
|
requiresAuth: true,
|
|
12
|
-
requiresProject: true,
|
|
13
14
|
}),
|
|
14
15
|
};
|
|
@@ -40,27 +40,53 @@ class OneMcpServer {
|
|
|
40
40
|
return (this.options.allowedTools.includes(mcpTool.name) ||
|
|
41
41
|
this.options.allowedTools.includes(`${this.feature}_${mcpTool.name}`));
|
|
42
42
|
});
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
43
|
+
const optOutSet = new Set(this.options.toolsToOptOutProjectRequirement || []);
|
|
44
|
+
return tools.map((mcpTool) => {
|
|
45
|
+
const isOptedOut = this.meta.requiresProject === false ||
|
|
46
|
+
optOutSet.has(mcpTool.name) ||
|
|
47
|
+
optOutSet.has(`${this.feature}_${mcpTool.name}`);
|
|
48
|
+
const toolRequiresProject = !isOptedOut;
|
|
49
|
+
return {
|
|
50
|
+
mcp: {
|
|
51
|
+
...mcpTool,
|
|
52
|
+
name: `${this.feature}_${mcpTool.name}`,
|
|
53
|
+
_meta: {
|
|
54
|
+
...this.meta,
|
|
55
|
+
requiresProject: toolRequiresProject,
|
|
56
|
+
feature: this.feature,
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
fn: (args, ctx) => this.callTool(mcpTool.name, mcpTool.inputSchema, args, ctx),
|
|
60
|
+
isAvailable: () => Promise.resolve(true),
|
|
61
|
+
};
|
|
62
|
+
});
|
|
52
63
|
}
|
|
53
64
|
catch (error) {
|
|
54
65
|
throw new error_1.FirebaseError("Failed to fetch remote tools for " + this.serverUrl + ": " + JSON.stringify(error));
|
|
55
66
|
}
|
|
56
67
|
}
|
|
57
|
-
async callTool(toolName, args, ctx) {
|
|
68
|
+
async callTool(toolName, inputSchema, args, ctx) {
|
|
58
69
|
if (this.options.allowedTools?.length &&
|
|
59
70
|
!this.options.allowedTools.includes(toolName) &&
|
|
60
71
|
!this.options.allowedTools.includes(`${this.feature}_${toolName}`)) {
|
|
61
72
|
throw new error_1.FirebaseError(`Tool '${toolName}' is not allowed on remote server for feature '${this.feature}'.`);
|
|
62
73
|
}
|
|
63
|
-
|
|
74
|
+
const paramHeaders = {};
|
|
75
|
+
const props = inputSchema?.properties;
|
|
76
|
+
if (props && typeof props === "object" && args) {
|
|
77
|
+
for (const [paramName, propSchema] of Object.entries(props)) {
|
|
78
|
+
if (propSchema && typeof propSchema === "object" && "x-mcp-header" in propSchema) {
|
|
79
|
+
const headerName = propSchema["x-mcp-header"];
|
|
80
|
+
const argValue = args[paramName];
|
|
81
|
+
if (argValue !== undefined && argValue !== null) {
|
|
82
|
+
paramHeaders[`Mcp-Param-${headerName}`] = String(argValue);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
if (ctx.projectId) {
|
|
88
|
+
await (0, ensureApiEnabled_1.ensure)(ctx.projectId, this.serverUrl, this.feature, true);
|
|
89
|
+
}
|
|
64
90
|
try {
|
|
65
91
|
const res = await this.callClient.post("/mcp", {
|
|
66
92
|
method: "tools/call",
|
|
@@ -76,6 +102,7 @@ class OneMcpServer {
|
|
|
76
102
|
"Mcp-Method": "tools/call",
|
|
77
103
|
"Mcp-Name": toolName,
|
|
78
104
|
...(ctx.projectId ? { "x-goog-user-project": ctx.projectId } : {}),
|
|
105
|
+
...paramHeaders,
|
|
79
106
|
},
|
|
80
107
|
});
|
|
81
108
|
return types_js_1.CallToolResultSchema.parse(res.body.result);
|
|
@@ -24,7 +24,7 @@ exports.connect = (0, prompt_1.prompt)("crashlytics", {
|
|
|
24
24
|
content: {
|
|
25
25
|
type: "text",
|
|
26
26
|
text: `
|
|
27
|
-
You will assist developers in investigating and resolving mobile application issues by leveraging Firebase Crashlytics data.
|
|
27
|
+
You will assist developers in investigating and resolving mobile and web application issues by leveraging Firebase Crashlytics data.
|
|
28
28
|
|
|
29
29
|
### Required First Steps
|
|
30
30
|
|
|
@@ -18,14 +18,14 @@ Follow these steps to fetch issues and prioritize them.
|
|
|
18
18
|
|
|
19
19
|
1. Use the 'crashlytics_get_report' tool to fetch the 'topIssues' report.
|
|
20
20
|
1a. Analyze the user's query and apply the appropriate filters. Use the information in the [Firebase Crashlytics Reports Guide](firebase://guides/crashlytics/reports) to further construct appropriate report requests.
|
|
21
|
-
1b. If the user asks for crashes, then set the *issueErrorType* filter to *FATAL*.
|
|
21
|
+
1b. If the user asks for crashes and it is a mobile app, then set the *issueErrorType* filter to *FATAL*.
|
|
22
22
|
1c. If the user asks about a particular time range, then set both the *intervalStartTime* and *intervalEndTime*.
|
|
23
23
|
2. Use the 'crashlytics_get_report' tool to fetch the 'topVersions' for this app.
|
|
24
24
|
3. If the user instructions include statements about prioritization, use those instructions.
|
|
25
25
|
4. If the user instructions do not include statements about prioritization, then prioritize the returned issues using the following criteria:
|
|
26
26
|
4a. The app versions for the issue include the most recent version of the app.
|
|
27
27
|
4b. The number of users experiencing the issue across variants
|
|
28
|
-
4c. The volume of
|
|
28
|
+
4c. The volume of issues
|
|
29
29
|
5. Return the top 5 issues, with a brief description each in a numerical list with the recommended format.
|
|
30
30
|
5a. Describe the rationale for the prioritization order.
|
|
31
31
|
6. Ask the user if they would like to diagnose and fix any of the issues presented before taking any action.
|
|
@@ -34,7 +34,7 @@ exports.crashlytics_issues = (0, resource_1.resource)({
|
|
|
34
34
|
uri: "firebase://guides/crashlytics/issues",
|
|
35
35
|
name: "crashlytics_issues_guide",
|
|
36
36
|
title: "Firebase Crashlytics Issues Guide",
|
|
37
|
-
description: "Guides the coding agent when working with Crashlytics issues, including prioritization rules and procedures for diagnosing and fixing
|
|
37
|
+
description: "Guides the coding agent when working with Crashlytics issues, including prioritization rules and procedures for diagnosing and fixing issues. ",
|
|
38
38
|
}, async (uri) => {
|
|
39
39
|
return {
|
|
40
40
|
contents: [{ uri, type: "text", text: RESOURCE_CONTENT }],
|
|
@@ -14,14 +14,6 @@ The following reports are available for all Crashlytics applications.
|
|
|
14
14
|
Counts events and distinct impacted users, grouped by issue.
|
|
15
15
|
Issue groups are sorted by event count, in descending order.
|
|
16
16
|
|
|
17
|
-
- name: "topVariants"
|
|
18
|
-
display_name: "Top Variants"
|
|
19
|
-
usage: |
|
|
20
|
-
Counts events and distinct impacted users, grouped by issue variant.
|
|
21
|
-
Issue variant groups are sorted by event count, in descending order.
|
|
22
|
-
required: |
|
|
23
|
-
An issue filter including an issue id is required.
|
|
24
|
-
|
|
25
17
|
- name: "topVersions"
|
|
26
18
|
display_name: "Top Versions"
|
|
27
19
|
usage: |
|
|
@@ -34,7 +26,17 @@ The following reports are available for all Crashlytics applications.
|
|
|
34
26
|
Counts events, grouped by device operating systems and their versions.
|
|
35
27
|
Operating systems are sorted by event count, in descending order.
|
|
36
28
|
|
|
37
|
-
Mobile apps have
|
|
29
|
+
Mobile apps have the following report available:
|
|
30
|
+
|
|
31
|
+
- name: "topVariants"
|
|
32
|
+
display_name: "Top Variants"
|
|
33
|
+
usage: |
|
|
34
|
+
Counts events and distinct impacted users, grouped by issue variant.
|
|
35
|
+
Issue variant groups are sorted by event count, in descending order.
|
|
36
|
+
required: |
|
|
37
|
+
An issue filter including an issue id is required.
|
|
38
|
+
|
|
39
|
+
Mobile apps also have one of the following reports available, depending on the platform.
|
|
38
40
|
|
|
39
41
|
- name: "topAndroidDevices"
|
|
40
42
|
display_name: "Top Android Devices"
|
|
@@ -48,10 +50,27 @@ Mobile apps have one of the following reports available, depending on the platfo
|
|
|
48
50
|
Counts events, grouped by operating system and Apple device.
|
|
49
51
|
Devices are sorted by event count, in descending order.
|
|
50
52
|
|
|
53
|
+
Web apps have the following additional reports available.
|
|
54
|
+
|
|
55
|
+
- name: "topBrowsers"
|
|
56
|
+
display_name: "Top Browsers"
|
|
57
|
+
usage: |
|
|
58
|
+
Counts events, grouped by browser.
|
|
59
|
+
Browsers are sorted by event count, in descending order.
|
|
60
|
+
required: |
|
|
61
|
+
An issue filter including an issue id is required.
|
|
62
|
+
|
|
63
|
+
- name: "webMetrics"
|
|
64
|
+
display_name: "Web Metrics"
|
|
65
|
+
usage: |
|
|
66
|
+
Counts events and distinct impacted users, grouped by error type.
|
|
67
|
+
Error types are sorted by event count, in descending order.
|
|
68
|
+
|
|
51
69
|
Report responses contain the following metrics:
|
|
52
70
|
|
|
53
71
|
- eventsCount: the number of events matching
|
|
54
72
|
- impactedUsers: the number of distinct end users in all the matching events
|
|
73
|
+
- sessionsCount: the number of distinct sessions in all the matching events. Only available for web apps.
|
|
55
74
|
|
|
56
75
|
Report responses are always grouped by one of the following dimensions:
|
|
57
76
|
|
|
@@ -59,14 +78,16 @@ Report responses are always grouped by one of the following dimensions:
|
|
|
59
78
|
- issue
|
|
60
79
|
- variant
|
|
61
80
|
- operating system
|
|
62
|
-
- mobile device type
|
|
81
|
+
- mobile device type (mobile only)
|
|
82
|
+
- browser (web only)
|
|
83
|
+
- error type (web only)
|
|
63
84
|
|
|
64
85
|
### Filters
|
|
65
86
|
|
|
66
87
|
When setting report filters adhere to the following instructions.
|
|
67
88
|
|
|
68
89
|
* Issue Filtering:
|
|
69
|
-
*
|
|
90
|
+
* For mobile apps, use the \`issueErrorTypes\` field to focus on events of different fatalities:
|
|
70
91
|
* FATAL: native crashes, which caused the app to exit.
|
|
71
92
|
* NON_FATAL: uncaught or manually reported exceptions, which did not crash the app.
|
|
72
93
|
* ANR: "app not responding" events, only relevant on Android platforms.
|
package/lib/mcp/tool.js
CHANGED
|
@@ -10,6 +10,11 @@ function tool(feature, options, fn) {
|
|
|
10
10
|
mcp: {
|
|
11
11
|
...mcpOptions,
|
|
12
12
|
inputSchema: (0, util_1.cleanSchema)(zod_1.z.toJSONSchema(options.inputSchema, { target: "draft-7", io: "input" })),
|
|
13
|
+
...(options.outputSchema
|
|
14
|
+
? {
|
|
15
|
+
outputSchema: (0, util_1.cleanSchema)(zod_1.z.toJSONSchema(options.outputSchema, { target: "draft-7", io: "output" })),
|
|
16
|
+
}
|
|
17
|
+
: {}),
|
|
13
18
|
},
|
|
14
19
|
fn,
|
|
15
20
|
isAvailable: (ctx) => {
|