@andreprado/agentkit 0.1.0-alpha.22 → 0.1.0-alpha.23

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@andreprado/agentkit",
3
- "version": "0.1.0-alpha.22",
3
+ "version": "0.1.0-alpha.23",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "repository": {
@@ -29,6 +29,16 @@ type DeployReadinessReport = {
29
29
  apiUrl: string;
30
30
  context: DeployReadinessContext;
31
31
  checks: DeployReadinessCheck[];
32
+ cloudAuth: {
33
+ source?: string;
34
+ accountEmail?: string;
35
+ };
36
+ onlineCapacity: {
37
+ accountUsed?: number;
38
+ accountLimit?: number;
39
+ globalUsed?: number;
40
+ globalLimit?: number;
41
+ };
32
42
  };
33
43
 
34
44
  export async function checkDeployReadiness(options: {
@@ -39,6 +49,12 @@ export async function checkDeployReadiness(options: {
39
49
  const auth = options.requireLogin ? await readCloudAuthForApiUrl(options.apiUrl) : null;
40
50
  const checks: DeployReadinessCheck[] = [];
41
51
  let cloudAuthUsable = false;
52
+ const cloudAuth: DeployReadinessReport["cloudAuth"] = {};
53
+ const onlineCapacity: DeployReadinessReport["onlineCapacity"] = {};
54
+
55
+ if (auth?.token) {
56
+ cloudAuth.source = formatCloudAuthSource(auth);
57
+ }
42
58
 
43
59
  if (context.runtime !== "edge") {
44
60
  checks.push({
@@ -84,6 +100,9 @@ export async function checkDeployReadiness(options: {
84
100
  try {
85
101
  const me = (await cloudApiRequest(options.apiUrl, "/v1/me", { method: "GET" })) as CloudMeResponse;
86
102
  const email = me.account?.email;
103
+ if (email) {
104
+ cloudAuth.accountEmail = email;
105
+ }
87
106
  checks.push({
88
107
  status: "pass",
89
108
  title: "Login",
@@ -164,6 +183,22 @@ export async function checkDeployReadiness(options: {
164
183
  const globalLimit = normalizeOptionalNumber(global?.limit);
165
184
  const globalUsed = normalizeOptionalNumber(global?.used);
166
185
 
186
+ if (accountLimit !== undefined) {
187
+ onlineCapacity.accountLimit = accountLimit;
188
+ }
189
+
190
+ if (accountUsed !== undefined) {
191
+ onlineCapacity.accountUsed = accountUsed;
192
+ }
193
+
194
+ if (globalLimit !== undefined) {
195
+ onlineCapacity.globalLimit = globalLimit;
196
+ }
197
+
198
+ if (globalUsed !== undefined) {
199
+ onlineCapacity.globalUsed = globalUsed;
200
+ }
201
+
167
202
  if (accountLimit !== undefined && accountUsed !== undefined && accountUsed >= accountLimit) {
168
203
  checks.push({
169
204
  status: "fail",
@@ -374,6 +409,8 @@ export async function checkDeployReadiness(options: {
374
409
  apiUrl: options.apiUrl,
375
410
  context,
376
411
  checks,
412
+ cloudAuth,
413
+ onlineCapacity,
377
414
  };
378
415
  }
379
416
 
@@ -383,6 +420,19 @@ export function printDeployReadinessReport(report: DeployReadinessReport): void
383
420
  console.log(`Project ID: ${report.context.projectId}`);
384
421
  console.log(`Target: ${report.context.target}`);
385
422
  console.log(`API: ${report.apiUrl}`);
423
+ const authSummary = formatDeployCloudAuthSummary(report);
424
+
425
+ if (authSummary) {
426
+ console.log(`Account: ${authSummary.account}`);
427
+ console.log(`Auth source: ${authSummary.source}`);
428
+ }
429
+
430
+ const capacitySummary = formatDeployOnlineCapacity(report, "current");
431
+
432
+ if (capacitySummary) {
433
+ console.log(`Capacity: ${capacitySummary}`);
434
+ }
435
+
386
436
  console.log("");
387
437
 
388
438
  for (const check of report.checks) {
@@ -394,6 +444,36 @@ export function printDeployReadinessReport(report: DeployReadinessReport): void
394
444
  }
395
445
  }
396
446
 
447
+ export function formatDeployCloudAuthSummary(
448
+ report: DeployReadinessReport,
449
+ ): { account: string; source: string } | null {
450
+ if (!report.cloudAuth.accountEmail || !report.cloudAuth.source) {
451
+ return null;
452
+ }
453
+
454
+ return {
455
+ account: report.cloudAuth.accountEmail,
456
+ source: report.cloudAuth.source,
457
+ };
458
+ }
459
+
460
+ export function formatDeployOnlineCapacity(
461
+ report: DeployReadinessReport,
462
+ timing: "current" | "before deploy",
463
+ ): string | null {
464
+ const suffix = timing === "before deploy" ? " before deploy" : "";
465
+
466
+ if (report.onlineCapacity.accountUsed !== undefined && report.onlineCapacity.accountLimit !== undefined) {
467
+ return `${report.onlineCapacity.accountUsed}/${report.onlineCapacity.accountLimit} account online deploy slots in use${suffix}`;
468
+ }
469
+
470
+ if (report.onlineCapacity.globalUsed !== undefined && report.onlineCapacity.globalLimit !== undefined) {
471
+ return `${report.onlineCapacity.globalUsed}/${report.onlineCapacity.globalLimit} global online deploy slots in use${suffix}`;
472
+ }
473
+
474
+ return null;
475
+ }
476
+
397
477
  export async function syncHostedSecretsFromLocal(options: { apiUrl: string; projectId: string }): Promise<void> {
398
478
  const context = await loadDeployReadinessContext(process.cwd(), process.env);
399
479
  const localEnv = await loadCapsuleEnv(context.root, {});
package/src/cli/index.ts CHANGED
@@ -57,6 +57,8 @@ import {
57
57
  } from "./cloud-client";
58
58
  import {
59
59
  checkDeployReadiness,
60
+ formatDeployCloudAuthSummary,
61
+ formatDeployOnlineCapacity,
60
62
  formatReadinessError,
61
63
  printDeployReadinessReport,
62
64
  resolveProjectIdForSecretCommand,
@@ -1002,6 +1004,7 @@ async function main() {
1002
1004
  console.log(`Project: ${deploy.project.id}`);
1003
1005
  console.log(`Deploy: ${deploy.deploy.id}`);
1004
1006
  console.log(`State: ${statePath}`);
1007
+ printDeployCloudSummary(readinessReport);
1005
1008
 
1006
1009
  if (chatAccess?.status === "ready") {
1007
1010
  console.log(`Chat auth: ${relativePath(process.cwd(), chatAccess.path)}`);
@@ -1501,6 +1504,25 @@ function printDeployProductionHandoff(input: {
1501
1504
  console.log(`Next: ${nextCommand}`);
1502
1505
  }
1503
1506
 
1507
+ function printDeployCloudSummary(report: Awaited<ReturnType<typeof checkDeployReadiness>> | null): void {
1508
+ if (!report) {
1509
+ return;
1510
+ }
1511
+
1512
+ const authSummary = formatDeployCloudAuthSummary(report);
1513
+
1514
+ if (authSummary) {
1515
+ console.log(`Account: ${authSummary.account}`);
1516
+ console.log(`Auth: ${authSummary.source}`);
1517
+ }
1518
+
1519
+ const capacitySummary = formatDeployOnlineCapacity(report, "before deploy");
1520
+
1521
+ if (capacitySummary) {
1522
+ console.log(`Capacity: ${capacitySummary}`);
1523
+ }
1524
+ }
1525
+
1504
1526
  async function ensureDeployChatAccessToken(options: {
1505
1527
  apiUrl: string;
1506
1528
  root: string;