@granular-software/sdk 0.4.25 → 0.4.27

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.
@@ -4590,6 +4590,22 @@ var Session = class {
4590
4590
  }
4591
4591
  };
4592
4592
  }
4593
+ stringifyConversationValue(value) {
4594
+ if (typeof value === "string") {
4595
+ return value;
4596
+ }
4597
+ if (typeof value === "boolean") {
4598
+ return value ? "Confirmed" : "Canceled";
4599
+ }
4600
+ if (value === void 0) {
4601
+ return "";
4602
+ }
4603
+ try {
4604
+ return JSON.stringify(value, null, 2);
4605
+ } catch {
4606
+ return String(value);
4607
+ }
4608
+ }
4593
4609
  // --- Public API ---
4594
4610
  get document() {
4595
4611
  return this.client.doc;
@@ -4740,6 +4756,20 @@ var Session = class {
4740
4756
  answer: resolvedAnswer,
4741
4757
  value: resolvedAnswer
4742
4758
  });
4759
+ try {
4760
+ const content = this.stringifyConversationValue(resolvedAnswer);
4761
+ if (content.trim()) {
4762
+ await this.appendConversationMessage({
4763
+ role: "user",
4764
+ content,
4765
+ promptId
4766
+ });
4767
+ }
4768
+ } catch {
4769
+ }
4770
+ }
4771
+ async appendConversationMessage(input) {
4772
+ return this.client.call("conversation.append", input);
4743
4773
  }
4744
4774
  /**
4745
4775
  * Get the current list of available effects.
@@ -4879,9 +4909,24 @@ var Session = class {
4879
4909
  * Get domain documentation for LLMs. Returns types (preferred) or fallback.
4880
4910
  */
4881
4911
  async getDomainDocumentation() {
4882
- const types = await this.getDomainTypes();
4883
- if (types && (types.includes("export declare class") || types.includes("export async function"))) {
4884
- return types;
4912
+ const [types, docs] = await Promise.all([
4913
+ this.getDomainTypes(),
4914
+ this.getDomainDocs()
4915
+ ]);
4916
+ const normalizedTypes = types.trim();
4917
+ const normalizedDocs = docs.trim();
4918
+ if (normalizedTypes && (normalizedTypes.includes("export declare class") || normalizedTypes.includes("export async function"))) {
4919
+ if (!normalizedDocs) {
4920
+ return normalizedTypes;
4921
+ }
4922
+ return [
4923
+ normalizedTypes,
4924
+ "Generated usage notes from ./sandbox-tools docs:",
4925
+ normalizedDocs
4926
+ ].join("\n\n");
4927
+ }
4928
+ if (normalizedDocs) {
4929
+ return normalizedDocs;
4885
4930
  }
4886
4931
  const summary = await this.getDomain();
4887
4932
  return this.generateFallbackDocs(summary);
@@ -9691,10 +9736,15 @@ external_exports.union([
9691
9736
  scalarType: external_exports.string().optional()
9692
9737
  }).strict()
9693
9738
  ]);
9739
+ external_exports.union([
9740
+ external_exports.boolean(),
9741
+ external_exports.object({
9742
+ enabled: external_exports.boolean().optional(),
9743
+ phonetic: external_exports.boolean().optional()
9744
+ }).strict()
9745
+ ]);
9694
9746
  external_exports.object({
9695
- operator: external_exports.enum(
9696
- [...VALIDATION_RULE_OPERATORS]
9697
- ),
9747
+ operator: external_exports.enum([...VALIDATION_RULE_OPERATORS]),
9698
9748
  stringValue: external_exports.string().optional(),
9699
9749
  numberValue: external_exports.number().optional(),
9700
9750
  booleanValue: external_exports.boolean().optional(),
@@ -9787,12 +9837,18 @@ function collectMetamodelSummarySelections(packages) {
9787
9837
  const propertyFields = [];
9788
9838
  const methodFields = [];
9789
9839
  for (const metamodelPackage of packages) {
9790
- pushUnique(classFields, metamodelPackage.summary.selections?.classFields || []);
9840
+ pushUnique(
9841
+ classFields,
9842
+ metamodelPackage.summary.selections?.classFields || []
9843
+ );
9791
9844
  pushUnique(
9792
9845
  propertyFields,
9793
9846
  metamodelPackage.summary.selections?.propertyFields || []
9794
9847
  );
9795
- pushUnique(methodFields, metamodelPackage.summary.selections?.methodFields || []);
9848
+ pushUnique(
9849
+ methodFields,
9850
+ metamodelPackage.summary.selections?.methodFields || []
9851
+ );
9796
9852
  }
9797
9853
  return {
9798
9854
  classFields: unique(classFields),
@@ -9880,7 +9936,11 @@ function createMetamodelRegistry(metamodelPackages) {
9880
9936
  return collectMetamodelSummarySelections(packages);
9881
9937
  },
9882
9938
  applyClassSummaryReaders(rawClass, classSummary) {
9883
- return applyMetamodelSummaryReadersToClass(packages, rawClass, classSummary);
9939
+ return applyMetamodelSummaryReadersToClass(
9940
+ packages,
9941
+ rawClass,
9942
+ classSummary
9943
+ );
9884
9944
  },
9885
9945
  applyPropertySummaryReaders(rawProperty, propertySummary) {
9886
9946
  return applyMetamodelSummaryReadersToProperty(
@@ -9890,7 +9950,11 @@ function createMetamodelRegistry(metamodelPackages) {
9890
9950
  );
9891
9951
  },
9892
9952
  applyMethodSummaryReaders(rawMethod, methodSummary) {
9893
- return applyMetamodelSummaryReadersToMethod(packages, rawMethod, methodSummary);
9953
+ return applyMetamodelSummaryReadersToMethod(
9954
+ packages,
9955
+ rawMethod,
9956
+ methodSummary
9957
+ );
9894
9958
  },
9895
9959
  applyClassIR(classIR, classSummary) {
9896
9960
  return applyMetamodelClassIR(packages, classIR, classSummary);
@@ -9938,6 +10002,10 @@ function mergeClassSummaryPatch(target, patch) {
9938
10002
  }
9939
10003
  function mergePropertySummaryPatch(target, patch) {
9940
10004
  pushUnique(target.notes, patch.notes || []);
10005
+ if (patch.searchable !== void 0) target.searchable = patch.searchable;
10006
+ if (patch.searchablePhonetic !== void 0) {
10007
+ target.searchablePhonetic = patch.searchablePhonetic;
10008
+ }
9941
10009
  if (patch.required !== void 0) target.required = patch.required;
9942
10010
  if (patch.enumRule !== void 0) target.enumRule = patch.enumRule;
9943
10011
  if (patch.filterBy !== void 0) target.filterBy = patch.filterBy;
@@ -9949,9 +10017,11 @@ function mergeMethodSummaryPatch(target, patch) {
9949
10017
  if (patch.effectKey !== void 0) target.effectKey = patch.effectKey;
9950
10018
  if (patch.description !== void 0) target.description = patch.description;
9951
10019
  if (patch.inputSchema !== void 0) target.inputSchema = patch.inputSchema;
9952
- if (patch.outputSchema !== void 0) target.outputSchema = patch.outputSchema;
10020
+ if (patch.outputSchema !== void 0)
10021
+ target.outputSchema = patch.outputSchema;
9953
10022
  if (patch.metamodels !== void 0) target.metamodels = patch.metamodels;
9954
- if (patch.effectBehaviors !== void 0) target.effectBehaviors = patch.effectBehaviors;
10023
+ if (patch.effectBehaviors !== void 0)
10024
+ target.effectBehaviors = patch.effectBehaviors;
9955
10025
  if (patch.static !== void 0) target.static = patch.static;
9956
10026
  }
9957
10027
  function toPascalCase(value) {
@@ -10457,12 +10527,20 @@ function defaultFilterOperators(scalarType) {
10457
10527
  switch ((scalarType || "").toLowerCase()) {
10458
10528
  case "number":
10459
10529
  case "date":
10460
- return ["equal_to", "greater_than", "less_than", "not_null"];
10530
+ return [
10531
+ "equal_to",
10532
+ "greater_than",
10533
+ "greater_than_or_equal_to",
10534
+ "less_than",
10535
+ "less_than_or_equal_to",
10536
+ "not_null"
10537
+ ];
10461
10538
  case "boolean":
10462
- return ["equal_to", "not_null"];
10539
+ return ["equal_to", "true", "false", "not_null"];
10463
10540
  default:
10464
10541
  return [
10465
10542
  "equal_to",
10543
+ "in",
10466
10544
  "contains",
10467
10545
  "not_contains",
10468
10546
  "starts_with",
@@ -10471,16 +10549,26 @@ function defaultFilterOperators(scalarType) {
10471
10549
  ];
10472
10550
  }
10473
10551
  }
10552
+ function supportsDefaultFilterBy(scalarType) {
10553
+ return ["string", "number", "boolean", "date"].includes(
10554
+ String(scalarType || "").toLowerCase()
10555
+ );
10556
+ }
10474
10557
  function normalizeFilterByInput(filterBy, scalarType) {
10475
- if (!filterBy) return null;
10558
+ if (filterBy === false) return null;
10559
+ if (filterBy === void 0) {
10560
+ if (!supportsDefaultFilterBy(scalarType)) return null;
10561
+ return { operators: defaultFilterOperators(scalarType), scalarType };
10562
+ }
10476
10563
  if (filterBy === true) {
10477
- return { operators: defaultFilterOperators(scalarType) };
10564
+ return { operators: defaultFilterOperators(scalarType), scalarType };
10478
10565
  }
10479
10566
  if (Array.isArray(filterBy)) {
10480
- return { operators: filterBy };
10567
+ return { operators: filterBy, scalarType };
10481
10568
  }
10482
10569
  return {
10483
- operators: filterBy.operators
10570
+ operators: filterBy.operators,
10571
+ scalarType: filterBy.scalarType || scalarType
10484
10572
  };
10485
10573
  }
10486
10574
  function buildFilterByFieldMutations(fieldPath, filterBy, scalarType) {
@@ -10491,7 +10579,7 @@ function buildFilterByFieldMutations(fieldPath, filterBy, scalarType) {
10491
10579
  label: `set filterBy on ${fieldPath}`,
10492
10580
  query: `mutation { at(path: ${JSON.stringify(fieldPath)}) { set_filter_by(operators: ${JSON.stringify(
10493
10581
  normalized.operators
10494
- )}) { operators } } }`
10582
+ )}${normalized.scalarType ? `, scalar_type: ${JSON.stringify(normalized.scalarType)}` : ""}) { operators } } }`
10495
10583
  }
10496
10584
  ];
10497
10585
  }
@@ -10501,7 +10589,7 @@ var filterByMetamodelPackage = defineMetamodelPackage({
10501
10589
  fieldRows: [
10502
10590
  {
10503
10591
  key: "filterBy",
10504
- description: "Exposes filter operators for generated query surfaces. Accepts `true`, an operator array, or `{ operators, scalarType }`."
10592
+ description: "Exposes filter operators for generated query surfaces. Scalar fields are filterable by default; set `filterBy: false` to opt out, or override with `true`, an operator array, or `{ operators, scalarType }`."
10505
10593
  }
10506
10594
  ]
10507
10595
  },
@@ -10765,6 +10853,123 @@ var requiredMetamodelPackage = defineMetamodelPackage({
10765
10853
  }
10766
10854
  });
10767
10855
 
10856
+ // ../metamodel-searchable/src/index.ts
10857
+ function supportsDefaultSearchable(scalarType) {
10858
+ return String(scalarType || "").toLowerCase() === "string";
10859
+ }
10860
+ function normalizeSearchableInput(searchable, scalarType) {
10861
+ if (!supportsDefaultSearchable(scalarType)) return null;
10862
+ if (typeof searchable === "boolean" || searchable === void 0) {
10863
+ return {
10864
+ enabled: searchable !== false,
10865
+ phonetic: false
10866
+ };
10867
+ }
10868
+ const enabled = searchable.enabled !== false;
10869
+ return {
10870
+ enabled,
10871
+ phonetic: enabled && searchable.phonetic === true
10872
+ };
10873
+ }
10874
+ function buildSearchableFieldMutations(fieldPath, searchable, scalarType) {
10875
+ const normalized = normalizeSearchableInput(searchable, scalarType);
10876
+ if (normalized === null) return [];
10877
+ return [
10878
+ {
10879
+ label: `set searchable on ${fieldPath}`,
10880
+ query: `mutation { at(path: ${JSON.stringify(fieldPath)}) { set_searchable(enabled: ${normalized.enabled}, phonetic: ${normalized.phonetic}) { enabled phonetic } } }`
10881
+ }
10882
+ ];
10883
+ }
10884
+ var searchableMetamodelPackage = defineMetamodelPackage({
10885
+ id: "searchable",
10886
+ docs: {
10887
+ fieldRows: [
10888
+ {
10889
+ key: "searchable",
10890
+ description: "Controls full-text search exposure for string fields. String fields are searchable by default; set `searchable: false` to opt out, or use `searchable: { phonetic: true }` to keep the field searchable while enabling FalkorDB phonetic matching for class-wide search."
10891
+ }
10892
+ ]
10893
+ },
10894
+ graphql: {
10895
+ typeDefs: [
10896
+ `
10897
+ type SearchableMetamodel {
10898
+ model: Model!
10899
+ enabled: Boolean!
10900
+ phonetic: Boolean!
10901
+ }
10902
+
10903
+ extend type Model {
10904
+ searchable: SearchableMetamodel
10905
+ }
10906
+
10907
+ extend type ModelMutation {
10908
+ set_searchable(enabled: Boolean!, phonetic: Boolean): SearchableMetamodel
10909
+ }
10910
+ `
10911
+ ],
10912
+ createResolvers({ run }) {
10913
+ return {
10914
+ SearchableMetamodel: {
10915
+ model: (value) => value.model,
10916
+ enabled: (value) => value.enabled !== false,
10917
+ phonetic: (value) => value.phonetic === true
10918
+ },
10919
+ Model: {
10920
+ searchable: async (ant) => await run(ant.searchable())
10921
+ },
10922
+ ModelMutation: {
10923
+ set_searchable: async (ant, { enabled, phonetic }) => {
10924
+ return {
10925
+ model: await run(ant.set_searchable(enabled, phonetic === true)),
10926
+ enabled,
10927
+ phonetic: phonetic === true
10928
+ };
10929
+ }
10930
+ }
10931
+ };
10932
+ }
10933
+ },
10934
+ manifest: {
10935
+ buildFieldMutations(fieldPath, spec) {
10936
+ return buildSearchableFieldMutations(
10937
+ fieldPath,
10938
+ spec.searchable,
10939
+ spec.type
10940
+ );
10941
+ }
10942
+ },
10943
+ summary: {
10944
+ selections: {
10945
+ propertyFields: [`searchable { enabled phonetic }`]
10946
+ },
10947
+ readPropertySummary(rawProperty) {
10948
+ if (typeof rawProperty.searchable?.enabled !== "boolean") {
10949
+ return {};
10950
+ }
10951
+ return {
10952
+ searchable: rawProperty.searchable.enabled,
10953
+ searchablePhonetic: rawProperty.searchable.phonetic === true
10954
+ };
10955
+ }
10956
+ },
10957
+ domain: {
10958
+ applyToPropertyIR(propertyIR, propertySummary) {
10959
+ if (String(propertySummary.type || "").toLowerCase() !== "string" || propertySummary.searchable === false) {
10960
+ return propertyIR;
10961
+ }
10962
+ return {
10963
+ ...propertyIR,
10964
+ docs: [
10965
+ ...propertyIR.docs,
10966
+ propertySummary.searchablePhonetic ? "Searchable via `search` using FalkorDB full-text query syntax with phonetic matching enabled." : "Searchable via `search` using FalkorDB full-text query syntax."
10967
+ ]
10968
+ };
10969
+ }
10970
+ }
10971
+ });
10972
+
10768
10973
  // ../metamodel-state-machine/src/index.ts
10769
10974
  function normalizeStateMachines(values) {
10770
10975
  return (values || []).map((machine) => {
@@ -11345,6 +11550,7 @@ var DEFAULT_METAMODEL_PACKAGES = [
11345
11550
  requiredMetamodelPackage,
11346
11551
  enumMetamodelPackage,
11347
11552
  filterByMetamodelPackage,
11553
+ searchableMetamodelPackage,
11348
11554
  validationRuleMetamodelPackage,
11349
11555
  stateMachineMetamodelPackage,
11350
11556
  effectBehaviorsMetamodelPackage