@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.
@@ -1,4 +1,4 @@
1
- import { P as Prompt, d as Environment, c as SessionHeapSnapshot, a$ as ManifestContent, ax as RecordObjectOptions, T as ToolWithHandler, G as Granular, C as ConnectOptions, y as CreateEnvironmentData, i as GranularOptions } from './client-BeKRGMoT.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, d as Environment, c as SessionHeapSnapshot, a$ as ManifestContent, ax as RecordObjectOptions, T as ToolWithHandler, G as Granular, C as ConnectOptions, y as CreateEnvironmentData, i as GranularOptions } from './client-BeKRGMoT.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';
@@ -4615,6 +4615,22 @@ var Session = class {
4615
4615
  }
4616
4616
  };
4617
4617
  }
4618
+ stringifyConversationValue(value) {
4619
+ if (typeof value === "string") {
4620
+ return value;
4621
+ }
4622
+ if (typeof value === "boolean") {
4623
+ return value ? "Confirmed" : "Canceled";
4624
+ }
4625
+ if (value === void 0) {
4626
+ return "";
4627
+ }
4628
+ try {
4629
+ return JSON.stringify(value, null, 2);
4630
+ } catch {
4631
+ return String(value);
4632
+ }
4633
+ }
4618
4634
  // --- Public API ---
4619
4635
  get document() {
4620
4636
  return this.client.doc;
@@ -4765,6 +4781,20 @@ var Session = class {
4765
4781
  answer: resolvedAnswer,
4766
4782
  value: resolvedAnswer
4767
4783
  });
4784
+ try {
4785
+ const content = this.stringifyConversationValue(resolvedAnswer);
4786
+ if (content.trim()) {
4787
+ await this.appendConversationMessage({
4788
+ role: "user",
4789
+ content,
4790
+ promptId
4791
+ });
4792
+ }
4793
+ } catch {
4794
+ }
4795
+ }
4796
+ async appendConversationMessage(input) {
4797
+ return this.client.call("conversation.append", input);
4768
4798
  }
4769
4799
  /**
4770
4800
  * Get the current list of available effects.
@@ -4904,9 +4934,24 @@ var Session = class {
4904
4934
  * Get domain documentation for LLMs. Returns types (preferred) or fallback.
4905
4935
  */
4906
4936
  async getDomainDocumentation() {
4907
- const types = await this.getDomainTypes();
4908
- if (types && (types.includes("export declare class") || types.includes("export async function"))) {
4909
- 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;
4910
4955
  }
4911
4956
  const summary = await this.getDomain();
4912
4957
  return this.generateFallbackDocs(summary);
@@ -9716,10 +9761,15 @@ external_exports.union([
9716
9761
  scalarType: external_exports.string().optional()
9717
9762
  }).strict()
9718
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
+ ]);
9719
9771
  external_exports.object({
9720
- operator: external_exports.enum(
9721
- [...VALIDATION_RULE_OPERATORS]
9722
- ),
9772
+ operator: external_exports.enum([...VALIDATION_RULE_OPERATORS]),
9723
9773
  stringValue: external_exports.string().optional(),
9724
9774
  numberValue: external_exports.number().optional(),
9725
9775
  booleanValue: external_exports.boolean().optional(),
@@ -9812,12 +9862,18 @@ function collectMetamodelSummarySelections(packages) {
9812
9862
  const propertyFields = [];
9813
9863
  const methodFields = [];
9814
9864
  for (const metamodelPackage of packages) {
9815
- pushUnique(classFields, metamodelPackage.summary.selections?.classFields || []);
9865
+ pushUnique(
9866
+ classFields,
9867
+ metamodelPackage.summary.selections?.classFields || []
9868
+ );
9816
9869
  pushUnique(
9817
9870
  propertyFields,
9818
9871
  metamodelPackage.summary.selections?.propertyFields || []
9819
9872
  );
9820
- pushUnique(methodFields, metamodelPackage.summary.selections?.methodFields || []);
9873
+ pushUnique(
9874
+ methodFields,
9875
+ metamodelPackage.summary.selections?.methodFields || []
9876
+ );
9821
9877
  }
9822
9878
  return {
9823
9879
  classFields: unique(classFields),
@@ -9905,7 +9961,11 @@ function createMetamodelRegistry(metamodelPackages) {
9905
9961
  return collectMetamodelSummarySelections(packages);
9906
9962
  },
9907
9963
  applyClassSummaryReaders(rawClass, classSummary) {
9908
- return applyMetamodelSummaryReadersToClass(packages, rawClass, classSummary);
9964
+ return applyMetamodelSummaryReadersToClass(
9965
+ packages,
9966
+ rawClass,
9967
+ classSummary
9968
+ );
9909
9969
  },
9910
9970
  applyPropertySummaryReaders(rawProperty, propertySummary) {
9911
9971
  return applyMetamodelSummaryReadersToProperty(
@@ -9915,7 +9975,11 @@ function createMetamodelRegistry(metamodelPackages) {
9915
9975
  );
9916
9976
  },
9917
9977
  applyMethodSummaryReaders(rawMethod, methodSummary) {
9918
- return applyMetamodelSummaryReadersToMethod(packages, rawMethod, methodSummary);
9978
+ return applyMetamodelSummaryReadersToMethod(
9979
+ packages,
9980
+ rawMethod,
9981
+ methodSummary
9982
+ );
9919
9983
  },
9920
9984
  applyClassIR(classIR, classSummary) {
9921
9985
  return applyMetamodelClassIR(packages, classIR, classSummary);
@@ -9963,6 +10027,10 @@ function mergeClassSummaryPatch(target, patch) {
9963
10027
  }
9964
10028
  function mergePropertySummaryPatch(target, patch) {
9965
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
+ }
9966
10034
  if (patch.required !== void 0) target.required = patch.required;
9967
10035
  if (patch.enumRule !== void 0) target.enumRule = patch.enumRule;
9968
10036
  if (patch.filterBy !== void 0) target.filterBy = patch.filterBy;
@@ -9974,9 +10042,11 @@ function mergeMethodSummaryPatch(target, patch) {
9974
10042
  if (patch.effectKey !== void 0) target.effectKey = patch.effectKey;
9975
10043
  if (patch.description !== void 0) target.description = patch.description;
9976
10044
  if (patch.inputSchema !== void 0) target.inputSchema = patch.inputSchema;
9977
- if (patch.outputSchema !== void 0) target.outputSchema = patch.outputSchema;
10045
+ if (patch.outputSchema !== void 0)
10046
+ target.outputSchema = patch.outputSchema;
9978
10047
  if (patch.metamodels !== void 0) target.metamodels = patch.metamodels;
9979
- if (patch.effectBehaviors !== void 0) target.effectBehaviors = patch.effectBehaviors;
10048
+ if (patch.effectBehaviors !== void 0)
10049
+ target.effectBehaviors = patch.effectBehaviors;
9980
10050
  if (patch.static !== void 0) target.static = patch.static;
9981
10051
  }
9982
10052
  function toPascalCase(value) {
@@ -10482,12 +10552,20 @@ function defaultFilterOperators(scalarType) {
10482
10552
  switch ((scalarType || "").toLowerCase()) {
10483
10553
  case "number":
10484
10554
  case "date":
10485
- 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
+ ];
10486
10563
  case "boolean":
10487
- return ["equal_to", "not_null"];
10564
+ return ["equal_to", "true", "false", "not_null"];
10488
10565
  default:
10489
10566
  return [
10490
10567
  "equal_to",
10568
+ "in",
10491
10569
  "contains",
10492
10570
  "not_contains",
10493
10571
  "starts_with",
@@ -10496,16 +10574,26 @@ function defaultFilterOperators(scalarType) {
10496
10574
  ];
10497
10575
  }
10498
10576
  }
10577
+ function supportsDefaultFilterBy(scalarType) {
10578
+ return ["string", "number", "boolean", "date"].includes(
10579
+ String(scalarType || "").toLowerCase()
10580
+ );
10581
+ }
10499
10582
  function normalizeFilterByInput(filterBy, scalarType) {
10500
- 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
+ }
10501
10588
  if (filterBy === true) {
10502
- return { operators: defaultFilterOperators(scalarType) };
10589
+ return { operators: defaultFilterOperators(scalarType), scalarType };
10503
10590
  }
10504
10591
  if (Array.isArray(filterBy)) {
10505
- return { operators: filterBy };
10592
+ return { operators: filterBy, scalarType };
10506
10593
  }
10507
10594
  return {
10508
- operators: filterBy.operators
10595
+ operators: filterBy.operators,
10596
+ scalarType: filterBy.scalarType || scalarType
10509
10597
  };
10510
10598
  }
10511
10599
  function buildFilterByFieldMutations(fieldPath, filterBy, scalarType) {
@@ -10516,7 +10604,7 @@ function buildFilterByFieldMutations(fieldPath, filterBy, scalarType) {
10516
10604
  label: `set filterBy on ${fieldPath}`,
10517
10605
  query: `mutation { at(path: ${JSON.stringify(fieldPath)}) { set_filter_by(operators: ${JSON.stringify(
10518
10606
  normalized.operators
10519
- )}) { operators } } }`
10607
+ )}${normalized.scalarType ? `, scalar_type: ${JSON.stringify(normalized.scalarType)}` : ""}) { operators } } }`
10520
10608
  }
10521
10609
  ];
10522
10610
  }
@@ -10526,7 +10614,7 @@ var filterByMetamodelPackage = defineMetamodelPackage({
10526
10614
  fieldRows: [
10527
10615
  {
10528
10616
  key: "filterBy",
10529
- 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 }`."
10530
10618
  }
10531
10619
  ]
10532
10620
  },
@@ -10790,6 +10878,123 @@ var requiredMetamodelPackage = defineMetamodelPackage({
10790
10878
  }
10791
10879
  });
10792
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
+
10793
10998
  // ../metamodel-state-machine/src/index.ts
10794
10999
  function normalizeStateMachines(values) {
10795
11000
  return (values || []).map((machine) => {
@@ -11370,6 +11575,7 @@ var DEFAULT_METAMODEL_PACKAGES = [
11370
11575
  requiredMetamodelPackage,
11371
11576
  enumMetamodelPackage,
11372
11577
  filterByMetamodelPackage,
11578
+ searchableMetamodelPackage,
11373
11579
  validationRuleMetamodelPackage,
11374
11580
  stateMachineMetamodelPackage,
11375
11581
  effectBehaviorsMetamodelPackage