passport-bridge 0.48.2 → 0.50.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/dist/cliHook.js +13 -0
- package/dist/cliHookAfter.js +10 -1
- package/dist/cliHookDecide.d.ts +9 -3
- package/dist/cliHookDecide.js +185 -28
- package/dist/cliHookDeliver.d.ts +2 -2
- package/dist/cliHookDeliver.js +8 -4
- package/dist/cliHookSessionState.d.ts +4 -1
- package/dist/cliHookSessionState.js +1 -1
- package/dist/connectorKit/callEffects.generated.d.ts +36 -0
- package/dist/connectorKit/callEffects.generated.js +73 -0
- package/dist/connectorKit/cli.generated.js +5 -2
- package/dist/connectorKit/engine.generated.d.ts +1 -1
- package/dist/connectorKit/engine.generated.js +32 -13
- package/dist/connectorKit/githubIds.generated.d.ts +1 -1
- package/dist/connectorKit/githubIds.generated.js +3 -2
- package/dist/connectorKit/manifest.generated.d.ts +34 -14
- package/dist/connectorKit/manifests/cloudflare.generated.d.ts +2 -0
- package/dist/connectorKit/manifests/cloudflare.generated.js +186 -0
- package/dist/connectorKit/manifests/cloudflareApi.generated.d.ts +4 -0
- package/dist/connectorKit/manifests/cloudflareApi.generated.js +207 -0
- package/dist/connectorKit/manifests/cloudflareCatalog.generated.d.ts +18 -0
- package/dist/connectorKit/manifests/cloudflareCatalog.generated.js +83 -0
- package/dist/connectorKit/manifests/cloudflareCli.generated.d.ts +2 -0
- package/dist/connectorKit/manifests/cloudflareCli.generated.js +441 -0
- package/dist/connectorKit/manifests/githubCapture.generated.js +19 -1
- package/dist/connectorKit/manifests/githubReads.generated.js +0 -3
- package/dist/connectorKit/manifests/kubernetes.generated.d.ts +76 -0
- package/dist/connectorKit/manifests/kubernetes.generated.js +210 -0
- package/dist/connectorKit/manifests/kubernetesArgs.generated.d.ts +21 -0
- package/dist/connectorKit/manifests/kubernetesArgs.generated.js +82 -0
- package/dist/connectorKit/manifests/kubernetesCli.generated.d.ts +30 -0
- package/dist/connectorKit/manifests/kubernetesCli.generated.js +530 -0
- package/dist/connectorKit/manifests/kubernetesEffects.generated.d.ts +15 -0
- package/dist/connectorKit/manifests/kubernetesEffects.generated.js +111 -0
- package/dist/connectorKit/manifests/kubernetesObjects.generated.d.ts +24 -0
- package/dist/connectorKit/manifests/kubernetesObjects.generated.js +154 -0
- package/dist/connectorKit/manifests/railwayHooks.generated.js +11 -5
- package/dist/connectorKit/manifests/sentry.generated.d.ts +6 -0
- package/dist/connectorKit/manifests/sentry.generated.js +27 -0
- package/dist/connectorKit/manifests/sentryApi.generated.d.ts +6 -0
- package/dist/connectorKit/manifests/sentryApi.generated.js +282 -0
- package/dist/connectorKit/manifests/sentryCapture.generated.d.ts +2 -0
- package/dist/connectorKit/manifests/sentryCapture.generated.js +165 -0
- package/dist/connectorKit/manifests/sentryCatalog.generated.d.ts +5 -0
- package/dist/connectorKit/manifests/sentryCatalog.generated.js +70 -0
- package/dist/connectorKit/manifests/sentryCli.generated.d.ts +2 -0
- package/dist/connectorKit/manifests/sentryCli.generated.js +230 -0
- package/dist/connectorKit/manifests/sentryIssues.generated.d.ts +20 -0
- package/dist/connectorKit/manifests/sentryIssues.generated.js +204 -0
- package/dist/connectorKit/manifests/supabase.generated.js +3 -2
- package/dist/connectorKit/manifests/supabaseApi.generated.js +52 -52
- package/dist/connectorKit/manifests/supabaseCapture.generated.js +22 -21
- package/dist/connectorKit/manifests/supabaseCatalog.generated.d.ts +2 -2
- package/dist/connectorKit/manifests/supabaseCatalog.generated.js +8 -7
- package/dist/connectorKit/manifests/supabaseCli.generated.js +32 -32
- package/dist/connectorKit/manifests/supabaseProbes.generated.js +29 -29
- package/dist/connectorKit/manifests/terraform.generated.d.ts +5 -0
- package/dist/connectorKit/manifests/terraform.generated.js +214 -0
- package/dist/connectorKit/manifests/terraformLink.generated.d.ts +30 -0
- package/dist/connectorKit/manifests/terraformLink.generated.js +73 -0
- package/dist/connectorKit/manifests/terraformPlan.generated.d.ts +48 -0
- package/dist/connectorKit/manifests/terraformPlan.generated.js +192 -0
- package/dist/connectorKit/params.generated.js +2 -0
- package/dist/connectorKit/shell.generated.d.ts +5 -1
- package/dist/connectorKit/shell.generated.js +121 -20
- package/dist/connectorKit/sources/cloudflare/api-operations.generated.d.ts +37 -0
- package/dist/connectorKit/sources/cloudflare/api-operations.generated.js +2 -0
- package/dist/connectorKit/sources/cloudflare/cli-flags.generated.d.ts +617 -0
- package/dist/connectorKit/sources/cloudflare/cli-flags.generated.js +2 -0
- package/dist/connectorKit/sources/cloudflare/mcp-tools.generated.d.ts +16 -0
- package/dist/connectorKit/sources/cloudflare/mcp-tools.generated.js +2 -0
- package/dist/connectorKit/sources/sentry/api-operations.generated.d.ts +121 -0
- package/dist/connectorKit/sources/sentry/api-operations.generated.js +2 -0
- package/dist/connectorKit/sources/sentry/cli-commands.generated.d.ts +530 -0
- package/dist/connectorKit/sources/sentry/cli-commands.generated.js +2 -0
- package/dist/connectorKit/sources/sentry/mcp-tools.generated.d.ts +32 -0
- package/dist/connectorKit/sources/sentry/mcp-tools.generated.js +2 -0
- package/dist/connectorKit/template.generated.d.ts +8 -4
- package/dist/connectorKit/template.generated.js +19 -6
- package/dist/controlPlane.generated.d.ts +11 -2
- package/dist/controlPlaneActions.generated.d.ts +52 -12
- package/dist/controlPlaneActions.generated.js +40 -11
- package/dist/controlPlaneAnswer.d.ts +35 -0
- package/dist/controlPlaneAnswer.js +23 -0
- package/dist/controlPlaneCli.d.ts +1 -1
- package/dist/controlPlaneCloudflare.d.ts +70 -0
- package/dist/controlPlaneCloudflare.js +188 -0
- package/dist/controlPlaneGuard.d.ts +6 -31
- package/dist/controlPlaneGuard.js +17 -24
- package/dist/controlPlaneKubernetes.d.ts +72 -0
- package/dist/controlPlaneKubernetes.js +260 -0
- package/dist/controlPlaneModel.generated.d.ts +6 -0
- package/dist/controlPlaneNpm.generated.d.ts +83 -0
- package/dist/controlPlaneNpm.generated.js +307 -0
- package/dist/controlPlaneNpmCommands.generated.d.ts +35 -0
- package/dist/controlPlaneNpmCommands.generated.js +567 -0
- package/dist/controlPlaneNpmGuard.d.ts +44 -0
- package/dist/controlPlaneNpmGuard.js +210 -0
- package/dist/controlPlaneOffline.d.ts +1 -1
- package/dist/controlPlaneRailway.generated.js +2 -2
- package/dist/controlPlaneRailwayCli.generated.js +13 -2
- package/dist/controlPlaneRailwayGuard.d.ts +1 -1
- package/dist/controlPlaneRailwayGuard.js +1 -1
- package/dist/controlPlaneRailwayModel.generated.d.ts +5 -0
- package/dist/controlPlaneRailwayModel.generated.js +15 -1
- package/dist/controlPlaneSentry.d.ts +68 -0
- package/dist/controlPlaneSentry.js +205 -0
- package/dist/controlPlaneSupabase.d.ts +1 -1
- package/dist/controlPlaneSupabase.js +1 -1
- package/dist/controlPlaneTerraform.d.ts +86 -0
- package/dist/controlPlaneTerraform.js +273 -0
- package/dist/controlPlaneUnnamed.generated.d.ts +41 -2
- package/dist/controlPlaneUnnamed.generated.js +148 -2
- package/dist/cpCli.d.ts +1 -1
- package/dist/cpCli.js +1 -1
- package/dist/gitPush.d.ts +8 -3
- package/dist/gitPush.js +37 -12
- package/dist/githubMergeHold.d.ts +42 -0
- package/dist/githubMergeHold.js +134 -0
- package/dist/githubMergeIds.d.ts +18 -0
- package/dist/githubMergeIds.js +51 -0
- package/dist/pluginPin.d.ts +1 -1
- package/dist/pluginPin.js +1 -1
- package/dist/terraformPlans.d.ts +45 -0
- package/dist/terraformPlans.js +96 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/dist/cliHook.js
CHANGED
|
@@ -183,6 +183,19 @@ async function runAudit(args, runtime, deps) {
|
|
|
183
183
|
await (await import("./controlPlaneLateHold.js")).releaseLate(profile, sessionId, toolUseId, now);
|
|
184
184
|
// Ran while Passport couldn't be reached and no rules were known: Passport is told what it was.
|
|
185
185
|
await (await import("./controlPlaneOffline.js")).releaseOffline(profile, sessionId, toolUseId, now);
|
|
186
|
+
// A merge that didn't name its pull request: its number, from gh's output read here, goes to its decision. Only a
|
|
187
|
+
// line that merges can have one held, so nothing else loads this.
|
|
188
|
+
const merged = /\bmerge\b/.test(event.command)
|
|
189
|
+
? await (await import("./githubMergeHold.js")).releaseMerges(profile, {
|
|
190
|
+
sessionId,
|
|
191
|
+
toolUseId,
|
|
192
|
+
exitCode: outcomeOfInput(input).exitCode,
|
|
193
|
+
output: async () => (await import("./signInFailure.js")).outputTail(input)
|
|
194
|
+
}, now)
|
|
195
|
+
: 0;
|
|
196
|
+
// Sent by the detached flush, as every after-hook report is (tests inject `send`/`fetch` and start none).
|
|
197
|
+
if (merged && !deps.send && !deps.fetch)
|
|
198
|
+
await startFlushIfDue(profile, args, detectRuntime(input, runtime.env, value(args, "client")), now);
|
|
186
199
|
}
|
|
187
200
|
const declared = value(args, "client");
|
|
188
201
|
const runtimeName = detectRuntime(input, runtime.env, declared);
|
package/dist/cliHookAfter.js
CHANGED
|
@@ -51,6 +51,15 @@ async function heldKey(profile, vendor) {
|
|
|
51
51
|
const marked = readExecVendors(profile).has(vendor);
|
|
52
52
|
return { held: marked, rerouted: marked && !readKeysChoices(profile).kept[vendor] };
|
|
53
53
|
}
|
|
54
|
+
/** A `terraform plan -out` that ran: its plan read now (counts and resource-type names only) and remembered for the
|
|
55
|
+
* session, so the apply that follows is decided on it at once (`terraformPlans.ts`). */
|
|
56
|
+
async function withTerraformPlans(context, state, failed) {
|
|
57
|
+
if (failed || !/(?:terraform|tofu)\b[^;&|]*\bplan\b[^;&|]*-out/.test(context.command))
|
|
58
|
+
return state;
|
|
59
|
+
const { rememberTerraformPlans } = await import("./controlPlaneTerraform.js");
|
|
60
|
+
const where = { cwd: workingFolder(context.input) ?? null, env: process.env };
|
|
61
|
+
return rememberTerraformPlans(context.command, where, state).catch(() => state);
|
|
62
|
+
}
|
|
54
63
|
/** Each fact's code loads only when the command could carry it: a sign-in
|
|
55
64
|
* only after a failure, resources and a pushed branch only after a success. */
|
|
56
65
|
async function learn(context, state) {
|
|
@@ -62,7 +71,7 @@ async function learn(context, state) {
|
|
|
62
71
|
const resources = failed || !context.findings.length
|
|
63
72
|
? { creates: [], removes: [] }
|
|
64
73
|
: (await import("./cliHookCreates.js")).resourcesOf(context.findings);
|
|
65
|
-
const retry = nextRetry(state, context.command, exitCode, context.now);
|
|
74
|
+
const retry = nextRetry(await withTerraformPlans(context, state, failed), context.command, exitCode, context.now);
|
|
66
75
|
const program = retry.state.retry?.program;
|
|
67
76
|
const pushes = context.findings.some((finding) => finding.vendor === "git" && finding.verb === "push");
|
|
68
77
|
const pushed = failed || !pushes ? undefined : (await import("./cliHookPushed.js")).pushedOf(context.findings);
|
package/dist/cliHookDecide.d.ts
CHANGED
|
@@ -2,9 +2,15 @@
|
|
|
2
2
|
* The guard's decision, only through the control plane (docs/design/control-plane.md). What it asks about, all at
|
|
3
3
|
* once inside the hook's budget:
|
|
4
4
|
*
|
|
5
|
-
* - a consequential `gh`, `git push`, `railway` or `supabase` command on a connected platform
|
|
6
|
-
* `platforms`): `POST /api/cp/decide`,
|
|
7
|
-
* `controlPlaneRailwayGuard.ts`, `controlPlaneSupabase.ts
|
|
5
|
+
* - a consequential `gh`, `git push`, `railway` or `supabase` command on a connected platform, or a `kubectl` or
|
|
6
|
+
* `helm` command (Kubernetes has nothing to connect) (`GET /api/cp/cli` `platforms`): `POST /api/cp/decide`,
|
|
7
|
+
* through the classifiers (`controlPlaneGuard.ts`, `controlPlaneRailwayGuard.ts`, `controlPlaneSupabase.ts`,
|
|
8
|
+
* `controlPlaneKubernetes.ts`); a `terraform` or `tofu` command (Terraform has no setup either), through
|
|
9
|
+
* `controlPlaneTerraform.ts`;
|
|
10
|
+
* - a `sentry-cli` command or a curl to Sentry's API (Sentry needs no setup either): the same, through
|
|
11
|
+
* `controlPlaneSentry.ts`;
|
|
12
|
+
* - an `npm`, `pnpm` or `yarn` command that acts on a registry (npm has nothing to connect): the same, through
|
|
13
|
+
* `controlPlaneNpmGuard.ts`;
|
|
8
14
|
* - a recognized write or delete verb of a vendor CLI that is a basic platform for this person (`vendors`):
|
|
9
15
|
* `POST /api/cp/decide/cli` with the verb only (`controlPlaneCli.ts`);
|
|
10
16
|
* - a command that can't be undone on this computer (`localIrreversible.ts`): `POST /api/cp/decide/cli` as vendor
|
package/dist/cliHookDecide.js
CHANGED
|
@@ -2,9 +2,15 @@
|
|
|
2
2
|
* The guard's decision, only through the control plane (docs/design/control-plane.md). What it asks about, all at
|
|
3
3
|
* once inside the hook's budget:
|
|
4
4
|
*
|
|
5
|
-
* - a consequential `gh`, `git push`, `railway` or `supabase` command on a connected platform
|
|
6
|
-
* `platforms`): `POST /api/cp/decide`,
|
|
7
|
-
* `controlPlaneRailwayGuard.ts`, `controlPlaneSupabase.ts
|
|
5
|
+
* - a consequential `gh`, `git push`, `railway` or `supabase` command on a connected platform, or a `kubectl` or
|
|
6
|
+
* `helm` command (Kubernetes has nothing to connect) (`GET /api/cp/cli` `platforms`): `POST /api/cp/decide`,
|
|
7
|
+
* through the classifiers (`controlPlaneGuard.ts`, `controlPlaneRailwayGuard.ts`, `controlPlaneSupabase.ts`,
|
|
8
|
+
* `controlPlaneKubernetes.ts`); a `terraform` or `tofu` command (Terraform has no setup either), through
|
|
9
|
+
* `controlPlaneTerraform.ts`;
|
|
10
|
+
* - a `sentry-cli` command or a curl to Sentry's API (Sentry needs no setup either): the same, through
|
|
11
|
+
* `controlPlaneSentry.ts`;
|
|
12
|
+
* - an `npm`, `pnpm` or `yarn` command that acts on a registry (npm has nothing to connect): the same, through
|
|
13
|
+
* `controlPlaneNpmGuard.ts`;
|
|
8
14
|
* - a recognized write or delete verb of a vendor CLI that is a basic platform for this person (`vendors`):
|
|
9
15
|
* `POST /api/cp/decide/cli` with the verb only (`controlPlaneCli.ts`);
|
|
10
16
|
* - a command that can't be undone on this computer (`localIrreversible.ts`): `POST /api/cp/decide/cli` as vendor
|
|
@@ -41,6 +47,16 @@ export function githubWord(command, hosts = []) {
|
|
|
41
47
|
const railwayWord = (command) => /railway/i.test(command.replace(/["'\\]/g, ""));
|
|
42
48
|
/** The same for `supabase` (and a `curl` to Supabase's API): the kit's resolver decides what is really Supabase. */
|
|
43
49
|
const supabaseWord = (command) => /supabase/i.test(command.replace(/["'\\]/g, ""));
|
|
50
|
+
/** `kubectl` or `helm` anywhere: the classifier decides what really runs one. */
|
|
51
|
+
const kubernetesWord = (command) => /kubectl|helm/i.test(command.replace(/["'\\]/g, ""));
|
|
52
|
+
/** The same for `terraform` and `tofu`. */
|
|
53
|
+
const terraformWord = (command) => /terraform|tofu/i.test(command.replace(/["'\\]/g, ""));
|
|
54
|
+
/** The same for `sentry-cli` (and a call to Sentry's API, sentry.io). */
|
|
55
|
+
const sentryWord = (command) => /sentry/i.test(command.replace(/["'\\]/g, ""));
|
|
56
|
+
/** The same for `wrangler` (and a raw HTTP call to Cloudflare's API). */
|
|
57
|
+
const cloudflareWord = (command) => /wrangler|api\.cloudflare\.com/i.test(command.replace(/["'\\]/g, ""));
|
|
58
|
+
/** The same for `npm`, `pnpm` and `yarn`: the npm classifier decides what acts on a registry. */
|
|
59
|
+
const npmWord = (command) => /(?:^|[^a-z0-9_-])(?:npm|pnpm|yarn)(?:$|[^a-z0-9_-])/i.test(command.replace(/["'\\]/g, ""));
|
|
44
60
|
/** A verb as the server reads it (`CLI_VERB` in server/src/controlPlane/cliRoutes.ts): never an argument. */
|
|
45
61
|
const CLI_VERB = /^-{0,2}[a-z0-9][a-z0-9_:-]*(?: -{0,2}[a-z0-9][a-z0-9_:-]*){0,3}$/;
|
|
46
62
|
const VERB_TOKEN = /^-{0,2}[A-Za-z0-9][A-Za-z0-9._:+-]{0,39}$/;
|
|
@@ -87,6 +103,11 @@ function asking(context, local) {
|
|
|
87
103
|
github: Boolean(cp?.platforms.github) && githubWord(command, cp?.githubHosts),
|
|
88
104
|
railway: Boolean(cp?.platforms.railway) && railwayWord(command),
|
|
89
105
|
supabase: Boolean(cp?.platforms.supabase) && supabaseWord(command),
|
|
106
|
+
kubernetes: Boolean(cp?.platforms.kubernetes) && kubernetesWord(command),
|
|
107
|
+
terraform: Boolean(cp?.platforms.terraform) && terraformWord(command),
|
|
108
|
+
sentry: Boolean(cp?.platforms.sentry) && sentryWord(command),
|
|
109
|
+
cloudflare: Boolean(cp?.platforms.cloudflare) && cloudflareWord(command),
|
|
110
|
+
npm: Boolean(cp?.platforms.npm) && npmWord(command),
|
|
90
111
|
verbs: [
|
|
91
112
|
...vendorVerbs(context.findings, cp?.vendors ?? []),
|
|
92
113
|
...local.map((verb) => [LOCAL_VENDOR, verb])
|
|
@@ -101,14 +122,15 @@ export async function planGuard(context) {
|
|
|
101
122
|
});
|
|
102
123
|
if (!context.canAsk)
|
|
103
124
|
return local[0] ? refuse(local[0], "signed-out") : { output: null };
|
|
104
|
-
const { github, railway, supabase, verbs } = asking(context, local);
|
|
125
|
+
const { github, railway, supabase, kubernetes, terraform, sentry, cloudflare, npm, verbs } = asking(context, local);
|
|
105
126
|
const left = context.deadline - context.now();
|
|
106
127
|
if (left <= 0) {
|
|
107
128
|
if (local[0])
|
|
108
129
|
return refuse(local[0], "unreachable");
|
|
109
|
-
|
|
130
|
+
const asked = { github, railway, supabase, kubernetes, terraform, sentry, cloudflare, npm };
|
|
131
|
+
return { output: await whenUnreachable(context, asked, []) };
|
|
110
132
|
}
|
|
111
|
-
if (!github
|
|
133
|
+
if (![github, railway, supabase, kubernetes, terraform, sentry, cloudflare, npm].some(Boolean) && !verbs.length)
|
|
112
134
|
return { output: null };
|
|
113
135
|
// The kit's shadow run (`kitShadow.ts`) stops before the guard's deadline.
|
|
114
136
|
setShadowDeadline(context.deadline, context.now);
|
|
@@ -116,28 +138,36 @@ export async function planGuard(context) {
|
|
|
116
138
|
const open = async () => (api ??= (await context.openApi()) ?? undefined) ?? null;
|
|
117
139
|
const signal = AbortSignal.any([context.budget, AbortSignal.timeout(left)]);
|
|
118
140
|
const extra = context.report?.sessionId ? { sessionId: context.report.sessionId } : {};
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
const threw = { github: false, railway: false, supabase: false };
|
|
122
|
-
const failed = (platform) => () => {
|
|
123
|
-
threw[platform] = true;
|
|
124
|
-
return null;
|
|
125
|
-
};
|
|
126
|
-
const [githubLine, railwayAnswer, supabaseAnswer, verbAnswers] = await Promise.all([
|
|
127
|
-
github ? githubLinePlan(context, open, extra, signal).catch(failed("github")) : null,
|
|
128
|
-
railway ? railwayLine(context, open, extra, signal).catch(failed("railway")) : null,
|
|
129
|
-
supabase ? supabaseLine(context, open, extra, signal).catch(failed("supabase")) : null,
|
|
130
|
-
askVerbs(verbs, open, extra, signal).catch(() => [])
|
|
131
|
-
]);
|
|
141
|
+
const asked = { github, railway, supabase, kubernetes, terraform, sentry, cloudflare, npm };
|
|
142
|
+
const { threw, githubLine, railwayAnswer, supabaseAnswer, kubernetesAnswer, terraformAnswer, sentryAnswer, cloudflareAnswer, npmAnswer, verbAnswers } = await askAll(context, asked, verbs, { open, extra, signal });
|
|
132
143
|
// Decided: the kit's shadow run reads what was asked about, off the decision's path.
|
|
133
144
|
shadowAfterDecision();
|
|
134
145
|
const withApi = (output) => ({ output, ...(api ? { api } : {}) });
|
|
135
|
-
const answers = [
|
|
146
|
+
const answers = [
|
|
147
|
+
githubLine?.decided?.answer,
|
|
148
|
+
railwayAnswer?.answer,
|
|
149
|
+
supabaseAnswer?.answer,
|
|
150
|
+
kubernetesAnswer?.answer,
|
|
151
|
+
terraformAnswer?.answer,
|
|
152
|
+
sentryAnswer?.answer,
|
|
153
|
+
cloudflareAnswer?.answer,
|
|
154
|
+
npmAnswer?.answer,
|
|
155
|
+
...verbAnswers
|
|
156
|
+
];
|
|
136
157
|
const blocked = answers.find((answer) => answer?.kind === "block");
|
|
137
158
|
if (blocked)
|
|
138
159
|
return withApi(denyOutput(context.client, blocked.message));
|
|
139
160
|
const late = answers.flatMap((answer) => (answer?.kind === "unreachable" ? (answer.late ?? []) : []));
|
|
140
|
-
const
|
|
161
|
+
const others = {
|
|
162
|
+
railwayAnswer,
|
|
163
|
+
supabaseAnswer,
|
|
164
|
+
kubernetesAnswer,
|
|
165
|
+
terraformAnswer,
|
|
166
|
+
sentryAnswer,
|
|
167
|
+
cloudflareAnswer,
|
|
168
|
+
npmAnswer
|
|
169
|
+
};
|
|
170
|
+
const missed = missedPlatforms(asked, threw, githubLine, othersOf(others));
|
|
141
171
|
const offline = await whenUnreachable(context, missed, late);
|
|
142
172
|
if (offline)
|
|
143
173
|
return withApi(offline);
|
|
@@ -148,9 +178,83 @@ export async function planGuard(context) {
|
|
|
148
178
|
return withApi(refuse(unanswered, "unreachable").output);
|
|
149
179
|
// The whole line is allowed: each decision is left for what spends it, and the unanswered ones for the after-hook.
|
|
150
180
|
await supabaseAnswer?.leave();
|
|
151
|
-
await leaveDecisions(githubLine?.decided ?? null, railwayAnswer, context, [
|
|
181
|
+
await leaveDecisions(githubLine?.decided ?? null, railwayAnswer, context, [
|
|
182
|
+
supabaseAnswer?.answer,
|
|
183
|
+
kubernetesAnswer?.answer,
|
|
184
|
+
terraformAnswer?.answer,
|
|
185
|
+
sentryAnswer?.answer,
|
|
186
|
+
cloudflareAnswer?.answer,
|
|
187
|
+
npmAnswer?.answer,
|
|
188
|
+
...verbAnswers
|
|
189
|
+
]);
|
|
152
190
|
return withApi(null);
|
|
153
191
|
}
|
|
192
|
+
/** Each platform's answer but GitHub's (which is the line's), for the offline rules. */
|
|
193
|
+
function othersOf(answers) {
|
|
194
|
+
return {
|
|
195
|
+
railway: answers.railwayAnswer?.answer,
|
|
196
|
+
supabase: answers.supabaseAnswer?.answer,
|
|
197
|
+
kubernetes: answers.kubernetesAnswer?.answer,
|
|
198
|
+
terraform: answers.terraformAnswer?.answer,
|
|
199
|
+
sentry: answers.sentryAnswer?.answer,
|
|
200
|
+
cloudflare: answers.cloudflareAnswer?.answer,
|
|
201
|
+
npm: answers.npmAnswer?.answer
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
/** Every platform's part of a line, asked at once. A step that fails is no answer from its platform (it counts as
|
|
205
|
+
* unreachable for the offline rules); it never drops another's block or a local refusal. */
|
|
206
|
+
async function askAll(context, asked, verbs, how) {
|
|
207
|
+
const { open, extra, signal } = how;
|
|
208
|
+
const threw = {
|
|
209
|
+
github: false,
|
|
210
|
+
railway: false,
|
|
211
|
+
supabase: false,
|
|
212
|
+
kubernetes: false,
|
|
213
|
+
terraform: false,
|
|
214
|
+
sentry: false,
|
|
215
|
+
cloudflare: false,
|
|
216
|
+
npm: false
|
|
217
|
+
};
|
|
218
|
+
const failed = (platform) => () => {
|
|
219
|
+
threw[platform] = true;
|
|
220
|
+
return null;
|
|
221
|
+
};
|
|
222
|
+
const [githubLine, railwayAnswer, supabaseAnswer, kubernetesAnswer, terraformAnswer, sentryAnswer, cloudflareAnswer, npmAnswer, verbAnswers] = await Promise.all([
|
|
223
|
+
asked.github ? githubLinePlan(context, open, extra, signal).catch(failed("github")) : null,
|
|
224
|
+
asked.railway ? railwayLine(context, open, extra, signal).catch(failed("railway")) : null,
|
|
225
|
+
asked.supabase ? supabaseLine(context, open, extra, signal).catch(failed("supabase")) : null,
|
|
226
|
+
asked.kubernetes ? kubernetesLine(context, open, extra, signal).catch(failed("kubernetes")) : null,
|
|
227
|
+
asked.terraform ? terraformLine(context, open, extra, signal).catch(failed("terraform")) : null,
|
|
228
|
+
asked.sentry ? sentryLine(context, open, extra, signal).catch(failed("sentry")) : null,
|
|
229
|
+
asked.cloudflare ? cloudflareLine(context, open, extra, signal).catch(failed("cloudflare")) : null,
|
|
230
|
+
asked.npm ? npmLine(context, open, extra, signal).catch(failed("npm")) : null,
|
|
231
|
+
askVerbs(verbs, open, extra, signal).catch(() => [])
|
|
232
|
+
]);
|
|
233
|
+
return {
|
|
234
|
+
threw,
|
|
235
|
+
githubLine,
|
|
236
|
+
railwayAnswer,
|
|
237
|
+
supabaseAnswer,
|
|
238
|
+
kubernetesAnswer,
|
|
239
|
+
terraformAnswer,
|
|
240
|
+
sentryAnswer,
|
|
241
|
+
cloudflareAnswer,
|
|
242
|
+
npmAnswer,
|
|
243
|
+
verbAnswers
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
async function npmLine(context, open, extra, signal) {
|
|
247
|
+
const where = { cwd: context.cwd ?? null, env: context.env ?? process.env, home: homedir() };
|
|
248
|
+
return (await import("./controlPlaneNpmGuard.js")).npmLinePlan(context.command, where, open, extra, signal);
|
|
249
|
+
}
|
|
250
|
+
async function cloudflareLine(context, open, extra, signal) {
|
|
251
|
+
const where = { cwd: context.cwd ?? null, env: context.env ?? process.env };
|
|
252
|
+
return (await import("./controlPlaneCloudflare.js")).cloudflareLinePlan(context.command, where, open, extra, signal);
|
|
253
|
+
}
|
|
254
|
+
async function sentryLine(context, open, extra, signal) {
|
|
255
|
+
const where = { cwd: context.cwd ?? null, env: context.env ?? process.env };
|
|
256
|
+
return (await import("./controlPlaneSentry.js")).sentryLinePlan(context.command, where, open, extra, signal);
|
|
257
|
+
}
|
|
154
258
|
async function railwayLine(context, open, extra, signal) {
|
|
155
259
|
const where = { cwd: context.cwd, env: context.env ?? process.env, home: homedir() };
|
|
156
260
|
return (await import("./controlPlaneRailwayGuard.js")).railwayLinePlan(context.command, where, open, extra, signal);
|
|
@@ -159,6 +263,29 @@ async function supabaseLine(context, open, extra, signal) {
|
|
|
159
263
|
const where = { cwd: context.cwd ?? null, env: context.env ?? process.env };
|
|
160
264
|
return (await import("./controlPlaneSupabase.js")).supabaseLinePlan(context.command, where, open, extra, signal);
|
|
161
265
|
}
|
|
266
|
+
async function kubernetesLine(context, open, extra, signal) {
|
|
267
|
+
const where = { cwd: context.cwd ?? null, env: context.env ?? process.env, home: homedir() };
|
|
268
|
+
return (await import("./controlPlaneKubernetes.js")).kubernetesLinePlan(context.command, where, open, extra, signal);
|
|
269
|
+
}
|
|
270
|
+
/** Terraform's part of a line, with the session's plans (`terraformPlans.ts`) and what is left of the budget for
|
|
271
|
+
* reading one. */
|
|
272
|
+
async function terraformLine(context, open, extra, signal) {
|
|
273
|
+
const where = { cwd: context.cwd ?? null, env: context.env ?? process.env };
|
|
274
|
+
const [{ terraformLinePlan }, sessions] = await Promise.all([
|
|
275
|
+
import("./controlPlaneTerraform.js"),
|
|
276
|
+
import("./cliHookSessionState.js")
|
|
277
|
+
]);
|
|
278
|
+
const runtime = context.report?.runtime;
|
|
279
|
+
const sessionId = context.report?.sessionId;
|
|
280
|
+
const state = runtime ? sessions.readSessionState(runtime, sessionId, context.now()) : {};
|
|
281
|
+
// Half of what is left reads a plan; the rest asks Passport.
|
|
282
|
+
const planMs = Math.max(0, Math.floor((context.deadline - context.now()) / 2));
|
|
283
|
+
const save = (next) => {
|
|
284
|
+
if (runtime)
|
|
285
|
+
sessions.writeSessionState(runtime, sessionId, next);
|
|
286
|
+
};
|
|
287
|
+
return terraformLinePlan(context.command, where, open, extra, signal, { state, planMs, save });
|
|
288
|
+
}
|
|
162
289
|
async function askVerbs(verbs, open, extra, signal) {
|
|
163
290
|
if (!verbs.length)
|
|
164
291
|
return [];
|
|
@@ -195,18 +322,28 @@ async function leaveDecisions(github, railway, context, others) {
|
|
|
195
322
|
// A push's decisions are no longer left for `passport git-credential`: it issues no token in v1 (2026-11-16).
|
|
196
323
|
if (railway)
|
|
197
324
|
await railway.leave();
|
|
325
|
+
// A merge that didn't name its pull request: the after-hook names it from gh's output (`githubMergeHold.ts`).
|
|
326
|
+
if (github?.merges.length)
|
|
327
|
+
(await import("./githubMergeHold.js")).holdMerges(context.report?.sessionId, context.report?.toolUseId, github.merges, context.now());
|
|
198
328
|
await holdLate([github?.answer, railway?.answer, ...others], context.report, context.now());
|
|
199
329
|
}
|
|
200
330
|
/** The platforms asked and not answered: Passport couldn't be reached for them. Every non-answer counts: no response,
|
|
201
331
|
* a 401, 403, 404, 429 or 5xx, a timeout, a 200 that isn't Passport's JSON (each reads as unreachable), or a step
|
|
202
332
|
* that threw. An `undecided` from Passport itself is an answer. */
|
|
203
|
-
function missedPlatforms(asked, threw, github,
|
|
333
|
+
function missedPlatforms(asked, threw, github, others) {
|
|
204
334
|
// A real `undecided` (Passport answered, and doesn't decide this) keeps today's behavior: it isn't offline.
|
|
205
335
|
const missed = (answer) => !answer || answer.kind === "unreachable";
|
|
206
336
|
return {
|
|
207
337
|
github: asked.github && (threw.github || (Boolean(github?.label) && missed(github?.decided?.answer))),
|
|
208
|
-
railway: asked.railway && (threw.railway || missed(railway)),
|
|
209
|
-
supabase: asked.supabase && (threw.supabase || missed(supabase))
|
|
338
|
+
railway: asked.railway && (threw.railway || missed(others.railway)),
|
|
339
|
+
supabase: asked.supabase && (threw.supabase || missed(others.supabase)),
|
|
340
|
+
// A line with no kubectl or helm write asks nothing: no answer to miss.
|
|
341
|
+
kubernetes: asked.kubernetes && (threw.kubernetes || (others.kubernetes !== null && missed(others.kubernetes))),
|
|
342
|
+
terraform: asked.terraform && (threw.terraform || missed(others.terraform)),
|
|
343
|
+
sentry: asked.sentry && (threw.sentry || missed(others.sentry)),
|
|
344
|
+
// A line with no consequential wrangler command asks nothing: no answer to miss.
|
|
345
|
+
cloudflare: asked.cloudflare && (threw.cloudflare || (others.cloudflare !== null && missed(others.cloudflare))),
|
|
346
|
+
npm: asked.npm && (threw.npm || missed(others.npm))
|
|
210
347
|
};
|
|
211
348
|
}
|
|
212
349
|
/** What the line does on each platform Passport didn't answer for, classified on this computer. */
|
|
@@ -229,13 +366,33 @@ async function foundOffline(context, missed) {
|
|
|
229
366
|
const where = { cwd: context.cwd ?? null, env: context.env ?? process.env };
|
|
230
367
|
found.push(...(await import("./controlPlaneSupabase.js")).supabaseFound(context.command, where));
|
|
231
368
|
}
|
|
369
|
+
if (missed.kubernetes) {
|
|
370
|
+
const where = { cwd: context.cwd ?? null, env: context.env ?? process.env, home: homedir() };
|
|
371
|
+
found.push(...(await import("./controlPlaneKubernetes.js")).kubernetesFound(context.command, where));
|
|
372
|
+
}
|
|
373
|
+
if (missed.terraform) {
|
|
374
|
+
const where = { cwd: context.cwd ?? null, env: context.env ?? process.env };
|
|
375
|
+
found.push(...(await (await import("./controlPlaneTerraform.js")).terraformFound(context.command, where)));
|
|
376
|
+
}
|
|
377
|
+
if (missed.sentry) {
|
|
378
|
+
const where = { cwd: context.cwd ?? null, env: context.env ?? process.env };
|
|
379
|
+
found.push(...(await import("./controlPlaneSentry.js")).sentryFound(context.command, where));
|
|
380
|
+
}
|
|
381
|
+
if (missed.cloudflare) {
|
|
382
|
+
const where = { cwd: context.cwd ?? null, env: context.env ?? process.env };
|
|
383
|
+
found.push(...(await import("./controlPlaneCloudflare.js")).cloudflareFound(context.command, where));
|
|
384
|
+
}
|
|
385
|
+
if (missed.npm) {
|
|
386
|
+
const where = { cwd: context.cwd ?? null, env: context.env ?? process.env, home: homedir() };
|
|
387
|
+
found.push(...(await import("./controlPlaneNpmGuard.js")).npmFound(context.command, where));
|
|
388
|
+
}
|
|
232
389
|
return found;
|
|
233
390
|
}
|
|
234
391
|
/** The guard never got to ask (its budget ran out first, or something failed before it answered): every platform the
|
|
235
392
|
* line would have asked about counts as unreachable, so a covered action is refused and the rest is recorded. */
|
|
236
393
|
export async function planUnreachable(context) {
|
|
237
|
-
const { github, railway, supabase } = asking(context, []);
|
|
238
|
-
return whenUnreachable(context, { github, railway, supabase }, []);
|
|
394
|
+
const { github, railway, supabase, kubernetes, terraform, sentry, cloudflare, npm } = asking(context, []);
|
|
395
|
+
return whenUnreachable(context, { github, railway, supabase, kubernetes, terraform, sentry, cloudflare, npm }, []);
|
|
239
396
|
}
|
|
240
397
|
/** What the agent reads when the guard couldn't even classify a line Passport didn't answer for. */
|
|
241
398
|
export const UNCHECKED_REFUSAL = "Passport couldn't be reached or check this command, so it didn't run.";
|
|
@@ -246,7 +403,7 @@ export const UNCHECKED_REFUSAL = "Passport couldn't be reached or check this com
|
|
|
246
403
|
* (recorded as no rules known). Anything that throws here refuses: a covered action is never allowed by an error.
|
|
247
404
|
*/
|
|
248
405
|
async function whenUnreachable(context, missed, late) {
|
|
249
|
-
if (!
|
|
406
|
+
if (!Object.values(missed).some(Boolean))
|
|
250
407
|
return null;
|
|
251
408
|
try {
|
|
252
409
|
const found = await foundOffline(context, missed);
|
package/dist/cliHookDeliver.d.ts
CHANGED
|
@@ -156,8 +156,8 @@ export declare function flushDeadline(release: () => void, exit?: (code: number)
|
|
|
156
156
|
* process nobody waits for. Only one runs at a time per profile, and a
|
|
157
157
|
* detached one always exits by FLUSH_DEADLINE_MS. */
|
|
158
158
|
export declare function runFlush(args: ParsedArgs, runtime: Runtime, deps: HookDependencies): Promise<void>;
|
|
159
|
-
/** Leftover budget: Activity reports, late notices, the computer's daily
|
|
160
|
-
* report, and, at most hourly, a refresh of what the control plane decides. */
|
|
159
|
+
/** Leftover budget: Activity reports, late notices, a merge's pull request for its decision, the computer's daily
|
|
160
|
+
* guard report, and, at most hourly, a refresh of what the control plane decides. */
|
|
161
161
|
export declare function leftovers(queued: CliHookReport[], context: {
|
|
162
162
|
profile: string;
|
|
163
163
|
api?: ApiCall;
|
package/dist/cliHookDeliver.js
CHANGED
|
@@ -283,19 +283,22 @@ export async function runFlush(args, runtime, deps) {
|
|
|
283
283
|
release();
|
|
284
284
|
}
|
|
285
285
|
}
|
|
286
|
-
/** Leftover budget: Activity reports, late notices, the computer's daily
|
|
287
|
-
* report, and, at most hourly, a refresh of what the control plane decides. */
|
|
286
|
+
/** Leftover budget: Activity reports, late notices, a merge's pull request for its decision, the computer's daily
|
|
287
|
+
* guard report, and, at most hourly, a refresh of what the control plane decides. */
|
|
288
288
|
export async function leftovers(queued, context) {
|
|
289
289
|
const { profile, budget, deps } = context;
|
|
290
290
|
const now = (deps.now ?? Date.now)();
|
|
291
291
|
const late = await import("./controlPlaneLate.js");
|
|
292
292
|
const offlineNotices = await import("./controlPlaneOffline.js");
|
|
293
293
|
const { offline, rest } = offlineNotices.splitOffline(queued);
|
|
294
|
-
|
|
294
|
+
// A merge's pull request for its decision (`githubMergeHold.ts`), loaded only when one is queued.
|
|
295
|
+
const merges = rest.some((entry) => "cpDecideIds" in entry) ? await import("./githubMergeHold.js") : null;
|
|
296
|
+
const { ids: decisionIds, rest: unsplit } = merges ? merges.splitDecisionIds(rest) : { ids: [], rest };
|
|
297
|
+
const { late: lateIds, reports } = late.splitLate(unsplit);
|
|
295
298
|
const refresh = claimStaleRefresh(profile, readCpCli(profile), now);
|
|
296
299
|
const extras = await import("./cliHookExtras.js");
|
|
297
300
|
const heartbeat = await extras.heartbeatDue(profile, now);
|
|
298
|
-
if (!reports.length && !lateIds.length && !offline.length && !refresh && !heartbeat)
|
|
301
|
+
if (!reports.length && !lateIds.length && !decisionIds.length && !offline.length && !refresh && !heartbeat)
|
|
299
302
|
return;
|
|
300
303
|
const api = context.api ?? (await profileApi(profile, budget, deps.fetch ?? fetch));
|
|
301
304
|
if (!api)
|
|
@@ -306,6 +309,7 @@ export async function leftovers(queued, context) {
|
|
|
306
309
|
await Promise.allSettled([
|
|
307
310
|
...reports.map((entry) => send(entry)),
|
|
308
311
|
lateIds.length ? late.tellLate(api, lateIds, budget) : null,
|
|
312
|
+
merges && decisionIds.length ? merges.sendDecisionIds(api, decisionIds, budget) : null,
|
|
309
313
|
offline.length ? offlineNotices.tellOffline(api, offline, budget) : null,
|
|
310
314
|
heartbeat ? extras.heartbeat(api, profile, context.runtime.env, budget, now) : null,
|
|
311
315
|
refresh ? refreshCpCli(profile, budget, { api, ...(deps.now ? { now: deps.now } : {}) }) : null
|
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* Cursor on their next try. One small owner-only file per session, named by a
|
|
7
7
|
* digest of the agent and session id; bounded in count and age. Never throws.
|
|
8
8
|
*/
|
|
9
|
+
import type { PlanMemo } from "./terraformPlans.js";
|
|
9
10
|
/** A session quiet this long starts over. */
|
|
10
11
|
export declare const STATE_MAX_AGE_MS: number;
|
|
11
12
|
/** A sign-in failure is told to Codex or Cursor on a try within this long. */
|
|
@@ -21,11 +22,13 @@ export type SignInState = {
|
|
|
21
22
|
held: boolean;
|
|
22
23
|
at: number;
|
|
23
24
|
};
|
|
24
|
-
/** `created`: folders this session made itself (`sessionCreated.ts`), canonical paths.
|
|
25
|
+
/** `created`: folders this session made itself (`sessionCreated.ts`), canonical paths. `terraformPlans`: the plans
|
|
26
|
+
* this session made or read, reduced to counts and resource-type names (`terraformPlans.ts`). */
|
|
25
27
|
export type SessionState = {
|
|
26
28
|
retry?: RetryState;
|
|
27
29
|
signIn?: SignInState;
|
|
28
30
|
created?: string[];
|
|
31
|
+
terraformPlans?: PlanMemo[];
|
|
29
32
|
};
|
|
30
33
|
/** The same command, however it was spaced, and the command inside a
|
|
31
34
|
* `passport exec` rewrite, so the guard's and the after-hook's agree. */
|
|
@@ -70,7 +70,7 @@ export function writeSessionState(runtime, sessionId, state) {
|
|
|
70
70
|
if (!path)
|
|
71
71
|
return;
|
|
72
72
|
try {
|
|
73
|
-
if (!state.retry && !state.signIn && !state.created?.length) {
|
|
73
|
+
if (!state.retry && !state.signIn && !state.created?.length && !state.terraformPlans?.length) {
|
|
74
74
|
rmSync(path, { force: true });
|
|
75
75
|
return;
|
|
76
76
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { Effect, EffectVerb, ObjectType } from "../controlPlaneActions.generated.js";
|
|
2
|
+
/**
|
|
3
|
+
* Per-call effects for the kit's apps (docs/design/control-plane.md, "Action model", Layer 2 inputs): what the
|
|
4
|
+
* operation a classifier named does, from its summary template ("Restart {where}", "Delete branch {name}"), which the
|
|
5
|
+
* kit renders from the call's arguments and both sides send. The server reads them for the gateway and the guard
|
|
6
|
+
* alike, so no bridge release is needed for a new entry. A summary no template matches keeps its action's defaults.
|
|
7
|
+
*/
|
|
8
|
+
/** One reviewed operation: the action key it is classified as (the classifier's own, before `REMOVED_ACTIONS`), its
|
|
9
|
+
* summary template, and its effects. */
|
|
10
|
+
export type CallEffectEntry = readonly [actionKey: string, template: string, effects: readonly Effect[]];
|
|
11
|
+
/** A summary template as a pattern: each `{param}` matches any text, and the kit's own asides (" (staged)", "(run SQL
|
|
12
|
+
* on project x)") may follow. */
|
|
13
|
+
export declare function templatePattern(template: string): RegExp;
|
|
14
|
+
export type CallEffectsOf = (keys: readonly string[], summary: string) => Effect[] | undefined;
|
|
15
|
+
/** A lookup over reviewed entries: the most specific template of one of `keys` (the classification's key and the
|
|
16
|
+
* catalog key it is recorded as) that matches the summary. */
|
|
17
|
+
export declare function callEffectsTable(entries: readonly CallEffectEntry[]): CallEffectsOf;
|
|
18
|
+
/** The verb an operation's first word says; anything else changes something. */
|
|
19
|
+
export declare function verbOf(words: string): EffectVerb;
|
|
20
|
+
export declare function objectOf(words: string): ObjectType;
|
|
21
|
+
/** The derivation: the words' verb on their object type, a run created when the words start code. */
|
|
22
|
+
export declare function deriveEffects(words: string): Effect[];
|
|
23
|
+
/** Something stops working: Destructive beside whatever else the call does. */
|
|
24
|
+
export declare const OUTAGE: Effect;
|
|
25
|
+
/** It may stop something working (a restart under load, a key some app may still use). */
|
|
26
|
+
export declare const MAY_OUTAGE: Effect;
|
|
27
|
+
/** Starts code running now. */
|
|
28
|
+
export declare const RUN: Effect;
|
|
29
|
+
/** May start code running later (a variable change Railway redeploys on, a trigger). */
|
|
30
|
+
export declare const MAY_RUN_LATER: Effect;
|
|
31
|
+
/** Reachable from the internet (a domain, a TCP proxy, a public bucket). */
|
|
32
|
+
export declare const PUBLIC_DATA: Effect;
|
|
33
|
+
/** An invitation emails the person invited. */
|
|
34
|
+
export declare const EMAILS_OUTSIDE: Effect;
|
|
35
|
+
/** It changes what the workspace pays (an add-on, compute, a usage limit). */
|
|
36
|
+
export declare const BILLING: Effect;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
const escape = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
2
|
+
/** A summary template as a pattern: each `{param}` matches any text, and the kit's own asides (" (staged)", "(run SQL
|
|
3
|
+
* on project x)") may follow. */
|
|
4
|
+
export function templatePattern(template) {
|
|
5
|
+
const literal = template.split(/\{[^}]*\}/).map(escape);
|
|
6
|
+
return new RegExp(`^${literal.join(".+?")}(?: \\(.*\\))?$`, "s");
|
|
7
|
+
}
|
|
8
|
+
/** How many literal characters a template has: the more, the more specific. */
|
|
9
|
+
const specificity = (template) => template.replace(/\{[^}]*\}/g, "").length;
|
|
10
|
+
/** A lookup over reviewed entries: the most specific template of one of `keys` (the classification's key and the
|
|
11
|
+
* catalog key it is recorded as) that matches the summary. */
|
|
12
|
+
export function callEffectsTable(entries) {
|
|
13
|
+
const compiled = [...entries]
|
|
14
|
+
.sort((a, b) => specificity(b[1]) - specificity(a[1]))
|
|
15
|
+
.map(([key, template, effects]) => ({ key, pattern: templatePattern(template), effects }));
|
|
16
|
+
return (keys, summary) => {
|
|
17
|
+
const text = summary.trim();
|
|
18
|
+
const found = compiled.find((entry) => keys.includes(entry.key) && entry.pattern.test(text));
|
|
19
|
+
return found ? found.effects.map((effect) => ({ ...effect })) : undefined;
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
const DELETE_WORDS = /^(delete|remove|drop|empty|purge|destroy)\b/i;
|
|
23
|
+
const CREATE_WORDS = /^(create|add|invite|upload|seed|import|accept|generate|define|record)\b/i;
|
|
24
|
+
/** The verb an operation's first word says; anything else changes something. */
|
|
25
|
+
export function verbOf(words) {
|
|
26
|
+
if (DELETE_WORDS.test(words))
|
|
27
|
+
return "delete";
|
|
28
|
+
if (CREATE_WORDS.test(words))
|
|
29
|
+
return "create";
|
|
30
|
+
return "change";
|
|
31
|
+
}
|
|
32
|
+
/** Object type by an operation's words, first match wins (shared by Railway and Supabase). */
|
|
33
|
+
const OBJECT_RULES = [
|
|
34
|
+
[
|
|
35
|
+
/secret|api key|jwt|signing key|token|password|role|privilege|grant|member|access|sign-in|sso|saml|auth|ssl|network|claim|encryption|variable|credential|sign-ups|policy/i,
|
|
36
|
+
"access"
|
|
37
|
+
],
|
|
38
|
+
[/deploy|redeploy|restart|rollback|run |shell|ssh|session/i, "run"],
|
|
39
|
+
[/function|code|source/i, "code"],
|
|
40
|
+
[/notebook|history entry|migration history|from history/i, "record"],
|
|
41
|
+
[/table|rows|data|bucket|object|migration|backup|restore|branch|database|volume|dump|seed/i, "data"]
|
|
42
|
+
];
|
|
43
|
+
export function objectOf(words) {
|
|
44
|
+
for (const [pattern, object] of OBJECT_RULES)
|
|
45
|
+
if (pattern.test(words))
|
|
46
|
+
return object;
|
|
47
|
+
return "service";
|
|
48
|
+
}
|
|
49
|
+
/** The derivation: the words' verb on their object type, a run created when the words start code. */
|
|
50
|
+
export function deriveEffects(words) {
|
|
51
|
+
const verb = verbOf(words);
|
|
52
|
+
const object = objectOf(words);
|
|
53
|
+
if (object === "run")
|
|
54
|
+
return verb === "delete" ? [{ verb: "change", object: "run" }] : [{ verb: "create", object }];
|
|
55
|
+
return [{ verb, object }];
|
|
56
|
+
}
|
|
57
|
+
/* ------------------------------------------------------------------ */
|
|
58
|
+
/* Effects the reviews reuse */
|
|
59
|
+
/* ------------------------------------------------------------------ */
|
|
60
|
+
/** Something stops working: Destructive beside whatever else the call does. */
|
|
61
|
+
export const OUTAGE = { verb: "change", object: "service", disrupts: true };
|
|
62
|
+
/** It may stop something working (a restart under load, a key some app may still use). */
|
|
63
|
+
export const MAY_OUTAGE = { verb: "change", object: "service", disrupts: true, possible: true };
|
|
64
|
+
/** Starts code running now. */
|
|
65
|
+
export const RUN = { verb: "create", object: "run" };
|
|
66
|
+
/** May start code running later (a variable change Railway redeploys on, a trigger). */
|
|
67
|
+
export const MAY_RUN_LATER = { verb: "create", object: "run", when: "later", possible: true };
|
|
68
|
+
/** Reachable from the internet (a domain, a TCP proxy, a public bucket). */
|
|
69
|
+
export const PUBLIC_DATA = { verb: "change", object: "data", audience: "public" };
|
|
70
|
+
/** An invitation emails the person invited. */
|
|
71
|
+
export const EMAILS_OUTSIDE = { verb: "create", object: "message", audience: "outside" };
|
|
72
|
+
/** It changes what the workspace pays (an add-on, compute, a usage limit). */
|
|
73
|
+
export const BILLING = { verb: "change", object: "money" };
|
|
@@ -80,9 +80,12 @@ function parseArgs(words, specs, strict, framework) {
|
|
|
80
80
|
out.positional.push(...words.slice(i + 1));
|
|
81
81
|
break;
|
|
82
82
|
}
|
|
83
|
-
|
|
83
|
+
// Go's flag package: one dash or two, never letters grouped (`-auto-approve`, `--out=plan`).
|
|
84
|
+
const go = framework === "go" && word.startsWith("-") && word.length > 1 && word !== "-";
|
|
85
|
+
if (word.startsWith("--") || go) {
|
|
86
|
+
const dashes = word.startsWith("--") ? 2 : 1;
|
|
84
87
|
const eq = word.indexOf("=");
|
|
85
|
-
const name = eq < 0 ? word.slice(
|
|
88
|
+
const name = eq < 0 ? word.slice(dashes) : word.slice(dashes, eq);
|
|
86
89
|
const spec = long.get(name);
|
|
87
90
|
if (!spec) {
|
|
88
91
|
if (strict)
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
import { type Classification, type DiscoveredNode } from "../controlPlane.generated.js";
|
|
19
19
|
import { type Manifest } from "./manifest.generated.js";
|
|
20
20
|
import type { ClassifyContext, ConnectorHooks, Normalized, Request } from "./types.generated.js";
|
|
21
|
-
export { at, fill, parseTemplate, placeholders, render, safeName } from "./template.generated.js";
|
|
21
|
+
export { at, fill, parseTemplate, placeholders, render, safeName, valuePlaceholders } from "./template.generated.js";
|
|
22
22
|
export type * from "./types.generated.js";
|
|
23
23
|
export declare function normalize(m: Manifest, request: Request): Normalized | null;
|
|
24
24
|
export type Chain = {
|