opensteer 0.8.4 → 0.8.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli/bin.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { assertProviderSupportsEngine, createOpensteerSemanticRuntime, OpensteerBrowserManager, dispatchSemanticOperation, pathExists, resolveOpensteerEngineName, normalizeOpensteerProviderKind, discoverLocalCdpBrowsers, inspectCdpEndpoint, resolveOpensteerRuntimeConfig, resolveOpensteerProvider, resolveFilesystemWorkspacePath, readPersistedLocalBrowserSessionRecord, readPersistedCloudSessionRecord, OpensteerCloudClient, isProcessRunning } from '../chunk-C7GWMSTV.js';
2
+ import { assertProviderSupportsEngine, createOpensteerSemanticRuntime, OpensteerBrowserManager, dispatchSemanticOperation, pathExists, normalizeOpensteerProviderMode, discoverLocalCdpBrowsers, inspectCdpEndpoint, resolveOpensteerRuntimeConfig, resolveOpensteerEngineName, resolveOpensteerProvider, resolveFilesystemWorkspacePath, readPersistedLocalBrowserSessionRecord, readPersistedCloudSessionRecord, OpensteerCloudClient, isProcessRunning } from '../chunk-KYRC6CLB.js';
3
3
  import process2 from 'process';
4
4
  import { readFile } from 'fs/promises';
5
5
  import path2 from 'path';
@@ -8,6 +8,9 @@ import { existsSync } from 'fs';
8
8
  import { createRequire } from 'module';
9
9
  import { fileURLToPath } from 'url';
10
10
 
11
+ // package.json
12
+ var package_default = {
13
+ version: "0.8.6"};
11
14
  var ENV_FILENAMES = [".env", ".env.local"];
12
15
  async function loadCliEnvironment(cwd) {
13
16
  const protectedKeys = new Set(Object.keys(process.env));
@@ -163,7 +166,7 @@ function resolveSelectedSkills(options) {
163
166
  async function collectOpensteerStatus(input) {
164
167
  const output = {
165
168
  provider: {
166
- current: input.provider.kind,
169
+ current: input.provider.mode,
167
170
  source: mapProviderSource(input.provider.source),
168
171
  ...input.cloudConfig === void 0 ? {} : { cloudBaseUrl: input.cloudConfig.baseUrl }
169
172
  },
@@ -182,10 +185,10 @@ async function collectOpensteerStatus(input) {
182
185
  ...output,
183
186
  rootPath,
184
187
  lanes: {
185
- local: describeLocalLane(localRecord, input.provider.kind === "local"),
188
+ local: describeLocalLane(localRecord, input.provider.mode === "local"),
186
189
  cloud: await describeCloudLane({
187
190
  record: cloudRecord,
188
- current: input.provider.kind === "cloud",
191
+ current: input.provider.mode === "cloud",
189
192
  cloudConfig: input.cloudConfig
190
193
  })
191
194
  }
@@ -371,12 +374,18 @@ var OPERATION_ALIASES = /* @__PURE__ */ new Map([
371
374
  ["close", "session.close"]
372
375
  ]);
373
376
  async function main() {
374
- await loadCliEnvironment(process2.cwd());
375
- const parsed = parseCommandLine(process2.argv.slice(2));
376
- if (parsed.help || parsed.command.length === 0) {
377
+ const argv = process2.argv.slice(2);
378
+ const bootstrapAction = resolveCliBootstrapAction(argv);
379
+ if (bootstrapAction === "version") {
380
+ printVersion();
381
+ return;
382
+ }
383
+ if (bootstrapAction === "help") {
377
384
  printHelp();
378
385
  return;
379
386
  }
387
+ await loadCliEnvironment(process2.cwd());
388
+ const parsed = parseCommandLine(argv);
380
389
  if (parsed.command[0] === "browser") {
381
390
  await handleBrowserCommand(parsed);
382
391
  return;
@@ -407,15 +416,16 @@ async function main() {
407
416
  if (parsed.options.workspace === void 0) {
408
417
  throw new Error('Stateful commands require "--workspace <id>".');
409
418
  }
419
+ const engineName = resolveCliEngineName(parsed);
410
420
  const provider = resolveCliProvider(parsed);
411
- assertProviderSupportsEngine(provider.kind, parsed.options.engineName);
412
- assertCloudCliOptionsMatchProvider(parsed, provider.kind);
413
- const runtimeProvider = buildCliRuntimeProvider(parsed, provider.kind);
421
+ assertProviderSupportsEngine(provider.mode, engineName);
422
+ assertCloudCliOptionsMatchProvider(parsed, provider.mode);
423
+ const runtimeProvider = buildCliRuntimeProvider(parsed, provider.mode);
414
424
  if (operation === "session.close") {
415
- if (provider.kind === "cloud") {
425
+ if (provider.mode === "cloud") {
416
426
  const runtime2 = createOpensteerSemanticRuntime({
417
427
  ...runtimeProvider === void 0 ? {} : { provider: runtimeProvider },
418
- engine: parsed.options.engineName,
428
+ engine: engineName,
419
429
  runtimeOptions: {
420
430
  workspace: parsed.options.workspace,
421
431
  rootDir: process2.cwd(),
@@ -432,7 +442,7 @@ async function main() {
432
442
  const manager = new OpensteerBrowserManager({
433
443
  rootDir: process2.cwd(),
434
444
  workspace: parsed.options.workspace,
435
- engineName: parsed.options.engineName,
445
+ engineName,
436
446
  browser: "persistent",
437
447
  ...parsed.options.launch === void 0 ? {} : { launch: parsed.options.launch },
438
448
  ...parsed.options.context === void 0 ? {} : { context: parsed.options.context }
@@ -444,7 +454,7 @@ async function main() {
444
454
  }
445
455
  const runtime = createOpensteerSemanticRuntime({
446
456
  ...runtimeProvider === void 0 ? {} : { provider: runtimeProvider },
447
- engine: parsed.options.engineName,
457
+ engine: engineName,
448
458
  runtimeOptions: {
449
459
  workspace: parsed.options.workspace,
450
460
  rootDir: process2.cwd(),
@@ -498,10 +508,11 @@ async function handleBrowserCommand(parsed) {
498
508
  if (parsed.options.workspace === void 0) {
499
509
  throw new Error('Browser workspace commands require "--workspace <id>".');
500
510
  }
511
+ const engineName = resolveCliEngineName(parsed);
501
512
  const manager = new OpensteerBrowserManager({
502
513
  rootDir: process2.cwd(),
503
514
  workspace: parsed.options.workspace,
504
- ...parsed.options.engineName === void 0 ? {} : { engineName: parsed.options.engineName },
515
+ engineName,
505
516
  browser: "persistent",
506
517
  ...parsed.options.launch === void 0 ? {} : { launch: parsed.options.launch },
507
518
  ...parsed.options.context === void 0 ? {} : { context: parsed.options.context }
@@ -633,14 +644,8 @@ function parseCommandLine(argv) {
633
644
  const commandTokens = leadingTokens.slice(0, commandLength);
634
645
  const rest = leadingTokens.slice(commandLength);
635
646
  const rawOptions = /* @__PURE__ */ new Map();
636
- let help = false;
637
647
  while (index < argv.length) {
638
648
  const token = argv[index];
639
- if (token === "--help" || token === "-h") {
640
- help = true;
641
- index += 1;
642
- continue;
643
- }
644
649
  if (!token.startsWith("--")) {
645
650
  rest.push(token);
646
651
  index += 1;
@@ -657,11 +662,7 @@ function parseCommandLine(argv) {
657
662
  index += 2;
658
663
  }
659
664
  const browserKind = readSingle(rawOptions, "browser");
660
- const requestedEngine = readSingle(rawOptions, "engine");
661
- const engineName = resolveOpensteerEngineName({
662
- ...requestedEngine === void 0 ? {} : { requested: requestedEngine },
663
- ...process2.env.OPENSTEER_ENGINE === void 0 ? {} : { environment: process2.env.OPENSTEER_ENGINE }
664
- });
665
+ const requestedEngineName = readSingle(rawOptions, "engine");
665
666
  const attachEndpoint = readSingle(rawOptions, "attach-endpoint");
666
667
  const attachHeaders = parseKeyValueList(rawOptions.get("attach-header"));
667
668
  const freshTab = readOptionalBoolean(rawOptions, "fresh-tab");
@@ -700,7 +701,7 @@ function parseCommandLine(argv) {
700
701
  const inputJson = readJsonObject(rawOptions, "input-json");
701
702
  const schemaJson = readJsonObject(rawOptions, "schema-json");
702
703
  const providerValue = readSingle(rawOptions, "provider");
703
- const provider = providerValue === void 0 ? void 0 : normalizeOpensteerProviderKind(providerValue, "--provider");
704
+ const provider = providerValue === void 0 ? void 0 : normalizeOpensteerProviderMode(providerValue, "--provider");
704
705
  const cloudBaseUrl = readSingle(rawOptions, "cloud-base-url");
705
706
  const cloudApiKey = readSingle(rawOptions, "cloud-api-key");
706
707
  const cloudProfileId = readSingle(rawOptions, "cloud-profile-id");
@@ -718,7 +719,7 @@ function parseCommandLine(argv) {
718
719
  const list = readOptionalBoolean(rawOptions, "list");
719
720
  const options = {
720
721
  ...workspace === void 0 ? {} : { workspace },
721
- engineName,
722
+ ...requestedEngineName === void 0 ? {} : { requestedEngineName },
722
723
  ...provider === void 0 ? {} : { provider },
723
724
  ...cloudBaseUrl === void 0 ? {} : { cloudBaseUrl },
724
725
  ...cloudApiKey === void 0 ? {} : { cloudApiKey },
@@ -752,10 +753,23 @@ function parseCommandLine(argv) {
752
753
  return {
753
754
  command: commandTokens,
754
755
  rest,
755
- options,
756
- help
756
+ options
757
757
  };
758
758
  }
759
+ function resolveCliBootstrapAction(argv) {
760
+ if (argv.length === 0) {
761
+ return "help";
762
+ }
763
+ for (const token of argv) {
764
+ if (token === "--version") {
765
+ return "version";
766
+ }
767
+ if (token === "--help" || token === "-h") {
768
+ return "help";
769
+ }
770
+ }
771
+ return void 0;
772
+ }
759
773
  function buildCliBrowserProfile(parsed) {
760
774
  if (parsed.options.cloudProfileReuseIfActive === true && parsed.options.cloudProfileId === void 0) {
761
775
  throw new Error('"--cloud-profile-reuse-if-active" requires "--cloud-profile-id <id>".');
@@ -767,13 +781,19 @@ function buildCliBrowserProfile(parsed) {
767
781
  }
768
782
  function buildCliExplicitProvider(parsed) {
769
783
  if (parsed.options.provider === "local") {
770
- return { kind: "local" };
784
+ return { mode: "local" };
771
785
  }
772
786
  if (parsed.options.provider === "cloud") {
773
- return { kind: "cloud" };
787
+ return { mode: "cloud" };
774
788
  }
775
789
  return void 0;
776
790
  }
791
+ function resolveCliEngineName(parsed) {
792
+ return resolveOpensteerEngineName({
793
+ ...parsed.options.requestedEngineName === void 0 ? {} : { requested: parsed.options.requestedEngineName },
794
+ ...process2.env.OPENSTEER_ENGINE === void 0 ? {} : { environment: process2.env.OPENSTEER_ENGINE }
795
+ });
796
+ }
777
797
  function resolveCliProvider(parsed) {
778
798
  const explicitProvider = buildCliExplicitProvider(parsed);
779
799
  return resolveOpensteerProvider({
@@ -781,25 +801,25 @@ function resolveCliProvider(parsed) {
781
801
  ...process2.env.OPENSTEER_PROVIDER === void 0 ? {} : { environmentProvider: process2.env.OPENSTEER_PROVIDER }
782
802
  });
783
803
  }
784
- function buildCliRuntimeProvider(parsed, providerKind) {
804
+ function buildCliRuntimeProvider(parsed, providerMode) {
785
805
  const explicitProvider = buildCliExplicitProvider(parsed);
786
- if (providerKind === "local") {
787
- return explicitProvider?.kind === "local" ? explicitProvider : void 0;
806
+ if (providerMode === "local") {
807
+ return explicitProvider?.mode === "local" ? explicitProvider : void 0;
788
808
  }
789
809
  const browserProfile = buildCliBrowserProfile(parsed);
790
810
  const hasCloudOverrides = parsed.options.cloudBaseUrl !== void 0 || parsed.options.cloudApiKey !== void 0 || browserProfile !== void 0;
791
- if (!hasCloudOverrides && explicitProvider?.kind !== "cloud") {
811
+ if (!hasCloudOverrides && explicitProvider?.mode !== "cloud") {
792
812
  return void 0;
793
813
  }
794
814
  return {
795
- kind: "cloud",
815
+ mode: "cloud",
796
816
  ...parsed.options.cloudBaseUrl === void 0 ? {} : { baseUrl: parsed.options.cloudBaseUrl },
797
817
  ...parsed.options.cloudApiKey === void 0 ? {} : { apiKey: parsed.options.cloudApiKey },
798
818
  ...browserProfile === void 0 ? {} : { browserProfile }
799
819
  };
800
820
  }
801
- function assertCloudCliOptionsMatchProvider(parsed, providerKind) {
802
- if (providerKind !== "cloud" && (parsed.options.cloudBaseUrl !== void 0 || parsed.options.cloudApiKey !== void 0 || parsed.options.cloudProfileId !== void 0 || parsed.options.cloudProfileReuseIfActive === true)) {
821
+ function assertCloudCliOptionsMatchProvider(parsed, providerMode) {
822
+ if (providerMode !== "cloud" && (parsed.options.cloudBaseUrl !== void 0 || parsed.options.cloudApiKey !== void 0 || parsed.options.cloudProfileId !== void 0 || parsed.options.cloudProfileReuseIfActive === true)) {
803
823
  throw new Error(
804
824
  'Cloud-specific options require provider=cloud. Set "--provider cloud" or OPENSTEER_PROVIDER=cloud.'
805
825
  );
@@ -807,8 +827,8 @@ function assertCloudCliOptionsMatchProvider(parsed, providerKind) {
807
827
  }
808
828
  async function handleStatusCommand(parsed) {
809
829
  const provider = resolveCliProvider(parsed);
810
- assertCloudCliOptionsMatchProvider(parsed, provider.kind);
811
- const runtimeProvider = buildCliRuntimeProvider(parsed, provider.kind);
830
+ assertCloudCliOptionsMatchProvider(parsed, provider.mode);
831
+ const runtimeProvider = buildCliRuntimeProvider(parsed, provider.mode);
812
832
  const runtimeConfig = resolveOpensteerRuntimeConfig({
813
833
  ...runtimeProvider === void 0 ? {} : { provider: runtimeProvider },
814
834
  ...process2.env.OPENSTEER_PROVIDER === void 0 ? {} : { environmentProvider: process2.env.OPENSTEER_PROVIDER }
@@ -929,6 +949,8 @@ Usage:
929
949
  opensteer run <semantic-operation> --workspace <id> --input-json <json>
930
950
 
931
951
  Common options:
952
+ --help
953
+ --version
932
954
  --workspace <id>
933
955
  --provider local|cloud
934
956
  --cloud-base-url <url>
@@ -950,6 +972,10 @@ Common options:
950
972
  --agent <name> repeatable
951
973
  `);
952
974
  }
975
+ function printVersion() {
976
+ process2.stdout.write(`${package_default.version}
977
+ `);
978
+ }
953
979
  main().catch((error) => {
954
980
  const payload = error instanceof Error ? {
955
981
  error: {