@axiom-lattice/core 2.1.99 → 2.1.100

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.mjs CHANGED
@@ -9974,7 +9974,7 @@ import {
9974
9974
  asyncScheduler
9975
9975
  } from "rxjs";
9976
9976
  import { eachValueFrom } from "rxjs-for-await";
9977
- import { filter, takeWhile } from "rxjs/operators";
9977
+ import { takeWhile, skip } from "rxjs/operators";
9978
9978
  var InMemoryChunkBuffer = class extends ChunkBuffer {
9979
9979
  constructor(config) {
9980
9980
  super();
@@ -10184,17 +10184,18 @@ var InMemoryChunkBuffer = class extends ChunkBuffer {
10184
10184
  MessageChunkTypes.THREAD_IDLE
10185
10185
  ];
10186
10186
  const typesToStop = stopTypes ?? defaultStopTypes;
10187
- let startYieldChunk = false;
10188
- console.log("start from messageId", messageId);
10187
+ let startIndex = 0;
10188
+ for (let i = buffer2.chunks.length - 1; i >= 0; i--) {
10189
+ if (buffer2.chunks[i].data?.id === messageId) {
10190
+ startIndex = i;
10191
+ break;
10192
+ }
10193
+ }
10194
+ const stopSet = new Set(typesToStop);
10189
10195
  const filtered$ = buffer2.chunks$.pipe(
10190
10196
  observeOn(asyncScheduler),
10191
- // 1. 从指定 messageId 开始
10192
- filter((chunk) => {
10193
- if (chunk.data?.id === messageId) startYieldChunk = true;
10194
- return startYieldChunk;
10195
- }),
10196
- // 2. 包含指定的停止类型,但收到后停止
10197
- takeWhile((chunk) => !typesToStop.includes(chunk.type), true)
10197
+ skip(startIndex),
10198
+ takeWhile((chunk) => !stopSet.has(chunk.type), true)
10198
10199
  );
10199
10200
  yield* eachValueFrom(filtered$);
10200
10201
  }
@@ -26719,6 +26720,230 @@ var PersonalAssistantConfig = class {
26719
26720
  };
26720
26721
  PersonalAssistantConfig._config = deepClone(DEFAULT_CONFIG);
26721
26722
 
26723
+ // src/export_import/ExportableEntityRegistry.ts
26724
+ var ExportableEntityRegistry = class _ExportableEntityRegistry {
26725
+ constructor() {
26726
+ this.definitions = /* @__PURE__ */ new Map();
26727
+ }
26728
+ /**
26729
+ * Returns the singleton registry instance, creating it if necessary.
26730
+ *
26731
+ * @returns The singleton {@link ExportableEntityRegistry} instance.
26732
+ */
26733
+ static getInstance() {
26734
+ if (!_ExportableEntityRegistry.instance) {
26735
+ _ExportableEntityRegistry.instance = new _ExportableEntityRegistry();
26736
+ }
26737
+ return _ExportableEntityRegistry.instance;
26738
+ }
26739
+ /**
26740
+ * Registers an exportable entity type definition.
26741
+ *
26742
+ * @param def - The entity definition to register.
26743
+ *
26744
+ * @throws If an entity type with the same `entityType` is already registered.
26745
+ */
26746
+ register(def) {
26747
+ if (this.definitions.has(def.entityType)) {
26748
+ throw new Error(
26749
+ `Exportable entity type "${def.entityType}" is already registered`
26750
+ );
26751
+ }
26752
+ this.definitions.set(def.entityType, def);
26753
+ }
26754
+ /**
26755
+ * Retrieves a registered entity definition by type name.
26756
+ *
26757
+ * @param entityType - The entity type identifier (e.g. `'skill'`, `'agent'`).
26758
+ *
26759
+ * @returns The registered {@link ExportableEntityDefinition}.
26760
+ *
26761
+ * @throws If no definition is registered for the given type.
26762
+ */
26763
+ get(entityType) {
26764
+ const def = this.definitions.get(entityType);
26765
+ if (!def) {
26766
+ throw new Error(`Exportable entity type "${entityType}" not found`);
26767
+ }
26768
+ return def;
26769
+ }
26770
+ /**
26771
+ * Returns lightweight metadata for all registered types (for the frontend).
26772
+ *
26773
+ * @returns An array of {@link ExportableTypeInfo} objects.
26774
+ */
26775
+ listTypes() {
26776
+ return [...this.definitions.values()].map((d) => ({
26777
+ entityType: d.entityType,
26778
+ label: d.label,
26779
+ category: d.category,
26780
+ dependsOn: d.dependsOn,
26781
+ cascadeParents: d.cascadeParents
26782
+ }));
26783
+ }
26784
+ /**
26785
+ * Returns all registered entity definitions.
26786
+ *
26787
+ * @returns An array of all registered {@link ExportableEntityDefinition} objects.
26788
+ */
26789
+ getAll() {
26790
+ return [...this.definitions.values()];
26791
+ }
26792
+ /**
26793
+ * Removes a registered entity type definition.
26794
+ *
26795
+ * @param entityType - The entity type identifier to remove.
26796
+ */
26797
+ unregister(entityType) {
26798
+ this.definitions.delete(entityType);
26799
+ }
26800
+ };
26801
+
26802
+ // src/export_import/DependencyResolver.ts
26803
+ var DependencyResolver = class {
26804
+ /**
26805
+ * Topological sort of entity types based on their {@link ExportableEntityDefinition.dependsOn}
26806
+ * declarations. Entities with no dependencies come first.
26807
+ *
26808
+ * @param defs - All registered exportable entity definitions.
26809
+ * @returns Entity type names in dependency-first order.
26810
+ */
26811
+ static resolveOrder(defs) {
26812
+ const typeMap = new Map(defs.map((d) => [d.entityType, d]));
26813
+ const visited = /* @__PURE__ */ new Set();
26814
+ const result = [];
26815
+ function visit(type) {
26816
+ if (visited.has(type)) return;
26817
+ visited.add(type);
26818
+ const def = typeMap.get(type);
26819
+ if (def) {
26820
+ for (const dep of def.dependsOn) {
26821
+ if (typeMap.has(dep)) {
26822
+ visit(dep);
26823
+ }
26824
+ }
26825
+ }
26826
+ result.push(type);
26827
+ }
26828
+ for (const def of defs) {
26829
+ visit(def.entityType);
26830
+ }
26831
+ return result;
26832
+ }
26833
+ /**
26834
+ * Given a set of selected entity types, expand to include all CASCADE
26835
+ * parents. Only walks **upward** (parents), never downward (children).
26836
+ *
26837
+ * @param defs - All registered exportable entity definitions.
26838
+ * @param selected - Entity type names the user explicitly chose.
26839
+ * @returns The original selection plus every reachable cascade parent.
26840
+ */
26841
+ static expandCascade(defs, selected) {
26842
+ const typeMap = new Map(defs.map((d) => [d.entityType, d]));
26843
+ const result = new Set(selected);
26844
+ let changed = true;
26845
+ while (changed) {
26846
+ changed = false;
26847
+ for (const type of [...result]) {
26848
+ const def = typeMap.get(type);
26849
+ if (def) {
26850
+ for (const parent of def.cascadeParents) {
26851
+ if (!result.has(parent)) {
26852
+ result.add(parent);
26853
+ changed = true;
26854
+ }
26855
+ }
26856
+ }
26857
+ }
26858
+ }
26859
+ return [...result];
26860
+ }
26861
+ /**
26862
+ * Compute which required dependencies are missing from the selected types.
26863
+ *
26864
+ * Only considers dependencies that are themselves registered as exportable
26865
+ * entity types. Unregistered dependencies (e.g. `Workspace`, `Project` —
26866
+ * infrastructure types) are silently excluded.
26867
+ *
26868
+ * @param defs - All registered exportable entity definitions.
26869
+ * @param selected - Entity type names the user has selected.
26870
+ * @returns The list of entity types that must also be selected (or
26871
+ * auto-included).
26872
+ */
26873
+ static computeDependencies(defs, selected) {
26874
+ const typeMap = new Map(defs.map((d) => [d.entityType, d]));
26875
+ const selectedSet = new Set(selected);
26876
+ const missing = /* @__PURE__ */ new Set();
26877
+ function collectMissing(type) {
26878
+ if (selectedSet.has(type)) return;
26879
+ const def = typeMap.get(type);
26880
+ if (!def) return;
26881
+ missing.add(type);
26882
+ for (const dep of def.dependsOn) {
26883
+ collectMissing(dep);
26884
+ }
26885
+ }
26886
+ for (const type of selected) {
26887
+ const def = typeMap.get(type);
26888
+ if (def) {
26889
+ for (const dep of def.dependsOn) {
26890
+ collectMissing(dep);
26891
+ }
26892
+ }
26893
+ }
26894
+ return { missing: [...missing] };
26895
+ }
26896
+ };
26897
+
26898
+ // src/export_import/IdRemapper.ts
26899
+ var REF_PATTERN = /^@(\w+)\/(.+)$/;
26900
+ var IdRemapper = class {
26901
+ constructor(idMap) {
26902
+ this.idMap = idMap;
26903
+ }
26904
+ /**
26905
+ * Deep-traverse an object/array and replace all @type/exportId string values
26906
+ * with their corresponding real IDs from the idMap.
26907
+ * Values not matching the @type/exportId pattern are returned unchanged.
26908
+ */
26909
+ remapReferences(value) {
26910
+ if (value === null || value === void 0) return value;
26911
+ if (typeof value === "string") {
26912
+ const match = value.match(REF_PATTERN);
26913
+ if (match) {
26914
+ const exportId = match[2];
26915
+ if (this.idMap[exportId] !== void 0) {
26916
+ return this.idMap[exportId];
26917
+ }
26918
+ }
26919
+ return value;
26920
+ }
26921
+ if (Array.isArray(value)) {
26922
+ return value.map((item) => this.remapReferences(item));
26923
+ }
26924
+ if (typeof value === "object") {
26925
+ const result = {};
26926
+ for (const [key4, val] of Object.entries(value)) {
26927
+ result[key4] = this.remapReferences(val);
26928
+ }
26929
+ return result;
26930
+ }
26931
+ return value;
26932
+ }
26933
+ /**
26934
+ * Replace raw skill IDs in an agent's graphDefinition.skillIds array.
26935
+ * This handles the implicit agent->skill reference that uses raw skill IDs
26936
+ * (not @type/exportId format). Agents reference skills by their string ID.
26937
+ */
26938
+ remapSkillIds(graphDefinition, skillRemap) {
26939
+ const cloned = structuredClone(graphDefinition);
26940
+ if (Array.isArray(cloned.skillIds)) {
26941
+ cloned.skillIds = cloned.skillIds.map((id) => skillRemap[id] ?? id);
26942
+ }
26943
+ return cloned;
26944
+ }
26945
+ };
26946
+
26722
26947
  // src/index.ts
26723
26948
  registerBuiltinPlugins();
26724
26949
  export {
@@ -26741,13 +26966,16 @@ export {
26741
26966
  DaytonaInstance,
26742
26967
  DaytonaProvider,
26743
26968
  DefaultScheduleClient,
26969
+ DependencyResolver,
26744
26970
  E2BInstance,
26745
26971
  E2BProvider,
26746
26972
  EMPTY_CONTENT_WARNING,
26747
26973
  EmbeddingsLatticeManager,
26974
+ ExportableEntityRegistry,
26748
26975
  FileSystemSkillStore,
26749
26976
  FilesystemBackend,
26750
26977
  HumanMessage4 as HumanMessage,
26978
+ IdRemapper,
26751
26979
  InMemoryA2AApiKeyStore,
26752
26980
  InMemoryAssistantStore,
26753
26981
  InMemoryBindingStore,