@granular-software/sdk 0.4.26 → 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.
@@ -1,4 +1,4 @@
1
- import { P as Prompt, e as Environment, c as SessionHeapSnapshot, b3 as ManifestContent, aB as RecordObjectOptions, T as ToolWithHandler, G as Granular, C as ConnectOptions, z as CreateEnvironmentData, j as GranularOptions } from './client-Zoo8YITZ.mjs';
1
+ import { P as Prompt, e as Environment, c as SessionHeapSnapshot, b3 as ManifestContent, aB as RecordObjectOptions, T as ToolWithHandler, G as Granular, C as ConnectOptions, z as CreateEnvironmentData, j as GranularOptions } from './client-CigjaeO8.mjs';
2
2
  import { GeneratedJobCodeIssue, HarnessControllerBudgets } from './agent-harness.mjs';
3
3
  import '@automerge/automerge';
4
4
  import '@automerge/automerge/slim';
@@ -1,4 +1,4 @@
1
- import { P as Prompt, e as Environment, c as SessionHeapSnapshot, b3 as ManifestContent, aB as RecordObjectOptions, T as ToolWithHandler, G as Granular, C as ConnectOptions, z as CreateEnvironmentData, j as GranularOptions } from './client-Zoo8YITZ.js';
1
+ import { P as Prompt, e as Environment, c as SessionHeapSnapshot, b3 as ManifestContent, aB as RecordObjectOptions, T as ToolWithHandler, G as Granular, C as ConnectOptions, z as CreateEnvironmentData, j as GranularOptions } from './client-CigjaeO8.js';
2
2
  import { GeneratedJobCodeIssue, HarnessControllerBudgets } from './agent-harness.js';
3
3
  import '@automerge/automerge';
4
4
  import '@automerge/automerge/slim';
@@ -4934,9 +4934,24 @@ var Session = class {
4934
4934
  * Get domain documentation for LLMs. Returns types (preferred) or fallback.
4935
4935
  */
4936
4936
  async getDomainDocumentation() {
4937
- const types = await this.getDomainTypes();
4938
- if (types && (types.includes("export declare class") || types.includes("export async function"))) {
4939
- return types;
4937
+ const [types, docs] = await Promise.all([
4938
+ this.getDomainTypes(),
4939
+ this.getDomainDocs()
4940
+ ]);
4941
+ const normalizedTypes = types.trim();
4942
+ const normalizedDocs = docs.trim();
4943
+ if (normalizedTypes && (normalizedTypes.includes("export declare class") || normalizedTypes.includes("export async function"))) {
4944
+ if (!normalizedDocs) {
4945
+ return normalizedTypes;
4946
+ }
4947
+ return [
4948
+ normalizedTypes,
4949
+ "Generated usage notes from ./sandbox-tools docs:",
4950
+ normalizedDocs
4951
+ ].join("\n\n");
4952
+ }
4953
+ if (normalizedDocs) {
4954
+ return normalizedDocs;
4940
4955
  }
4941
4956
  const summary = await this.getDomain();
4942
4957
  return this.generateFallbackDocs(summary);
@@ -9746,10 +9761,15 @@ external_exports.union([
9746
9761
  scalarType: external_exports.string().optional()
9747
9762
  }).strict()
9748
9763
  ]);
9764
+ external_exports.union([
9765
+ external_exports.boolean(),
9766
+ external_exports.object({
9767
+ enabled: external_exports.boolean().optional(),
9768
+ phonetic: external_exports.boolean().optional()
9769
+ }).strict()
9770
+ ]);
9749
9771
  external_exports.object({
9750
- operator: external_exports.enum(
9751
- [...VALIDATION_RULE_OPERATORS]
9752
- ),
9772
+ operator: external_exports.enum([...VALIDATION_RULE_OPERATORS]),
9753
9773
  stringValue: external_exports.string().optional(),
9754
9774
  numberValue: external_exports.number().optional(),
9755
9775
  booleanValue: external_exports.boolean().optional(),
@@ -9842,12 +9862,18 @@ function collectMetamodelSummarySelections(packages) {
9842
9862
  const propertyFields = [];
9843
9863
  const methodFields = [];
9844
9864
  for (const metamodelPackage of packages) {
9845
- pushUnique(classFields, metamodelPackage.summary.selections?.classFields || []);
9865
+ pushUnique(
9866
+ classFields,
9867
+ metamodelPackage.summary.selections?.classFields || []
9868
+ );
9846
9869
  pushUnique(
9847
9870
  propertyFields,
9848
9871
  metamodelPackage.summary.selections?.propertyFields || []
9849
9872
  );
9850
- pushUnique(methodFields, metamodelPackage.summary.selections?.methodFields || []);
9873
+ pushUnique(
9874
+ methodFields,
9875
+ metamodelPackage.summary.selections?.methodFields || []
9876
+ );
9851
9877
  }
9852
9878
  return {
9853
9879
  classFields: unique(classFields),
@@ -9935,7 +9961,11 @@ function createMetamodelRegistry(metamodelPackages) {
9935
9961
  return collectMetamodelSummarySelections(packages);
9936
9962
  },
9937
9963
  applyClassSummaryReaders(rawClass, classSummary) {
9938
- return applyMetamodelSummaryReadersToClass(packages, rawClass, classSummary);
9964
+ return applyMetamodelSummaryReadersToClass(
9965
+ packages,
9966
+ rawClass,
9967
+ classSummary
9968
+ );
9939
9969
  },
9940
9970
  applyPropertySummaryReaders(rawProperty, propertySummary) {
9941
9971
  return applyMetamodelSummaryReadersToProperty(
@@ -9945,7 +9975,11 @@ function createMetamodelRegistry(metamodelPackages) {
9945
9975
  );
9946
9976
  },
9947
9977
  applyMethodSummaryReaders(rawMethod, methodSummary) {
9948
- return applyMetamodelSummaryReadersToMethod(packages, rawMethod, methodSummary);
9978
+ return applyMetamodelSummaryReadersToMethod(
9979
+ packages,
9980
+ rawMethod,
9981
+ methodSummary
9982
+ );
9949
9983
  },
9950
9984
  applyClassIR(classIR, classSummary) {
9951
9985
  return applyMetamodelClassIR(packages, classIR, classSummary);
@@ -9993,6 +10027,10 @@ function mergeClassSummaryPatch(target, patch) {
9993
10027
  }
9994
10028
  function mergePropertySummaryPatch(target, patch) {
9995
10029
  pushUnique(target.notes, patch.notes || []);
10030
+ if (patch.searchable !== void 0) target.searchable = patch.searchable;
10031
+ if (patch.searchablePhonetic !== void 0) {
10032
+ target.searchablePhonetic = patch.searchablePhonetic;
10033
+ }
9996
10034
  if (patch.required !== void 0) target.required = patch.required;
9997
10035
  if (patch.enumRule !== void 0) target.enumRule = patch.enumRule;
9998
10036
  if (patch.filterBy !== void 0) target.filterBy = patch.filterBy;
@@ -10004,9 +10042,11 @@ function mergeMethodSummaryPatch(target, patch) {
10004
10042
  if (patch.effectKey !== void 0) target.effectKey = patch.effectKey;
10005
10043
  if (patch.description !== void 0) target.description = patch.description;
10006
10044
  if (patch.inputSchema !== void 0) target.inputSchema = patch.inputSchema;
10007
- if (patch.outputSchema !== void 0) target.outputSchema = patch.outputSchema;
10045
+ if (patch.outputSchema !== void 0)
10046
+ target.outputSchema = patch.outputSchema;
10008
10047
  if (patch.metamodels !== void 0) target.metamodels = patch.metamodels;
10009
- if (patch.effectBehaviors !== void 0) target.effectBehaviors = patch.effectBehaviors;
10048
+ if (patch.effectBehaviors !== void 0)
10049
+ target.effectBehaviors = patch.effectBehaviors;
10010
10050
  if (patch.static !== void 0) target.static = patch.static;
10011
10051
  }
10012
10052
  function toPascalCase(value) {
@@ -10512,12 +10552,20 @@ function defaultFilterOperators(scalarType) {
10512
10552
  switch ((scalarType || "").toLowerCase()) {
10513
10553
  case "number":
10514
10554
  case "date":
10515
- return ["equal_to", "greater_than", "less_than", "not_null"];
10555
+ return [
10556
+ "equal_to",
10557
+ "greater_than",
10558
+ "greater_than_or_equal_to",
10559
+ "less_than",
10560
+ "less_than_or_equal_to",
10561
+ "not_null"
10562
+ ];
10516
10563
  case "boolean":
10517
- return ["equal_to", "not_null"];
10564
+ return ["equal_to", "true", "false", "not_null"];
10518
10565
  default:
10519
10566
  return [
10520
10567
  "equal_to",
10568
+ "in",
10521
10569
  "contains",
10522
10570
  "not_contains",
10523
10571
  "starts_with",
@@ -10526,16 +10574,26 @@ function defaultFilterOperators(scalarType) {
10526
10574
  ];
10527
10575
  }
10528
10576
  }
10577
+ function supportsDefaultFilterBy(scalarType) {
10578
+ return ["string", "number", "boolean", "date"].includes(
10579
+ String(scalarType || "").toLowerCase()
10580
+ );
10581
+ }
10529
10582
  function normalizeFilterByInput(filterBy, scalarType) {
10530
- if (!filterBy) return null;
10583
+ if (filterBy === false) return null;
10584
+ if (filterBy === void 0) {
10585
+ if (!supportsDefaultFilterBy(scalarType)) return null;
10586
+ return { operators: defaultFilterOperators(scalarType), scalarType };
10587
+ }
10531
10588
  if (filterBy === true) {
10532
- return { operators: defaultFilterOperators(scalarType) };
10589
+ return { operators: defaultFilterOperators(scalarType), scalarType };
10533
10590
  }
10534
10591
  if (Array.isArray(filterBy)) {
10535
- return { operators: filterBy };
10592
+ return { operators: filterBy, scalarType };
10536
10593
  }
10537
10594
  return {
10538
- operators: filterBy.operators
10595
+ operators: filterBy.operators,
10596
+ scalarType: filterBy.scalarType || scalarType
10539
10597
  };
10540
10598
  }
10541
10599
  function buildFilterByFieldMutations(fieldPath, filterBy, scalarType) {
@@ -10546,7 +10604,7 @@ function buildFilterByFieldMutations(fieldPath, filterBy, scalarType) {
10546
10604
  label: `set filterBy on ${fieldPath}`,
10547
10605
  query: `mutation { at(path: ${JSON.stringify(fieldPath)}) { set_filter_by(operators: ${JSON.stringify(
10548
10606
  normalized.operators
10549
- )}) { operators } } }`
10607
+ )}${normalized.scalarType ? `, scalar_type: ${JSON.stringify(normalized.scalarType)}` : ""}) { operators } } }`
10550
10608
  }
10551
10609
  ];
10552
10610
  }
@@ -10556,7 +10614,7 @@ var filterByMetamodelPackage = defineMetamodelPackage({
10556
10614
  fieldRows: [
10557
10615
  {
10558
10616
  key: "filterBy",
10559
- description: "Exposes filter operators for generated query surfaces. Accepts `true`, an operator array, or `{ operators, scalarType }`."
10617
+ 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 }`."
10560
10618
  }
10561
10619
  ]
10562
10620
  },
@@ -10820,6 +10878,123 @@ var requiredMetamodelPackage = defineMetamodelPackage({
10820
10878
  }
10821
10879
  });
10822
10880
 
10881
+ // ../metamodel-searchable/src/index.ts
10882
+ function supportsDefaultSearchable(scalarType) {
10883
+ return String(scalarType || "").toLowerCase() === "string";
10884
+ }
10885
+ function normalizeSearchableInput(searchable, scalarType) {
10886
+ if (!supportsDefaultSearchable(scalarType)) return null;
10887
+ if (typeof searchable === "boolean" || searchable === void 0) {
10888
+ return {
10889
+ enabled: searchable !== false,
10890
+ phonetic: false
10891
+ };
10892
+ }
10893
+ const enabled = searchable.enabled !== false;
10894
+ return {
10895
+ enabled,
10896
+ phonetic: enabled && searchable.phonetic === true
10897
+ };
10898
+ }
10899
+ function buildSearchableFieldMutations(fieldPath, searchable, scalarType) {
10900
+ const normalized = normalizeSearchableInput(searchable, scalarType);
10901
+ if (normalized === null) return [];
10902
+ return [
10903
+ {
10904
+ label: `set searchable on ${fieldPath}`,
10905
+ query: `mutation { at(path: ${JSON.stringify(fieldPath)}) { set_searchable(enabled: ${normalized.enabled}, phonetic: ${normalized.phonetic}) { enabled phonetic } } }`
10906
+ }
10907
+ ];
10908
+ }
10909
+ var searchableMetamodelPackage = defineMetamodelPackage({
10910
+ id: "searchable",
10911
+ docs: {
10912
+ fieldRows: [
10913
+ {
10914
+ key: "searchable",
10915
+ 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."
10916
+ }
10917
+ ]
10918
+ },
10919
+ graphql: {
10920
+ typeDefs: [
10921
+ `
10922
+ type SearchableMetamodel {
10923
+ model: Model!
10924
+ enabled: Boolean!
10925
+ phonetic: Boolean!
10926
+ }
10927
+
10928
+ extend type Model {
10929
+ searchable: SearchableMetamodel
10930
+ }
10931
+
10932
+ extend type ModelMutation {
10933
+ set_searchable(enabled: Boolean!, phonetic: Boolean): SearchableMetamodel
10934
+ }
10935
+ `
10936
+ ],
10937
+ createResolvers({ run }) {
10938
+ return {
10939
+ SearchableMetamodel: {
10940
+ model: (value) => value.model,
10941
+ enabled: (value) => value.enabled !== false,
10942
+ phonetic: (value) => value.phonetic === true
10943
+ },
10944
+ Model: {
10945
+ searchable: async (ant) => await run(ant.searchable())
10946
+ },
10947
+ ModelMutation: {
10948
+ set_searchable: async (ant, { enabled, phonetic }) => {
10949
+ return {
10950
+ model: await run(ant.set_searchable(enabled, phonetic === true)),
10951
+ enabled,
10952
+ phonetic: phonetic === true
10953
+ };
10954
+ }
10955
+ }
10956
+ };
10957
+ }
10958
+ },
10959
+ manifest: {
10960
+ buildFieldMutations(fieldPath, spec) {
10961
+ return buildSearchableFieldMutations(
10962
+ fieldPath,
10963
+ spec.searchable,
10964
+ spec.type
10965
+ );
10966
+ }
10967
+ },
10968
+ summary: {
10969
+ selections: {
10970
+ propertyFields: [`searchable { enabled phonetic }`]
10971
+ },
10972
+ readPropertySummary(rawProperty) {
10973
+ if (typeof rawProperty.searchable?.enabled !== "boolean") {
10974
+ return {};
10975
+ }
10976
+ return {
10977
+ searchable: rawProperty.searchable.enabled,
10978
+ searchablePhonetic: rawProperty.searchable.phonetic === true
10979
+ };
10980
+ }
10981
+ },
10982
+ domain: {
10983
+ applyToPropertyIR(propertyIR, propertySummary) {
10984
+ if (String(propertySummary.type || "").toLowerCase() !== "string" || propertySummary.searchable === false) {
10985
+ return propertyIR;
10986
+ }
10987
+ return {
10988
+ ...propertyIR,
10989
+ docs: [
10990
+ ...propertyIR.docs,
10991
+ propertySummary.searchablePhonetic ? "Searchable via `search` using FalkorDB full-text query syntax with phonetic matching enabled." : "Searchable via `search` using FalkorDB full-text query syntax."
10992
+ ]
10993
+ };
10994
+ }
10995
+ }
10996
+ });
10997
+
10823
10998
  // ../metamodel-state-machine/src/index.ts
10824
10999
  function normalizeStateMachines(values) {
10825
11000
  return (values || []).map((machine) => {
@@ -11400,6 +11575,7 @@ var DEFAULT_METAMODEL_PACKAGES = [
11400
11575
  requiredMetamodelPackage,
11401
11576
  enumMetamodelPackage,
11402
11577
  filterByMetamodelPackage,
11578
+ searchableMetamodelPackage,
11403
11579
  validationRuleMetamodelPackage,
11404
11580
  stateMachineMetamodelPackage,
11405
11581
  effectBehaviorsMetamodelPackage