@kortexya/reasoninglayer 1.24.0 → 1.25.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.js CHANGED
@@ -5,7 +5,7 @@ var __export = (target, all) => {
5
5
  };
6
6
 
7
7
  // src/config.ts
8
- var SDK_VERSION = "1.24.0";
8
+ var SDK_VERSION = "1.25.0";
9
9
  function resolveConfig(config) {
10
10
  if (!config.baseUrl) {
11
11
  throw new Error("ClientConfig.baseUrl is required");
@@ -8438,6 +8438,23 @@ var Functions = class {
8438
8438
  constructor(http) {
8439
8439
  this.http = http;
8440
8440
  }
8441
+ /**
8442
+ * @description # The disposition is the caller's `?callers=refuse` (the default) refuses while anything calls the function and names every caller; `?callers=orphan` withdraws it anyway and reports the callers left naming something that no longer resolves. A withdrawal that silently orphans its callers is the state the missing route already produced. # Authorization Requires `X-Tenant-Id`. The function store is tenant-keyed, so another tenant's function is `404` rather than forbidden. Every request is captured by the audit middleware.
8443
+ *
8444
+ * @tags functions
8445
+ * @name DeleteFunction
8446
+ * @summary Withdraw a registered function.
8447
+ * @request DELETE:/api/v1/functions/{name}
8448
+ * @secure
8449
+ */
8450
+ deleteFunction = (name, query, params = {}) => this.http.request({
8451
+ path: `/api/v1/functions/${name}`,
8452
+ method: "DELETE",
8453
+ query,
8454
+ secure: true,
8455
+ format: "json",
8456
+ ...params
8457
+ });
8441
8458
  /**
8442
8459
  * @description Never writes to the KB — returns a validated draft for human review.
8443
8460
  *
@@ -8508,6 +8525,24 @@ var Functions = class {
8508
8525
  format: "json",
8509
8526
  ...params
8510
8527
  });
8528
+ /**
8529
+ * @description # Why this is not `POST /functions/register` Registration already replaces by name — silently, reporting nothing about what it displaced. `PUT` is the operation that says so: it refuses when nothing is registered under the name (that is registration's job), and answers with the previous signature, the new one, whether the arity moved, and everything that calls the function. # The arity is the hazard A function's identity is its NAME, so a replacement keeps every caller's reference valid — nothing dangles. That is exactly why an arity change is dangerous rather than merely breaking: every call still resolves, and one passing the old number of arguments starts failing at evaluation time. Reported, not refused: the caller may be replacing the function precisely because its signature was wrong. # Authorization Identical to `DELETE`: tenant-keyed, plugin-owned functions refused, audited.
8530
+ *
8531
+ * @tags functions
8532
+ * @name ReplaceFunction
8533
+ * @summary Replace a registered function's definition.
8534
+ * @request PUT:/api/v1/functions/{name}
8535
+ * @secure
8536
+ */
8537
+ replaceFunction = (name, data, params = {}) => this.http.request({
8538
+ path: `/api/v1/functions/${name}`,
8539
+ method: "PUT",
8540
+ body: data,
8541
+ secure: true,
8542
+ type: "application/json",
8543
+ format: "json",
8544
+ ...params
8545
+ });
8511
8546
  };
8512
8547
 
8513
8548
  // src/api-spec/generated/WebhookActions.ts
@@ -14330,7 +14365,13 @@ function RuleEntryDtoFromApiToFront(dto) {
14330
14365
  ruleId: dto.rule_id,
14331
14366
  head: PsiTermDtoFromApiToFront(dto.head),
14332
14367
  body: dto.body.map(PsiTermDtoFromApiToFront),
14333
- certainty: dto.certainty ?? void 0
14368
+ certainty: dto.certainty ?? void 0,
14369
+ origin: dto.origin,
14370
+ withdrawable: dto.withdrawable,
14371
+ notWithdrawable: dto.not_withdrawable ? {
14372
+ code: dto.not_withdrawable.code,
14373
+ reason: dto.not_withdrawable.reason
14374
+ } : void 0
14334
14375
  };
14335
14376
  }
14336
14377
  function GetRulesResponseFromApiToFront(dto) {
@@ -15229,7 +15270,8 @@ function FindBySortRequestFromFrontToApi(model) {
15229
15270
  return {
15230
15271
  sort_id: model.sortId ?? void 0,
15231
15272
  sort_name: model.sortName ?? void 0,
15232
- filter: model.filter ?? void 0
15273
+ filter: model.filter ?? void 0,
15274
+ limit: model.limit ?? void 0
15233
15275
  };
15234
15276
  }
15235
15277
  function OsfSearchRequestFromFrontToApi(model) {
@@ -17401,7 +17443,7 @@ var ConstraintsClient = class {
17401
17443
  type: "application/json",
17402
17444
  format: "json"
17403
17445
  });
17404
- return response.data;
17446
+ return ConstraintGraphResponseFromApiToFront(response.data);
17405
17447
  }
17406
17448
  // --- Session Management ---
17407
17449
  /**
@@ -23476,9 +23518,11 @@ function StructuredIngestionStatsDtoFromApiToFront(dto) {
23476
23518
  elapsedMs: dto.elapsed_ms,
23477
23519
  entitiesCreated: dto.entities_created,
23478
23520
  entitiesExtracted: dto.entities_extracted,
23521
+ recordsAvailable: dto.records_available,
23479
23522
  recordsProcessed: dto.records_processed,
23480
23523
  relationsCreated: dto.relations_created,
23481
23524
  relationsDiscovered: dto.relations_discovered,
23525
+ rowsCollapsed: dto.rows_collapsed,
23482
23526
  sortsCreated: dto.sorts_created,
23483
23527
  tablesDiscovered: dto.tables_discovered,
23484
23528
  termsCreated: dto.terms_created,
@@ -26335,6 +26379,34 @@ function DraftFunctionResponseFromApiToFront(dto) {
26335
26379
  warnings: dto.warnings
26336
26380
  };
26337
26381
  }
26382
+ function FunctionCallerFromApiToFront(dto) {
26383
+ return {
26384
+ kind: dto.kind,
26385
+ name: dto.name,
26386
+ termId: dto.term_id ?? void 0
26387
+ };
26388
+ }
26389
+ function FunctionWithdrawalReportFromApiToFront(dto) {
26390
+ return {
26391
+ name: dto.name,
26392
+ functionId: dto.function_id,
26393
+ carrierDeleted: dto.carrier_deleted,
26394
+ deregistered: dto.deregistered,
26395
+ // The wire omits the field when nothing was orphaned; the SDK always
26396
+ // hands back an array, so a caller never has to guard the read.
26397
+ callersOrphaned: (dto.callers_orphaned ?? []).map(FunctionCallerFromApiToFront)
26398
+ };
26399
+ }
26400
+ function ReplaceFunctionResponseFromApiToFront(dto) {
26401
+ return {
26402
+ name: dto.name,
26403
+ functionId: dto.function_id,
26404
+ previous: FunctionSummaryDtoFromApiToFront(dto.previous),
26405
+ current: FunctionSummaryDtoFromApiToFront(dto.current),
26406
+ arityChanged: dto.arity_changed,
26407
+ callers: (dto.callers ?? []).map(FunctionCallerFromApiToFront)
26408
+ };
26409
+ }
26338
26410
 
26339
26411
  // src/resources/functions.ts
26340
26412
  var FunctionsClient = class {
@@ -26479,6 +26551,85 @@ var FunctionsClient = class {
26479
26551
  const response = await this.api.listFunctions();
26480
26552
  return ListFunctionsResponseFromApiToFront(response.data);
26481
26553
  }
26554
+ /**
26555
+ * Withdraw a registered function.
26556
+ *
26557
+ * @param name - The registered function's name — its identity.
26558
+ * @param options - `callers` decides what happens to the things that call
26559
+ * it. Defaults to `'refuse'`.
26560
+ * @returns What the withdrawal removed, in each representation that held it.
26561
+ * @throws {ApiError} 400 if something still calls the function under the
26562
+ * default `'refuse'` (the body carries `code: 'function_has_callers'` and
26563
+ * the caller list); 403 for a plugin-contributed function; 404 if nothing
26564
+ * is registered under that name.
26565
+ *
26566
+ * @remarks
26567
+ * A function is carried twice — the durable `meta.function` carrier that is
26568
+ * the source of truth, and the evaluator's own registry used for dispatch
26569
+ * and recursive cross-calls — and the report names both, because forgetting
26570
+ * either leaves it half-alive: still evaluable, or back after a restart.
26571
+ *
26572
+ * `'refuse'` names every caller; `'orphan'` withdraws anyway and reports the
26573
+ * callers left naming something that no longer resolves.
26574
+ *
26575
+ * @example
26576
+ * ```typescript
26577
+ * const report = await client.functions.deleteFunction('scale', { callers: 'orphan' });
26578
+ * for (const orphan of report.callersOrphaned) {
26579
+ * console.warn(`${orphan.kind} ${orphan.name} now calls a function that is gone`);
26580
+ * }
26581
+ * ```
26582
+ */
26583
+ async deleteFunction(name, options) {
26584
+ const response = await this.api.deleteFunction(
26585
+ name,
26586
+ options?.callers === void 0 ? void 0 : { callers: options.callers }
26587
+ );
26588
+ return FunctionWithdrawalReportFromApiToFront(response.data);
26589
+ }
26590
+ /**
26591
+ * Replace a registered function's definition.
26592
+ *
26593
+ * @param name - The registered function's name. Unchanged by the
26594
+ * replacement — the name IS the identity.
26595
+ * @param request - The replacement's arity and clauses.
26596
+ * @returns Both signatures, whether the arity moved, and everything that
26597
+ * calls the function.
26598
+ * @throws {ApiError} 400 if the replacement's clauses are rejected — in
26599
+ * which case the registration is left exactly as it was; 403 for a
26600
+ * plugin-contributed function; 404 if nothing is registered under that
26601
+ * name (creating one is {@link FunctionsClient.registerFunction}'s job).
26602
+ *
26603
+ * @remarks
26604
+ * `registerFunction` already replaces by name — silently, reporting nothing
26605
+ * about what it displaced. This is the operation that says so.
26606
+ *
26607
+ * A function's identity is its NAME, so a replacement keeps every caller's
26608
+ * reference valid: nothing dangles. That is exactly why an arity change is
26609
+ * the dangerous edit — every call still resolves, and one passing the old
26610
+ * argument count starts failing at evaluation time. `arityChanged` is
26611
+ * reported rather than refused, because a caller may be replacing the
26612
+ * function precisely because its signature was wrong.
26613
+ *
26614
+ * @example
26615
+ * ```typescript
26616
+ * const result = await client.functions.replaceFunction('scale', {
26617
+ * arity: 2,
26618
+ * clauses: [multiplyClause],
26619
+ * });
26620
+ * if (result.arityChanged) {
26621
+ * console.warn(`arity ${result.previous.arity} -> ${result.current.arity};`,
26622
+ * `${result.callers.length} caller(s) were written against the old one`);
26623
+ * }
26624
+ * ```
26625
+ */
26626
+ async replaceFunction(name, request) {
26627
+ const response = await this.api.replaceFunction(name, {
26628
+ arity: request.arity,
26629
+ clauses: request.clauses.map(FunctionClauseDtoFromFrontToApi)
26630
+ });
26631
+ return ReplaceFunctionResponseFromApiToFront(response.data);
26632
+ }
26482
26633
  /**
26483
26634
  * Draft a user-defined function from a natural-language description.
26484
26635
  *
@@ -27732,6 +27883,7 @@ function ClearTenantResponseFromApiToFront(dto) {
27732
27883
  sortsDeleted: dto.sorts_deleted,
27733
27884
  inferenceStateCleared: dto.inference_state_cleared,
27734
27885
  cacheInvalidated: dto.cache_invalidated,
27886
+ vectorsDeleted: dto.vectors_deleted,
27735
27887
  pluginInstallsDeleted: dto.plugin_installs_deleted
27736
27888
  };
27737
27889
  }
@@ -32896,7 +33048,14 @@ function BindingSummaryDtoFromApiToFront(dto) {
32896
33048
  keyColumns: dto.key_columns,
32897
33049
  sortId: dto.sort_id,
32898
33050
  sourceId: dto.source_id,
32899
- tableName: dto.table_name
33051
+ tableName: dto.table_name,
33052
+ keyProvenance: {
33053
+ source: dto.key_provenance.source,
33054
+ chosenBy: dto.key_provenance.chosen_by,
33055
+ explanation: dto.key_provenance.explanation,
33056
+ guaranteedUnique: dto.key_provenance.guaranteed_unique,
33057
+ durability: dto.key_provenance.durability
33058
+ }
32900
33059
  };
32901
33060
  }
32902
33061
  function ListBindingsResponseFromApiToFront(dto) {