mirror of
https://github.com/nexu-io/open-design.git
synced 2026-09-20 06:15:06 +08:00
809d45f27c
* feat(daemon): expose Vela login through CLI and MCP * feat(mcp): add interactive local brief card * feat(packaged): bootstrap local MCP headlessly * feat(daemon): secure local BYOK credential profiles * feat(cli): manage secure BYOK profiles * feat(web): store BYOK keys in secure profiles * fix(runs): deduplicate cloud generation requests * feat(daemon): add end-to-end plugin observability * fix(pack): include native PTY runtime in desktop packages Lazy-load node-pty in the daemon so missing native binaries only disable Terminal and interactive Keychain operations instead of crashing startup. Ship and validate target prebuilds in macOS and Windows packages. Repair the macOS spawn helper before signing, and invalidate stale Windows packaging caches. Cover the packaged PTY path in macOS and Windows smoke tests. Require Vela CLI for every beta desktop build target. * fix(mcp): localize and stabilize plugin briefs Keep collect and confirm on one MCP Apps card, report intrinsic size changes, and remove the fragile widget-state fallback. Localize brief forms, summaries, status, and public errors from the current request or Host locale while preserving stable protocol ids and selections. Keep internal runtime identifiers out of user-facing MCP guidance. * fix(packaged): register live Studio URLs with daemon Register the packaged web sidecar loopback origin over namespace-scoped daemon IPC after dynamic binding. Invalidate install-info by the live web port and remove the second MCP URL cache so run and project responses use the current Studio address. Validate loopback origins and cover registration, rebind, and cache refresh. * fix(mcp): stabilize brief confirmation lifecycle Keep confirmed briefs locked after Host publication failures and retry only the cached follow-up message instead of confirming twice. Replace blank initialization with a compact loading state, accept immediate and delayed tool results, and bump the MCP Apps resource to v3 so Codex does not reuse the stale card. Add an executable JSDOM Host bridge harness covering double-submit, publication retry, delayed results, and repeated draft notifications. Validated with the full daemon suite, workspace typecheck, and guard. * fix(mcp): prevent brief app resize feedback loops Replace the self-observed intrinsic-height loop with deduplicated body measurements so Codex MCP app iframes do not repeatedly resize themselves and fail sandbox startup. Bump the brief resource URI to v4 to avoid cached v3 cards and cover the regression with the focused brief-app spec. Validated with daemon tests/build, workspace guard/typecheck, a verified beta DMG, and a direct packaged MCP resource smoke. * fix(mcp): use the final Open Design plugin identity Make open-design the only accepted external plugin ID across MCP tools, run attribution, artifact version origins, and telemetry. Rename the Brief MCP App resource to v5 and reject the unpublished old ID instead of aliasing it. Validated with 171 daemon tests, 5 web tests, daemon/web typechecks, and guard. * chore(pack): bump Vela CLI to 0.0.27 * chore(nix): refresh pnpm dependency hashes * fix(mcp): honor host and plugin request contracts Respect independently advertised MCP Apps capabilities and prefer the Codex-native follow-up bridge so confirmed briefs render as readable user turns instead of context-only messages. Bump the brief resource to v6 to invalidate stale cards.\n\nMark Vela login and account probes as open-world interactions, and require stable request IDs for attributed generation so lost responses cannot create a second logical run. * fix(cli): support keyless BYOK profiles Add an explicit --no-api-key save mode for local and self-hosted providers while keeping credential-bearing profiles stdin-only. Reject missing or conflicting credential modes and cover both paths in the CLI tests. * fix(pack): replace headless owner when desktop opens Advertise headless packaged runtimes as having no visible window, then shut them down before a normal desktop launch continues instead of treating SHOW as a successful focus. Validated with the focused packaged headless and launcher lifecycle tests (20 passed). * fix(pack): clean up failed headless startup Acquire the headless identity, sidecars, and IPC server through one failure-atomic lifecycle so later bootstrap errors close every previously acquired owner in reverse order. Cover MCP-install and web-identity publication failures; validated with 22 focused tests and the packaged typecheck. * fix(byok): remove raw provider request contract Expose only daemon-owned BYOK profile references from shared run types and the web transport, while retaining the daemon's fail-closed rejection for legacy or untyped raw credential payloads. Validated with 76 web provider tests plus web and contracts typechecks. * fix(daemon): preserve interrupted run idempotency Hydrate queued or running durable requests as DAEMON_RESTARTED failures before idempotency reuse, preserving the original request and workflow mappings instead of creating a second cloud operation. Share the restart transition with boot reconciliation and expose synthetic terminal events to reattaching clients. Validated with 48 focused tests and the daemon typecheck. * fix(byok): roll back failed credential metadata writes Snapshot secure-store values before mutation and compensate create, update, and delete operations when profile metadata cannot be persisted, preventing orphaned or lost credentials. Validated with nine focused credential-service tests and the daemon typecheck. * fix(web): reconcile selected BYOK profile metadata Treat the daemon's selected secure profile as authoritative for protocol, endpoint, model, and API version so CLI profile edits cannot leave the browser showing stale execution settings. Validated with 66 config tests and the web typecheck. * fix(byok): migrate legacy credentials before cleanup Import each supported legacy browser credential into a stable daemon-owned secure profile before removing plaintext copies. Keep the original browser record on secure-store or unsupported-provider failures and surface a Settings recovery path. Cover successful migration, duplicate projections, and injected secure-backend failure while preserving existing Bedrock downgrade behavior in memory. * fix(byok): secure Windows profiles with DPAPI Dispatch native Windows BYOK profiles to a CurrentUser DPAPI backend rooted under the resolved daemon data directory. Secrets enter PowerShell only through stdin, encrypted blobs stay separate from non-secret profile metadata, and API responses remain secret-free. Add platform dispatch coverage, a Windows-only real DPAPI round-trip test, and the packaged Windows smoke path for create, resolve, response-redaction, and delete behavior. * fix(web): preserve config writes during hydration * fix(byok): persist secure credentials across entry flows * test(byok): cover secure onboarding persistence --------- Co-authored-by: Cheems <94773058+itscheems@users.noreply.github.com> Co-authored-by: lefarcen <935902669@qq.com>
110 lines
3.6 KiB
TypeScript
110 lines
3.6 KiB
TypeScript
import type { ArtifactOrigin, ProjectFileVersion } from '@open-design/contracts';
|
|
import type { ArtifactExportResultProps } from '@open-design/contracts/analytics';
|
|
|
|
const CONTENT_DIGEST_RE = /^[a-f0-9]{64}$/u;
|
|
const ORIGIN_ID_RE = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/u;
|
|
const EXTERNAL_PLUGIN_IDS = new Set(['open-design']);
|
|
|
|
export type ArtifactExportOriginProps = Pick<
|
|
ArtifactExportResultProps,
|
|
| 'entry_surface'
|
|
| 'artifact_origin_status'
|
|
| 'artifact_version_id'
|
|
| 'origin_entry_surface'
|
|
| 'origin_external_plugin_id'
|
|
| 'origin_plugin_workflow_id'
|
|
| 'origin_run_id'
|
|
>;
|
|
|
|
function safeOriginId(value: unknown): value is string {
|
|
return typeof value === 'string' && ORIGIN_ID_RE.test(value);
|
|
}
|
|
|
|
function isValidArtifactOrigin(origin: ArtifactOrigin): boolean {
|
|
if (
|
|
origin.entrySurface !== 'open_design_ui'
|
|
&& origin.entrySurface !== 'od_cli'
|
|
&& origin.entrySurface !== 'external_mcp'
|
|
&& origin.entrySurface !== 'unknown'
|
|
) {
|
|
return false;
|
|
}
|
|
if (
|
|
origin.externalPluginId !== undefined
|
|
&& !EXTERNAL_PLUGIN_IDS.has(origin.externalPluginId)
|
|
) {
|
|
return false;
|
|
}
|
|
if (origin.pluginWorkflowId !== undefined && !safeOriginId(origin.pluginWorkflowId)) {
|
|
return false;
|
|
}
|
|
if (origin.runId !== undefined && !safeOriginId(origin.runId)) return false;
|
|
return true;
|
|
}
|
|
|
|
export async function artifactVersionContentDigest(content: string): Promise<string> {
|
|
const bytes = new TextEncoder().encode(String(content ?? ''));
|
|
const digest = await globalThis.crypto.subtle.digest('SHA-256', bytes);
|
|
return Array.from(new Uint8Array(digest), (byte) => byte.toString(16).padStart(2, '0')).join('');
|
|
}
|
|
|
|
export async function matchingArtifactVersionId(
|
|
content: string,
|
|
version: ProjectFileVersion | null | undefined,
|
|
): Promise<string | undefined> {
|
|
if (!version?.contentDigest || !CONTENT_DIGEST_RE.test(version.contentDigest)) {
|
|
return undefined;
|
|
}
|
|
return await artifactVersionContentDigest(content) === version.contentDigest
|
|
? version.id
|
|
: undefined;
|
|
}
|
|
|
|
export async function artifactExportOriginProps(
|
|
content: string,
|
|
version: ProjectFileVersion | null | undefined,
|
|
): Promise<ArtifactExportOriginProps> {
|
|
const unknownBase = {
|
|
entry_surface: 'open_design_ui' as const,
|
|
origin_entry_surface: 'unknown' as const,
|
|
};
|
|
if (!version) {
|
|
return { ...unknownBase, artifact_origin_status: 'missing_version' };
|
|
}
|
|
if (!version.contentDigest || !CONTENT_DIGEST_RE.test(version.contentDigest)) {
|
|
return { ...unknownBase, artifact_origin_status: 'unknown' };
|
|
}
|
|
const actualDigest = await artifactVersionContentDigest(content);
|
|
if (actualDigest !== version.contentDigest) {
|
|
return { ...unknownBase, artifact_origin_status: 'digest_mismatch' };
|
|
}
|
|
const artifactVersion = { artifact_version_id: version.id };
|
|
if (!version.origin) {
|
|
return {
|
|
...unknownBase,
|
|
...artifactVersion,
|
|
artifact_origin_status: 'unknown',
|
|
};
|
|
}
|
|
if (!isValidArtifactOrigin(version.origin)) {
|
|
return {
|
|
...unknownBase,
|
|
...artifactVersion,
|
|
artifact_origin_status: 'invalid_origin',
|
|
};
|
|
}
|
|
return {
|
|
entry_surface: 'open_design_ui',
|
|
artifact_origin_status: version.origin.entrySurface === 'unknown' ? 'unknown' : 'matched',
|
|
...artifactVersion,
|
|
origin_entry_surface: version.origin.entrySurface,
|
|
...(version.origin.externalPluginId
|
|
? { origin_external_plugin_id: version.origin.externalPluginId }
|
|
: {}),
|
|
...(version.origin.pluginWorkflowId
|
|
? { origin_plugin_workflow_id: version.origin.pluginWorkflowId }
|
|
: {}),
|
|
...(version.origin.runId ? { origin_run_id: version.origin.runId } : {}),
|
|
};
|
|
}
|