@pactor-app/chat 0.1.0 → 1.0.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/index.cjs CHANGED
@@ -719,20 +719,34 @@ function createChatRuntime(options = {}) {
719
719
  }
720
720
 
721
721
  // src/dsl-guard.ts
722
+ var import_core2 = require("@pactor-app/core");
722
723
  var CHAT_DENIED_TYPE = "ChatDenied";
723
724
  function guardChatDsl(node, registry) {
724
- if (node.type !== CHAT_DENIED_TYPE && !registry.has(node.type)) {
725
+ const type = node.type ?? "(reference)";
726
+ if (type !== CHAT_DENIED_TYPE && !registry.has(type)) {
725
727
  return {
726
728
  type: CHAT_DENIED_TYPE,
727
- props: { deniedType: node.type }
729
+ props: { deniedType: type }
728
730
  };
729
731
  }
730
- if (!node.children || node.children.length === 0) {
732
+ if (node.children === void 0) {
733
+ return node;
734
+ }
735
+ if (!Array.isArray(node.children)) {
736
+ return {
737
+ type: CHAT_DENIED_TYPE,
738
+ props: { deniedType: `${type}(remote)` }
739
+ };
740
+ }
741
+ if (node.children.length === 0) {
731
742
  return node;
732
743
  }
733
744
  return {
734
745
  ...node,
735
- children: node.children.map((child) => guardChatDsl(child, registry))
746
+ // 数组中混排的引用元素同样无法静态过白名单:替换为受控占位
747
+ children: node.children.map(
748
+ (child) => (0, import_core2.isDslSourceRef)(child) ? { type: CHAT_DENIED_TYPE, props: { deniedType: "(remote)" } } : guardChatDsl(child, registry)
749
+ )
736
750
  };
737
751
  }
738
752
 
@@ -973,7 +987,7 @@ function AppShell({ sidebar, brand, locationKey, sidebarFooter, collapsible = fa
973
987
 
974
988
  // src/view/ArtifactPanel.tsx
975
989
  var import_lucide_react3 = require("lucide-react");
976
- var import_core2 = require("@pactor-app/core");
990
+ var import_core3 = require("@pactor-app/core");
977
991
  var import_markdown2 = require("@pactor-app/markdown");
978
992
  var import_runtime3 = require("@pactor-app/runtime");
979
993
  var import_react5 = require("react");
@@ -1065,7 +1079,7 @@ function useArtifactRuntime(safeRegistry, user) {
1065
1079
  if (!safeRegistry) {
1066
1080
  return void 0;
1067
1081
  }
1068
- const components = new import_core2.Registry("ChatArtifactRegistry");
1082
+ const components = new import_core3.Registry("ChatArtifactRegistry");
1069
1083
  components.register(CHAT_DENIED_TYPE, ChatDenied);
1070
1084
  for (const name of safeRegistry.list()) {
1071
1085
  components.register(name, safeRegistry.get(name));
@@ -1199,7 +1213,7 @@ function ArtifactPanel({
1199
1213
 
1200
1214
  // src/view/ChatView.tsx
1201
1215
  var import_lucide_react8 = require("lucide-react");
1202
- var import_core3 = require("@pactor-app/core");
1216
+ var import_core4 = require("@pactor-app/core");
1203
1217
  var import_react13 = require("react");
1204
1218
 
1205
1219
  // src/view/Composer.tsx
@@ -2388,7 +2402,7 @@ function ChatView({
2388
2402
  if (!safeRegistry) {
2389
2403
  return void 0;
2390
2404
  }
2391
- const components = new import_core3.Registry("ChatComponentRegistry");
2405
+ const components = new import_core4.Registry("ChatComponentRegistry");
2392
2406
  components.register(CHAT_DENIED_TYPE, ChatDenied);
2393
2407
  for (const name of safeRegistry.list()) {
2394
2408
  components.register(name, safeRegistry.get(name));
package/dist/index.js CHANGED
@@ -653,20 +653,34 @@ function createChatRuntime(options = {}) {
653
653
  }
654
654
 
655
655
  // src/dsl-guard.ts
656
+ import { isDslSourceRef } from "@pactor-app/core";
656
657
  var CHAT_DENIED_TYPE = "ChatDenied";
657
658
  function guardChatDsl(node, registry) {
658
- if (node.type !== CHAT_DENIED_TYPE && !registry.has(node.type)) {
659
+ const type = node.type ?? "(reference)";
660
+ if (type !== CHAT_DENIED_TYPE && !registry.has(type)) {
659
661
  return {
660
662
  type: CHAT_DENIED_TYPE,
661
- props: { deniedType: node.type }
663
+ props: { deniedType: type }
662
664
  };
663
665
  }
664
- if (!node.children || node.children.length === 0) {
666
+ if (node.children === void 0) {
667
+ return node;
668
+ }
669
+ if (!Array.isArray(node.children)) {
670
+ return {
671
+ type: CHAT_DENIED_TYPE,
672
+ props: { deniedType: `${type}(remote)` }
673
+ };
674
+ }
675
+ if (node.children.length === 0) {
665
676
  return node;
666
677
  }
667
678
  return {
668
679
  ...node,
669
- children: node.children.map((child) => guardChatDsl(child, registry))
680
+ // 数组中混排的引用元素同样无法静态过白名单:替换为受控占位
681
+ children: node.children.map(
682
+ (child) => isDslSourceRef(child) ? { type: CHAT_DENIED_TYPE, props: { deniedType: "(remote)" } } : guardChatDsl(child, registry)
683
+ )
670
684
  };
671
685
  }
672
686
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pactor-app/chat",
3
- "version": "0.1.0",
3
+ "version": "1.0.0",
4
4
  "description": "Pactor chat: AI message rendering protocol (message model, streaming reducer, safe registry, capability action) and chat runtime view (ChatView / MessageBubble / PartRenderer / Composer / chat layout)",
5
5
  "keywords": [
6
6
  "pactor",
@@ -50,10 +50,10 @@
50
50
  },
51
51
  "dependencies": {
52
52
  "lucide-react": "^1.31.0",
53
- "@pactor-app/runtime": "0.1.0",
54
- "@pactor-app/markdown": "0.1.0",
55
- "@pactor-app/core": "0.1.0",
56
- "@pactor-app/permission": "0.1.0"
53
+ "@pactor-app/markdown": "1.0.0",
54
+ "@pactor-app/runtime": "1.0.0",
55
+ "@pactor-app/permission": "1.0.0",
56
+ "@pactor-app/core": "1.0.0"
57
57
  },
58
58
  "peerDependencies": {
59
59
  "react": ">=18"
@@ -66,7 +66,7 @@
66
66
  "jsdom": "^30.0.1",
67
67
  "react": "^19.2.8",
68
68
  "react-dom": "^19.2.8",
69
- "@pactor-app/ui": "0.1.0"
69
+ "@pactor-app/ui": "1.0.0"
70
70
  },
71
71
  "scripts": {
72
72
  "build": "tsup",