postgresai 0.19.0-rc.5 → 0.19.0-rc.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -3
- package/dist/bin/postgres-ai.js +177 -27
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -196,8 +196,8 @@ pgai mon deploy 'postgresql://postgres:<password>@<host>:5432/postgres'
|
|
|
196
196
|
```
|
|
197
197
|
|
|
198
198
|
It signs you in if needed, creates the `postgres_ai_mon` role (with an admin URL; otherwise it
|
|
199
|
-
prints the SQL), provisions monitoring in PostgresAI Cloud, waits, and prints two links: the project's
|
|
200
|
-
(`<console>/<org>/projects/<project>/health`, the next step) and Grafana, which signs you in
|
|
199
|
+
prints the SQL), provisions monitoring in PostgresAI Cloud, waits, and prints two links: the project's Database health in the console
|
|
200
|
+
(`<console>/<org>/projects/<project>/health-preview`, the next step) and Grafana, which signs you in
|
|
201
201
|
with your PostgresAI account (`https://<box>/login/generic_oauth?redirectTo=%2F`). Safe to re-run; a `--clickhouse-key` given on a
|
|
202
202
|
re-run is checked, and a rejected one is `action_required`. For ClickHouse Managed Postgres add `--clickhouse-key <key-id>:<key-secret>`
|
|
203
203
|
(a Basic Service API Reader key) for CPU, memory and disk. `--self-hosted` runs the stack on this
|
|
@@ -633,7 +633,7 @@ Tools exposed:
|
|
|
633
633
|
- `list_issues`: returns the same JSON as `postgresai issues list` (args: `{ org_id, status?, hidden_only?, limit?, offset?, debug? }`). Unlike the CLI, omitting `status` returns open and closed issues; pass `status: "open"` to match the CLI default.
|
|
634
634
|
- `view_issue`: view a single issue with its comments (args: `{ issue_id, org_id, debug? }`).
|
|
635
635
|
- `create_issue`: create a new issue (args: `{ title, description?, org_id, project_id?, labels?, attachments?, is_hidden?, debug? }`).
|
|
636
|
-
- `update_issue`: update title/description/status/labels/is_hidden (args: `{ issue_id, org_id, title?, description?, status?, labels?, attachments?, is_hidden?, debug? }`).
|
|
636
|
+
- `update_issue`: update title/description/status/labels/is_hidden (args: `{ issue_id, org_id, title?, description?, status?, labels?, attachments?, is_hidden?, notify?, debug? }`). `notify: true` with `is_hidden: false` asks for the new-issue email and Slack post (see `--notify` below); a second text item says whether they were requested.
|
|
637
637
|
- `post_issue_comment`: post a comment (args: `{ issue_id, org_id, content?, parent_comment_id?, attachments?, debug? }`).
|
|
638
638
|
- `update_issue_comment`: update an existing comment (args: `{ comment_id, org_id, content?, attachments?, debug? }`).
|
|
639
639
|
- `upload_file`: upload a local file and return the storage URL plus a ready-to-paste markdown link (args: `{ path, org_id, debug? }`).
|
|
@@ -690,6 +690,7 @@ postgresai issues create --org-id <id> <title> # Create a new issu
|
|
|
690
690
|
postgresai issues create --org-id <id> <title> --hidden # Create a hidden issue (PostgresAI staff)
|
|
691
691
|
postgresai issues update <issueId> [--title ... --status ...]# Update an existing issue
|
|
692
692
|
postgresai issues update <issueId> --hidden|--no-hidden # Hide / unhide an issue (PostgresAI staff)
|
|
693
|
+
postgresai issues update <issueId> --no-hidden --notify # Unhide and send the new-issue email + Slack post (first time only)
|
|
693
694
|
postgresai issues post-comment <issueId> <content> # Post a comment to an issue
|
|
694
695
|
postgresai issues update-comment <commentId> <content> # Update an existing comment
|
|
695
696
|
postgresai issues files upload <path> # Upload a file, print URL + markdown
|
|
@@ -711,6 +712,20 @@ ones, filtered server-side. `issues create --hidden` creates one, and
|
|
|
711
712
|
check of its own: the platform refuses a visibility change for a non-staff
|
|
712
713
|
credential with a plain error, and the CLI prints it and exits non-zero.
|
|
713
714
|
|
|
715
|
+
Making a hidden issue visible is silent unless you add `--notify` (MCP:
|
|
716
|
+
`notify: true`): then the organization gets the new-issue email and Slack post,
|
|
717
|
+
as when staff pick "Make visible and notify" in the Console. The platform sends
|
|
718
|
+
them only the first time an issue becomes visible, and a plain `--no-hidden`
|
|
719
|
+
also uses up that one chance. So the CLI reads the issue first and says what
|
|
720
|
+
happened, on stderr (`--json` output also carries `notify`):
|
|
721
|
+
|
|
722
|
+
- `Notifications requested: the new-issue email and Slack post go out now.`
|
|
723
|
+
- `Nothing sent: this issue was visible before (<time>); the email and Slack post go out only the first time.`
|
|
724
|
+
- `Nothing sent: the issue is already visible.`
|
|
725
|
+
|
|
726
|
+
`--notify` needs `--no-hidden`, and a platform without notify support refuses it
|
|
727
|
+
with a message (nothing is unhidden).
|
|
728
|
+
|
|
714
729
|
Staff access is granted per credential, not per person, and a credential that
|
|
715
730
|
does not qualify simply sees nothing — `--hidden-only` returns an empty list
|
|
716
731
|
and `is_hidden` never appears, with no error, which is indistinguishable from
|
package/dist/bin/postgres-ai.js
CHANGED
|
@@ -13538,7 +13538,7 @@ var {
|
|
|
13538
13538
|
// package.json
|
|
13539
13539
|
var package_default = {
|
|
13540
13540
|
name: "postgresai",
|
|
13541
|
-
version: "0.19.0-rc.
|
|
13541
|
+
version: "0.19.0-rc.6",
|
|
13542
13542
|
description: "postgres_ai CLI",
|
|
13543
13543
|
license: "Apache-2.0",
|
|
13544
13544
|
private: false,
|
|
@@ -16898,7 +16898,7 @@ var Result = import_lib.default.Result;
|
|
|
16898
16898
|
var TypeOverrides = import_lib.default.TypeOverrides;
|
|
16899
16899
|
var defaults = import_lib.default.defaults;
|
|
16900
16900
|
// package.json
|
|
16901
|
-
var version = "0.19.0-rc.
|
|
16901
|
+
var version = "0.19.0-rc.6";
|
|
16902
16902
|
var package_default2 = {
|
|
16903
16903
|
name: "postgresai",
|
|
16904
16904
|
version,
|
|
@@ -17811,8 +17811,53 @@ async function createIssueComment(params) {
|
|
|
17811
17811
|
throw new Error(formatHttpError("Failed to create issue comment", response.status, data));
|
|
17812
17812
|
}
|
|
17813
17813
|
}
|
|
17814
|
+
function describeNotifyOutcome(outcome) {
|
|
17815
|
+
switch (outcome.reason) {
|
|
17816
|
+
case "first_publish":
|
|
17817
|
+
return "Notifications requested: the new-issue email and Slack post go out now.";
|
|
17818
|
+
case "visible_before":
|
|
17819
|
+
return `Nothing sent: this issue was visible before (${outcome.first_visible_at}); the email and Slack post go out only the first time.`;
|
|
17820
|
+
case "already_visible":
|
|
17821
|
+
return "Nothing sent: the issue is already visible.";
|
|
17822
|
+
}
|
|
17823
|
+
}
|
|
17824
|
+
async function checkNotifyPossible(params) {
|
|
17825
|
+
const { apiKey, apiBaseUrl, orgScope, issueId, debug } = params;
|
|
17826
|
+
await readPublishState(normalizeBaseUrl(apiBaseUrl), issueRequestHeaders(apiKey, orgScope), issueId, debug);
|
|
17827
|
+
}
|
|
17828
|
+
async function readPublishState(base, headers, issueId, debug) {
|
|
17829
|
+
const url = new URL(`${base}/issues`);
|
|
17830
|
+
url.searchParams.set("select", "id,is_hidden,first_visible_at");
|
|
17831
|
+
url.searchParams.set("id", `eq.${issueId}`);
|
|
17832
|
+
url.searchParams.set("limit", "1");
|
|
17833
|
+
if (debug) {
|
|
17834
|
+
console.error(`Debug: GET URL: ${url.toString()}`);
|
|
17835
|
+
}
|
|
17836
|
+
const response = await fetch(url.toString(), { method: "GET", headers });
|
|
17837
|
+
const data = await response.text();
|
|
17838
|
+
if (debug) {
|
|
17839
|
+
console.error(`Debug: Response status: ${response.status}`);
|
|
17840
|
+
}
|
|
17841
|
+
if (!response.ok) {
|
|
17842
|
+
if (response.status === 400 && /first_visible_at/.test(data)) {
|
|
17843
|
+
throw new Error("This PostgresAI platform does not support notify on unhide yet. Unhide without it, or retry after the platform update.");
|
|
17844
|
+
}
|
|
17845
|
+
throw new Error(formatHttpError("Failed to read the issue", response.status, data));
|
|
17846
|
+
}
|
|
17847
|
+
let rows;
|
|
17848
|
+
try {
|
|
17849
|
+
rows = JSON.parse(data);
|
|
17850
|
+
} catch {
|
|
17851
|
+
throw new Error(`Failed to parse issue response: ${data}`);
|
|
17852
|
+
}
|
|
17853
|
+
const row = Array.isArray(rows) ? rows[0] : undefined;
|
|
17854
|
+
if (!row) {
|
|
17855
|
+
throw new Error(`Issue not found: ${issueId}`);
|
|
17856
|
+
}
|
|
17857
|
+
return { is_hidden: row.is_hidden === true, first_visible_at: row.first_visible_at ?? null };
|
|
17858
|
+
}
|
|
17814
17859
|
async function updateIssue(params) {
|
|
17815
|
-
const { apiKey, apiBaseUrl, orgScope, issueId, title, description, status, labels, hidden, debug } = params;
|
|
17860
|
+
const { apiKey, apiBaseUrl, orgScope, issueId, title, description, status, labels, hidden, notify, debug } = params;
|
|
17816
17861
|
if (!apiKey) {
|
|
17817
17862
|
throw new Error("API key is required");
|
|
17818
17863
|
}
|
|
@@ -17822,6 +17867,9 @@ async function updateIssue(params) {
|
|
|
17822
17867
|
if (title === undefined && description === undefined && status === undefined && labels === undefined && hidden === undefined) {
|
|
17823
17868
|
throw new Error("At least one field to update is required (title, description, status, labels, or hidden)");
|
|
17824
17869
|
}
|
|
17870
|
+
if (notify && hidden !== false) {
|
|
17871
|
+
throw new Error("notify works only together with unhiding the issue (hidden=false)");
|
|
17872
|
+
}
|
|
17825
17873
|
const base = normalizeBaseUrl(apiBaseUrl);
|
|
17826
17874
|
const url = new URL(`${base}/rpc/issue_update`);
|
|
17827
17875
|
const bodyObj = {
|
|
@@ -17842,8 +17890,20 @@ async function updateIssue(params) {
|
|
|
17842
17890
|
if (hidden !== undefined) {
|
|
17843
17891
|
bodyObj.p_is_hidden = hidden;
|
|
17844
17892
|
}
|
|
17845
|
-
const body = JSON.stringify(bodyObj);
|
|
17846
17893
|
const headers = issueRequestHeaders(apiKey, orgScope);
|
|
17894
|
+
let notifyOutcome;
|
|
17895
|
+
if (notify) {
|
|
17896
|
+
const state = await readPublishState(base, headers, issueId, debug);
|
|
17897
|
+
if (!state.is_hidden) {
|
|
17898
|
+
notifyOutcome = { requested: false, reason: "already_visible" };
|
|
17899
|
+
} else if (state.first_visible_at) {
|
|
17900
|
+
notifyOutcome = { requested: false, reason: "visible_before", first_visible_at: state.first_visible_at };
|
|
17901
|
+
} else {
|
|
17902
|
+
notifyOutcome = { requested: true, reason: "first_publish" };
|
|
17903
|
+
bodyObj.p_notify = true;
|
|
17904
|
+
}
|
|
17905
|
+
}
|
|
17906
|
+
const body = JSON.stringify(bodyObj);
|
|
17847
17907
|
if (debug) {
|
|
17848
17908
|
const debugHeaders = { ...headers, "access-token": maskSecret(apiKey) };
|
|
17849
17909
|
console.error(`Debug: Resolved API base URL: ${base}`);
|
|
@@ -17863,11 +17923,13 @@ async function updateIssue(params) {
|
|
|
17863
17923
|
}
|
|
17864
17924
|
const data = await response.text();
|
|
17865
17925
|
if (response.ok) {
|
|
17926
|
+
let updated;
|
|
17866
17927
|
try {
|
|
17867
|
-
|
|
17928
|
+
updated = JSON.parse(data);
|
|
17868
17929
|
} catch {
|
|
17869
17930
|
throw new Error(`Failed to parse update issue response: ${data}`);
|
|
17870
17931
|
}
|
|
17932
|
+
return notifyOutcome ? { ...updated, notify: notifyOutcome } : updated;
|
|
17871
17933
|
} else {
|
|
17872
17934
|
throw new Error(formatHttpError("Failed to update issue", response.status, data));
|
|
17873
17935
|
}
|
|
@@ -25000,8 +25062,8 @@ async function clickhouseOrgFor(host, keyId, keySecret) {
|
|
|
25000
25062
|
}
|
|
25001
25063
|
throw failed ?? notFound;
|
|
25002
25064
|
}
|
|
25003
|
-
function
|
|
25004
|
-
return `${uiBaseUrl.replace(/\/+$/, "")}/${encodeURIComponent(orgAlias)}/projects/${encodeURIComponent(projectAlias)}/health`;
|
|
25065
|
+
function databaseHealthUrl(uiBaseUrl, orgAlias, projectAlias) {
|
|
25066
|
+
return `${uiBaseUrl.replace(/\/+$/, "")}/${encodeURIComponent(orgAlias)}/projects/${encodeURIComponent(projectAlias)}/health-preview`;
|
|
25005
25067
|
}
|
|
25006
25068
|
function grafanaOAuthUrl(dashboardUrl) {
|
|
25007
25069
|
let u;
|
|
@@ -25035,7 +25097,7 @@ function platformDeps(p) {
|
|
|
25035
25097
|
const project = list.find((x) => x.monitoring_instance_ids?.includes(row.id)) ?? list.find((x) => x.name === row.name);
|
|
25036
25098
|
if (!project)
|
|
25037
25099
|
projects = undefined;
|
|
25038
|
-
return org && project?.alias ?
|
|
25100
|
+
return org && project?.alias ? databaseHealthUrl(p.uiBaseUrl, org, project.alias) : undefined;
|
|
25039
25101
|
};
|
|
25040
25102
|
const withLinks = async (row) => {
|
|
25041
25103
|
const health_url = await healthUrl(row).catch(() => {
|
|
@@ -31965,6 +32027,13 @@ async function handleToolCall(req, rootOpts, extra) {
|
|
|
31965
32027
|
if (hiddenArg.error)
|
|
31966
32028
|
return hiddenArg.error;
|
|
31967
32029
|
const hidden = hiddenArg.value;
|
|
32030
|
+
if (args.notify !== undefined && args.notify !== null && typeof args.notify !== "boolean") {
|
|
32031
|
+
return { content: [{ type: "text", text: "notify must be a boolean" }], isError: true };
|
|
32032
|
+
}
|
|
32033
|
+
const notify = args.notify === true;
|
|
32034
|
+
if (notify && hidden !== false) {
|
|
32035
|
+
return { content: [{ type: "text", text: "notify works only with is_hidden=false (it notifies when the issue becomes visible)" }], isError: true };
|
|
32036
|
+
}
|
|
31968
32037
|
const attachments = Array.isArray(args.attachments) ? args.attachments.map(String).filter((p) => p.length > 0) : [];
|
|
31969
32038
|
if (title === undefined && description === undefined && status === undefined && labels === undefined && hidden === undefined && attachments.length === 0) {
|
|
31970
32039
|
return { content: [{ type: "text", text: "At least one field to update is required (title, description, status, labels, is_hidden, or attachments)" }], isError: true };
|
|
@@ -31975,6 +32044,9 @@ async function handleToolCall(req, rootOpts, extra) {
|
|
|
31975
32044
|
const scope = resolveMcpOrgScope(args, apiKey, cfg);
|
|
31976
32045
|
if (scope.error)
|
|
31977
32046
|
return scope.error;
|
|
32047
|
+
if (notify && attachments.length > 0) {
|
|
32048
|
+
await checkNotifyPossible({ apiKey, apiBaseUrl, issueId, orgScope: scope.orgScope, debug });
|
|
32049
|
+
}
|
|
31978
32050
|
if (attachments.length > 0) {
|
|
31979
32051
|
if (description === undefined) {
|
|
31980
32052
|
const existing = await fetchIssue({ apiKey, apiBaseUrl, issueId, orgScope: scope.orgScope, debug });
|
|
@@ -31987,8 +32059,11 @@ async function handleToolCall(req, rootOpts, extra) {
|
|
|
31987
32059
|
const uploaded = await uploadAttachments({ apiKey, orgScope: scope.orgScope, storageBaseUrl, attachmentPaths: attachments, debug });
|
|
31988
32060
|
description = appendAttachmentsToContent(description, uploaded);
|
|
31989
32061
|
}
|
|
31990
|
-
const result = await updateIssue({ apiKey, apiBaseUrl, issueId, title, description, status, labels, hidden, orgScope: scope.orgScope, debug });
|
|
31991
|
-
|
|
32062
|
+
const result = await updateIssue({ apiKey, apiBaseUrl, issueId, title, description, status, labels, hidden, notify, orgScope: scope.orgScope, debug });
|
|
32063
|
+
const content = [{ type: "text", text: JSON.stringify(result, null, 2) }];
|
|
32064
|
+
if (result.notify)
|
|
32065
|
+
content.push({ type: "text", text: describeNotifyOutcome(result.notify) });
|
|
32066
|
+
return { content };
|
|
31992
32067
|
}
|
|
31993
32068
|
if (toolName === "update_issue_comment") {
|
|
31994
32069
|
const commentId = String(args.comment_id || "").trim();
|
|
@@ -32291,6 +32366,7 @@ async function startMcpServer(rootOpts, extra) {
|
|
|
32291
32366
|
description: "Local file paths to upload and append as markdown links (images render inline). When provided without 'description', the existing description is fetched and appended to."
|
|
32292
32367
|
},
|
|
32293
32368
|
is_hidden: { type: "boolean", description: "true hides the issue, false unhides it (PostgresAI staff only; same as CLI --hidden / --no-hidden). Omit (or pass null) to leave unchanged." },
|
|
32369
|
+
notify: { type: "boolean", description: "With is_hidden=false: send the new-issue email and Slack post (same as CLI --notify). Sent only the first time the issue becomes visible; the result says whether it was requested." },
|
|
32294
32370
|
debug: { type: "boolean", description: "Enable verbose debug logs" }
|
|
32295
32371
|
},
|
|
32296
32372
|
required: ["issue_id"],
|
|
@@ -32424,7 +32500,7 @@ async function startMcpServer(rootOpts, extra) {
|
|
|
32424
32500
|
},
|
|
32425
32501
|
{
|
|
32426
32502
|
name: "deploy_monitoring",
|
|
32427
|
-
description: "Put a Postgres database under PostgresAI Cloud monitoring (same as `pgai mon deploy`): prepares the monitoring role (an admin URL creates it; otherwise returns the SQL), provisions the monitoring box, and returns JSON with status (ready | in_progress | deleting | deleted | inactive | action_required | failed: the same words as pgai dblab deploy), health_url (the project's
|
|
32503
|
+
description: "Put a Postgres database under PostgresAI Cloud monitoring (same as `pgai mon deploy`): prepares the monitoring role (an admin URL creates it; otherwise returns the SQL), provisions the monitoring box, and returns JSON with status (ready | in_progress | deleting | deleted | inactive | action_required | failed: the same words as pgai dblab deploy), health_url (the project's Database health in the console), dashboard_url (Grafana, signing in with PostgresAI) and next (the exact next action). A billed box is provisioned only with yes: true: without it the result is action_required with the price (and requires_payment_method), so show the price to the user first. It does not wait for the box: call it again to see the status. Safe to call again. When PostgresAI can't reach the database the way an IP allowlist refuses (or with ip_first), the box's IP is reserved first and the result is action_required with step allow_ip (ip, cidr, host, port, reserved_until): give the user the cidr and port to allow on the database, then call again with ip_allowed: true. ClickHouse Managed Postgres, RDS and Supabase are detected from the host. An RDS instance that is not publicly accessible is monitored over AWS PrivateLink (no public IP, nothing opened): the user creates a CloudFormation stack in their AWS account from a link. Until the stack exists the result is action_required with step privatelink_stack and cfn_url: give the user the link to open in the RDS's AWS account (the stack keeps its name); once they say it is created, call again. When this machine's aws CLI can read the RDS (read-only; aws_profile picks the profile, no_aws: true skips it), the link is filled in and the stack is found by itself; otherwise pass vpce_service, the stack's VpceServiceName output. When the URL's user can't create the monitoring role, or this machine can't reach the database (a private RDS seen from outside its VPC), the result is action_required with step prepare_db, sql, nonce and monitoring_password: the user runs the SQL as the master user in that database, then call again with monitoring_password and nonce. host_stats: true adds host CPU, memory, disk and IOPS through a read-only role the stack creates (host_stats_role: its HostStatsRoleArn output, when not read from AWS). Aurora and RDS Proxy endpoints are not supported over PrivateLink. Supabase needs no password (PostgresAI prepares the database through the Supabase Management API): the first time, the result is action_required with a consent link in next; give it to the user to open and approve, then call again. Elsewhere the URL must carry its password, and only these query parameters: sslmode, channel_binding, application_name. PGAI_MON_PASSWORD, PGPASSWORD and CLICKHOUSE_KEY_ID + CLICKHOUSE_KEY_SECRET of the server process are not used (pass clickhouse_key), and a TLS failure is not retried in plaintext (say sslmode=disable for a server without TLS). For another database on a server PostgresAI already monitors for the org, an admin URL with sslmode=require (or verify-*), each query parameter once, is enough: PostgresAI fills in the password of postgres_ai_mon it keeps, over TLS only (on a server without TLS, pass the postgres_ai_mon URL; if nobody has its password, the user runs in a terminal: pgai mon instances delete the server's other databases, then pgai mon deploy <admin-url> --reset-password with PGAI_MON_PASSWORD set to a new one, then deploys them again with it).",
|
|
32428
32504
|
inputSchema: {
|
|
32429
32505
|
type: "object",
|
|
32430
32506
|
properties: {
|
|
@@ -32836,8 +32912,53 @@ async function createIssueComment2(params) {
|
|
|
32836
32912
|
throw new Error(formatHttpError("Failed to create issue comment", response.status, data));
|
|
32837
32913
|
}
|
|
32838
32914
|
}
|
|
32915
|
+
function describeNotifyOutcome2(outcome) {
|
|
32916
|
+
switch (outcome.reason) {
|
|
32917
|
+
case "first_publish":
|
|
32918
|
+
return "Notifications requested: the new-issue email and Slack post go out now.";
|
|
32919
|
+
case "visible_before":
|
|
32920
|
+
return `Nothing sent: this issue was visible before (${outcome.first_visible_at}); the email and Slack post go out only the first time.`;
|
|
32921
|
+
case "already_visible":
|
|
32922
|
+
return "Nothing sent: the issue is already visible.";
|
|
32923
|
+
}
|
|
32924
|
+
}
|
|
32925
|
+
async function checkNotifyPossible2(params) {
|
|
32926
|
+
const { apiKey, apiBaseUrl, orgScope, issueId, debug } = params;
|
|
32927
|
+
await readPublishState2(normalizeBaseUrl(apiBaseUrl), issueRequestHeaders2(apiKey, orgScope), issueId, debug);
|
|
32928
|
+
}
|
|
32929
|
+
async function readPublishState2(base, headers, issueId, debug) {
|
|
32930
|
+
const url = new URL(`${base}/issues`);
|
|
32931
|
+
url.searchParams.set("select", "id,is_hidden,first_visible_at");
|
|
32932
|
+
url.searchParams.set("id", `eq.${issueId}`);
|
|
32933
|
+
url.searchParams.set("limit", "1");
|
|
32934
|
+
if (debug) {
|
|
32935
|
+
console.error(`Debug: GET URL: ${url.toString()}`);
|
|
32936
|
+
}
|
|
32937
|
+
const response = await fetch(url.toString(), { method: "GET", headers });
|
|
32938
|
+
const data = await response.text();
|
|
32939
|
+
if (debug) {
|
|
32940
|
+
console.error(`Debug: Response status: ${response.status}`);
|
|
32941
|
+
}
|
|
32942
|
+
if (!response.ok) {
|
|
32943
|
+
if (response.status === 400 && /first_visible_at/.test(data)) {
|
|
32944
|
+
throw new Error("This PostgresAI platform does not support notify on unhide yet. Unhide without it, or retry after the platform update.");
|
|
32945
|
+
}
|
|
32946
|
+
throw new Error(formatHttpError("Failed to read the issue", response.status, data));
|
|
32947
|
+
}
|
|
32948
|
+
let rows;
|
|
32949
|
+
try {
|
|
32950
|
+
rows = JSON.parse(data);
|
|
32951
|
+
} catch {
|
|
32952
|
+
throw new Error(`Failed to parse issue response: ${data}`);
|
|
32953
|
+
}
|
|
32954
|
+
const row = Array.isArray(rows) ? rows[0] : undefined;
|
|
32955
|
+
if (!row) {
|
|
32956
|
+
throw new Error(`Issue not found: ${issueId}`);
|
|
32957
|
+
}
|
|
32958
|
+
return { is_hidden: row.is_hidden === true, first_visible_at: row.first_visible_at ?? null };
|
|
32959
|
+
}
|
|
32839
32960
|
async function updateIssue2(params) {
|
|
32840
|
-
const { apiKey, apiBaseUrl, orgScope, issueId, title, description, status, labels, hidden, debug } = params;
|
|
32961
|
+
const { apiKey, apiBaseUrl, orgScope, issueId, title, description, status, labels, hidden, notify, debug } = params;
|
|
32841
32962
|
if (!apiKey) {
|
|
32842
32963
|
throw new Error("API key is required");
|
|
32843
32964
|
}
|
|
@@ -32847,6 +32968,9 @@ async function updateIssue2(params) {
|
|
|
32847
32968
|
if (title === undefined && description === undefined && status === undefined && labels === undefined && hidden === undefined) {
|
|
32848
32969
|
throw new Error("At least one field to update is required (title, description, status, labels, or hidden)");
|
|
32849
32970
|
}
|
|
32971
|
+
if (notify && hidden !== false) {
|
|
32972
|
+
throw new Error("notify works only together with unhiding the issue (hidden=false)");
|
|
32973
|
+
}
|
|
32850
32974
|
const base = normalizeBaseUrl(apiBaseUrl);
|
|
32851
32975
|
const url = new URL(`${base}/rpc/issue_update`);
|
|
32852
32976
|
const bodyObj = {
|
|
@@ -32867,8 +32991,20 @@ async function updateIssue2(params) {
|
|
|
32867
32991
|
if (hidden !== undefined) {
|
|
32868
32992
|
bodyObj.p_is_hidden = hidden;
|
|
32869
32993
|
}
|
|
32870
|
-
const body = JSON.stringify(bodyObj);
|
|
32871
32994
|
const headers = issueRequestHeaders2(apiKey, orgScope);
|
|
32995
|
+
let notifyOutcome;
|
|
32996
|
+
if (notify) {
|
|
32997
|
+
const state = await readPublishState2(base, headers, issueId, debug);
|
|
32998
|
+
if (!state.is_hidden) {
|
|
32999
|
+
notifyOutcome = { requested: false, reason: "already_visible" };
|
|
33000
|
+
} else if (state.first_visible_at) {
|
|
33001
|
+
notifyOutcome = { requested: false, reason: "visible_before", first_visible_at: state.first_visible_at };
|
|
33002
|
+
} else {
|
|
33003
|
+
notifyOutcome = { requested: true, reason: "first_publish" };
|
|
33004
|
+
bodyObj.p_notify = true;
|
|
33005
|
+
}
|
|
33006
|
+
}
|
|
33007
|
+
const body = JSON.stringify(bodyObj);
|
|
32872
33008
|
if (debug) {
|
|
32873
33009
|
const debugHeaders = { ...headers, "access-token": maskSecret(apiKey) };
|
|
32874
33010
|
console.error(`Debug: Resolved API base URL: ${base}`);
|
|
@@ -32888,11 +33024,13 @@ async function updateIssue2(params) {
|
|
|
32888
33024
|
}
|
|
32889
33025
|
const data = await response.text();
|
|
32890
33026
|
if (response.ok) {
|
|
33027
|
+
let updated;
|
|
32891
33028
|
try {
|
|
32892
|
-
|
|
33029
|
+
updated = JSON.parse(data);
|
|
32893
33030
|
} catch {
|
|
32894
33031
|
throw new Error(`Failed to parse update issue response: ${data}`);
|
|
32895
33032
|
}
|
|
33033
|
+
return notifyOutcome ? { ...updated, notify: notifyOutcome } : updated;
|
|
32896
33034
|
} else {
|
|
32897
33035
|
throw new Error(formatHttpError("Failed to update issue", response.status, data));
|
|
32898
33036
|
}
|
|
@@ -33764,12 +33902,12 @@ function personLines(r) {
|
|
|
33764
33902
|
case "ready":
|
|
33765
33903
|
return [
|
|
33766
33904
|
`Monitoring for ${who} is ready.`,
|
|
33767
|
-
...r.health_url ? [`
|
|
33768
|
-
...r.dashboard_url ? [` Grafana:
|
|
33769
|
-
...r.price ? [` Price:
|
|
33770
|
-
...r.cloud ? [` Runs on:
|
|
33771
|
-
...r.egress_ip ? [` Connects from:
|
|
33772
|
-
...r.provider === "rds" && r.host_metrics ? [" Host metrics:
|
|
33905
|
+
...r.health_url ? [` Database health: ${r.health_url}`] : [],
|
|
33906
|
+
...r.dashboard_url ? [` Grafana: ${r.dashboard_url}`] : [],
|
|
33907
|
+
...r.price ? [` Price: ${r.price}`] : [],
|
|
33908
|
+
...r.cloud ? [` Runs on: ${cloudWord2(r.cloud)}, ${r.location}`] : [],
|
|
33909
|
+
...r.egress_ip ? [` Connects from: ${r.egress_ip}`] : [],
|
|
33910
|
+
...r.provider === "rds" && r.host_metrics ? [" Host metrics: on (CPU, memory, disk, IOPS)"] : [],
|
|
33773
33911
|
...!r.health_url && !r.dashboard_url && r.next && r.next !== "none" ? [`Next: ${r.next}`] : [],
|
|
33774
33912
|
...extra && (r.health_url || r.dashboard_url) ? [`Note: ${extra}`] : []
|
|
33775
33913
|
];
|
|
@@ -35602,8 +35740,8 @@ function disconnectBilling(reply) {
|
|
|
35602
35740
|
}
|
|
35603
35741
|
return;
|
|
35604
35742
|
}
|
|
35605
|
-
function
|
|
35606
|
-
return `${uiBaseUrl.replace(/\/+$/, "")}/${encodeURIComponent(orgAlias)}/projects/${encodeURIComponent(projectAlias)}/health`;
|
|
35743
|
+
function databaseHealthUrl2(uiBaseUrl, orgAlias, projectAlias) {
|
|
35744
|
+
return `${uiBaseUrl.replace(/\/+$/, "")}/${encodeURIComponent(orgAlias)}/projects/${encodeURIComponent(projectAlias)}/health-preview`;
|
|
35607
35745
|
}
|
|
35608
35746
|
function grafanaOAuthUrl2(dashboardUrl) {
|
|
35609
35747
|
let u;
|
|
@@ -35637,7 +35775,7 @@ function platformDeps2(p) {
|
|
|
35637
35775
|
const project = list.find((x) => x.monitoring_instance_ids?.includes(row.id)) ?? list.find((x) => x.name === row.name);
|
|
35638
35776
|
if (!project)
|
|
35639
35777
|
projects = undefined;
|
|
35640
|
-
return org && project?.alias ?
|
|
35778
|
+
return org && project?.alias ? databaseHealthUrl2(p.uiBaseUrl, org, project.alias) : undefined;
|
|
35641
35779
|
};
|
|
35642
35780
|
const withLinks = async (row) => {
|
|
35643
35781
|
const health_url = await healthUrl(row).catch(() => {
|
|
@@ -50744,11 +50882,11 @@ Projects in the Supabase organization "${org}":`));
|
|
|
50744
50882
|
}
|
|
50745
50883
|
}
|
|
50746
50884
|
var mon = program2.command("mon").description("monitoring services management");
|
|
50747
|
-
sharedDeployOptions2(withOrgOptions(mon.command("deploy")), 20, "instance name (default: host[:port]/database)", "the box's region on its cloud (default: the database's region when that cloud has it; see below)", "where the monitoring box runs: aws or hetzner (default: the database's cloud, else aws)").description("deploy PostgresAI Cloud monitoring for a database: prepare it, provision the monitoring box, print its
|
|
50885
|
+
sharedDeployOptions2(withOrgOptions(mon.command("deploy")), 20, "instance name (default: host[:port]/database)", "the box's region on its cloud (default: the database's region when that cloud has it; see below)", "where the monitoring box runs: aws or hetzner (default: the database's cloud, else aws)").description("deploy PostgresAI Cloud monitoring for a database: prepare it, provision the monitoring box, print its Database health and dashboard").option("--provider <provider>", "generic (direct PostgreSQL URL; alias: self-managed) | clickhouse | rds | supabase (default: detected from the host)").option("--clickhouse-key <id:secret>", "ClickHouse Cloud API key (Basic Service API Reader) for CPU, memory and disk; or CLICKHOUSE_KEY_ID + CLICKHOUSE_KEY_SECRET").option("--self-hosted", "run the monitoring stack on this machine (mon local-install) instead of PostgresAI Cloud").option("--reset-password", "the monitoring role exists and its password is lost: set a new one (admin URL; refused while another database on the server is monitored)").option("--monitoring-user <name>", "monitoring role to create or use (not over AWS PrivateLink, which uses postgres_ai_mon)", DEFAULT_MONITORING_USER2).option("--coupon <code>", "promotion code for the organization's monitoring subscription (applies when it is first created)").option("--vcpus <n>", "vCPUs of the database server; without it there is no AAS (database load) data (asked at a terminal; Supabase: from the project's compute size)").option("--supabase-project <name|project-id>", "the Supabase project to monitor (its exact name, or its project ID), instead of a URL; implies --provider supabase").option("--ip-first", "reserve the monitoring box's IP and stop before the box: the IP is kept for a week, so you can allow it on the database and continue the deploy afterwards with --ip-allowed (PostgresAI Cloud only)").option("--ip-allowed", "the database now allows the reserved IP: create the box with it").option("--privatelink", "RDS: monitor over AWS PrivateLink (the instance is not publicly accessible; default: decided from AWS or public DNS)").option("--no-privatelink", "RDS: monitor directly (the instance is publicly accessible)").option("--vpce-service <name>", "RDS over PrivateLink: the stack's VpceServiceName output, when this machine can't read it from AWS").option("--host-stats", "RDS over PrivateLink: also host CPU, memory, disk and IOPS, through a read-only role the stack creates").option("--host-stats-role <arn>", "RDS over PrivateLink: the stack's HostStatsRoleArn output, when not read from AWS (implies --host-stats)").option("--aws-profile <name>", "RDS: the aws CLI profile that reads the instance and its stack, read-only (default: the aws CLI's own)").option("--no-aws", "RDS: do not use the aws CLI on this machine").option("--terraform", "RDS over PrivateLink: write the stack as a Terraform module (./postgresai-privatelink-<instance>/) instead of the CloudFormation link").addHelpText("after", [
|
|
50748
50886
|
"",
|
|
50749
50887
|
"Steps (each skipped when already done; safe to re-run): sign in, prepare the database",
|
|
50750
50888
|
"(an admin URL creates the postgres_ai_mon role; otherwise the SQL is printed), provision",
|
|
50751
|
-
"the monitoring box, wait, print
|
|
50889
|
+
"the monitoring box, wait, print Database health (health_url) and Grafana, signed in with",
|
|
50752
50890
|
"your PostgresAI account (dashboard_url). The box runs its first checkup at first_checkup_eta",
|
|
50753
50891
|
"at the earliest (3 minutes after it is ready), once every target has data (at most 30 minutes).",
|
|
50754
50892
|
"",
|
|
@@ -50963,7 +51101,7 @@ withOrgOptions(monInstances.command("set <id-or-name>")).description("change a m
|
|
|
50963
51101
|
}
|
|
50964
51102
|
throw err;
|
|
50965
51103
|
}
|
|
50966
|
-
const next = !r.changed ? `${row.name} already has ${vcpus} vCPUs: nothing changed` : r.aas_status === "no_labels" ? "AAS (database load) is collected once the monitoring box has registered" : "AAS (database load) is collected from the next minute;
|
|
51104
|
+
const next = !r.changed ? `${row.name} already has ${vcpus} vCPUs: nothing changed` : r.aas_status === "no_labels" ? "AAS (database load) is collected once the monitoring box has registered" : "AAS (database load) is collected from the next minute; Database health fills in as data arrives";
|
|
50967
51105
|
const result = { status: monitoringStatus2(row.status), name: row.name, id: row.id, vcpus: r.vcpus, previous_vcpus: r.previous_vcpus, changed: r.changed, next };
|
|
50968
51106
|
if (json)
|
|
50969
51107
|
printResult(result, true);
|
|
@@ -53037,7 +53175,7 @@ withOrgOptions(issues.command("update <issueId>")).description("update an existi
|
|
|
53037
53175
|
}, []).option("--clear-labels", "set labels to an empty list").option("--attach <path>", "attach a file (uploads and appends a markdown link to --description; if --description is omitted the existing description is fetched and appended to; repeatable)", (value, previous) => {
|
|
53038
53176
|
previous.push(value);
|
|
53039
53177
|
return previous;
|
|
53040
|
-
}, []).option("--hidden", "hide the issue (PostgresAI staff)").option("--no-hidden", "unhide the issue (PostgresAI staff)").option("--debug", "enable debug output").option("--json", "output raw JSON").action(async (issueId, opts) => {
|
|
53178
|
+
}, []).option("--hidden", "hide the issue (PostgresAI staff)").option("--no-hidden", "unhide the issue (PostgresAI staff)").option("--notify", "with --no-hidden: send the new-issue email and Slack post; only the first time the issue becomes visible (PostgresAI staff)").option("--debug", "enable debug output").option("--json", "output raw JSON").action(async (issueId, opts) => {
|
|
53041
53179
|
const rootOpts = program2.opts();
|
|
53042
53180
|
const cfg = readConfig();
|
|
53043
53181
|
const { apiKey } = getConfig(rootOpts);
|
|
@@ -53047,6 +53185,11 @@ withOrgOptions(issues.command("update <issueId>")).description("update an existi
|
|
|
53047
53185
|
return;
|
|
53048
53186
|
}
|
|
53049
53187
|
const { apiBaseUrl, storageBaseUrl } = resolveBaseUrls2(rootOpts, cfg);
|
|
53188
|
+
if (opts.notify && opts.hidden !== false) {
|
|
53189
|
+
console.error("--notify works only with --no-hidden (it notifies when the issue becomes visible)");
|
|
53190
|
+
process.exitCode = 1;
|
|
53191
|
+
return;
|
|
53192
|
+
}
|
|
53050
53193
|
const title = opts.title !== undefined ? interpretEscapes2(String(opts.title)) : undefined;
|
|
53051
53194
|
let description = opts.description !== undefined ? interpretEscapes2(String(opts.description)) : undefined;
|
|
53052
53195
|
let status = undefined;
|
|
@@ -53080,6 +53223,9 @@ withOrgOptions(issues.command("update <issueId>")).description("update an existi
|
|
|
53080
53223
|
const attachPaths = Array.isArray(opts.attach) ? opts.attach : [];
|
|
53081
53224
|
const spinner = createTtySpinner(process.stdout.isTTY ?? false, attachPaths.length > 0 ? "Uploading attachments..." : "Updating issue...");
|
|
53082
53225
|
try {
|
|
53226
|
+
if (opts.notify && attachPaths.length > 0) {
|
|
53227
|
+
await checkNotifyPossible2({ apiKey, apiBaseUrl, issueId, debug: !!opts.debug });
|
|
53228
|
+
}
|
|
53083
53229
|
if (attachPaths.length > 0) {
|
|
53084
53230
|
if (description === undefined) {
|
|
53085
53231
|
const existing = await fetchIssue2({ apiKey, apiBaseUrl, issueId, debug: !!opts.debug });
|
|
@@ -53109,10 +53255,14 @@ withOrgOptions(issues.command("update <issueId>")).description("update an existi
|
|
|
53109
53255
|
status,
|
|
53110
53256
|
labels,
|
|
53111
53257
|
hidden: typeof opts.hidden === "boolean" ? opts.hidden : undefined,
|
|
53258
|
+
notify: opts.notify === true,
|
|
53112
53259
|
debug: !!opts.debug
|
|
53113
53260
|
});
|
|
53114
53261
|
spinner.stop();
|
|
53115
53262
|
printResult(result, opts.json);
|
|
53263
|
+
if (result.notify) {
|
|
53264
|
+
console.error(describeNotifyOutcome2(result.notify));
|
|
53265
|
+
}
|
|
53116
53266
|
} catch (err) {
|
|
53117
53267
|
spinner.stop();
|
|
53118
53268
|
const message = err instanceof Error ? err.message : String(err);
|