@kortexya/reasoninglayer 4.0.0 → 4.2.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/README.md CHANGED
@@ -316,7 +316,7 @@ pnpm run docs:build # Build documentation site
316
316
 
317
317
  | SDK Version | Min Backend Version | Node | Browser |
318
318
  | ----------- | ------------------- | ---- | ------- |
319
- | 4.0.0 | engine `5cef4fa34` | 20+ | ES2022+ |
319
+ | 4.2.0 | engine `cfd780622` | 20+ | ES2022+ |
320
320
 
321
321
  ## License
322
322
 
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 = "4.0.0";
10
+ var SDK_VERSION = "4.2.0";
11
11
  function resolveConfig(config) {
12
12
  if (!config.baseUrl) {
13
13
  throw new Error("ClientConfig.baseUrl is required");
@@ -2532,7 +2532,7 @@ var Inference = class {
2532
2532
  ...params
2533
2533
  });
2534
2534
  /**
2535
- * @description # The disposition is the caller's `?derivations=refuse` (the default) refuses while the rule still supports materialized conclusions and says how many; `?derivations=retract` withdraws them with it and reports the counts. A delete that silently drops derivations is as wrong as one that silently keeps them, so neither is the unnamed default. # Authorization Requires `X-Tenant-Id`. Runs the same delete guard as `DELETE /api/v1/terms/{id}` — a rule is a policy-relevant object, and withdrawing one changes what the engine will conclude. Honours `If-Match` against the conclusion's content ETag, and requires it under `OSFKB_REQUIRE_IF_MATCH=1`. Every request is captured by the audit middleware.
2535
+ * @description # The disposition is the caller's `?derivations=refuse` (the default) refuses while the rule still supports materialized conclusions and says how many; `?derivations=retract` withdraws them with it and reports the counts. A delete that silently drops derivations is as wrong as one that silently keeps them, so neither is the unnamed default. # Authorization Requires `X-Tenant-Id`. Runs the same delete guard as `DELETE /api/v1/terms/{id}` — a rule is a policy-relevant object, and withdrawing one changes what the engine will conclude. Honours `If-Match` against the conclusion's content ETag — the tag [`rule_content_tag`] publishes on the rule routes (#473) — and requires it under `OSFKB_REQUIRE_IF_MATCH=1`. Every request is captured by the audit middleware.
2536
2536
  *
2537
2537
  * @tags inference
2538
2538
  * @name DeleteRule
@@ -11007,7 +11007,7 @@ var Ui = class {
11007
11007
  ...params
11008
11008
  });
11009
11009
  /**
11010
- * @description Events: - `layout_ready` — LayoutSurface JSON - `component_ready` — {slot_id, descriptor} JSON - `data_chunk` — {slot_id, data} JSON (if data was loaded) - `complete` — {} POST /api/v1/ui/describe/stream
11010
+ * @description Events: - `layout_ready` — LayoutSurface JSON - `component_ready` — {slot_id, descriptor} JSON - `data_chunk` — {slot_id, data} JSON (if data was loaded) - `data_load_error` — {slot_id, error} JSON (if the data load failed; the error carries the typed `code`, `message` and `query`, #475) - `complete` — {} POST /api/v1/ui/describe/stream
11011
11011
  *
11012
11012
  * @tags ui
11013
11013
  * @name DescribeUiStream
@@ -17786,6 +17786,7 @@ var RESPONSE_COMPONENTS = {
17786
17786
  injection: [2, "InjectionSummaryDto"],
17787
17787
  intent: [1, 0],
17788
17788
  matched_templates: [2, { array: "QueryTemplateDto" }],
17789
+ notices: [1, { array: 0 }],
17789
17790
  produced_term_ids: [1, { array: 0 }],
17790
17791
  prompt_trace: [2, "PromptTraceDto"],
17791
17792
  proof_trace: [2, "ProofTraceNodeDto"],
@@ -17969,6 +17970,7 @@ var RESPONSE_COMPONENTS = {
17969
17970
  explanation: [1, 0]
17970
17971
  }
17971
17972
  },
17973
+ DataLoadErrorDto: { object: { code: [1, 0], message: [1, 0], query: [1, 0] } },
17972
17974
  DataMixingStatsDto: {
17973
17975
  object: {
17974
17976
  negative_count: [1, 0],
@@ -18438,6 +18440,7 @@ var RESPONSE_COMPONENTS = {
18438
18440
  chunks_processed: [1, 0],
18439
18441
  document_id: [1, 0],
18440
18442
  entities_extracted: [1, 0],
18443
+ entities_refused: [1, { array: "RefusedEntityDto" }],
18441
18444
  processing_time_ms: [1, 0],
18442
18445
  relations_extracted: [1, 0],
18443
18446
  relations_integrated: [1, 0],
@@ -21269,9 +21272,11 @@ var RESPONSE_COMPONENTS = {
21269
21272
  }
21270
21273
  },
21271
21274
  PromptTraceDto: { object: { llm_context: [1, "LlmContextTraceDto"], system_prompt: [1, 0] } },
21275
+ ProofConclusionDto: { object: { features: [1, { object: {} }], sort_id: [1, 0] } },
21272
21276
  ProofDto: {
21273
21277
  object: {
21274
21278
  certainty: [1, 0],
21279
+ conclusion: [0, "ProofConclusionDto"],
21275
21280
  kind: [1, 0],
21276
21281
  subproofs: [0, { array: "ProofDto" }],
21277
21282
  substitution: [1, "HomoiconicSubstitutionDto"]
@@ -22340,6 +22345,7 @@ var RESPONSE_COMPONENTS = {
22340
22345
  SolutionDto: {
22341
22346
  object: {
22342
22347
  certainty: [1, 0],
22348
+ conclusion: [2, "ProofConclusionDto"],
22343
22349
  matched_sorts: [0, { array: 0 }],
22344
22350
  proof: [2, "ProofDto"],
22345
22351
  residuated_sorts: [0, { array: 0 }],
@@ -23062,6 +23068,7 @@ var RESPONSE_COMPONENTS = {
23062
23068
  UIAssemblyStatsDto: {
23063
23069
  object: {
23064
23070
  component_count: [1, 0],
23071
+ data_load_error: [2, "DataLoadErrorDto"],
23065
23072
  included_features: [1, 0],
23066
23073
  sort_name: [1, 0],
23067
23074
  total_features: [1, 0],
@@ -23100,6 +23107,7 @@ var RESPONSE_COMPONENTS = {
23100
23107
  UIGenerateResponse: {
23101
23108
  object: {
23102
23109
  data: [2, "DataPayloadDto"],
23110
+ data_load_errors: [0, { array: "DataLoadErrorDto" }],
23103
23111
  data_sources: [0, { array: "DataSourcePayloadDto" }],
23104
23112
  descriptor: [2, "UIDescriptorDto"],
23105
23113
  diagnostics: [0, { array: 0 }],
@@ -24788,6 +24796,11 @@ var RESPONSE_OPERATIONS = {
24788
24796
  path: "/api/v1/constraint-sessions/{session_id}",
24789
24797
  responses: { 200: "ConstraintSessionStatusResponse" }
24790
24798
  },
24799
+ getConversation: {
24800
+ method: "GET",
24801
+ path: "/api/v1/conversation/{id}",
24802
+ responses: { 200: "ConversationSummaryDto" }
24803
+ },
24791
24804
  getConversationEntries: {
24792
24805
  method: "GET",
24793
24806
  path: "/api/v1/audit/entries/{conversation_id}",
@@ -28616,10 +28629,11 @@ var TermsClient = class {
28616
28629
  * `etag` is optional in every case, not only for `asOf`. A historical read
28617
28630
  * carries none (a past state is not a representation `If-Match` can guard,
28618
28631
  * and a client that could capture one could overwrite the present with the
28619
- * past), and neither does a rule's conclusion or a term answered straight
28620
- * from durable storage. A rule's id is its conclusion term's id, so
28621
- * `getTerm(ruleId).etag` is the tag {@link InferenceClient.deleteRule} and
28622
- * {@link InferenceClient.replaceRule} take as `ifMatch`.
28632
+ * past), and neither does a term answered straight from durable storage.
28633
+ * A rule's id answers 404 here; read the tag
28634
+ * {@link InferenceClient.deleteRule} and {@link InferenceClient.replaceRule}
28635
+ * take as `ifMatch` from the rule routes ({@link AddRuleResponse.etag},
28636
+ * {@link RuleEntryDto.etag}).
28623
28637
  *
28624
28638
  * @example
28625
28639
  * ```typescript
@@ -29295,6 +29309,14 @@ function HomoiconicSubstitutionDtoFromApiToFront(dto) {
29295
29309
  bindings: dto.bindings.map(BindingDtoFromApiToFront)
29296
29310
  };
29297
29311
  }
29312
+ function ProofConclusionDtoFromApiToFront(dto) {
29313
+ return {
29314
+ features: featuresFromApiToFront(dto.features),
29315
+ sortId: dto.sort_id,
29316
+ sortName: dto.sort_name ?? void 0,
29317
+ termId: dto.term_id ?? void 0
29318
+ };
29319
+ }
29298
29320
  function ProofDtoFromApiToFront(dto) {
29299
29321
  return {
29300
29322
  kind: dto.kind,
@@ -29302,6 +29324,7 @@ function ProofDtoFromApiToFront(dto) {
29302
29324
  ruleTermId: dto.rule_term_id,
29303
29325
  ruleHeadTermId: dto.rule_head_term_id,
29304
29326
  goalDisplay: dto.goal_display,
29327
+ conclusion: dto.conclusion ? ProofConclusionDtoFromApiToFront(dto.conclusion) : void 0,
29305
29328
  ruleLabel: dto.rule_label,
29306
29329
  substitution: HomoiconicSubstitutionDtoFromApiToFront(dto.substitution),
29307
29330
  subproofs: dto.subproofs?.map(ProofDtoFromApiToFront),
@@ -29355,6 +29378,7 @@ function SolutionDtoFromApiToFront(dto) {
29355
29378
  const solution = {
29356
29379
  substitution: HomoiconicSubstitutionDtoFromApiToFront(dto.substitution),
29357
29380
  proof: dto.proof ? ProofDtoFromApiToFront(dto.proof) : void 0,
29381
+ conclusion: dto.conclusion ? ProofConclusionDtoFromApiToFront(dto.conclusion) : void 0,
29358
29382
  certainty: dto.certainty,
29359
29383
  evidenceMatched: dto.evidence_matched ?? void 0,
29360
29384
  evidenceRatio: dto.evidence_ratio ?? void 0,
@@ -29601,6 +29625,7 @@ function RuleEntryDtoFromApiToFront(dto) {
29601
29625
  if (dto.aggregator !== void 0 && dto.aggregator !== null) {
29602
29626
  entry.aggregator = RuleAggregatorDtoFromApiToFront(dto.aggregator);
29603
29627
  }
29628
+ if (dto.etag !== void 0 && dto.etag !== null) entry.etag = dto.etag;
29604
29629
  if (dto.osfql !== void 0 && dto.osfql !== null) entry.osfql = dto.osfql;
29605
29630
  return entry;
29606
29631
  }
@@ -30052,7 +30077,10 @@ var InferenceClient = class {
30052
30077
  *
30053
30078
  * @param request - Rule definition using TermInputDto. Set `aggregator` to declare an
30054
30079
  * engine-side head aggregator (see {@link RuleAggregatorDto}).
30055
- * @returns The created rule wrapped in an AddRuleResponse.
30080
+ * @returns The created rule wrapped in an AddRuleResponse, with its
30081
+ * {@link AddRuleResponse.etag} when the engine sends the `ETag` header.
30082
+ * @throws {@link ValidationError} before the request is sent, when `antecedents` is
30083
+ * not an array (a request built from untyped data) — `field` is `antecedents`.
30056
30084
  * @throws {ApiError} If the rule is rejected or the request fails — 422 when
30057
30085
  * it is unusable as written: a head or body antecedent naming a sort or
30058
30086
  * term that does not exist (the message names it and its position — `the
@@ -30062,9 +30090,8 @@ var InferenceClient = class {
30062
30090
  * cycle the program already had is not blamed on it), or a rule with no
30063
30091
  * antecedents (`rule rejected: a rule needs at least one antecedent; a
30064
30092
  * term with no antecedents is a fact — write it through POST
30065
- * /api/v1/terms` — write a fact with `client.terms.createTerm`). A body
30066
- * with no `antecedents` key at all is refused by the body decoder with a
30067
- * plain-text 422. The refusal is a
30093
+ * /api/v1/terms` — write a fact with `client.terms.createTerm`). The
30094
+ * refusal is a
30068
30095
  * plain {@link ApiError} with `status` 422 — not a `BadRequestError`
30069
30096
  * (earlier engines answered an unknown head sort with 400), and not a
30070
30097
  * `NamedConstraintViolationError`, which is reserved for a feature
@@ -30075,6 +30102,9 @@ var InferenceClient = class {
30075
30102
  *
30076
30103
  * Ask {@link InferenceClient.validateRule} first to learn every reason the
30077
30104
  * write would refuse, without writing.
30105
+ * The `ETag` response header is the rule's content tag, folded into
30106
+ * `etag`: the `ifMatch` for {@link InferenceClient.deleteRule} and
30107
+ * {@link InferenceClient.replaceRule}.
30078
30108
  * A `{ termId }` reference to a term that is durable but not yet loaded
30079
30109
  * into the engine process resolves: the route loads the terms the request
30080
30110
  * names before it converts them.
@@ -30091,7 +30121,7 @@ var InferenceClient = class {
30091
30121
  async addRule(request, requestOptions) {
30092
30122
  const wireRequest = {
30093
30123
  term: convertTermArg(request.term),
30094
- antecedents: request.antecedents.map(convertTermArg),
30124
+ antecedents: convertAntecedents(request.antecedents, "antecedents"),
30095
30125
  certainty: request.certainty,
30096
30126
  aggregator: request.aggregator
30097
30127
  };
@@ -30099,7 +30129,7 @@ var InferenceClient = class {
30099
30129
  AddRuleRequestFromFrontToApi(wireRequest),
30100
30130
  toRequestParams(requestOptions)
30101
30131
  );
30102
- return decodeResponse(response, AddRuleResponseFromApiToFront);
30132
+ return withRuleEtag(decodeResponse(response, AddRuleResponseFromApiToFront), response.headers);
30103
30133
  }
30104
30134
  /**
30105
30135
  * Run every check {@link InferenceClient.addRule} runs — without writing.
@@ -30108,6 +30138,8 @@ var InferenceClient = class {
30108
30138
  * @returns Whether the write would accept it (`ok`), every refusal with the
30109
30139
  * status the write would answer, the NAF-safety warnings, and the rule as
30110
30140
  * the write would build it.
30141
+ * @throws {@link ValidationError} before the request is sent, when `antecedents` is
30142
+ * not an array (a request built from untyped data) — `field` is `antecedents`.
30111
30143
  * @throws {ApiError} If the request itself fails.
30112
30144
  *
30113
30145
  * @remarks
@@ -30132,7 +30164,7 @@ var InferenceClient = class {
30132
30164
  async validateRule(request, requestOptions) {
30133
30165
  const wireRequest = {
30134
30166
  term: convertTermArg(request.term),
30135
- antecedents: request.antecedents.map(convertTermArg),
30167
+ antecedents: convertAntecedents(request.antecedents, "antecedents"),
30136
30168
  certainty: request.certainty,
30137
30169
  aggregator: request.aggregator
30138
30170
  };
@@ -30177,10 +30209,11 @@ var InferenceClient = class {
30177
30209
  * @param requestOptions - Per-call request options.
30178
30210
  * @returns What was written, and what was refused: `ruleTermIds` and
30179
30211
  * `rulesAdded` for the accepted rules, `rejected` naming each refused one.
30180
- * @throws {@link ApiError} 422 when the body is malformed (for example a row
30181
- * with no `antecedents` key) — a 422 never means a refused row.
30212
+ * @throws {@link ApiError} 422 when the body is malformed — a 422 never
30213
+ * means a refused row.
30182
30214
  * @throws {@link ValidationError} before the request is sent, when a rule's
30183
- * term cannot be encoded — `field` names it as `rules[k].term` or
30215
+ * term cannot be encoded, or a row has no `antecedents` array — `field`
30216
+ * names it as `rules[k].term`, `rules[k].antecedents` or
30184
30217
  * `rules[k].antecedents[i]`.
30185
30218
  *
30186
30219
  * @remarks
@@ -30195,7 +30228,8 @@ var InferenceClient = class {
30195
30228
  * number submitted. A row with an empty `antecedents` list is refused per
30196
30229
  * row this way (`rule rejected: a rule needs at least one antecedent; …`)
30197
30230
  * and is not counted in `rulesAdded` or `ruleTermIds`; a row with no
30198
- * `antecedents` key fails the whole batch with a 422. A rule that closes a
30231
+ * `antecedents` array is refused before the request is sent, with a
30232
+ * `ValidationError` whose `field` is `rules[k].antecedents`. A rule that closes a
30199
30233
  * NEW cycle through negation is refused the same way (the reason names the
30200
30234
  * cycle's sorts), decided for every row before any row is written.
30201
30235
  *
@@ -30209,9 +30243,9 @@ var InferenceClient = class {
30209
30243
  */
30210
30244
  async bulkAddRules(request, requestOptions) {
30211
30245
  const wireRequest = {
30212
- rules: request.rules.map((r) => ({
30246
+ rules: request.rules.map((r, k) => ({
30213
30247
  term: convertTermArg(r.term),
30214
- antecedents: r.antecedents.map(convertTermArg),
30248
+ antecedents: convertAntecedents(r.antecedents, `rules[${k}].antecedents`),
30215
30249
  certainty: r.certainty,
30216
30250
  aggregator: r.aggregator
30217
30251
  }))
@@ -30321,8 +30355,8 @@ var InferenceClient = class {
30321
30355
  * @param ruleId - Term id of the rule (its conclusion), as returned by
30322
30356
  * {@link InferenceClient.addRule} or {@link InferenceClient.getRules}.
30323
30357
  * @param options - `derivations` decides what happens to the conclusions the
30324
- * rule derived (defaults to `'refuse'`); `ifMatch` is the ETag of the
30325
- * rule's term, sent as the `If-Match` header.
30358
+ * rule derived (defaults to `'refuse'`); `ifMatch` is the rule's content
30359
+ * tag, sent as the `If-Match` header.
30326
30360
  * @param requestOptions - Per-call request options.
30327
30361
  * @returns What the withdrawal removed, tier by tier.
30328
30362
  * @throws {@link ApiError} 400 if the id names a fact rather than a rule, or
@@ -30351,14 +30385,16 @@ var InferenceClient = class {
30351
30385
  * conclusions are resident is refused too; `'retract'` removes them and
30352
30386
  * {@link RuleWithdrawalReport.consequencesInvalidated} counts them.
30353
30387
  *
30354
- * **Optimistic concurrency.** The rule routes send no ETag of their own.
30355
- * A rule's id is its conclusion term's id, so read the tag with
30356
- * `client.terms.getTerm(ruleId)` and pass its `etag` as `ifMatch`; a rule
30357
- * edited since answers 412.
30388
+ * **Optimistic concurrency.** Read the rule's tag from
30389
+ * {@link AddRuleResponse.etag}, {@link ReplaceRuleResponse.etag} or the
30390
+ * listing's {@link RuleEntryDto.etag} ({@link InferenceClient.getRules}),
30391
+ * and pass it as `ifMatch`; a rule edited since answers 412. The term route
30392
+ * does not serve it: `client.terms.getTerm(ruleId)` answers 404 for a rule.
30358
30393
  *
30359
30394
  * @example
30360
30395
  * ```typescript
30361
- * const { etag } = await client.terms.getTerm(ruleId);
30396
+ * const { rules } = await client.inference.getRules();
30397
+ * const etag = rules.find((rule) => rule.ruleId === ruleId)?.etag;
30362
30398
  * const report = await client.inference.deleteRule(ruleId, {
30363
30399
  * derivations: 'retract',
30364
30400
  * ifMatch: etag,
@@ -30379,11 +30415,12 @@ var InferenceClient = class {
30379
30415
  *
30380
30416
  * @param ruleId - Term id of the rule (its conclusion) to replace.
30381
30417
  * @param request - The replacement rule, in the same shape
30382
- * {@link InferenceClient.addRule} takes, plus `ifMatch`: the ETag of the
30383
- * outgoing rule's term, sent as the `If-Match` header and never in the body.
30418
+ * {@link InferenceClient.addRule} takes, plus `ifMatch`: the content tag
30419
+ * of the outgoing rule, sent as the `If-Match` header and never in the body.
30384
30420
  * @param requestOptions - Per-call request options.
30385
30421
  * @returns The replacement, the id it replaced, what the withdrawal removed,
30386
- * and how the rule base's guarantees moved.
30422
+ * and how the rule base's guarantees moved; `etag` is the replacement's
30423
+ * content tag when the engine sends the `ETag` header.
30387
30424
  * @throws {@link ApiError} 422 if the replacement is rejected by the
30388
30425
  * authoring guards — in which case the original rule is left live. An
30389
30426
  * empty `antecedents` list is one such refusal (`rule rejected: a rule
@@ -30394,7 +30431,8 @@ var InferenceClient = class {
30394
30431
  * @throws {@link PreconditionRequiredError} 428 when `ifMatch` is omitted
30395
30432
  * and the engine runs with `OSFKB_REQUIRE_IF_MATCH=1`.
30396
30433
  * @throws {@link ValidationError} before the request is sent, when a term
30397
- * cannot be encoded — `field` names it (`term`, `antecedents[i]`).
30434
+ * cannot be encoded, or `antecedents` is not an array — `field` names it
30435
+ * (`term`, `antecedents`, `antecedents[i]`).
30398
30436
  *
30399
30437
  * @remarks
30400
30438
  * A rule's id IS its conclusion term id, so an edit changes it by
@@ -30406,16 +30444,23 @@ var InferenceClient = class {
30406
30444
  * addresses a single clause.
30407
30445
  *
30408
30446
  * `ifMatch` guards the edit exactly as it guards
30409
- * {@link InferenceClient.deleteRule}: read the tag with
30410
- * `client.terms.getTerm(ruleId)`.
30447
+ * {@link InferenceClient.deleteRule}: read the tag from
30448
+ * {@link AddRuleResponse.etag}, a previous {@link ReplaceRuleResponse.etag}
30449
+ * or the listing's {@link RuleEntryDto.etag}. The response's own `etag` is
30450
+ * the REPLACEMENT's tag, the `ifMatch` for the next edit.
30411
30451
  *
30412
30452
  * **Serialization format**: untagged `TermInputDto` / `FeatureInputValueDto`.
30413
30453
  *
30414
30454
  * @example
30415
30455
  * ```typescript
30416
- * const result = await client.inference.replaceRule(ruleId, {
30456
+ * const created = await client.inference.addRule({
30457
+ * term: psi('senior', { name: Var('N') }),
30458
+ * antecedents: [psi('person', { name: Var('N') })],
30459
+ * });
30460
+ * const result = await client.inference.replaceRule(created.term.termId, {
30417
30461
  * term: psi('retiree', { name: Var('N') }),
30418
30462
  * antecedents: [psi('person', { name: Var('N') })],
30463
+ * ifMatch: created.etag,
30419
30464
  * });
30420
30465
  * console.log(result.previousRuleId, '->', result.term.termId);
30421
30466
  * if (result.certification.regressed) {
@@ -30426,7 +30471,7 @@ var InferenceClient = class {
30426
30471
  async replaceRule(ruleId, request, requestOptions) {
30427
30472
  const wireRequest = {
30428
30473
  term: convertTermArg(request.term),
30429
- antecedents: request.antecedents.map(convertTermArg),
30474
+ antecedents: convertAntecedents(request.antecedents, "antecedents"),
30430
30475
  certainty: request.certainty,
30431
30476
  aggregator: request.aggregator
30432
30477
  };
@@ -30435,7 +30480,10 @@ var InferenceClient = class {
30435
30480
  AddRuleRequestFromFrontToApi(wireRequest),
30436
30481
  ifMatchParams(request.ifMatch, requestOptions)
30437
30482
  );
30438
- return decodeResponse(response, ReplaceRuleResponseFromApiToFront);
30483
+ return withRuleEtag(
30484
+ decodeResponse(response, ReplaceRuleResponseFromApiToFront),
30485
+ response.headers
30486
+ );
30439
30487
  }
30440
30488
  /**
30441
30489
  * Query for matching data by searching rules and facts backwards from a goal pattern.
@@ -30933,6 +30981,16 @@ var InferenceClient = class {
30933
30981
  function convertTermArg(input) {
30934
30982
  return isPsiTermInput(input) ? toTermInputDto(input) : input;
30935
30983
  }
30984
+ function convertAntecedents(antecedents, field) {
30985
+ if (!Array.isArray(antecedents)) {
30986
+ throw new ValidationError(`${field} must be an array of terms`, field);
30987
+ }
30988
+ return antecedents.map(convertTermArg);
30989
+ }
30990
+ function withRuleEtag(body, headers) {
30991
+ const etag = headers.get("etag");
30992
+ return etag === null ? body : { ...body, etag };
30993
+ }
30936
30994
 
30937
30995
  // src/normalizers/query.ts
30938
30996
  function TermPatternDtoFromFrontToApi(model) {
@@ -37217,6 +37275,7 @@ function DocumentReceiptFromApiToFront(dto) {
37217
37275
  function SessionDocumentFromApiToFront(dto) {
37218
37276
  const out = { documentId: dto.document_id, status: dto.status };
37219
37277
  if (dto.error != null) out.error = dto.error;
37278
+ if (dto.error_code != null) out.errorCode = dto.error_code;
37220
37279
  if (dto.receipt != null) out.receipt = DocumentReceiptFromApiToFront(dto.receipt);
37221
37280
  return out;
37222
37281
  }
@@ -37330,6 +37389,7 @@ function DocumentStatsDtoFromApiToFront(dto) {
37330
37389
  documentId: dto.document_id,
37331
37390
  documentTermId: dto.document_term_id ?? void 0,
37332
37391
  entitiesExtracted: dto.entities_extracted,
37392
+ entitiesRefused: dto.entities_refused.map(RefusedEntityDtoFromApiToFront),
37333
37393
  processingTimeMs: dto.processing_time_ms,
37334
37394
  relationsExtracted: dto.relations_extracted,
37335
37395
  relationsIntegrated: dto.relations_integrated,
@@ -43048,8 +43108,8 @@ function MaterializeScenarioRequestFromFrontToApi(model) {
43048
43108
  return {
43049
43109
  // The prefix keys are data (`''`, `myOnt`), copied verbatim.
43050
43110
  prefixes: model.prefixes === void 0 ? void 0 : { ...model.prefixes },
43051
- // Accepted: the scenario is opaque user data sent verbatim (RAW_BODY_HEADER,
43052
- // #39); the engine validates its shape, so the SDK does not re-type it.
43111
+ // The scenario is user data sent verbatim (RAW_BODY_HEADER, #39): every
43112
+ // key reaches the engine under the spelling the caller wrote.
43053
43113
  scenario: model.scenario
43054
43114
  };
43055
43115
  }
@@ -51179,10 +51239,14 @@ function LayoutSurfaceDtoFromApiToFront(dto) {
51179
51239
  slots: dto.slots
51180
51240
  };
51181
51241
  }
51242
+ function DataLoadErrorFromApiToFront(dto) {
51243
+ return { code: dto.code, message: dto.message, query: dto.query };
51244
+ }
51182
51245
  function UIAssemblyStatsDtoFromApiToFront(dto) {
51183
51246
  return {
51184
51247
  componentCount: dto.component_count,
51185
51248
  dataRows: dto.data_rows ?? void 0,
51249
+ dataLoadError: dto.data_load_error ? DataLoadErrorFromApiToFront(dto.data_load_error) : void 0,
51186
51250
  includedFeatures: dto.included_features,
51187
51251
  osfqlExecuted: dto.osfql_executed ?? void 0,
51188
51252
  sortName: dto.sort_name,
@@ -51331,6 +51395,9 @@ function UIGenerateResponseFromApiToFront(dto) {
51331
51395
  if (dto.data_sources !== void 0) {
51332
51396
  result.dataSources = dto.data_sources.map(UIDataSourcePayloadFromApiToFront);
51333
51397
  }
51398
+ if (dto.data_load_errors !== void 0) {
51399
+ result.dataLoadErrors = dto.data_load_errors.map(DataLoadErrorFromApiToFront);
51400
+ }
51334
51401
  if (dto.intents !== void 0) result.intents = dto.intents.map(UIGenerateIntentFromApiToFront);
51335
51402
  if (dto.trace != null) result.trace = dto.trace.map(UIPipelineStageTraceFromApiToFront);
51336
51403
  return result;
@@ -51578,6 +51645,34 @@ function ReasoningTraceDtoFromApiToFront(dto) {
51578
51645
  llmCalls: dto.llm_calls
51579
51646
  };
51580
51647
  }
51648
+ function ConversationNoticeFromApiToFront(dto) {
51649
+ switch (dto.kind) {
51650
+ case "pruned_features":
51651
+ return {
51652
+ kind: dto.kind,
51653
+ message: dto.message,
51654
+ skipped: dto.skipped.map((s) => ({ feature: s.feature, sort: s.sort }))
51655
+ };
51656
+ case "value_grounding":
51657
+ return {
51658
+ kind: dto.kind,
51659
+ message: dto.message,
51660
+ substitutions: dto.substitutions.map((s) => ({
51661
+ feature: s.feature,
51662
+ from: s.from,
51663
+ sort: s.sort,
51664
+ to: s.to
51665
+ }))
51666
+ };
51667
+ case "retrieval_rescue":
51668
+ return {
51669
+ kind: dto.kind,
51670
+ message: dto.message,
51671
+ recordCount: dto.record_count,
51672
+ sorts: [...dto.sorts]
51673
+ };
51674
+ }
51675
+ }
51581
51676
  function ConversationMessageResponseFromApiToFront(dto) {
51582
51677
  return {
51583
51678
  assistantMessage: dto.assistant_message,
@@ -51591,6 +51686,7 @@ function ConversationMessageResponseFromApiToFront(dto) {
51591
51686
  producedTermIds: dto.produced_term_ids,
51592
51687
  uiSortId: dto.ui_sort_id ?? void 0,
51593
51688
  suggestions: dto.suggestions,
51689
+ notices: dto.notices.map(ConversationNoticeFromApiToFront),
51594
51690
  claimAnnotations: dto.claim_annotations?.map(ClaimAnnotationDtoFromApiToFront) ?? void 0,
51595
51691
  proofTrace: dto.proof_trace ? ProofTraceNodeDtoFromApiToFront(dto.proof_trace) : void 0,
51596
51692
  uiCustomizations: dto.ui_customizations?.map(UICustomizationDtoFromApiToFront) ?? void 0,
@@ -51613,7 +51709,7 @@ function isJsonObject2(value) {
51613
51709
  }
51614
51710
  function isConversationMessageResponseDto(value) {
51615
51711
  if (!isJsonObject2(value)) return false;
51616
- return typeof Reflect.get(value, "assistant_message") === "string" && typeof Reflect.get(value, "conversation_id") === "string" && typeof Reflect.get(value, "intent") === "string" && typeof Reflect.get(value, "turn_id") === "string" && Array.isArray(Reflect.get(value, "produced_term_ids")) && Array.isArray(Reflect.get(value, "suggestions"));
51712
+ return typeof Reflect.get(value, "assistant_message") === "string" && typeof Reflect.get(value, "conversation_id") === "string" && typeof Reflect.get(value, "intent") === "string" && typeof Reflect.get(value, "turn_id") === "string" && Array.isArray(Reflect.get(value, "produced_term_ids")) && Array.isArray(Reflect.get(value, "suggestions")) && Array.isArray(Reflect.get(value, "notices"));
51617
51713
  }
51618
51714
  function decodeConversationMessage(payload) {
51619
51715
  return isConversationMessageResponseDto(payload) ? ConversationMessageResponseFromApiToFront(payload) : null;
@@ -51966,6 +52062,37 @@ var ConversationClient = class {
51966
52062
  });
51967
52063
  return decodeResponse(response, ListConversationsResponseFromApiToFront);
51968
52064
  }
52065
+ /**
52066
+ * Read one conversation's summary: the row {@link listConversations}
52067
+ * returns for it.
52068
+ *
52069
+ * @param conversationId - The conversation ID.
52070
+ * @param requestOptions - Per-call transport overrides.
52071
+ * @returns The summary, with its `kind` and `title`.
52072
+ * @throws {BadRequestError} `400` if the ID is malformed.
52073
+ * @throws {NotFoundError} `404` if the conversation is not the caller's.
52074
+ * @throws {ApiError} If the request fails.
52075
+ *
52076
+ * @remarks
52077
+ * Uses GET `/api/v1/conversation/{id}`. A caller that resumes a conversation
52078
+ * by ID learns its `kind` and `title` here without reading the whole listing.
52079
+ *
52080
+ * @example
52081
+ * ```typescript
52082
+ * const summary = await client.conversation.getConversation('conv-uuid');
52083
+ * console.log(`${summary.kind}: ${summary.title ?? '(untitled)'}`);
52084
+ * ```
52085
+ */
52086
+ async getConversation(conversationId, requestOptions) {
52087
+ const response = await this.http.request({
52088
+ ...toRequestParams(requestOptions),
52089
+ path: `/api/v1/conversation/${encodeURIComponent(conversationId)}`,
52090
+ method: "GET",
52091
+ secure: true,
52092
+ format: "json"
52093
+ });
52094
+ return decodeResponse(response, ConversationSummaryDtoFromApiToFront);
52095
+ }
51969
52096
  /**
51970
52097
  * List the registered comparison models so the UI can populate a
51971
52098
  * selector / compare panel.
@@ -53513,10 +53640,12 @@ var UiClient = class {
53513
53640
  * keys inside them — `params`, `props_override`, a `component`'s `props`
53514
53641
  * (`dataKey`) and `initial_values` — reach the engine exactly as written.
53515
53642
  *
53516
- * The data load runs read-only OSFQL. A query that writes the store is
53517
- * refused without an exception: the answer's `stats.osfqlExecuted` starts
53518
- * with `FAILED:` (`FAILED: <query> — a data load runs read-only OSFQL, and this query writes the store; run it through POST /api/v1/ui/action or POST /api/v1/osfql`) and no rows load. Read a `FAILED:` value as a refused
53519
- * load, not as an empty result.
53643
+ * The data load runs read-only OSFQL. A load that fails, including a query
53644
+ * that writes the store, does not throw: the view renders without rows,
53645
+ * `stats.dataLoadError` carries the typed `code`, the `message` and the
53646
+ * `query`, and `stats.osfqlExecuted` is absent. Branch on `code`
53647
+ * (`data_load_writes`, `osfql_parse_error`, `osfql_compile_error`,
53648
+ * `osfql_execution_failed`), not on the message.
53520
53649
  *
53521
53650
  * A data view (table, graph, chart, map, timeline, matrix) names in
53522
53651
  * `props.rowKey` the column in which each loaded row carries its term's id.
@@ -53556,8 +53685,8 @@ var UiClient = class {
53556
53685
  * `delete_record` template, is not a UUID; if a `"sort_ref"` field's sort
53557
53686
  * declares no entity range; if `sortName` names no sort of the tenant or
53558
53687
  * contains a backtick; if `values` names a feature the sort does not
53559
- * declare; if an `update_form`'s term is held under another sort than
53560
- * `sortName`; or if the request is malformed otherwise.
53688
+ * declare; if an `update_form` names a term the tenant does not hold, or a
53689
+ * term whose own sort `sortName` does not subsume; or if the request is malformed otherwise.
53561
53690
  * @throws {ApiError} If the request fails otherwise.
53562
53691
  *
53563
53692
  * @remarks
@@ -53627,8 +53756,8 @@ var UiClient = class {
53627
53756
  * endpoint abstains with live-schema suggestions. Data rows always come from OSFQL
53628
53757
  * execution after certification — never from the model. The data source runs
53629
53758
  * read-only OSFQL: a load query that writes the store is refused without an
53630
- * exception, and the load reports `FAILED: <query> — a data load runs read-only
53631
- * OSFQL, …` instead of rows.
53759
+ * exception, and the failure is a `dataLoadErrors` entry (typed `code`,
53760
+ * `message`, `query`) instead of rows.
53632
53761
  *
53633
53762
  * A certified single-pattern data query is bound to its rows' term ids: the
53634
53763
  * engine adds the identity binding to its root pattern (a note in
@@ -60776,8 +60905,9 @@ var AguiClient = class {
60776
60905
  *
60777
60906
  * A data load the run performs executes read-only OSFQL. A load query that
60778
60907
  * writes the store is refused without an exception or a `RUN_ERROR`: the
60779
- * load reports `FAILED: <query> — a data load runs read-only OSFQL, …` in
60780
- * place of rows.
60908
+ * run emits a `CUSTOM` event named `osfkb.data_load_error` whose `value` is
60909
+ * `{ code, message, query }`, and the `STATE_SNAPSHOT` carries the same
60910
+ * object at `osfkb.dataLoadError`; branch on `code`. No rows are loaded.
60781
60911
  *
60782
60912
  * @example
60783
60913
  * ```typescript