@kortexya/reasoninglayer 1.25.0 → 1.26.0

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.cjs CHANGED
@@ -7,7 +7,7 @@ var __export = (target, all) => {
7
7
  };
8
8
 
9
9
  // src/config.ts
10
- var SDK_VERSION = "1.25.0";
10
+ var SDK_VERSION = "1.26.0";
11
11
  function resolveConfig(config) {
12
12
  if (!config.baseUrl) {
13
13
  throw new Error("ClientConfig.baseUrl is required");
@@ -8493,6 +8493,22 @@ var Functions = class {
8493
8493
  format: "json",
8494
8494
  ...params
8495
8495
  });
8496
+ /**
8497
+ * @description # Why this route had to exist `/api/v1/functions` had five routes and none of them returned a definition: the listing answers summaries (`name`, `arity`, `clauses_count`, `kind`), and `GET /api/v1/functions/{name}` was a `405`. So `PUT` replaced a definition its caller could not see — a client fixing one clause of a three-clause function had to remember the other two or lose them, and the route made a partial edit look like a whole one (#235). # The clauses come back in the shape `PUT` takes [`GetFunctionResponse::clauses`] is the exact `clauses` payload `POST /functions/register` and `PUT /functions/{name}` accept, so a read-modify-write needs no translation layer that could drop a body variant on the way through. Making that true meant widening the request shape: `BinaryOperatorDto` carried four of the domain's thirteen operators and `ExpressionDto` was missing `UnaryOp` and `Conditional`, while OSFQL `DERIVE` builds function bodies with every one of them. A read in the old shape would have had to drop a `CASE WHEN` or lie about a `%`. # Reading is not changing A plugin-contributed function is refused by `DELETE` and `PUT` and **returned** by this route, with `replaceable: false` and the refusal the mutation would answer with. The listing already admits it exists; refusing to describe it would leave a client unable to show what the plugin contributed while still showing its name. The refusal is read from the same walk the mutation routes run, so the two cannot disagree. # Authorization Requires `X-Tenant-Id`. The function store is tenant-keyed, so another tenant's function is `404` rather than forbidden — saying anything else would confirm the name exists somewhere.
8498
+ *
8499
+ * @tags functions
8500
+ * @name GetFunction
8501
+ * @summary Read one registered function's definition.
8502
+ * @request GET:/api/v1/functions/{name}
8503
+ * @secure
8504
+ */
8505
+ getFunction = (name, params = {}) => this.http.request({
8506
+ path: `/api/v1/functions/${name}`,
8507
+ method: "GET",
8508
+ secure: true,
8509
+ format: "json",
8510
+ ...params
8511
+ });
8496
8512
  /**
8497
8513
  * @description This is the discovery counterpart to `register_function`/`evaluate_function`: it projects the tenant's slice of the function sub-lattice into a list of typed signatures (name + arity + clause count) without evaluating anything. The tenant is taken from the authenticated principal (never a body field), honouring the tenancy-scoping invariant.
8498
8514
  *
@@ -26175,6 +26191,23 @@ function ExpressionDtoFromFrontToApi(model) {
26175
26191
  right: ExpressionDtoFromFrontToApi(model.right)
26176
26192
  };
26177
26193
  }
26194
+ if (model.type === "UnaryOp") {
26195
+ return {
26196
+ type: "UnaryOp",
26197
+ op: model.op,
26198
+ operand: ExpressionDtoFromFrontToApi(model.operand)
26199
+ };
26200
+ }
26201
+ if (model.type === "Conditional") {
26202
+ return {
26203
+ type: "Conditional",
26204
+ branches: model.branches.map((b) => ({
26205
+ when: ExpressionDtoFromFrontToApi(b.when),
26206
+ then: ExpressionDtoFromFrontToApi(b.then)
26207
+ })),
26208
+ default: model.default ? ExpressionDtoFromFrontToApi(model.default) : model.default
26209
+ };
26210
+ }
26178
26211
  return model;
26179
26212
  }
26180
26213
  function ExpressionDtoFromApiToFront(dto) {
@@ -26193,6 +26226,23 @@ function ExpressionDtoFromApiToFront(dto) {
26193
26226
  right: ExpressionDtoFromApiToFront(dto.right)
26194
26227
  };
26195
26228
  }
26229
+ if (dto.type === "UnaryOp") {
26230
+ return {
26231
+ type: "UnaryOp",
26232
+ op: dto.op,
26233
+ operand: ExpressionDtoFromApiToFront(dto.operand)
26234
+ };
26235
+ }
26236
+ if (dto.type === "Conditional") {
26237
+ return {
26238
+ type: "Conditional",
26239
+ branches: dto.branches.map((b) => ({
26240
+ when: ExpressionDtoFromApiToFront(b.when),
26241
+ then: ExpressionDtoFromApiToFront(b.then)
26242
+ })),
26243
+ default: dto.default ? ExpressionDtoFromApiToFront(dto.default) : dto.default
26244
+ };
26245
+ }
26196
26246
  return dto;
26197
26247
  }
26198
26248
  function FunctionBodyDtoFromFrontToApi(model) {
@@ -26409,6 +26459,26 @@ function ReplaceFunctionResponseFromApiToFront(dto) {
26409
26459
  callers: (dto.callers ?? []).map(FunctionCallerFromApiToFront)
26410
26460
  };
26411
26461
  }
26462
+ function GetFunctionResponseFromApiToFront(dto) {
26463
+ const signature = {
26464
+ name: dto.name,
26465
+ functionId: dto.function_id,
26466
+ arity: dto.arity,
26467
+ kind: dto.kind,
26468
+ replaceable: dto.replaceable,
26469
+ notReplaceable: dto.not_replaceable ?? void 0,
26470
+ // The wire omits the field when nothing calls it; the SDK always hands
26471
+ // back an array, as the withdrawal report already does.
26472
+ callers: (dto.callers ?? []).map(FunctionCallerFromApiToFront)
26473
+ };
26474
+ if (dto.clauses == null) {
26475
+ return {
26476
+ ...signature,
26477
+ unrepresentable: dto.unrepresentable ?? "The engine returned no clauses for this function and gave no reason."
26478
+ };
26479
+ }
26480
+ return { ...signature, clauses: dto.clauses.map(FunctionClauseDtoFromApiToFront) };
26481
+ }
26412
26482
 
26413
26483
  // src/resources/functions.ts
26414
26484
  var FunctionsClient = class {
@@ -26472,7 +26542,9 @@ var FunctionsClient = class {
26472
26542
  * ```
26473
26543
  */
26474
26544
  async registerFunction(request) {
26475
- const response = await this.api.registerFunction(RegisterFunctionRequestFromFrontToApi(request));
26545
+ const response = await this.api.registerFunction(
26546
+ RegisterFunctionRequestFromFrontToApi(request)
26547
+ );
26476
26548
  return RegisterFunctionResponseFromApiToFront(response.data);
26477
26549
  }
26478
26550
  /**
@@ -26523,7 +26595,9 @@ var FunctionsClient = class {
26523
26595
  * ```
26524
26596
  */
26525
26597
  async evaluateFunction(request) {
26526
- const response = await this.api.evaluateFunction(EvaluateFunctionRequestFromFrontToApi(request));
26598
+ const response = await this.api.evaluateFunction(
26599
+ EvaluateFunctionRequestFromFrontToApi(request)
26600
+ );
26527
26601
  return EvaluateFunctionResponseFromApiToFront(response.data);
26528
26602
  }
26529
26603
  /**
@@ -26553,6 +26627,49 @@ var FunctionsClient = class {
26553
26627
  const response = await this.api.listFunctions();
26554
26628
  return ListFunctionsResponseFromApiToFront(response.data);
26555
26629
  }
26630
+ /**
26631
+ * Read one registered function's definition.
26632
+ *
26633
+ * @param name - The registered function's name — its identity.
26634
+ * @returns The signature, everything that calls it, whether a `PUT` would
26635
+ * act or refuse, and the clauses in the shape a replacement takes.
26636
+ * @throws {ApiError} 404 if nothing is registered under that name for the
26637
+ * authenticated tenant. Another tenant's function is 404 too — saying
26638
+ * anything else would confirm the name exists somewhere.
26639
+ *
26640
+ * @remarks
26641
+ * This is what makes {@link FunctionsClient.replaceFunction} an edit. `PUT`
26642
+ * replaces the WHOLE definition, so without a read a client fixing one
26643
+ * clause of a three-clause function had to re-author the other two from
26644
+ * memory, and any it forgot were deleted.
26645
+ *
26646
+ * `clauses` and `unrepresentable` are exclusive: a definition holding a
26647
+ * construct the register shape cannot express comes back with no clauses and
26648
+ * a reason, because a degraded read written back would destroy the real
26649
+ * definition. Narrow on `clauses === undefined` before using them.
26650
+ *
26651
+ * A plugin-contributed function is refused by `DELETE`/`PUT` and returned
26652
+ * here, with `replaceable: false` and the refusal the mutation would give.
26653
+ *
26654
+ * @example
26655
+ * ```typescript
26656
+ * const definition = await client.functions.getFunction('scale');
26657
+ * if (definition.clauses === undefined) {
26658
+ * throw new Error(`scale cannot be edited: ${definition.unrepresentable}`);
26659
+ * }
26660
+ * if (!definition.replaceable) {
26661
+ * throw new Error(definition.notReplaceable?.reason);
26662
+ * }
26663
+ * await client.functions.replaceFunction('scale', {
26664
+ * arity: definition.arity,
26665
+ * clauses: definition.clauses.map(tweak),
26666
+ * });
26667
+ * ```
26668
+ */
26669
+ async getFunction(name) {
26670
+ const response = await this.api.getFunction(name);
26671
+ return GetFunctionResponseFromApiToFront(response.data);
26672
+ }
26556
26673
  /**
26557
26674
  * Withdraw a registered function.
26558
26675
  *