soma-core 2.1.5 → 2.2.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.
Files changed (96) hide show
  1. package/README.md +2 -2
  2. package/bin/soma.cjs +1 -1
  3. package/bin/soma.ts +64 -15
  4. package/core/build/compiler/soma-precompile.js +11 -1
  5. package/core/client/base/SomaHttpClient.ts +85 -12
  6. package/core/client/data/data-object-resolver.ts +12 -1
  7. package/core/client/engine/event-engine.ts +3 -3
  8. package/core/client/engine/soma-bootstrap.ts +30 -30
  9. package/core/client/host-bridge/load-host-domain-class.ts +74 -20
  10. package/core/client/host-bridge/resolve-host-bootstrap.ts +125 -23
  11. package/core/client/infra/http/IHttpClient.ts +3 -1
  12. package/core/client/infra/http/SomaHttpService.ts +15 -6
  13. package/core/client/parser/data-config-parser.ts +6 -1
  14. package/core/server/api/dispatch-service-api.ts +212 -0
  15. package/core/server/api/load-host-service.ts +230 -56
  16. package/core/server/api/service-path.ts +78 -14
  17. package/core/server/engines/style/candidate-guard.ts +57 -0
  18. package/core/server/engines/style/index.ts +1 -1
  19. package/core/server/engines/style/tailwind-adapter.ts +83 -16
  20. package/core/server/host/source-packages.cjs +96 -30
  21. package/core/server/host/source-packages.ts +12 -5
  22. package/core/server/index.ts +39 -17
  23. package/core/server/infra/cache/ServerFileCache.ts +138 -25
  24. package/core/server/node.ts +32 -8
  25. package/core/shared/registry-generated/error-codes.ts +5 -0
  26. package/core/shared/registry-generated/limits.ts +5 -0
  27. package/core/shared/types/data-config.types.ts +2 -0
  28. package/dist/browser/soma-runtime.js +197 -49
  29. package/dist/cli/soma.js +68 -14
  30. package/dist/core/index.cjs +284 -64
  31. package/dist/host-native/aot-builder.cjs +850 -0
  32. package/dist/host-native/native-server.cjs +15338 -0
  33. package/dist/lsp/component-tree.cjs +11 -1
  34. package/dist/types/client/base/SomaHttpClient.d.ts +1 -8
  35. package/dist/types/client/data/data-object-resolver.d.ts +1 -0
  36. package/dist/types/client/engine/event-engine.d.ts +2 -2
  37. package/dist/types/client/engine/soma-bootstrap.d.ts +3 -2
  38. package/dist/types/client/host-bridge/load-host-domain-class.d.ts +1 -0
  39. package/dist/types/client/host-bridge/resolve-host-bootstrap.d.ts +20 -0
  40. package/dist/types/client/infra/http/IHttpClient.d.ts +2 -0
  41. package/dist/types/server/api/dispatch-service-api.d.ts +18 -0
  42. package/dist/types/server/api/load-host-service.d.ts +7 -2
  43. package/dist/types/server/api/service-path.d.ts +21 -1
  44. package/dist/types/server/engines/style/candidate-guard.d.ts +10 -0
  45. package/dist/types/server/engines/style/index.d.ts +1 -1
  46. package/dist/types/server/engines/style/tailwind-adapter.d.ts +12 -0
  47. package/dist/types/server/host/source-packages.d.cts +13 -1
  48. package/dist/types/server/host/source-packages.d.ts +7 -4
  49. package/dist/types/server/index.d.ts +18 -17
  50. package/dist/types/server/infra/cache/ServerFileCache.d.ts +28 -5
  51. package/dist/types/server/node.d.ts +10 -7
  52. package/dist/types/shared/registry-generated/error-codes.d.ts +4 -0
  53. package/dist/types/shared/registry-generated/limits.d.ts +4 -0
  54. package/dist/types/shared/types/data-config.types.d.ts +2 -0
  55. package/host-native/bin/host-native.cjs +204 -0
  56. package/host-native/client/browser-entry.ts +499 -0
  57. package/{host-next/app → host-native/client}/page-access.ts +12 -0
  58. package/host-native/client/router-bridge.ts +120 -0
  59. package/host-native/src/aot-builder.ts +486 -0
  60. package/host-native/src/csp-headers.ts +75 -0
  61. package/host-native/src/host-prepare.ts +123 -0
  62. package/{host-next/app/soma/manifest/route.ts → host-native/src/manifest-http.ts} +10 -10
  63. package/host-native/src/native-server.ts +691 -0
  64. package/host-native/src/page-http.ts +223 -0
  65. package/host-native/src/public-packages.cjs +167 -0
  66. package/{host-next/app/api/soma-registry/[...path]/route.ts → host-native/src/registry-handler.ts} +17 -19
  67. package/{host-next → host-native}/src/shell-routes.cjs +23 -13
  68. package/host-native/src/static-file.ts +172 -0
  69. package/host-native/src/workspace.ts +185 -0
  70. package/{host-next/app → host-native/styles}/globals.css +2 -2
  71. package/package.json +13 -32
  72. package/tsconfig.json +1 -1
  73. package/host-next/app/SomaPageClient.tsx +0 -359
  74. package/host-next/app/[...path]/page.tsx +0 -22
  75. package/host-next/app/api/[...path]/route.ts +0 -98
  76. package/host-next/app/components/SomaHostPage.tsx +0 -128
  77. package/host-next/app/components/SomaHydrationShell.tsx +0 -20
  78. package/host-next/app/components/SomaPageClientBoundary.tsx +0 -13
  79. package/host-next/app/components/SomaPageForbidden.tsx +0 -19
  80. package/host-next/app/favicon.ico/route.ts +0 -13
  81. package/host-next/app/layout.tsx +0 -27
  82. package/host-next/app/page.tsx +0 -9
  83. package/host-next/app/router-bridge.ts +0 -42
  84. package/host-next/app/soma/[...path]/route.ts +0 -9
  85. package/host-next/app/soma/_shared/host-prepare.ts +0 -33
  86. package/host-next/app/soma/_shared/page-http.ts +0 -86
  87. package/host-next/app/soma/page/route.ts +0 -36
  88. package/host-next/app/soma/route.ts +0 -9
  89. package/host-next/app/soma-runtime/[...file]/route.ts +0 -21
  90. package/host-next/app/soma-runtime/_shared/static-file.ts +0 -89
  91. package/host-next/bin/host-next.cjs +0 -60
  92. package/host-next/instrumentation.ts +0 -18
  93. package/host-next/next-env.d.ts +0 -7
  94. package/host-next/next.config.js +0 -410
  95. package/host-next/proxy.ts +0 -43
  96. package/host-next/src/workspace.ts +0 -543
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Node 安全的服务端子路径(`soma-core/server/node`,R-28 / C9)。
3
3
  *
4
- * 为什么单开一个口:`soma-core/server` 带 `import 'server-only'`,并连带 CSP 这类只在 Next 服务端成立的模块;
4
+ * 为什么单开一个口:`soma-core/server` 带 `import "server-only"`,并连带 CSP 这类只在 Next 服务端成立的模块;
5
5
  * CLI、testkit、经 jiti 在纯 Node 语境加载的 Host 服务一进来就会抛。这里只放「宿主资源定位 / 页面资产 / 块加载 /
6
6
  * Registry 写管线」这类纯 Node 能力,**不 import `server-only`,也不得(经任何传递依赖)加载
7
7
  * `server/host/content-security-policy` / `csp-nonce-metadata`**——由 `tests/unit/server/node-entry-purity.test.ts` 看守。
@@ -11,9 +11,11 @@
11
11
 
12
12
  // 宿主资源定位(源包 / 宿主根 / 页面入口 / 共享片段 / 配置根)
13
13
  export {
14
+ clearSomaAssetSourcesCache,
14
15
  collectIncludes,
15
16
  collectPageEntries,
16
17
  getSomaAssetSources,
18
+ getSomaHostApiRoot,
17
19
  getSomaHostConfigRoot,
18
20
  getSomaHostSourceRoot,
19
21
  listSomaSourcePackageNames,
@@ -26,7 +28,7 @@ export {
26
28
  type SomaAssetSource,
27
29
  type SomaEnvName,
28
30
  type SomaSourcePageEntry,
29
- } from './host/source-packages';
31
+ } from "./host/source-packages";
30
32
 
31
33
  // 页面资产与页面标记配置
32
34
  export {
@@ -34,11 +36,33 @@ export {
34
36
  resolveSomaPageSource,
35
37
  SomaPageAssetError,
36
38
  type SomaServerPageAssets,
37
- } from './host/server-page-assets';
38
- export { loadPageMarkupConfig, renderColorSchemeMeta } from './host/page-markup-config';
39
+ } from "./host/server-page-assets";
40
+ export { loadPageMarkupConfig, renderColorSchemeMeta } from "./host/page-markup-config";
39
41
 
40
- // 服务路径与外部块
41
- export { resolveServiceFilePath, toPascalCase } from './api/service-path';
42
+ // 服务路径与服务分发
43
+ export {
44
+ resolveHostServiceCandidate,
45
+ resolveServiceFilePath,
46
+ toPascalCase,
47
+ validateServiceSegments,
48
+ type ResolveHostServiceCandidateOptions,
49
+ } from "./api/service-path";
50
+ export {
51
+ clearHostServiceCache,
52
+ getAotServiceResolver,
53
+ loadHostService,
54
+ registerAotServiceResolver,
55
+ resolveServiceExport,
56
+ type AotServiceResolver,
57
+ } from "./api/load-host-service";
58
+ export {
59
+ dispatchHostServiceApiRequest,
60
+ polyfillServiceRequest,
61
+ type DispatchHostServiceApiOptions,
62
+ type RequestCookie,
63
+ type RequestCookiesAdapter,
64
+ } from "./api/dispatch-service-api";
65
+ export type { IService, SomaServiceRequest } from "./api/IService";
42
66
 
43
67
  // Registry 写管线(地址闸门 / 发布后绑定 / 下架解绑;限流复位给测试)
44
68
  export {
@@ -46,7 +70,7 @@ export {
46
70
  bindPublishedRegistryPage,
47
71
  resetRegistryWriteRateLimit,
48
72
  unbindArchivedRegistryPage,
49
- } from './registry/registry-write-pipeline';
73
+ } from "./registry/registry-write-pipeline";
50
74
 
51
75
  // 过期时间换算(信封 `expires` 的唯一算法)
52
- export { expiresToMinutes } from '../shared/page-envelope';
76
+ export { expiresToMinutes } from "../shared/page-envelope";
@@ -34,6 +34,11 @@ export const SOMA_PIPELINE_ERROR_CODES = {
34
34
  "module": "soma-ai-page",
35
35
  "file": "src/versions/errors.ts",
36
36
  "symbol": "SOMA_PIPELINE_ERROR_CODES_AI_PAGE"
37
+ },
38
+ {
39
+ "module": "soma-robot",
40
+ "file": "src/common/errors.ts",
41
+ "symbol": "SOMA_PIPELINE_ERROR_CODES_AI_ROBOT"
37
42
  }
38
43
  ],
39
44
  "families": {
@@ -439,6 +439,11 @@ export const SOMA_PIPELINE_LIMITS = {
439
439
  "module": "soma-lite",
440
440
  "file": "src/app/server/provenance-limit.ts",
441
441
  "symbol": "SOMA_PIPELINE_LIMITS"
442
+ },
443
+ {
444
+ "module": "soma-robot",
445
+ "file": "src/common/limits.ts",
446
+ "symbol": "SOMA_PIPELINE_LIMITS_AI_ROBOT"
442
447
  }
443
448
  ],
444
449
  "registry": {
@@ -125,6 +125,8 @@ export interface SomaDataSourceConfig {
125
125
  failWhen?: SomaFieldPredicate;
126
126
  /** 命中 failWhen 时,业务错误信息在响应体里的点路径 */
127
127
  messagePath?: string;
128
+ /** 响应体数据点路径(当未指定 into 时,按点路径取出内层载荷并入对象根) */
129
+ dataPath?: string;
128
130
  }
129
131
 
130
132
  /**
@@ -20720,7 +20720,7 @@ function parsePlainText(rawText, style, defaultOuterWidth, defaultOuterHeight) {
20720
20720
  var paddingH = padding ? padding[1] + padding[3] : 0;
20721
20721
  var paddingV = padding ? padding[0] + padding[2] : 0;
20722
20722
  var font = style.font;
20723
- var truncate = overflow === "truncate";
20723
+ var truncate2 = overflow === "truncate";
20724
20724
  var calculatedLineHeight = getLineHeight(font);
20725
20725
  var lineHeight = retrieve2(style.lineHeight, calculatedLineHeight);
20726
20726
  var truncateLineOverflow = style.lineOverflow === "truncate";
@@ -20749,7 +20749,7 @@ function parsePlainText(rawText, style, defaultOuterWidth, defaultOuterHeight) {
20749
20749
  lines = lines.slice(0, lineCount);
20750
20750
  contentHeight = lines.length * lineHeight;
20751
20751
  }
20752
- if (text2 && truncate && width != null) {
20752
+ if (text2 && truncate2 && width != null) {
20753
20753
  var options = prepareTruncateOptions(width, font, style.ellipsis, {
20754
20754
  minChar: style.truncateMinChar,
20755
20755
  placeholder: style.placeholder
@@ -20821,7 +20821,7 @@ function parseRichText(rawText, style, defaultOuterWidth, defaultOuterHeight, to
20821
20821
  var pendingList = [];
20822
20822
  var calculatedHeight = 0;
20823
20823
  var calculatedWidth = 0;
20824
- var truncate = overflow === "truncate";
20824
+ var truncate2 = overflow === "truncate";
20825
20825
  var truncateLine = style.lineOverflow === "truncate";
20826
20826
  var tmpTruncateOut = {};
20827
20827
  function finishLine(line2, lineWidth2, lineHeight2) {
@@ -20877,7 +20877,7 @@ function parseRichText(rawText, style, defaultOuterWidth, defaultOuterHeight, to
20877
20877
  }
20878
20878
  }
20879
20879
  }
20880
- var remainTruncWidth = truncate && topWidth != null ? topWidth - lineWidth : null;
20880
+ var remainTruncWidth = truncate2 && topWidth != null ? topWidth - lineWidth : null;
20881
20881
  if (remainTruncWidth != null && remainTruncWidth < token.width) {
20882
20882
  if (!tokenWidthNotSpecified || remainTruncWidth < paddingH) {
20883
20883
  token.text = "";
@@ -28223,7 +28223,7 @@ var init_time = __esm({
28223
28223
  });
28224
28224
 
28225
28225
  // ../node_modules/echarts/lib/legacy/getTextRect.js
28226
- function getTextRect(text2, font, align, verticalAlign, padding, rich, truncate, lineHeight) {
28226
+ function getTextRect(text2, font, align, verticalAlign, padding, rich, truncate2, lineHeight) {
28227
28227
  var textEl = new Text_default({
28228
28228
  style: {
28229
28229
  text: text2,
@@ -28232,7 +28232,7 @@ function getTextRect(text2, font, align, verticalAlign, padding, rich, truncate,
28232
28232
  verticalAlign,
28233
28233
  padding,
28234
28234
  rich,
28235
- overflow: truncate ? "truncate" : null,
28235
+ overflow: truncate2 ? "truncate" : null,
28236
28236
  lineHeight
28237
28237
  }
28238
28238
  });
@@ -96034,7 +96034,30 @@ function checkFieldAll(rules, value, context = {}) {
96034
96034
  // ../soma-foundation/dist/esm/values/collection-payload.js
96035
96035
  var ROW_KEYS = ["items", "rows", "list"];
96036
96036
  var META_KEYS = /* @__PURE__ */ new Set([...ROW_KEYS, "total", "page", "pageSize", "cursor", "hasMore", "pages", "facets", "cap", "truncated", "meta"]);
96037
- var WRAPPER_KEYS = /* @__PURE__ */ new Set(["ret", "success", "ok", "code", "message", "msg", "data"]);
96037
+ var WRAPPER_KEYS = /* @__PURE__ */ new Set([
96038
+ "ret",
96039
+ "success",
96040
+ "ok",
96041
+ "code",
96042
+ "message",
96043
+ "msg",
96044
+ "data",
96045
+ "traceId",
96046
+ "trace_id",
96047
+ "requestId",
96048
+ "request_id",
96049
+ "timestamp",
96050
+ "ts",
96051
+ "time",
96052
+ "cost",
96053
+ "status",
96054
+ "errMsg",
96055
+ "err_msg",
96056
+ "errmsg",
96057
+ "error",
96058
+ "reason",
96059
+ "detail"
96060
+ ]);
96038
96061
  function isPlain(value) {
96039
96062
  if (value === null || typeof value !== "object" || Array.isArray(value)) return false;
96040
96063
  const proto = Object.getPrototypeOf(value);
@@ -105115,9 +105138,9 @@ var SomaEventEngine = class {
105115
105138
  }
105116
105139
  return void 0;
105117
105140
  }
105118
- /** 分级确认的唯一出口:typed / consent 且注入了执行口 -> 执行口;否则回落 plain(一句话 `adapter.confirm`) */
105141
+ /** 分级确认的唯一出口:注入了执行口 -> 执行口(plain / consent / typed 全级别);否则安全回退 adapter.confirm(spec.text) */
105119
105142
  askConfirm(spec) {
105120
- if (spec.level !== "plain" && this.confirmGraded) return this.confirmGraded(spec);
105143
+ if (this.confirmGraded) return this.confirmGraded(spec);
105121
105144
  return this.adapter.confirm(spec.text);
105122
105145
  }
105123
105146
  preCheck(config, somaId, element) {
@@ -107851,19 +107874,74 @@ var SomaLocaleOnlyPageRoot = class extends SomaPageRootBase {
107851
107874
 
107852
107875
  // core/client/base/SomaHttpClient.ts
107853
107876
  var ERROR_BODY_MAX_LENGTH = 500;
107854
- function describeHttpErrorBody(body, statusText) {
107877
+ var CANDIDATE_KEYS = [
107878
+ "error",
107879
+ "message",
107880
+ "msg",
107881
+ "errMsg",
107882
+ "err_msg",
107883
+ "errmsg",
107884
+ "reason",
107885
+ "detail"
107886
+ ];
107887
+ function pickMessageField(record2) {
107888
+ for (const key of CANDIDATE_KEYS) {
107889
+ const val = record2[key];
107890
+ if (typeof val === "string" && val.trim() !== "") {
107891
+ return val.trim();
107892
+ }
107893
+ }
107894
+ return void 0;
107895
+ }
107896
+ function extractHtmlTitle(text2) {
107897
+ const match = text2.match(/<title[^>]*>([\s\S]*?)<\/title>/i);
107898
+ if (!match) return void 0;
107899
+ const plain = match[1].replace(/<[^>]+>/g, "").replace(/\s+/g, " ").trim();
107900
+ if (plain === "") return void 0;
107901
+ return plain.length > 120 ? `${plain.slice(0, 120)}\u2026` : plain;
107902
+ }
107903
+ function describeHttpErrorBody(body, statusText, status) {
107855
107904
  const text2 = (body ?? "").trim();
107856
- if (text2 === "") return statusText;
107857
- let message = text2;
107905
+ const fallbackStatus = statusText.trim() || (status ? `\u8BF7\u6C42\u5931\u8D25\uFF08HTTP ${status}\uFF09` : "\u8BF7\u6C42\u5931\u8D25");
107906
+ if (text2 === "") return fallbackStatus;
107907
+ if (/^\s*<(?:!doctype\s+html|html)/i.test(text2)) {
107908
+ const title = extractHtmlTitle(text2);
107909
+ if (title) return title;
107910
+ return statusText.trim() || (status ? `\u670D\u52A1\u5F02\u5E38\uFF08HTTP ${status}\uFF09` : "\u670D\u52A1\u5F02\u5E38");
107911
+ }
107858
107912
  try {
107859
107913
  const parsed = JSON.parse(text2);
107860
107914
  if (parsed && typeof parsed === "object") {
107861
- const field = parsed.error ?? parsed.message;
107862
- if (typeof field === "string" && field.trim() !== "") message = field.trim();
107915
+ if (!Array.isArray(parsed)) {
107916
+ const obj = parsed;
107917
+ const top2 = pickMessageField(obj);
107918
+ if (top2) return truncate(top2);
107919
+ if (obj.error && typeof obj.error === "object" && !Array.isArray(obj.error)) {
107920
+ const nested = pickMessageField(obj.error);
107921
+ if (nested) return truncate(nested);
107922
+ }
107923
+ if (obj.data && typeof obj.data === "object" && !Array.isArray(obj.data)) {
107924
+ const nested = pickMessageField(obj.data);
107925
+ if (nested) return truncate(nested);
107926
+ }
107927
+ if (typeof obj.code === "string" && obj.code.trim() !== "" && obj.code.trim().length <= 40) {
107928
+ return truncate(obj.code.trim());
107929
+ }
107930
+ }
107931
+ return fallbackStatus;
107863
107932
  }
107864
107933
  } catch {
107934
+ if (text2.startsWith("<")) {
107935
+ const title = extractHtmlTitle(text2);
107936
+ if (title) return title;
107937
+ return statusText.trim() || (status ? `\u670D\u52A1\u5F02\u5E38\uFF08HTTP ${status}\uFF09` : "\u670D\u52A1\u5F02\u5E38");
107938
+ }
107939
+ return truncate(text2);
107865
107940
  }
107866
- return message.length > ERROR_BODY_MAX_LENGTH ? `${message.slice(0, ERROR_BODY_MAX_LENGTH)}\u2026` : message;
107941
+ return fallbackStatus;
107942
+ }
107943
+ function truncate(msg) {
107944
+ return msg.length > ERROR_BODY_MAX_LENGTH ? `${msg.slice(0, ERROR_BODY_MAX_LENGTH)}\u2026` : msg;
107867
107945
  }
107868
107946
  var SomaHttpClient = class {
107869
107947
  baseURL;
@@ -107938,7 +108016,7 @@ var SomaHttpClient = class {
107938
108016
  const res = await fetch(url, options);
107939
108017
  if (!res.ok) {
107940
108018
  const errorBody = typeof res.text === "function" ? await res.text().catch(() => "") : "";
107941
- throw new Error(`HTTP ${res.status}: ${describeHttpErrorBody(errorBody, res.statusText)}`);
108019
+ throw new Error(`HTTP ${res.status}: ${describeHttpErrorBody(errorBody, res.statusText, res.status)}`);
107942
108020
  }
107943
108021
  return await res.json();
107944
108022
  } finally {
@@ -108002,8 +108080,10 @@ var SomaHttpService = class {
108002
108080
  try {
108003
108081
  const res = await fetch(fullUrl, { method: "POST", body: form, signal: controller.signal });
108004
108082
  if (!res.ok) {
108005
- this.onHttpError?.(res.status, res.statusText);
108006
- throw new Error(`HTTP ${res.status}: ${res.statusText}`);
108083
+ const body = typeof res.text === "function" ? await res.text().catch(() => "") : "";
108084
+ const readable = describeHttpErrorBody(body, res.statusText, res.status);
108085
+ this.onHttpError?.(res.status, readable);
108086
+ throw new Error(`HTTP ${res.status}: ${readable}`);
108007
108087
  }
108008
108088
  onProgress?.(100);
108009
108089
  return await res.json();
@@ -108033,8 +108113,10 @@ var SomaHttpService = class {
108033
108113
  reject(new Error("Invalid JSON response"));
108034
108114
  }
108035
108115
  } else {
108036
- this.onHttpError?.(xhr.status, xhr.statusText);
108037
- reject(new Error(`HTTP ${xhr.status}: ${xhr.statusText}`));
108116
+ const body = xhr.responseText ?? "";
108117
+ const readable = describeHttpErrorBody(body, xhr.statusText, xhr.status);
108118
+ this.onHttpError?.(xhr.status, readable);
108119
+ reject(new Error(`HTTP ${xhr.status}: ${readable}`));
108038
108120
  }
108039
108121
  });
108040
108122
  xhr.addEventListener("error", () => {
@@ -108087,8 +108169,11 @@ var SomaHttpService = class {
108087
108169
  const res = await fetch(fullUrl, options);
108088
108170
  if (!res.ok) {
108089
108171
  const body2 = typeof res.text === "function" ? await res.text().catch(() => "") : "";
108090
- this.onHttpError?.(res.status, body2 || res.statusText);
108091
- throw new Error(`HTTP ${res.status}: ${describeHttpErrorBody(body2, res.statusText)}`);
108172
+ const readable = describeHttpErrorBody(body2, res.statusText, res.status);
108173
+ if (config?.silentErrorToast !== true) {
108174
+ this.onHttpError?.(res.status, readable);
108175
+ }
108176
+ throw new Error(`HTTP ${res.status}: ${readable}`);
108092
108177
  }
108093
108178
  try {
108094
108179
  config?.onResponse?.({ status: res.status });
@@ -112581,6 +112666,11 @@ var SOMA_PIPELINE_LIMITS = {
112581
112666
  "module": "soma-lite",
112582
112667
  "file": "src/app/server/provenance-limit.ts",
112583
112668
  "symbol": "SOMA_PIPELINE_LIMITS"
112669
+ },
112670
+ {
112671
+ "module": "soma-robot",
112672
+ "file": "src/common/limits.ts",
112673
+ "symbol": "SOMA_PIPELINE_LIMITS_AI_ROBOT"
112584
112674
  }
112585
112675
  ],
112586
112676
  "registry": {
@@ -112891,8 +112981,13 @@ function parseSource(raw, path, objectNames, selfName, deps) {
112891
112981
  source.failWhen = value;
112892
112982
  } else if (key === "messagePath") {
112893
112983
  source.messagePath = value;
112984
+ } else if (key === "dataPath") {
112985
+ if (typeof value !== "string" || value.trim() === "") {
112986
+ throw new SomaDataConfigError(`dataPath \u5FC5\u987B\u662F\u975E\u7A7A\u7684\u54CD\u5E94\u4F53\u70B9\u8DEF\u5F84`, `${path}.dataPath`);
112987
+ }
112988
+ source.dataPath = value.trim();
112894
112989
  } else {
112895
- throw new SomaDataConfigError(`\u672A\u77E5\u7684\u6765\u6E90\u5B57\u6BB5 "${key}"\uFF08\u652F\u6301: api / params / into / require / failWhen / messagePath\uFF09`, `${path}.${key}`);
112990
+ throw new SomaDataConfigError(`\u672A\u77E5\u7684\u6765\u6E90\u5B57\u6BB5 "${key}"\uFF08\u652F\u6301: api / params / into / require / failWhen / messagePath / dataPath\uFF09`, `${path}.${key}`);
112896
112991
  }
112897
112992
  }
112898
112993
  if (source.failWhen !== void 0 || source.messagePath !== void 0) {
@@ -114598,14 +114693,24 @@ var SomaDataObjectResolver = class {
114598
114693
  return data;
114599
114694
  });
114600
114695
  }
114696
+ pickDotted(root, path) {
114697
+ let current = root;
114698
+ for (const segment2 of path.split(".")) {
114699
+ if (segment2 === "") continue;
114700
+ if (current === null || typeof current !== "object") return void 0;
114701
+ current = current[segment2];
114702
+ }
114703
+ return current;
114704
+ }
114601
114705
  /** 聚合来源结果:into 写入子键;缺省先解开宿主信封,再浅合并进根(数组整体替换) */
114602
114706
  mergeSource(current, source, data) {
114603
- const payload = source.into ? data : unwrapHostPayload(data);
114604
114707
  if (source.into) {
114605
114708
  const target = isPlainObject7(current) ? current : {};
114606
114709
  target[source.into] = data;
114607
114710
  return target;
114608
114711
  }
114712
+ const rawData = source.dataPath ? this.pickDotted(data, source.dataPath) : data;
114713
+ const payload = unwrapHostPayload(rawData);
114609
114714
  if (isPlainObject7(payload)) {
114610
114715
  if (isPlainObject7(current)) {
114611
114716
  Object.assign(current, payload);
@@ -114772,6 +114877,53 @@ var SomaDataObjectResolver = class {
114772
114877
  return value;
114773
114878
  }
114774
114879
  };
114880
+ function createSomaDataPort(currentResolver, hostState = createDataPortHostState()) {
114881
+ const noResolver = (action) => ({
114882
+ ok: false,
114883
+ message: `\u6570\u636E\u5BF9\u8C61\u5C1A\u672A\u5C31\u7EEA\uFF0C\u65E0\u6CD5${action}\uFF08\u672C\u9875\u53EF\u80FD\u6CA1\u6709\u5728\u9875\u9762\u5757\u58F0\u660E data:\uFF09`
114884
+ });
114885
+ return {
114886
+ getObject: (name2) => currentResolver()?.getObject(name2),
114887
+ getObjectStatus: (name2) => currentResolver()?.getObjectStatus(name2),
114888
+ getDict: (name2) => currentResolver()?.getDict(name2) ?? {},
114889
+ submit: async (name2, model, mode, options) => {
114890
+ const resolver = currentResolver();
114891
+ return resolver ? resolver.submit(name2, model, mode, options) : noResolver(`\u63D0\u4EA4 "${name2}"`);
114892
+ },
114893
+ remove: async (name2, target) => {
114894
+ const resolver = currentResolver();
114895
+ return resolver ? resolver.remove(name2, target) : { ok: false, message: `\u6570\u636E\u5BF9\u8C61\u5C1A\u672A\u5C31\u7EEA\uFF0C\u65E0\u6CD5\u5220\u9664 "${name2}" \u7684\u8BB0\u5F55` };
114896
+ },
114897
+ reload: async (names) => {
114898
+ await currentResolver()?.reload(names);
114899
+ },
114900
+ validate: (name2, model, trigger3) => currentResolver()?.validate(name2, model, trigger3) ?? {},
114901
+ writeOutcome: (scope) => hostState.writeOutcomes().get(scope),
114902
+ onWriteOutcome: (listener) => hostState.writeOutcomes().subscribe(listener),
114903
+ clearWriteOptimistic: (scope, key) => hostState.writeOutcomes().clearOptimistic(scope, key),
114904
+ clearOutcome: (scope) => hostState.writeOutcomes().clear(scope),
114905
+ dispatch: (name2, payload) => hostState.dispatchAction(name2, payload)
114906
+ };
114907
+ }
114908
+ function createDataPortHostState() {
114909
+ const outcomes = createWriteOutcomeStore();
114910
+ let dispatcher;
114911
+ return {
114912
+ writeOutcomes: () => outcomes,
114913
+ setActionDispatcher(next) {
114914
+ dispatcher = next;
114915
+ },
114916
+ async dispatchAction(name2, payload) {
114917
+ if (dispatcher === void 0) {
114918
+ const scope = typeof payload.scope === "string" ? payload.scope : String(payload.object ?? "");
114919
+ const seq2 = outcomes.begin(scope);
114920
+ outcomes.settle(scope, seq2, { ok: false, message: "\u9875\u9762\u6CA1\u6709\u4E8B\u4EF6\u5F15\u64CE\uFF0C\u5199\u5165\u4E8B\u4EF6\u65E0\u5904\u6267\u884C" });
114921
+ return;
114922
+ }
114923
+ await dispatcher(name2, payload);
114924
+ }
114925
+ };
114926
+ }
114775
114927
 
114776
114928
  // core/client/data/data-subscriptions.ts
114777
114929
  function parseInvalidation(message) {
@@ -118191,8 +118343,11 @@ var SomaBootstrap = class {
118191
118343
  dataResolver = null;
118192
118344
  dataLoadEpoch = 0;
118193
118345
  dataOwnerEpoch = 0;
118194
- /** 写入结果存储:与 bootstrap 同寿(字段错误、冲突、乐观叠层),`services.data.writeOutcome` 读它 */
118195
- writeOutcomeStore = createWriteOutcomeStore();
118346
+ /** 数据端口宿主状态(单一真源):持有写入结果存储与写入事件执行口,端口重建同寿 */
118347
+ dataPortHostState = createDataPortHostState();
118348
+ get writeOutcomeStore() {
118349
+ return this.dataPortHostState.writeOutcomes();
118350
+ }
118196
118351
  /** 快捷键注册中心(C-r18):唯一一份,`services.shortcuts` 直通 */
118197
118352
  shortcutsInstance;
118198
118353
  componentStyleNonce;
@@ -119214,36 +119369,26 @@ ${lines}
119214
119369
  createStableDataPort() {
119215
119370
  const owner = this.dataOwnerEpoch;
119216
119371
  const current = () => owner === this.dataOwnerEpoch ? this.dataResolver : null;
119217
- const notReady = (action) => ({
119218
- ok: false,
119219
- message: `\u6570\u636E\u5BF9\u8C61\u5C1A\u672A\u5C31\u7EEA\uFF0C\u65E0\u6CD5${action}\uFF08\u672C\u9875\u53EF\u80FD\u6CA1\u6709\u5728\u9875\u9762\u5757\u58F0\u660E data:\uFF09`
119220
- });
119221
- const port = {
119222
- getObject: (name2) => current()?.getObject(name2),
119223
- getObjectStatus: (name2) => current()?.getObjectStatus(name2),
119224
- getDict: (name2) => current()?.getDict(name2) ?? {},
119372
+ const base2 = createSomaDataPort(current, this.dataPortHostState);
119373
+ return {
119374
+ ...base2,
119225
119375
  submit: async (name2, model, mode, options) => {
119226
- const resolver = current();
119227
- if (!resolver) return notReady(`\u63D0\u4EA4 "${name2}"`);
119228
- const result = await resolver.submit(name2, model, mode, options);
119229
- this.dataPolling?.arm();
119376
+ const result = await base2.submit(name2, model, mode, options);
119377
+ if (current()) {
119378
+ this.dataPolling?.arm();
119379
+ }
119230
119380
  return result;
119231
119381
  },
119232
- remove: async (name2, target) => {
119233
- const resolver = current();
119234
- return resolver ? resolver.remove(name2, target) : notReady(`\u5220\u9664 "${name2}" \u7684\u8BB0\u5F55`);
119235
- },
119236
119382
  reload: async (names) => {
119237
- await current()?.reload(names === void 0 ? void 0 : [...names]);
119383
+ await base2.reload(names);
119238
119384
  this.dataPolling?.arm();
119239
119385
  },
119240
- validate: (name2, model, trigger3) => current()?.validate(name2, model, trigger3) ?? {},
119241
- writeOutcome: (scope) => this.writeOutcomeStore.get(scope),
119242
- onWriteOutcome: (listener) => this.writeOutcomeStore.subscribe(listener),
119243
- clearWriteOptimistic: (scope, key) => this.writeOutcomeStore.clearOptimistic(scope, key),
119244
- clearOutcome: (scope) => this.writeOutcomeStore.clear(scope)
119386
+ dispatch: async (name2, payload) => {
119387
+ if (owner !== this.dataOwnerEpoch) return;
119388
+ await base2.dispatch(name2, payload);
119389
+ this.dataPolling?.arm();
119390
+ }
119245
119391
  };
119246
- return port;
119247
119392
  }
119248
119393
  /** 推送失效 → 刷新:对象 reload(依赖它的下游随 DAG 一起重取) */
119249
119394
  async refreshDataObjects(owner, names) {
@@ -119454,6 +119599,7 @@ ${featureIssues.map((issue) => ` \xB7 ${issue}`).join("\n")}`
119454
119599
  async buildRuntime(parsed) {
119455
119600
  if (!this.container || !this.domainInstance) return;
119456
119601
  this.stopDeclarativeTimers();
119602
+ this.dataPortHostState.setActionDispatcher(void 0);
119457
119603
  this.eventEngine?.destroy();
119458
119604
  this.renderEngine?.destroy();
119459
119605
  this.styleBinder?.destroy();
@@ -119488,6 +119634,7 @@ ${featureIssues.map((issue) => ` \xB7 ${issue}`).join("\n")}`
119488
119634
  const writeEngine = this.eventEngine;
119489
119635
  const builtinActions = createDataWriteActions({ resolver: () => this.dataResolver, store: this.writeOutcomeStore });
119490
119636
  writeEngine.setBuiltinActions(builtinActions);
119637
+ this.dataPortHostState.setActionDispatcher((name2, payload) => writeEngine.dispatchAction(name2, payload));
119491
119638
  this.eventEngine.setScopeHandler(this.createScopeEventHandler());
119492
119639
  this.eventEngine.setRoleGate((roles) => this.domainInstance?._services?.permission?.hasAnyRole([...roles]) === true);
119493
119640
  this.assertNamedActionsResolvable(parsed.eventConfig, this.domainInstance, builtinActions);
@@ -119633,6 +119780,7 @@ ${featureIssues.map((issue) => ` \xB7 ${issue}`).join("\n")}`
119633
119780
  this.componentManager?.destroy();
119634
119781
  this.componentManager = null;
119635
119782
  this.proxy?.dispose();
119783
+ this.dataPortHostState.setActionDispatcher(void 0);
119636
119784
  this.eventEngine?.destroy();
119637
119785
  this.renderEngine?.destroy();
119638
119786
  this.styleBinder?.destroy();
package/dist/cli/soma.js CHANGED
@@ -127,9 +127,9 @@ if (command === 'check') {
127
127
  process.exit(1);
128
128
  });
129
129
  }
130
- /** Next 宿主壳命令行:随 soma-core 包发布的 host-next/bin/host-next.cjs(包内相对定位,不去 node_modules 找外部包) */
131
- function locateHostNextCli() {
132
- const candidate = node_path_1.default.join(packageRoot, 'host-next', 'bin', 'host-next.cjs');
130
+ /** 原生宿主壳命令行:随 soma-core 包发布的 host-native/bin/host-native.cjs(包内相对定位,不去 node_modules 找外部包) */
131
+ function locateHostNativeCli() {
132
+ const candidate = node_path_1.default.join(packageRoot, 'host-native', 'bin', 'host-native.cjs');
133
133
  return node_fs_1.default.existsSync(candidate) ? candidate : null;
134
134
  }
135
135
  // check 的 runtime 阶段是异步收尾(上面 then 里 process.exit),不得落进下面的 dev/build/start 转调
@@ -138,20 +138,74 @@ if (command !== 'check') {
138
138
  console.error('Usage: soma <dev|build|start|codegen|sync|lsp|eject|check|runtime|doctor|扩展命令> [...args](soma help 查看说明)');
139
139
  process.exit(1);
140
140
  }
141
- // `soma dev|build|start`:Next 宿主壳(app/、next.config、proxy、Next 工作区装配)在包内 host-next/ 目录,
142
- // core 运行时(core/**)不 import 它、不含 Next / React;这里以子进程转调它的命令行,参数、环境变量与退出码透传。
141
+ // `soma dev|build|start`:原生宿主壳(AOT 预编译 + 原生单进程内核)在包内 host-native/ 目录,
142
+ // core 运行时(core/**)不 import 它;这里以子进程转调它的命令行,参数、环境变量与退出码透传。
143
143
  // Host 目录取当前目录,覆盖外部陈旧的 SOMA_HOST_DIR。
144
144
  const hostDir = node_path_1.default.resolve(process.cwd());
145
145
  process.env.SOMA_HOST_DIR = hostDir;
146
- const hostNextCli = locateHostNextCli();
147
- if (!hostNextCli) {
148
- console.error(`[soma ${command}] 找不到 Next 宿主壳入口 host-next/bin/host-next.cjs:soma-core 包不完整,请重新安装。`);
146
+ const restArgs = args.slice(1);
147
+ for (let i = 0; i < restArgs.length; i++) {
148
+ const arg = restArgs[i];
149
+ if (arg === '--web-dir' && i + 1 < restArgs.length) {
150
+ process.env.SOMA_WEB_DIR = node_path_1.default.resolve(process.cwd(), restArgs[i + 1]);
151
+ }
152
+ else if (arg.startsWith('--web-dir=')) {
153
+ process.env.SOMA_WEB_DIR = node_path_1.default.resolve(process.cwd(), arg.slice('--web-dir='.length));
154
+ }
155
+ else if (arg === '--api-dir' && i + 1 < restArgs.length) {
156
+ process.env.SOMA_API_DIR = node_path_1.default.resolve(process.cwd(), restArgs[i + 1]);
157
+ }
158
+ else if (arg.startsWith('--api-dir=')) {
159
+ process.env.SOMA_API_DIR = node_path_1.default.resolve(process.cwd(), arg.slice('--api-dir='.length));
160
+ }
161
+ }
162
+ const hostNativeCli = locateHostNativeCli();
163
+ if (!hostNativeCli) {
164
+ console.error(`[soma ${command}] 找不到原生宿主壳入口 host-native/bin/host-native.cjs:soma-core 包不完整,请重新安装。`);
149
165
  process.exit(1);
150
166
  }
151
- const child = (0, node_child_process_1.spawnSync)(process.execPath, [hostNextCli, command, ...args.slice(1)], {
152
- cwd: process.cwd(),
153
- stdio: 'inherit',
154
- env: { ...process.env, SOMA_HOST_DIR: hostDir },
155
- });
156
- process.exit(child.status === null ? 1 : child.status);
167
+ const hasHeapArg = process.execArgv.some((a) => a.includes('--max-old-space-size'))
168
+ || (process.env.NODE_OPTIONS || '').includes('--max-old-space-size');
169
+ const nodeArgs = [];
170
+ if (!hasHeapArg && !process.env.SOMA_DISABLE_HEAP_CAP) {
171
+ const defaultCap = command === 'dev' ? 1024 : 512;
172
+ const cap = process.env.SOMA_MAX_OLD_SPACE_MB
173
+ ? parseInt(process.env.SOMA_MAX_OLD_SPACE_MB, 10)
174
+ : defaultCap;
175
+ if (Number.isFinite(cap) && cap > 0) {
176
+ nodeArgs.push(`--max-old-space-size=${cap}`);
177
+ }
178
+ }
179
+ nodeArgs.push(hostNativeCli, command, ...args.slice(1));
180
+ const childEnv = {
181
+ ...process.env,
182
+ SOMA_HOST_DIR: hostDir,
183
+ SOMA_NATIVE_HEAP_APPLIED: '1',
184
+ };
185
+ if (command === 'build') {
186
+ const child = (0, node_child_process_1.spawnSync)(process.execPath, nodeArgs, {
187
+ cwd: process.cwd(),
188
+ stdio: 'inherit',
189
+ env: childEnv,
190
+ });
191
+ process.exit(child.status === null ? 1 : child.status);
192
+ }
193
+ else {
194
+ const child = (0, node_child_process_1.spawn)(process.execPath, nodeArgs, {
195
+ cwd: process.cwd(),
196
+ stdio: 'inherit',
197
+ env: childEnv,
198
+ });
199
+ const forward = (sig) => {
200
+ try {
201
+ child.kill(sig);
202
+ }
203
+ catch { }
204
+ };
205
+ process.on('SIGINT', () => forward('SIGINT'));
206
+ process.on('SIGTERM', () => forward('SIGTERM'));
207
+ child.on('exit', (code, signal) => {
208
+ process.exit(code ?? (signal ? 0 : 0));
209
+ });
210
+ }
157
211
  }