@openspecui/core 3.0.0 → 3.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.
- package/dist/hosted-app-B6b6fAYZ.d.mts +31 -0
- package/dist/hosted-app-RXZDSUtU.mjs +74 -0
- package/dist/hosted-app.d.mts +2 -2
- package/dist/hosted-app.mjs +2 -2
- package/dist/index.d.mts +28 -2
- package/dist/index.mjs +14 -2
- package/package.json +1 -1
- package/dist/hosted-app-Bv10mEdq.mjs +0 -86
- package/dist/hosted-app-Dy4D7wV9.d.mts +0 -46
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
//#region src/hosted-app.d.ts
|
|
2
|
+
declare const OFFICIAL_APP_BASE_URL = "https://app.openspecui.com";
|
|
3
|
+
declare const HOSTED_SHELL_PROTOCOL_VERSION = 1;
|
|
4
|
+
interface HostedBackendHealthResponse {
|
|
5
|
+
status: 'ok';
|
|
6
|
+
projectDir: string;
|
|
7
|
+
projectName: string;
|
|
8
|
+
watcherEnabled: boolean;
|
|
9
|
+
openspecuiVersion: string;
|
|
10
|
+
hostedShellProtocolVersion: typeof HOSTED_SHELL_PROTOCOL_VERSION;
|
|
11
|
+
embeddedUiUrl: string;
|
|
12
|
+
}
|
|
13
|
+
declare function normalizeHostedAppBaseUrl(input: string): string;
|
|
14
|
+
declare function resolveHostedAppBaseUrl(options: {
|
|
15
|
+
override?: string | null;
|
|
16
|
+
configured?: string | null;
|
|
17
|
+
}): string;
|
|
18
|
+
declare function normalizeEmbeddedUiUrl(input: string): string;
|
|
19
|
+
declare function isSupportedEmbeddedUiUrl(input: string): boolean;
|
|
20
|
+
declare function buildHostedLaunchUrl(options: {
|
|
21
|
+
baseUrl: string;
|
|
22
|
+
apiBaseUrl: string;
|
|
23
|
+
}): string;
|
|
24
|
+
declare function buildEmbeddedUiLaunchUrl(options: {
|
|
25
|
+
embeddedUiUrl: string;
|
|
26
|
+
apiBaseUrl: string;
|
|
27
|
+
sessionId: string;
|
|
28
|
+
}): string;
|
|
29
|
+
declare function isHostedBackendHealthResponse(value: unknown): value is HostedBackendHealthResponse;
|
|
30
|
+
//#endregion
|
|
31
|
+
export { buildHostedLaunchUrl as a, normalizeEmbeddedUiUrl as c, buildEmbeddedUiLaunchUrl as i, normalizeHostedAppBaseUrl as l, HostedBackendHealthResponse as n, isHostedBackendHealthResponse as o, OFFICIAL_APP_BASE_URL as r, isSupportedEmbeddedUiUrl as s, HOSTED_SHELL_PROTOCOL_VERSION as t, resolveHostedAppBaseUrl as u };
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
//#region src/hosted-app.ts
|
|
2
|
+
const OFFICIAL_APP_BASE_URL = "https://app.openspecui.com";
|
|
3
|
+
const HOSTED_SHELL_PROTOCOL_VERSION = 1;
|
|
4
|
+
function isRecord(value) {
|
|
5
|
+
return typeof value === "object" && value !== null;
|
|
6
|
+
}
|
|
7
|
+
function withHttpsProtocol(value) {
|
|
8
|
+
if (/^[a-zA-Z][a-zA-Z\d+.-]*:\/\//.test(value)) return value;
|
|
9
|
+
return `https://${value}`;
|
|
10
|
+
}
|
|
11
|
+
function normalizeHostedAppBaseUrl(input) {
|
|
12
|
+
const trimmed = input.trim();
|
|
13
|
+
if (!trimmed) throw new Error("Hosted app base URL must not be empty");
|
|
14
|
+
let parsed;
|
|
15
|
+
try {
|
|
16
|
+
parsed = new URL(withHttpsProtocol(trimmed));
|
|
17
|
+
} catch (error) {
|
|
18
|
+
throw new Error(`Invalid hosted app base URL: ${error instanceof Error ? error.message : String(error)}`);
|
|
19
|
+
}
|
|
20
|
+
parsed.hash = "";
|
|
21
|
+
parsed.search = "";
|
|
22
|
+
const pathname = parsed.pathname.replace(/\/+$/, "");
|
|
23
|
+
parsed.pathname = pathname.length > 0 ? pathname : "/";
|
|
24
|
+
return parsed.toString().replace(/\/$/, parsed.pathname === "/" ? "" : "");
|
|
25
|
+
}
|
|
26
|
+
function resolveHostedAppBaseUrl(options) {
|
|
27
|
+
return normalizeHostedAppBaseUrl(options.override?.trim() || options.configured?.trim() || OFFICIAL_APP_BASE_URL);
|
|
28
|
+
}
|
|
29
|
+
function normalizeEmbeddedUiUrl(input) {
|
|
30
|
+
const trimmed = input.trim();
|
|
31
|
+
if (!trimmed) throw new Error("Embedded UI URL must not be empty");
|
|
32
|
+
let parsed;
|
|
33
|
+
try {
|
|
34
|
+
parsed = new URL(trimmed);
|
|
35
|
+
} catch (error) {
|
|
36
|
+
throw new Error(`Invalid embedded UI URL: ${error instanceof Error ? error.message : String(error)}`);
|
|
37
|
+
}
|
|
38
|
+
parsed.hash = "";
|
|
39
|
+
const pathname = parsed.pathname.replace(/\/+$/, "");
|
|
40
|
+
parsed.pathname = pathname.length > 0 ? pathname : "/";
|
|
41
|
+
return parsed.toString().replace(/\/$/, parsed.pathname === "/" ? "" : "");
|
|
42
|
+
}
|
|
43
|
+
function isLoopbackHostname(hostname) {
|
|
44
|
+
const normalized = hostname.toLowerCase();
|
|
45
|
+
return normalized === "localhost" || normalized === "127.0.0.1" || normalized === "[::1]" || normalized.endsWith(".localhost");
|
|
46
|
+
}
|
|
47
|
+
function isSupportedEmbeddedUiUrl(input) {
|
|
48
|
+
let parsed;
|
|
49
|
+
try {
|
|
50
|
+
parsed = new URL(input);
|
|
51
|
+
} catch {
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
if (parsed.protocol === "https:") return true;
|
|
55
|
+
return parsed.protocol === "http:" && isLoopbackHostname(parsed.hostname);
|
|
56
|
+
}
|
|
57
|
+
function buildHostedLaunchUrl(options) {
|
|
58
|
+
const url = new URL(normalizeHostedAppBaseUrl(options.baseUrl));
|
|
59
|
+
url.searchParams.set("api", options.apiBaseUrl);
|
|
60
|
+
return url.toString();
|
|
61
|
+
}
|
|
62
|
+
function buildEmbeddedUiLaunchUrl(options) {
|
|
63
|
+
const url = new URL(normalizeEmbeddedUiUrl(options.embeddedUiUrl));
|
|
64
|
+
url.searchParams.set("api", options.apiBaseUrl);
|
|
65
|
+
url.searchParams.set("session", options.sessionId);
|
|
66
|
+
return url.toString();
|
|
67
|
+
}
|
|
68
|
+
function isHostedBackendHealthResponse(value) {
|
|
69
|
+
if (!isRecord(value)) return false;
|
|
70
|
+
return value.status === "ok" && typeof value.projectDir === "string" && typeof value.projectName === "string" && typeof value.watcherEnabled === "boolean" && typeof value.openspecuiVersion === "string" && value.hostedShellProtocolVersion === HOSTED_SHELL_PROTOCOL_VERSION && typeof value.embeddedUiUrl === "string" && isSupportedEmbeddedUiUrl(value.embeddedUiUrl);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
//#endregion
|
|
74
|
+
export { isHostedBackendHealthResponse as a, normalizeHostedAppBaseUrl as c, buildHostedLaunchUrl as i, resolveHostedAppBaseUrl as l, OFFICIAL_APP_BASE_URL as n, isSupportedEmbeddedUiUrl as o, buildEmbeddedUiLaunchUrl as r, normalizeEmbeddedUiUrl as s, HOSTED_SHELL_PROTOCOL_VERSION as t };
|
package/dist/hosted-app.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as
|
|
2
|
-
export {
|
|
1
|
+
import { a as buildHostedLaunchUrl, c as normalizeEmbeddedUiUrl, i as buildEmbeddedUiLaunchUrl, l as normalizeHostedAppBaseUrl, n as HostedBackendHealthResponse, o as isHostedBackendHealthResponse, r as OFFICIAL_APP_BASE_URL, s as isSupportedEmbeddedUiUrl, t as HOSTED_SHELL_PROTOCOL_VERSION, u as resolveHostedAppBaseUrl } from "./hosted-app-B6b6fAYZ.mjs";
|
|
2
|
+
export { HOSTED_SHELL_PROTOCOL_VERSION, HostedBackendHealthResponse, OFFICIAL_APP_BASE_URL, buildEmbeddedUiLaunchUrl, buildHostedLaunchUrl, isHostedBackendHealthResponse, isSupportedEmbeddedUiUrl, normalizeEmbeddedUiUrl, normalizeHostedAppBaseUrl, resolveHostedAppBaseUrl };
|
package/dist/hosted-app.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as isHostedBackendHealthResponse, c as
|
|
1
|
+
import { a as isHostedBackendHealthResponse, c as normalizeHostedAppBaseUrl, i as buildHostedLaunchUrl, l as resolveHostedAppBaseUrl, n as OFFICIAL_APP_BASE_URL, o as isSupportedEmbeddedUiUrl, r as buildEmbeddedUiLaunchUrl, s as normalizeEmbeddedUiUrl, t as HOSTED_SHELL_PROTOCOL_VERSION } from "./hosted-app-RXZDSUtU.mjs";
|
|
2
2
|
|
|
3
|
-
export { OFFICIAL_APP_BASE_URL, buildHostedLaunchUrl,
|
|
3
|
+
export { HOSTED_SHELL_PROTOCOL_VERSION, OFFICIAL_APP_BASE_URL, buildEmbeddedUiLaunchUrl, buildHostedLaunchUrl, isHostedBackendHealthResponse, isSupportedEmbeddedUiUrl, normalizeEmbeddedUiUrl, normalizeHostedAppBaseUrl, resolveHostedAppBaseUrl };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as
|
|
1
|
+
import { a as buildHostedLaunchUrl, c as normalizeEmbeddedUiUrl, i as buildEmbeddedUiLaunchUrl, l as normalizeHostedAppBaseUrl, n as HostedBackendHealthResponse, o as isHostedBackendHealthResponse, r as OFFICIAL_APP_BASE_URL, s as isSupportedEmbeddedUiUrl, t as HOSTED_SHELL_PROTOCOL_VERSION, u as resolveHostedAppBaseUrl } from "./hosted-app-B6b6fAYZ.mjs";
|
|
2
2
|
import { n as toOpsxDisplayPath, t as VIRTUAL_PROJECT_DIRNAME } from "./opsx-display-path-C1H1ryBL.mjs";
|
|
3
3
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
4
4
|
import { z } from "zod";
|
|
@@ -1326,8 +1326,11 @@ declare function createFileChangeObservable(watcher: OpenSpecWatcher): {
|
|
|
1326
1326
|
//#endregion
|
|
1327
1327
|
//#region src/config.d.ts
|
|
1328
1328
|
declare const CODE_EDITOR_THEME_VALUES: readonly ["github", "material", "vscode", "tokyo", "gruvbox", "monokai", "nord"];
|
|
1329
|
+
declare const OPSX_AGENT_INVOCATION_MODE_VALUES: readonly ["compose", "command"];
|
|
1329
1330
|
declare const TerminalRendererEngineSchema: z.ZodEnum<["xterm", "ghostty"]>;
|
|
1330
1331
|
type TerminalRendererEngine = z.infer<typeof TerminalRendererEngineSchema>;
|
|
1332
|
+
declare const OpsxAgentInvocationModeSchema: z.ZodEnum<["compose", "command"]>;
|
|
1333
|
+
type OpsxAgentInvocationMode = z.infer<typeof OpsxAgentInvocationModeSchema>;
|
|
1331
1334
|
declare const CodeEditorThemeSchema: z.ZodEnum<["github", "material", "vscode", "tokyo", "gruvbox", "monokai", "nord"]>;
|
|
1332
1335
|
type CodeEditorTheme = z.infer<typeof CodeEditorThemeSchema>;
|
|
1333
1336
|
declare function isTerminalRendererEngine(value: string): value is TerminalRendererEngine;
|
|
@@ -1436,6 +1439,14 @@ declare const GitConfigSchema: z.ZodObject<{
|
|
|
1436
1439
|
diffEagerLineBudget?: number | undefined;
|
|
1437
1440
|
}>;
|
|
1438
1441
|
type GitConfig = z.infer<typeof GitConfigSchema>;
|
|
1442
|
+
declare const OpsxConfigSchema: z.ZodObject<{
|
|
1443
|
+
agentInvocationMode: z.ZodDefault<z.ZodEnum<["compose", "command"]>>;
|
|
1444
|
+
}, "strip", z.ZodTypeAny, {
|
|
1445
|
+
agentInvocationMode: "compose" | "command";
|
|
1446
|
+
}, {
|
|
1447
|
+
agentInvocationMode?: "compose" | "command" | undefined;
|
|
1448
|
+
}>;
|
|
1449
|
+
type OpsxConfig = z.infer<typeof OpsxConfigSchema>;
|
|
1439
1450
|
/**
|
|
1440
1451
|
* OpenSpecUI 配置 Schema
|
|
1441
1452
|
*
|
|
@@ -1467,6 +1478,14 @@ declare const OpenSpecUIConfigSchema: z.ZodObject<{
|
|
|
1467
1478
|
}>>;
|
|
1468
1479
|
/** Hosted app 基础 URL(空字符串表示使用官方默认值) */
|
|
1469
1480
|
appBaseUrl: z.ZodDefault<z.ZodString>;
|
|
1481
|
+
/** OPSX workflow invocation preferences */
|
|
1482
|
+
opsx: z.ZodDefault<z.ZodObject<{
|
|
1483
|
+
agentInvocationMode: z.ZodDefault<z.ZodEnum<["compose", "command"]>>;
|
|
1484
|
+
}, "strip", z.ZodTypeAny, {
|
|
1485
|
+
agentInvocationMode: "compose" | "command";
|
|
1486
|
+
}, {
|
|
1487
|
+
agentInvocationMode?: "compose" | "command" | undefined;
|
|
1488
|
+
}>>;
|
|
1470
1489
|
/** 终端配置 */
|
|
1471
1490
|
terminal: z.ZodDefault<z.ZodObject<{
|
|
1472
1491
|
fontSize: z.ZodDefault<z.ZodNumber>;
|
|
@@ -1516,6 +1535,9 @@ declare const OpenSpecUIConfigSchema: z.ZodObject<{
|
|
|
1516
1535
|
theme: "github" | "material" | "vscode" | "tokyo" | "gruvbox" | "monokai" | "nord";
|
|
1517
1536
|
};
|
|
1518
1537
|
appBaseUrl: string;
|
|
1538
|
+
opsx: {
|
|
1539
|
+
agentInvocationMode: "compose" | "command";
|
|
1540
|
+
};
|
|
1519
1541
|
terminal: {
|
|
1520
1542
|
fontSize: number;
|
|
1521
1543
|
fontFamily: string;
|
|
@@ -1540,6 +1562,9 @@ declare const OpenSpecUIConfigSchema: z.ZodObject<{
|
|
|
1540
1562
|
theme?: "github" | "material" | "vscode" | "tokyo" | "gruvbox" | "monokai" | "nord" | undefined;
|
|
1541
1563
|
} | undefined;
|
|
1542
1564
|
appBaseUrl?: string | undefined;
|
|
1565
|
+
opsx?: {
|
|
1566
|
+
agentInvocationMode?: "compose" | "command" | undefined;
|
|
1567
|
+
} | undefined;
|
|
1543
1568
|
terminal?: {
|
|
1544
1569
|
fontSize?: number | undefined;
|
|
1545
1570
|
fontFamily?: string | undefined;
|
|
@@ -1564,6 +1589,7 @@ type OpenSpecUIConfigUpdate = {
|
|
|
1564
1589
|
theme?: OpenSpecUIConfig['theme'];
|
|
1565
1590
|
codeEditor?: Partial<OpenSpecUIConfig['codeEditor']>;
|
|
1566
1591
|
appBaseUrl?: OpenSpecUIConfig['appBaseUrl'];
|
|
1592
|
+
opsx?: Partial<OpsxConfig>;
|
|
1567
1593
|
terminal?: Partial<TerminalConfig>;
|
|
1568
1594
|
dashboard?: Partial<DashboardConfig>;
|
|
1569
1595
|
git?: Partial<GitConfig>;
|
|
@@ -3149,4 +3175,4 @@ type PtyServerMessage = z.infer<typeof PtyServerMessageSchema>;
|
|
|
3149
3175
|
type PtySessionInfo = z.infer<typeof PtySessionInfoSchema>;
|
|
3150
3176
|
type PtyPlatform = z.infer<typeof PtyPlatformSchema>;
|
|
3151
3177
|
//#endregion
|
|
3152
|
-
export { type AIToolOption, AI_TOOLS, type ApplyInstructions, ApplyInstructionsContextFilesSchema, 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, DEFAULT_GIT_DIFF_EAGER_LINE_BUDGET, 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 GitConfig, GitConfigSchema, type GitEntriesPage, type GitEntryCursor, type GitEntryDetail, type GitEntryFileDiff, type GitEntryFilePatch, type GitEntryFileSource, type GitEntryFileSummary, type GitEntryFiles, type GitEntryPatch, type GitEntrySelector, type GitEntryShell, type GitFileChangeType, type GitPatchFile, type GitPatchState, type GitWorktreeHandoff, type GitWorktreeOverview, type GitWorktreeSummary,
|
|
3178
|
+
export { type AIToolOption, AI_TOOLS, type ApplyInstructions, ApplyInstructionsContextFilesSchema, 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, DEFAULT_GIT_DIFF_EAGER_LINE_BUDGET, 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 GitConfig, GitConfigSchema, type GitEntriesPage, type GitEntryCursor, type GitEntryDetail, type GitEntryFileDiff, type GitEntryFilePatch, type GitEntryFileSource, type GitEntryFileSummary, type GitEntryFiles, type GitEntryPatch, type GitEntrySelector, type GitEntryShell, type GitFileChangeType, type GitPatchFile, type GitPatchState, type GitWorktreeHandoff, type GitWorktreeOverview, type GitWorktreeSummary, HOSTED_SHELL_PROTOCOL_VERSION, type HostedBackendHealthResponse, MarkdownParser, OFFICIAL_APP_BASE_URL, OPSX_AGENT_INVOCATION_MODE_VALUES, OpenSpecAdapter, type OpenSpecUIConfig, OpenSpecUIConfigSchema, type OpenSpecUIConfigUpdate, OpenSpecWatcher, type OpsxAgentInvocationMode, OpsxAgentInvocationModeSchema, type OpsxConfig, OpsxConfigSchema, OpsxKernel, type PathCallback, type ProjectRecoveryStatus, type ProjectResidencyEvictionReason, type ProjectResidencyStatus, ProjectWatcher, type ProjectWatcherReinitializeReason, type ProjectWatcherRuntimeStatus, type ProjectWatcherRuntimeStatusListener, 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, TOOL_WORKFLOW_TO_SKILL_DIR, type Task, TaskSchema, type TemplateContentMap, type TemplatesMap, TemplatesSchema, type TerminalConfig, TerminalConfigSchema, type TerminalRendererEngine, TerminalRendererEngineSchema, type ToolConfig, type ToolInitDelivery, type ToolInitState, type ToolInitStatus, type ToolWorkflowId, VIRTUAL_PROJECT_DIRNAME, type ValidationIssue, type ValidationResult, Validator, type WatchEvent, type WatchEventType, type WatcherRuntimeStatus, acquireWatcher, buildCliRunnerCandidates, buildEmbeddedUiLaunchUrl, buildHostedLaunchUrl, clearCache, closeAllProjectWatchers, closeAllWatchers, contextStorage, createCleanCliEnv, createFileChangeObservable, getActiveWatcherCount, getAllToolIds, getAllTools, getAvailableToolIds, getAvailableTools, getCacheSize, getConfiguredTools, getDefaultCliCommand, getDefaultCliCommandString, getDetectedProjectTools, getProjectWatcher, getToolById, getToolInitStates, getWatchedProjectDir, getWatcherRuntimeStatus, initWatcherPool, isGlobPattern, isHostedBackendHealthResponse, isSupportedEmbeddedUiUrl, isTerminalRendererEngine, isToolConfigured, isWatcherPoolInitialized, normalizeEmbeddedUiUrl, normalizeHostedAppBaseUrl, parseCliCommand, reactiveExists, reactiveReadDir, reactiveReadFile, reactiveStat, resolveHostedAppBaseUrl, sniffGlobalCli, subscribeWatcherRuntimeStatus, toOpsxDisplayPath };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as isHostedBackendHealthResponse, c as
|
|
1
|
+
import { a as isHostedBackendHealthResponse, c as normalizeHostedAppBaseUrl, i as buildHostedLaunchUrl, l as resolveHostedAppBaseUrl, n as OFFICIAL_APP_BASE_URL, o as isSupportedEmbeddedUiUrl, r as buildEmbeddedUiLaunchUrl, s as normalizeEmbeddedUiUrl, t as HOSTED_SHELL_PROTOCOL_VERSION } from "./hosted-app-RXZDSUtU.mjs";
|
|
2
2
|
import { n as toOpsxDisplayPath, t as VIRTUAL_PROJECT_DIRNAME } from "./opsx-display-path-Cja3Bt1P.mjs";
|
|
3
3
|
import { mkdir, readFile, rename, writeFile } from "fs/promises";
|
|
4
4
|
import { dirname, join } from "path";
|
|
@@ -2117,7 +2117,9 @@ const CODE_EDITOR_THEME_VALUES = [
|
|
|
2117
2117
|
"nord"
|
|
2118
2118
|
];
|
|
2119
2119
|
const TERMINAL_RENDERER_ENGINE_VALUES = ["xterm", "ghostty"];
|
|
2120
|
+
const OPSX_AGENT_INVOCATION_MODE_VALUES = ["compose", "command"];
|
|
2120
2121
|
const TerminalRendererEngineSchema = z.enum(TERMINAL_RENDERER_ENGINE_VALUES);
|
|
2122
|
+
const OpsxAgentInvocationModeSchema = z.enum(OPSX_AGENT_INVOCATION_MODE_VALUES);
|
|
2121
2123
|
const CodeEditorThemeSchema = z.enum(CODE_EDITOR_THEME_VALUES);
|
|
2122
2124
|
function isTerminalRendererEngine(value) {
|
|
2123
2125
|
return TERMINAL_RENDERER_ENGINE_VALUES.includes(value);
|
|
@@ -2495,6 +2497,7 @@ const DashboardConfigSchema = z.object({ trendPointLimit: z.number().int().min(2
|
|
|
2495
2497
|
const DEFAULT_GIT_DIFF_EAGER_LINE_BUDGET = 1e3;
|
|
2496
2498
|
const GitConfigSchema = z.object({ diffEagerLineBudget: z.number().int().min(0).max(2e5).default(DEFAULT_GIT_DIFF_EAGER_LINE_BUDGET) });
|
|
2497
2499
|
const CodeEditorConfigSchema = z.object({ theme: CodeEditorThemeSchema.default("github") });
|
|
2500
|
+
const OpsxConfigSchema = z.object({ agentInvocationMode: OpsxAgentInvocationModeSchema.default("compose") });
|
|
2498
2501
|
/**
|
|
2499
2502
|
* OpenSpecUI 配置 Schema
|
|
2500
2503
|
*
|
|
@@ -2508,6 +2511,7 @@ const OpenSpecUIConfigSchema = z.object({
|
|
|
2508
2511
|
theme: z.enum(THEME_VALUES).default("system"),
|
|
2509
2512
|
codeEditor: CodeEditorConfigSchema.default(CodeEditorConfigSchema.parse({})),
|
|
2510
2513
|
appBaseUrl: z.string().default(""),
|
|
2514
|
+
opsx: OpsxConfigSchema.default(OpsxConfigSchema.parse({})),
|
|
2511
2515
|
terminal: TerminalConfigSchema.default(TerminalConfigSchema.parse({})),
|
|
2512
2516
|
dashboard: DashboardConfigSchema.default(DashboardConfigSchema.parse({})),
|
|
2513
2517
|
git: GitConfigSchema.default(GitConfigSchema.parse({}))
|
|
@@ -2518,6 +2522,7 @@ const DEFAULT_CONFIG = {
|
|
|
2518
2522
|
theme: "system",
|
|
2519
2523
|
codeEditor: CodeEditorConfigSchema.parse({}),
|
|
2520
2524
|
appBaseUrl: "",
|
|
2525
|
+
opsx: OpsxConfigSchema.parse({}),
|
|
2521
2526
|
terminal: TerminalConfigSchema.parse({}),
|
|
2522
2527
|
dashboard: DashboardConfigSchema.parse({}),
|
|
2523
2528
|
git: GitConfigSchema.parse({})
|
|
@@ -2560,6 +2565,9 @@ function toPersistedConfig(config, options = {}) {
|
|
|
2560
2565
|
if (config.codeEditor.theme !== DEFAULT_CONFIG.codeEditor.theme) codeEditor.theme = config.codeEditor.theme;
|
|
2561
2566
|
if (hasOwnEntries(codeEditor)) persisted.codeEditor = codeEditor;
|
|
2562
2567
|
if (config.appBaseUrl !== DEFAULT_CONFIG.appBaseUrl) persisted.appBaseUrl = config.appBaseUrl;
|
|
2568
|
+
const opsx = {};
|
|
2569
|
+
if (config.opsx.agentInvocationMode !== DEFAULT_CONFIG.opsx.agentInvocationMode) opsx.agentInvocationMode = config.opsx.agentInvocationMode;
|
|
2570
|
+
if (hasOwnEntries(opsx)) persisted.opsx = opsx;
|
|
2563
2571
|
const terminal = {};
|
|
2564
2572
|
if (config.terminal.fontSize !== DEFAULT_CONFIG.terminal.fontSize) terminal.fontSize = config.terminal.fontSize;
|
|
2565
2573
|
if (config.terminal.fontFamily !== DEFAULT_CONFIG.terminal.fontFamily) terminal.fontFamily = config.terminal.fontFamily;
|
|
@@ -2653,6 +2661,10 @@ var ConfigManager = class {
|
|
|
2653
2661
|
...config.codeEditor
|
|
2654
2662
|
},
|
|
2655
2663
|
appBaseUrl: config.appBaseUrl ?? current.appBaseUrl,
|
|
2664
|
+
opsx: {
|
|
2665
|
+
...current.opsx,
|
|
2666
|
+
...config.opsx
|
|
2667
|
+
},
|
|
2656
2668
|
terminal: {
|
|
2657
2669
|
...current.terminal,
|
|
2658
2670
|
...config.terminal
|
|
@@ -4575,4 +4587,4 @@ const PtyServerMessageSchema = z.discriminatedUnion("type", [
|
|
|
4575
4587
|
]);
|
|
4576
4588
|
|
|
4577
4589
|
//#endregion
|
|
4578
|
-
export { AI_TOOLS, ApplyInstructionsContextFilesSchema, ApplyInstructionsSchema, ApplyTaskSchema, ArtifactInstructionsSchema, ArtifactStatusSchema, CODE_EDITOR_THEME_VALUES, ChangeFileSchema, ChangeSchema, ChangeStatusSchema, CliExecutor, CodeEditorThemeSchema, ConfigManager, DASHBOARD_METRIC_KEYS, DEFAULT_CONFIG, DEFAULT_GIT_DIFF_EAGER_LINE_BUDGET, DashboardConfigSchema, DeltaOperationType, DeltaSchema, DeltaSpecSchema, DependencyInfoSchema, GitConfigSchema, 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, TOOL_WORKFLOW_TO_SKILL_DIR, TaskSchema, TemplatesSchema, TerminalConfigSchema, TerminalRendererEngineSchema, VIRTUAL_PROJECT_DIRNAME, Validator, acquireWatcher, buildCliRunnerCandidates,
|
|
4590
|
+
export { AI_TOOLS, ApplyInstructionsContextFilesSchema, ApplyInstructionsSchema, ApplyTaskSchema, ArtifactInstructionsSchema, ArtifactStatusSchema, CODE_EDITOR_THEME_VALUES, ChangeFileSchema, ChangeSchema, ChangeStatusSchema, CliExecutor, CodeEditorThemeSchema, ConfigManager, DASHBOARD_METRIC_KEYS, DEFAULT_CONFIG, DEFAULT_GIT_DIFF_EAGER_LINE_BUDGET, DashboardConfigSchema, DeltaOperationType, DeltaSchema, DeltaSpecSchema, DependencyInfoSchema, GitConfigSchema, HOSTED_SHELL_PROTOCOL_VERSION, MarkdownParser, OFFICIAL_APP_BASE_URL, OPSX_AGENT_INVOCATION_MODE_VALUES, OpenSpecAdapter, OpenSpecUIConfigSchema, OpenSpecWatcher, OpsxAgentInvocationModeSchema, OpsxConfigSchema, 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, TOOL_WORKFLOW_TO_SKILL_DIR, TaskSchema, TemplatesSchema, TerminalConfigSchema, TerminalRendererEngineSchema, VIRTUAL_PROJECT_DIRNAME, Validator, acquireWatcher, buildCliRunnerCandidates, buildEmbeddedUiLaunchUrl, buildHostedLaunchUrl, clearCache, closeAllProjectWatchers, closeAllWatchers, contextStorage, createCleanCliEnv, createFileChangeObservable, getActiveWatcherCount, getAllToolIds, getAllTools, getAvailableToolIds, getAvailableTools, getCacheSize, getConfiguredTools, getDefaultCliCommand, getDefaultCliCommandString, getDetectedProjectTools, getProjectWatcher, getToolById, getToolInitStates, getWatchedProjectDir, getWatcherRuntimeStatus, initWatcherPool, isGlobPattern, isHostedBackendHealthResponse, isSupportedEmbeddedUiUrl, isTerminalRendererEngine, isToolConfigured, isWatcherPoolInitialized, normalizeEmbeddedUiUrl, normalizeHostedAppBaseUrl, parseCliCommand, reactiveExists, reactiveReadDir, reactiveReadFile, reactiveStat, resolveHostedAppBaseUrl, sniffGlobalCli, subscribeWatcherRuntimeStatus, toOpsxDisplayPath };
|
package/package.json
CHANGED
|
@@ -1,86 +0,0 @@
|
|
|
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 };
|
|
@@ -1,46 +0,0 @@
|
|
|
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 };
|