@coasys/ad4m 0.11.2-dev.5 → 0.12.0-dev-whisper-lang

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/lib/index.js CHANGED
@@ -5787,6 +5787,7 @@ class PerspectiveProxy {
5787
5787
  const collName = result.Coll;
5788
5788
  let predicate = null;
5789
5789
  let instanceFilter = undefined;
5790
+ let condition = undefined;
5790
5791
  // Try to extract predicate from collection_adder first
5791
5792
  const adderResults = await this.infer(`subject_class("${className}", C), collection_adder(C, "${collName}", Adder)`);
5792
5793
  if (adderResults && adderResults.length > 0) {
@@ -5796,6 +5797,8 @@ class PerspectiveProxy {
5796
5797
  predicate = predicateMatch[1] || predicateMatch[2];
5797
5798
  }
5798
5799
  }
5800
+ // Note: condition is not stored in SDNA, it's read from class metadata
5801
+ // It will be populated by augmentMetadataWithCollectionOptions() when needed
5799
5802
  // Parse collection_getter from SDNA to extract predicate and instanceFilter
5800
5803
  // Format 1 (findall): collection_getter(c, Base, "comments", List) :- findall(C, triple(Base, "todo://comment", C), List).
5801
5804
  // Format 2 (setof): collection_getter(c, Base, "messages", List) :- setof(Target, (triple(Base, "flux://entry_type", Target), ...), List).
@@ -5831,7 +5834,7 @@ class PerspectiveProxy {
5831
5834
  }
5832
5835
  }
5833
5836
  if (predicate) {
5834
- collections.set(collName, { predicate, instanceFilter });
5837
+ collections.set(collName, { predicate, instanceFilter, condition });
5835
5838
  }
5836
5839
  }
5837
5840
  }
@@ -5907,6 +5910,7 @@ class PerspectiveProxy {
5907
5910
  /**
5908
5911
  * Gets collection values using SurrealDB when Prolog fails.
5909
5912
  * This is used as a fallback in SdnaOnly mode where link data isn't in Prolog.
5913
+ * Note: This is used by Subject.ts (legacy pattern). Ad4mModel.ts uses getModelMetadata() instead.
5910
5914
  */
5911
5915
  async getCollectionValuesViaSurreal(baseExpression, className, collectionName) {
5912
5916
  const metadata = await this.getSubjectClassMetadataFromSDNA(className);
@@ -5925,6 +5929,31 @@ class PerspectiveProxy {
5925
5929
  return [];
5926
5930
  }
5927
5931
  let values = result.map(r => r.value).filter(v => v !== "" && v !== '');
5932
+ // Apply condition filtering if present
5933
+ if (collMeta.condition && values.length > 0) {
5934
+ try {
5935
+ const filteredValues = [];
5936
+ for (const value of values) {
5937
+ let condition = collMeta.condition
5938
+ .replace(/\$perspective/g, `'${this.uuid}'`)
5939
+ .replace(/\$base/g, `'${baseExpression}'`)
5940
+ .replace(/Target/g, `'${value.replace(/'/g, "\\'")}'`);
5941
+ // If condition starts with WHERE, wrap in array length check
5942
+ if (condition.trim().startsWith('WHERE')) {
5943
+ condition = `array::len(SELECT * FROM link ${condition}) > 0`;
5944
+ }
5945
+ const filterResult = await this.querySurrealDB(`RETURN ${condition}`);
5946
+ const isTrue = filterResult === true || (Array.isArray(filterResult) && filterResult.length > 0 && filterResult[0] === true);
5947
+ if (isTrue) {
5948
+ filteredValues.push(value);
5949
+ }
5950
+ }
5951
+ values = filteredValues;
5952
+ }
5953
+ catch (error) {
5954
+ console.warn(`Failed to apply condition filter for ${collectionName}:`, error);
5955
+ }
5956
+ }
5928
5957
  // Apply instance filter if present - batch-check all values at once
5929
5958
  if (collMeta.instanceFilter) {
5930
5959
  try {
@@ -5966,11 +5995,13 @@ class PerspectiveProxy {
5966
5995
  if (triple.target) {
5967
5996
  // Flag: must match both predicate AND exact target value
5968
5997
  const escapedTarget = escapeSurrealString(triple.target);
5969
- checkQuery = `SELECT in.uri AS uri FROM link WHERE in.uri IN [${escapedExpressions}] AND predicate = '${escapedPredicate}' AND out.uri = '${escapedTarget}' GROUP BY in.uri`;
5998
+ // Note: Removed GROUP BY because it was causing SurrealDB to only return one result
5999
+ checkQuery = `SELECT in.uri AS uri FROM link WHERE in.uri IN [${escapedExpressions}] AND predicate = '${escapedPredicate}' AND out.uri = '${escapedTarget}'`;
5970
6000
  }
5971
6001
  else {
5972
6002
  // Property: just check predicate exists
5973
- checkQuery = `SELECT in.uri AS uri FROM link WHERE in.uri IN [${escapedExpressions}] AND predicate = '${escapedPredicate}' GROUP BY in.uri`;
6003
+ // Note: Removed GROUP BY because it was causing SurrealDB to only return one result
6004
+ checkQuery = `SELECT in.uri AS uri FROM link WHERE in.uri IN [${escapedExpressions}] AND predicate = '${escapedPredicate}'`;
5974
6005
  }
5975
6006
  const result = await this.querySurrealDB(checkQuery);
5976
6007
  validExpressionSets.push(new Set(result.map(r => r.uri)));
@@ -15814,16 +15845,17 @@ class AIClient {
15814
15845
  const decompressed = JSON.parse(pako.inflate(compressed, { to: 'string' }));
15815
15846
  return decompressed;
15816
15847
  }
15817
- async openTranscriptionStream(modelId, streamCallback, params) {
15848
+ async openTranscriptionStream(modelId, streamCallback, params, language) {
15818
15849
  const { aiOpenTranscriptionStream } = unwrapApolloResult(await __classPrivateFieldGet$3(this, _AIClient_apolloClient, "f").mutate({
15819
15850
  mutation: gql `
15820
- mutation AiOpenTranscriptionStream($modelId: String!, $params: VoiceActivityParamsInput) {
15821
- aiOpenTranscriptionStream(modelId: $modelId, params: $params)
15851
+ mutation AiOpenTranscriptionStream($modelId: String!, $params: VoiceActivityParamsInput, $language: String) {
15852
+ aiOpenTranscriptionStream(modelId: $modelId, params: $params, language: $language)
15822
15853
  }
15823
15854
  `,
15824
15855
  variables: {
15825
15856
  modelId,
15826
- params
15857
+ params,
15858
+ language
15827
15859
  }
15828
15860
  }));
15829
15861
  const subscription = __classPrivateFieldGet$3(this, _AIClient_apolloClient, "f").subscribe({
@@ -16457,14 +16489,14 @@ function hasLink(predicate) {
16457
16489
  * static async findByName(perspective: PerspectiveProxy): Promise<Recipe[]> { return [] }
16458
16490
  *
16459
16491
  * // Get highly rated recipes using a custom condition
16460
- * @InstanceQuery({ condition: "triple(Instance, 'recipe://rating', Rating), Rating > 4" })
16492
+ * @InstanceQuery({ prologCondition: "triple(Instance, 'recipe://rating', Rating), Rating > 4" })
16461
16493
  * static async topRated(perspective: PerspectiveProxy): Promise<Recipe[]> { return [] }
16462
16494
  * }
16463
16495
  * ```
16464
16496
  *
16465
16497
  * @param {Object} [options] - Query options
16466
16498
  * @param {object} [options.where] - Object with property-value pairs to match
16467
- * @param {string} [options.condition] - Custom Prolog condition for more complex queries
16499
+ * @param {string} [options.prologCondition] - Custom Prolog condition for more complex queries
16468
16500
  */
16469
16501
  function InstanceQuery(options) {
16470
16502
  return function (target, key, descriptor) {
@@ -16483,8 +16515,8 @@ function InstanceQuery(options) {
16483
16515
  query += `, property_getter(C, Instance, "${prop}", "${value}")`;
16484
16516
  }
16485
16517
  }
16486
- if (options && options.condition) {
16487
- query += ', ' + options.condition;
16518
+ if (options && options.prologCondition) {
16519
+ query += ', ' + options.prologCondition;
16488
16520
  }
16489
16521
  // Try Prolog first
16490
16522
  try {
@@ -16604,8 +16636,8 @@ function InstanceQuery(options) {
16604
16636
  * @param {boolean} [opts.required] - Whether the property must have a value
16605
16637
  * @param {boolean} [opts.writable=true] - Whether the property can be modified
16606
16638
  * @param {string} [opts.resolveLanguage] - Language to use for value resolution (e.g. "literal")
16607
- * @param {string} [opts.getter] - Custom Prolog code for getting the property value
16608
- * @param {string} [opts.setter] - Custom Prolog code for setting the property value
16639
+ * @param {string} [opts.prologGetter] - Custom Prolog code for getting the property value
16640
+ * @param {string} [opts.prologSetter] - Custom Prolog code for setting the property value
16609
16641
  * @param {boolean} [opts.local] - Whether the property should only be stored locally
16610
16642
  */
16611
16643
  function Optional(opts) {
@@ -16616,8 +16648,8 @@ function Optional(opts) {
16616
16648
  if (opts.required && !opts.initial) {
16617
16649
  throw new Error("SubjectProperty requires an 'initial' option if 'required' is true");
16618
16650
  }
16619
- if (!opts.through && !opts.getter) {
16620
- throw new Error("SubjectProperty requires either 'through' or 'getter' option");
16651
+ if (!opts.through && !opts.prologGetter) {
16652
+ throw new Error("SubjectProperty requires either 'through' or 'prologGetter' option");
16621
16653
  }
16622
16654
  target["__properties"] = target["__properties"] || {};
16623
16655
  target["__properties"][key] = target["__properties"][key] || {};
@@ -16743,13 +16775,20 @@ function Flag(opts) {
16743
16775
  * })
16744
16776
  * comments: string[] = [];
16745
16777
  *
16746
- * // Collection with custom filter condition
16778
+ * // Collection with custom Prolog filter condition
16747
16779
  * @Collection({
16748
16780
  * through: "recipe://step",
16749
- * where: { condition: `triple(Target, "step://order", Order), Order < 3` }
16781
+ * where: { prologCondition: `triple(Target, "step://order", Order), Order < 3` }
16750
16782
  * })
16751
16783
  * firstSteps: string[] = [];
16752
16784
  *
16785
+ * // Collection with custom SurrealDB filter condition
16786
+ * @Collection({
16787
+ * through: "recipe://entries",
16788
+ * where: { condition: `WHERE in.uri = Target AND predicate = 'recipe://has_ingredient' AND out.uri = 'recipe://test')`
16789
+ * })
16790
+ * ingredients: string[] = [];
16791
+ *
16753
16792
  * // Local-only collection not shared with network
16754
16793
  * @Collection({
16755
16794
  * through: "recipe://note",
@@ -16769,7 +16808,7 @@ function Flag(opts) {
16769
16808
  * @param {string} opts.through - The predicate URI for collection links
16770
16809
  * @param {WhereOptions} [opts.where] - Filter conditions for collection values
16771
16810
  * @param {any} [opts.where.isInstance] - Model class to filter instances by
16772
- * @param {string} [opts.where.condition] - Custom Prolog condition for filtering
16811
+ * @param {string} [opts.where.prologCondition] - Custom Prolog condition for filtering
16773
16812
  * @param {boolean} [opts.local] - Whether collection links are stored locally only
16774
16813
  */
16775
16814
  function Collection(opts) {
@@ -16869,13 +16908,13 @@ function ModelOptions(opts) {
16869
16908
  let properties = obj.__properties || {};
16870
16909
  for (let property in properties) {
16871
16910
  let propertyCode = `property(${uuid}, "${property}").\n`;
16872
- let { through, initial, required, resolveLanguage, writable, flag, getter, setter, local } = properties[property];
16911
+ let { through, initial, required, resolveLanguage, writable, flag, prologGetter, prologSetter, local } = properties[property];
16873
16912
  if (resolveLanguage) {
16874
16913
  propertyCode += `property_resolve(${uuid}, "${property}").\n`;
16875
16914
  propertyCode += `property_resolve_language(${uuid}, "${property}", "${resolveLanguage}").\n`;
16876
16915
  }
16877
- if (getter) {
16878
- propertyCode += `property_getter(${uuid}, Base, "${property}", Value) :- ${getter}.\n`;
16916
+ if (prologGetter) {
16917
+ propertyCode += `property_getter(${uuid}, Base, "${property}", Value) :- ${prologGetter}.\n`;
16879
16918
  }
16880
16919
  else if (through) {
16881
16920
  propertyCode += `property_getter(${uuid}, Base, "${property}", Value) :- triple(Base, "${through}", Value).\n`;
@@ -16888,8 +16927,8 @@ function ModelOptions(opts) {
16888
16927
  }
16889
16928
  }
16890
16929
  }
16891
- if (setter) {
16892
- propertyCode += `property_setter(${uuid}, "${property}", Actions) :- ${setter}.\n`;
16930
+ if (prologSetter) {
16931
+ propertyCode += `property_setter(${uuid}, "${property}", Actions) :- ${prologSetter}.\n`;
16893
16932
  }
16894
16933
  else if (writable && through) {
16895
16934
  let setter = obj[propertyNameToSetterName(property)];
@@ -16927,8 +16966,8 @@ function ModelOptions(opts) {
16927
16966
  let { through, where, local } = collections[collection];
16928
16967
  if (through) {
16929
16968
  if (where) {
16930
- if (!where.isInstance && !where.condition) {
16931
- throw "'where' needs one of 'isInstance' or 'condition'";
16969
+ if (!where.isInstance && !where.prologCondition && !where.condition) {
16970
+ throw "'where' needs one of 'isInstance', 'prologCondition', or 'condition'";
16932
16971
  }
16933
16972
  let conditions = [];
16934
16973
  if (where.isInstance) {
@@ -16941,11 +16980,19 @@ function ModelOptions(opts) {
16941
16980
  }
16942
16981
  conditions.push(`instance(OtherClass, Target), subject_class("${otherClass}", OtherClass)`);
16943
16982
  }
16944
- if (where.condition) {
16945
- conditions.push(where.condition);
16983
+ if (where.prologCondition) {
16984
+ conditions.push(where.prologCondition);
16985
+ }
16986
+ // If there are Prolog conditions (isInstance or prologCondition), use setof with conditions
16987
+ // If only condition is present, use simple findall (SurrealDB will filter later)
16988
+ if (conditions.length > 0) {
16989
+ const conditionString = conditions.join(", ");
16990
+ collectionCode += `collection_getter(${uuid}, Base, "${collection}", List) :- setof(Target, (triple(Base, "${through}", Target), ${conditionString}), List).\n`;
16991
+ }
16992
+ else {
16993
+ // Only SurrealDB condition present (no Prolog filtering)
16994
+ collectionCode += `collection_getter(${uuid}, Base, "${collection}", List) :- findall(C, triple(Base, "${through}", C), List).\n`;
16946
16995
  }
16947
- const conditionString = conditions.join(", ");
16948
- collectionCode += `collection_getter(${uuid}, Base, "${collection}", List) :- setof(Target, (triple(Base, "${through}", Target), ${conditionString}), List).\n`;
16949
16996
  }
16950
16997
  else {
16951
16998
  collectionCode += `collection_getter(${uuid}, Base, "${collection}", List) :- findall(C, triple(Base, "${through}", C), List).\n`;
@@ -17047,8 +17094,8 @@ function ModelOptions(opts) {
17047
17094
  * @param {string} opts.through - The predicate URI for the property
17048
17095
  * @param {string} [opts.initial] - Initial value (defaults to "literal://string:uninitialized")
17049
17096
  * @param {string} [opts.resolveLanguage] - Language to use for value resolution (e.g. "literal")
17050
- * @param {string} [opts.getter] - Custom Prolog code for getting the property value
17051
- * @param {string} [opts.setter] - Custom Prolog code for setting the property value
17097
+ * @param {string} [opts.prologGetter] - Custom Prolog code for getting the property value
17098
+ * @param {string} [opts.prologSetter] - Custom Prolog code for setting the property value
17052
17099
  * @param {boolean} [opts.local] - Whether the property should only be stored locally
17053
17100
  */
17054
17101
  function Property(opts) {
@@ -17111,7 +17158,7 @@ function Property(opts) {
17111
17158
  * @param {string} opts.through - The predicate URI for the property
17112
17159
  * @param {string} [opts.initial] - Initial value (if property should have one)
17113
17160
  * @param {string} [opts.resolveLanguage] - Language to use for value resolution (e.g. "literal")
17114
- * @param {string} [opts.getter] - Custom Prolog code for getting the property value
17161
+ * @param {string} [opts.prologGetter] - Custom Prolog code for getting the property value
17115
17162
  * @param {boolean} [opts.local] - Whether the property should only be stored locally
17116
17163
  */
17117
17164
  function ReadOnly(opts) {
@@ -17432,7 +17479,7 @@ type Mutation {
17432
17479
  aiCloseTranscriptionStream(streamId: String!): String!
17433
17480
  aiEmbed(modelId: String!, text: String!): String!
17434
17481
  aiFeedTranscriptionStream(audio: [Float!]!, streamIds: [String!]!): String!
17435
- aiOpenTranscriptionStream(modelId: String!, params: VoiceActivityParamsInput): String!
17482
+ aiOpenTranscriptionStream(language: String, modelId: String!, params: VoiceActivityParamsInput): String!
17436
17483
  aiPrompt(prompt: String!, taskId: String!): String!
17437
17484
  aiRemoveModel(modelId: String!): Boolean!
17438
17485
  aiRemoveTask(taskId: String!): AITask!
@@ -18918,9 +18965,9 @@ class Ad4mModel {
18918
18965
  writable: options.writable || false,
18919
18966
  ...(options.initial !== undefined && { initial: options.initial }),
18920
18967
  ...(options.resolveLanguage !== undefined && { resolveLanguage: options.resolveLanguage }),
18968
+ ...(options.prologGetter !== undefined && { prologGetter: options.prologGetter }),
18921
18969
  ...(options.getter !== undefined && { getter: options.getter }),
18922
- ...(options.surrealGetter !== undefined && { surrealGetter: options.surrealGetter }),
18923
- ...(options.setter !== undefined && { setter: options.setter }),
18970
+ ...(options.prologSetter !== undefined && { prologSetter: options.prologSetter }),
18924
18971
  ...(options.local !== undefined && { local: options.local }),
18925
18972
  ...(options.transform !== undefined && { transform: options.transform }),
18926
18973
  ...(options.flag !== undefined && { flag: options.flag })
@@ -18936,7 +18983,7 @@ class Ad4mModel {
18936
18983
  predicate: options.through || "",
18937
18984
  ...(options.where !== undefined && { where: options.where }),
18938
18985
  ...(options.local !== undefined && { local: options.local }),
18939
- ...(options.surrealGetter !== undefined && { surrealGetter: options.surrealGetter })
18986
+ ...(options.getter !== undefined && { getter: options.getter })
18940
18987
  };
18941
18988
  }
18942
18989
  // Fallback: If both structures are empty but a JSON schema is attached, derive from it
@@ -19047,9 +19094,9 @@ class Ad4mModel {
19047
19094
  if (metadata.writable === false) {
19048
19095
  throw new Error(`Property "${key}" is read-only and cannot be written`);
19049
19096
  }
19050
- if (metadata.setter) {
19051
- // Custom setter - throw error for now (Phase 2)
19052
- throw new Error(`Custom setter for property "${key}" not yet supported without Prolog. ` +
19097
+ if (metadata.prologSetter) {
19098
+ // Custom Prolog setter - throw error for now (Phase 2)
19099
+ throw new Error(`Custom Prolog setter for property "${key}" not yet supported without Prolog. ` +
19053
19100
  `Use standard @Property decorator or enable Prolog for custom setters.`);
19054
19101
  }
19055
19102
  if (!metadata.through) {
@@ -19179,10 +19226,10 @@ class Ad4mModel {
19179
19226
  let maxTimestamp = null;
19180
19227
  let latestAuthor = null;
19181
19228
  let originalAuthor = null;
19182
- // Process properties (skip those with surrealGetter)
19229
+ // Process properties (skip those with custom getter)
19183
19230
  for (const [propName, propMeta] of Object.entries(metadata.properties)) {
19184
- if (propMeta.surrealGetter)
19185
- continue; // Handle via surrealGetter evaluation
19231
+ if (propMeta.getter)
19232
+ continue; // Handle via custom getter evaluation
19186
19233
  const matching = links.filter((l) => l.predicate === propMeta.predicate);
19187
19234
  if (matching.length > 0) {
19188
19235
  // "Latest wins" semantics: select the last element since links are ordered ASC.
@@ -19234,14 +19281,44 @@ class Ad4mModel {
19234
19281
  this[propName] = value;
19235
19282
  }
19236
19283
  }
19237
- // Process collections (skip those with surrealGetter)
19284
+ // Process collections (skip those with custom getter)
19238
19285
  for (const [collName, collMeta] of Object.entries(metadata.collections)) {
19239
- if (collMeta.surrealGetter)
19240
- continue; // Handle via surrealGetter evaluation
19286
+ if (collMeta.getter)
19287
+ continue; // Handle via custom getter evaluation
19241
19288
  const matching = links.filter((l) => l.predicate === collMeta.predicate);
19242
19289
  // Collections preserve chronological order: links are sorted ASC by timestamp,
19243
19290
  // so the collection reflects the order in which items were added (oldest to newest).
19244
19291
  let values = matching.map((l) => l.target);
19292
+ // Apply where.condition filtering if present
19293
+ if (collMeta.where?.condition && values.length > 0) {
19294
+ try {
19295
+ // Filter values by evaluating condition for each value
19296
+ const filteredValues = [];
19297
+ for (const value of values) {
19298
+ let condition = collMeta.where.condition
19299
+ .replace(/\$perspective/g, `'${__classPrivateFieldGet(this, _Ad4mModel_perspective, "f").uuid}'`)
19300
+ .replace(/\$base/g, `'${__classPrivateFieldGet(this, _Ad4mModel_baseExpression, "f")}'`)
19301
+ .replace(/Target/g, `'${value.replace(/'/g, "\\'")}'`);
19302
+ // If condition starts with WHERE, wrap it in array length check pattern
19303
+ // Using array::len() to properly count matching links
19304
+ if (condition.trim().startsWith('WHERE')) {
19305
+ condition = `array::len(SELECT * FROM link ${condition}) > 0`;
19306
+ }
19307
+ const filterQuery = `RETURN ${condition}`;
19308
+ const result = await __classPrivateFieldGet(this, _Ad4mModel_perspective, "f").querySurrealDB(filterQuery);
19309
+ // RETURN can return the value directly or in an array
19310
+ const isTrue = result === true || (Array.isArray(result) && result.length > 0 && result[0] === true);
19311
+ if (isTrue) {
19312
+ filteredValues.push(value);
19313
+ }
19314
+ }
19315
+ values = filteredValues;
19316
+ }
19317
+ catch (error) {
19318
+ console.warn(`Failed to apply condition filter for ${collName}:`, error);
19319
+ // Keep unfiltered values on error
19320
+ }
19321
+ }
19245
19322
  // Apply where.isInstance filtering if present
19246
19323
  if (collMeta.where?.isInstance && values.length > 0) {
19247
19324
  try {
@@ -19271,11 +19348,11 @@ class Ad4mModel {
19271
19348
  }
19272
19349
  }
19273
19350
  // Evaluate SurrealQL getters
19274
- await ctor.evaluateSurrealGettersForInstance(this, __classPrivateFieldGet(this, _Ad4mModel_perspective, "f"), metadata);
19275
- // Apply where.isInstance filtering to surrealGetter collections
19276
- // (non-surrealGetter collections were already filtered above)
19351
+ await ctor.evaluateCustomGettersForInstance(this, __classPrivateFieldGet(this, _Ad4mModel_perspective, "f"), metadata);
19352
+ // Apply where.isInstance filtering to getter collections
19353
+ // (non-getter collections were already filtered above)
19277
19354
  for (const [collName, collMeta] of Object.entries(metadata.collections)) {
19278
- if (collMeta.surrealGetter && collMeta.where?.isInstance && this[collName]?.length > 0) {
19355
+ if (collMeta.getter && collMeta.where?.isInstance && this[collName]?.length > 0) {
19279
19356
  try {
19280
19357
  const className = typeof collMeta.where.isInstance === 'string'
19281
19358
  ? collMeta.where.isInstance
@@ -19323,14 +19400,14 @@ class Ad4mModel {
19323
19400
  * Evaluates custom SurrealQL getters for properties and collections on a specific instance.
19324
19401
  * @private
19325
19402
  */
19326
- static async evaluateSurrealGettersForInstance(instance, perspective, metadata) {
19403
+ static async evaluateCustomGettersForInstance(instance, perspective, metadata) {
19327
19404
  const safeBaseExpression = this.formatSurrealValue(instance.baseExpression);
19328
- // Evaluate property surrealGetters
19405
+ // Evaluate property getters
19329
19406
  for (const [propName, propMeta] of Object.entries(metadata.properties)) {
19330
- if (propMeta.surrealGetter) {
19407
+ if (propMeta.getter) {
19331
19408
  try {
19332
19409
  // Replace 'Base' placeholder with actual base expression
19333
- const query = propMeta.surrealGetter.replace(/Base/g, safeBaseExpression);
19410
+ const query = propMeta.getter.replace(/Base/g, safeBaseExpression);
19334
19411
  // Query from node table to have graph traversal context
19335
19412
  const result = await perspective.querySurrealDB(`SELECT (${query}) AS value FROM node WHERE uri = ${safeBaseExpression}`);
19336
19413
  if (result && result.length > 0 && result[0].value !== undefined && result[0].value !== null && result[0].value !== 'None' && result[0].value !== '') {
@@ -19338,16 +19415,16 @@ class Ad4mModel {
19338
19415
  }
19339
19416
  }
19340
19417
  catch (error) {
19341
- console.warn(`Failed to evaluate surrealGetter for ${propName}:`, error);
19418
+ console.warn(`Failed to evaluate getter for ${propName}:`, error);
19342
19419
  }
19343
19420
  }
19344
19421
  }
19345
- // Evaluate collection surrealGetters
19422
+ // Evaluate collection getters
19346
19423
  for (const [collName, collMeta] of Object.entries(metadata.collections)) {
19347
- if (collMeta.surrealGetter) {
19424
+ if (collMeta.getter) {
19348
19425
  try {
19349
19426
  // Replace 'Base' placeholder with actual base expression
19350
- const query = collMeta.surrealGetter.replace(/Base/g, safeBaseExpression);
19427
+ const query = collMeta.getter.replace(/Base/g, safeBaseExpression);
19351
19428
  // Query from node table to have graph traversal context
19352
19429
  const result = await perspective.querySurrealDB(`SELECT (${query}) AS value FROM node WHERE uri = ${safeBaseExpression}`);
19353
19430
  if (result && result.length > 0 && result[0].value !== undefined && result[0].value !== null) {
@@ -19359,7 +19436,7 @@ class Ad4mModel {
19359
19436
  }
19360
19437
  }
19361
19438
  catch (error) {
19362
- console.warn(`Failed to evaluate surrealGetter for ${collName}:`, error);
19439
+ console.warn(`Failed to evaluate getter for ${collName}:`, error);
19363
19440
  }
19364
19441
  }
19365
19442
  }
@@ -19925,11 +20002,11 @@ WHERE ${whereConditions.join(' AND ')}
19925
20002
  latestAuthor = link.author;
19926
20003
  }
19927
20004
  }
19928
- // Find matching property (skip those with surrealGetter)
20005
+ // Find matching property (skip those with getter)
19929
20006
  let foundProperty = false;
19930
20007
  for (const [propName, propMeta] of Object.entries(metadata.properties)) {
19931
- if (propMeta.surrealGetter)
19932
- continue; // Handle via surrealGetter evaluation
20008
+ if (propMeta.getter)
20009
+ continue; // Handle via getter evaluation
19933
20010
  if (propMeta.predicate === predicate) {
19934
20011
  // For properties, take the first value (or we could use timestamp to get latest)
19935
20012
  // Note: Empty objects {} are truthy, so we need to check for them explicitly
@@ -19999,11 +20076,11 @@ WHERE ${whereConditions.join(' AND ')}
19999
20076
  break;
20000
20077
  }
20001
20078
  }
20002
- // If not a property, check if it's a collection (skip those with surrealGetter)
20079
+ // If not a property, check if it's a collection (skip those with getter)
20003
20080
  if (!foundProperty) {
20004
20081
  for (const [collName, collMeta] of Object.entries(metadata.collections)) {
20005
- if (collMeta.surrealGetter)
20006
- continue; // Handle via surrealGetter evaluation
20082
+ if (collMeta.getter)
20083
+ continue; // Handle via getter evaluation
20007
20084
  if (collMeta.predicate === predicate) {
20008
20085
  // For collections, accumulate all values with their timestamps and indices for sorting
20009
20086
  if (!instance[collName]) {
@@ -20106,10 +20183,10 @@ WHERE ${whereConditions.join(' AND ')}
20106
20183
  console.error(`Failed to process SurrealDB instance ${base}:`, error);
20107
20184
  }
20108
20185
  }
20109
- // Evaluate SurrealQL getters for all instances (single pass)
20186
+ // Evaluate custom getters for all instances (single pass)
20110
20187
  // This populates collection values needed for where.isInstance filtering
20111
20188
  for (const instance of instances) {
20112
- await this.evaluateSurrealGettersForInstance(instance, perspective, metadata);
20189
+ await this.evaluateCustomGettersForInstance(instance, perspective, metadata);
20113
20190
  }
20114
20191
  // Filter collections by where.isInstance if specified
20115
20192
  // Do this after initial evaluation so collection values exist for filtering
@@ -26,7 +26,7 @@ export declare class AIClient {
26
26
  endThreshold?: number;
27
27
  endWindow?: number;
28
28
  timeBeforeSpeech?: number;
29
- }): Promise<string>;
29
+ }, language?: string): Promise<string>;
30
30
  closeTranscriptionStream(streamId: string): Promise<void>;
31
31
  feedTranscriptionStream(streamIds: string | string[], audio: Float32Array): Promise<void>;
32
32
  }
@@ -279,16 +279,17 @@ export class AIClient {
279
279
  const decompressed = JSON.parse(pako.inflate(compressed, { to: 'string' }));
280
280
  return decompressed;
281
281
  }
282
- async openTranscriptionStream(modelId, streamCallback, params) {
282
+ async openTranscriptionStream(modelId, streamCallback, params, language) {
283
283
  const { aiOpenTranscriptionStream } = unwrapApolloResult(await __classPrivateFieldGet(this, _AIClient_apolloClient, "f").mutate({
284
284
  mutation: gql `
285
- mutation AiOpenTranscriptionStream($modelId: String!, $params: VoiceActivityParamsInput) {
286
- aiOpenTranscriptionStream(modelId: $modelId, params: $params)
285
+ mutation AiOpenTranscriptionStream($modelId: String!, $params: VoiceActivityParamsInput, $language: String) {
286
+ aiOpenTranscriptionStream(modelId: $modelId, params: $params, language: $language)
287
287
  }
288
288
  `,
289
289
  variables: {
290
290
  modelId,
291
- params
291
+ params,
292
+ language
292
293
  }
293
294
  }));
294
295
  const subscription = __classPrivateFieldGet(this, _AIClient_apolloClient, "f").subscribe({
@@ -68,7 +68,7 @@ export default class AIResolver {
68
68
  aiModelLoadingStatus(model: string): AIModelLoadingStatus;
69
69
  aiPrompt(taskId: string, input: string): string;
70
70
  aiEmbed(modelId: string, text: string): string;
71
- aiOpenTranscriptionStream(modelId: string, params?: VoiceActivityParamsInput): string;
71
+ aiOpenTranscriptionStream(modelId: string, params?: VoiceActivityParamsInput, language?: string): string;
72
72
  aiCloseTranscriptionStream(streamId: string): boolean;
73
73
  aiFeedTranscriptionStream(streamIds: string[], audio: number[], pubSub: any): boolean;
74
74
  aiTranscriptionText(streamId: string): string;
@@ -307,7 +307,7 @@ let AIResolver = class AIResolver {
307
307
  const compressedString = base64js.fromByteArray(compressed);
308
308
  return compressedString;
309
309
  }
310
- aiOpenTranscriptionStream(modelId, params) {
310
+ aiOpenTranscriptionStream(modelId, params, language) {
311
311
  return "streamId";
312
312
  }
313
313
  aiCloseTranscriptionStream(streamId) {
@@ -422,8 +422,9 @@ __decorate([
422
422
  Mutation(() => String),
423
423
  __param(0, Arg("modelId")),
424
424
  __param(1, Arg("params", () => VoiceActivityParamsInput, { nullable: true })),
425
+ __param(2, Arg("language", { nullable: true })),
425
426
  __metadata("design:type", Function),
426
- __metadata("design:paramtypes", [String, VoiceActivityParamsInput]),
427
+ __metadata("design:paramtypes", [String, VoiceActivityParamsInput, String]),
427
428
  __metadata("design:returntype", String)
428
429
  ], AIResolver.prototype, "aiOpenTranscriptionStream", null);
429
430
  __decorate([
@@ -100,11 +100,11 @@ export interface PropertyMetadata {
100
100
  /** Language for resolution (e.g., "literal") */
101
101
  resolveLanguage?: string;
102
102
  /** Custom Prolog getter code */
103
- getter?: string;
103
+ prologGetter?: string;
104
104
  /** Custom Prolog setter code */
105
- setter?: string;
105
+ prologSetter?: string;
106
106
  /** Custom SurrealQL getter code */
107
- surrealGetter?: string;
107
+ getter?: string;
108
108
  /** Whether stored locally only */
109
109
  local?: boolean;
110
110
  /** Transform function */
@@ -123,10 +123,11 @@ export interface CollectionMetadata {
123
123
  /** Filter conditions */
124
124
  where?: {
125
125
  isInstance?: any;
126
+ prologCondition?: string;
126
127
  condition?: string;
127
128
  };
128
129
  /** Custom SurrealQL getter code */
129
- surrealGetter?: string;
130
+ getter?: string;
130
131
  /** Whether stored locally only */
131
132
  local?: boolean;
132
133
  }
@@ -349,7 +350,7 @@ export declare class Ad4mModel {
349
350
  * Evaluates custom SurrealQL getters for properties and collections on a specific instance.
350
351
  * @private
351
352
  */
352
- private static evaluateSurrealGettersForInstance;
353
+ private static evaluateCustomGettersForInstance;
353
354
  /**
354
355
  * Generates a SurrealQL query from a Query object.
355
356
  *