@aopslab/aops-cli 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,9 +1,19 @@
1
1
  # @aopslab/aops-cli
2
2
 
3
- AOPS Community operator CLI for an existing local or remote AOPS server.
3
+ AOPS Community operator CLI. The global CLI controls the local AOPS server,
4
+ including setup, start, stop, status, health, authentication, and agent-facing
5
+ operations.
4
6
 
5
- Install globally with `npm install --global @aopslab/aops-cli`, or run once with
6
- `npx --yes --package @aopslab/aops-cli aops-cli --help`.
7
+ ```sh
8
+ npm install --global @aopslab/aops-cli
9
+ aops-cli --help
10
+ aops-cli setup server-env
11
+ aops-cli server setup --runtime native --postgres external --apply
12
+ ```
7
13
 
8
- The public source distribution is available with
9
- `git clone https://github.com/eeemzs/aops-community.git`.
14
+ The npm installation includes the matching `@aopslab/aops-server` runtime, so
15
+ the default setup path does not require Git or a source checkout. Advanced
16
+ users can still run an explicit AOPS Community checkout with `--source-root`.
17
+
18
+ Server data, configuration, credentials, logs, and lifecycle state are stored
19
+ outside npm's package directory. PostgreSQL remains operator-owned.
@@ -1,13 +1,10 @@
1
- AOPS Community Product Third-Party Notices
2
-
3
- This file is generated deterministically from the exact production payload union.
4
- pnpm: 11.9.0
5
- pnpm lockfile: sha256:fb0c58e5687f5518b120c058a8dd1089682005bafdb3c77915a0fcf038b60cc2
6
- Platforms: linux/amd64, linux/arm64
7
- Payloads: server production deploy, separate CLI artifact production deploy, Cockpit emitted bundle
8
- Third-party packages: 295
9
- First-party source records excluded from the sections below: 31
10
- First-party registry packages excluded from the sections below: 22
1
+ AOPS Community Third-Party Notices
2
+
3
+ This file preserves the reviewed license notices for third-party components
4
+ used by the AOPS Community CLI, server, and Cockpit. It is intentionally a
5
+ conservative superset: a particular installation may use fewer components.
6
+ The exact dependency closure of an npm server release is recorded in that
7
+ package's npm-shrinkwrap.json.
11
8
 
12
9
  ================================================================================
13
10
  @drizzle-team/brocli@0.10.2
package/dist/aops-cli.mjs CHANGED
@@ -12,11 +12,20 @@ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require
12
12
  if (typeof require !== "undefined") return require.apply(this, arguments);
13
13
  throw Error('Dynamic require of "' + x + '" is not supported');
14
14
  });
15
- var __esm = (fn, res) => function __init() {
16
- return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
15
+ var __esm = (fn, res, err) => function __init() {
16
+ if (err) throw err[0];
17
+ try {
18
+ return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
19
+ } catch (e) {
20
+ throw err = [e], e;
21
+ }
17
22
  };
18
23
  var __commonJS = (cb, mod) => function __require2() {
19
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
24
+ try {
25
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
26
+ } catch (e) {
27
+ throw mod = 0, e;
28
+ }
20
29
  };
21
30
  var __export = (target, all) => {
22
31
  for (var name in all)
@@ -70945,7 +70954,7 @@ function compareCore(left, right) {
70945
70954
  return 0;
70946
70955
  }
70947
70956
  function resolveCommunityCliIdentity(environment = process.env) {
70948
- const injectedVersion = true ? "0.1.1" : void 0;
70957
+ const injectedVersion = true ? "0.1.3" : void 0;
70949
70958
  const version = nonEmpty(environment.AOPS_CLI_VERSION) ?? nonEmpty(injectedVersion) ?? "0.0.1";
70950
70959
  if (!validSemver(version)) throw new Error("community_cli_version_invalid");
70951
70960
  const injectedSource = true ? "public-release-bundle" : void 0;
@@ -84385,6 +84394,7 @@ function buildCommunityInstanceContract(input) {
84385
84394
  // apps/aops-cli/src/lib/community-native-lifecycle.ts
84386
84395
  import { createHash as createHash14, randomBytes as randomBytes8, randomUUID as randomUUID7 } from "node:crypto";
84387
84396
  import { spawn as spawn5 } from "node:child_process";
84397
+ import { createRequire as createRequire3 } from "node:module";
84388
84398
  import {
84389
84399
  closeSync as closeSync8,
84390
84400
  existsSync as existsSync13,
@@ -87308,6 +87318,7 @@ var COMMUNITY_STRICT_MIGRATION_TABLES_V1 = Object.freeze({
87308
87318
  import { lstatSync as lstatSync11, readFileSync as readFileSync13, realpathSync as realpathSync11 } from "node:fs";
87309
87319
  import path22 from "node:path";
87310
87320
  var COMMUNITY_NATIVE_MIGRATION_POLICY_PATH = "apps/aops-server/scripts/community-migration-policy-v1.json";
87321
+ var COMMUNITY_NATIVE_PACKAGE_MIGRATION_POLICY_PATH = "scripts/community-migration-policy-v1.json";
87311
87322
  var MAX_POLICY_BYTES = 2 * 1024 * 1024;
87312
87323
  var INSTANCE_NAME2 = /^[a-z0-9](?:[a-z0-9-]{0,30}[a-z0-9])?$/;
87313
87324
  var UUID4 = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
@@ -87338,7 +87349,15 @@ function readCommunityNativeMigrationPolicy(sourceRoot) {
87338
87349
  if (path22.relative(resolvedRoot, canonicalRoot) !== "" || path22.relative(canonicalRoot, resolvedRoot) !== "") {
87339
87350
  throw new Error("community_native_migration_source_root_alias_refused");
87340
87351
  }
87341
- const policyPath = path22.resolve(canonicalRoot, ...COMMUNITY_NATIVE_MIGRATION_POLICY_PATH.split("/"));
87352
+ const manifest = (() => {
87353
+ try {
87354
+ return JSON.parse(readFileSync13(path22.join(canonicalRoot, "package.json"), "utf8"));
87355
+ } catch {
87356
+ return {};
87357
+ }
87358
+ })();
87359
+ const relativePolicyPath = manifest.name === "@aopslab/aops-server" ? COMMUNITY_NATIVE_PACKAGE_MIGRATION_POLICY_PATH : COMMUNITY_NATIVE_MIGRATION_POLICY_PATH;
87360
+ const policyPath = path22.resolve(canonicalRoot, ...relativePolicyPath.split("/"));
87342
87361
  if (!isWithin4(canonicalRoot, policyPath)) throw new Error("community_native_migration_policy_path_escape");
87343
87362
  const stats = lstatSync11(policyPath);
87344
87363
  if (!stats.isFile() || stats.isSymbolicLink() || stats.size < 1 || stats.size > MAX_POLICY_BYTES) {
@@ -88749,6 +88768,7 @@ function inspectCommunityNativeApplicationRecoveryStatus(paths) {
88749
88768
 
88750
88769
  // apps/aops-cli/src/lib/community-native-lifecycle.ts
88751
88770
  var PUBLIC_ROOT_NAME = "aops-community-distribution";
88771
+ var PUBLIC_SERVER_PACKAGE_NAME = "@aopslab/aops-server";
88752
88772
  var PUBLIC_PACKAGE_MANAGER = /^pnpm@(11\.[0-9]+\.[0-9]+)$/;
88753
88773
  var RELEASE_VERSION4 = /^(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)\.(?:0|[1-9]\d*)(?:-[0-9A-Za-z]+(?:\.[0-9A-Za-z]+)*)?(?:\+[0-9A-Za-z]+(?:\.[0-9A-Za-z]+)*)?$/;
88754
88774
  var INSTANCE_NAME4 = /^[a-z0-9](?:[a-z0-9-]{0,30}[a-z0-9])?$/;
@@ -88784,7 +88804,7 @@ var RUNTIME_INVENTORY_EXCLUDED_DIRECTORIES = /* @__PURE__ */ new Set([
88784
88804
  "coverage",
88785
88805
  "node_modules"
88786
88806
  ]);
88787
- var REQUIRED_SOURCE_PATHS = Object.freeze([
88807
+ var CHECKOUT_REQUIRED_SOURCE_PATHS = Object.freeze([
88788
88808
  "apps/aops-cli/package.json",
88789
88809
  "apps/aops-cockpit-v2/package.json",
88790
88810
  "apps/aops-server/package.json",
@@ -88794,11 +88814,31 @@ var REQUIRED_SOURCE_PATHS = Object.freeze([
88794
88814
  "pnpm-lock.yaml",
88795
88815
  "pnpm-workspace.yaml"
88796
88816
  ]);
88797
- var REQUIRED_BUILD_PATHS = Object.freeze({
88817
+ var CHECKOUT_BUILD_PATHS = Object.freeze({
88798
88818
  hostEntry: "apps/aops-server/scripts/community-host.mjs",
88799
88819
  handlerEntry: "apps/aops-server/build/handler.js",
88800
88820
  cockpitIndex: "apps/aops-cockpit-v2/dist/index.html"
88801
88821
  });
88822
+ var PACKAGE_REQUIRED_SOURCE_PATHS = Object.freeze([
88823
+ "aops-server-runtime.json",
88824
+ "community-postgres.json",
88825
+ "npm-shrinkwrap.json",
88826
+ "package.json",
88827
+ "runtime/agentspace-host-adapter.mjs",
88828
+ "runtime/agentspace-tooling.mjs",
88829
+ "runtime/docman-host-adapter.mjs",
88830
+ "runtime/docman-policy.mjs",
88831
+ "runtime/docman-tooling.mjs",
88832
+ "runtime/projectman-host-adapter.mjs",
88833
+ "runtime/scope-context.mjs",
88834
+ "scripts/community-host.mjs",
88835
+ "scripts/community-migration-policy-v1.json"
88836
+ ]);
88837
+ var PACKAGE_BUILD_PATHS = Object.freeze({
88838
+ hostEntry: "scripts/community-host.mjs",
88839
+ handlerEntry: "build/handler.js",
88840
+ cockpitIndex: "cockpit/index.html"
88841
+ });
88802
88842
  function sha2566(content) {
88803
88843
  return `sha256:${createHash14("sha256").update(content).digest("hex")}`;
88804
88844
  }
@@ -89078,7 +89118,8 @@ function parseNativeState(value, paths) {
89078
89118
  input.build.runtimeInventorySha256,
89079
89119
  input.build.buildFingerprint
89080
89120
  ].every((item) => SHA2567.test(String(item))) || input.server.host !== "127.0.0.1" || !validPort(input.server.port)) throw new Error("community_native_state_schema_invalid");
89081
- if (!samePhysicalPath(input.build.hostEntry, path25.join(input.source.root, REQUIRED_BUILD_PATHS.hostEntry)) || !samePhysicalPath(input.build.handlerEntry, path25.join(input.source.root, REQUIRED_BUILD_PATHS.handlerEntry)) || !samePhysicalPath(input.build.cockpitIndex, path25.join(input.source.root, REQUIRED_BUILD_PATHS.cockpitIndex))) throw new Error("community_native_state_build_path_mismatch");
89121
+ const layout = sourceLayout(input.source.root);
89122
+ if (!samePhysicalPath(input.build.hostEntry, path25.join(input.source.root, layout.buildPaths.hostEntry)) || !samePhysicalPath(input.build.handlerEntry, path25.join(input.source.root, layout.buildPaths.handlerEntry)) || !samePhysicalPath(input.build.cockpitIndex, path25.join(input.source.root, layout.buildPaths.cockpitIndex))) throw new Error("community_native_state_build_path_mismatch");
89082
89123
  if (input.profile === "native-external-postgres") {
89083
89124
  exactKeys5(input.postgres, ["mode", "configRef", "tlsPolicy"], "community_native_state_postgres_invalid");
89084
89125
  if (input.postgres.mode !== "external" || !path25.isAbsolute(input.postgres.configRef) || !["disable", "require", "verify-full"].includes(input.postgres.tlsPolicy)) throw new Error("community_native_state_postgres_invalid");
@@ -89358,6 +89399,51 @@ function sourcePackage(root) {
89358
89399
  throw new Error("community_native_source_package_json_invalid");
89359
89400
  }
89360
89401
  }
89402
+ function sourceLayout(root, manifest = sourcePackage(root)) {
89403
+ if (manifest.name === PUBLIC_ROOT_NAME && manifest.private === true && typeof manifest.version === "string" && RELEASE_VERSION4.test(manifest.version) && typeof manifest.packageManager === "string" && PUBLIC_PACKAGE_MANAGER.test(manifest.packageManager)) {
89404
+ return {
89405
+ kind: "checkout",
89406
+ requiredSourcePaths: CHECKOUT_REQUIRED_SOURCE_PATHS,
89407
+ lockfilePath: "pnpm-lock.yaml",
89408
+ buildPaths: CHECKOUT_BUILD_PATHS
89409
+ };
89410
+ }
89411
+ if (manifest.name === PUBLIC_SERVER_PACKAGE_NAME && manifest.private !== true && typeof manifest.version === "string" && RELEASE_VERSION4.test(manifest.version) && typeof manifest.packageManager === "string" && PUBLIC_PACKAGE_MANAGER.test(manifest.packageManager)) {
89412
+ const markerPath = safeRegularFile(root, "aops-server-runtime.json");
89413
+ let marker;
89414
+ try {
89415
+ marker = JSON.parse(readFileSync16(markerPath, "utf8"));
89416
+ } catch {
89417
+ throw new Error("community_native_server_package_marker_invalid");
89418
+ }
89419
+ if (marker.schemaVersion !== 1 || marker.kind !== "aops-server-npm-runtime" || marker.packageName !== manifest.name || marker.packageVersion !== manifest.version || marker.packageManager !== manifest.packageManager || !marker.source || typeof marker.source !== "object" || Object.keys(marker.source).sort().join(",") !== "commit,repository" || marker.source.repository !== "https://github.com/eeemzs/aops-community" || !/^[a-f0-9]{40}$/.test(String(marker.source.commit ?? "")) || JSON.stringify(marker.source) !== JSON.stringify(manifest.aopsSource) || Object.keys(marker).sort().join(",") !== "kind,packageManager,packageName,packageVersion,schemaVersion,source") throw new Error("community_native_server_package_marker_invalid");
89420
+ return {
89421
+ kind: "npm-package",
89422
+ requiredSourcePaths: PACKAGE_REQUIRED_SOURCE_PATHS,
89423
+ lockfilePath: "npm-shrinkwrap.json",
89424
+ buildPaths: PACKAGE_BUILD_PATHS
89425
+ };
89426
+ }
89427
+ throw new Error("community_native_public_source_required");
89428
+ }
89429
+ function isPackagedCommunityServerSource(source) {
89430
+ return sourceLayout(source.root).kind === "npm-package";
89431
+ }
89432
+ function isCommunityNativeNpmPackageSource(sourceRoot) {
89433
+ const resolved = path25.resolve(sourceRoot);
89434
+ return sourceLayout(realpathSync14(resolved)).kind === "npm-package";
89435
+ }
89436
+ function resolveCommunityNativeDefaultSourceRoot(fallbackRoot = process.cwd(), moduleUrl = import.meta.url) {
89437
+ try {
89438
+ const require2 = createRequire3(moduleUrl);
89439
+ const packageJsonPath = require2.resolve(`${PUBLIC_SERVER_PACKAGE_NAME}/package.json`);
89440
+ const packageRoot = path25.dirname(packageJsonPath);
89441
+ sourceLayout(packageRoot);
89442
+ return packageRoot;
89443
+ } catch {
89444
+ return path25.resolve(fallbackRoot);
89445
+ }
89446
+ }
89361
89447
  function inspectCommunityNativeSource(sourceRoot = process.cwd()) {
89362
89448
  const resolved = path25.resolve(sourceRoot);
89363
89449
  let rootStats;
@@ -89369,10 +89455,10 @@ function inspectCommunityNativeSource(sourceRoot = process.cwd()) {
89369
89455
  if (!rootStats.isDirectory() || rootStats.isSymbolicLink()) throw new Error("community_native_source_root_invalid");
89370
89456
  const root = realpathSync14(resolved);
89371
89457
  const manifest = sourcePackage(root);
89372
- if (manifest.name !== PUBLIC_ROOT_NAME || manifest.private !== true || typeof manifest.version !== "string" || !RELEASE_VERSION4.test(manifest.version) || typeof manifest.packageManager !== "string" || !PUBLIC_PACKAGE_MANAGER.test(manifest.packageManager)) throw new Error("community_native_public_checkout_required");
89373
- for (const relativePath3 of REQUIRED_SOURCE_PATHS) safeRegularFile(root, relativePath3);
89458
+ const layout = sourceLayout(root, manifest);
89459
+ for (const relativePath3 of layout.requiredSourcePaths) safeRegularFile(root, relativePath3);
89374
89460
  const packageSha256 = hashFile(path25.join(root, "package.json"));
89375
- const lockfileSha256 = hashFile(path25.join(root, "pnpm-lock.yaml"));
89461
+ const lockfileSha256 = hashFile(path25.join(root, layout.lockfilePath));
89376
89462
  const postgresProfileSha256 = hashFile(path25.join(root, COMMUNITY_NATIVE_POSTGRES_CONTRACT_PATH));
89377
89463
  const sourceInventory = inventoryCommunityNativeTree(root, SOURCE_INVENTORY_EXCLUDED_DIRECTORIES);
89378
89464
  return {
@@ -89397,9 +89483,10 @@ function inspectCommunityNativeSource(sourceRoot = process.cwd()) {
89397
89483
  }
89398
89484
  function inspectCommunityNativeBuild(source, completedAt, currentSource = inspectCommunityNativeSource(source.root)) {
89399
89485
  if (currentSource.packageSha256 !== source.packageSha256 || currentSource.lockfileSha256 !== source.lockfileSha256 || currentSource.sourceFileCount !== source.sourceFileCount || currentSource.sourceInventorySha256 !== source.sourceInventorySha256 || currentSource.sourceFingerprint !== source.sourceFingerprint) throw new Error("community_native_source_changed_during_build");
89400
- const hostEntry = safeRegularFile(source.root, REQUIRED_BUILD_PATHS.hostEntry);
89401
- const handlerEntry = safeRegularFile(source.root, REQUIRED_BUILD_PATHS.handlerEntry);
89402
- const cockpitIndex = safeRegularFile(source.root, REQUIRED_BUILD_PATHS.cockpitIndex);
89486
+ const layout = sourceLayout(source.root);
89487
+ const hostEntry = safeRegularFile(source.root, layout.buildPaths.hostEntry);
89488
+ const handlerEntry = safeRegularFile(source.root, layout.buildPaths.handlerEntry);
89489
+ const cockpitIndex = safeRegularFile(source.root, layout.buildPaths.cockpitIndex);
89403
89490
  const hostEntrySha256 = hashFile(hostEntry);
89404
89491
  const handlerEntrySha256 = hashFile(handlerEntry);
89405
89492
  const cockpitIndexSha256 = hashFile(cockpitIndex);
@@ -90599,7 +90686,9 @@ async function setupCommunityNativeInstall(params) {
90599
90686
  }
90600
90687
  assertCommunityNativeApplicationCurrent(inspection.state);
90601
90688
  }
90602
- const source = inspectCommunityNativeSource(params.sourceRoot ?? process.cwd());
90689
+ const source = inspectCommunityNativeSource(
90690
+ params.sourceRoot ?? resolveCommunityNativeDefaultSourceRoot()
90691
+ );
90603
90692
  let configRef;
90604
90693
  if (params.contract.profile === "native-external-postgres") {
90605
90694
  if (params.contract.postgres.mode !== "external" || !params.contract.postgres.configRef || !params.contract.postgres.tlsPolicy) throw new Error("community_native_external_postgres_contract_required");
@@ -90609,16 +90698,18 @@ async function setupCommunityNativeInstall(params) {
90609
90698
  } else if (params.contract.postgres.mode !== "container") {
90610
90699
  throw new Error("community_native_container_postgres_contract_required");
90611
90700
  }
90612
- await runBuildChecked(
90613
- runtime,
90614
- { ...buildCommunityPnpmInvocation(source.root, ["install", "--frozen-lockfile"], params.env), signal: params.signal },
90615
- "install"
90616
- );
90617
- await runBuildChecked(
90618
- runtime,
90619
- { ...buildCommunityPnpmInvocation(source.root, ["run", "build"], params.env), signal: params.signal },
90620
- "build"
90621
- );
90701
+ if (!isPackagedCommunityServerSource(source)) {
90702
+ await runBuildChecked(
90703
+ runtime,
90704
+ { ...buildCommunityPnpmInvocation(source.root, ["install", "--frozen-lockfile"], params.env), signal: params.signal },
90705
+ "install"
90706
+ );
90707
+ await runBuildChecked(
90708
+ runtime,
90709
+ { ...buildCommunityPnpmInvocation(source.root, ["run", "build"], params.env), signal: params.signal },
90710
+ "build"
90711
+ );
90712
+ }
90622
90713
  throwIfNativeAborted(params.signal);
90623
90714
  const updatedAt = now().toISOString();
90624
90715
  const build = inspectCommunityNativeBuild(source, updatedAt);
@@ -90766,16 +90857,18 @@ async function rollbackCommunityNativeApplication(params) {
90766
90857
  throw new Error("community_native_application_update_target_not_active");
90767
90858
  }
90768
90859
  const source = inspectCommunityNativeSource(params.sourceRoot);
90769
- await runBuildChecked(
90770
- runtime,
90771
- { ...buildCommunityPnpmInvocation(source.root, ["install", "--frozen-lockfile"], params.env), signal: params.signal },
90772
- "rollback_install"
90773
- );
90774
- await runBuildChecked(
90775
- runtime,
90776
- { ...buildCommunityPnpmInvocation(source.root, ["run", "build"], params.env), signal: params.signal },
90777
- "rollback_build"
90778
- );
90860
+ if (!isPackagedCommunityServerSource(source)) {
90861
+ await runBuildChecked(
90862
+ runtime,
90863
+ { ...buildCommunityPnpmInvocation(source.root, ["install", "--frozen-lockfile"], params.env), signal: params.signal },
90864
+ "rollback_install"
90865
+ );
90866
+ await runBuildChecked(
90867
+ runtime,
90868
+ { ...buildCommunityPnpmInvocation(source.root, ["run", "build"], params.env), signal: params.signal },
90869
+ "rollback_build"
90870
+ );
90871
+ }
90779
90872
  throwIfNativeAborted(params.signal);
90780
90873
  const updatedAt = now().toISOString();
90781
90874
  const build = inspectCommunityNativeBuild(source, updatedAt);
@@ -92180,7 +92273,7 @@ async function runCommunityServerSetup(options, dependencies = {}) {
92180
92273
  status: "community-server-setup-preview",
92181
92274
  mutationFree: true,
92182
92275
  contract,
92183
- next: contract.runtime === "native" ? "Re-run with --apply to install dependencies, build the public checkout, and start the loopback native host." : "Re-run with --apply to verify the signed release and start the OCI stack."
92276
+ next: contract.runtime === "native" ? "Re-run with --apply to start the installed npm server package, or build an explicit public checkout supplied with --source-root." : "Re-run with --apply to verify the signed release and start the OCI stack."
92184
92277
  }, options.json, options);
92185
92278
  return;
92186
92279
  }
@@ -92549,6 +92642,50 @@ async function runCommunityServerStatus(options) {
92549
92642
  }
92550
92643
  if (result.exitCode !== 0) process.exitCode = 1;
92551
92644
  }
92645
+ async function runCommunityServerHealth(options) {
92646
+ const native = inspectNativeFrom(options);
92647
+ if (native.status === "installed" && native.state) {
92648
+ const observed = await inspectCommunityNativeRuntime(installSelection2(options));
92649
+ const healthy = observed.runtimeState === "running" && observed.health === "healthy";
92650
+ writeResult({
92651
+ status: healthy ? "healthy" : "unhealthy",
92652
+ runtime: "native",
92653
+ profile: native.state.profile,
92654
+ instance: native.state.instanceName,
92655
+ origin: `http://127.0.0.1:${native.state.server.port}`,
92656
+ runtimeState: observed.runtimeState,
92657
+ supervisor: observed.supervisorAlive,
92658
+ host: observed.hostAlive,
92659
+ health: observed.health,
92660
+ identityBound: observed.identity !== null,
92661
+ error: observed.reason ?? null
92662
+ }, options.json);
92663
+ if (!healthy) process.exitCode = 1;
92664
+ return;
92665
+ }
92666
+ if (native.status !== "not-installed") {
92667
+ throw new Error(`community_native_health_refused:${native.status}:${native.error ?? "run_doctor"}`);
92668
+ }
92669
+ const inspection = requireInstalled(options);
92670
+ try {
92671
+ const lifecycle = createCommunityDockerAdapter({ verifyRelease: async () => void 0 });
92672
+ await lifecycle.health({ paths: inspection.paths, state: inspection.state });
92673
+ writeResult({
92674
+ status: "healthy",
92675
+ runtime: "oci",
92676
+ instance: inspection.state.instanceName,
92677
+ releaseVersion: inspection.state.activeRelease.releaseVersion
92678
+ }, options.json);
92679
+ } catch (error) {
92680
+ writeResult({
92681
+ status: "unhealthy",
92682
+ runtime: "oci",
92683
+ instance: inspection.state.instanceName,
92684
+ error: error instanceof Error ? error.message : String(error)
92685
+ }, options.json);
92686
+ process.exitCode = 1;
92687
+ }
92688
+ }
92552
92689
  async function runCommunityServerMigrationPlan(options, dependencies = {}) {
92553
92690
  const runtime = resolveDependencies(dependencies);
92554
92691
  await withCommunityCommandAbortScope(runtime.commandAbortRuntime, async (signal) => {
@@ -93404,11 +93541,12 @@ function releaseOptions(command) {
93404
93541
  function makeCommunityServerCommand(identity2 = {}) {
93405
93542
  const dependencies = { cliVersion: identity2.cliVersion };
93406
93543
  const command = new Command("server").description("Configure and operate a named AOPS Community server instance");
93407
- common3(releaseOptions(command.command("setup").description("Configure, build, and start an explicit native or OCI setup profile"))).requiredOption("--runtime <native|oci>", "Application runtime; no implicit default").option("--postgres <external|container>", "PostgreSQL owner for --runtime native").option("--postgres-config <path>", "Explicit external PostgreSQL env-file override; default: ~/.aops/aops.server.env (or AOPS_CLI_CONFIG_PATH directory)").option("--postgres-tls <disable|require|verify-full>", "Explicit external PostgreSQL TLS policy").option("--source-root <path>", "Public aops-community checkout root; defaults to the current directory").option("--port <number>", "Host port", "5900").option("--foreground", "Keep the native server attached to this terminal").option("--detach", "Start the native server in the background (default)").option("--preview", "Validate and print the setup contract without mutation").option("--apply", "Apply the selected setup contract").action((options) => runCommunityServerSetup(options, dependencies));
93408
- common3(command.command("start").alias("up").description("Start the installed native source host or OCI stack")).option("--foreground", "Keep the native server attached to this terminal").option("--detach", "Start the native server in the background (default)").action((options) => runCommunityServerStart(options, dependencies));
93544
+ common3(releaseOptions(command.command("setup").description("Configure and start an npm-package, source-checkout, or OCI server profile"))).requiredOption("--runtime <native|oci>", "Application runtime; no implicit default").option("--postgres <external|container>", "PostgreSQL owner for --runtime native").option("--postgres-config <path>", "Explicit external PostgreSQL env-file override; default: ~/.aops/aops.server.env (or AOPS_CLI_CONFIG_PATH directory)").option("--postgres-tls <disable|require|verify-full>", "Explicit external PostgreSQL TLS policy").option("--source-root <path>", "Optional public aops-community checkout root; defaults to the installed @aopslab/aops-server package").option("--port <number>", "Host port", "5900").option("--foreground", "Keep the native server attached to this terminal").option("--detach", "Start the native server in the background (default)").option("--preview", "Validate and print the setup contract without mutation").option("--apply", "Apply the selected setup contract").action((options) => runCommunityServerSetup(options, dependencies));
93545
+ common3(command.command("start").alias("up").description("Start the installed native npm/source host or OCI stack")).option("--foreground", "Keep the native server attached to this terminal").option("--detach", "Start the native server in the background (default)").action((options) => runCommunityServerStart(options, dependencies));
93409
93546
  common3(command.command("stop").alias("down").description("Stop the server without deleting data")).action((options) => runCommunityServerStop(options, dependencies));
93410
93547
  common3(command.command("restart").description("Restart the installed server")).option("--foreground", "Keep the restarted native server attached to this terminal").option("--detach", "Restart the native server in the background (default)").action((options) => runCommunityServerRestart(options, dependencies));
93411
93548
  common3(command.command("status").description("Show install and runtime status")).action(runCommunityServerStatus);
93549
+ common3(command.command("health").description("Check the installed server health without mutation")).action(runCommunityServerHealth);
93412
93550
  common3(command.command("migration-plan").description("Read the exact pending native database migration plan without mutation")).action((options) => runCommunityServerMigrationPlan(options, dependencies));
93413
93551
  common3(command.command("attest-external-snapshot").description("Bind an operator-owned external PostgreSQL snapshot to one exact migration plan")).requiredOption("--expected-plan-sha256 <digest>", "Exact raw plan SHA-256 returned by server migration-plan").requiredOption("--provider <name>", "External snapshot provider or platform").requiredOption("--snapshot-ref <reference>", "Immutable external snapshot reference").option("--snapshot-digest <sha256:digest>", "Optional immutable snapshot content digest").requiredOption("--attested-by <identity>", "Operator identity accepting external recovery ownership").requiredOption("--restore-instructions-ref <reference>", "Durable runbook or restore-instructions reference").option("--preview", "Validate and print the exact attestation without writing it").option("--apply", "Write the immutable plan-bound attestation").option("--confirm-external-recovery-owner", "Confirm that restore execution remains externally owned").action((options) => runCommunityServerAttestExternalSnapshot(options, dependencies));
93414
93552
  common3(command.command("logs").description("Show recent server logs")).option("--tail <number>", "Number of log lines", "100").action(runCommunityServerLogs);
@@ -95275,6 +95413,9 @@ var NativeRuntimeRoot = class {
95275
95413
  this.rootIdentitySha256 = rootIdentitySha256;
95276
95414
  this.run = run;
95277
95415
  }
95416
+ id;
95417
+ rootIdentitySha256;
95418
+ run;
95278
95419
  async createDirectory(relativePath3) {
95279
95420
  await this.run(["runtime-mkdir", this.id, hexUtf8(relativePath3)]);
95280
95421
  }
@@ -97205,17 +97346,17 @@ var SETUP_PATHS = [
97205
97346
  {
97206
97347
  id: "native-external",
97207
97348
  number: "1",
97208
- title: "Native server with external PostgreSQL"
97349
+ title: "Npm server with operator-owned PostgreSQL"
97209
97350
  },
97210
97351
  {
97211
97352
  id: "native-container",
97212
97353
  number: "2",
97213
- title: "Native server with managed PostgreSQL container"
97354
+ title: "Source server with PostgreSQL container (deferred)"
97214
97355
  },
97215
97356
  {
97216
97357
  id: "oci-ready",
97217
97358
  number: "3",
97218
- title: "Ready OCI stack from published images"
97359
+ title: "Ready OCI stack from published images (deferred)"
97219
97360
  },
97220
97361
  {
97221
97362
  id: "cli-existing",
@@ -97547,15 +97688,19 @@ async function inspectSetupReadiness(options = {}) {
97547
97688
  }
97548
97689
  const hasCommand = probes.commandAvailable ?? commandAvailable;
97549
97690
  if (selected === "native-external" || selected === "native-container") {
97550
- const selectedSourceRoot = path35.resolve(options.sourceRoot ?? native.state?.source.root ?? cwd);
97691
+ const selectedSourceRoot = path35.resolve(
97692
+ options.sourceRoot ?? native.state?.source.root ?? resolveCommunityNativeDefaultSourceRoot(cwd)
97693
+ );
97551
97694
  let nativeSourceReady = false;
97695
+ let npmPackage = false;
97552
97696
  let nativeSourceError = null;
97553
97697
  if (probes.commandAvailable) {
97554
- nativeSourceReady = hasCommand("pnpm");
97698
+ nativeSourceReady = options.sourceRoot ? hasCommand("pnpm") : true;
97555
97699
  } else {
97556
97700
  try {
97557
97701
  inspectCommunityNativeSource(selectedSourceRoot);
97558
- buildCommunityPnpmInvocation(selectedSourceRoot, ["--version"], processEnv);
97702
+ npmPackage = isCommunityNativeNpmPackageSource(selectedSourceRoot);
97703
+ if (!npmPackage) buildCommunityPnpmInvocation(selectedSourceRoot, ["--version"], processEnv);
97559
97704
  nativeSourceReady = true;
97560
97705
  } catch (error) {
97561
97706
  nativeSourceError = safeReason(error, "community_native_source_runtime_invalid");
@@ -97568,11 +97713,12 @@ async function inspectSetupReadiness(options = {}) {
97568
97713
  id: "runtime",
97569
97714
  state: runtimeReady ? "ready" : "action-required",
97570
97715
  required: true,
97571
- summary: runtimeReady ? "Native source runtime requirements are available." : needsDocker ? "The native source checkout, pnpm 11 and a running Docker daemon are required." : "A valid Community source checkout and pnpm 11 are required.",
97716
+ summary: runtimeReady ? npmPackage ? "The installed npm server runtime is ready; no source build is required." : "Native source runtime requirements are available." : needsDocker ? "The native source checkout, pnpm 11 and a running Docker daemon are required." : "Install @aopslab/aops-server through the CLI package, or provide a valid Community checkout with pnpm 11.",
97572
97717
  next: runtimeReady ? void 0 : "Use a Community source checkout and install its declared pnpm version and required container runtime.",
97573
97718
  data: {
97574
97719
  node: process.version,
97575
97720
  sourceRoot: selectedSourceRoot,
97721
+ sourceKind: npmPackage ? "npm-package" : "source-checkout",
97576
97722
  nativeSource: nativeSourceReady,
97577
97723
  docker: needsDocker ? dockerReady : null,
97578
97724
  error: nativeSourceError
@@ -97729,7 +97875,7 @@ async function runSetupInitOrchestrator(options = {}, dependencies = {}) {
97729
97875
  name: `${entry.number}. ${entry.title}`,
97730
97876
  value: entry.id
97731
97877
  })),
97732
- default: "oci-ready"
97878
+ default: "native-external"
97733
97879
  });
97734
97880
  }
97735
97881
  }
@@ -97790,9 +97936,10 @@ async function runSetupInitOrchestrator(options = {}, dependencies = {}) {
97790
97936
  throw new Error("setup_init_postgres_tls_required_for_path_1");
97791
97937
  }
97792
97938
  const localServerPath = selectedPath !== "cli-existing";
97939
+ const catalogDeferredForNpm = selectedPath === "native-external" && !options.sourceRoot && !normalizeNonEmpty9(options.catalogRelease) && !normalizeNonEmpty9(options.agentAssetsRelease);
97793
97940
  let officialCatalogRelease;
97794
97941
  let officialCatalogReleaseSource;
97795
- if (localServerPath && !options.noCatalog && dependencies.officialCatalog) {
97942
+ if (localServerPath && !options.noCatalog && !catalogDeferredForNpm && dependencies.officialCatalog) {
97796
97943
  const selectedRelease = options.catalogRelease ?? options.agentAssetsRelease;
97797
97944
  if (normalizeNonEmpty9(selectedRelease)) {
97798
97945
  officialCatalogRelease = resolveOfficialCatalogReleasePath(selectedRelease);
@@ -97885,6 +98032,14 @@ async function runSetupInitOrchestrator(options = {}, dependencies = {}) {
97885
98032
  coreClientAssetsAffected: false,
97886
98033
  existingCatalogRowsDeleted: false
97887
98034
  });
98035
+ } else if (localServerPath && catalogDeferredForNpm) {
98036
+ steps.push({
98037
+ action: "setup.catalog.skip",
98038
+ status: "skipped",
98039
+ reason: "npm-runtime-has-no-signed-catalog-release",
98040
+ coreClientAssetsAffected: false,
98041
+ existingCatalogRowsDeleted: false
98042
+ });
97888
98043
  } else if (localServerPath && dependencies.officialCatalog && officialCatalogRelease) {
97889
98044
  const catalog = await dependencies.officialCatalog.reconcile({
97890
98045
  fromRelease: officialCatalogRelease,
@@ -98345,27 +98500,28 @@ async function runCommunitySetupInit(options = {}) {
98345
98500
  });
98346
98501
  }
98347
98502
  function addSetupInitOptions(command) {
98348
- return command.option("--path <path>", "Setup path: 1 | 2 | 3 | 4 (semantic ids are also accepted)").option("--postgres-config <path>", "Explicit PostgreSQL env file override for path 1").option("--postgres-tls <policy>", "Path 1 TLS policy: disable | require | verify-full").option("--api-base-url <url>", "Local or existing-server API base URL without credentials").option("--instance <name>", "Local Community instance name").option("--data-root <path>", "Local Community data root override").option("--source-root <path>", "Native Community source checkout override for paths 1 and 2").option("--port <port>", "Local server port", (value) => Number.parseInt(String(value), 10)).option("--target-name <name>", "Persistent target name for path 4").option("--target-auth-provider <provider>", "Path 4 target auth: trusted-local | authv2-jwt-session").option("--target-tls-policy <policy>", "Path 4 target TLS: loopback-http | system-ca").option("--agent-assets <action>", "Global AOPS gateway action: status | install | repair | skip").option("--agent-assets-release <path>", "Verified release directory for --agent-assets install").option("--no-catalog", "Skip the default inert official server catalog import").option("--catalog-release <path>", "Explicit verified-release override (normally resolved from the Community install)").option("--catalog-idempotency-key <key>", "Explicit official catalog reconcile replay key").option("--apply", "Apply the selected path after readiness checks").option("--resume", "With --apply, resume the same idempotent setup orchestration").option("--timeout-ms <ms>", "Read-only host probe timeout", (value) => Number.parseInt(String(value), 10)).option("--yes", "Non-interactive; report missing selections as actions").option("--json", "Output one typed readiness or apply-result envelope");
98503
+ return command.option("--path <path>", "Setup path: 1 | 2 | 3 | 4 (semantic ids are also accepted)").option("--postgres-config <path>", "Explicit PostgreSQL env file override for the default npm server path").option("--postgres-tls <policy>", "PostgreSQL TLS policy: disable | require | verify-full").option("--api-base-url <url>", "Local or existing-server API base URL without credentials").option("--instance <name>", "Local Community instance name").option("--data-root <path>", "Local Community data root override").option("--source-root <path>", "Optional native Community source checkout override; npm server package is the default").option("--port <port>", "Local server port", (value) => Number.parseInt(String(value), 10)).option("--target-name <name>", "Persistent target name for path 4").option("--target-auth-provider <provider>", "Path 4 target auth: trusted-local | authv2-jwt-session").option("--target-tls-policy <policy>", "Path 4 target TLS: loopback-http | system-ca").option("--agent-assets <action>", "Global AOPS gateway action: status | install | repair | skip").option("--agent-assets-release <path>", "Verified release directory for --agent-assets install").option("--no-catalog", "Skip the default inert official server catalog import").option("--catalog-release <path>", "Explicit verified-release override (normally resolved from the Community install)").option("--catalog-idempotency-key <key>", "Explicit official catalog reconcile replay key").option("--apply", "Apply the selected path after readiness checks").option("--resume", "With --apply, resume the same idempotent setup orchestration").option("--timeout-ms <ms>", "Read-only host probe timeout", (value) => Number.parseInt(String(value), 10)).option("--yes", "Non-interactive; report missing selections as actions").option("--json", "Output one typed readiness or apply-result envelope");
98349
98504
  }
98350
98505
  function makeCommunitySetupCommand() {
98351
98506
  const command = new Command("setup").description("Inspect and bootstrap an AOPS Community installation");
98352
98507
  command.addCommand(makeOfficialCatalogSetupCommand());
98353
- addSetupInitOptions(command.command("init").description("Guide paths 1, 2, 3, or 4; read-only unless --apply is supplied")).addHelpText("after", `
98508
+ addSetupInitOptions(command.command("init").description("Guide npm-server, source, deferred Docker, or existing-server setup; read-only unless --apply is supplied")).addHelpText("after", `
98354
98509
  Examples:
98355
98510
  aops-cli setup init
98356
98511
  aops-cli setup init --path 1 --postgres-tls verify-full --json
98357
- aops-cli setup init --path 3 --apply --yes
98358
98512
  aops-cli setup init --path 4 --api-base-url https://aops.example.com --json
98359
- aops-cli setup init --path 2 --catalog-release <path> --apply --yes
98360
- aops-cli setup init --path 2 --no-catalog --apply --yes
98513
+ aops-cli setup init --path 1 --no-catalog --apply --yes
98361
98514
 
98362
98515
  This command is distinct from repo-local \`aops-cli init\`.
98363
- Path 1 uses \`~/.aops/aops.server.env\` by default, or the directory selected by
98516
+ Path 1 is the promoted npm-server path and uses \`~/.aops/aops.server.env\` by default, or the directory selected by
98364
98517
  \`AOPS_CLI_CONFIG_PATH\`. A relative \`AOPS_PG_SSL_ROOT_CERT\` is resolved beside
98365
98518
  the selected env file. \`--postgres-config\` remains an explicit override.
98366
98519
  Community agent assets use the TASK-136 \`aops-cli assets\` contract; the
98367
98520
  development-only repo-mirror installer is not part of this command.
98368
- Fresh server setup imports only the inert signed official catalog by default.
98521
+ Source/release setup imports only the inert signed official catalog by default.
98522
+ The npm runtime skips that optional catalog unless \`--catalog-release\` is supplied.
98523
+ Docker-backed paths 2 and 3 are retained for later reactivation but are not the
98524
+ promoted installation path in this release.
98369
98525
  The CLI first resolves the canonical signed release from the selected source or
98370
98526
  installed Community runtime; \`--catalog-release\` is only an explicit override.
98371
98527
  \`--no-catalog\` is the bare/minimal opt-out; it never removes existing rows or
@@ -98375,7 +98531,7 @@ changes the offline client core. Reconcile and rollback remain explicit under
98375
98531
  const { catalog, ...options } = commandOptions2;
98376
98532
  await runCommunitySetupInit({ ...options, noCatalog: catalog === false });
98377
98533
  });
98378
- command.command("server-env").description("Create or validate the global trusted-local PostgreSQL env for path 1").option("--env-path <path>", "Explicit env file override (default: ~/.aops/aops.server.env)").option("--yes", "Non-interactive; read AOPS_PG_URL from the environment or existing file").option("--json", "Output a secret-free JSON summary").addHelpText("after", `
98534
+ command.command("server-env").description("Create or validate the global trusted-local PostgreSQL env for the npm server").option("--env-path <path>", "Explicit env file override (default: ~/.aops/aops.server.env)").option("--yes", "Non-interactive; read AOPS_PG_URL from the environment or existing file").option("--json", "Output a secret-free JSON summary").addHelpText("after", `
98379
98535
  Examples:
98380
98536
  aops-cli setup server-env
98381
98537
  AOPS_PG_URL='<private-url>' aops-cli setup server-env --yes --json
@@ -102108,19 +102264,15 @@ var GUIDE_TARGETS = {
102108
102264
  mirrorPath: path47.join(".aops", "docman", "domain-guides", "agentspace-user-guide.md")
102109
102265
  },
102110
102266
  projectman: {
102111
- fallbackPath: "../../../../domains/projectman/USER_GUIDE.md",
102112
102267
  mirrorPath: path47.join(".aops", "docman", "domain-guides", "projectman-user-guide.md")
102113
102268
  },
102114
102269
  docman: {
102115
- fallbackPath: "../../../../domains/docman/USER_GUIDE.md",
102116
102270
  mirrorPath: path47.join(".aops", "docman", "domain-guides", "docman-user-guide.md")
102117
102271
  },
102118
102272
  fileman: {
102119
- fallbackPath: "../../../../domains/fileman/USER_GUIDE.md",
102120
102273
  mirrorPath: path47.join(".aops", "docman", "domain-guides", "fileman-user-guide.md")
102121
102274
  },
102122
102275
  tasker: {
102123
- fallbackPath: "../../../../domains/tasker/USER_GUIDE.md",
102124
102276
  mirrorPath: path47.join(".aops", "docman", "domain-guides", "tasker-user-guide.md")
102125
102277
  },
102126
102278
  agentAssets: {
@@ -123776,7 +123928,7 @@ function makeChatCommand() {
123776
123928
  // apps/aops-cli/src/commands/chatv3.ts
123777
123929
  import { readFileSync as readFileSync29 } from "node:fs";
123778
123930
 
123779
- // domains/chatv3/chatv3-product-client/dist/crypto.js
123931
+ // node_modules/.pnpm/@aopslab+domain-product-client-chatv3@0.1.1_react@19.2.4/node_modules/@aopslab/domain-product-client-chatv3/dist/crypto.js
123780
123932
  var V0_CIPHER_SUITE = "v0-shared-epoch";
123781
123933
  var V0_KDF_META = {
123782
123934
  kdf: "hkdf-sha256",
@@ -123856,7 +124008,7 @@ async function decryptText(epochKey, envelope) {
123856
124008
  return decoder.decode(plaintext);
123857
124009
  }
123858
124010
 
123859
- // domains/chatv3/chatv3-product-client/dist/invite.js
124011
+ // node_modules/.pnpm/@aopslab+domain-product-client-chatv3@0.1.1_react@19.2.4/node_modules/@aopslab/domain-product-client-chatv3/dist/invite.js
123860
124012
  function buildInvite(invite) {
123861
124013
  const base = encodeURIComponent(invite.serverBaseUrl);
123862
124014
  if (invite.mode === "server-encrypted") {
@@ -123898,7 +124050,7 @@ function parseInvite(value) {
123898
124050
  };
123899
124051
  }
123900
124052
 
123901
- // domains/chatv3/chatv3-product-client/dist/keystore.js
124053
+ // node_modules/.pnpm/@aopslab+domain-product-client-chatv3@0.1.1_react@19.2.4/node_modules/@aopslab/domain-product-client-chatv3/dist/keystore.js
123902
124054
  var MemoryKeyStore = class {
123903
124055
  wrapSecrets = /* @__PURE__ */ new Map();
123904
124056
  epochKeys = /* @__PURE__ */ new Map();
@@ -123916,7 +124068,7 @@ var MemoryKeyStore = class {
123916
124068
  }
123917
124069
  };
123918
124070
 
123919
- // domains/chatv3/light-client-core/dist/config.js
124071
+ // node_modules/.pnpm/@aopslab+light-client-core@0.1.1_react@19.2.4/node_modules/@aopslab/light-client-core/dist/config.js
123920
124072
  function normalizeBaseUrl2(value) {
123921
124073
  return value.replace(/\/$/, "");
123922
124074
  }
@@ -123924,7 +124076,7 @@ function bindFetch() {
123924
124076
  return globalThis.fetch.bind(globalThis);
123925
124077
  }
123926
124078
 
123927
- // domains/chatv3/light-client-core/dist/token.js
124079
+ // node_modules/.pnpm/@aopslab+light-client-core@0.1.1_react@19.2.4/node_modules/@aopslab/light-client-core/dist/token.js
123928
124080
  var MemoryTokenProvider = class {
123929
124081
  token = null;
123930
124082
  constructor(initial) {
@@ -123941,7 +124093,7 @@ var MemoryTokenProvider = class {
123941
124093
  }
123942
124094
  };
123943
124095
 
123944
- // domains/chatv3/light-client-core/dist/http.js
124096
+ // node_modules/.pnpm/@aopslab+light-client-core@0.1.1_react@19.2.4/node_modules/@aopslab/light-client-core/dist/http.js
123945
124097
  function makeError(status, code, message) {
123946
124098
  const err = new Error(message);
123947
124099
  err.status = status;
@@ -124003,13 +124155,13 @@ var EnvelopeHttp = class {
124003
124155
  }
124004
124156
  };
124005
124157
 
124006
- // domains/chatv3/light-client-core/dist/stream/index.js
124158
+ // node_modules/.pnpm/@aopslab+light-client-core@0.1.1_react@19.2.4/node_modules/@aopslab/light-client-core/dist/stream/index.js
124007
124159
  function appendQueryParam(url, key, value) {
124008
124160
  const sep = url.includes("?") ? "&" : "?";
124009
124161
  return `${url}${sep}${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
124010
124162
  }
124011
124163
 
124012
- // domains/chatv3/chatv3-product-client/dist/http.js
124164
+ // node_modules/.pnpm/@aopslab+domain-product-client-chatv3@0.1.1_react@19.2.4/node_modules/@aopslab/domain-product-client-chatv3/dist/http.js
124013
124165
  var Chatv3Http = class extends EnvelopeHttp {
124014
124166
  memberHeaders;
124015
124167
  authv2AccessToken;
@@ -124071,7 +124223,7 @@ var Chatv3Http = class extends EnvelopeHttp {
124071
124223
  }
124072
124224
  };
124073
124225
 
124074
- // domains/chatv3/chatv3-product-client/dist/client.js
124226
+ // node_modules/.pnpm/@aopslab+domain-product-client-chatv3@0.1.1_react@19.2.4/node_modules/@aopslab/domain-product-client-chatv3/dist/client.js
124075
124227
  var Chatv3Client = class {
124076
124228
  http;
124077
124229
  keyStore;
@@ -0,0 +1,223 @@
1
+ // apps/aops-cli/src/lib/community-native-child.ts
2
+ import { randomBytes } from "node:crypto";
3
+ import { spawn } from "node:child_process";
4
+ import { existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "node:fs";
5
+ import path from "node:path";
6
+ import { pathToFileURL } from "node:url";
7
+ var COMMUNITY_NATIVE_CHILD_PROTOCOL = "aops-community-native-child-v1";
8
+ var COMMUNITY_NATIVE_CONTROL_PROTOCOL = "aops-community-native-control-v1";
9
+ var UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
10
+ var SHA256 = /^sha256:[a-f0-9]{64}$/;
11
+ var HOST_STOP_GRACE_MS = 2e3;
12
+ function requiredEnv(env, key) {
13
+ const value = String(env[key] ?? "").trim();
14
+ if (!value) throw new Error(`community_native_child_env_required:${key}`);
15
+ return value;
16
+ }
17
+ function parsePort(value) {
18
+ if (!/^[1-9]\d{0,4}$/.test(value) || Number(value) > 65535) {
19
+ throw new Error("community_native_child_port_invalid");
20
+ }
21
+ return Number(value);
22
+ }
23
+ function atomicJsonWrite(targetPath, value) {
24
+ const parent = path.dirname(targetPath);
25
+ if (!existsSync(parent)) throw new Error("community_native_child_identity_parent_missing");
26
+ const tempPath = path.join(parent, `.${path.basename(targetPath)}.${process.pid}.${randomBytes(8).toString("hex")}.tmp`);
27
+ try {
28
+ writeFileSync(tempPath, `${JSON.stringify(value, null, 2)}
29
+ `, { encoding: "utf8", flag: "wx", mode: 384 });
30
+ renameSync(tempPath, targetPath);
31
+ } finally {
32
+ rmSync(tempPath, { force: true });
33
+ }
34
+ }
35
+ function buildCommunityNativeChildIdentity(env = process.env, pid = process.pid, hostPid = pid) {
36
+ const launchId = requiredEnv(env, "AOPS_NATIVE_LAUNCH_ID");
37
+ const startedAt = requiredEnv(env, "AOPS_NATIVE_STARTED_AT");
38
+ const sourceFingerprint = requiredEnv(env, "AOPS_NATIVE_SOURCE_FINGERPRINT");
39
+ const hostEntry = path.resolve(requiredEnv(env, "AOPS_NATIVE_HOST_ENTRY"));
40
+ const controlPathInput = requiredEnv(env, "AOPS_NATIVE_CONTROL_PATH");
41
+ if (!path.isAbsolute(controlPathInput)) throw new Error("community_native_child_control_path_invalid");
42
+ const controlPath = path.resolve(controlPathInput);
43
+ if (!UUID.test(launchId)) throw new Error("community_native_child_launch_id_invalid");
44
+ if (!Number.isSafeInteger(pid) || pid < 1 || !Number.isSafeInteger(hostPid) || hostPid < 1) {
45
+ throw new Error("community_native_child_pid_invalid");
46
+ }
47
+ if (Number.isNaN(Date.parse(startedAt))) throw new Error("community_native_child_started_at_invalid");
48
+ if (!SHA256.test(sourceFingerprint)) throw new Error("community_native_child_source_fingerprint_invalid");
49
+ if (!path.isAbsolute(hostEntry)) throw new Error("community_native_child_host_entry_invalid");
50
+ return {
51
+ schemaVersion: 1,
52
+ protocol: COMMUNITY_NATIVE_CHILD_PROTOCOL,
53
+ launchId,
54
+ pid,
55
+ hostPid,
56
+ startedAt,
57
+ sourceFingerprint,
58
+ hostEntry,
59
+ controlPath,
60
+ port: parsePort(requiredEnv(env, "AOPS_NATIVE_PORT"))
61
+ };
62
+ }
63
+ function removeIdentityIfOwned(identityPath, launchId) {
64
+ try {
65
+ const parsed = JSON.parse(readFileSync(identityPath, "utf8"));
66
+ if (parsed.protocol === COMMUNITY_NATIVE_CHILD_PROTOCOL && parsed.launchId === launchId) {
67
+ rmSync(identityPath, { force: true });
68
+ }
69
+ } catch {
70
+ }
71
+ }
72
+ function readOwnedStopRequest(controlPath, launchId) {
73
+ try {
74
+ const parsed = JSON.parse(readFileSync(controlPath, "utf8"));
75
+ if (parsed.schemaVersion !== 1 || parsed.protocol !== COMMUNITY_NATIVE_CONTROL_PROTOCOL || parsed.launchId !== launchId || parsed.command !== "stop" || Number.isNaN(Date.parse(String(parsed.requestedAt))) || Object.keys(parsed).sort().join(",") !== "command,launchId,protocol,requestedAt,schemaVersion") return null;
76
+ return parsed;
77
+ } catch {
78
+ return null;
79
+ }
80
+ }
81
+ function removeControlIfOwned(controlPath, launchId) {
82
+ if (readOwnedStopRequest(controlPath, launchId)) rmSync(controlPath, { force: true });
83
+ }
84
+ function spawnCommunityNativeHost(hostEntry, env) {
85
+ return spawn(process.execPath, [hostEntry], {
86
+ cwd: process.cwd(),
87
+ env,
88
+ detached: false,
89
+ windowsHide: true,
90
+ stdio: "inherit"
91
+ });
92
+ }
93
+ async function waitForHostSpawn(host) {
94
+ await new Promise((resolve, reject) => {
95
+ const onSpawn = () => {
96
+ host.off("error", onError);
97
+ resolve();
98
+ };
99
+ const onError = (error) => {
100
+ host.off("spawn", onSpawn);
101
+ reject(error);
102
+ };
103
+ host.once("spawn", onSpawn);
104
+ host.once("error", onError);
105
+ });
106
+ }
107
+ function observeHostOutcome(host) {
108
+ if (host.exitCode !== null || host.signalCode !== null) {
109
+ return Promise.resolve({
110
+ kind: "exit",
111
+ value: { exitCode: host.exitCode, signal: host.signalCode }
112
+ });
113
+ }
114
+ return new Promise((resolve) => {
115
+ const onExit = (exitCode, signal) => {
116
+ host.off("error", onError);
117
+ resolve({ kind: "exit", value: { exitCode, signal } });
118
+ };
119
+ const onError = (error) => {
120
+ host.off("exit", onExit);
121
+ resolve({ kind: "error", error });
122
+ };
123
+ host.once("exit", onExit);
124
+ host.once("error", onError);
125
+ });
126
+ }
127
+ async function terminateAndReapHost(host) {
128
+ if (host.exitCode !== null || host.signalCode !== null) return;
129
+ const exited = new Promise((resolve) => {
130
+ host.once("exit", () => resolve());
131
+ });
132
+ host.kill("SIGKILL");
133
+ await exited;
134
+ }
135
+ async function runCommunityNativeChild(env = process.env, runtime = {}) {
136
+ const identityPathInput = requiredEnv(env, "AOPS_NATIVE_IDENTITY_PATH");
137
+ if (!path.isAbsolute(identityPathInput)) throw new Error("community_native_child_identity_path_invalid");
138
+ const identityPath = path.resolve(identityPathInput);
139
+ const controlPathInput = requiredEnv(env, "AOPS_NATIVE_CONTROL_PATH");
140
+ if (!path.isAbsolute(controlPathInput)) throw new Error("community_native_child_control_path_invalid");
141
+ const controlPath = path.resolve(controlPathInput);
142
+ const hostEntry = path.resolve(requiredEnv(env, "AOPS_NATIVE_HOST_ENTRY"));
143
+ if (!existsSync(hostEntry)) throw new Error("community_native_child_host_entry_missing");
144
+ mkdirSync(path.dirname(identityPath), { recursive: true, mode: 448 });
145
+ const host = (runtime.spawnHost ?? spawnCommunityNativeHost)(hostEntry, env);
146
+ await waitForHostSpawn(host);
147
+ const hostOutcome = observeHostOutcome(host);
148
+ let cleanup;
149
+ let controlTimer;
150
+ let forceStopTimer;
151
+ let stopping = false;
152
+ const forward = (signal) => {
153
+ if (stopping) return;
154
+ stopping = true;
155
+ try {
156
+ host.kill(signal);
157
+ } catch {
158
+ }
159
+ forceStopTimer = setTimeout(() => {
160
+ if (host.exitCode === null && host.signalCode === null) {
161
+ try {
162
+ host.kill("SIGKILL");
163
+ } catch {
164
+ }
165
+ }
166
+ }, HOST_STOP_GRACE_MS);
167
+ forceStopTimer.unref();
168
+ };
169
+ const onSigint = () => forward("SIGINT");
170
+ const onSigterm = () => forward("SIGTERM");
171
+ try {
172
+ if (!host.pid) throw new Error("community_native_child_host_pid_missing");
173
+ const identity = buildCommunityNativeChildIdentity(env, process.pid, host.pid);
174
+ atomicJsonWrite(identityPath, identity);
175
+ cleanup = () => {
176
+ removeIdentityIfOwned(identityPath, identity.launchId);
177
+ removeControlIfOwned(controlPath, identity.launchId);
178
+ };
179
+ process.once("exit", cleanup);
180
+ process.once("SIGINT", onSigint);
181
+ process.once("SIGTERM", onSigterm);
182
+ controlTimer = setInterval(() => {
183
+ if (readOwnedStopRequest(controlPath, identity.launchId)) {
184
+ removeControlIfOwned(controlPath, identity.launchId);
185
+ forward("SIGTERM");
186
+ }
187
+ }, 100);
188
+ const outcome = await hostOutcome;
189
+ if (outcome.kind === "error") throw outcome.error;
190
+ if (!stopping && outcome.value.exitCode !== 0) {
191
+ throw new Error(
192
+ `community_native_child_host_failed:${outcome.value.exitCode ?? outcome.value.signal ?? "unknown"}`
193
+ );
194
+ }
195
+ } catch (error) {
196
+ await terminateAndReapHost(host);
197
+ throw error;
198
+ } finally {
199
+ process.off("SIGINT", onSigint);
200
+ process.off("SIGTERM", onSigterm);
201
+ if (cleanup) process.off("exit", cleanup);
202
+ if (controlTimer) clearInterval(controlTimer);
203
+ if (forceStopTimer) clearTimeout(forceStopTimer);
204
+ cleanup?.();
205
+ }
206
+ }
207
+ function isCommunityNativeChildEntry(moduleUrl = import.meta.url, argvPath = process.argv[1]) {
208
+ return typeof argvPath === "string" && /^community-native-child\.[cm]?[jt]s$/i.test(path.basename(argvPath)) && moduleUrl === pathToFileURL(argvPath).href;
209
+ }
210
+ if (isCommunityNativeChildEntry()) {
211
+ runCommunityNativeChild().catch((error) => {
212
+ process.stderr.write(`[aops-community] native child failed: ${error instanceof Error ? error.message : String(error)}
213
+ `);
214
+ process.exitCode = 1;
215
+ });
216
+ }
217
+ export {
218
+ COMMUNITY_NATIVE_CHILD_PROTOCOL,
219
+ COMMUNITY_NATIVE_CONTROL_PROTOCOL,
220
+ buildCommunityNativeChildIdentity,
221
+ isCommunityNativeChildEntry,
222
+ runCommunityNativeChild
223
+ };
File without changes
File without changes
File without changes
File without changes
File without changes
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@aopslab/aops-cli",
3
- "version": "0.1.1",
4
- "type": "module",
3
+ "version": "0.1.3",
5
4
  "description": "AOPS Community operator CLI.",
6
5
  "license": "Apache-2.0",
6
+ "type": "module",
7
7
  "repository": {
8
8
  "type": "git",
9
9
  "url": "git+https://github.com/eeemzs/aops-community.git",
@@ -27,10 +27,16 @@
27
27
  "engines": {
28
28
  "node": ">=22.9.0"
29
29
  },
30
+ "packageManager": "pnpm@11.9.0",
31
+ "aopsSource": {
32
+ "repository": "https://github.com/eeemzs/aops-community",
33
+ "commit": "c04eead7a23aee089eab02942764b0672fc41d71"
34
+ },
35
+ "dependencies": {
36
+ "@aopslab/aops-server": "0.1.0"
37
+ },
30
38
  "publishConfig": {
31
39
  "access": "public",
32
- "registry": "https://registry.npmjs.org/",
33
- "provenance": true,
34
- "tag": "latest"
40
+ "registry": "https://registry.npmjs.org"
35
41
  }
36
42
  }