@hireobi/cli 0.1.7 → 0.1.9

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/obi.js CHANGED
@@ -14618,6 +14618,7 @@ var optionDefinitions = {
14618
14618
  "field-path": { type: "string" },
14619
14619
  "segment-name": { type: "string" },
14620
14620
  text: { type: "string" },
14621
+ tag: { type: "string" },
14621
14622
  company: { type: "string" },
14622
14623
  "company-unknown": { type: "boolean" },
14623
14624
  product: { type: "string" },
@@ -14632,7 +14633,7 @@ var optionDefinitions = {
14632
14633
  help: { type: "boolean" },
14633
14634
  version: { type: "boolean" }
14634
14635
  };
14635
- var namedCommands = ["business", "capabilities", "credentials", "doctor", "eval", "harness", "login", "logout", "memory", "questions", "readiness", "research", "skill", "status", "strategies"];
14636
+ var namedCommands = ["business", "capabilities", "credentials", "doctor", "eval", "harness", "login", "logout", "memory", "questions", "readiness", "research", "skill", "status", "strategies", "support"];
14636
14637
  var memoryKinds = ["preference", "constraint", "decision"];
14637
14638
  var credentialsActions = ["list", "revoke"];
14638
14639
  var emailSchema = external_exports.email().max(254);
@@ -14651,6 +14652,8 @@ var CliError = class extends Error {
14651
14652
  command;
14652
14653
  authorization;
14653
14654
  account;
14655
+ /** The message `obi support` could not send, with the block to paste. */
14656
+ support;
14654
14657
  constructor(options) {
14655
14658
  super(options.message);
14656
14659
  this.name = "CliError";
@@ -14662,6 +14665,7 @@ var CliError = class extends Error {
14662
14665
  this.command = options.command;
14663
14666
  this.authorization = options.authorization;
14664
14667
  this.account = options.account;
14668
+ this.support = options.support;
14665
14669
  }
14666
14670
  };
14667
14671
  function usageError(message = "Invalid command usage.", options = {}) {
@@ -15174,6 +15178,52 @@ function parseMemoryArguments(positionals, values, context, common2) {
15174
15178
  throw invalid3();
15175
15179
  }
15176
15180
 
15181
+ // src/support-contract.ts
15182
+ var SUPPORT_EMAIL = "support@hireobi.com";
15183
+ var SUPPORT_TAGS = ["market-request", "scope-request"];
15184
+ var lastErrorSchema = external_exports.strictObject({
15185
+ code: external_exports.string().regex(/^[A-Z][A-Z0-9_]{0,79}$/),
15186
+ command: external_exports.string().regex(/^[a-z][a-z-]{0,39}$/),
15187
+ at: external_exports.iso.datetime({ offset: true })
15188
+ });
15189
+ var SupportMessageSchema = external_exports.strictObject({
15190
+ requestId: external_exports.string().regex(/^[0-9a-f]{32}$/),
15191
+ message: external_exports.string().trim().min(1).max(2e3),
15192
+ tag: external_exports.enum(SUPPORT_TAGS).nullable(),
15193
+ diagnostic: external_exports.strictObject({
15194
+ cliVersion: external_exports.string().min(1).max(40),
15195
+ node: external_exports.string().min(1).max(40),
15196
+ os: external_exports.string().min(1).max(120),
15197
+ lastError: lastErrorSchema.nullable()
15198
+ })
15199
+ });
15200
+ var SupportMessageResponseSchema = external_exports.object({
15201
+ schemaVersion: external_exports.literal(1),
15202
+ data: external_exports.object({ received: external_exports.literal(true) })
15203
+ });
15204
+ var supportDataSchema = external_exports.object({
15205
+ delivery: external_exports.enum(["sent", "not_sent"]),
15206
+ /** Why nothing was sent: the error code met, null once sent. */
15207
+ reason: external_exports.string().nullable(),
15208
+ supportEmail: external_exports.literal(SUPPORT_EMAIL),
15209
+ mailto: external_exports.string(),
15210
+ tag: external_exports.enum(SUPPORT_TAGS).nullable(),
15211
+ account: external_exports.string().nullable(),
15212
+ origin: external_exports.string().min(1),
15213
+ diagnosticText: external_exports.string()
15214
+ });
15215
+
15216
+ // src/support-arguments.ts
15217
+ function parseSupportArguments(positionals, values, context, common2) {
15218
+ const allowed = /* @__PURE__ */ new Set(["json", "timeout-ms", "tag"]);
15219
+ const message = positionals[1]?.trim() ?? "";
15220
+ const tag = values.tag;
15221
+ if (Object.entries(values).some(([key, value]) => value !== void 0 && value !== false && !allowed.has(key)) || positionals.length !== 2 || message.length === 0 || message.length > 2e3 || tag !== void 0 && !SUPPORT_TAGS.includes(tag)) {
15222
+ throw usageError(`Use support "<message of at most 2000 characters>" [--tag ${SUPPORT_TAGS.join("|")}].`, context);
15223
+ }
15224
+ return { command: "support", supportMessage: message, ...tag === void 0 ? {} : { supportTag: tag }, ...common2 };
15225
+ }
15226
+
15177
15227
  // src/research-arguments.ts
15178
15228
  function parseResearchScope(values, context) {
15179
15229
  const locale = values.locale;
@@ -15576,7 +15626,7 @@ function commandMode(command, testServer) {
15576
15626
  if (testServer) {
15577
15627
  return "test";
15578
15628
  }
15579
- return command === "login" || command === "logout" || command === "status" || command === "credentials" || command === "eval" || command === "harness" || command === "business" || command === "questions" || command === "strategies" || command === "readiness" || command === "memory" ? "product" : "local";
15629
+ return command === "login" || command === "logout" || command === "status" || command === "credentials" || command === "eval" || command === "harness" || command === "business" || command === "questions" || command === "strategies" || command === "readiness" || command === "memory" || command === "support" ? "product" : "local";
15580
15630
  }
15581
15631
  function errorContext(argv) {
15582
15632
  const usesTestServer = argv.some(
@@ -15762,6 +15812,8 @@ function parseCommandArguments(argv) {
15762
15812
  throw usageError("Use research crawl <domain> --checkpoint <file> --output <file> [--batch-size <1-100>] [--locale <tag>] [--pages priority|all] [--max-pages <n|none>] [--retry-failed|--refresh], research capture --input <selected-page-file> --checkpoint <file> --output <corpus-file>, research readiness --input <file> --output <file>, or research video <url> --output <directory> [--frames <0-30>].", context);
15763
15813
  }
15764
15814
  if (positionals[0] === "memory") return parseMemoryArguments(positionals, values, context, { evaluationCaseId, json: json2, timeoutMs });
15815
+ if (positionals[0] === "support") return parseSupportArguments(positionals, values, context, { json: json2, timeoutMs });
15816
+ if (values.tag !== void 0) throw usageError("--tag is only valid with obi support.", context);
15765
15817
  if (stage !== void 0 || input !== void 0 || output !== void 0 || checkpoint !== void 0 || batchSize !== void 0 || retryFailed || refresh || scopeFlagsUsed || values.frames !== void 0 || free || evidenceOptionsUsed) {
15766
15818
  throw usageError("--stage and --input are only valid with obi harness.", context);
15767
15819
  }
@@ -15856,9 +15908,6 @@ function parseCommandArguments(argv) {
15856
15908
  }
15857
15909
  if (command === "doctor") {
15858
15910
  if (evaluationCaseId !== void 0) throw usageError("Doctor cannot use --eval-case.", context);
15859
- if (timeoutValue !== void 0 && testServer === void 0) {
15860
- throw usageError("A timeout is only valid with a test server.", context);
15861
- }
15862
15911
  return { command, json: json2, testServer, timeoutMs };
15863
15912
  }
15864
15913
  if (command === "status") {
@@ -16587,6 +16636,34 @@ var BusinessItemReviewRequestSchema = external_exports.discriminatedUnion("decis
16587
16636
  })
16588
16637
  ]);
16589
16638
 
16639
+ // ../shared/lib/geo/markets.ts
16640
+ var SUPPORTED_MARKETS = [
16641
+ { iso: "US", name: "United States" },
16642
+ { iso: "CA", name: "Canada" },
16643
+ { iso: "GB", name: "United Kingdom" },
16644
+ { iso: "FR", name: "France" },
16645
+ { iso: "DE", name: "Germany" },
16646
+ { iso: "ES", name: "Spain" },
16647
+ { iso: "IT", name: "Italy" },
16648
+ { iso: "NL", name: "Netherlands" },
16649
+ { iso: "BE", name: "Belgium" },
16650
+ { iso: "CH", name: "Switzerland" },
16651
+ { iso: "AU", name: "Australia" },
16652
+ { iso: "SA", name: "Saudi Arabia" },
16653
+ { iso: "AE", name: "UAE" },
16654
+ { iso: "QA", name: "Qatar" },
16655
+ { iso: "KW", name: "Kuwait" }
16656
+ ];
16657
+ var BY_KEY = new Map(
16658
+ SUPPORTED_MARKETS.flatMap((market) => [
16659
+ [market.iso.toLowerCase(), market],
16660
+ [market.name.toLowerCase(), market]
16661
+ ])
16662
+ );
16663
+ var SUPPORTED_MARKET_NAMES = SUPPORTED_MARKETS.map(
16664
+ (market) => market.name
16665
+ );
16666
+
16590
16667
  // src/product-api-failures.ts
16591
16668
  function transportError(code, message, exitCode, retryable) {
16592
16669
  return new CliError({
@@ -16594,7 +16671,7 @@ function transportError(code, message, exitCode, retryable) {
16594
16671
  message,
16595
16672
  exitCode,
16596
16673
  retryable,
16597
- nextAction: exitCode === 6 ? "Check the network connection and try again." : "Update the Obi CLI, then try again.",
16674
+ nextAction: exitCode === 6 ? `Check the network connection and try again. If it keeps failing, run obi support "<what happened>" or write to ${SUPPORT_EMAIL} with the command you ran and the error code ${code}.` : "Update the Obi CLI, then try again.",
16598
16675
  mode: "product"
16599
16676
  });
16600
16677
  }
@@ -16624,6 +16701,14 @@ function failureError(failure2, evaluationCaseId) {
16624
16701
  mode: "product",
16625
16702
  nextAction: `Run obi business show${scope} --json and read the current work before preparing a new result.`
16626
16703
  });
16704
+ if (failure2.code === "MARKET_UNSUPPORTED") return new CliError({
16705
+ code: failure2.code,
16706
+ message: "Obi does not measure this market yet.",
16707
+ exitCode: 5,
16708
+ retryable: false,
16709
+ mode: "product",
16710
+ nextAction: `Obi measures in: ${SUPPORTED_MARKET_NAMES.join(", ")}. Choose one of them with the customer, or record the request with obi support "<market and domain>" --tag market-request.`
16711
+ });
16627
16712
  if (failure2.code === "RATE_LIMITED") {
16628
16713
  const wait = failure2.retryAfterSeconds === null ? "a moment" : `${failure2.retryAfterSeconds} seconds`;
16629
16714
  return new CliError({
@@ -17213,7 +17298,7 @@ var originMarker = {
17213
17298
  };
17214
17299
  var helpDataSchema = external_exports.object({
17215
17300
  usage: external_exports.string(),
17216
- commands: external_exports.array(external_exports.enum(["business", "capabilities", "credentials", "doctor", "eval", "harness", "login", "logout", "memory", "questions", "readiness", "research", "skill", "status", "strategies"]))
17301
+ commands: external_exports.array(external_exports.enum(["business", "capabilities", "credentials", "doctor", "eval", "harness", "login", "logout", "memory", "questions", "readiness", "research", "skill", "status", "strategies", "support"]))
17217
17302
  });
17218
17303
  var versionDataSchema = external_exports.object({ version: external_exports.string() });
17219
17304
  var skillDataSchema = external_exports.discriminatedUnion("action", [
@@ -17223,6 +17308,13 @@ var skillDataSchema = external_exports.discriminatedUnion("action", [
17223
17308
  var capabilitiesDataSchema = external_exports.object({
17224
17309
  expertise: external_exports.object({ manifestVersion: external_exports.string(), competencies: external_exports.array(external_exports.object({ id: external_exports.string(), reference: external_exports.string(), sha256: external_exports.string(), reviewedOn: external_exports.string(), sources: external_exports.array(external_exports.string()) })) }).optional(),
17225
17310
  version: external_exports.string(),
17311
+ measurementMarkets: external_exports.array(external_exports.object({ iso: external_exports.string().length(2), name: external_exports.string().min(1) })),
17312
+ catalog: external_exports.object({ version: external_exports.string(), currency: external_exports.literal("usd"), monthlyCents: external_exports.object({
17313
+ corePack: external_exports.number().int().positive(),
17314
+ claudePerPack: external_exports.number().int().positive(),
17315
+ perplexityPerPack: external_exports.number().int().positive()
17316
+ }) }),
17317
+ support: external_exports.object({ email: external_exports.literal(SUPPORT_EMAIL) }),
17226
17318
  realLogin: external_exports.literal("available"),
17227
17319
  paidExecution: external_exports.literal("server_authorized"),
17228
17320
  commands: external_exports.object({
@@ -17240,7 +17332,8 @@ var capabilitiesDataSchema = external_exports.object({
17240
17332
  memory: external_exports.object({ actions: external_exports.array(external_exports.string()), options: external_exports.array(external_exports.string()) }).optional(),
17241
17333
  status: external_exports.object({ options: external_exports.array(external_exports.string()) }),
17242
17334
  readiness: external_exports.object({ options: external_exports.array(external_exports.string()) }),
17243
- strategies: external_exports.object({ options: external_exports.array(external_exports.string()) })
17335
+ strategies: external_exports.object({ options: external_exports.array(external_exports.string()) }),
17336
+ support: external_exports.object({ tags: external_exports.array(external_exports.enum(SUPPORT_TAGS)), options: external_exports.array(external_exports.string()) })
17244
17337
  })
17245
17338
  });
17246
17339
  var localDoctorDataSchema = external_exports.object({
@@ -17249,6 +17342,7 @@ var localDoctorDataSchema = external_exports.object({
17249
17342
  origin: external_exports.string(),
17250
17343
  credentialStorage: external_exports.union([backendKindSchema, external_exports.literal("none")]),
17251
17344
  videoTools: external_exports.object({ ytDlp: external_exports.boolean(), ffmpeg: external_exports.boolean() }),
17345
+ server: external_exports.enum(["reachable", "degraded", "unreachable"]),
17252
17346
  diagnostic: external_exports.literal("completed")
17253
17347
  });
17254
17348
  var loginDataSchema = external_exports.object({
@@ -17545,6 +17639,7 @@ var successfulResultSchema = external_exports.union([
17545
17639
  external_exports.object({ ...envelope2, command: external_exports.literal("harness"), mode: external_exports.literal("product"), data: harnessCoverageDataSchema }),
17546
17640
  ...harnessEvidenceDataSchema.map((schema) => external_exports.object({ ...envelope2, command: external_exports.literal("harness"), mode: external_exports.literal("product"), data: schema })),
17547
17641
  external_exports.object({ ...envelope2, command: external_exports.literal("harness"), mode: external_exports.literal("product"), data: harnessEvidenceExportDataSchema }),
17642
+ external_exports.object({ ...envelope2, command: external_exports.literal("support"), mode: external_exports.literal("product"), data: supportDataSchema }),
17548
17643
  external_exports.object({ ...envelope2, command: external_exports.literal("memory"), mode: external_exports.literal("product"), data: memoryListDataSchema }),
17549
17644
  external_exports.object({ ...envelope2, command: external_exports.literal("memory"), mode: external_exports.literal("product"), data: memoryChangeDataSchema }),
17550
17645
  external_exports.object({
@@ -17595,7 +17690,8 @@ var failedResultSchema = external_exports.object({
17595
17690
  ...originMarker,
17596
17691
  error: errorSchema,
17597
17692
  authorization: pendingAuthorizationViewSchema.optional(),
17598
- account: confirmedAccountSchema.optional()
17693
+ account: confirmedAccountSchema.optional(),
17694
+ support: supportDataSchema.optional()
17599
17695
  });
17600
17696
  var cliResultSchema = external_exports.union([successfulResultSchema, failedResultSchema]);
17601
17697
 
@@ -17692,7 +17788,7 @@ async function send(context, request) {
17692
17788
  headers2.authorization = `Bearer ${request.bearer}`;
17693
17789
  }
17694
17790
  if (context.evaluationCaseId && /^\/api\/v1\/(?:status|business(?:\/.*)?|questions(?:\/.*)?|readiness|strategies|work\/[0-9a-fA-F-]+\/artifact(?:\/revisions(?:\/[1-9][0-9]*)?)?|harness(?:\/(?:evidence|outcomes))?|memory)(?:\?.*)?$/.test(request.path)) {
17695
- headers2["x-heysurface-evaluation-case"] = context.evaluationCaseId;
17791
+ headers2["x-obi-evaluation-case"] = context.evaluationCaseId;
17696
17792
  }
17697
17793
  if (request.idempotencyKey !== void 0) {
17698
17794
  headers2[IDEMPOTENCY_KEY_HEADER] = request.idempotencyKey;
@@ -18060,40 +18156,120 @@ async function readReadiness(context, accessToken) {
18060
18156
  responseLimitBytes: BUSINESS_REVIEW_RESPONSE_LIMIT_BYTES
18061
18157
  }), ProductReadinessResponseSchema);
18062
18158
  }
18159
+ async function sendSupportMessage(context, accessToken, message) {
18160
+ return interpretReview(await send(context, { method: "POST", path: "/api/v1/support", bearer: accessToken, body: SupportMessageSchema.parse(message) }), SupportMessageResponseSchema);
18161
+ }
18063
18162
 
18064
18163
  // src/refresh.ts
18065
18164
  import { randomBytes as randomBytes2 } from "node:crypto";
18066
- import { open as open2, readFile, stat, unlink as unlink2 } from "node:fs/promises";
18165
+ import { open as open2, readFile, stat, unlink as unlink3 } from "node:fs/promises";
18067
18166
  import { hostname as hostname3 } from "node:os";
18068
18167
  import { join as join3 } from "node:path";
18069
18168
  import { setTimeout as sleep } from "node:timers/promises";
18070
18169
 
18071
18170
  // src/file-backend.ts
18072
18171
  import { randomBytes } from "node:crypto";
18073
- import { constants } from "node:fs";
18074
- import { lstat as lstat2, open, readdir, rename, unlink } from "node:fs/promises";
18172
+ import { constants as constants2 } from "node:fs";
18173
+ import { lstat as lstat2, open, readdir as readdir2, rename as rename2, unlink as unlink2 } from "node:fs/promises";
18075
18174
  import { join as join2 } from "node:path";
18076
18175
 
18077
18176
  // src/state-directory.ts
18078
18177
  import { createHash } from "node:crypto";
18079
- import { chmod, lstat, mkdir } from "node:fs/promises";
18178
+ import { constants } from "node:fs";
18179
+ import { chmod, copyFile, cp, link, lstat, mkdir, readdir, rename, rm, unlink } from "node:fs/promises";
18080
18180
  import { homedir } from "node:os";
18081
- import { dirname, isAbsolute, join } from "node:path";
18181
+ import { basename, dirname, isAbsolute, join } from "node:path";
18082
18182
  var posixModes = process.platform !== "win32";
18083
- function resolveStateDirectory(environment) {
18183
+ function stateBase(environment) {
18084
18184
  const stateHome = environment.XDG_STATE_HOME;
18085
18185
  if (stateHome !== void 0 && isAbsolute(stateHome)) {
18086
- return join(stateHome, "heysurface");
18186
+ return stateHome;
18087
18187
  }
18088
18188
  if (process.platform === "darwin") {
18089
- return join(homedir(), "Library", "Application Support", "heysurface");
18189
+ return join(homedir(), "Library", "Application Support");
18090
18190
  }
18091
18191
  if (process.platform === "win32") {
18092
18192
  const localAppData = environment.LOCALAPPDATA;
18093
- const base = localAppData !== void 0 && isAbsolute(localAppData) ? localAppData : join(homedir(), "AppData", "Local");
18094
- return join(base, "heysurface");
18193
+ return localAppData !== void 0 && isAbsolute(localAppData) ? localAppData : join(homedir(), "AppData", "Local");
18095
18194
  }
18096
- return join(homedir(), ".local", "state", "heysurface");
18195
+ return join(homedir(), ".local", "state");
18196
+ }
18197
+ var currentName = "obi-cli";
18198
+ function resolveStateDirectory(environment) {
18199
+ return join(stateBase(environment), currentName);
18200
+ }
18201
+ var legacyName = "heysurface";
18202
+ function legacyStateDirectory(environment) {
18203
+ return join(stateBase(environment), legacyName);
18204
+ }
18205
+ function legacySibling(stateDirectory) {
18206
+ return basename(stateDirectory) === currentName ? join(dirname(stateDirectory), legacyName) : null;
18207
+ }
18208
+ async function present(path) {
18209
+ try {
18210
+ await lstat(path);
18211
+ return true;
18212
+ } catch (error51) {
18213
+ if (error51.code === "ENOENT") return false;
18214
+ throw error51;
18215
+ }
18216
+ }
18217
+ async function prepareStateDirectory(environment) {
18218
+ const current = resolveStateDirectory(environment);
18219
+ const legacy = legacyStateDirectory(environment);
18220
+ try {
18221
+ if (!await present(legacy)) return current;
18222
+ if (await present(current)) {
18223
+ await adoptConnection(legacy, current).catch(() => void 0);
18224
+ return current;
18225
+ }
18226
+ try {
18227
+ await rename(legacy, current);
18228
+ return current;
18229
+ } catch (error51) {
18230
+ const code = error51.code;
18231
+ if (code === "EXDEV") {
18232
+ await copyThenRemove(legacy, current);
18233
+ return current;
18234
+ }
18235
+ if ((code === "ENOENT" || code === "EEXIST" || code === "ENOTEMPTY") && await present(current)) return current;
18236
+ return legacy;
18237
+ }
18238
+ } catch {
18239
+ return await present(current).catch(() => false) ? current : legacy;
18240
+ }
18241
+ }
18242
+ var connectionFile = /^(credentials|pending)-[0-9a-f]{24}\.json$/;
18243
+ async function adoptConnection(legacy, current) {
18244
+ if ((await readdir(current)).some((name) => connectionFile.test(name))) return;
18245
+ for (const name of (await readdir(legacy)).filter((entry) => connectionFile.test(entry))) {
18246
+ const source = join(legacy, name);
18247
+ const target = join(current, name);
18248
+ if (!(await lstat(source)).isFile() || await present(target)) continue;
18249
+ try {
18250
+ await link(source, target);
18251
+ } catch (error51) {
18252
+ if (error51.code !== "EXDEV") throw error51;
18253
+ await copyFile(source, target, constants.COPYFILE_EXCL);
18254
+ if (posixModes) await chmod(target, 384);
18255
+ }
18256
+ await unlink(source);
18257
+ }
18258
+ }
18259
+ async function copyThenRemove(legacy, current) {
18260
+ const stats = await lstat(legacy);
18261
+ if (!stats.isDirectory()) throw new Error("not a directory");
18262
+ const staging = `${current}.${process.pid}.moving`;
18263
+ await mkdir(staging, { mode: 448 });
18264
+ try {
18265
+ await cp(legacy, staging, { recursive: true, preserveTimestamps: true, verbatimSymlinks: true, errorOnExist: true, force: false });
18266
+ if (posixModes) await chmod(staging, stats.mode & 511);
18267
+ await rename(staging, current);
18268
+ } catch (error51) {
18269
+ await rm(staging, { recursive: true, force: true });
18270
+ throw error51;
18271
+ }
18272
+ await rm(legacy, { recursive: true, force: true });
18097
18273
  }
18098
18274
  function originKey(origin) {
18099
18275
  return createHash("sha256").update(origin).digest("hex").slice(0, 24);
@@ -18148,7 +18324,7 @@ async function ensureStateDirectory(directory) {
18148
18324
 
18149
18325
  // src/file-backend.ts
18150
18326
  var maxItemBytes = 64 * 1024;
18151
- var noFollow = constants.O_NOFOLLOW ?? 0;
18327
+ var noFollow = constants2.O_NOFOLLOW ?? 0;
18152
18328
  function isMissing(error51) {
18153
18329
  return error51.code === "ENOENT";
18154
18330
  }
@@ -18190,7 +18366,7 @@ var FileBackend = class {
18190
18366
  }
18191
18367
  let handle;
18192
18368
  try {
18193
- handle = await open(path, constants.O_RDONLY | noFollow);
18369
+ handle = await open(path, constants2.O_RDONLY | noFollow);
18194
18370
  } catch (error51) {
18195
18371
  if (error51.code === "ELOOP") {
18196
18372
  throw insecureStorage();
@@ -18220,7 +18396,7 @@ var FileBackend = class {
18220
18396
  }
18221
18397
  }
18222
18398
  const temporary = join2(this.directory, `.${item}-${originKey(origin)}.${process.pid}.${randomBytes(6).toString("hex")}.tmp`);
18223
- const handle = await open(temporary, constants.O_WRONLY | constants.O_CREAT | constants.O_EXCL | noFollow, 384);
18399
+ const handle = await open(temporary, constants2.O_WRONLY | constants2.O_CREAT | constants2.O_EXCL | noFollow, 384);
18224
18400
  try {
18225
18401
  if (posixModes) {
18226
18402
  await handle.chmod(384);
@@ -18229,14 +18405,14 @@ var FileBackend = class {
18229
18405
  await handle.sync();
18230
18406
  } catch (error51) {
18231
18407
  await handle.close();
18232
- await unlink(temporary);
18408
+ await unlink2(temporary);
18233
18409
  throw error51;
18234
18410
  }
18235
18411
  await handle.close();
18236
18412
  try {
18237
- await rename(temporary, path);
18413
+ await rename2(temporary, path);
18238
18414
  } catch (error51) {
18239
- await unlink(temporary);
18415
+ await unlink2(temporary);
18240
18416
  throw error51;
18241
18417
  }
18242
18418
  }
@@ -18244,7 +18420,7 @@ var FileBackend = class {
18244
18420
  async remove(item, origin) {
18245
18421
  let names;
18246
18422
  try {
18247
- names = await readdir(this.directory);
18423
+ names = await readdir2(this.directory);
18248
18424
  } catch (error51) {
18249
18425
  if (isMissing(error51)) {
18250
18426
  return;
@@ -18255,7 +18431,7 @@ var FileBackend = class {
18255
18431
  const paths = names.filter((name) => name.startsWith(leftover) && name.endsWith(".tmp")).map((name) => join2(this.directory, name));
18256
18432
  for (const path of [this.path(item, origin), ...paths]) {
18257
18433
  try {
18258
- await unlink(path);
18434
+ await unlink2(path);
18259
18435
  } catch (error51) {
18260
18436
  if (!isMissing(error51)) {
18261
18437
  throw error51;
@@ -18266,8 +18442,9 @@ var FileBackend = class {
18266
18442
  };
18267
18443
 
18268
18444
  // src/os-backends.ts
18269
- import { accessSync, constants as constants2, existsSync as existsSync2, statSync } from "node:fs";
18270
- var service = "heysurface-cli";
18445
+ import { accessSync, constants as constants3, existsSync as existsSync2, statSync } from "node:fs";
18446
+ var currentService = "obi-cli";
18447
+ var legacyService = "heysurface-cli";
18271
18448
  var plainToken = /^[A-Za-z0-9:/.[\]_-]+$/;
18272
18449
  var keychainNotFound = 44;
18273
18450
  var maxCommandLength = 4e3;
@@ -18305,14 +18482,16 @@ async function run(executable, args, stdin) {
18305
18482
  var KeychainBackend = class {
18306
18483
  kind = "keychain";
18307
18484
  executable;
18308
- constructor(executable) {
18485
+ service;
18486
+ constructor(executable, service = currentService) {
18309
18487
  this.executable = executable;
18488
+ this.service = service;
18310
18489
  }
18311
18490
  async exists(item, origin) {
18312
18491
  return await this.read(item, origin) !== null;
18313
18492
  }
18314
18493
  async read(item, origin) {
18315
- const result = await run(this.executable, ["find-generic-password", "-s", service, "-a", account(item, origin), "-w"]);
18494
+ const result = await run(this.executable, ["find-generic-password", "-s", this.service, "-a", account(item, origin), "-w"]);
18316
18495
  if (result.exitCode === keychainNotFound) {
18317
18496
  return null;
18318
18497
  }
@@ -18323,7 +18502,7 @@ var KeychainBackend = class {
18323
18502
  }
18324
18503
  async write(item, origin, value) {
18325
18504
  const hex3 = Buffer.from(encode3(value), "utf8").toString("hex");
18326
- const command = `add-generic-password -U -s ${service} -a ${account(item, origin)} -X ${hex3}
18505
+ const command = `add-generic-password -U -s ${this.service} -a ${account(item, origin)} -X ${hex3}
18327
18506
  `;
18328
18507
  if (command.length > maxCommandLength) {
18329
18508
  throw refused();
@@ -18334,7 +18513,7 @@ var KeychainBackend = class {
18334
18513
  }
18335
18514
  }
18336
18515
  async remove(item, origin) {
18337
- const result = await run(this.executable, ["delete-generic-password", "-s", service, "-a", account(item, origin)]);
18516
+ const result = await run(this.executable, ["delete-generic-password", "-s", this.service, "-a", account(item, origin)]);
18338
18517
  if (result.exitCode !== 0 && result.exitCode !== keychainNotFound) {
18339
18518
  throw refused();
18340
18519
  }
@@ -18343,11 +18522,13 @@ var KeychainBackend = class {
18343
18522
  var SecretServiceBackend = class {
18344
18523
  kind = "secret-service";
18345
18524
  executable;
18346
- constructor(executable) {
18525
+ service;
18526
+ constructor(executable, service = currentService) {
18347
18527
  this.executable = executable;
18528
+ this.service = service;
18348
18529
  }
18349
18530
  attributes(item, origin) {
18350
- return ["service", service, "account", account(item, origin)];
18531
+ return ["service", this.service, "account", account(item, origin)];
18351
18532
  }
18352
18533
  async exists(item, origin) {
18353
18534
  return await this.read(item, origin) !== null;
@@ -18363,7 +18544,7 @@ var SecretServiceBackend = class {
18363
18544
  return decode3(result.stdout);
18364
18545
  }
18365
18546
  async write(item, origin, value) {
18366
- const result = await run(this.executable, ["store", "--label=Heysurface CLI", ...this.attributes(item, origin)], encode3(value));
18547
+ const result = await run(this.executable, ["store", "--label=Obi CLI", ...this.attributes(item, origin)], encode3(value));
18367
18548
  if (result.exitCode !== 0) {
18368
18549
  throw refused();
18369
18550
  }
@@ -18379,7 +18560,7 @@ var secretToolLocations = ["/usr/bin/secret-tool", "/usr/local/bin/secret-tool",
18379
18560
  function installedSecretTool() {
18380
18561
  for (const candidate of secretToolLocations) {
18381
18562
  try {
18382
- accessSync(candidate, constants2.X_OK);
18563
+ accessSync(candidate, constants3.X_OK);
18383
18564
  if (statSync(candidate).isFile()) {
18384
18565
  return candidate;
18385
18566
  }
@@ -18388,15 +18569,58 @@ function installedSecretTool() {
18388
18569
  }
18389
18570
  return null;
18390
18571
  }
18572
+ var MigratingBackend = class {
18573
+ kind;
18574
+ current;
18575
+ legacy;
18576
+ constructor(current, legacy) {
18577
+ this.kind = current.kind;
18578
+ this.current = current;
18579
+ this.legacy = legacy;
18580
+ }
18581
+ async exists(item, origin) {
18582
+ return await this.read(item, origin) !== null;
18583
+ }
18584
+ async read(item, origin) {
18585
+ const value = await this.current.read(item, origin);
18586
+ if (value !== null) return value;
18587
+ const old = await this.legacy.read(item, origin);
18588
+ if (old === null) return null;
18589
+ const moved = await this.current.read(item, origin);
18590
+ if (moved !== null) {
18591
+ await this.legacy.remove(item, origin).catch(() => void 0);
18592
+ return moved;
18593
+ }
18594
+ try {
18595
+ await this.current.write(item, origin, old);
18596
+ } catch {
18597
+ return old;
18598
+ }
18599
+ await this.legacy.remove(item, origin).catch(() => void 0);
18600
+ return old;
18601
+ }
18602
+ async write(item, origin, value) {
18603
+ await this.current.write(item, origin, value);
18604
+ }
18605
+ async remove(item, origin) {
18606
+ await this.current.remove(item, origin);
18607
+ try {
18608
+ await this.legacy.remove(item, origin);
18609
+ } catch {
18610
+ process.stderr.write("Warning: a copy of this connection under the former store name could not be removed.\n");
18611
+ }
18612
+ }
18613
+ };
18391
18614
  function systemBackend() {
18392
18615
  if (process.platform === "darwin") {
18393
- return existsSync2("/usr/bin/security") ? new KeychainBackend("/usr/bin/security") : null;
18616
+ const security = "/usr/bin/security";
18617
+ return existsSync2(security) ? new MigratingBackend(new KeychainBackend(security), new KeychainBackend(security, legacyService)) : null;
18394
18618
  }
18395
18619
  if (process.platform === "win32") {
18396
18620
  return null;
18397
18621
  }
18398
18622
  const secretTool = installedSecretTool();
18399
- return secretTool === null ? null : new SecretServiceBackend(secretTool);
18623
+ return secretTool === null ? null : new MigratingBackend(new SecretServiceBackend(secretTool), new SecretServiceBackend(secretTool, legacyService));
18400
18624
  }
18401
18625
 
18402
18626
  // src/retired-origin.ts
@@ -18634,7 +18858,7 @@ async function acquireLock(path) {
18634
18858
  if (holder !== null && isStale(holder)) {
18635
18859
  const current = await readHolder(path);
18636
18860
  if (current !== null && current.raw === holder.raw && current.identity === holder.identity) {
18637
- await unlink2(path).catch((error51) => {
18861
+ await unlink3(path).catch((error51) => {
18638
18862
  if (error51.code !== "ENOENT") throw error51;
18639
18863
  });
18640
18864
  }
@@ -18653,7 +18877,7 @@ async function withCredentialLock(context, action) {
18653
18877
  try {
18654
18878
  return await action();
18655
18879
  } finally {
18656
- await unlink2(path).catch((error51) => {
18880
+ await unlink3(path).catch((error51) => {
18657
18881
  if (error51.code !== "ENOENT") throw error51;
18658
18882
  });
18659
18883
  }
@@ -19085,7 +19309,7 @@ async function submitHarnessObservation(context, path) {
19085
19309
 
19086
19310
  // src/commands.ts
19087
19311
  import { access } from "node:fs/promises";
19088
- import { fileURLToPath } from "node:url";
19312
+ import { fileURLToPath as fileURLToPath2 } from "node:url";
19089
19313
 
19090
19314
  // src/onboarding-guide.ts
19091
19315
  var READING_POLL_MS = 6e4;
@@ -19708,7 +19932,7 @@ import { resolve } from "node:path";
19708
19932
 
19709
19933
  // src/local-json.ts
19710
19934
  import { randomUUID as randomUUID2 } from "node:crypto";
19711
- import { rename as rename2, unlink as unlink3, writeFile as writeFile2 } from "node:fs/promises";
19935
+ import { rename as rename3, unlink as unlink4, writeFile as writeFile2 } from "node:fs/promises";
19712
19936
  function localFileError(message, nextAction) {
19713
19937
  return new CliError({
19714
19938
  code: "RESEARCH_FILE_ERROR",
@@ -19726,9 +19950,9 @@ async function writeJsonAtomic(path, value, options) {
19726
19950
  if (bytes > options.maxBytes) throw localFileError(options.tooLarge, options.nextAction);
19727
19951
  try {
19728
19952
  await writeFile2(temporary, content, { mode: 384, flag: "wx" });
19729
- await rename2(temporary, path);
19953
+ await rename3(temporary, path);
19730
19954
  } catch {
19731
- await unlink3(temporary).catch(() => void 0);
19955
+ await unlink4(temporary).catch(() => void 0);
19732
19956
  throw localFileError("The output could not be written atomically.", options.nextAction);
19733
19957
  }
19734
19958
  return bytes;
@@ -20020,7 +20244,7 @@ import { setTimeout as sleep2 } from "node:timers/promises";
20020
20244
  import { execFileSync } from "node:child_process";
20021
20245
  import { readFileSync } from "node:fs";
20022
20246
  import { hostname as hostname4 } from "node:os";
20023
- import { basename } from "node:path";
20247
+ import { basename as basename2 } from "node:path";
20024
20248
  var maxLabelLength = 64;
20025
20249
  function parentProcessName() {
20026
20250
  try {
@@ -20033,7 +20257,7 @@ function parentProcessName() {
20033
20257
  stdio: ["ignore", "pipe", "ignore"],
20034
20258
  timeout: 2e3
20035
20259
  });
20036
- return basename(command.trim());
20260
+ return basename2(command.trim());
20037
20261
  }
20038
20262
  } catch {
20039
20263
  }
@@ -20056,17 +20280,30 @@ function deviceLabel() {
20056
20280
  // src/origin.ts
20057
20281
  var productionOrigin = "https://agent.hireobi.com";
20058
20282
  var developmentOrigin = /^http:\/\/(localhost|127\.0\.0\.1|\[::1\]):([1-9][0-9]{0,4})$/;
20283
+ var retiredVariable = "HEYSURFACE_ORIGIN";
20059
20284
  function invalidOrigin() {
20060
20285
  return new CliError({
20061
20286
  code: "INVALID_ORIGIN",
20062
- message: "HEYSURFACE_ORIGIN must be a loopback development origin with an explicit port.",
20287
+ message: "OBI_ORIGIN must be a loopback development origin with an explicit port.",
20288
+ exitCode: 2,
20289
+ retryable: false,
20290
+ nextAction: "Unset OBI_ORIGIN, or set it to http://localhost:<port>, http://127.0.0.1:<port> or http://[::1]:<port>."
20291
+ });
20292
+ }
20293
+ function retiredOrigin() {
20294
+ return new CliError({
20295
+ code: "INVALID_ORIGIN",
20296
+ message: `${retiredVariable} is no longer read; the development origin is OBI_ORIGIN.`,
20063
20297
  exitCode: 2,
20064
20298
  retryable: false,
20065
- nextAction: "Unset HEYSURFACE_ORIGIN, or set it to http://localhost:<port>, http://127.0.0.1:<port> or http://[::1]:<port>."
20299
+ nextAction: `Unset ${retiredVariable}, and set OBI_ORIGIN instead if you meant a development server.`
20066
20300
  });
20067
20301
  }
20068
20302
  function resolveOrigin(environment) {
20069
- const override = environment.HEYSURFACE_ORIGIN;
20303
+ if (environment[retiredVariable] !== void 0) {
20304
+ throw retiredOrigin();
20305
+ }
20306
+ const override = environment.OBI_ORIGIN;
20070
20307
  if (override === void 0) {
20071
20308
  return { origin: productionOrigin, development: false };
20072
20309
  }
@@ -20137,6 +20374,111 @@ function memoryText(data) {
20137
20374
  `;
20138
20375
  }
20139
20376
 
20377
+ // src/support-commands.ts
20378
+ import { createHash as createHash2 } from "node:crypto";
20379
+ import { release } from "node:os";
20380
+
20381
+ // src/last-error.ts
20382
+ import { readFile as readFile6, writeFile as writeFile3 } from "node:fs/promises";
20383
+ import { join as join4 } from "node:path";
20384
+ var fileIn = (stateDirectory) => join4(stateDirectory, "last-error.json");
20385
+ async function recordLastError(stateDirectory, error51) {
20386
+ try {
20387
+ const parsed = lastErrorSchema.safeParse({ ...error51, at: (/* @__PURE__ */ new Date()).toISOString() });
20388
+ if (!parsed.success) return;
20389
+ await ensureStateDirectory(stateDirectory);
20390
+ await writeFile3(fileIn(stateDirectory), JSON.stringify(parsed.data), { mode: 384 });
20391
+ } catch {
20392
+ }
20393
+ }
20394
+ async function readLastError(stateDirectory) {
20395
+ try {
20396
+ const parsed = lastErrorSchema.safeParse(JSON.parse(await readFile6(fileIn(stateDirectory), "utf8")));
20397
+ return parsed.success ? parsed.data : null;
20398
+ } catch {
20399
+ return null;
20400
+ }
20401
+ }
20402
+
20403
+ // src/version.ts
20404
+ var cliVersion = "0.1.9";
20405
+
20406
+ // src/support-commands.ts
20407
+ async function probeServer(origin, timeoutMs) {
20408
+ try {
20409
+ const response = await exchange({
20410
+ url: new URL("/api/health", origin.origin),
20411
+ method: "GET",
20412
+ headers: { accept: "application/json" },
20413
+ timeoutMs
20414
+ });
20415
+ return response.status === 200 ? "reachable" : "degraded";
20416
+ } catch {
20417
+ return "unreachable";
20418
+ }
20419
+ }
20420
+ async function sendSupport(context, input) {
20421
+ const lastError = await readLastError(context.stateDirectory);
20422
+ const diagnostic = { cliVersion, node: process.version, os: `${process.platform} ${release()} ${process.arch}`, lastError };
20423
+ let account2 = null;
20424
+ let reason = null;
20425
+ try {
20426
+ const located = await locateCredential(context);
20427
+ if (located === null) {
20428
+ reason = "AUTH_REQUIRED";
20429
+ } else {
20430
+ account2 = located.credential.account.email;
20431
+ const requestId = createHash2("sha256").update(JSON.stringify([
20432
+ context.origin.origin,
20433
+ account2,
20434
+ input.message,
20435
+ input.tag,
20436
+ (/* @__PURE__ */ new Date()).toISOString().slice(0, 10)
20437
+ ])).digest("hex").slice(0, 32);
20438
+ const { result } = await useCredential(
20439
+ context,
20440
+ located,
20441
+ (token) => sendSupportMessage(context, token, { requestId, ...input, diagnostic })
20442
+ );
20443
+ if (!result.ok) reason = result.failure.httpStatus >= 500 ? "SERVICE_UNAVAILABLE" : result.failure.code;
20444
+ }
20445
+ } catch (error51) {
20446
+ reason = error51 instanceof CliError ? error51.code : "INTERNAL_ERROR";
20447
+ }
20448
+ const diagnosticText = [
20449
+ `Message: ${input.message}`,
20450
+ `Tag: ${input.tag ?? "general"}`,
20451
+ `Obi CLI ${diagnostic.cliVersion} \xB7 Node ${diagnostic.node} \xB7 ${diagnostic.os}`,
20452
+ `Last error: ${lastError === null ? "none" : `${lastError.code} (${lastError.command}) at ${lastError.at}`}`,
20453
+ `Account: ${account2 ?? "not signed in"}`
20454
+ ].join("\n");
20455
+ const data = {
20456
+ delivery: reason === null ? "sent" : "not_sent",
20457
+ reason,
20458
+ supportEmail: SUPPORT_EMAIL,
20459
+ mailto: `mailto:${SUPPORT_EMAIL}`,
20460
+ tag: input.tag,
20461
+ account: account2,
20462
+ origin: context.origin.origin,
20463
+ diagnosticText
20464
+ };
20465
+ if (reason === null) return data;
20466
+ throw new CliError({
20467
+ code: "SUPPORT_NOT_SENT",
20468
+ message: `The message was not sent to Obi support (${reason}).`,
20469
+ exitCode: reason === "AUTH_REQUIRED" ? 3 : 6,
20470
+ retryable: reason !== "AUTH_REQUIRED",
20471
+ mode: "product",
20472
+ command: "support",
20473
+ nextAction: `Write to ${SUPPORT_EMAIL} and paste the block below (support.diagnosticText with --json). Never add a token or a credential file.`,
20474
+ support: data
20475
+ });
20476
+ }
20477
+ function supportText(data) {
20478
+ return `Sent to Obi support (${data.supportEmail}). The reply goes to ${sanitizeHumanText(data.account ?? "the account email")}.
20479
+ `;
20480
+ }
20481
+
20140
20482
  // src/scan-output.ts
20141
20483
  function heading(data) {
20142
20484
  const scored = `${data.scoredCells}/${data.expectedCells} answers scored from question version ${data.candidateVersion ?? "none"}.`;
@@ -20261,6 +20603,7 @@ function failureText(result) {
20261
20603
  lines.push(`Approving account: ${sanitizeHumanText(result.account.email)} (${result.account.role}).`);
20262
20604
  }
20263
20605
  lines.push(sanitizeHumanText(result.error.nextAction));
20606
+ if (result.support !== void 0) lines.push("", ...result.support.diagnosticText.split("\n").map(sanitizeHumanText));
20264
20607
  return `${lines.join("\n")}
20265
20608
  `;
20266
20609
  }
@@ -20294,22 +20637,21 @@ var storageLabels = {
20294
20637
  "secret-service": "the system Secret Service",
20295
20638
  file: "a file readable only by your user"
20296
20639
  };
20297
- function toHumanOutput(result, identity = "heysurface") {
20640
+ function toHumanOutput(result) {
20298
20641
  if (!result.ok) {
20299
20642
  return failureText(result);
20300
20643
  }
20301
20644
  if (result.command === "help") {
20302
- if (identity === "heysurface") return `Usage: ${result.data.usage}
20303
- `;
20304
- const usage2 = result.data.usage.split("\n").map((line) => ` ${line.trimStart().replace(/^heysurface /, "obi ")}`).join("\n");
20645
+ const usage2 = result.data.usage.split("\n").map((line) => ` ${line.trimStart()}`).join("\n");
20305
20646
  return `Obi \xB7 AI Search Employee
20306
20647
 
20307
20648
  Get started
20308
- 1. obi skill install
20309
- 2. In a new Claude Code or Cursor chat, type /obi.
20649
+ 1. In Claude Code or Cursor, type /obi.
20310
20650
  In Codex CLI, type $obi or choose Obi from /skills.
20311
20651
  In the desktop app, select Obi from the skills picker.
20312
- 3. Give Obi a website or ask to continue saved work.
20652
+ In OpenCode, type @obi.
20653
+ 2. Give Obi a website or ask to continue saved work.
20654
+ Every obi command registers the Skill; obi skill install repairs it.
20313
20655
 
20314
20656
  Commands
20315
20657
  ${usage2}
@@ -20321,11 +20663,11 @@ ${usage2}
20321
20663
  }
20322
20664
  if (result.command === "skill") {
20323
20665
  return result.data.action === "path" ? `${sanitizeHumanText(result.data.path)}
20324
- ` : identity === "obi" ? `Obi Skill registered locally. In a new Claude Code or Cursor chat, type /obi. In Codex CLI, type $obi or choose Obi from /skills. In the desktop app, select Obi from the skills picker.
20325
- ${result.data.removed.length > 0 ? "The earlier /heysurface Skill links of this package were removed; use /obi instead.\n" : ""}` : "Heysurface Skill registered locally. Open a new Claude Code or Cursor agent chat and type /heysurface.\n";
20666
+ ` : `Obi Skill registered locally. In a new Claude Code or Cursor chat, type /obi. In Codex CLI, type $obi or choose Obi from /skills. In the desktop app, select Obi from the skills picker. In OpenCode, type @obi.
20667
+ ${result.data.removed.length > 0 ? "Earlier Skill links of this package under another name were removed; use /obi.\n" : ""}`;
20326
20668
  }
20327
20669
  if (result.command === "capabilities") {
20328
- return "Available: business, capabilities, credentials, doctor, eval, harness, login, logout, memory, questions, readiness, research, skill, status, strategies. Scan execution requires server authorization and a separate customer decision.\n";
20670
+ return "Available: business, capabilities, credentials, doctor, eval, harness, login, logout, memory, questions, readiness, research, skill, status, strategies, support. Scan execution requires server authorization and a separate customer decision.\n";
20329
20671
  }
20330
20672
  if (result.command === "eval") {
20331
20673
  if ("evaluation" in result.data) {
@@ -20340,6 +20682,7 @@ Next: ${sanitizeHumanText(result.data.nextStep)}
20340
20682
  return result.data.action === "list" ? connectionListText(result.data) : revocationText(result.data);
20341
20683
  }
20342
20684
  if (result.command === "memory") return memoryText(result.data);
20685
+ if (result.command === "support") return supportText(result.data);
20343
20686
  if (result.command === "doctor") {
20344
20687
  if (result.mode === "test") {
20345
20688
  return `Synthetic test protocol reachable. State: ${String(result.data.state)}.
@@ -20347,7 +20690,12 @@ Next: ${sanitizeHumanText(result.data.nextStep)}
20347
20690
  }
20348
20691
  const storage = result.data.credentialStorage === "none" ? "no stored connection" : `connection stored in ${storageLabels[result.data.credentialStorage]}`;
20349
20692
  const video = result.data.videoTools.ytDlp ? `video reading available${result.data.videoTools.ffmpeg ? " with frames" : " (captions only; frames need ffmpeg)"}` : "video reading needs yt-dlp";
20350
- return `Local diagnostic completed for ${sanitizeHumanText(result.data.origin)}: ${storage}; ${video}. No request was sent.
20693
+ const server = {
20694
+ reachable: "Obi server reachable.",
20695
+ degraded: `Obi server degraded: try again later, and write to ${SUPPORT_EMAIL} if it lasts.`,
20696
+ unreachable: `Obi server unreachable: check the network connection, and write to ${SUPPORT_EMAIL} if it lasts.`
20697
+ }[result.data.server];
20698
+ return `Local diagnostic completed for ${sanitizeHumanText(result.data.origin)}: ${storage}; ${video}. ${server}
20351
20699
  `;
20352
20700
  }
20353
20701
  if (result.command === "login") {
@@ -20538,11 +20886,11 @@ ${sanitizeHumanText(data.revision.content)}
20538
20886
  ];
20539
20887
  if (review.identity === null) lines.push(" pending");
20540
20888
  else {
20541
- const { identity: identity2 } = review;
20542
- lines.push(` Current company name [${identity2.origin}${identity2.latestReview === null ? "" : `, ${identity2.latestReview}`}]: ${sanitizeHumanText(identity2.value.companyName ?? "unresolved")} (company only).`);
20543
- lines.push(` Site proposal [${identity2.proposal.status}]: ${sanitizeHumanText(identity2.proposal.name ?? "unresolved")} on ${sanitizeHumanText(identity2.proposal.domain)} (${sanitizeHumanText(identity2.proposal.reason)}).`);
20544
- if (identity2.conflict !== null) lines.push(` Name conflict: customer says ${sanitizeHumanText(identity2.conflict.customerName)}; site proposes ${sanitizeHumanText(identity2.conflict.siteProposedName)}. Keep the customer name and review the discrepancy.`);
20545
- for (const evidence2 of identity2.proposal.evidence) lines.push(` Proposal evidence: ${sanitizeHumanText(evidence2.quote)} \u2014 ${sanitizeHumanText(evidence2.url)}`);
20889
+ const { identity } = review;
20890
+ lines.push(` Current company name [${identity.origin}${identity.latestReview === null ? "" : `, ${identity.latestReview}`}]: ${sanitizeHumanText(identity.value.companyName ?? "unresolved")} (company only).`);
20891
+ lines.push(` Site proposal [${identity.proposal.status}]: ${sanitizeHumanText(identity.proposal.name ?? "unresolved")} on ${sanitizeHumanText(identity.proposal.domain)} (${sanitizeHumanText(identity.proposal.reason)}).`);
20892
+ if (identity.conflict !== null) lines.push(` Name conflict: customer says ${sanitizeHumanText(identity.conflict.customerName)}; site proposes ${sanitizeHumanText(identity.conflict.siteProposedName)}. Keep the customer name and review the discrepancy.`);
20893
+ for (const evidence2 of identity.proposal.evidence) lines.push(` Proposal evidence: ${sanitizeHumanText(evidence2.quote)} \u2014 ${sanitizeHumanText(evidence2.url)}`);
20546
20894
  }
20547
20895
  lines.push("Summary:");
20548
20896
  if (review.summary === null) lines.push(" pending");
@@ -20649,13 +20997,13 @@ function humanWarnings(result) {
20649
20997
  }
20650
20998
  return "";
20651
20999
  }
20652
- function writeResult(result, json2, identity = "heysurface") {
21000
+ function writeResult(result, json2) {
20653
21001
  if (json2) {
20654
21002
  process.stdout.write(toJsonLine(result));
20655
21003
  return;
20656
21004
  }
20657
- const human = toHumanOutput(result, identity);
20658
- const heading2 = identity === "obi" && (!result.ok || result.command !== "version" && result.command !== "skill" && result.command !== "help") ? "Obi\n\n" : "";
21005
+ const human = toHumanOutput(result);
21006
+ const heading2 = !result.ok || result.command !== "version" && result.command !== "skill" && result.command !== "help" ? "Obi\n\n" : "";
20659
21007
  const output = `${heading2}${result.evaluationCaseId ? `Evaluation case ${result.evaluationCaseId}
20660
21008
  ${human}` : human}`;
20661
21009
  if (result.ok) {
@@ -20683,9 +21031,6 @@ async function confirmAccount(account2) {
20683
21031
  }
20684
21032
  }
20685
21033
 
20686
- // src/version.ts
20687
- var cliVersion = "0.1.7";
20688
-
20689
21034
  // src/login.ts
20690
21035
  var loginRequestTimeoutMs = 1e4;
20691
21036
  var maxLinkLength = 200;
@@ -20704,10 +21049,10 @@ function connectionLink(pending) {
20704
21049
  return pending.verificationUriComplete ?? pending.verificationUri;
20705
21050
  }
20706
21051
  function announcementLines(pending, opening) {
20707
- const link = sanitizeHumanText(connectionLink(pending));
21052
+ const link2 = sanitizeHumanText(connectionLink(pending));
20708
21053
  const code = sanitizeHumanText(pending.userCode);
20709
21054
  return [
20710
- opening ? `Opening ${link} in your browser: sign in there, or create your Obi account.` : `Open ${link} to sign in or create your Obi account.`,
21055
+ opening ? `Opening ${link2} in your browser: sign in there, or create your Obi account.` : `Open ${link2} to sign in or create your Obi account.`,
20711
21056
  `Check that the page shows the code ${code}, and approve the connection only if it does.`
20712
21057
  ];
20713
21058
  }
@@ -20895,7 +21240,7 @@ function accountMismatch(account2, revoked, expected) {
20895
21240
  }
20896
21241
  async function confirmAndStore(context, store, pair, receivedAt, expectedEmail) {
20897
21242
  const api = context;
20898
- const release2 = guardNewFamily(api, pair);
21243
+ const release3 = guardNewFamily(api, pair);
20899
21244
  let stored = false;
20900
21245
  try {
20901
21246
  const status = await readAccountStatus(api, pair.accessToken);
@@ -20926,7 +21271,7 @@ async function confirmAndStore(context, store, pair, receivedAt, expectedEmail)
20926
21271
  }
20927
21272
  await store.writeCredential(credentialFromPair(context.origin.origin, pair, confirmed, receivedAt));
20928
21273
  stored = true;
20929
- release2();
21274
+ release3();
20930
21275
  });
20931
21276
  try {
20932
21277
  await store.removePending();
@@ -20946,7 +21291,7 @@ async function confirmAndStore(context, store, pair, receivedAt, expectedEmail)
20946
21291
  }
20947
21292
  throw error51;
20948
21293
  } finally {
20949
- release2();
21294
+ release3();
20950
21295
  }
20951
21296
  }
20952
21297
  async function login(session, options) {
@@ -21085,12 +21430,12 @@ async function proceedToFirstScan(context, candidateVersion) {
21085
21430
  }
21086
21431
 
21087
21432
  // src/research-commands.ts
21088
- import { readFile as readFile6, stat as stat6 } from "node:fs/promises";
21433
+ import { readFile as readFile7, stat as stat6 } from "node:fs/promises";
21089
21434
  import { isDeepStrictEqual as isDeepStrictEqual2 } from "node:util";
21090
21435
  import { resolve as resolve2 } from "node:path";
21091
21436
 
21092
21437
  // ../geo-engine/src/geo/host-acquisition.ts
21093
- import { createHash as createHash5 } from "node:crypto";
21438
+ import { createHash as createHash6 } from "node:crypto";
21094
21439
 
21095
21440
  // ../geo-engine/src/url-safety.ts
21096
21441
  var PRIVATE_IP_RE = /^(127\.|10\.|192\.168\.|169\.254\.|172\.(1[6-9]|2\d|3[01])\.|0\.)/;
@@ -21140,12 +21485,12 @@ import { urlToHttpOptions } from "node:url";
21140
21485
 
21141
21486
  // ../geo-engine/src/safe-fetch-decoding.ts
21142
21487
  import { Duplex, pipeline } from "node:stream";
21143
- import { constants as constants3, createBrotliDecompress, createGunzip, createInflate, createInflateRaw } from "node:zlib";
21488
+ import { constants as constants4, createBrotliDecompress, createGunzip, createInflate, createInflateRaw } from "node:zlib";
21144
21489
  var MAX_CODINGS = 5;
21145
21490
  var ZLIB_DEFLATE_METHOD = 8;
21146
21491
  var BODILESS_STATUSES = /* @__PURE__ */ new Set([204, 205, 304]);
21147
- var ZLIB_LENIENCY = { flush: constants3.Z_SYNC_FLUSH, finishFlush: constants3.Z_SYNC_FLUSH };
21148
- var BROTLI_LENIENCY = { flush: constants3.BROTLI_OPERATION_FLUSH, finishFlush: constants3.BROTLI_OPERATION_FLUSH };
21492
+ var ZLIB_LENIENCY = { flush: constants4.Z_SYNC_FLUSH, finishFlush: constants4.Z_SYNC_FLUSH };
21493
+ var BROTLI_LENIENCY = { flush: constants4.BROTLI_OPERATION_FLUSH, finishFlush: constants4.BROTLI_OPERATION_FLUSH };
21149
21494
  function createDeflateDecoder() {
21150
21495
  let inflater;
21151
21496
  const start = (format) => {
@@ -21261,7 +21606,7 @@ async function safeFetch(url3, opts = {}) {
21261
21606
  if (!REDIRECT_STATUSES.has(res.status)) return res;
21262
21607
  const location = res.headers.get("location");
21263
21608
  if (!location) return res;
21264
- await release(res);
21609
+ await release2(res);
21265
21610
  let next;
21266
21611
  try {
21267
21612
  next = new URL(location, current).href;
@@ -21272,7 +21617,7 @@ async function safeFetch(url3, opts = {}) {
21272
21617
  }
21273
21618
  throw new TooManyRedirectsError(url3, maxRedirects);
21274
21619
  }
21275
- async function release(res) {
21620
+ async function release2(res) {
21276
21621
  await res.body?.cancel().catch((err) => {
21277
21622
  console.warn("[safe-fetch] cancelling an unread body failed:", err);
21278
21623
  });
@@ -21280,7 +21625,7 @@ async function release(res) {
21280
21625
  async function readCapped(res, maxBytes = MAX_RESPONSE_BYTES) {
21281
21626
  const declared = Number(res.headers.get("content-length"));
21282
21627
  if (Number.isFinite(declared) && declared > maxBytes) {
21283
- await release(res);
21628
+ await release2(res);
21284
21629
  return "";
21285
21630
  }
21286
21631
  if (!res.body) return (await res.text()).slice(0, maxBytes);
@@ -21446,7 +21791,7 @@ function createVettedTransport(options = {}) {
21446
21791
  }
21447
21792
 
21448
21793
  // ../geo-engine/src/geo/page-evidence.ts
21449
- import { createHash as createHash2 } from "node:crypto";
21794
+ import { createHash as createHash3 } from "node:crypto";
21450
21795
 
21451
21796
  // ../node_modules/parse5/dist/common/unicode.js
21452
21797
  var UNDEFINED_CODE_POINTS = /* @__PURE__ */ new Set([
@@ -21523,20 +21868,20 @@ var SEQUENCES = {
21523
21868
  PUBLIC: "public",
21524
21869
  SYSTEM: "system"
21525
21870
  };
21526
- function isSurrogate(cp) {
21527
- return cp >= 55296 && cp <= 57343;
21871
+ function isSurrogate(cp2) {
21872
+ return cp2 >= 55296 && cp2 <= 57343;
21528
21873
  }
21529
- function isSurrogatePair(cp) {
21530
- return cp >= 56320 && cp <= 57343;
21874
+ function isSurrogatePair(cp2) {
21875
+ return cp2 >= 56320 && cp2 <= 57343;
21531
21876
  }
21532
21877
  function getSurrogatePairCodePoint(cp1, cp2) {
21533
21878
  return (cp1 - 55296) * 1024 + 9216 + cp2;
21534
21879
  }
21535
- function isControlCodePoint(cp) {
21536
- return cp !== 32 && cp !== 10 && cp !== 13 && cp !== 9 && cp !== 12 && cp >= 1 && cp <= 31 || cp >= 127 && cp <= 159;
21880
+ function isControlCodePoint(cp2) {
21881
+ return cp2 !== 32 && cp2 !== 10 && cp2 !== 13 && cp2 !== 9 && cp2 !== 12 && cp2 >= 1 && cp2 <= 31 || cp2 >= 127 && cp2 <= 159;
21537
21882
  }
21538
- function isUndefinedCodePoint(cp) {
21539
- return cp >= 64976 && cp <= 65007 || UNDEFINED_CODE_POINTS.has(cp);
21883
+ function isUndefinedCodePoint(cp2) {
21884
+ return cp2 >= 64976 && cp2 <= 65007 || UNDEFINED_CODE_POINTS.has(cp2);
21540
21885
  }
21541
21886
 
21542
21887
  // ../node_modules/parse5/dist/common/error-codes.js
@@ -21654,20 +21999,20 @@ var Preprocessor = class {
21654
21999
  this.gapStack.push(this.lastGapPos);
21655
22000
  this.lastGapPos = this.pos;
21656
22001
  }
21657
- _processSurrogate(cp) {
22002
+ _processSurrogate(cp2) {
21658
22003
  if (this.pos !== this.html.length - 1) {
21659
22004
  const nextCp = this.html.charCodeAt(this.pos + 1);
21660
22005
  if (isSurrogatePair(nextCp)) {
21661
22006
  this.pos++;
21662
22007
  this._addGap();
21663
- return getSurrogatePairCodePoint(cp, nextCp);
22008
+ return getSurrogatePairCodePoint(cp2, nextCp);
21664
22009
  }
21665
22010
  } else if (!this.lastChunkWritten) {
21666
22011
  this.endOfChunkHit = true;
21667
22012
  return CODE_POINTS.EOF;
21668
22013
  }
21669
22014
  this._err(ERR.surrogateInInputStream);
21670
- return cp;
22015
+ return cp2;
21671
22016
  }
21672
22017
  willDropParsedChunk() {
21673
22018
  return this.pos > this.bufferWaterline;
@@ -21704,8 +22049,8 @@ var Preprocessor = class {
21704
22049
  return this.html.startsWith(pattern, this.pos);
21705
22050
  }
21706
22051
  for (let i = 0; i < pattern.length; i++) {
21707
- const cp = this.html.charCodeAt(this.pos + i) | 32;
21708
- if (cp !== pattern.charCodeAt(i)) {
22052
+ const cp2 = this.html.charCodeAt(this.pos + i) | 32;
22053
+ if (cp2 !== pattern.charCodeAt(i)) {
21709
22054
  return false;
21710
22055
  }
21711
22056
  }
@@ -21731,13 +22076,13 @@ var Preprocessor = class {
21731
22076
  this.endOfChunkHit = !this.lastChunkWritten;
21732
22077
  return CODE_POINTS.EOF;
21733
22078
  }
21734
- let cp = this.html.charCodeAt(this.pos);
21735
- if (cp === CODE_POINTS.CARRIAGE_RETURN) {
22079
+ let cp2 = this.html.charCodeAt(this.pos);
22080
+ if (cp2 === CODE_POINTS.CARRIAGE_RETURN) {
21736
22081
  this.isEol = true;
21737
22082
  this.skipNextNewLine = true;
21738
22083
  return CODE_POINTS.LINE_FEED;
21739
22084
  }
21740
- if (cp === CODE_POINTS.LINE_FEED) {
22085
+ if (cp2 === CODE_POINTS.LINE_FEED) {
21741
22086
  this.isEol = true;
21742
22087
  if (this.skipNextNewLine) {
21743
22088
  this.line--;
@@ -21747,19 +22092,19 @@ var Preprocessor = class {
21747
22092
  }
21748
22093
  }
21749
22094
  this.skipNextNewLine = false;
21750
- if (isSurrogate(cp)) {
21751
- cp = this._processSurrogate(cp);
22095
+ if (isSurrogate(cp2)) {
22096
+ cp2 = this._processSurrogate(cp2);
21752
22097
  }
21753
- const isCommonValidRange = this.handler.onParseError === null || cp > 31 && cp < 127 || cp === CODE_POINTS.LINE_FEED || cp === CODE_POINTS.CARRIAGE_RETURN || cp > 159 && cp < 64976;
22098
+ const isCommonValidRange = this.handler.onParseError === null || cp2 > 31 && cp2 < 127 || cp2 === CODE_POINTS.LINE_FEED || cp2 === CODE_POINTS.CARRIAGE_RETURN || cp2 > 159 && cp2 < 64976;
21754
22099
  if (!isCommonValidRange) {
21755
- this._checkForProblematicCharacters(cp);
22100
+ this._checkForProblematicCharacters(cp2);
21756
22101
  }
21757
- return cp;
22102
+ return cp2;
21758
22103
  }
21759
- _checkForProblematicCharacters(cp) {
21760
- if (isControlCodePoint(cp)) {
22104
+ _checkForProblematicCharacters(cp2) {
22105
+ if (isControlCodePoint(cp2)) {
21761
22106
  this._err(ERR.controlCharacterInInputStream);
21762
- } else if (isUndefinedCodePoint(cp)) {
22107
+ } else if (isUndefinedCodePoint(cp2)) {
21763
22108
  this._err(ERR.noncharacterInInputStream);
21764
22109
  }
21765
22110
  }
@@ -22825,29 +23170,29 @@ var TokenizerMode = {
22825
23170
  PLAINTEXT: State.PLAINTEXT,
22826
23171
  CDATA_SECTION: State.CDATA_SECTION
22827
23172
  };
22828
- function isAsciiDigit(cp) {
22829
- return cp >= CODE_POINTS.DIGIT_0 && cp <= CODE_POINTS.DIGIT_9;
23173
+ function isAsciiDigit(cp2) {
23174
+ return cp2 >= CODE_POINTS.DIGIT_0 && cp2 <= CODE_POINTS.DIGIT_9;
22830
23175
  }
22831
- function isAsciiUpper(cp) {
22832
- return cp >= CODE_POINTS.LATIN_CAPITAL_A && cp <= CODE_POINTS.LATIN_CAPITAL_Z;
23176
+ function isAsciiUpper(cp2) {
23177
+ return cp2 >= CODE_POINTS.LATIN_CAPITAL_A && cp2 <= CODE_POINTS.LATIN_CAPITAL_Z;
22833
23178
  }
22834
- function isAsciiLower(cp) {
22835
- return cp >= CODE_POINTS.LATIN_SMALL_A && cp <= CODE_POINTS.LATIN_SMALL_Z;
23179
+ function isAsciiLower(cp2) {
23180
+ return cp2 >= CODE_POINTS.LATIN_SMALL_A && cp2 <= CODE_POINTS.LATIN_SMALL_Z;
22836
23181
  }
22837
- function isAsciiLetter(cp) {
22838
- return isAsciiLower(cp) || isAsciiUpper(cp);
23182
+ function isAsciiLetter(cp2) {
23183
+ return isAsciiLower(cp2) || isAsciiUpper(cp2);
22839
23184
  }
22840
- function isAsciiAlphaNumeric2(cp) {
22841
- return isAsciiLetter(cp) || isAsciiDigit(cp);
23185
+ function isAsciiAlphaNumeric2(cp2) {
23186
+ return isAsciiLetter(cp2) || isAsciiDigit(cp2);
22842
23187
  }
22843
- function toAsciiLower(cp) {
22844
- return cp + 32;
23188
+ function toAsciiLower(cp2) {
23189
+ return cp2 + 32;
22845
23190
  }
22846
- function isWhitespace(cp) {
22847
- return cp === CODE_POINTS.SPACE || cp === CODE_POINTS.LINE_FEED || cp === CODE_POINTS.TABULATION || cp === CODE_POINTS.FORM_FEED;
23191
+ function isWhitespace(cp2) {
23192
+ return cp2 === CODE_POINTS.SPACE || cp2 === CODE_POINTS.LINE_FEED || cp2 === CODE_POINTS.TABULATION || cp2 === CODE_POINTS.FORM_FEED;
22848
23193
  }
22849
- function isScriptDataDoubleEscapeSequenceEnd(cp) {
22850
- return isWhitespace(cp) || cp === CODE_POINTS.SOLIDUS || cp === CODE_POINTS.GREATER_THAN_SIGN;
23194
+ function isScriptDataDoubleEscapeSequenceEnd(cp2) {
23195
+ return isWhitespace(cp2) || cp2 === CODE_POINTS.SOLIDUS || cp2 === CODE_POINTS.GREATER_THAN_SIGN;
22851
23196
  }
22852
23197
  function getErrorForNumericCharacterReference(code) {
22853
23198
  if (code === CODE_POINTS.NULL) {
@@ -22881,9 +23226,9 @@ var Tokenizer = class {
22881
23226
  this.currentAttr = { name: "", value: "" };
22882
23227
  this.preprocessor = new Preprocessor(handler);
22883
23228
  this.currentLocation = this.getCurrentLocation(-1);
22884
- this.entityDecoder = new EntityDecoder(htmlDecodeTree, (cp, consumed) => {
23229
+ this.entityDecoder = new EntityDecoder(htmlDecodeTree, (cp2, consumed) => {
22885
23230
  this.preprocessor.pos = this.entityStartPos + consumed - 1;
22886
- this._flushCodePointConsumedAsCharacterReference(cp);
23231
+ this._flushCodePointConsumedAsCharacterReference(cp2);
22887
23232
  }, handler.onParseError ? {
22888
23233
  missingSemicolonAfterCharacterReference: () => {
22889
23234
  this._err(ERR.missingSemicolonAfterCharacterReference, 1);
@@ -22923,9 +23268,9 @@ var Tokenizer = class {
22923
23268
  this.inLoop = true;
22924
23269
  while (this.active && !this.paused) {
22925
23270
  this.consumedAfterSnapshot = 0;
22926
- const cp = this._consume();
23271
+ const cp2 = this._consume();
22927
23272
  if (!this._ensureHibernation()) {
22928
- this._callState(cp);
23273
+ this._callState(cp2);
22929
23274
  }
22930
23275
  }
22931
23276
  this.inLoop = false;
@@ -23160,9 +23505,9 @@ var Tokenizer = class {
23160
23505
  }
23161
23506
  this._createCharacterToken(type, ch);
23162
23507
  }
23163
- _emitCodePoint(cp) {
23164
- const type = isWhitespace(cp) ? TokenType.WHITESPACE_CHARACTER : cp === CODE_POINTS.NULL ? TokenType.NULL_CHARACTER : TokenType.CHARACTER;
23165
- this._appendCharToCurrentCharacterToken(type, cp < 65536 ? String.fromCharCode(cp) : String.fromCodePoint(cp));
23508
+ _emitCodePoint(cp2) {
23509
+ const type = isWhitespace(cp2) ? TokenType.WHITESPACE_CHARACTER : cp2 === CODE_POINTS.NULL ? TokenType.NULL_CHARACTER : TokenType.CHARACTER;
23510
+ this._appendCharToCurrentCharacterToken(type, cp2 < 65536 ? String.fromCharCode(cp2) : String.fromCodePoint(cp2));
23166
23511
  }
23167
23512
  //NOTE: used when we emit characters explicitly.
23168
23513
  //This is always for non-whitespace and non-null characters, which allows us to avoid additional checks.
@@ -23179,298 +23524,298 @@ var Tokenizer = class {
23179
23524
  _isCharacterReferenceInAttribute() {
23180
23525
  return this.returnState === State.ATTRIBUTE_VALUE_DOUBLE_QUOTED || this.returnState === State.ATTRIBUTE_VALUE_SINGLE_QUOTED || this.returnState === State.ATTRIBUTE_VALUE_UNQUOTED;
23181
23526
  }
23182
- _flushCodePointConsumedAsCharacterReference(cp) {
23527
+ _flushCodePointConsumedAsCharacterReference(cp2) {
23183
23528
  if (this._isCharacterReferenceInAttribute()) {
23184
- this.currentAttr.value += String.fromCodePoint(cp);
23529
+ this.currentAttr.value += String.fromCodePoint(cp2);
23185
23530
  } else {
23186
- this._emitCodePoint(cp);
23531
+ this._emitCodePoint(cp2);
23187
23532
  }
23188
23533
  }
23189
23534
  // Calling states this way turns out to be much faster than any other approach.
23190
- _callState(cp) {
23535
+ _callState(cp2) {
23191
23536
  switch (this.state) {
23192
23537
  case State.DATA: {
23193
- this._stateData(cp);
23538
+ this._stateData(cp2);
23194
23539
  break;
23195
23540
  }
23196
23541
  case State.RCDATA: {
23197
- this._stateRcdata(cp);
23542
+ this._stateRcdata(cp2);
23198
23543
  break;
23199
23544
  }
23200
23545
  case State.RAWTEXT: {
23201
- this._stateRawtext(cp);
23546
+ this._stateRawtext(cp2);
23202
23547
  break;
23203
23548
  }
23204
23549
  case State.SCRIPT_DATA: {
23205
- this._stateScriptData(cp);
23550
+ this._stateScriptData(cp2);
23206
23551
  break;
23207
23552
  }
23208
23553
  case State.PLAINTEXT: {
23209
- this._statePlaintext(cp);
23554
+ this._statePlaintext(cp2);
23210
23555
  break;
23211
23556
  }
23212
23557
  case State.TAG_OPEN: {
23213
- this._stateTagOpen(cp);
23558
+ this._stateTagOpen(cp2);
23214
23559
  break;
23215
23560
  }
23216
23561
  case State.END_TAG_OPEN: {
23217
- this._stateEndTagOpen(cp);
23562
+ this._stateEndTagOpen(cp2);
23218
23563
  break;
23219
23564
  }
23220
23565
  case State.TAG_NAME: {
23221
- this._stateTagName(cp);
23566
+ this._stateTagName(cp2);
23222
23567
  break;
23223
23568
  }
23224
23569
  case State.RCDATA_LESS_THAN_SIGN: {
23225
- this._stateRcdataLessThanSign(cp);
23570
+ this._stateRcdataLessThanSign(cp2);
23226
23571
  break;
23227
23572
  }
23228
23573
  case State.RCDATA_END_TAG_OPEN: {
23229
- this._stateRcdataEndTagOpen(cp);
23574
+ this._stateRcdataEndTagOpen(cp2);
23230
23575
  break;
23231
23576
  }
23232
23577
  case State.RCDATA_END_TAG_NAME: {
23233
- this._stateRcdataEndTagName(cp);
23578
+ this._stateRcdataEndTagName(cp2);
23234
23579
  break;
23235
23580
  }
23236
23581
  case State.RAWTEXT_LESS_THAN_SIGN: {
23237
- this._stateRawtextLessThanSign(cp);
23582
+ this._stateRawtextLessThanSign(cp2);
23238
23583
  break;
23239
23584
  }
23240
23585
  case State.RAWTEXT_END_TAG_OPEN: {
23241
- this._stateRawtextEndTagOpen(cp);
23586
+ this._stateRawtextEndTagOpen(cp2);
23242
23587
  break;
23243
23588
  }
23244
23589
  case State.RAWTEXT_END_TAG_NAME: {
23245
- this._stateRawtextEndTagName(cp);
23590
+ this._stateRawtextEndTagName(cp2);
23246
23591
  break;
23247
23592
  }
23248
23593
  case State.SCRIPT_DATA_LESS_THAN_SIGN: {
23249
- this._stateScriptDataLessThanSign(cp);
23594
+ this._stateScriptDataLessThanSign(cp2);
23250
23595
  break;
23251
23596
  }
23252
23597
  case State.SCRIPT_DATA_END_TAG_OPEN: {
23253
- this._stateScriptDataEndTagOpen(cp);
23598
+ this._stateScriptDataEndTagOpen(cp2);
23254
23599
  break;
23255
23600
  }
23256
23601
  case State.SCRIPT_DATA_END_TAG_NAME: {
23257
- this._stateScriptDataEndTagName(cp);
23602
+ this._stateScriptDataEndTagName(cp2);
23258
23603
  break;
23259
23604
  }
23260
23605
  case State.SCRIPT_DATA_ESCAPE_START: {
23261
- this._stateScriptDataEscapeStart(cp);
23606
+ this._stateScriptDataEscapeStart(cp2);
23262
23607
  break;
23263
23608
  }
23264
23609
  case State.SCRIPT_DATA_ESCAPE_START_DASH: {
23265
- this._stateScriptDataEscapeStartDash(cp);
23610
+ this._stateScriptDataEscapeStartDash(cp2);
23266
23611
  break;
23267
23612
  }
23268
23613
  case State.SCRIPT_DATA_ESCAPED: {
23269
- this._stateScriptDataEscaped(cp);
23614
+ this._stateScriptDataEscaped(cp2);
23270
23615
  break;
23271
23616
  }
23272
23617
  case State.SCRIPT_DATA_ESCAPED_DASH: {
23273
- this._stateScriptDataEscapedDash(cp);
23618
+ this._stateScriptDataEscapedDash(cp2);
23274
23619
  break;
23275
23620
  }
23276
23621
  case State.SCRIPT_DATA_ESCAPED_DASH_DASH: {
23277
- this._stateScriptDataEscapedDashDash(cp);
23622
+ this._stateScriptDataEscapedDashDash(cp2);
23278
23623
  break;
23279
23624
  }
23280
23625
  case State.SCRIPT_DATA_ESCAPED_LESS_THAN_SIGN: {
23281
- this._stateScriptDataEscapedLessThanSign(cp);
23626
+ this._stateScriptDataEscapedLessThanSign(cp2);
23282
23627
  break;
23283
23628
  }
23284
23629
  case State.SCRIPT_DATA_ESCAPED_END_TAG_OPEN: {
23285
- this._stateScriptDataEscapedEndTagOpen(cp);
23630
+ this._stateScriptDataEscapedEndTagOpen(cp2);
23286
23631
  break;
23287
23632
  }
23288
23633
  case State.SCRIPT_DATA_ESCAPED_END_TAG_NAME: {
23289
- this._stateScriptDataEscapedEndTagName(cp);
23634
+ this._stateScriptDataEscapedEndTagName(cp2);
23290
23635
  break;
23291
23636
  }
23292
23637
  case State.SCRIPT_DATA_DOUBLE_ESCAPE_START: {
23293
- this._stateScriptDataDoubleEscapeStart(cp);
23638
+ this._stateScriptDataDoubleEscapeStart(cp2);
23294
23639
  break;
23295
23640
  }
23296
23641
  case State.SCRIPT_DATA_DOUBLE_ESCAPED: {
23297
- this._stateScriptDataDoubleEscaped(cp);
23642
+ this._stateScriptDataDoubleEscaped(cp2);
23298
23643
  break;
23299
23644
  }
23300
23645
  case State.SCRIPT_DATA_DOUBLE_ESCAPED_DASH: {
23301
- this._stateScriptDataDoubleEscapedDash(cp);
23646
+ this._stateScriptDataDoubleEscapedDash(cp2);
23302
23647
  break;
23303
23648
  }
23304
23649
  case State.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH: {
23305
- this._stateScriptDataDoubleEscapedDashDash(cp);
23650
+ this._stateScriptDataDoubleEscapedDashDash(cp2);
23306
23651
  break;
23307
23652
  }
23308
23653
  case State.SCRIPT_DATA_DOUBLE_ESCAPED_LESS_THAN_SIGN: {
23309
- this._stateScriptDataDoubleEscapedLessThanSign(cp);
23654
+ this._stateScriptDataDoubleEscapedLessThanSign(cp2);
23310
23655
  break;
23311
23656
  }
23312
23657
  case State.SCRIPT_DATA_DOUBLE_ESCAPE_END: {
23313
- this._stateScriptDataDoubleEscapeEnd(cp);
23658
+ this._stateScriptDataDoubleEscapeEnd(cp2);
23314
23659
  break;
23315
23660
  }
23316
23661
  case State.BEFORE_ATTRIBUTE_NAME: {
23317
- this._stateBeforeAttributeName(cp);
23662
+ this._stateBeforeAttributeName(cp2);
23318
23663
  break;
23319
23664
  }
23320
23665
  case State.ATTRIBUTE_NAME: {
23321
- this._stateAttributeName(cp);
23666
+ this._stateAttributeName(cp2);
23322
23667
  break;
23323
23668
  }
23324
23669
  case State.AFTER_ATTRIBUTE_NAME: {
23325
- this._stateAfterAttributeName(cp);
23670
+ this._stateAfterAttributeName(cp2);
23326
23671
  break;
23327
23672
  }
23328
23673
  case State.BEFORE_ATTRIBUTE_VALUE: {
23329
- this._stateBeforeAttributeValue(cp);
23674
+ this._stateBeforeAttributeValue(cp2);
23330
23675
  break;
23331
23676
  }
23332
23677
  case State.ATTRIBUTE_VALUE_DOUBLE_QUOTED: {
23333
- this._stateAttributeValueDoubleQuoted(cp);
23678
+ this._stateAttributeValueDoubleQuoted(cp2);
23334
23679
  break;
23335
23680
  }
23336
23681
  case State.ATTRIBUTE_VALUE_SINGLE_QUOTED: {
23337
- this._stateAttributeValueSingleQuoted(cp);
23682
+ this._stateAttributeValueSingleQuoted(cp2);
23338
23683
  break;
23339
23684
  }
23340
23685
  case State.ATTRIBUTE_VALUE_UNQUOTED: {
23341
- this._stateAttributeValueUnquoted(cp);
23686
+ this._stateAttributeValueUnquoted(cp2);
23342
23687
  break;
23343
23688
  }
23344
23689
  case State.AFTER_ATTRIBUTE_VALUE_QUOTED: {
23345
- this._stateAfterAttributeValueQuoted(cp);
23690
+ this._stateAfterAttributeValueQuoted(cp2);
23346
23691
  break;
23347
23692
  }
23348
23693
  case State.SELF_CLOSING_START_TAG: {
23349
- this._stateSelfClosingStartTag(cp);
23694
+ this._stateSelfClosingStartTag(cp2);
23350
23695
  break;
23351
23696
  }
23352
23697
  case State.BOGUS_COMMENT: {
23353
- this._stateBogusComment(cp);
23698
+ this._stateBogusComment(cp2);
23354
23699
  break;
23355
23700
  }
23356
23701
  case State.MARKUP_DECLARATION_OPEN: {
23357
- this._stateMarkupDeclarationOpen(cp);
23702
+ this._stateMarkupDeclarationOpen(cp2);
23358
23703
  break;
23359
23704
  }
23360
23705
  case State.COMMENT_START: {
23361
- this._stateCommentStart(cp);
23706
+ this._stateCommentStart(cp2);
23362
23707
  break;
23363
23708
  }
23364
23709
  case State.COMMENT_START_DASH: {
23365
- this._stateCommentStartDash(cp);
23710
+ this._stateCommentStartDash(cp2);
23366
23711
  break;
23367
23712
  }
23368
23713
  case State.COMMENT: {
23369
- this._stateComment(cp);
23714
+ this._stateComment(cp2);
23370
23715
  break;
23371
23716
  }
23372
23717
  case State.COMMENT_LESS_THAN_SIGN: {
23373
- this._stateCommentLessThanSign(cp);
23718
+ this._stateCommentLessThanSign(cp2);
23374
23719
  break;
23375
23720
  }
23376
23721
  case State.COMMENT_LESS_THAN_SIGN_BANG: {
23377
- this._stateCommentLessThanSignBang(cp);
23722
+ this._stateCommentLessThanSignBang(cp2);
23378
23723
  break;
23379
23724
  }
23380
23725
  case State.COMMENT_LESS_THAN_SIGN_BANG_DASH: {
23381
- this._stateCommentLessThanSignBangDash(cp);
23726
+ this._stateCommentLessThanSignBangDash(cp2);
23382
23727
  break;
23383
23728
  }
23384
23729
  case State.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH: {
23385
- this._stateCommentLessThanSignBangDashDash(cp);
23730
+ this._stateCommentLessThanSignBangDashDash(cp2);
23386
23731
  break;
23387
23732
  }
23388
23733
  case State.COMMENT_END_DASH: {
23389
- this._stateCommentEndDash(cp);
23734
+ this._stateCommentEndDash(cp2);
23390
23735
  break;
23391
23736
  }
23392
23737
  case State.COMMENT_END: {
23393
- this._stateCommentEnd(cp);
23738
+ this._stateCommentEnd(cp2);
23394
23739
  break;
23395
23740
  }
23396
23741
  case State.COMMENT_END_BANG: {
23397
- this._stateCommentEndBang(cp);
23742
+ this._stateCommentEndBang(cp2);
23398
23743
  break;
23399
23744
  }
23400
23745
  case State.DOCTYPE: {
23401
- this._stateDoctype(cp);
23746
+ this._stateDoctype(cp2);
23402
23747
  break;
23403
23748
  }
23404
23749
  case State.BEFORE_DOCTYPE_NAME: {
23405
- this._stateBeforeDoctypeName(cp);
23750
+ this._stateBeforeDoctypeName(cp2);
23406
23751
  break;
23407
23752
  }
23408
23753
  case State.DOCTYPE_NAME: {
23409
- this._stateDoctypeName(cp);
23754
+ this._stateDoctypeName(cp2);
23410
23755
  break;
23411
23756
  }
23412
23757
  case State.AFTER_DOCTYPE_NAME: {
23413
- this._stateAfterDoctypeName(cp);
23758
+ this._stateAfterDoctypeName(cp2);
23414
23759
  break;
23415
23760
  }
23416
23761
  case State.AFTER_DOCTYPE_PUBLIC_KEYWORD: {
23417
- this._stateAfterDoctypePublicKeyword(cp);
23762
+ this._stateAfterDoctypePublicKeyword(cp2);
23418
23763
  break;
23419
23764
  }
23420
23765
  case State.BEFORE_DOCTYPE_PUBLIC_IDENTIFIER: {
23421
- this._stateBeforeDoctypePublicIdentifier(cp);
23766
+ this._stateBeforeDoctypePublicIdentifier(cp2);
23422
23767
  break;
23423
23768
  }
23424
23769
  case State.DOCTYPE_PUBLIC_IDENTIFIER_DOUBLE_QUOTED: {
23425
- this._stateDoctypePublicIdentifierDoubleQuoted(cp);
23770
+ this._stateDoctypePublicIdentifierDoubleQuoted(cp2);
23426
23771
  break;
23427
23772
  }
23428
23773
  case State.DOCTYPE_PUBLIC_IDENTIFIER_SINGLE_QUOTED: {
23429
- this._stateDoctypePublicIdentifierSingleQuoted(cp);
23774
+ this._stateDoctypePublicIdentifierSingleQuoted(cp2);
23430
23775
  break;
23431
23776
  }
23432
23777
  case State.AFTER_DOCTYPE_PUBLIC_IDENTIFIER: {
23433
- this._stateAfterDoctypePublicIdentifier(cp);
23778
+ this._stateAfterDoctypePublicIdentifier(cp2);
23434
23779
  break;
23435
23780
  }
23436
23781
  case State.BETWEEN_DOCTYPE_PUBLIC_AND_SYSTEM_IDENTIFIERS: {
23437
- this._stateBetweenDoctypePublicAndSystemIdentifiers(cp);
23782
+ this._stateBetweenDoctypePublicAndSystemIdentifiers(cp2);
23438
23783
  break;
23439
23784
  }
23440
23785
  case State.AFTER_DOCTYPE_SYSTEM_KEYWORD: {
23441
- this._stateAfterDoctypeSystemKeyword(cp);
23786
+ this._stateAfterDoctypeSystemKeyword(cp2);
23442
23787
  break;
23443
23788
  }
23444
23789
  case State.BEFORE_DOCTYPE_SYSTEM_IDENTIFIER: {
23445
- this._stateBeforeDoctypeSystemIdentifier(cp);
23790
+ this._stateBeforeDoctypeSystemIdentifier(cp2);
23446
23791
  break;
23447
23792
  }
23448
23793
  case State.DOCTYPE_SYSTEM_IDENTIFIER_DOUBLE_QUOTED: {
23449
- this._stateDoctypeSystemIdentifierDoubleQuoted(cp);
23794
+ this._stateDoctypeSystemIdentifierDoubleQuoted(cp2);
23450
23795
  break;
23451
23796
  }
23452
23797
  case State.DOCTYPE_SYSTEM_IDENTIFIER_SINGLE_QUOTED: {
23453
- this._stateDoctypeSystemIdentifierSingleQuoted(cp);
23798
+ this._stateDoctypeSystemIdentifierSingleQuoted(cp2);
23454
23799
  break;
23455
23800
  }
23456
23801
  case State.AFTER_DOCTYPE_SYSTEM_IDENTIFIER: {
23457
- this._stateAfterDoctypeSystemIdentifier(cp);
23802
+ this._stateAfterDoctypeSystemIdentifier(cp2);
23458
23803
  break;
23459
23804
  }
23460
23805
  case State.BOGUS_DOCTYPE: {
23461
- this._stateBogusDoctype(cp);
23806
+ this._stateBogusDoctype(cp2);
23462
23807
  break;
23463
23808
  }
23464
23809
  case State.CDATA_SECTION: {
23465
- this._stateCdataSection(cp);
23810
+ this._stateCdataSection(cp2);
23466
23811
  break;
23467
23812
  }
23468
23813
  case State.CDATA_SECTION_BRACKET: {
23469
- this._stateCdataSectionBracket(cp);
23814
+ this._stateCdataSectionBracket(cp2);
23470
23815
  break;
23471
23816
  }
23472
23817
  case State.CDATA_SECTION_END: {
23473
- this._stateCdataSectionEnd(cp);
23818
+ this._stateCdataSectionEnd(cp2);
23474
23819
  break;
23475
23820
  }
23476
23821
  case State.CHARACTER_REFERENCE: {
@@ -23478,7 +23823,7 @@ var Tokenizer = class {
23478
23823
  break;
23479
23824
  }
23480
23825
  case State.AMBIGUOUS_AMPERSAND: {
23481
- this._stateAmbiguousAmpersand(cp);
23826
+ this._stateAmbiguousAmpersand(cp2);
23482
23827
  break;
23483
23828
  }
23484
23829
  default: {
@@ -23489,8 +23834,8 @@ var Tokenizer = class {
23489
23834
  // State machine
23490
23835
  // Data state
23491
23836
  //------------------------------------------------------------------
23492
- _stateData(cp) {
23493
- switch (cp) {
23837
+ _stateData(cp2) {
23838
+ switch (cp2) {
23494
23839
  case CODE_POINTS.LESS_THAN_SIGN: {
23495
23840
  this.state = State.TAG_OPEN;
23496
23841
  break;
@@ -23501,7 +23846,7 @@ var Tokenizer = class {
23501
23846
  }
23502
23847
  case CODE_POINTS.NULL: {
23503
23848
  this._err(ERR.unexpectedNullCharacter);
23504
- this._emitCodePoint(cp);
23849
+ this._emitCodePoint(cp2);
23505
23850
  break;
23506
23851
  }
23507
23852
  case CODE_POINTS.EOF: {
@@ -23509,14 +23854,14 @@ var Tokenizer = class {
23509
23854
  break;
23510
23855
  }
23511
23856
  default: {
23512
- this._emitCodePoint(cp);
23857
+ this._emitCodePoint(cp2);
23513
23858
  }
23514
23859
  }
23515
23860
  }
23516
23861
  // RCDATA state
23517
23862
  //------------------------------------------------------------------
23518
- _stateRcdata(cp) {
23519
- switch (cp) {
23863
+ _stateRcdata(cp2) {
23864
+ switch (cp2) {
23520
23865
  case CODE_POINTS.AMPERSAND: {
23521
23866
  this._startCharacterReference();
23522
23867
  break;
@@ -23535,14 +23880,14 @@ var Tokenizer = class {
23535
23880
  break;
23536
23881
  }
23537
23882
  default: {
23538
- this._emitCodePoint(cp);
23883
+ this._emitCodePoint(cp2);
23539
23884
  }
23540
23885
  }
23541
23886
  }
23542
23887
  // RAWTEXT state
23543
23888
  //------------------------------------------------------------------
23544
- _stateRawtext(cp) {
23545
- switch (cp) {
23889
+ _stateRawtext(cp2) {
23890
+ switch (cp2) {
23546
23891
  case CODE_POINTS.LESS_THAN_SIGN: {
23547
23892
  this.state = State.RAWTEXT_LESS_THAN_SIGN;
23548
23893
  break;
@@ -23557,14 +23902,14 @@ var Tokenizer = class {
23557
23902
  break;
23558
23903
  }
23559
23904
  default: {
23560
- this._emitCodePoint(cp);
23905
+ this._emitCodePoint(cp2);
23561
23906
  }
23562
23907
  }
23563
23908
  }
23564
23909
  // Script data state
23565
23910
  //------------------------------------------------------------------
23566
- _stateScriptData(cp) {
23567
- switch (cp) {
23911
+ _stateScriptData(cp2) {
23912
+ switch (cp2) {
23568
23913
  case CODE_POINTS.LESS_THAN_SIGN: {
23569
23914
  this.state = State.SCRIPT_DATA_LESS_THAN_SIGN;
23570
23915
  break;
@@ -23579,14 +23924,14 @@ var Tokenizer = class {
23579
23924
  break;
23580
23925
  }
23581
23926
  default: {
23582
- this._emitCodePoint(cp);
23927
+ this._emitCodePoint(cp2);
23583
23928
  }
23584
23929
  }
23585
23930
  }
23586
23931
  // PLAINTEXT state
23587
23932
  //------------------------------------------------------------------
23588
- _statePlaintext(cp) {
23589
- switch (cp) {
23933
+ _statePlaintext(cp2) {
23934
+ switch (cp2) {
23590
23935
  case CODE_POINTS.NULL: {
23591
23936
  this._err(ERR.unexpectedNullCharacter);
23592
23937
  this._emitChars(REPLACEMENT_CHARACTER);
@@ -23597,19 +23942,19 @@ var Tokenizer = class {
23597
23942
  break;
23598
23943
  }
23599
23944
  default: {
23600
- this._emitCodePoint(cp);
23945
+ this._emitCodePoint(cp2);
23601
23946
  }
23602
23947
  }
23603
23948
  }
23604
23949
  // Tag open state
23605
23950
  //------------------------------------------------------------------
23606
- _stateTagOpen(cp) {
23607
- if (isAsciiLetter(cp)) {
23951
+ _stateTagOpen(cp2) {
23952
+ if (isAsciiLetter(cp2)) {
23608
23953
  this._createStartTagToken();
23609
23954
  this.state = State.TAG_NAME;
23610
- this._stateTagName(cp);
23955
+ this._stateTagName(cp2);
23611
23956
  } else
23612
- switch (cp) {
23957
+ switch (cp2) {
23613
23958
  case CODE_POINTS.EXCLAMATION_MARK: {
23614
23959
  this.state = State.MARKUP_DECLARATION_OPEN;
23615
23960
  break;
@@ -23622,7 +23967,7 @@ var Tokenizer = class {
23622
23967
  this._err(ERR.unexpectedQuestionMarkInsteadOfTagName);
23623
23968
  this._createCommentToken(1);
23624
23969
  this.state = State.BOGUS_COMMENT;
23625
- this._stateBogusComment(cp);
23970
+ this._stateBogusComment(cp2);
23626
23971
  break;
23627
23972
  }
23628
23973
  case CODE_POINTS.EOF: {
@@ -23635,19 +23980,19 @@ var Tokenizer = class {
23635
23980
  this._err(ERR.invalidFirstCharacterOfTagName);
23636
23981
  this._emitChars("<");
23637
23982
  this.state = State.DATA;
23638
- this._stateData(cp);
23983
+ this._stateData(cp2);
23639
23984
  }
23640
23985
  }
23641
23986
  }
23642
23987
  // End tag open state
23643
23988
  //------------------------------------------------------------------
23644
- _stateEndTagOpen(cp) {
23645
- if (isAsciiLetter(cp)) {
23989
+ _stateEndTagOpen(cp2) {
23990
+ if (isAsciiLetter(cp2)) {
23646
23991
  this._createEndTagToken();
23647
23992
  this.state = State.TAG_NAME;
23648
- this._stateTagName(cp);
23993
+ this._stateTagName(cp2);
23649
23994
  } else
23650
- switch (cp) {
23995
+ switch (cp2) {
23651
23996
  case CODE_POINTS.GREATER_THAN_SIGN: {
23652
23997
  this._err(ERR.missingEndTagName);
23653
23998
  this.state = State.DATA;
@@ -23663,15 +24008,15 @@ var Tokenizer = class {
23663
24008
  this._err(ERR.invalidFirstCharacterOfTagName);
23664
24009
  this._createCommentToken(2);
23665
24010
  this.state = State.BOGUS_COMMENT;
23666
- this._stateBogusComment(cp);
24011
+ this._stateBogusComment(cp2);
23667
24012
  }
23668
24013
  }
23669
24014
  }
23670
24015
  // Tag name state
23671
24016
  //------------------------------------------------------------------
23672
- _stateTagName(cp) {
24017
+ _stateTagName(cp2) {
23673
24018
  const token = this.currentToken;
23674
- switch (cp) {
24019
+ switch (cp2) {
23675
24020
  case CODE_POINTS.SPACE:
23676
24021
  case CODE_POINTS.LINE_FEED:
23677
24022
  case CODE_POINTS.TABULATION:
@@ -23699,31 +24044,31 @@ var Tokenizer = class {
23699
24044
  break;
23700
24045
  }
23701
24046
  default: {
23702
- token.tagName += String.fromCodePoint(isAsciiUpper(cp) ? toAsciiLower(cp) : cp);
24047
+ token.tagName += String.fromCodePoint(isAsciiUpper(cp2) ? toAsciiLower(cp2) : cp2);
23703
24048
  }
23704
24049
  }
23705
24050
  }
23706
24051
  // RCDATA less-than sign state
23707
24052
  //------------------------------------------------------------------
23708
- _stateRcdataLessThanSign(cp) {
23709
- if (cp === CODE_POINTS.SOLIDUS) {
24053
+ _stateRcdataLessThanSign(cp2) {
24054
+ if (cp2 === CODE_POINTS.SOLIDUS) {
23710
24055
  this.state = State.RCDATA_END_TAG_OPEN;
23711
24056
  } else {
23712
24057
  this._emitChars("<");
23713
24058
  this.state = State.RCDATA;
23714
- this._stateRcdata(cp);
24059
+ this._stateRcdata(cp2);
23715
24060
  }
23716
24061
  }
23717
24062
  // RCDATA end tag open state
23718
24063
  //------------------------------------------------------------------
23719
- _stateRcdataEndTagOpen(cp) {
23720
- if (isAsciiLetter(cp)) {
24064
+ _stateRcdataEndTagOpen(cp2) {
24065
+ if (isAsciiLetter(cp2)) {
23721
24066
  this.state = State.RCDATA_END_TAG_NAME;
23722
- this._stateRcdataEndTagName(cp);
24067
+ this._stateRcdataEndTagName(cp2);
23723
24068
  } else {
23724
24069
  this._emitChars("</");
23725
24070
  this.state = State.RCDATA;
23726
- this._stateRcdata(cp);
24071
+ this._stateRcdata(cp2);
23727
24072
  }
23728
24073
  }
23729
24074
  handleSpecialEndTag(_cp) {
@@ -23733,8 +24078,8 @@ var Tokenizer = class {
23733
24078
  this._createEndTagToken();
23734
24079
  const token = this.currentToken;
23735
24080
  token.tagName = this.lastStartTagName;
23736
- const cp = this.preprocessor.peek(this.lastStartTagName.length);
23737
- switch (cp) {
24081
+ const cp2 = this.preprocessor.peek(this.lastStartTagName.length);
24082
+ switch (cp2) {
23738
24083
  case CODE_POINTS.SPACE:
23739
24084
  case CODE_POINTS.LINE_FEED:
23740
24085
  case CODE_POINTS.TABULATION:
@@ -23761,49 +24106,49 @@ var Tokenizer = class {
23761
24106
  }
23762
24107
  // RCDATA end tag name state
23763
24108
  //------------------------------------------------------------------
23764
- _stateRcdataEndTagName(cp) {
23765
- if (this.handleSpecialEndTag(cp)) {
24109
+ _stateRcdataEndTagName(cp2) {
24110
+ if (this.handleSpecialEndTag(cp2)) {
23766
24111
  this._emitChars("</");
23767
24112
  this.state = State.RCDATA;
23768
- this._stateRcdata(cp);
24113
+ this._stateRcdata(cp2);
23769
24114
  }
23770
24115
  }
23771
24116
  // RAWTEXT less-than sign state
23772
24117
  //------------------------------------------------------------------
23773
- _stateRawtextLessThanSign(cp) {
23774
- if (cp === CODE_POINTS.SOLIDUS) {
24118
+ _stateRawtextLessThanSign(cp2) {
24119
+ if (cp2 === CODE_POINTS.SOLIDUS) {
23775
24120
  this.state = State.RAWTEXT_END_TAG_OPEN;
23776
24121
  } else {
23777
24122
  this._emitChars("<");
23778
24123
  this.state = State.RAWTEXT;
23779
- this._stateRawtext(cp);
24124
+ this._stateRawtext(cp2);
23780
24125
  }
23781
24126
  }
23782
24127
  // RAWTEXT end tag open state
23783
24128
  //------------------------------------------------------------------
23784
- _stateRawtextEndTagOpen(cp) {
23785
- if (isAsciiLetter(cp)) {
24129
+ _stateRawtextEndTagOpen(cp2) {
24130
+ if (isAsciiLetter(cp2)) {
23786
24131
  this.state = State.RAWTEXT_END_TAG_NAME;
23787
- this._stateRawtextEndTagName(cp);
24132
+ this._stateRawtextEndTagName(cp2);
23788
24133
  } else {
23789
24134
  this._emitChars("</");
23790
24135
  this.state = State.RAWTEXT;
23791
- this._stateRawtext(cp);
24136
+ this._stateRawtext(cp2);
23792
24137
  }
23793
24138
  }
23794
24139
  // RAWTEXT end tag name state
23795
24140
  //------------------------------------------------------------------
23796
- _stateRawtextEndTagName(cp) {
23797
- if (this.handleSpecialEndTag(cp)) {
24141
+ _stateRawtextEndTagName(cp2) {
24142
+ if (this.handleSpecialEndTag(cp2)) {
23798
24143
  this._emitChars("</");
23799
24144
  this.state = State.RAWTEXT;
23800
- this._stateRawtext(cp);
24145
+ this._stateRawtext(cp2);
23801
24146
  }
23802
24147
  }
23803
24148
  // Script data less-than sign state
23804
24149
  //------------------------------------------------------------------
23805
- _stateScriptDataLessThanSign(cp) {
23806
- switch (cp) {
24150
+ _stateScriptDataLessThanSign(cp2) {
24151
+ switch (cp2) {
23807
24152
  case CODE_POINTS.SOLIDUS: {
23808
24153
  this.state = State.SCRIPT_DATA_END_TAG_OPEN;
23809
24154
  break;
@@ -23816,57 +24161,57 @@ var Tokenizer = class {
23816
24161
  default: {
23817
24162
  this._emitChars("<");
23818
24163
  this.state = State.SCRIPT_DATA;
23819
- this._stateScriptData(cp);
24164
+ this._stateScriptData(cp2);
23820
24165
  }
23821
24166
  }
23822
24167
  }
23823
24168
  // Script data end tag open state
23824
24169
  //------------------------------------------------------------------
23825
- _stateScriptDataEndTagOpen(cp) {
23826
- if (isAsciiLetter(cp)) {
24170
+ _stateScriptDataEndTagOpen(cp2) {
24171
+ if (isAsciiLetter(cp2)) {
23827
24172
  this.state = State.SCRIPT_DATA_END_TAG_NAME;
23828
- this._stateScriptDataEndTagName(cp);
24173
+ this._stateScriptDataEndTagName(cp2);
23829
24174
  } else {
23830
24175
  this._emitChars("</");
23831
24176
  this.state = State.SCRIPT_DATA;
23832
- this._stateScriptData(cp);
24177
+ this._stateScriptData(cp2);
23833
24178
  }
23834
24179
  }
23835
24180
  // Script data end tag name state
23836
24181
  //------------------------------------------------------------------
23837
- _stateScriptDataEndTagName(cp) {
23838
- if (this.handleSpecialEndTag(cp)) {
24182
+ _stateScriptDataEndTagName(cp2) {
24183
+ if (this.handleSpecialEndTag(cp2)) {
23839
24184
  this._emitChars("</");
23840
24185
  this.state = State.SCRIPT_DATA;
23841
- this._stateScriptData(cp);
24186
+ this._stateScriptData(cp2);
23842
24187
  }
23843
24188
  }
23844
24189
  // Script data escape start state
23845
24190
  //------------------------------------------------------------------
23846
- _stateScriptDataEscapeStart(cp) {
23847
- if (cp === CODE_POINTS.HYPHEN_MINUS) {
24191
+ _stateScriptDataEscapeStart(cp2) {
24192
+ if (cp2 === CODE_POINTS.HYPHEN_MINUS) {
23848
24193
  this.state = State.SCRIPT_DATA_ESCAPE_START_DASH;
23849
24194
  this._emitChars("-");
23850
24195
  } else {
23851
24196
  this.state = State.SCRIPT_DATA;
23852
- this._stateScriptData(cp);
24197
+ this._stateScriptData(cp2);
23853
24198
  }
23854
24199
  }
23855
24200
  // Script data escape start dash state
23856
24201
  //------------------------------------------------------------------
23857
- _stateScriptDataEscapeStartDash(cp) {
23858
- if (cp === CODE_POINTS.HYPHEN_MINUS) {
24202
+ _stateScriptDataEscapeStartDash(cp2) {
24203
+ if (cp2 === CODE_POINTS.HYPHEN_MINUS) {
23859
24204
  this.state = State.SCRIPT_DATA_ESCAPED_DASH_DASH;
23860
24205
  this._emitChars("-");
23861
24206
  } else {
23862
24207
  this.state = State.SCRIPT_DATA;
23863
- this._stateScriptData(cp);
24208
+ this._stateScriptData(cp2);
23864
24209
  }
23865
24210
  }
23866
24211
  // Script data escaped state
23867
24212
  //------------------------------------------------------------------
23868
- _stateScriptDataEscaped(cp) {
23869
- switch (cp) {
24213
+ _stateScriptDataEscaped(cp2) {
24214
+ switch (cp2) {
23870
24215
  case CODE_POINTS.HYPHEN_MINUS: {
23871
24216
  this.state = State.SCRIPT_DATA_ESCAPED_DASH;
23872
24217
  this._emitChars("-");
@@ -23887,14 +24232,14 @@ var Tokenizer = class {
23887
24232
  break;
23888
24233
  }
23889
24234
  default: {
23890
- this._emitCodePoint(cp);
24235
+ this._emitCodePoint(cp2);
23891
24236
  }
23892
24237
  }
23893
24238
  }
23894
24239
  // Script data escaped dash state
23895
24240
  //------------------------------------------------------------------
23896
- _stateScriptDataEscapedDash(cp) {
23897
- switch (cp) {
24241
+ _stateScriptDataEscapedDash(cp2) {
24242
+ switch (cp2) {
23898
24243
  case CODE_POINTS.HYPHEN_MINUS: {
23899
24244
  this.state = State.SCRIPT_DATA_ESCAPED_DASH_DASH;
23900
24245
  this._emitChars("-");
@@ -23917,14 +24262,14 @@ var Tokenizer = class {
23917
24262
  }
23918
24263
  default: {
23919
24264
  this.state = State.SCRIPT_DATA_ESCAPED;
23920
- this._emitCodePoint(cp);
24265
+ this._emitCodePoint(cp2);
23921
24266
  }
23922
24267
  }
23923
24268
  }
23924
24269
  // Script data escaped dash dash state
23925
24270
  //------------------------------------------------------------------
23926
- _stateScriptDataEscapedDashDash(cp) {
23927
- switch (cp) {
24271
+ _stateScriptDataEscapedDashDash(cp2) {
24272
+ switch (cp2) {
23928
24273
  case CODE_POINTS.HYPHEN_MINUS: {
23929
24274
  this._emitChars("-");
23930
24275
  break;
@@ -23951,64 +24296,64 @@ var Tokenizer = class {
23951
24296
  }
23952
24297
  default: {
23953
24298
  this.state = State.SCRIPT_DATA_ESCAPED;
23954
- this._emitCodePoint(cp);
24299
+ this._emitCodePoint(cp2);
23955
24300
  }
23956
24301
  }
23957
24302
  }
23958
24303
  // Script data escaped less-than sign state
23959
24304
  //------------------------------------------------------------------
23960
- _stateScriptDataEscapedLessThanSign(cp) {
23961
- if (cp === CODE_POINTS.SOLIDUS) {
24305
+ _stateScriptDataEscapedLessThanSign(cp2) {
24306
+ if (cp2 === CODE_POINTS.SOLIDUS) {
23962
24307
  this.state = State.SCRIPT_DATA_ESCAPED_END_TAG_OPEN;
23963
- } else if (isAsciiLetter(cp)) {
24308
+ } else if (isAsciiLetter(cp2)) {
23964
24309
  this._emitChars("<");
23965
24310
  this.state = State.SCRIPT_DATA_DOUBLE_ESCAPE_START;
23966
- this._stateScriptDataDoubleEscapeStart(cp);
24311
+ this._stateScriptDataDoubleEscapeStart(cp2);
23967
24312
  } else {
23968
24313
  this._emitChars("<");
23969
24314
  this.state = State.SCRIPT_DATA_ESCAPED;
23970
- this._stateScriptDataEscaped(cp);
24315
+ this._stateScriptDataEscaped(cp2);
23971
24316
  }
23972
24317
  }
23973
24318
  // Script data escaped end tag open state
23974
24319
  //------------------------------------------------------------------
23975
- _stateScriptDataEscapedEndTagOpen(cp) {
23976
- if (isAsciiLetter(cp)) {
24320
+ _stateScriptDataEscapedEndTagOpen(cp2) {
24321
+ if (isAsciiLetter(cp2)) {
23977
24322
  this.state = State.SCRIPT_DATA_ESCAPED_END_TAG_NAME;
23978
- this._stateScriptDataEscapedEndTagName(cp);
24323
+ this._stateScriptDataEscapedEndTagName(cp2);
23979
24324
  } else {
23980
24325
  this._emitChars("</");
23981
24326
  this.state = State.SCRIPT_DATA_ESCAPED;
23982
- this._stateScriptDataEscaped(cp);
24327
+ this._stateScriptDataEscaped(cp2);
23983
24328
  }
23984
24329
  }
23985
24330
  // Script data escaped end tag name state
23986
24331
  //------------------------------------------------------------------
23987
- _stateScriptDataEscapedEndTagName(cp) {
23988
- if (this.handleSpecialEndTag(cp)) {
24332
+ _stateScriptDataEscapedEndTagName(cp2) {
24333
+ if (this.handleSpecialEndTag(cp2)) {
23989
24334
  this._emitChars("</");
23990
24335
  this.state = State.SCRIPT_DATA_ESCAPED;
23991
- this._stateScriptDataEscaped(cp);
24336
+ this._stateScriptDataEscaped(cp2);
23992
24337
  }
23993
24338
  }
23994
24339
  // Script data double escape start state
23995
24340
  //------------------------------------------------------------------
23996
- _stateScriptDataDoubleEscapeStart(cp) {
24341
+ _stateScriptDataDoubleEscapeStart(cp2) {
23997
24342
  if (this.preprocessor.startsWith(SEQUENCES.SCRIPT, false) && isScriptDataDoubleEscapeSequenceEnd(this.preprocessor.peek(SEQUENCES.SCRIPT.length))) {
23998
- this._emitCodePoint(cp);
24343
+ this._emitCodePoint(cp2);
23999
24344
  for (let i = 0; i < SEQUENCES.SCRIPT.length; i++) {
24000
24345
  this._emitCodePoint(this._consume());
24001
24346
  }
24002
24347
  this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED;
24003
24348
  } else if (!this._ensureHibernation()) {
24004
24349
  this.state = State.SCRIPT_DATA_ESCAPED;
24005
- this._stateScriptDataEscaped(cp);
24350
+ this._stateScriptDataEscaped(cp2);
24006
24351
  }
24007
24352
  }
24008
24353
  // Script data double escaped state
24009
24354
  //------------------------------------------------------------------
24010
- _stateScriptDataDoubleEscaped(cp) {
24011
- switch (cp) {
24355
+ _stateScriptDataDoubleEscaped(cp2) {
24356
+ switch (cp2) {
24012
24357
  case CODE_POINTS.HYPHEN_MINUS: {
24013
24358
  this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED_DASH;
24014
24359
  this._emitChars("-");
@@ -24030,14 +24375,14 @@ var Tokenizer = class {
24030
24375
  break;
24031
24376
  }
24032
24377
  default: {
24033
- this._emitCodePoint(cp);
24378
+ this._emitCodePoint(cp2);
24034
24379
  }
24035
24380
  }
24036
24381
  }
24037
24382
  // Script data double escaped dash state
24038
24383
  //------------------------------------------------------------------
24039
- _stateScriptDataDoubleEscapedDash(cp) {
24040
- switch (cp) {
24384
+ _stateScriptDataDoubleEscapedDash(cp2) {
24385
+ switch (cp2) {
24041
24386
  case CODE_POINTS.HYPHEN_MINUS: {
24042
24387
  this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED_DASH_DASH;
24043
24388
  this._emitChars("-");
@@ -24061,14 +24406,14 @@ var Tokenizer = class {
24061
24406
  }
24062
24407
  default: {
24063
24408
  this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED;
24064
- this._emitCodePoint(cp);
24409
+ this._emitCodePoint(cp2);
24065
24410
  }
24066
24411
  }
24067
24412
  }
24068
24413
  // Script data double escaped dash dash state
24069
24414
  //------------------------------------------------------------------
24070
- _stateScriptDataDoubleEscapedDashDash(cp) {
24071
- switch (cp) {
24415
+ _stateScriptDataDoubleEscapedDashDash(cp2) {
24416
+ switch (cp2) {
24072
24417
  case CODE_POINTS.HYPHEN_MINUS: {
24073
24418
  this._emitChars("-");
24074
24419
  break;
@@ -24096,39 +24441,39 @@ var Tokenizer = class {
24096
24441
  }
24097
24442
  default: {
24098
24443
  this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED;
24099
- this._emitCodePoint(cp);
24444
+ this._emitCodePoint(cp2);
24100
24445
  }
24101
24446
  }
24102
24447
  }
24103
24448
  // Script data double escaped less-than sign state
24104
24449
  //------------------------------------------------------------------
24105
- _stateScriptDataDoubleEscapedLessThanSign(cp) {
24106
- if (cp === CODE_POINTS.SOLIDUS) {
24450
+ _stateScriptDataDoubleEscapedLessThanSign(cp2) {
24451
+ if (cp2 === CODE_POINTS.SOLIDUS) {
24107
24452
  this.state = State.SCRIPT_DATA_DOUBLE_ESCAPE_END;
24108
24453
  this._emitChars("/");
24109
24454
  } else {
24110
24455
  this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED;
24111
- this._stateScriptDataDoubleEscaped(cp);
24456
+ this._stateScriptDataDoubleEscaped(cp2);
24112
24457
  }
24113
24458
  }
24114
24459
  // Script data double escape end state
24115
24460
  //------------------------------------------------------------------
24116
- _stateScriptDataDoubleEscapeEnd(cp) {
24461
+ _stateScriptDataDoubleEscapeEnd(cp2) {
24117
24462
  if (this.preprocessor.startsWith(SEQUENCES.SCRIPT, false) && isScriptDataDoubleEscapeSequenceEnd(this.preprocessor.peek(SEQUENCES.SCRIPT.length))) {
24118
- this._emitCodePoint(cp);
24463
+ this._emitCodePoint(cp2);
24119
24464
  for (let i = 0; i < SEQUENCES.SCRIPT.length; i++) {
24120
24465
  this._emitCodePoint(this._consume());
24121
24466
  }
24122
24467
  this.state = State.SCRIPT_DATA_ESCAPED;
24123
24468
  } else if (!this._ensureHibernation()) {
24124
24469
  this.state = State.SCRIPT_DATA_DOUBLE_ESCAPED;
24125
- this._stateScriptDataDoubleEscaped(cp);
24470
+ this._stateScriptDataDoubleEscaped(cp2);
24126
24471
  }
24127
24472
  }
24128
24473
  // Before attribute name state
24129
24474
  //------------------------------------------------------------------
24130
- _stateBeforeAttributeName(cp) {
24131
- switch (cp) {
24475
+ _stateBeforeAttributeName(cp2) {
24476
+ switch (cp2) {
24132
24477
  case CODE_POINTS.SPACE:
24133
24478
  case CODE_POINTS.LINE_FEED:
24134
24479
  case CODE_POINTS.TABULATION:
@@ -24139,7 +24484,7 @@ var Tokenizer = class {
24139
24484
  case CODE_POINTS.GREATER_THAN_SIGN:
24140
24485
  case CODE_POINTS.EOF: {
24141
24486
  this.state = State.AFTER_ATTRIBUTE_NAME;
24142
- this._stateAfterAttributeName(cp);
24487
+ this._stateAfterAttributeName(cp2);
24143
24488
  break;
24144
24489
  }
24145
24490
  case CODE_POINTS.EQUALS_SIGN: {
@@ -24151,14 +24496,14 @@ var Tokenizer = class {
24151
24496
  default: {
24152
24497
  this._createAttr("");
24153
24498
  this.state = State.ATTRIBUTE_NAME;
24154
- this._stateAttributeName(cp);
24499
+ this._stateAttributeName(cp2);
24155
24500
  }
24156
24501
  }
24157
24502
  }
24158
24503
  // Attribute name state
24159
24504
  //------------------------------------------------------------------
24160
- _stateAttributeName(cp) {
24161
- switch (cp) {
24505
+ _stateAttributeName(cp2) {
24506
+ switch (cp2) {
24162
24507
  case CODE_POINTS.SPACE:
24163
24508
  case CODE_POINTS.LINE_FEED:
24164
24509
  case CODE_POINTS.TABULATION:
@@ -24168,7 +24513,7 @@ var Tokenizer = class {
24168
24513
  case CODE_POINTS.EOF: {
24169
24514
  this._leaveAttrName();
24170
24515
  this.state = State.AFTER_ATTRIBUTE_NAME;
24171
- this._stateAfterAttributeName(cp);
24516
+ this._stateAfterAttributeName(cp2);
24172
24517
  break;
24173
24518
  }
24174
24519
  case CODE_POINTS.EQUALS_SIGN: {
@@ -24180,7 +24525,7 @@ var Tokenizer = class {
24180
24525
  case CODE_POINTS.APOSTROPHE:
24181
24526
  case CODE_POINTS.LESS_THAN_SIGN: {
24182
24527
  this._err(ERR.unexpectedCharacterInAttributeName);
24183
- this.currentAttr.name += String.fromCodePoint(cp);
24528
+ this.currentAttr.name += String.fromCodePoint(cp2);
24184
24529
  break;
24185
24530
  }
24186
24531
  case CODE_POINTS.NULL: {
@@ -24189,14 +24534,14 @@ var Tokenizer = class {
24189
24534
  break;
24190
24535
  }
24191
24536
  default: {
24192
- this.currentAttr.name += String.fromCodePoint(isAsciiUpper(cp) ? toAsciiLower(cp) : cp);
24537
+ this.currentAttr.name += String.fromCodePoint(isAsciiUpper(cp2) ? toAsciiLower(cp2) : cp2);
24193
24538
  }
24194
24539
  }
24195
24540
  }
24196
24541
  // After attribute name state
24197
24542
  //------------------------------------------------------------------
24198
- _stateAfterAttributeName(cp) {
24199
- switch (cp) {
24543
+ _stateAfterAttributeName(cp2) {
24544
+ switch (cp2) {
24200
24545
  case CODE_POINTS.SPACE:
24201
24546
  case CODE_POINTS.LINE_FEED:
24202
24547
  case CODE_POINTS.TABULATION:
@@ -24224,14 +24569,14 @@ var Tokenizer = class {
24224
24569
  default: {
24225
24570
  this._createAttr("");
24226
24571
  this.state = State.ATTRIBUTE_NAME;
24227
- this._stateAttributeName(cp);
24572
+ this._stateAttributeName(cp2);
24228
24573
  }
24229
24574
  }
24230
24575
  }
24231
24576
  // Before attribute value state
24232
24577
  //------------------------------------------------------------------
24233
- _stateBeforeAttributeValue(cp) {
24234
- switch (cp) {
24578
+ _stateBeforeAttributeValue(cp2) {
24579
+ switch (cp2) {
24235
24580
  case CODE_POINTS.SPACE:
24236
24581
  case CODE_POINTS.LINE_FEED:
24237
24582
  case CODE_POINTS.TABULATION:
@@ -24254,14 +24599,14 @@ var Tokenizer = class {
24254
24599
  }
24255
24600
  default: {
24256
24601
  this.state = State.ATTRIBUTE_VALUE_UNQUOTED;
24257
- this._stateAttributeValueUnquoted(cp);
24602
+ this._stateAttributeValueUnquoted(cp2);
24258
24603
  }
24259
24604
  }
24260
24605
  }
24261
24606
  // Attribute value (double-quoted) state
24262
24607
  //------------------------------------------------------------------
24263
- _stateAttributeValueDoubleQuoted(cp) {
24264
- switch (cp) {
24608
+ _stateAttributeValueDoubleQuoted(cp2) {
24609
+ switch (cp2) {
24265
24610
  case CODE_POINTS.QUOTATION_MARK: {
24266
24611
  this.state = State.AFTER_ATTRIBUTE_VALUE_QUOTED;
24267
24612
  break;
@@ -24281,14 +24626,14 @@ var Tokenizer = class {
24281
24626
  break;
24282
24627
  }
24283
24628
  default: {
24284
- this.currentAttr.value += String.fromCodePoint(cp);
24629
+ this.currentAttr.value += String.fromCodePoint(cp2);
24285
24630
  }
24286
24631
  }
24287
24632
  }
24288
24633
  // Attribute value (single-quoted) state
24289
24634
  //------------------------------------------------------------------
24290
- _stateAttributeValueSingleQuoted(cp) {
24291
- switch (cp) {
24635
+ _stateAttributeValueSingleQuoted(cp2) {
24636
+ switch (cp2) {
24292
24637
  case CODE_POINTS.APOSTROPHE: {
24293
24638
  this.state = State.AFTER_ATTRIBUTE_VALUE_QUOTED;
24294
24639
  break;
@@ -24308,14 +24653,14 @@ var Tokenizer = class {
24308
24653
  break;
24309
24654
  }
24310
24655
  default: {
24311
- this.currentAttr.value += String.fromCodePoint(cp);
24656
+ this.currentAttr.value += String.fromCodePoint(cp2);
24312
24657
  }
24313
24658
  }
24314
24659
  }
24315
24660
  // Attribute value (unquoted) state
24316
24661
  //------------------------------------------------------------------
24317
- _stateAttributeValueUnquoted(cp) {
24318
- switch (cp) {
24662
+ _stateAttributeValueUnquoted(cp2) {
24663
+ switch (cp2) {
24319
24664
  case CODE_POINTS.SPACE:
24320
24665
  case CODE_POINTS.LINE_FEED:
24321
24666
  case CODE_POINTS.TABULATION:
@@ -24345,7 +24690,7 @@ var Tokenizer = class {
24345
24690
  case CODE_POINTS.EQUALS_SIGN:
24346
24691
  case CODE_POINTS.GRAVE_ACCENT: {
24347
24692
  this._err(ERR.unexpectedCharacterInUnquotedAttributeValue);
24348
- this.currentAttr.value += String.fromCodePoint(cp);
24693
+ this.currentAttr.value += String.fromCodePoint(cp2);
24349
24694
  break;
24350
24695
  }
24351
24696
  case CODE_POINTS.EOF: {
@@ -24354,14 +24699,14 @@ var Tokenizer = class {
24354
24699
  break;
24355
24700
  }
24356
24701
  default: {
24357
- this.currentAttr.value += String.fromCodePoint(cp);
24702
+ this.currentAttr.value += String.fromCodePoint(cp2);
24358
24703
  }
24359
24704
  }
24360
24705
  }
24361
24706
  // After attribute value (quoted) state
24362
24707
  //------------------------------------------------------------------
24363
- _stateAfterAttributeValueQuoted(cp) {
24364
- switch (cp) {
24708
+ _stateAfterAttributeValueQuoted(cp2) {
24709
+ switch (cp2) {
24365
24710
  case CODE_POINTS.SPACE:
24366
24711
  case CODE_POINTS.LINE_FEED:
24367
24712
  case CODE_POINTS.TABULATION:
@@ -24389,14 +24734,14 @@ var Tokenizer = class {
24389
24734
  default: {
24390
24735
  this._err(ERR.missingWhitespaceBetweenAttributes);
24391
24736
  this.state = State.BEFORE_ATTRIBUTE_NAME;
24392
- this._stateBeforeAttributeName(cp);
24737
+ this._stateBeforeAttributeName(cp2);
24393
24738
  }
24394
24739
  }
24395
24740
  }
24396
24741
  // Self-closing start tag state
24397
24742
  //------------------------------------------------------------------
24398
- _stateSelfClosingStartTag(cp) {
24399
- switch (cp) {
24743
+ _stateSelfClosingStartTag(cp2) {
24744
+ switch (cp2) {
24400
24745
  case CODE_POINTS.GREATER_THAN_SIGN: {
24401
24746
  const token = this.currentToken;
24402
24747
  token.selfClosing = true;
@@ -24412,15 +24757,15 @@ var Tokenizer = class {
24412
24757
  default: {
24413
24758
  this._err(ERR.unexpectedSolidusInTag);
24414
24759
  this.state = State.BEFORE_ATTRIBUTE_NAME;
24415
- this._stateBeforeAttributeName(cp);
24760
+ this._stateBeforeAttributeName(cp2);
24416
24761
  }
24417
24762
  }
24418
24763
  }
24419
24764
  // Bogus comment state
24420
24765
  //------------------------------------------------------------------
24421
- _stateBogusComment(cp) {
24766
+ _stateBogusComment(cp2) {
24422
24767
  const token = this.currentToken;
24423
- switch (cp) {
24768
+ switch (cp2) {
24424
24769
  case CODE_POINTS.GREATER_THAN_SIGN: {
24425
24770
  this.state = State.DATA;
24426
24771
  this.emitCurrentComment(token);
@@ -24437,13 +24782,13 @@ var Tokenizer = class {
24437
24782
  break;
24438
24783
  }
24439
24784
  default: {
24440
- token.data += String.fromCodePoint(cp);
24785
+ token.data += String.fromCodePoint(cp2);
24441
24786
  }
24442
24787
  }
24443
24788
  }
24444
24789
  // Markup declaration open state
24445
24790
  //------------------------------------------------------------------
24446
- _stateMarkupDeclarationOpen(cp) {
24791
+ _stateMarkupDeclarationOpen(cp2) {
24447
24792
  if (this._consumeSequenceIfMatch(SEQUENCES.DASH_DASH, true)) {
24448
24793
  this._createCommentToken(SEQUENCES.DASH_DASH.length + 1);
24449
24794
  this.state = State.COMMENT_START;
@@ -24463,13 +24808,13 @@ var Tokenizer = class {
24463
24808
  this._err(ERR.incorrectlyOpenedComment);
24464
24809
  this._createCommentToken(2);
24465
24810
  this.state = State.BOGUS_COMMENT;
24466
- this._stateBogusComment(cp);
24811
+ this._stateBogusComment(cp2);
24467
24812
  }
24468
24813
  }
24469
24814
  // Comment start state
24470
24815
  //------------------------------------------------------------------
24471
- _stateCommentStart(cp) {
24472
- switch (cp) {
24816
+ _stateCommentStart(cp2) {
24817
+ switch (cp2) {
24473
24818
  case CODE_POINTS.HYPHEN_MINUS: {
24474
24819
  this.state = State.COMMENT_START_DASH;
24475
24820
  break;
@@ -24483,15 +24828,15 @@ var Tokenizer = class {
24483
24828
  }
24484
24829
  default: {
24485
24830
  this.state = State.COMMENT;
24486
- this._stateComment(cp);
24831
+ this._stateComment(cp2);
24487
24832
  }
24488
24833
  }
24489
24834
  }
24490
24835
  // Comment start dash state
24491
24836
  //------------------------------------------------------------------
24492
- _stateCommentStartDash(cp) {
24837
+ _stateCommentStartDash(cp2) {
24493
24838
  const token = this.currentToken;
24494
- switch (cp) {
24839
+ switch (cp2) {
24495
24840
  case CODE_POINTS.HYPHEN_MINUS: {
24496
24841
  this.state = State.COMMENT_END;
24497
24842
  break;
@@ -24511,15 +24856,15 @@ var Tokenizer = class {
24511
24856
  default: {
24512
24857
  token.data += "-";
24513
24858
  this.state = State.COMMENT;
24514
- this._stateComment(cp);
24859
+ this._stateComment(cp2);
24515
24860
  }
24516
24861
  }
24517
24862
  }
24518
24863
  // Comment state
24519
24864
  //------------------------------------------------------------------
24520
- _stateComment(cp) {
24865
+ _stateComment(cp2) {
24521
24866
  const token = this.currentToken;
24522
- switch (cp) {
24867
+ switch (cp2) {
24523
24868
  case CODE_POINTS.HYPHEN_MINUS: {
24524
24869
  this.state = State.COMMENT_END_DASH;
24525
24870
  break;
@@ -24541,15 +24886,15 @@ var Tokenizer = class {
24541
24886
  break;
24542
24887
  }
24543
24888
  default: {
24544
- token.data += String.fromCodePoint(cp);
24889
+ token.data += String.fromCodePoint(cp2);
24545
24890
  }
24546
24891
  }
24547
24892
  }
24548
24893
  // Comment less-than sign state
24549
24894
  //------------------------------------------------------------------
24550
- _stateCommentLessThanSign(cp) {
24895
+ _stateCommentLessThanSign(cp2) {
24551
24896
  const token = this.currentToken;
24552
- switch (cp) {
24897
+ switch (cp2) {
24553
24898
  case CODE_POINTS.EXCLAMATION_MARK: {
24554
24899
  token.data += "!";
24555
24900
  this.state = State.COMMENT_LESS_THAN_SIGN_BANG;
@@ -24561,44 +24906,44 @@ var Tokenizer = class {
24561
24906
  }
24562
24907
  default: {
24563
24908
  this.state = State.COMMENT;
24564
- this._stateComment(cp);
24909
+ this._stateComment(cp2);
24565
24910
  }
24566
24911
  }
24567
24912
  }
24568
24913
  // Comment less-than sign bang state
24569
24914
  //------------------------------------------------------------------
24570
- _stateCommentLessThanSignBang(cp) {
24571
- if (cp === CODE_POINTS.HYPHEN_MINUS) {
24915
+ _stateCommentLessThanSignBang(cp2) {
24916
+ if (cp2 === CODE_POINTS.HYPHEN_MINUS) {
24572
24917
  this.state = State.COMMENT_LESS_THAN_SIGN_BANG_DASH;
24573
24918
  } else {
24574
24919
  this.state = State.COMMENT;
24575
- this._stateComment(cp);
24920
+ this._stateComment(cp2);
24576
24921
  }
24577
24922
  }
24578
24923
  // Comment less-than sign bang dash state
24579
24924
  //------------------------------------------------------------------
24580
- _stateCommentLessThanSignBangDash(cp) {
24581
- if (cp === CODE_POINTS.HYPHEN_MINUS) {
24925
+ _stateCommentLessThanSignBangDash(cp2) {
24926
+ if (cp2 === CODE_POINTS.HYPHEN_MINUS) {
24582
24927
  this.state = State.COMMENT_LESS_THAN_SIGN_BANG_DASH_DASH;
24583
24928
  } else {
24584
24929
  this.state = State.COMMENT_END_DASH;
24585
- this._stateCommentEndDash(cp);
24930
+ this._stateCommentEndDash(cp2);
24586
24931
  }
24587
24932
  }
24588
24933
  // Comment less-than sign bang dash dash state
24589
24934
  //------------------------------------------------------------------
24590
- _stateCommentLessThanSignBangDashDash(cp) {
24591
- if (cp !== CODE_POINTS.GREATER_THAN_SIGN && cp !== CODE_POINTS.EOF) {
24935
+ _stateCommentLessThanSignBangDashDash(cp2) {
24936
+ if (cp2 !== CODE_POINTS.GREATER_THAN_SIGN && cp2 !== CODE_POINTS.EOF) {
24592
24937
  this._err(ERR.nestedComment);
24593
24938
  }
24594
24939
  this.state = State.COMMENT_END;
24595
- this._stateCommentEnd(cp);
24940
+ this._stateCommentEnd(cp2);
24596
24941
  }
24597
24942
  // Comment end dash state
24598
24943
  //------------------------------------------------------------------
24599
- _stateCommentEndDash(cp) {
24944
+ _stateCommentEndDash(cp2) {
24600
24945
  const token = this.currentToken;
24601
- switch (cp) {
24946
+ switch (cp2) {
24602
24947
  case CODE_POINTS.HYPHEN_MINUS: {
24603
24948
  this.state = State.COMMENT_END;
24604
24949
  break;
@@ -24612,15 +24957,15 @@ var Tokenizer = class {
24612
24957
  default: {
24613
24958
  token.data += "-";
24614
24959
  this.state = State.COMMENT;
24615
- this._stateComment(cp);
24960
+ this._stateComment(cp2);
24616
24961
  }
24617
24962
  }
24618
24963
  }
24619
24964
  // Comment end state
24620
24965
  //------------------------------------------------------------------
24621
- _stateCommentEnd(cp) {
24966
+ _stateCommentEnd(cp2) {
24622
24967
  const token = this.currentToken;
24623
- switch (cp) {
24968
+ switch (cp2) {
24624
24969
  case CODE_POINTS.GREATER_THAN_SIGN: {
24625
24970
  this.state = State.DATA;
24626
24971
  this.emitCurrentComment(token);
@@ -24643,15 +24988,15 @@ var Tokenizer = class {
24643
24988
  default: {
24644
24989
  token.data += "--";
24645
24990
  this.state = State.COMMENT;
24646
- this._stateComment(cp);
24991
+ this._stateComment(cp2);
24647
24992
  }
24648
24993
  }
24649
24994
  }
24650
24995
  // Comment end bang state
24651
24996
  //------------------------------------------------------------------
24652
- _stateCommentEndBang(cp) {
24997
+ _stateCommentEndBang(cp2) {
24653
24998
  const token = this.currentToken;
24654
- switch (cp) {
24999
+ switch (cp2) {
24655
25000
  case CODE_POINTS.HYPHEN_MINUS: {
24656
25001
  token.data += "--!";
24657
25002
  this.state = State.COMMENT_END_DASH;
@@ -24672,14 +25017,14 @@ var Tokenizer = class {
24672
25017
  default: {
24673
25018
  token.data += "--!";
24674
25019
  this.state = State.COMMENT;
24675
- this._stateComment(cp);
25020
+ this._stateComment(cp2);
24676
25021
  }
24677
25022
  }
24678
25023
  }
24679
25024
  // DOCTYPE state
24680
25025
  //------------------------------------------------------------------
24681
- _stateDoctype(cp) {
24682
- switch (cp) {
25026
+ _stateDoctype(cp2) {
25027
+ switch (cp2) {
24683
25028
  case CODE_POINTS.SPACE:
24684
25029
  case CODE_POINTS.LINE_FEED:
24685
25030
  case CODE_POINTS.TABULATION:
@@ -24689,7 +25034,7 @@ var Tokenizer = class {
24689
25034
  }
24690
25035
  case CODE_POINTS.GREATER_THAN_SIGN: {
24691
25036
  this.state = State.BEFORE_DOCTYPE_NAME;
24692
- this._stateBeforeDoctypeName(cp);
25037
+ this._stateBeforeDoctypeName(cp2);
24693
25038
  break;
24694
25039
  }
24695
25040
  case CODE_POINTS.EOF: {
@@ -24704,18 +25049,18 @@ var Tokenizer = class {
24704
25049
  default: {
24705
25050
  this._err(ERR.missingWhitespaceBeforeDoctypeName);
24706
25051
  this.state = State.BEFORE_DOCTYPE_NAME;
24707
- this._stateBeforeDoctypeName(cp);
25052
+ this._stateBeforeDoctypeName(cp2);
24708
25053
  }
24709
25054
  }
24710
25055
  }
24711
25056
  // Before DOCTYPE name state
24712
25057
  //------------------------------------------------------------------
24713
- _stateBeforeDoctypeName(cp) {
24714
- if (isAsciiUpper(cp)) {
24715
- this._createDoctypeToken(String.fromCharCode(toAsciiLower(cp)));
25058
+ _stateBeforeDoctypeName(cp2) {
25059
+ if (isAsciiUpper(cp2)) {
25060
+ this._createDoctypeToken(String.fromCharCode(toAsciiLower(cp2)));
24716
25061
  this.state = State.DOCTYPE_NAME;
24717
25062
  } else
24718
- switch (cp) {
25063
+ switch (cp2) {
24719
25064
  case CODE_POINTS.SPACE:
24720
25065
  case CODE_POINTS.LINE_FEED:
24721
25066
  case CODE_POINTS.TABULATION:
@@ -24747,16 +25092,16 @@ var Tokenizer = class {
24747
25092
  break;
24748
25093
  }
24749
25094
  default: {
24750
- this._createDoctypeToken(String.fromCodePoint(cp));
25095
+ this._createDoctypeToken(String.fromCodePoint(cp2));
24751
25096
  this.state = State.DOCTYPE_NAME;
24752
25097
  }
24753
25098
  }
24754
25099
  }
24755
25100
  // DOCTYPE name state
24756
25101
  //------------------------------------------------------------------
24757
- _stateDoctypeName(cp) {
25102
+ _stateDoctypeName(cp2) {
24758
25103
  const token = this.currentToken;
24759
- switch (cp) {
25104
+ switch (cp2) {
24760
25105
  case CODE_POINTS.SPACE:
24761
25106
  case CODE_POINTS.LINE_FEED:
24762
25107
  case CODE_POINTS.TABULATION:
@@ -24782,15 +25127,15 @@ var Tokenizer = class {
24782
25127
  break;
24783
25128
  }
24784
25129
  default: {
24785
- token.name += String.fromCodePoint(isAsciiUpper(cp) ? toAsciiLower(cp) : cp);
25130
+ token.name += String.fromCodePoint(isAsciiUpper(cp2) ? toAsciiLower(cp2) : cp2);
24786
25131
  }
24787
25132
  }
24788
25133
  }
24789
25134
  // After DOCTYPE name state
24790
25135
  //------------------------------------------------------------------
24791
- _stateAfterDoctypeName(cp) {
25136
+ _stateAfterDoctypeName(cp2) {
24792
25137
  const token = this.currentToken;
24793
- switch (cp) {
25138
+ switch (cp2) {
24794
25139
  case CODE_POINTS.SPACE:
24795
25140
  case CODE_POINTS.LINE_FEED:
24796
25141
  case CODE_POINTS.TABULATION:
@@ -24818,16 +25163,16 @@ var Tokenizer = class {
24818
25163
  this._err(ERR.invalidCharacterSequenceAfterDoctypeName);
24819
25164
  token.forceQuirks = true;
24820
25165
  this.state = State.BOGUS_DOCTYPE;
24821
- this._stateBogusDoctype(cp);
25166
+ this._stateBogusDoctype(cp2);
24822
25167
  }
24823
25168
  }
24824
25169
  }
24825
25170
  }
24826
25171
  // After DOCTYPE public keyword state
24827
25172
  //------------------------------------------------------------------
24828
- _stateAfterDoctypePublicKeyword(cp) {
25173
+ _stateAfterDoctypePublicKeyword(cp2) {
24829
25174
  const token = this.currentToken;
24830
- switch (cp) {
25175
+ switch (cp2) {
24831
25176
  case CODE_POINTS.SPACE:
24832
25177
  case CODE_POINTS.LINE_FEED:
24833
25178
  case CODE_POINTS.TABULATION:
@@ -24865,15 +25210,15 @@ var Tokenizer = class {
24865
25210
  this._err(ERR.missingQuoteBeforeDoctypePublicIdentifier);
24866
25211
  token.forceQuirks = true;
24867
25212
  this.state = State.BOGUS_DOCTYPE;
24868
- this._stateBogusDoctype(cp);
25213
+ this._stateBogusDoctype(cp2);
24869
25214
  }
24870
25215
  }
24871
25216
  }
24872
25217
  // Before DOCTYPE public identifier state
24873
25218
  //------------------------------------------------------------------
24874
- _stateBeforeDoctypePublicIdentifier(cp) {
25219
+ _stateBeforeDoctypePublicIdentifier(cp2) {
24875
25220
  const token = this.currentToken;
24876
- switch (cp) {
25221
+ switch (cp2) {
24877
25222
  case CODE_POINTS.SPACE:
24878
25223
  case CODE_POINTS.LINE_FEED:
24879
25224
  case CODE_POINTS.TABULATION:
@@ -24908,15 +25253,15 @@ var Tokenizer = class {
24908
25253
  this._err(ERR.missingQuoteBeforeDoctypePublicIdentifier);
24909
25254
  token.forceQuirks = true;
24910
25255
  this.state = State.BOGUS_DOCTYPE;
24911
- this._stateBogusDoctype(cp);
25256
+ this._stateBogusDoctype(cp2);
24912
25257
  }
24913
25258
  }
24914
25259
  }
24915
25260
  // DOCTYPE public identifier (double-quoted) state
24916
25261
  //------------------------------------------------------------------
24917
- _stateDoctypePublicIdentifierDoubleQuoted(cp) {
25262
+ _stateDoctypePublicIdentifierDoubleQuoted(cp2) {
24918
25263
  const token = this.currentToken;
24919
- switch (cp) {
25264
+ switch (cp2) {
24920
25265
  case CODE_POINTS.QUOTATION_MARK: {
24921
25266
  this.state = State.AFTER_DOCTYPE_PUBLIC_IDENTIFIER;
24922
25267
  break;
@@ -24941,15 +25286,15 @@ var Tokenizer = class {
24941
25286
  break;
24942
25287
  }
24943
25288
  default: {
24944
- token.publicId += String.fromCodePoint(cp);
25289
+ token.publicId += String.fromCodePoint(cp2);
24945
25290
  }
24946
25291
  }
24947
25292
  }
24948
25293
  // DOCTYPE public identifier (single-quoted) state
24949
25294
  //------------------------------------------------------------------
24950
- _stateDoctypePublicIdentifierSingleQuoted(cp) {
25295
+ _stateDoctypePublicIdentifierSingleQuoted(cp2) {
24951
25296
  const token = this.currentToken;
24952
- switch (cp) {
25297
+ switch (cp2) {
24953
25298
  case CODE_POINTS.APOSTROPHE: {
24954
25299
  this.state = State.AFTER_DOCTYPE_PUBLIC_IDENTIFIER;
24955
25300
  break;
@@ -24974,15 +25319,15 @@ var Tokenizer = class {
24974
25319
  break;
24975
25320
  }
24976
25321
  default: {
24977
- token.publicId += String.fromCodePoint(cp);
25322
+ token.publicId += String.fromCodePoint(cp2);
24978
25323
  }
24979
25324
  }
24980
25325
  }
24981
25326
  // After DOCTYPE public identifier state
24982
25327
  //------------------------------------------------------------------
24983
- _stateAfterDoctypePublicIdentifier(cp) {
25328
+ _stateAfterDoctypePublicIdentifier(cp2) {
24984
25329
  const token = this.currentToken;
24985
- switch (cp) {
25330
+ switch (cp2) {
24986
25331
  case CODE_POINTS.SPACE:
24987
25332
  case CODE_POINTS.LINE_FEED:
24988
25333
  case CODE_POINTS.TABULATION:
@@ -25018,15 +25363,15 @@ var Tokenizer = class {
25018
25363
  this._err(ERR.missingQuoteBeforeDoctypeSystemIdentifier);
25019
25364
  token.forceQuirks = true;
25020
25365
  this.state = State.BOGUS_DOCTYPE;
25021
- this._stateBogusDoctype(cp);
25366
+ this._stateBogusDoctype(cp2);
25022
25367
  }
25023
25368
  }
25024
25369
  }
25025
25370
  // Between DOCTYPE public and system identifiers state
25026
25371
  //------------------------------------------------------------------
25027
- _stateBetweenDoctypePublicAndSystemIdentifiers(cp) {
25372
+ _stateBetweenDoctypePublicAndSystemIdentifiers(cp2) {
25028
25373
  const token = this.currentToken;
25029
- switch (cp) {
25374
+ switch (cp2) {
25030
25375
  case CODE_POINTS.SPACE:
25031
25376
  case CODE_POINTS.LINE_FEED:
25032
25377
  case CODE_POINTS.TABULATION:
@@ -25059,15 +25404,15 @@ var Tokenizer = class {
25059
25404
  this._err(ERR.missingQuoteBeforeDoctypeSystemIdentifier);
25060
25405
  token.forceQuirks = true;
25061
25406
  this.state = State.BOGUS_DOCTYPE;
25062
- this._stateBogusDoctype(cp);
25407
+ this._stateBogusDoctype(cp2);
25063
25408
  }
25064
25409
  }
25065
25410
  }
25066
25411
  // After DOCTYPE system keyword state
25067
25412
  //------------------------------------------------------------------
25068
- _stateAfterDoctypeSystemKeyword(cp) {
25413
+ _stateAfterDoctypeSystemKeyword(cp2) {
25069
25414
  const token = this.currentToken;
25070
- switch (cp) {
25415
+ switch (cp2) {
25071
25416
  case CODE_POINTS.SPACE:
25072
25417
  case CODE_POINTS.LINE_FEED:
25073
25418
  case CODE_POINTS.TABULATION:
@@ -25105,15 +25450,15 @@ var Tokenizer = class {
25105
25450
  this._err(ERR.missingQuoteBeforeDoctypeSystemIdentifier);
25106
25451
  token.forceQuirks = true;
25107
25452
  this.state = State.BOGUS_DOCTYPE;
25108
- this._stateBogusDoctype(cp);
25453
+ this._stateBogusDoctype(cp2);
25109
25454
  }
25110
25455
  }
25111
25456
  }
25112
25457
  // Before DOCTYPE system identifier state
25113
25458
  //------------------------------------------------------------------
25114
- _stateBeforeDoctypeSystemIdentifier(cp) {
25459
+ _stateBeforeDoctypeSystemIdentifier(cp2) {
25115
25460
  const token = this.currentToken;
25116
- switch (cp) {
25461
+ switch (cp2) {
25117
25462
  case CODE_POINTS.SPACE:
25118
25463
  case CODE_POINTS.LINE_FEED:
25119
25464
  case CODE_POINTS.TABULATION:
@@ -25148,15 +25493,15 @@ var Tokenizer = class {
25148
25493
  this._err(ERR.missingQuoteBeforeDoctypeSystemIdentifier);
25149
25494
  token.forceQuirks = true;
25150
25495
  this.state = State.BOGUS_DOCTYPE;
25151
- this._stateBogusDoctype(cp);
25496
+ this._stateBogusDoctype(cp2);
25152
25497
  }
25153
25498
  }
25154
25499
  }
25155
25500
  // DOCTYPE system identifier (double-quoted) state
25156
25501
  //------------------------------------------------------------------
25157
- _stateDoctypeSystemIdentifierDoubleQuoted(cp) {
25502
+ _stateDoctypeSystemIdentifierDoubleQuoted(cp2) {
25158
25503
  const token = this.currentToken;
25159
- switch (cp) {
25504
+ switch (cp2) {
25160
25505
  case CODE_POINTS.QUOTATION_MARK: {
25161
25506
  this.state = State.AFTER_DOCTYPE_SYSTEM_IDENTIFIER;
25162
25507
  break;
@@ -25181,15 +25526,15 @@ var Tokenizer = class {
25181
25526
  break;
25182
25527
  }
25183
25528
  default: {
25184
- token.systemId += String.fromCodePoint(cp);
25529
+ token.systemId += String.fromCodePoint(cp2);
25185
25530
  }
25186
25531
  }
25187
25532
  }
25188
25533
  // DOCTYPE system identifier (single-quoted) state
25189
25534
  //------------------------------------------------------------------
25190
- _stateDoctypeSystemIdentifierSingleQuoted(cp) {
25535
+ _stateDoctypeSystemIdentifierSingleQuoted(cp2) {
25191
25536
  const token = this.currentToken;
25192
- switch (cp) {
25537
+ switch (cp2) {
25193
25538
  case CODE_POINTS.APOSTROPHE: {
25194
25539
  this.state = State.AFTER_DOCTYPE_SYSTEM_IDENTIFIER;
25195
25540
  break;
@@ -25214,15 +25559,15 @@ var Tokenizer = class {
25214
25559
  break;
25215
25560
  }
25216
25561
  default: {
25217
- token.systemId += String.fromCodePoint(cp);
25562
+ token.systemId += String.fromCodePoint(cp2);
25218
25563
  }
25219
25564
  }
25220
25565
  }
25221
25566
  // After DOCTYPE system identifier state
25222
25567
  //------------------------------------------------------------------
25223
- _stateAfterDoctypeSystemIdentifier(cp) {
25568
+ _stateAfterDoctypeSystemIdentifier(cp2) {
25224
25569
  const token = this.currentToken;
25225
- switch (cp) {
25570
+ switch (cp2) {
25226
25571
  case CODE_POINTS.SPACE:
25227
25572
  case CODE_POINTS.LINE_FEED:
25228
25573
  case CODE_POINTS.TABULATION:
@@ -25244,15 +25589,15 @@ var Tokenizer = class {
25244
25589
  default: {
25245
25590
  this._err(ERR.unexpectedCharacterAfterDoctypeSystemIdentifier);
25246
25591
  this.state = State.BOGUS_DOCTYPE;
25247
- this._stateBogusDoctype(cp);
25592
+ this._stateBogusDoctype(cp2);
25248
25593
  }
25249
25594
  }
25250
25595
  }
25251
25596
  // Bogus DOCTYPE state
25252
25597
  //------------------------------------------------------------------
25253
- _stateBogusDoctype(cp) {
25598
+ _stateBogusDoctype(cp2) {
25254
25599
  const token = this.currentToken;
25255
- switch (cp) {
25600
+ switch (cp2) {
25256
25601
  case CODE_POINTS.GREATER_THAN_SIGN: {
25257
25602
  this.emitCurrentDoctype(token);
25258
25603
  this.state = State.DATA;
@@ -25272,8 +25617,8 @@ var Tokenizer = class {
25272
25617
  }
25273
25618
  // CDATA section state
25274
25619
  //------------------------------------------------------------------
25275
- _stateCdataSection(cp) {
25276
- switch (cp) {
25620
+ _stateCdataSection(cp2) {
25621
+ switch (cp2) {
25277
25622
  case CODE_POINTS.RIGHT_SQUARE_BRACKET: {
25278
25623
  this.state = State.CDATA_SECTION_BRACKET;
25279
25624
  break;
@@ -25284,25 +25629,25 @@ var Tokenizer = class {
25284
25629
  break;
25285
25630
  }
25286
25631
  default: {
25287
- this._emitCodePoint(cp);
25632
+ this._emitCodePoint(cp2);
25288
25633
  }
25289
25634
  }
25290
25635
  }
25291
25636
  // CDATA section bracket state
25292
25637
  //------------------------------------------------------------------
25293
- _stateCdataSectionBracket(cp) {
25294
- if (cp === CODE_POINTS.RIGHT_SQUARE_BRACKET) {
25638
+ _stateCdataSectionBracket(cp2) {
25639
+ if (cp2 === CODE_POINTS.RIGHT_SQUARE_BRACKET) {
25295
25640
  this.state = State.CDATA_SECTION_END;
25296
25641
  } else {
25297
25642
  this._emitChars("]");
25298
25643
  this.state = State.CDATA_SECTION;
25299
- this._stateCdataSection(cp);
25644
+ this._stateCdataSection(cp2);
25300
25645
  }
25301
25646
  }
25302
25647
  // CDATA section end state
25303
25648
  //------------------------------------------------------------------
25304
- _stateCdataSectionEnd(cp) {
25305
- switch (cp) {
25649
+ _stateCdataSectionEnd(cp2) {
25650
+ switch (cp2) {
25306
25651
  case CODE_POINTS.GREATER_THAN_SIGN: {
25307
25652
  this.state = State.DATA;
25308
25653
  break;
@@ -25314,7 +25659,7 @@ var Tokenizer = class {
25314
25659
  default: {
25315
25660
  this._emitChars("]]");
25316
25661
  this.state = State.CDATA_SECTION;
25317
- this._stateCdataSection(cp);
25662
+ this._stateCdataSection(cp2);
25318
25663
  }
25319
25664
  }
25320
25665
  }
@@ -25343,15 +25688,15 @@ var Tokenizer = class {
25343
25688
  }
25344
25689
  // Ambiguos ampersand state
25345
25690
  //------------------------------------------------------------------
25346
- _stateAmbiguousAmpersand(cp) {
25347
- if (isAsciiAlphaNumeric2(cp)) {
25348
- this._flushCodePointConsumedAsCharacterReference(cp);
25691
+ _stateAmbiguousAmpersand(cp2) {
25692
+ if (isAsciiAlphaNumeric2(cp2)) {
25693
+ this._flushCodePointConsumedAsCharacterReference(cp2);
25349
25694
  } else {
25350
- if (cp === CODE_POINTS.SEMICOLON) {
25695
+ if (cp2 === CODE_POINTS.SEMICOLON) {
25351
25696
  this._err(ERR.unknownNamedCharacterReference);
25352
25697
  }
25353
25698
  this.state = this.returnState;
25354
- this._callState(cp);
25699
+ this._callState(cp2);
25355
25700
  }
25356
25701
  }
25357
25702
  };
@@ -29366,7 +29711,7 @@ function* descendants(node) {
29366
29711
  }
29367
29712
  }
29368
29713
  function sha256(s) {
29369
- return createHash2("sha256").update(s).digest("hex");
29714
+ return createHash3("sha256").update(s).digest("hex");
29370
29715
  }
29371
29716
  var SKIPPED = /* @__PURE__ */ new Set(["script", "style", "noscript", "template", "svg", "iframe", "object", "canvas", "select", "head"]);
29372
29717
  var HEADING = /^h([1-6])$/;
@@ -29657,7 +30002,7 @@ function headingTexts(html, level) {
29657
30002
  }
29658
30003
 
29659
30004
  // ../geo-engine/src/geo/selected-page-evidence.ts
29660
- import { createHash as createHash3 } from "node:crypto";
30005
+ import { createHash as createHash4 } from "node:crypto";
29661
30006
 
29662
30007
  // ../geo-engine/src/geo/material-fact-contract.ts
29663
30008
  var text = external_exports.string().trim().min(1);
@@ -29763,10 +30108,10 @@ var SelectedPageEvidenceSchema = external_exports.strictObject({
29763
30108
  function selectedPageId(pageUrl) {
29764
30109
  const selected = new URL(pageUrl);
29765
30110
  selected.hash = "";
29766
- return `page:${createHash3("sha256").update(selected.href).digest("hex")}`;
30111
+ return `page:${createHash4("sha256").update(selected.href).digest("hex")}`;
29767
30112
  }
29768
30113
  function observationBodyHash(body) {
29769
- return createHash3("sha256").update(body).digest("hex");
30114
+ return createHash4("sha256").update(body).digest("hex");
29770
30115
  }
29771
30116
  function sameSelectedHost(selectedUrl, finalUrl) {
29772
30117
  const host = (value) => new URL(value).hostname.toLowerCase().replace(/^www\./, "");
@@ -30218,14 +30563,14 @@ function evaluateAccess(parsed, token, url3, fallbackTokens = []) {
30218
30563
  }
30219
30564
 
30220
30565
  // ../geo-engine/src/geo/readiness/findings.ts
30221
- import { createHash as createHash4 } from "node:crypto";
30566
+ import { createHash as createHash5 } from "node:crypto";
30222
30567
  function issueId(origin, checkId, scopeKey) {
30223
- return createHash4("sha256").update(`${origin.toLowerCase()}
30568
+ return createHash5("sha256").update(`${origin.toLowerCase()}
30224
30569
  ${checkId}
30225
30570
  ${scopeKey}`).digest("hex").slice(0, 16);
30226
30571
  }
30227
30572
  function fingerprint(body) {
30228
- return body === null ? null : createHash4("sha256").update(body).digest("hex");
30573
+ return body === null ? null : createHash5("sha256").update(body).digest("hex");
30229
30574
  }
30230
30575
  function makeFinding({ origin, scopeKey, policyChoice = false, materiality = "site", ...rest }) {
30231
30576
  return { id: issueId(origin, rest.checkId, scopeKey), policyChoice, materiality, ...rest };
@@ -30516,7 +30861,7 @@ function searchCrawlers() {
30516
30861
  return CRAWLER_REGISTRY.filter((entry) => entry.purpose === "search_index").map((entry) => entry.token);
30517
30862
  }
30518
30863
  function probeUserAgent(token) {
30519
- return `Mozilla/5.0 (compatible; ${token}; Heysurface readiness check)`;
30864
+ return `Mozilla/5.0 (compatible; ${token}; Obi readiness check)`;
30520
30865
  }
30521
30866
  function firewallProbePlan(origin) {
30522
30867
  const base = new URL(origin).origin;
@@ -30622,6 +30967,7 @@ function auditFirewall(probes, origin) {
30622
30967
  }
30623
30968
 
30624
30969
  // ../geo-engine/src/geo/host-acquisition.ts
30970
+ var ROBOTS_TOKENS = ["Obi", "Heysurface"];
30625
30971
  var INVENTORY_SAFETY_LIMIT = 1e5;
30626
30972
  var priority = { robots: 0, sitemap: 1, page: 2, llms: 3 };
30627
30973
  var pagePriority = {
@@ -30697,9 +31043,9 @@ function discoverHostPageLinks(state, body, pageUrl, known = new Set(state.resou
30697
31043
  const alias = new URL(pageUrl);
30698
31044
  alias.hostname = alias.hostname.startsWith("www.") ? alias.hostname.slice(4) : `www.${alias.hostname}`;
30699
31045
  const links = [pageUrl, alias.href].flatMap((base) => extractSameOriginLinks(body, base, INVENTORY_SAFETY_LIMIT));
30700
- for (const link of links) {
30701
- if (/\.(?:xml|pdf|png|jpe?g|gif|svg|webp|ico|css|js|zip|mp4|woff2?)$/i.test(new URL(link).pathname)) continue;
30702
- const resource = appendResource(state, link, "page", known);
31046
+ for (const link2 of links) {
31047
+ if (/\.(?:xml|pdf|png|jpe?g|gif|svg|webp|ico|css|js|zip|mp4|woff2?)$/i.test(new URL(link2).pathname)) continue;
31048
+ const resource = appendResource(state, link2, "page", known);
30703
31049
  if (resource) added.push(resource);
30704
31050
  }
30705
31051
  return added;
@@ -30727,7 +31073,7 @@ function validateState(raw) {
30727
31073
  return state;
30728
31074
  }
30729
31075
  function matchesFingerprint(observation) {
30730
- return observation.body === null ? observation.bodyHash === null : observation.bodyHash === createHash5("sha256").update(observation.body).digest("hex");
31076
+ return observation.body === null ? observation.bodyHash === null : observation.bodyHash === createHash6("sha256").update(observation.body).digest("hex");
30731
31077
  }
30732
31078
  function pendingProbeRequests(state) {
30733
31079
  const home = state.resources.find((resource) => resource.kind === "page" && resource.url === `${state.origin}/`);
@@ -30794,6 +31140,7 @@ async function crawlHostBatch(raw, options = {}) {
30794
31140
  const pages = [];
30795
31141
  const fetcher = options.fetcher ?? observeSelectedHttp;
30796
31142
  const probePlan = options.probeBots ? firewallProbePlan(state.origin) : [];
31143
+ const parsedRobots = /* @__PURE__ */ new Map();
30797
31144
  for (let attempt = 0; attempt < batchSize; attempt++) {
30798
31145
  if (pendingChanged) {
30799
31146
  pending.sort((a, b) => order.get(a.url) - order.get(b.url));
@@ -30829,7 +31176,12 @@ async function crawlHostBatch(raw, options = {}) {
30829
31176
  if (next.kind !== "robots" && state.robots) {
30830
31177
  const robots = state.robots;
30831
31178
  const unavailable2 = robots.errorKind || robots.truncated || robots.status === null || robots.status === 429 || robots.status >= 500;
30832
- const blocked = robots.status === 200 && robots.body !== null && !evaluateAccess(parseRobots(robots.body), "Heysurface", next.url).allowed;
31179
+ let rules = null;
31180
+ if (robots.status === 200 && robots.body !== null) {
31181
+ rules = parsedRobots.get(robots.body) ?? parseRobots(robots.body);
31182
+ parsedRobots.set(robots.body, rules);
31183
+ }
31184
+ const blocked = rules !== null && ROBOTS_TOKENS.some((token) => !evaluateAccess(rules, token, next.url).allowed);
30833
31185
  if (unavailable2 || blocked) {
30834
31186
  next.status = "blocked";
30835
31187
  next.error = unavailable2 ? "robots_unavailable" : "robots_disallow";
@@ -31147,7 +31499,7 @@ function auditLlms(obs, ctx) {
31147
31499
  }
31148
31500
  const valid = links.filter((l) => l.resolved !== null);
31149
31501
  const seen = /* @__PURE__ */ new Map();
31150
- for (const link of valid) seen.set(normalize(link.resolved), [...seen.get(normalize(link.resolved)) ?? [], link]);
31502
+ for (const link2 of valid) seen.set(normalize(link2.resolved), [...seen.get(normalize(link2.resolved)) ?? [], link2]);
31151
31503
  const duplicates = [...seen.entries()].filter(([, list]) => list.length > 1).slice(0, MAX_LISTED);
31152
31504
  if (duplicates.length > 0) {
31153
31505
  fail("llms.duplicate-links", duplicates.map(([u]) => u).join("\n"), duplicates.flatMap(([, list]) => list.map((l) => l.line)), { links: duplicates.map(([u]) => u) }, "info");
@@ -32492,7 +32844,7 @@ async function readJson(path, maxBytes = maxCorpusBytes) {
32492
32844
  try {
32493
32845
  const info = await stat6(path);
32494
32846
  if (!info.isFile() || info.size > maxBytes) throw fileError(`The research file is not a regular JSON file within the ${maxBytes / 1024 / 1024} MiB local limit.`);
32495
- const content = await readFile6(path);
32847
+ const content = await readFile7(path);
32496
32848
  if (content.byteLength > maxBytes) throw fileError(`The research file exceeds the ${maxBytes / 1024 / 1024} MiB local limit.`);
32497
32849
  return JSON.parse(content.toString("utf8"));
32498
32850
  } catch (error51) {
@@ -32680,8 +33032,8 @@ async function captureResearch(input, checkpoint, output) {
32680
33032
 
32681
33033
  // src/research-video.ts
32682
33034
  import { spawn as spawn2 } from "node:child_process";
32683
- import { mkdir as mkdir2, readdir as readdir2, readFile as readFile7, rm } from "node:fs/promises";
32684
- import { join as join4, resolve as resolve3 } from "node:path";
33035
+ import { mkdir as mkdir2, readdir as readdir3, readFile as readFile8, rm as rm2 } from "node:fs/promises";
33036
+ import { join as join5, resolve as resolve3 } from "node:path";
32685
33037
  var maxToolOutputBytes = 256 * 1024;
32686
33038
  var runTool = (executable, args, timeoutMs) => new Promise((done, fail) => {
32687
33039
  const child = spawn2(executable, [...args], { stdio: ["ignore", "pipe", "pipe"], shell: false });
@@ -32708,7 +33060,7 @@ var runTool = (executable, args, timeoutMs) => new Promise((done, fail) => {
32708
33060
  });
32709
33061
  });
32710
33062
  var presenceTimeoutMs = 6e4;
32711
- async function present(runner, executable, flag) {
33063
+ async function present2(runner, executable, flag) {
32712
33064
  try {
32713
33065
  return (await runner(executable, [flag], presenceTimeoutMs)).exitCode === 0;
32714
33066
  } catch {
@@ -32716,7 +33068,7 @@ async function present(runner, executable, flag) {
32716
33068
  }
32717
33069
  }
32718
33070
  async function videoTools(runner = runTool) {
32719
- const [ytDlp, ffmpeg] = await Promise.all([present(runner, "yt-dlp", "--version"), present(runner, "ffmpeg", "-version")]);
33071
+ const [ytDlp, ffmpeg] = await Promise.all([present2(runner, "yt-dlp", "--version"), present2(runner, "ffmpeg", "-version")]);
32720
33072
  return { ytDlp, ffmpeg };
32721
33073
  }
32722
33074
  var missingTool = (frames) => videoError(
@@ -32776,16 +33128,16 @@ function publicVideoUrl(raw) {
32776
33128
  }
32777
33129
  async function readVideo(rawUrl, outputDir, frames, runner = runTool) {
32778
33130
  const url3 = publicVideoUrl(rawUrl);
32779
- if (frames > 0 && !await present(runner, "ffmpeg", "-version")) throw missingTool(frames);
33131
+ if (frames > 0 && !await present2(runner, "ffmpeg", "-version")) throw missingTool(frames);
32780
33132
  const directory = resolve3(outputDir);
32781
33133
  await mkdir2(directory, { recursive: true });
32782
33134
  const base = ["--ignore-config", "--no-playlist", "--quiet", "--no-warnings"];
32783
- const target = ["-o", join4(templateSafe(directory), "video.%(ext)s")];
33135
+ const target = ["-o", join5(templateSafe(directory), "video.%(ext)s")];
32784
33136
  const failed = (message, nextAction) => videoError("RESEARCH_VIDEO_FAILED", message, nextAction);
32785
33137
  const metadata = await runner("yt-dlp", [...base, "--skip-download", "--write-info-json", ...target, url3.href], 18e4).catch((error51) => {
32786
33138
  throw error51.code === "ENOENT" ? missingTool(frames) : failed("yt-dlp did not finish reading this video page.", "Retry once; a slow or blocked network leaves the video unread.");
32787
33139
  });
32788
- const info = metadata.exitCode === 0 ? JSON.parse(await readFile7(join4(directory, "video.info.json"), "utf8")) : null;
33140
+ const info = metadata.exitCode === 0 ? JSON.parse(await readFile8(join5(directory, "video.info.json"), "utf8")) : null;
32789
33141
  if (!info) {
32790
33142
  throw failed("yt-dlp could not read this video page.", "Check the address in a browser; a private or region-locked video stays unread.");
32791
33143
  }
@@ -32803,15 +33155,15 @@ async function readVideo(rawUrl, outputDir, frames, runner = runTool) {
32803
33155
  ...target,
32804
33156
  url3.href
32805
33157
  ], 18e4).catch(() => null);
32806
- const file2 = (await readdir2(directory)).find((name) => name === `video.${chosen.language}.vtt`);
33158
+ const file2 = (await readdir3(directory)).find((name) => name === `video.${chosen.language}.vtt`);
32807
33159
  if (subtitles?.exitCode !== 0 || !file2) {
32808
33160
  throw failed("The video has captions but their download failed.", "Retry in a minute; the platform may be rate-limiting.");
32809
33161
  }
32810
- segments = parseVtt(await readFile7(join4(directory, file2), "utf8"));
33162
+ segments = parseVtt(await readFile8(join5(directory, file2), "utf8"));
32811
33163
  }
32812
33164
  const duration3 = typeof info.duration === "number" ? info.duration : null;
32813
33165
  const frameFiles = [];
32814
- const output = join4(directory, "transcript.json");
33166
+ const output = join5(directory, "transcript.json");
32815
33167
  const save = () => writeJsonAtomic(
32816
33168
  output,
32817
33169
  {
@@ -32831,7 +33183,7 @@ async function readVideo(rawUrl, outputDir, frames, runner = runTool) {
32831
33183
  throw failed("The video's length is unknown, so frames cannot be spaced.", "Retry with --frames 0 to keep the captions only.");
32832
33184
  }
32833
33185
  if (frames > 0 && duration3) {
32834
- const removeMedia = async () => Promise.all((await readdir2(directory)).filter((file2) => file2.startsWith("media.")).map((file2) => rm(join4(directory, file2), { force: true })));
33186
+ const removeMedia = async () => Promise.all((await readdir3(directory)).filter((file2) => file2.startsWith("media.")).map((file2) => rm2(join5(directory, file2), { force: true })));
32835
33187
  await removeMedia();
32836
33188
  try {
32837
33189
  const download = await runner("yt-dlp", [
@@ -32839,12 +33191,12 @@ async function readVideo(rawUrl, outputDir, frames, runner = runTool) {
32839
33191
  "-f",
32840
33192
  "b[height<=480]/bv*[height<=480]/w",
32841
33193
  "-o",
32842
- join4(templateSafe(directory), "media.%(ext)s"),
33194
+ join5(templateSafe(directory), "media.%(ext)s"),
32843
33195
  url3.href
32844
33196
  ], 6e5).catch(() => {
32845
33197
  throw failed("The video download did not finish.", "Retry with --frames 0 to keep the captions only.");
32846
33198
  });
32847
- const media = (await readdir2(directory)).find((file2) => file2.startsWith("media.") && !file2.endsWith(".part"));
33199
+ const media = (await readdir3(directory)).find((file2) => file2.startsWith("media.") && !file2.endsWith(".part"));
32848
33200
  if (download.exitCode !== 0 || !media) {
32849
33201
  throw failed("The video could not be downloaded for frames.", "Retry with --frames 0 to keep the captions only.");
32850
33202
  }
@@ -32859,14 +33211,14 @@ async function readVideo(rawUrl, outputDir, frames, runner = runTool) {
32859
33211
  "-ss",
32860
33212
  String(atSeconds),
32861
33213
  "-i",
32862
- join4(directory, media),
33214
+ join5(directory, media),
32863
33215
  "-frames:v",
32864
33216
  "1",
32865
33217
  "-vf",
32866
33218
  "scale=1024:-2",
32867
- join4(directory, file2)
33219
+ join5(directory, file2)
32868
33220
  ], 6e4).catch(() => null);
32869
- if (extracted?.exitCode === 0) frameFiles.push({ file: join4(directory, file2), atSeconds });
33221
+ if (extracted?.exitCode === 0) frameFiles.push({ file: join5(directory, file2), atSeconds });
32870
33222
  }
32871
33223
  } finally {
32872
33224
  await removeMedia();
@@ -32925,7 +33277,20 @@ async function removeEverywhere(context) {
32925
33277
  await new CredentialStore(backend, context.origin.origin).removeCredential();
32926
33278
  }
32927
33279
  }
33280
+ async function forgetLegacyFolder(context) {
33281
+ const legacy = legacySibling(context.stateDirectory);
33282
+ if (legacy === null) return;
33283
+ const backend = new FileBackend(legacy);
33284
+ for (const item of ["credentials", "pending"]) {
33285
+ await backend.remove(item, context.origin.origin).catch(() => void 0);
33286
+ }
33287
+ }
32928
33288
  async function logout(context) {
33289
+ const data = await logoutHere(context);
33290
+ await forgetLegacyFolder(context);
33291
+ return data;
33292
+ }
33293
+ async function logoutHere(context) {
32929
33294
  const origin = context.origin.origin;
32930
33295
  let located;
32931
33296
  try {
@@ -32970,27 +33335,30 @@ async function showAlphaStrategies(context) {
32970
33335
  }
32971
33336
 
32972
33337
  // src/skill-install.ts
32973
- import { lstat as lstat3, mkdir as mkdir3, realpath, symlink, unlink as unlink4 } from "node:fs/promises";
33338
+ import { lstat as lstat3, mkdir as mkdir3, readlink, realpath, symlink, unlink as unlink5 } from "node:fs/promises";
32974
33339
  import { homedir as homedir2 } from "node:os";
32975
- import { join as join5, sep } from "node:path";
33340
+ import { join as join6, sep } from "node:path";
33341
+ import { fileURLToPath } from "node:url";
32976
33342
  var skillDirectories = [".agents/skills", ".claude/skills"];
32977
- function installError(message, identity) {
33343
+ var alphaSkillName = "heysurface";
33344
+ var messageLimit = 300;
33345
+ function installError(message) {
32978
33346
  return new CliError({
32979
33347
  code: "SKILL_INSTALL_FAILED",
32980
- message,
33348
+ message: message.length > messageLimit ? `${message.slice(0, messageLimit - 1)}\u2026` : message,
32981
33349
  exitCode: 4,
32982
33350
  retryable: false,
32983
- nextAction: `Check the personal Skill directories and run ${identity} skill install again. Existing files are never replaced.`,
33351
+ nextAction: "Check the personal Skill directories and run obi skill install again. Existing files are never replaced.",
32984
33352
  mode: "local"
32985
33353
  });
32986
33354
  }
32987
- async function existingPath(path, identity) {
33355
+ async function existingPath(path) {
32988
33356
  try {
32989
33357
  await lstat3(path);
32990
33358
  return true;
32991
33359
  } catch (error51) {
32992
33360
  if (error51.code === "ENOENT") return false;
32993
- throw installError(`Cannot inspect ${path}.`, identity);
33361
+ throw installError(`Cannot inspect ${path}.`);
32994
33362
  }
32995
33363
  }
32996
33364
  async function linksIntoPackage(path, packageRoot) {
@@ -32999,52 +33367,86 @@ async function linksIntoPackage(path, packageRoot) {
32999
33367
  entry = await lstat3(path);
33000
33368
  } catch (error51) {
33001
33369
  if (error51.code === "ENOENT") return false;
33002
- throw installError(`Cannot inspect ${path}.`, "obi");
33370
+ throw installError(`Cannot inspect ${path}.`);
33003
33371
  }
33004
33372
  if (!entry.isSymbolicLink()) return false;
33005
- let target;
33006
33373
  try {
33007
- target = await realpath(path);
33374
+ const target = await realpath(path);
33375
+ return target === packageRoot || target.startsWith(`${packageRoot}${sep}`);
33008
33376
  } catch {
33009
- return false;
33377
+ try {
33378
+ return await readlink(path) === join6(packageRoot, "skills", alphaSkillName);
33379
+ } catch {
33380
+ return false;
33381
+ }
33010
33382
  }
33011
- return target === packageRoot || target.startsWith(`${packageRoot}${sep}`);
33012
33383
  }
33013
- async function installSkill(sourceDirectory, identity) {
33384
+ async function installSkill(sourceDirectory) {
33014
33385
  const source = await realpath(sourceDirectory);
33015
33386
  const home = homedir2();
33016
- const destinations = skillDirectories.map((directory) => join5(home, directory, identity));
33387
+ const destinations = skillDirectories.map((directory) => join6(home, directory, "obi"));
33388
+ const registered = async (destination) => {
33389
+ try {
33390
+ return await realpath(destination) === source;
33391
+ } catch {
33392
+ return false;
33393
+ }
33394
+ };
33017
33395
  for (const destination of destinations) {
33018
- if (!await existingPath(destination, identity)) continue;
33396
+ if (!await existingPath(destination) || await registered(destination)) continue;
33397
+ let target = null;
33019
33398
  try {
33020
- if (await realpath(destination) === source) continue;
33399
+ if ((await lstat3(destination)).isSymbolicLink()) target = await readlink(destination);
33021
33400
  } catch {
33401
+ continue;
33022
33402
  }
33023
- throw installError(`A Skill entry already exists at ${destination}.`, identity);
33403
+ throw installError(target === null ? `A Skill entry already exists: a file or folder this package did not create. Move it, then run obi skill install. It is at ${destination}` : `A Skill entry already exists: a link outside this installation. To use this installation, remove that link, then run obi skill install. The link: ${destination} -> ${target}`);
33024
33404
  }
33025
33405
  for (const destination of destinations) {
33026
- if (await existingPath(destination, identity)) continue;
33406
+ if (await registered(destination)) continue;
33027
33407
  try {
33028
- await mkdir3(join5(destination, ".."), { recursive: true });
33408
+ await mkdir3(join6(destination, ".."), { recursive: true });
33029
33409
  await symlink(source, destination, process.platform === "win32" ? "junction" : "dir");
33030
33410
  } catch {
33031
- throw installError(`Could not register the ${identity === "heysurface" ? "Heysurface" : "Obi"} Skill at ${destination}.`, identity);
33411
+ if (await registered(destination)) continue;
33412
+ throw installError(`Could not register the Obi Skill. Check that its folder can be written, then run obi skill install. The link to make: ${destination}`);
33032
33413
  }
33033
33414
  }
33034
33415
  const removed = [];
33035
- if (identity === "obi") {
33036
- const packageRoot = await realpath(join5(source, "..", ".."));
33037
- for (const alpha of skillDirectories.map((directory) => join5(home, directory, "heysurface"))) {
33038
- if (!await linksIntoPackage(alpha, packageRoot)) continue;
33416
+ const packageRoot = await realpath(join6(source, "..", ".."));
33417
+ for (const alpha of skillDirectories.map((directory) => join6(home, directory, alphaSkillName))) {
33418
+ if (!await linksIntoPackage(alpha, packageRoot)) continue;
33419
+ try {
33420
+ await unlink5(alpha);
33421
+ } catch (error51) {
33422
+ if (error51.code === "ENOENT") continue;
33423
+ throw installError(`Could not retire the earlier Skill link at ${alpha}.`);
33424
+ }
33425
+ removed.push(alpha);
33426
+ }
33427
+ return { paths: destinations, removed };
33428
+ }
33429
+ function packagedSkillDirectory() {
33430
+ return fileURLToPath(new URL("../skills/obi", import.meta.url));
33431
+ }
33432
+ async function registerSkillLinks(sourceDirectory, env) {
33433
+ if (env.OBI_SKILL_LINKS === "off") return { state: "off" };
33434
+ try {
33435
+ const source = await realpath(sourceDirectory);
33436
+ let present3 = true;
33437
+ for (const directory of skillDirectories) {
33039
33438
  try {
33040
- await unlink4(alpha);
33439
+ if (await realpath(join6(homedir2(), directory, "obi")) !== source) present3 = false;
33041
33440
  } catch {
33042
- throw installError(`Could not retire the alpha /heysurface Skill link at ${alpha}.`, identity);
33441
+ present3 = false;
33043
33442
  }
33044
- removed.push(alpha);
33045
33443
  }
33444
+ if (present3) return { state: "present" };
33445
+ await installSkill(sourceDirectory);
33446
+ return { state: "created" };
33447
+ } catch (error51) {
33448
+ return { state: "failed", reason: error51 instanceof CliError ? error51.message : "The Obi Skill could not be registered." };
33046
33449
  }
33047
- return { paths: destinations, removed };
33048
33450
  }
33049
33451
 
33050
33452
  // src/transport.ts
@@ -33170,7 +33572,7 @@ async function fetchTestStatus(origin, timeoutMs) {
33170
33572
  }
33171
33573
 
33172
33574
  // src/commands.ts
33173
- var usage = "obi <business|capabilities|credentials|doctor|eval|harness|login|logout|memory|questions|readiness|research|skill|status|strategies> [--json]\n obi eval <start <domain>|list> [--json]\n Evaluation commands: add --eval-case <id> to status, business, harness, readiness, questions and strategies\n obi harness coverage [--json]\n obi harness activate --free [--json]\n obi harness show --stage <business|questions|strategies> [--packs <1-40> for questions review] [--json]\n obi harness submit --stage <business|questions|strategies> --input <file> [--json]\n obi harness outcomes --task-id <UUID> [--cursor <event-id>] [--limit <1-50>] [--json]\n obi harness observe --input <file> [--json]\n obi harness purchase <quote|prepare|status|resume|change> [--input <quote-and-basket.json>; resume: quote ID only] [--confirm-checkout for prepare] [--confirm-change for change] [--json]\n obi harness artifact <save|show|history|export> --work-id <UUID> [--input <JSON file>] [--revision <n>] [--output <new file>] [--cursor <opaque>] [--limit <1-100>] [--json]\n obi harness evidence --work-id <UUID> [--kind claims|sections|measurements] [--cursor <opaque>] [--query <text>] [--url <exact URL>] [--all --output <file>] [--json]\n obi research crawl <domain> --checkpoint <file> --output <file> [--batch-size <1-100>] [--locale <tag>] [--pages priority|all] [--max-pages <n|none>] [--retry-failed|--refresh] [--json]\n obi research capture --input <selected-page-file> --checkpoint <file> --output <corpus-file> [--json]\n obi research readiness --input <corpus-file> --output <report-file> [--json]\n obi research video <url> --output <directory> [--frames <0-30>] [--json]\n obi memory <list|add --kind <preference|constraint|decision> --text <words>|remove <id>> [--eval-case <id>] [--json]\n obi questions show [--json]\n obi questions prepare --confirm-preparation [--json]\n obi questions edit <id> --candidate-version <n> --text <wording> [--json]\n obi questions proceed --candidate-version <n> --confirm-scan [--json]\n obi questions results [--run latest|first|<run ID>] [--from <question position>] [--json]\n obi readiness [--json]\n obi strategies [--json]\n obi skill <path|install> [--json]\n obi credentials <list|revoke <credentialId>> [--force]\n obi business start --confirm-domain <domain>\n obi business show\n obi business discover --snapshot <token> --confirm-discovery\n obi business clarify-identity --snapshot <token> --company <name>\n obi business clarify-fact <itemId> --snapshot <token> --field-path <path> --text <answer> --company <current name> --company-wide [--segment-name <name> for segments.append]\n obi business challenge <itemId> --snapshot <token> --reason <reason>\n obi business correct <itemId> --snapshot <token> --claim-id <id> --field-path <path> --text <affirmative correction> --company <current name> --company-wide\n obi business remove <competitorItemId> --snapshot <token> [--reason <reason>]\n obi business <add-competitor|remove-competitor|readd-competitor> <domain> --snapshot <token> [--reason <reason>]\n obi business confirm --snapshot <token> --confirm-review\n Global options: --json, --timeout-ms <100-30000>; login: --expect-email <email> [--storage file]; status/doctor test: --test-server <origin>";
33575
+ var usage = 'obi <business|capabilities|credentials|doctor|eval|harness|login|logout|memory|questions|readiness|research|skill|status|strategies|support> [--json]\n obi support "<message>" [--tag market-request|scope-request] [--json]\n obi eval <start <domain>|list> [--json]\n Evaluation commands: add --eval-case <id> to status, business, harness, readiness, questions and strategies\n obi harness coverage [--json]\n obi harness activate --free [--json]\n obi harness show --stage <business|questions|strategies> [--packs <1-40> for questions review] [--json]\n obi harness submit --stage <business|questions|strategies> --input <file> [--json]\n obi harness outcomes --task-id <UUID> [--cursor <event-id>] [--limit <1-50>] [--json]\n obi harness observe --input <file> [--json]\n obi harness purchase <quote|prepare|status|resume|change> [--input <quote-and-basket.json>; resume: quote ID only] [--confirm-checkout for prepare] [--confirm-change for change] [--json]\n obi harness artifact <save|show|history|export> --work-id <UUID> [--input <JSON file>] [--revision <n>] [--output <new file>] [--cursor <opaque>] [--limit <1-100>] [--json]\n obi harness evidence --work-id <UUID> [--kind claims|sections|measurements] [--cursor <opaque>] [--query <text>] [--url <exact URL>] [--all --output <file>] [--json]\n obi research crawl <domain> --checkpoint <file> --output <file> [--batch-size <1-100>] [--locale <tag>] [--pages priority|all] [--max-pages <n|none>] [--retry-failed|--refresh] [--json]\n obi research capture --input <selected-page-file> --checkpoint <file> --output <corpus-file> [--json]\n obi research readiness --input <corpus-file> --output <report-file> [--json]\n obi research video <url> --output <directory> [--frames <0-30>] [--json]\n obi memory <list|add --kind <preference|constraint|decision> --text <words>|remove <id>> [--eval-case <id>] [--json]\n obi questions show [--json]\n obi questions prepare --confirm-preparation [--json]\n obi questions edit <id> --candidate-version <n> --text <wording> [--json]\n obi questions proceed --candidate-version <n> --confirm-scan [--json]\n obi questions results [--run latest|first|<run ID>] [--from <question position>] [--json]\n obi readiness [--json]\n obi strategies [--json]\n obi skill <path|install> [--json]\n obi credentials <list|revoke <credentialId>> [--force]\n obi business start --confirm-domain <domain>\n obi business show\n obi business discover --snapshot <token> --confirm-discovery\n obi business clarify-identity --snapshot <token> --company <name>\n obi business clarify-fact <itemId> --snapshot <token> --field-path <path> --text <answer> --company <current name> --company-wide [--segment-name <name> for segments.append]\n obi business challenge <itemId> --snapshot <token> --reason <reason>\n obi business correct <itemId> --snapshot <token> --claim-id <id> --field-path <path> --text <affirmative correction> --company <current name> --company-wide\n obi business remove <competitorItemId> --snapshot <token> [--reason <reason>]\n obi business <add-competitor|remove-competitor|readd-competitor> <domain> --snapshot <token> [--reason <reason>]\n obi business confirm --snapshot <token> --confirm-review\n Global options: --json, --timeout-ms <100-30000>; login: --expect-email <email> [--storage file]; status/doctor test: --test-server <origin>';
33174
33576
  function success2(command, mode, data) {
33175
33577
  return cliResultSchema.parse({ schemaVersion: 1, command, mode, ok: true, data });
33176
33578
  }
@@ -33197,7 +33599,7 @@ function statusResult(status) {
33197
33599
  }
33198
33600
  return success2("status", "test", status);
33199
33601
  }
33200
- async function localDoctor(runtime) {
33602
+ async function localDoctor(runtime, timeoutMs) {
33201
33603
  const located = await locateCredential(runtime);
33202
33604
  return success2("doctor", "local", {
33203
33605
  node: process.version,
@@ -33205,6 +33607,7 @@ async function localDoctor(runtime) {
33205
33607
  origin: runtime.origin.origin,
33206
33608
  credentialStorage: located === null ? "none" : located.store.backend.kind,
33207
33609
  videoTools: await videoTools(),
33610
+ server: await probeServer(runtime.origin, timeoutMs),
33208
33611
  diagnostic: "completed"
33209
33612
  });
33210
33613
  }
@@ -33217,7 +33620,7 @@ async function executeCommand(args, runtime) {
33217
33620
  if (args.command === "help") {
33218
33621
  return success2("help", "local", {
33219
33622
  usage,
33220
- commands: ["business", "capabilities", "credentials", "doctor", "eval", "harness", "login", "logout", "memory", "questions", "readiness", "research", "skill", "status", "strategies"]
33623
+ commands: ["business", "capabilities", "credentials", "doctor", "eval", "harness", "login", "logout", "memory", "questions", "readiness", "research", "skill", "status", "strategies", "support"]
33221
33624
  });
33222
33625
  }
33223
33626
  if (args.command === "version") {
@@ -33226,6 +33629,13 @@ async function executeCommand(args, runtime) {
33226
33629
  if (args.command === "capabilities") {
33227
33630
  return success2("capabilities", "local", {
33228
33631
  version: cliVersion,
33632
+ measurementMarkets: SUPPORTED_MARKETS,
33633
+ catalog: { version: CLI_DOLLAR_CATALOG_VERSION, currency: "usd", monthlyCents: {
33634
+ corePack: CLI_DOLLAR_PRICES.core,
33635
+ claudePerPack: CLI_DOLLAR_PRICES.claude,
33636
+ perplexityPerPack: CLI_DOLLAR_PRICES.perplexity
33637
+ } },
33638
+ support: { email: SUPPORT_EMAIL },
33229
33639
  realLogin: "available",
33230
33640
  paidExecution: "server_authorized",
33231
33641
  expertise: { manifestVersion: AI_SEARCH_COMPETENCY_VERSION, competencies: AI_SEARCH_COMPETENCIES },
@@ -33244,13 +33654,14 @@ async function executeCommand(args, runtime) {
33244
33654
  skill: { actions: ["path", "install"], options: ["--json"] },
33245
33655
  status: { options: ["--json", "--eval-case", "--test-server", "--timeout-ms"] },
33246
33656
  readiness: { options: ["--json", "--eval-case", "--timeout-ms"] },
33247
- strategies: { options: ["--json", "--eval-case", "--timeout-ms"] }
33657
+ strategies: { options: ["--json", "--eval-case", "--timeout-ms"] },
33658
+ support: { tags: [...SUPPORT_TAGS], options: ["--json", "--tag", "--timeout-ms"] }
33248
33659
  }
33249
33660
  });
33250
33661
  }
33251
33662
  if (args.command === "doctor") {
33252
33663
  if (args.testServer === void 0) {
33253
- return localDoctor(runtime);
33664
+ return localDoctor(runtime, args.timeoutMs);
33254
33665
  }
33255
33666
  const status = await fetchTestStatus(args.testServer, args.timeoutMs);
33256
33667
  return success2("doctor", "test", {
@@ -33260,7 +33671,7 @@ async function executeCommand(args, runtime) {
33260
33671
  });
33261
33672
  }
33262
33673
  if (args.command === "skill") {
33263
- const path = fileURLToPath(new URL(`../skills/${runtime.identity}/SKILL.md`, import.meta.url));
33674
+ const path = fileURLToPath2(new URL("../skills/obi/SKILL.md", import.meta.url));
33264
33675
  try {
33265
33676
  await access(path);
33266
33677
  } catch {
@@ -33273,7 +33684,7 @@ async function executeCommand(args, runtime) {
33273
33684
  mode: "local"
33274
33685
  });
33275
33686
  }
33276
- return success2("skill", "local", args.skillAction === "install" ? { action: "install", ...await installSkill(fileURLToPath(new URL(`../skills/${runtime.identity}`, import.meta.url)), runtime.identity) } : { action: "path", path });
33687
+ return success2("skill", "local", args.skillAction === "install" ? { action: "install", ...await installSkill(fileURLToPath2(new URL("../skills/obi", import.meta.url))) } : { action: "path", path });
33277
33688
  }
33278
33689
  if (args.command === "login") {
33279
33690
  return success2("login", "product", await login(session, {
@@ -33330,6 +33741,9 @@ async function executeCommand(args, runtime) {
33330
33741
  }
33331
33742
  ) : args.researchAction === "video" ? await readVideo(args.researchVideoUrl, args.researchOutput, args.researchFrames ?? 0) : args.researchAction === "capture" ? await captureResearch(args.researchInput, args.researchCheckpoint, args.researchOutput) : await assessResearch(args.researchInput, args.researchOutput));
33332
33743
  }
33744
+ if (args.command === "support") {
33745
+ return success2("support", "product", await sendSupport(session, { message: args.supportMessage, tag: args.supportTag ?? null }));
33746
+ }
33333
33747
  if (args.command === "memory") {
33334
33748
  if (args.memoryAction === "list") return success2("memory", "product", await listMemory(session));
33335
33749
  return success2("memory", "product", await changeMemory(session, args.memoryAction === "add" ? { op: "add", kind: args.memoryKind, text: args.memoryText } : { op: "remove", id: args.memoryEntryId }));
@@ -33382,23 +33796,51 @@ async function executeCommand(args, runtime) {
33382
33796
  return success2("status", "product", await readStatus(session));
33383
33797
  }
33384
33798
 
33799
+ // src/start.ts
33800
+ import { join as join7 } from "node:path";
33801
+ var linkStates = {
33802
+ created: "created",
33803
+ present: "present",
33804
+ off: "off (OBI_SKILL_LINKS), run obi skill install"
33805
+ };
33806
+ function renderStart(input) {
33807
+ const links = input.registration.state === "failed" ? `failed. ${sanitizeHumanText(input.registration.reason)}` : `${linkStates[input.registration.state]}.`;
33808
+ const account2 = input.accountEmail === null ? [
33809
+ "Account: not connected. Connect: obi login --expect-email <the user's email> (prints an address and a code for the user).",
33810
+ "Then: obi status --json"
33811
+ ] : [`Account: connected as ${sanitizeHumanText(input.accountEmail)}. Its state: obi status --json`];
33812
+ return [
33813
+ `Obi CLI ${cliVersion}, npm package @hireobi/cli. Skill links: ${links}`,
33814
+ `Agent guide, a local file in this package: ${sanitizeHumanText(join7(input.skillDirectory, "SKILL.md"))}`,
33815
+ ...account2,
33816
+ input.registration.state === "created" || input.registration.state === "present" ? "In the agent: /obi (Claude Code, Cursor), $obi (Codex) or @obi (OpenCode); /reload-skills in Claude Code if /obi is missing." : "In the agent: /obi, $obi and @obi exist once the Skill links do; until then, read the guide above.",
33817
+ 'The obi command comes only from npm i -g @hireobi/cli; the npm package named "obi" is unrelated.'
33818
+ ].join("\n") + "\n";
33819
+ }
33820
+
33385
33821
  // src/welcome.ts
33386
33822
  var copy = {
33387
33823
  en: {
33388
33824
  tagline: "Your AI Search employee.",
33389
33825
  greeting: "Hi, I'm Obi. Let's get you discovered.",
33390
- install: "Get started: obi skill install",
33826
+ ready: "I'm in your assistants: Claude Code, Codex, Cursor and OpenCode.",
33827
+ off: "Get started: obi skill install",
33828
+ failed: "I could not join your assistants.",
33391
33829
  claude: "Claude Code / Cursor: /obi",
33392
33830
  codex: "Codex: $obi or the skills picker",
33831
+ opencode: "OpenCode: @obi",
33393
33832
  next: "Then give me your website in your assistant's chat.",
33394
33833
  help: "All commands: obi --help"
33395
33834
  },
33396
33835
  fr: {
33397
33836
  tagline: "Ton agent AI Search.",
33398
33837
  greeting: "Salut, moi c'est Obi. Faisons conna\xEEtre ton entreprise.",
33399
- install: "Pour d\xE9marrer : obi skill install",
33838
+ ready: "Je suis dans tes assistants : Claude Code, Codex, Cursor et OpenCode.",
33839
+ off: "Pour d\xE9marrer : obi skill install",
33840
+ failed: "Je n'ai pas pu rejoindre tes assistants.",
33400
33841
  claude: "Claude Code / Cursor : /obi",
33401
33842
  codex: "Codex : $obi ou le s\xE9lecteur de skills",
33843
+ opencode: "OpenCode : @obi",
33402
33844
  next: "Donne-moi ensuite ton site dans ton assistant.",
33403
33845
  help: "Toutes les commandes : obi --help"
33404
33846
  }
@@ -33452,7 +33894,7 @@ function mascotLine(row, depth) {
33452
33894
  return `${color(top, false, depth)}${color(bottom, true, depth)}\u2580`;
33453
33895
  }).join("") + reset;
33454
33896
  }
33455
- function renderWelcome(env, columns, colorDepth) {
33897
+ function renderWelcome(env, columns, colorDepth, registration) {
33456
33898
  const locale = [env.OBI_LANGUAGE, env.LC_ALL, env.LC_MESSAGES, env.LANG].find((value) => value?.trim())?.trim().toLowerCase() ?? "en";
33457
33899
  const text2 = copy[/^fr(?:[-_.@]|$)/.test(locale) ? "fr" : "en"];
33458
33900
  const colorful = columns >= 64 && colorDepth >= 8 && env.TERM !== "dumb" && !env.NO_COLOR;
@@ -33461,14 +33903,16 @@ function renderWelcome(env, columns, colorDepth) {
33461
33903
  return ` ${mascotLine(row, colorDepth)} ${aside}`;
33462
33904
  }).join("\n") : `Obi \xB7 ${cliVersion}
33463
33905
  ${text2.tagline}`;
33906
+ const skill = registration.state === "failed" ? `${text2.failed} ${sanitizeHumanText(registration.reason)}` : registration.state === "off" ? text2.off : text2.ready;
33464
33907
  return `
33465
33908
  ${title}
33466
33909
 
33467
33910
  ${text2.greeting}
33468
33911
 
33469
- ${text2.install}
33912
+ ${skill}
33470
33913
  ${text2.claude}
33471
33914
  ${text2.codex}
33915
+ ${text2.opencode}
33472
33916
 
33473
33917
  ${text2.next}
33474
33918
  ${text2.help}
@@ -33490,16 +33934,19 @@ function failureResult(error51, command, mode) {
33490
33934
  nextAction: error51.nextAction
33491
33935
  },
33492
33936
  authorization: error51.authorization,
33493
- account: error51.account
33937
+ account: error51.account,
33938
+ support: error51.support
33494
33939
  });
33495
33940
  }
33496
33941
  function markOrigin(result, origin) {
33497
33942
  return origin?.development === true ? cliResultSchema.parse({ ...result, origin: origin.origin, development: true }) : result;
33498
33943
  }
33499
- async function runCli(identity) {
33944
+ async function runCli() {
33500
33945
  const argv = process.argv.slice(2);
33501
33946
  const json2 = wantsJson(argv);
33502
33947
  const welcome = argv.length === 0 && process.stdin.isTTY === true && process.stdout.isTTY === true;
33948
+ const start = argv.length === 0 && !welcome;
33949
+ const registration = await registerSkillLinks(packagedSkillDirectory(), process.env);
33503
33950
  let command = "unknown";
33504
33951
  let mode = commandMode(
33505
33952
  void 0,
@@ -33511,21 +33958,27 @@ async function runCli(identity) {
33511
33958
  const resolved = resolveOrigin(process.env);
33512
33959
  if (resolved.development && !json2 && !warned) {
33513
33960
  warned = true;
33514
- process.stderr.write(`Warning: HEYSURFACE_ORIGIN points this CLI at the development server ${sanitizeHumanText(resolved.origin)}, not at Obi.
33961
+ process.stderr.write(`Warning: OBI_ORIGIN points this CLI at the development server ${sanitizeHumanText(resolved.origin)}, not at Obi.
33515
33962
  `);
33516
33963
  }
33517
33964
  return resolved;
33518
33965
  };
33519
33966
  try {
33520
- const args = parseCommandArguments(welcome ? ["--help"] : argv);
33967
+ const args = parseCommandArguments(welcome || start ? ["--help"] : argv);
33521
33968
  command = args.command;
33522
33969
  mode = commandMode(args.command, args.testServer !== void 0);
33523
33970
  origin = activeOrigin();
33524
- const result = await executeCommand(args, {
33525
- origin,
33526
- stateDirectory: resolveStateDirectory(process.env),
33527
- identity
33528
- });
33971
+ const runtime = { origin, stateDirectory: await prepareStateDirectory(process.env) };
33972
+ if (start) {
33973
+ const located = await locateCredential(runtime, "skip");
33974
+ process.stdout.write(renderStart({
33975
+ registration,
33976
+ skillDirectory: packagedSkillDirectory(),
33977
+ accountEmail: located === null ? null : located.credential.account.email
33978
+ }));
33979
+ return;
33980
+ }
33981
+ const result = await executeCommand(args, runtime);
33529
33982
  const evaluationCaseId = args.evaluationCaseId;
33530
33983
  const scopeNext = (data) => ({
33531
33984
  ...data,
@@ -33537,9 +33990,9 @@ async function runCli(identity) {
33537
33990
  ...result.ok && result.command === "status" && result.mode === "product" ? { data: scopeNext(result.data) } : result.ok && result.command === "business" && result.data.action === "start" ? { data: scopeNext(result.data) } : {}
33538
33991
  }) : result;
33539
33992
  if (scoped.ok && welcome) {
33540
- process.stdout.write(renderWelcome(process.env, process.stdout.columns, process.stdout.getColorDepth()));
33993
+ process.stdout.write(renderWelcome(process.env, process.stdout.columns, process.stdout.getColorDepth(), registration));
33541
33994
  } else {
33542
- writeResult(markOrigin(scoped, origin), args.json, identity);
33995
+ writeResult(markOrigin(scoped, origin), args.json);
33543
33996
  }
33544
33997
  } catch (error51) {
33545
33998
  if (origin === void 0) {
@@ -33555,7 +34008,14 @@ async function runCli(identity) {
33555
34008
  retryable: false,
33556
34009
  nextAction: "Run the command again or inspect the local CLI installation."
33557
34010
  });
33558
- writeResult(markOrigin(failureResult(knownError, knownError.command ?? command, mode), origin), json2, identity);
34011
+ const failure2 = failureResult(knownError, knownError.command ?? command, mode);
34012
+ if (failure2.mode !== "test" && failure2.command !== "support" && knownError.code !== "AUTHORIZATION_PENDING") {
34013
+ await prepareStateDirectory(process.env).then((directory) => recordLastError(
34014
+ directory,
34015
+ { code: knownError.code, command: failure2.command }
34016
+ ), () => void 0);
34017
+ }
34018
+ writeResult(markOrigin(failure2, origin), json2);
33559
34019
  process.exitCode = knownError.exitCode;
33560
34020
  } finally {
33561
34021
  closeIdleConnections();
@@ -33563,4 +34023,4 @@ async function runCli(identity) {
33563
34023
  }
33564
34024
 
33565
34025
  // src/obi.ts
33566
- void runCli("obi");
34026
+ void runCli();