@openspecui/core 2.0.0 → 2.1.0

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.
@@ -0,0 +1,86 @@
1
+ //#region src/hosted-app.ts
2
+ const OFFICIAL_APP_BASE_URL = "https://app.openspecui.com";
3
+ function isRecord(value) {
4
+ return typeof value === "object" && value !== null;
5
+ }
6
+ function withHttpsProtocol(value) {
7
+ if (/^[a-zA-Z][a-zA-Z\d+.-]*:\/\//.test(value)) return value;
8
+ return `https://${value}`;
9
+ }
10
+ function parseVersionTuple(raw) {
11
+ const match = raw.trim().match(/^(\d+)\.(\d+)\.(\d+)(?:[-+].*)?$/);
12
+ if (!match) return null;
13
+ return {
14
+ major: Number(match[1]),
15
+ minor: Number(match[2]),
16
+ patch: Number(match[3])
17
+ };
18
+ }
19
+ function parseCompatibilityRange(range) {
20
+ const match = range.trim().match(/^~(\d+)\.(\d+)\.\d+$/);
21
+ if (!match) return null;
22
+ return {
23
+ major: Number(match[1]),
24
+ minor: Number(match[2])
25
+ };
26
+ }
27
+ function normalizeHostedAppBaseUrl(input) {
28
+ const trimmed = input.trim();
29
+ if (!trimmed) throw new Error("Hosted app base URL must not be empty");
30
+ let parsed;
31
+ try {
32
+ parsed = new URL(withHttpsProtocol(trimmed));
33
+ } catch (error) {
34
+ throw new Error(`Invalid hosted app base URL: ${error instanceof Error ? error.message : String(error)}`);
35
+ }
36
+ parsed.hash = "";
37
+ parsed.search = "";
38
+ const pathname = parsed.pathname.replace(/\/+$/, "");
39
+ parsed.pathname = pathname.length > 0 ? pathname : "/";
40
+ return parsed.toString().replace(/\/$/, parsed.pathname === "/" ? "" : "");
41
+ }
42
+ function resolveHostedAppBaseUrl(options) {
43
+ return normalizeHostedAppBaseUrl(options.override?.trim() || options.configured?.trim() || OFFICIAL_APP_BASE_URL);
44
+ }
45
+ function buildHostedVersionManifestUrl(baseUrl) {
46
+ return `${normalizeHostedAppBaseUrl(baseUrl)}/version.json`;
47
+ }
48
+ function buildHostedLaunchUrl(options) {
49
+ const url = new URL(normalizeHostedAppBaseUrl(options.baseUrl));
50
+ url.searchParams.set("api", options.apiBaseUrl);
51
+ return url.toString();
52
+ }
53
+ function isHostedAppVersionManifest(value) {
54
+ if (!isRecord(value)) return false;
55
+ if (value.packageName !== "openspecui") return false;
56
+ if (typeof value.generatedAt !== "string") return false;
57
+ if (typeof value.defaultChannel !== "string") return false;
58
+ if (!isRecord(value.channels)) return false;
59
+ if (!Array.isArray(value.compatibility)) return false;
60
+ return Object.values(value.channels).every((channel) => {
61
+ if (!isRecord(channel)) return false;
62
+ return typeof channel.id === "string" && typeof channel.kind === "string" && typeof channel.selector === "string" && typeof channel.resolvedVersion === "string" && typeof channel.rootPath === "string" && typeof channel.shellPath === "string" && typeof channel.major === "number";
63
+ });
64
+ }
65
+ function isHostedBackendHealthResponse(value) {
66
+ if (!isRecord(value)) return false;
67
+ return value.status === "ok" && typeof value.projectDir === "string" && typeof value.projectName === "string" && typeof value.watcherEnabled === "boolean" && typeof value.openspecuiVersion === "string";
68
+ }
69
+ function resolveHostedChannelForVersion(manifest, version) {
70
+ const parsed = parseVersionTuple(version);
71
+ if (!parsed) return null;
72
+ for (const entry of manifest.compatibility) {
73
+ const range = parseCompatibilityRange(entry.range);
74
+ if (!range) continue;
75
+ if (!manifest.channels[entry.channel]) continue;
76
+ if (range.major === parsed.major && range.minor === parsed.minor) return entry.channel;
77
+ }
78
+ const exactMinorChannel = `v${parsed.major}.${parsed.minor}`;
79
+ if (manifest.channels[exactMinorChannel]) return exactMinorChannel;
80
+ const majorChannel = `v${parsed.major}`;
81
+ if (manifest.channels[majorChannel]) return majorChannel;
82
+ return manifest.channels[manifest.defaultChannel] ? manifest.defaultChannel : null;
83
+ }
84
+
85
+ //#endregion
86
+ export { isHostedBackendHealthResponse as a, resolveHostedChannelForVersion as c, isHostedAppVersionManifest as i, buildHostedLaunchUrl as n, normalizeHostedAppBaseUrl as o, buildHostedVersionManifestUrl as r, resolveHostedAppBaseUrl as s, OFFICIAL_APP_BASE_URL as t };
@@ -0,0 +1,46 @@
1
+ //#region src/hosted-app.d.ts
2
+ declare const OFFICIAL_APP_BASE_URL = "https://app.openspecui.com";
3
+ type HostedAppChannelKind = 'latest' | 'major' | 'minor';
4
+ interface HostedAppChannelManifest {
5
+ id: string;
6
+ kind: HostedAppChannelKind;
7
+ selector: string;
8
+ resolvedVersion: string;
9
+ rootPath: string;
10
+ shellPath: string;
11
+ major: number;
12
+ minor?: number;
13
+ }
14
+ interface HostedAppCompatibilityEntry {
15
+ range: string;
16
+ channel: string;
17
+ }
18
+ interface HostedAppVersionManifest {
19
+ packageName: 'openspecui';
20
+ generatedAt: string;
21
+ defaultChannel: string;
22
+ channels: Record<string, HostedAppChannelManifest>;
23
+ compatibility: HostedAppCompatibilityEntry[];
24
+ }
25
+ interface HostedBackendHealthResponse {
26
+ status: 'ok';
27
+ projectDir: string;
28
+ projectName: string;
29
+ watcherEnabled: boolean;
30
+ openspecuiVersion: string;
31
+ }
32
+ declare function normalizeHostedAppBaseUrl(input: string): string;
33
+ declare function resolveHostedAppBaseUrl(options: {
34
+ override?: string | null;
35
+ configured?: string | null;
36
+ }): string;
37
+ declare function buildHostedVersionManifestUrl(baseUrl: string): string;
38
+ declare function buildHostedLaunchUrl(options: {
39
+ baseUrl: string;
40
+ apiBaseUrl: string;
41
+ }): string;
42
+ declare function isHostedAppVersionManifest(value: unknown): value is HostedAppVersionManifest;
43
+ declare function isHostedBackendHealthResponse(value: unknown): value is HostedBackendHealthResponse;
44
+ declare function resolveHostedChannelForVersion(manifest: HostedAppVersionManifest, version: string): string | null;
45
+ //#endregion
46
+ export { HostedBackendHealthResponse as a, buildHostedVersionManifestUrl as c, normalizeHostedAppBaseUrl as d, resolveHostedAppBaseUrl as f, HostedAppVersionManifest as i, isHostedAppVersionManifest as l, HostedAppChannelManifest as n, OFFICIAL_APP_BASE_URL as o, resolveHostedChannelForVersion as p, HostedAppCompatibilityEntry as r, buildHostedLaunchUrl as s, HostedAppChannelKind as t, isHostedBackendHealthResponse as u };
@@ -0,0 +1,2 @@
1
+ import { a as HostedBackendHealthResponse, c as buildHostedVersionManifestUrl, d as normalizeHostedAppBaseUrl, f as resolveHostedAppBaseUrl, i as HostedAppVersionManifest, l as isHostedAppVersionManifest, n as HostedAppChannelManifest, o as OFFICIAL_APP_BASE_URL, p as resolveHostedChannelForVersion, r as HostedAppCompatibilityEntry, s as buildHostedLaunchUrl, t as HostedAppChannelKind, u as isHostedBackendHealthResponse } from "./hosted-app-CY1XHUcf.mjs";
2
+ export { HostedAppChannelKind, HostedAppChannelManifest, HostedAppCompatibilityEntry, HostedAppVersionManifest, HostedBackendHealthResponse, OFFICIAL_APP_BASE_URL, buildHostedLaunchUrl, buildHostedVersionManifestUrl, isHostedAppVersionManifest, isHostedBackendHealthResponse, normalizeHostedAppBaseUrl, resolveHostedAppBaseUrl, resolveHostedChannelForVersion };
@@ -0,0 +1,3 @@
1
+ import { a as isHostedBackendHealthResponse, c as resolveHostedChannelForVersion, i as isHostedAppVersionManifest, n as buildHostedLaunchUrl, o as normalizeHostedAppBaseUrl, r as buildHostedVersionManifestUrl, s as resolveHostedAppBaseUrl, t as OFFICIAL_APP_BASE_URL } from "./hosted-app-Bn-MNDZ0.mjs";
2
+
3
+ export { OFFICIAL_APP_BASE_URL, buildHostedLaunchUrl, buildHostedVersionManifestUrl, isHostedAppVersionManifest, isHostedBackendHealthResponse, normalizeHostedAppBaseUrl, resolveHostedAppBaseUrl, resolveHostedChannelForVersion };
package/dist/index.d.mts CHANGED
@@ -1,4 +1,5 @@
1
- import { n as toOpsxDisplayPath, t as VIRTUAL_PROJECT_DIRNAME } from "./opsx-display-path-RBULE8_G.mjs";
1
+ import { a as HostedBackendHealthResponse, c as buildHostedVersionManifestUrl, d as normalizeHostedAppBaseUrl, f as resolveHostedAppBaseUrl, i as HostedAppVersionManifest, l as isHostedAppVersionManifest, n as HostedAppChannelManifest, o as OFFICIAL_APP_BASE_URL, p as resolveHostedChannelForVersion, r as HostedAppCompatibilityEntry, s as buildHostedLaunchUrl, t as HostedAppChannelKind, u as isHostedBackendHealthResponse } from "./hosted-app-CY1XHUcf.mjs";
2
+ import { n as toOpsxDisplayPath, t as VIRTUAL_PROJECT_DIRNAME } from "./opsx-display-path-k65bc8bW.mjs";
2
3
  import { AsyncLocalStorage } from "node:async_hooks";
3
4
  import { z } from "zod";
4
5
  import { EventEmitter } from "events";
@@ -18,13 +19,13 @@ declare const ChangeFileSchema: z.ZodObject<{
18
19
  /** Optional byte size for files */
19
20
  size: z.ZodOptional<z.ZodNumber>;
20
21
  }, "strip", z.ZodTypeAny, {
21
- path: string;
22
22
  type: "file" | "directory";
23
+ path: string;
23
24
  content?: string | undefined;
24
25
  size?: number | undefined;
25
26
  }, {
26
- path: string;
27
27
  type: "file" | "directory";
28
+ path: string;
28
29
  content?: string | undefined;
29
30
  size?: number | undefined;
30
31
  }>;
@@ -1442,6 +1443,8 @@ declare const OpenSpecUIConfigSchema: z.ZodObject<{
1442
1443
  }, {
1443
1444
  theme?: "github" | "material" | "vscode" | "tokyo" | "gruvbox" | "monokai" | "nord" | undefined;
1444
1445
  }>>;
1446
+ /** Hosted app 基础 URL(空字符串表示使用官方默认值) */
1447
+ appBaseUrl: z.ZodDefault<z.ZodString>;
1445
1448
  /** 终端配置 */
1446
1449
  terminal: z.ZodDefault<z.ZodObject<{
1447
1450
  fontSize: z.ZodDefault<z.ZodNumber>;
@@ -1482,6 +1485,7 @@ declare const OpenSpecUIConfigSchema: z.ZodObject<{
1482
1485
  codeEditor: {
1483
1486
  theme: "github" | "material" | "vscode" | "tokyo" | "gruvbox" | "monokai" | "nord";
1484
1487
  };
1488
+ appBaseUrl: string;
1485
1489
  terminal: {
1486
1490
  fontSize: number;
1487
1491
  fontFamily: string;
@@ -1502,6 +1506,7 @@ declare const OpenSpecUIConfigSchema: z.ZodObject<{
1502
1506
  codeEditor?: {
1503
1507
  theme?: "github" | "material" | "vscode" | "tokyo" | "gruvbox" | "monokai" | "nord" | undefined;
1504
1508
  } | undefined;
1509
+ appBaseUrl?: string | undefined;
1505
1510
  terminal?: {
1506
1511
  fontSize?: number | undefined;
1507
1512
  fontFamily?: string | undefined;
@@ -1522,6 +1527,7 @@ type OpenSpecUIConfigUpdate = {
1522
1527
  };
1523
1528
  theme?: OpenSpecUIConfig['theme'];
1524
1529
  codeEditor?: Partial<OpenSpecUIConfig['codeEditor']>;
1530
+ appBaseUrl?: OpenSpecUIConfig['appBaseUrl'];
1525
1531
  terminal?: Partial<TerminalConfig>;
1526
1532
  dashboard?: Partial<DashboardConfig>;
1527
1533
  };
@@ -1853,14 +1859,14 @@ declare const ArtifactStatusSchema: z.ZodObject<{
1853
1859
  missingDeps: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
1854
1860
  relativePath: z.ZodOptional<z.ZodString>;
1855
1861
  }, "strip", z.ZodTypeAny, {
1856
- id: string;
1857
1862
  status: "done" | "ready" | "blocked";
1863
+ id: string;
1858
1864
  outputPath: string;
1859
1865
  missingDeps?: string[] | undefined;
1860
1866
  relativePath?: string | undefined;
1861
1867
  }, {
1862
- id: string;
1863
1868
  status: "done" | "ready" | "blocked";
1869
+ id: string;
1864
1870
  outputPath: string;
1865
1871
  missingDeps?: string[] | undefined;
1866
1872
  relativePath?: string | undefined;
@@ -1878,14 +1884,14 @@ declare const ChangeStatusSchema: z.ZodObject<{
1878
1884
  missingDeps: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
1879
1885
  relativePath: z.ZodOptional<z.ZodString>;
1880
1886
  }, "strip", z.ZodTypeAny, {
1881
- id: string;
1882
1887
  status: "done" | "ready" | "blocked";
1888
+ id: string;
1883
1889
  outputPath: string;
1884
1890
  missingDeps?: string[] | undefined;
1885
1891
  relativePath?: string | undefined;
1886
1892
  }, {
1887
- id: string;
1888
1893
  status: "done" | "ready" | "blocked";
1894
+ id: string;
1889
1895
  outputPath: string;
1890
1896
  missingDeps?: string[] | undefined;
1891
1897
  relativePath?: string | undefined;
@@ -1896,8 +1902,8 @@ declare const ChangeStatusSchema: z.ZodObject<{
1896
1902
  isComplete: boolean;
1897
1903
  applyRequires: string[];
1898
1904
  artifacts: {
1899
- id: string;
1900
1905
  status: "done" | "ready" | "blocked";
1906
+ id: string;
1901
1907
  outputPath: string;
1902
1908
  missingDeps?: string[] | undefined;
1903
1909
  relativePath?: string | undefined;
@@ -1908,8 +1914,8 @@ declare const ChangeStatusSchema: z.ZodObject<{
1908
1914
  isComplete: boolean;
1909
1915
  applyRequires: string[];
1910
1916
  artifacts: {
1911
- id: string;
1912
1917
  status: "done" | "ready" | "blocked";
1918
+ id: string;
1913
1919
  outputPath: string;
1914
1920
  missingDeps?: string[] | undefined;
1915
1921
  relativePath?: string | undefined;
@@ -1922,13 +1928,13 @@ declare const DependencyInfoSchema: z.ZodObject<{
1922
1928
  path: z.ZodString;
1923
1929
  description: z.ZodString;
1924
1930
  }, "strip", z.ZodTypeAny, {
1925
- id: string;
1926
1931
  path: string;
1932
+ id: string;
1927
1933
  description: string;
1928
1934
  done: boolean;
1929
1935
  }, {
1930
- id: string;
1931
1936
  path: string;
1937
+ id: string;
1932
1938
  description: string;
1933
1939
  done: boolean;
1934
1940
  }>;
@@ -2036,13 +2042,13 @@ declare const ArtifactInstructionsSchema: z.ZodObject<{
2036
2042
  path: z.ZodString;
2037
2043
  description: z.ZodString;
2038
2044
  }, "strip", z.ZodTypeAny, {
2039
- id: string;
2040
2045
  path: string;
2046
+ id: string;
2041
2047
  description: string;
2042
2048
  done: boolean;
2043
2049
  }, {
2044
- id: string;
2045
2050
  path: string;
2051
+ id: string;
2046
2052
  description: string;
2047
2053
  done: boolean;
2048
2054
  }>, "many">;
@@ -2056,8 +2062,8 @@ declare const ArtifactInstructionsSchema: z.ZodObject<{
2056
2062
  artifactId: string;
2057
2063
  template: string;
2058
2064
  dependencies: {
2059
- id: string;
2060
2065
  path: string;
2066
+ id: string;
2061
2067
  description: string;
2062
2068
  done: boolean;
2063
2069
  }[];
@@ -2074,8 +2080,8 @@ declare const ArtifactInstructionsSchema: z.ZodObject<{
2074
2080
  artifactId: string;
2075
2081
  template: string;
2076
2082
  dependencies: {
2077
- id: string;
2078
2083
  path: string;
2084
+ id: string;
2079
2085
  description: string;
2080
2086
  done: boolean;
2081
2087
  }[];
@@ -2121,8 +2127,8 @@ declare const SchemaResolutionSchema: z.ZodObject<{
2121
2127
  displayPath?: string | undefined;
2122
2128
  }>, "many">;
2123
2129
  }, "strip", z.ZodTypeAny, {
2124
- name: string;
2125
2130
  path: string;
2131
+ name: string;
2126
2132
  source: "project" | "user" | "package";
2127
2133
  shadows: {
2128
2134
  path: string;
@@ -2131,8 +2137,8 @@ declare const SchemaResolutionSchema: z.ZodObject<{
2131
2137
  }[];
2132
2138
  displayPath?: string | undefined;
2133
2139
  }, {
2134
- name: string;
2135
2140
  path: string;
2141
+ name: string;
2136
2142
  source: "project" | "user" | "package";
2137
2143
  shadows: {
2138
2144
  path: string;
@@ -2472,22 +2478,22 @@ declare const PtySessionInfoSchema: z.ZodObject<{
2472
2478
  closeTip: z.ZodOptional<z.ZodString>;
2473
2479
  closeCallbackUrl: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
2474
2480
  }, "strip", z.ZodTypeAny, {
2475
- id: string;
2476
2481
  command: string;
2477
2482
  args: string[];
2478
2483
  platform: "windows" | "macos" | "common";
2479
2484
  exitCode: number | null;
2480
2485
  title: string;
2486
+ id: string;
2481
2487
  isExited: boolean;
2482
2488
  closeTip?: string | undefined;
2483
2489
  closeCallbackUrl?: string | Record<string, string> | undefined;
2484
2490
  }, {
2485
- id: string;
2486
2491
  command: string;
2487
2492
  args: string[];
2488
2493
  platform: "windows" | "macos" | "common";
2489
2494
  exitCode: number | null;
2490
2495
  title: string;
2496
+ id: string;
2491
2497
  isExited: boolean;
2492
2498
  closeTip?: string | undefined;
2493
2499
  closeCallbackUrl?: string | Record<string, string> | undefined;
@@ -2504,19 +2510,19 @@ declare const PtyCreateMessageSchema: z.ZodObject<{
2504
2510
  }, "strip", z.ZodTypeAny, {
2505
2511
  type: "create";
2506
2512
  requestId: string;
2507
- command?: string | undefined;
2508
- args?: string[] | undefined;
2509
2513
  cols?: number | undefined;
2510
2514
  rows?: number | undefined;
2515
+ command?: string | undefined;
2516
+ args?: string[] | undefined;
2511
2517
  closeTip?: string | undefined;
2512
2518
  closeCallbackUrl?: string | Record<string, string> | undefined;
2513
2519
  }, {
2514
2520
  type: "create";
2515
2521
  requestId: string;
2516
- command?: string | undefined;
2517
- args?: string[] | undefined;
2518
2522
  cols?: number | undefined;
2519
2523
  rows?: number | undefined;
2524
+ command?: string | undefined;
2525
+ args?: string[] | undefined;
2520
2526
  closeTip?: string | undefined;
2521
2527
  closeCallbackUrl?: string | Record<string, string> | undefined;
2522
2528
  }>;
@@ -2594,19 +2600,19 @@ declare const PtyClientMessageSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObje
2594
2600
  }, "strip", z.ZodTypeAny, {
2595
2601
  type: "create";
2596
2602
  requestId: string;
2597
- command?: string | undefined;
2598
- args?: string[] | undefined;
2599
2603
  cols?: number | undefined;
2600
2604
  rows?: number | undefined;
2605
+ command?: string | undefined;
2606
+ args?: string[] | undefined;
2601
2607
  closeTip?: string | undefined;
2602
2608
  closeCallbackUrl?: string | Record<string, string> | undefined;
2603
2609
  }, {
2604
2610
  type: "create";
2605
2611
  requestId: string;
2606
- command?: string | undefined;
2607
- args?: string[] | undefined;
2608
2612
  cols?: number | undefined;
2609
2613
  rows?: number | undefined;
2614
+ command?: string | undefined;
2615
+ args?: string[] | undefined;
2610
2616
  closeTip?: string | undefined;
2611
2617
  closeCallbackUrl?: string | Record<string, string> | undefined;
2612
2618
  }>, z.ZodObject<{
@@ -2748,22 +2754,22 @@ declare const PtyListResponseSchema: z.ZodObject<{
2748
2754
  closeTip: z.ZodOptional<z.ZodString>;
2749
2755
  closeCallbackUrl: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
2750
2756
  }, "strip", z.ZodTypeAny, {
2751
- id: string;
2752
2757
  command: string;
2753
2758
  args: string[];
2754
2759
  platform: "windows" | "macos" | "common";
2755
2760
  exitCode: number | null;
2756
2761
  title: string;
2762
+ id: string;
2757
2763
  isExited: boolean;
2758
2764
  closeTip?: string | undefined;
2759
2765
  closeCallbackUrl?: string | Record<string, string> | undefined;
2760
2766
  }, {
2761
- id: string;
2762
2767
  command: string;
2763
2768
  args: string[];
2764
2769
  platform: "windows" | "macos" | "common";
2765
2770
  exitCode: number | null;
2766
2771
  title: string;
2772
+ id: string;
2767
2773
  isExited: boolean;
2768
2774
  closeTip?: string | undefined;
2769
2775
  closeCallbackUrl?: string | Record<string, string> | undefined;
@@ -2771,12 +2777,12 @@ declare const PtyListResponseSchema: z.ZodObject<{
2771
2777
  }, "strip", z.ZodTypeAny, {
2772
2778
  type: "list";
2773
2779
  sessions: {
2774
- id: string;
2775
2780
  command: string;
2776
2781
  args: string[];
2777
2782
  platform: "windows" | "macos" | "common";
2778
2783
  exitCode: number | null;
2779
2784
  title: string;
2785
+ id: string;
2780
2786
  isExited: boolean;
2781
2787
  closeTip?: string | undefined;
2782
2788
  closeCallbackUrl?: string | Record<string, string> | undefined;
@@ -2784,12 +2790,12 @@ declare const PtyListResponseSchema: z.ZodObject<{
2784
2790
  }, {
2785
2791
  type: "list";
2786
2792
  sessions: {
2787
- id: string;
2788
2793
  command: string;
2789
2794
  args: string[];
2790
2795
  platform: "windows" | "macos" | "common";
2791
2796
  exitCode: number | null;
2792
2797
  title: string;
2798
+ id: string;
2793
2799
  isExited: boolean;
2794
2800
  closeTip?: string | undefined;
2795
2801
  closeCallbackUrl?: string | Record<string, string> | undefined;
@@ -2802,14 +2808,14 @@ declare const PtyErrorResponseSchema: z.ZodObject<{
2802
2808
  message: z.ZodString;
2803
2809
  sessionId: z.ZodOptional<z.ZodString>;
2804
2810
  }, "strip", z.ZodTypeAny, {
2811
+ type: "error";
2805
2812
  code: "INVALID_JSON" | "INVALID_MESSAGE" | "SESSION_NOT_FOUND" | "PTY_CREATE_FAILED";
2806
2813
  message: string;
2807
- type: "error";
2808
2814
  sessionId?: string | undefined;
2809
2815
  }, {
2816
+ type: "error";
2810
2817
  code: "INVALID_JSON" | "INVALID_MESSAGE" | "SESSION_NOT_FOUND" | "PTY_CREATE_FAILED";
2811
2818
  message: string;
2812
- type: "error";
2813
2819
  sessionId?: string | undefined;
2814
2820
  }>;
2815
2821
  declare const PtyServerMessageSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
@@ -2888,22 +2894,22 @@ declare const PtyServerMessageSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObje
2888
2894
  closeTip: z.ZodOptional<z.ZodString>;
2889
2895
  closeCallbackUrl: z.ZodOptional<z.ZodUnion<[z.ZodString, z.ZodRecord<z.ZodString, z.ZodString>]>>;
2890
2896
  }, "strip", z.ZodTypeAny, {
2891
- id: string;
2892
2897
  command: string;
2893
2898
  args: string[];
2894
2899
  platform: "windows" | "macos" | "common";
2895
2900
  exitCode: number | null;
2896
2901
  title: string;
2902
+ id: string;
2897
2903
  isExited: boolean;
2898
2904
  closeTip?: string | undefined;
2899
2905
  closeCallbackUrl?: string | Record<string, string> | undefined;
2900
2906
  }, {
2901
- id: string;
2902
2907
  command: string;
2903
2908
  args: string[];
2904
2909
  platform: "windows" | "macos" | "common";
2905
2910
  exitCode: number | null;
2906
2911
  title: string;
2912
+ id: string;
2907
2913
  isExited: boolean;
2908
2914
  closeTip?: string | undefined;
2909
2915
  closeCallbackUrl?: string | Record<string, string> | undefined;
@@ -2911,12 +2917,12 @@ declare const PtyServerMessageSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObje
2911
2917
  }, "strip", z.ZodTypeAny, {
2912
2918
  type: "list";
2913
2919
  sessions: {
2914
- id: string;
2915
2920
  command: string;
2916
2921
  args: string[];
2917
2922
  platform: "windows" | "macos" | "common";
2918
2923
  exitCode: number | null;
2919
2924
  title: string;
2925
+ id: string;
2920
2926
  isExited: boolean;
2921
2927
  closeTip?: string | undefined;
2922
2928
  closeCallbackUrl?: string | Record<string, string> | undefined;
@@ -2924,12 +2930,12 @@ declare const PtyServerMessageSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObje
2924
2930
  }, {
2925
2931
  type: "list";
2926
2932
  sessions: {
2927
- id: string;
2928
2933
  command: string;
2929
2934
  args: string[];
2930
2935
  platform: "windows" | "macos" | "common";
2931
2936
  exitCode: number | null;
2932
2937
  title: string;
2938
+ id: string;
2933
2939
  isExited: boolean;
2934
2940
  closeTip?: string | undefined;
2935
2941
  closeCallbackUrl?: string | Record<string, string> | undefined;
@@ -2940,14 +2946,14 @@ declare const PtyServerMessageSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObje
2940
2946
  message: z.ZodString;
2941
2947
  sessionId: z.ZodOptional<z.ZodString>;
2942
2948
  }, "strip", z.ZodTypeAny, {
2949
+ type: "error";
2943
2950
  code: "INVALID_JSON" | "INVALID_MESSAGE" | "SESSION_NOT_FOUND" | "PTY_CREATE_FAILED";
2944
2951
  message: string;
2945
- type: "error";
2946
2952
  sessionId?: string | undefined;
2947
2953
  }, {
2954
+ type: "error";
2948
2955
  code: "INVALID_JSON" | "INVALID_MESSAGE" | "SESSION_NOT_FOUND" | "PTY_CREATE_FAILED";
2949
2956
  message: string;
2950
- type: "error";
2951
2957
  sessionId?: string | undefined;
2952
2958
  }>]>;
2953
2959
  type PtyClientMessage = z.infer<typeof PtyClientMessageSchema>;
@@ -2955,4 +2961,4 @@ type PtyServerMessage = z.infer<typeof PtyServerMessageSchema>;
2955
2961
  type PtySessionInfo = z.infer<typeof PtySessionInfoSchema>;
2956
2962
  type PtyPlatform = z.infer<typeof PtyPlatformSchema>;
2957
2963
  //#endregion
2958
- export { type AIToolOption, AI_TOOLS, type ApplyInstructions, ApplyInstructionsSchema, type ApplyTask, ApplyTaskSchema, type ArchiveMeta, type ArtifactInstructions, ArtifactInstructionsSchema, type ArtifactStatus, ArtifactStatusSchema, CODE_EDITOR_THEME_VALUES, type Change, type ChangeFile, ChangeFileSchema, type ChangeMeta, ChangeSchema, type ChangeStatus, ChangeStatusSchema, CliExecutor, type CliResult, type CliRunnerAttempt, type CliSniffResult, type CliStreamEvent, type CodeEditorTheme, CodeEditorThemeSchema, ConfigManager, DASHBOARD_METRIC_KEYS, DEFAULT_CONFIG, type DashboardCardAvailability, type DashboardConfig, DashboardConfigSchema, type DashboardGitCommitEntry, type DashboardGitDiffStats, type DashboardGitEntry, type DashboardGitSnapshot, type DashboardGitUncommittedEntry, type DashboardGitWorktree, type DashboardMetricKey, type DashboardOverview, type DashboardSummary, type DashboardTrendKind, type DashboardTrendMeta, type DashboardTrendPoint, type DashboardTriColorTrendPoint, type Delta, type DeltaOperation, DeltaOperationType, DeltaSchema, type DeltaSpec, DeltaSpecSchema, type DependencyInfo, DependencyInfoSchema, type ExportSnapshot, type FileChangeEvent, type FileChangeType, MarkdownParser, OpenSpecAdapter, type OpenSpecUIConfig, OpenSpecUIConfigSchema, type OpenSpecUIConfigUpdate, OpenSpecWatcher, OpsxKernel, type PathCallback, ProjectWatcher, type ProjectWatcherReinitializeReason, type ProjectWatcherRuntimeStatus, PtyAttachMessageSchema, PtyBufferResponseSchema, type PtyClientMessage, PtyClientMessageSchema, PtyCloseMessageSchema, PtyCreateMessageSchema, PtyCreatedResponseSchema, PtyErrorCodeSchema, PtyErrorResponseSchema, PtyExitResponseSchema, PtyInputMessageSchema, PtyListMessageSchema, PtyListResponseSchema, PtyOutputResponseSchema, type PtyPlatform, PtyPlatformSchema, PtyResizeMessageSchema, type PtyServerMessage, PtyServerMessageSchema, type PtySessionInfo, PtyTitleResponseSchema, ReactiveContext, ReactiveState, type ReactiveStateOptions, type Requirement, RequirementSchema, type ResolvedCliRunner, type SchemaArtifact, SchemaArtifactSchema, type SchemaDetail, SchemaDetailSchema, type SchemaInfo, SchemaInfoSchema, type SchemaResolution, SchemaResolutionSchema, type Spec, type SpecMeta, SpecSchema, type Task, TaskSchema, type TemplateContentMap, type TemplatesMap, TemplatesSchema, type TerminalConfig, TerminalConfigSchema, type TerminalRendererEngine, TerminalRendererEngineSchema, type ToolConfig, VIRTUAL_PROJECT_DIRNAME, type ValidationIssue, type ValidationResult, Validator, type WatchEvent, type WatchEventType, type WatcherRuntimeStatus, acquireWatcher, buildCliRunnerCandidates, clearCache, closeAllProjectWatchers, closeAllWatchers, contextStorage, createCleanCliEnv, createFileChangeObservable, getActiveWatcherCount, getAllToolIds, getAllTools, getAvailableToolIds, getAvailableTools, getCacheSize, getConfiguredTools, getDefaultCliCommand, getDefaultCliCommandString, getProjectWatcher, getToolById, getWatchedProjectDir, getWatcherRuntimeStatus, initWatcherPool, isGlobPattern, isTerminalRendererEngine, isToolConfigured, isWatcherPoolInitialized, parseCliCommand, reactiveExists, reactiveReadDir, reactiveReadFile, reactiveStat, sniffGlobalCli, toOpsxDisplayPath };
2964
+ export { type AIToolOption, AI_TOOLS, type ApplyInstructions, ApplyInstructionsSchema, type ApplyTask, ApplyTaskSchema, type ArchiveMeta, type ArtifactInstructions, ArtifactInstructionsSchema, type ArtifactStatus, ArtifactStatusSchema, CODE_EDITOR_THEME_VALUES, type Change, type ChangeFile, ChangeFileSchema, type ChangeMeta, ChangeSchema, type ChangeStatus, ChangeStatusSchema, CliExecutor, type CliResult, type CliRunnerAttempt, type CliSniffResult, type CliStreamEvent, type CodeEditorTheme, CodeEditorThemeSchema, ConfigManager, DASHBOARD_METRIC_KEYS, DEFAULT_CONFIG, type DashboardCardAvailability, type DashboardConfig, DashboardConfigSchema, type DashboardGitCommitEntry, type DashboardGitDiffStats, type DashboardGitEntry, type DashboardGitSnapshot, type DashboardGitUncommittedEntry, type DashboardGitWorktree, type DashboardMetricKey, type DashboardOverview, type DashboardSummary, type DashboardTrendKind, type DashboardTrendMeta, type DashboardTrendPoint, type DashboardTriColorTrendPoint, type Delta, type DeltaOperation, DeltaOperationType, DeltaSchema, type DeltaSpec, DeltaSpecSchema, type DependencyInfo, DependencyInfoSchema, type ExportSnapshot, type FileChangeEvent, type FileChangeType, type HostedAppChannelKind, type HostedAppChannelManifest, type HostedAppCompatibilityEntry, type HostedAppVersionManifest, type HostedBackendHealthResponse, MarkdownParser, OFFICIAL_APP_BASE_URL, OpenSpecAdapter, type OpenSpecUIConfig, OpenSpecUIConfigSchema, type OpenSpecUIConfigUpdate, OpenSpecWatcher, OpsxKernel, type PathCallback, ProjectWatcher, type ProjectWatcherReinitializeReason, type ProjectWatcherRuntimeStatus, PtyAttachMessageSchema, PtyBufferResponseSchema, type PtyClientMessage, PtyClientMessageSchema, PtyCloseMessageSchema, PtyCreateMessageSchema, PtyCreatedResponseSchema, PtyErrorCodeSchema, PtyErrorResponseSchema, PtyExitResponseSchema, PtyInputMessageSchema, PtyListMessageSchema, PtyListResponseSchema, PtyOutputResponseSchema, type PtyPlatform, PtyPlatformSchema, PtyResizeMessageSchema, type PtyServerMessage, PtyServerMessageSchema, type PtySessionInfo, PtyTitleResponseSchema, ReactiveContext, ReactiveState, type ReactiveStateOptions, type Requirement, RequirementSchema, type ResolvedCliRunner, type SchemaArtifact, SchemaArtifactSchema, type SchemaDetail, SchemaDetailSchema, type SchemaInfo, SchemaInfoSchema, type SchemaResolution, SchemaResolutionSchema, type Spec, type SpecMeta, SpecSchema, type Task, TaskSchema, type TemplateContentMap, type TemplatesMap, TemplatesSchema, type TerminalConfig, TerminalConfigSchema, type TerminalRendererEngine, TerminalRendererEngineSchema, type ToolConfig, VIRTUAL_PROJECT_DIRNAME, type ValidationIssue, type ValidationResult, Validator, type WatchEvent, type WatchEventType, type WatcherRuntimeStatus, acquireWatcher, buildCliRunnerCandidates, buildHostedLaunchUrl, buildHostedVersionManifestUrl, clearCache, closeAllProjectWatchers, closeAllWatchers, contextStorage, createCleanCliEnv, createFileChangeObservable, getActiveWatcherCount, getAllToolIds, getAllTools, getAvailableToolIds, getAvailableTools, getCacheSize, getConfiguredTools, getDefaultCliCommand, getDefaultCliCommandString, getProjectWatcher, getToolById, getWatchedProjectDir, getWatcherRuntimeStatus, initWatcherPool, isGlobPattern, isHostedAppVersionManifest, isHostedBackendHealthResponse, isTerminalRendererEngine, isToolConfigured, isWatcherPoolInitialized, normalizeHostedAppBaseUrl, parseCliCommand, reactiveExists, reactiveReadDir, reactiveReadFile, reactiveStat, resolveHostedAppBaseUrl, resolveHostedChannelForVersion, sniffGlobalCli, toOpsxDisplayPath };
package/dist/index.mjs CHANGED
@@ -1,4 +1,5 @@
1
- import { n as toOpsxDisplayPath, t as VIRTUAL_PROJECT_DIRNAME } from "./opsx-display-path-DYIjMsbM.mjs";
1
+ import { a as isHostedBackendHealthResponse, c as resolveHostedChannelForVersion, i as isHostedAppVersionManifest, n as buildHostedLaunchUrl, o as normalizeHostedAppBaseUrl, r as buildHostedVersionManifestUrl, s as resolveHostedAppBaseUrl, t as OFFICIAL_APP_BASE_URL } from "./hosted-app-Bn-MNDZ0.mjs";
2
+ import { n as toOpsxDisplayPath, t as VIRTUAL_PROJECT_DIRNAME } from "./opsx-display-path-D-YbNUvQ.mjs";
2
3
  import { mkdir, readFile, rename, writeFile } from "fs/promises";
3
4
  import { dirname, join } from "path";
4
5
  import { AsyncLocalStorage } from "node:async_hooks";
@@ -2330,6 +2331,7 @@ const OpenSpecUIConfigSchema = z.object({
2330
2331
  }).default({}),
2331
2332
  theme: z.enum(THEME_VALUES).default("system"),
2332
2333
  codeEditor: CodeEditorConfigSchema.default(CodeEditorConfigSchema.parse({})),
2334
+ appBaseUrl: z.string().default(""),
2333
2335
  terminal: TerminalConfigSchema.default(TerminalConfigSchema.parse({})),
2334
2336
  dashboard: DashboardConfigSchema.default(DashboardConfigSchema.parse({}))
2335
2337
  });
@@ -2338,6 +2340,7 @@ const DEFAULT_CONFIG = {
2338
2340
  cli: {},
2339
2341
  theme: "system",
2340
2342
  codeEditor: CodeEditorConfigSchema.parse({}),
2343
+ appBaseUrl: "",
2341
2344
  terminal: TerminalConfigSchema.parse({}),
2342
2345
  dashboard: DashboardConfigSchema.parse({})
2343
2346
  };
@@ -2406,6 +2409,7 @@ var ConfigManager = class {
2406
2409
  ...current.codeEditor,
2407
2410
  ...config.codeEditor
2408
2411
  },
2412
+ appBaseUrl: config.appBaseUrl ?? current.appBaseUrl,
2409
2413
  terminal: {
2410
2414
  ...current.terminal,
2411
2415
  ...config.terminal
@@ -4075,4 +4079,4 @@ const PtyServerMessageSchema = z.discriminatedUnion("type", [
4075
4079
  ]);
4076
4080
 
4077
4081
  //#endregion
4078
- export { AI_TOOLS, ApplyInstructionsSchema, ApplyTaskSchema, ArtifactInstructionsSchema, ArtifactStatusSchema, CODE_EDITOR_THEME_VALUES, ChangeFileSchema, ChangeSchema, ChangeStatusSchema, CliExecutor, CodeEditorThemeSchema, ConfigManager, DASHBOARD_METRIC_KEYS, DEFAULT_CONFIG, DashboardConfigSchema, DeltaOperationType, DeltaSchema, DeltaSpecSchema, DependencyInfoSchema, MarkdownParser, OpenSpecAdapter, OpenSpecUIConfigSchema, OpenSpecWatcher, OpsxKernel, ProjectWatcher, PtyAttachMessageSchema, PtyBufferResponseSchema, PtyClientMessageSchema, PtyCloseMessageSchema, PtyCreateMessageSchema, PtyCreatedResponseSchema, PtyErrorCodeSchema, PtyErrorResponseSchema, PtyExitResponseSchema, PtyInputMessageSchema, PtyListMessageSchema, PtyListResponseSchema, PtyOutputResponseSchema, PtyPlatformSchema, PtyResizeMessageSchema, PtyServerMessageSchema, PtyTitleResponseSchema, ReactiveContext, ReactiveState, RequirementSchema, SchemaArtifactSchema, SchemaDetailSchema, SchemaInfoSchema, SchemaResolutionSchema, SpecSchema, TaskSchema, TemplatesSchema, TerminalConfigSchema, TerminalRendererEngineSchema, VIRTUAL_PROJECT_DIRNAME, Validator, acquireWatcher, buildCliRunnerCandidates, clearCache, closeAllProjectWatchers, closeAllWatchers, contextStorage, createCleanCliEnv, createFileChangeObservable, getActiveWatcherCount, getAllToolIds, getAllTools, getAvailableToolIds, getAvailableTools, getCacheSize, getConfiguredTools, getDefaultCliCommand, getDefaultCliCommandString, getProjectWatcher, getToolById, getWatchedProjectDir, getWatcherRuntimeStatus, initWatcherPool, isGlobPattern, isTerminalRendererEngine, isToolConfigured, isWatcherPoolInitialized, parseCliCommand, reactiveExists, reactiveReadDir, reactiveReadFile, reactiveStat, sniffGlobalCli, toOpsxDisplayPath };
4082
+ export { AI_TOOLS, ApplyInstructionsSchema, ApplyTaskSchema, ArtifactInstructionsSchema, ArtifactStatusSchema, CODE_EDITOR_THEME_VALUES, ChangeFileSchema, ChangeSchema, ChangeStatusSchema, CliExecutor, CodeEditorThemeSchema, ConfigManager, DASHBOARD_METRIC_KEYS, DEFAULT_CONFIG, DashboardConfigSchema, DeltaOperationType, DeltaSchema, DeltaSpecSchema, DependencyInfoSchema, MarkdownParser, OFFICIAL_APP_BASE_URL, OpenSpecAdapter, OpenSpecUIConfigSchema, OpenSpecWatcher, OpsxKernel, ProjectWatcher, PtyAttachMessageSchema, PtyBufferResponseSchema, PtyClientMessageSchema, PtyCloseMessageSchema, PtyCreateMessageSchema, PtyCreatedResponseSchema, PtyErrorCodeSchema, PtyErrorResponseSchema, PtyExitResponseSchema, PtyInputMessageSchema, PtyListMessageSchema, PtyListResponseSchema, PtyOutputResponseSchema, PtyPlatformSchema, PtyResizeMessageSchema, PtyServerMessageSchema, PtyTitleResponseSchema, ReactiveContext, ReactiveState, RequirementSchema, SchemaArtifactSchema, SchemaDetailSchema, SchemaInfoSchema, SchemaResolutionSchema, SpecSchema, TaskSchema, TemplatesSchema, TerminalConfigSchema, TerminalRendererEngineSchema, VIRTUAL_PROJECT_DIRNAME, Validator, acquireWatcher, buildCliRunnerCandidates, buildHostedLaunchUrl, buildHostedVersionManifestUrl, clearCache, closeAllProjectWatchers, closeAllWatchers, contextStorage, createCleanCliEnv, createFileChangeObservable, getActiveWatcherCount, getAllToolIds, getAllTools, getAvailableToolIds, getAvailableTools, getCacheSize, getConfiguredTools, getDefaultCliCommand, getDefaultCliCommandString, getProjectWatcher, getToolById, getWatchedProjectDir, getWatcherRuntimeStatus, initWatcherPool, isGlobPattern, isHostedAppVersionManifest, isHostedBackendHealthResponse, isTerminalRendererEngine, isToolConfigured, isWatcherPoolInitialized, normalizeHostedAppBaseUrl, parseCliCommand, reactiveExists, reactiveReadDir, reactiveReadFile, reactiveStat, resolveHostedAppBaseUrl, resolveHostedChannelForVersion, sniffGlobalCli, toOpsxDisplayPath };
@@ -1,2 +1,2 @@
1
- import { n as toOpsxDisplayPath, t as VIRTUAL_PROJECT_DIRNAME } from "./opsx-display-path-RBULE8_G.mjs";
1
+ import { n as toOpsxDisplayPath, t as VIRTUAL_PROJECT_DIRNAME } from "./opsx-display-path-k65bc8bW.mjs";
2
2
  export { VIRTUAL_PROJECT_DIRNAME, toOpsxDisplayPath };
@@ -1,3 +1,3 @@
1
- import { n as toOpsxDisplayPath, t as VIRTUAL_PROJECT_DIRNAME } from "./opsx-display-path-DYIjMsbM.mjs";
1
+ import { n as toOpsxDisplayPath, t as VIRTUAL_PROJECT_DIRNAME } from "./opsx-display-path-D-YbNUvQ.mjs";
2
2
 
3
3
  export { VIRTUAL_PROJECT_DIRNAME, toOpsxDisplayPath };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openspecui/core",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "description": "Core OpenSpec adapter and parser",
5
5
  "type": "module",
6
6
  "main": "./dist/index.mjs",
@@ -10,6 +10,10 @@
10
10
  "import": "./dist/index.mjs",
11
11
  "types": "./dist/index.d.mts"
12
12
  },
13
+ "./hosted-app": {
14
+ "import": "./dist/hosted-app.mjs",
15
+ "types": "./dist/hosted-app.d.mts"
16
+ },
13
17
  "./opsx-display-path": {
14
18
  "import": "./dist/opsx-display-path.mjs",
15
19
  "types": "./dist/opsx-display-path.d.mts"
@@ -33,8 +37,8 @@
33
37
  "typescript": "^5.0.0"
34
38
  },
35
39
  "scripts": {
36
- "build": "tsdown src/index.ts src/opsx-display-path.ts --format esm --dts",
37
- "dev": "tsdown src/index.ts src/opsx-display-path.ts --format esm --dts --watch",
40
+ "build": "tsdown src/index.ts src/opsx-display-path.ts src/hosted-app.ts --format esm --dts",
41
+ "dev": "tsdown src/index.ts src/opsx-display-path.ts src/hosted-app.ts --format esm --dts --watch",
38
42
  "test": "vitest run",
39
43
  "test:watch": "vitest",
40
44
  "typecheck": "tsc --noEmit"