lane-sdk 0.1.7 → 0.1.8

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/cli/index.js CHANGED
@@ -4083,6 +4083,58 @@ function setupTerseEnv() {
4083
4083
  }
4084
4084
  }
4085
4085
 
4086
+ // src/cli/post-login.ts
4087
+ import * as readline from "readline";
4088
+ var brand = source_default.hex("#1201FF");
4089
+ var MENU_OPTIONS = [
4090
+ { key: "1", label: "View wallet status", description: "Check your wallet, cards, and limits", command: "wallet status" },
4091
+ { key: "2", label: "Add a payment card", description: "Link a card to your agent wallet", command: "card add" },
4092
+ { key: "3", label: "Set spending controls", description: "Configure budgets and transaction limits", command: "budget set" },
4093
+ { key: "4", label: "Manage instructions", description: "Set agent purchasing rules and preferences", command: "instruction list" },
4094
+ { key: "5", label: "View account info", description: "Show your developer profile", command: "whoami" }
4095
+ ];
4096
+ async function showPostLoginMenu() {
4097
+ if (!process.stdout.isTTY) return;
4098
+ console.log();
4099
+ console.log(brand(" What would you like to do?"));
4100
+ console.log();
4101
+ for (const opt of MENU_OPTIONS) {
4102
+ console.log(` ${brand(opt.key)} ${source_default.bold(opt.label)}`);
4103
+ console.log(` ${source_default.dim(opt.description)}`);
4104
+ }
4105
+ console.log();
4106
+ console.log(` ${source_default.dim("q")} ${source_default.dim("Exit")}`);
4107
+ console.log();
4108
+ const rl = readline.createInterface({
4109
+ input: process.stdin,
4110
+ output: process.stdout
4111
+ });
4112
+ const answer = await new Promise((resolve2) => {
4113
+ rl.question(brand(" \u2192 "), (ans) => {
4114
+ rl.close();
4115
+ resolve2(ans.trim());
4116
+ });
4117
+ });
4118
+ if (answer === "q" || answer === "") {
4119
+ console.log(source_default.dim("\n Run `lane --help` to see all commands.\n"));
4120
+ return;
4121
+ }
4122
+ const selected = MENU_OPTIONS.find((o) => o.key === answer);
4123
+ if (!selected) {
4124
+ console.log(source_default.dim("\n Run `lane --help` to see all commands.\n"));
4125
+ return;
4126
+ }
4127
+ console.log();
4128
+ const { execFileSync: execFileSync2 } = await import("child_process");
4129
+ try {
4130
+ execFileSync2(process.argv[0], [...process.argv.slice(1, -1), ...selected.command.split(" ")], {
4131
+ stdio: "inherit",
4132
+ env: process.env
4133
+ });
4134
+ } catch {
4135
+ }
4136
+ }
4137
+
4086
4138
  // src/cli/commands/login.ts
4087
4139
  var loginCommand = new Command("login").alias("signup").description("Authenticate with Lane (opens browser)").action(async (_options, cmd) => {
4088
4140
  const globalOpts = cmd.optsWithGlobals();
@@ -4130,6 +4182,11 @@ var loginCommand = new Command("login").alias("signup").description("Authenticat
4130
4182
  terseErr({ waiting_for_browser: true });
4131
4183
  } else {
4132
4184
  console.log(source_default.blue("Opening browser for authentication..."));
4185
+ if (deviceCode) {
4186
+ console.log(`
4187
+ Verify this code matches your browser: ${source_default.bold.white(deviceCode)}
4188
+ `);
4189
+ }
4133
4190
  }
4134
4191
  const code = await runBrowserAuthFlow(authUrl);
4135
4192
  const tokenResponse = await fetch(`${baseUrl}/agent/auth/token`, {
@@ -4174,9 +4231,10 @@ var loginCommand = new Command("login").alias("signup").description("Authenticat
4174
4231
  ...walletId ? { wallet_id: walletId } : { wallet_id: "none" }
4175
4232
  });
4176
4233
  } else {
4177
- console.log(source_default.green("Authenticated successfully."));
4178
- console.log(` Credentials stored at: ${store.path}`);
4179
- console.log(` Wallet: ${source_default.underline("api.getonlane.com/agent/wallet")}`);
4234
+ console.log(source_default.green("\n Authenticated successfully."));
4235
+ console.log(` Credentials stored at: ${store.path}
4236
+ `);
4237
+ await showPostLoginMenu();
4180
4238
  }
4181
4239
  } catch (err) {
4182
4240
  const message = err instanceof Error ? err.message : String(err);
@@ -4208,42 +4266,40 @@ var logoutCommand = new Command2("logout").description("Clear local credentials"
4208
4266
 
4209
4267
  // src/cli/commands/whoami.ts
4210
4268
  import { Command as Command3 } from "commander";
4211
- init_lane();
4269
+ init_token_store();
4212
4270
  var whoamiCommand = new Command3("whoami").description("Print authenticated developer profile").action(async (_options, cmd) => {
4213
4271
  const globalOpts = cmd.optsWithGlobals();
4214
4272
  const terse2 = getTerseFromOpts(globalOpts);
4215
4273
  try {
4216
- const lane = await Lane.create();
4217
- const profile = await lane.auth.whoami();
4274
+ const store = new FileTokenStore();
4275
+ const creds = await store.read();
4276
+ if (!creds) {
4277
+ if (terse2) {
4278
+ terseOut({ authenticated: false, error: "not_authenticated" });
4279
+ process.exit(1);
4280
+ }
4281
+ console.log(source_default.yellow("Not authenticated. Run `lane login` to get started."));
4282
+ process.exit(1);
4283
+ }
4284
+ const env2 = creds.environment ?? (creds.apiKey.includes("_test_") ? "test" : "live");
4218
4285
  if (terse2) {
4219
4286
  terseOut({
4220
4287
  authenticated: true,
4221
- email: profile.email,
4222
- plan: profile.plan,
4223
- id: profile.id,
4224
- mode: lane.testMode ? "test" : "live"
4288
+ email: creds.developerId,
4289
+ environment: env2,
4290
+ credentials: store.path
4225
4291
  });
4226
4292
  return;
4227
4293
  }
4228
- console.log(` Email: ${profile.email}`);
4229
- console.log(` Plan: ${profile.plan}`);
4230
- console.log(` Member since: ${profile.memberSince}`);
4231
- console.log(` ID: ${profile.id}`);
4232
- if (lane.testMode) {
4233
- console.log(source_default.yellow(" Mode: TEST"));
4234
- }
4294
+ console.log(source_default.bold("\n Developer Profile\n"));
4295
+ console.log(` Account: ${creds.developerId}`);
4296
+ console.log(` Environment: ${env2 === "test" ? source_default.yellow("TEST") : source_default.green("LIVE")}`);
4297
+ console.log(` Key: ${creds.apiKey.slice(0, 15)}...`);
4298
+ console.log(` Credentials: ${store.path}`);
4299
+ console.log();
4235
4300
  } catch (err) {
4236
4301
  if (terse2) {
4237
- const message = err instanceof Error ? err.message : String(err);
4238
- let code = "not_authenticated";
4239
- if (message.includes("401") || message.includes("Invalid API key")) {
4240
- code = "invalid_key";
4241
- } else if (message.includes("403") || message.includes("revoked")) {
4242
- code = "key_revoked";
4243
- } else if (message.includes("fetch failed") || message.includes("ECONNREFUSED")) {
4244
- code = "network";
4245
- }
4246
- terseOut({ authenticated: false, error: code });
4302
+ terseOut({ authenticated: false, error: "unknown" });
4247
4303
  process.exit(1);
4248
4304
  }
4249
4305
  console.error(source_default.red(`Error: ${err instanceof Error ? err.message : String(err)}`));
@@ -6108,7 +6164,7 @@ var LOGO_LINES = [
6108
6164
  var TAGLINE = " Trusted agentic commerce infrastructure for agents and merchants.";
6109
6165
  var NARROW_FALLBACK = " Lane \u2014 Trusted agentic commerce infrastructure";
6110
6166
  var LINE_DELAYS = [100, 80, 70, 60, 50, 40];
6111
- var brand = source_default.hex("#1201FF");
6167
+ var brand2 = source_default.hex("#1201FF");
6112
6168
  function shouldSuppress() {
6113
6169
  return process.argv.includes("--quiet") || process.argv.includes("-q") || process.argv.includes("-t") || process.argv.includes("--terse") || process.env.CI !== void 0 || process.env.NO_COLOR !== void 0;
6114
6170
  }
@@ -6119,12 +6175,12 @@ async function showBanner(options) {
6119
6175
  if (shouldSuppress()) return;
6120
6176
  const cols = process.stdout.columns || 80;
6121
6177
  if (cols < 60) {
6122
- console.log(brand(NARROW_FALLBACK));
6178
+ console.log(brand2(NARROW_FALLBACK));
6123
6179
  console.log();
6124
6180
  return;
6125
6181
  }
6126
6182
  const animate = options?.animate !== false && process.stdout.isTTY === true;
6127
- const lines = LOGO_LINES.map((l) => brand(l));
6183
+ const lines = LOGO_LINES.map((l) => brand2(l));
6128
6184
  if (animate) {
6129
6185
  for (let i = 0; i < lines.length; i++) {
6130
6186
  process.stdout.write(lines[i] + "\n");
@@ -6132,16 +6188,16 @@ async function showBanner(options) {
6132
6188
  }
6133
6189
  process.stdout.write("\n");
6134
6190
  await sleep2(LINE_DELAYS[lines.length] || 30);
6135
- process.stdout.write(brand(TAGLINE) + "\n");
6191
+ process.stdout.write(brand2(TAGLINE) + "\n");
6136
6192
  } else {
6137
6193
  for (const line of lines) {
6138
6194
  console.log(line);
6139
6195
  }
6140
6196
  console.log();
6141
- console.log(brand(TAGLINE));
6197
+ console.log(brand2(TAGLINE));
6142
6198
  }
6143
6199
  if (options?.version) {
6144
- console.log(brand(` v${options.version}`));
6200
+ console.log(brand2(` v${options.version}`));
6145
6201
  }
6146
6202
  console.log();
6147
6203
  }