@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.d.ts CHANGED
@@ -109,7 +109,7 @@ type JsonValue$1 = string | number | boolean | null | JsonValue$1[] | object;
109
109
  * This is the single source of truth for the version constant.
110
110
  * The `scripts/release.sh` script updates this value alongside `package.json`.
111
111
  */
112
- declare const SDK_VERSION = "1.25.0";
112
+ declare const SDK_VERSION = "1.26.0";
113
113
  /**
114
114
  * Authentication mode for the SDK.
115
115
  *
@@ -2532,8 +2532,17 @@ interface BeliefDto$1 {
2532
2532
  */
2533
2533
  sort_id?: string | null;
2534
2534
  }
2535
- /** Binary operator for expressions */
2536
- type BinaryOperatorDto$1 = "Add" | "Subtract" | "Multiply" | "Divide";
2535
+ /**
2536
+ * Binary operator for expressions.
2537
+ *
2538
+ * The full algebra the domain's `BinaryOperator` carries, not a subset of it.
2539
+ * Four arithmetic operators were declared here while the engine had fourteen,
2540
+ * and OSFQL `DERIVE` builds function bodies with every one of them
2541
+ * (`osfql/executor.rs`, `ir_expression_to_function_expr`) — so a definition
2542
+ * created that way could not be expressed in this shape, and a read that
2543
+ * answered in this shape had to either drop it or lie about it (#235).
2544
+ */
2545
+ type BinaryOperatorDto$1 = "Add" | "Subtract" | "Multiply" | "Divide" | "Modulo" | "LessThan" | "LessThanOrEqual" | "GreaterThan" | "GreaterThanOrEqual" | "Equal" | "NotEqual" | "And" | "Or";
2537
2546
  /** Request to bind a sort to a SQL table. */
2538
2547
  interface BindSortRequest$1 {
2539
2548
  /** Column mappings: feature name to column spec. */
@@ -5574,6 +5583,22 @@ interface CondResponse$1 {
5574
5583
  condition_succeeded: boolean;
5575
5584
  success: boolean;
5576
5585
  }
5586
+ /**
5587
+ * One `WHEN cond THEN value` branch of a conditional expression.
5588
+ *
5589
+ * The domain carries these as an unnamed `(Expression, Expression)` pair.
5590
+ * A two-element JSON array would round-trip just as well and read as nothing
5591
+ * at all, so the wire shape names both halves.
5592
+ */
5593
+ interface ConditionalBranchDto$1 {
5594
+ /**
5595
+ * The value of the whole conditional when this is the first branch whose
5596
+ * condition is `true`.
5597
+ */
5598
+ then: ExpressionDto$1;
5599
+ /** The condition, evaluated in source order against the clause's bindings. */
5600
+ when: ExpressionDto$1;
5601
+ }
5577
5602
  interface ConditionalIndependenceRequest$1 {
5578
5603
  /** Conditioning set */
5579
5604
  conditioning_set: string[];
@@ -10694,7 +10719,16 @@ type ExpressionDto$1 = {
10694
10719
  } | {
10695
10720
  /** Arithmetic/logical expression */
10696
10721
  left: ExpressionDto$1;
10697
- /** Binary operator for expressions */
10722
+ /**
10723
+ * Binary operator for expressions.
10724
+ *
10725
+ * The full algebra the domain's `BinaryOperator` carries, not a subset of it.
10726
+ * Four arithmetic operators were declared here while the engine had fourteen,
10727
+ * and OSFQL `DERIVE` builds function bodies with every one of them
10728
+ * (`osfql/executor.rs`, `ir_expression_to_function_expr`) — so a definition
10729
+ * created that way could not be expressed in this shape, and a read that
10730
+ * answered in this shape had to either drop it or lie about it (#235).
10731
+ */
10698
10732
  op: BinaryOperatorDto$1;
10699
10733
  /** Arithmetic/logical expression */
10700
10734
  right: ExpressionDto$1;
@@ -10703,6 +10737,16 @@ type ExpressionDto$1 = {
10703
10737
  arguments: ExpressionDto$1[];
10704
10738
  function_name: string;
10705
10739
  type: "FunctionCall";
10740
+ } | {
10741
+ /** Unary operator for expressions. */
10742
+ op: UnaryOperatorDto$1;
10743
+ /** Arithmetic/logical expression */
10744
+ operand: ExpressionDto$1;
10745
+ type: "UnaryOp";
10746
+ } | {
10747
+ branches: ConditionalBranchDto$1[];
10748
+ default?: null | ExpressionDto$1;
10749
+ type: "Conditional";
10706
10750
  };
10707
10751
  /** Extended agent state DTO with full cognitive state. */
10708
10752
  interface ExtendedAgentStateDto$1 {
@@ -12150,6 +12194,14 @@ type FunctionCallersDisposition$1 = "refuse" | "orphan";
12150
12194
  interface FunctionClauseDto$1 {
12151
12195
  /** Function body - what to compute */
12152
12196
  body: FunctionBodyDto$1;
12197
+ /**
12198
+ * The clause's guard, if it has one.
12199
+ *
12200
+ * Omitted rather than serialized as `null` when absent, so what
12201
+ * `GET /api/v1/functions/{name}` emits is byte-for-byte a body
12202
+ * `register` and `PUT` accept (#235). An explicit `"guard": null` is
12203
+ * still accepted on the way in.
12204
+ */
12153
12205
  guard?: null | GuardDto;
12154
12206
  parameters: PatternDto$1[];
12155
12207
  }
@@ -12165,6 +12217,26 @@ interface FunctionDraftDto$1 {
12165
12217
  }
12166
12218
  /** Execution kind for a registered function. */
12167
12219
  type FunctionKindDto$1 = "Classic" | "Neural";
12220
+ /**
12221
+ * Why a registered function cannot be replaced, in the same terms the
12222
+ * mutation route would answer with.
12223
+ *
12224
+ * Mirrors `RuleNotWithdrawableDto`: the read tells a client what the write
12225
+ * would say, so a UI can present the function without offering an edit that
12226
+ * is going to be refused.
12227
+ */
12228
+ interface FunctionNotReplaceableDto$1 {
12229
+ /**
12230
+ * The stable machine-readable discriminator `PUT` and `DELETE` carry —
12231
+ * currently `function_plugin_owned`.
12232
+ */
12233
+ code: string;
12234
+ /**
12235
+ * The refusal in words, naming the lifecycle operation that DOES remove
12236
+ * the function.
12237
+ */
12238
+ reason: string;
12239
+ }
12168
12240
  /**
12169
12241
  * Typed signature summary for a single registered function.
12170
12242
  *
@@ -13176,6 +13248,87 @@ interface GetFactsResponse$1 {
13176
13248
  /** List of facts */
13177
13249
  facts: PsiTermDto$1[];
13178
13250
  }
13251
+ /**
13252
+ * Response of `GET /api/v1/functions/{name}` — the registered definition.
13253
+ *
13254
+ * # Why the clauses come back in the register shape
13255
+ *
13256
+ * `PUT /api/v1/functions/{name}` reports what it displaced — `previous`,
13257
+ * `current`, `arity_changed`, every caller — and all of that describes the
13258
+ * change AFTER it happened. Nothing let a caller see what they were about to
13259
+ * overwrite, so a client editing one clause of a three-clause function had to
13260
+ * re-author the other two from memory (#235).
13261
+ *
13262
+ * [`Self::clauses`] is therefore the exact payload
13263
+ * `PUT /api/v1/functions/{name}` and `POST /api/v1/functions/register` accept:
13264
+ * a read-modify-write is an edit, not a re-authoring, and needs no
13265
+ * translation layer that could drop a body variant on the way through.
13266
+ *
13267
+ * # And why `clauses` is optional
13268
+ *
13269
+ * The clause shape is total over every construct the engine can currently
13270
+ * build — that is what widening `BinaryOperatorDto` and `ExpressionDto` was
13271
+ * for. It is NOT total over the domain's `Value`, which carries Ψ-terms,
13272
+ * lists, geometries and more that no function producer emits.
13273
+ *
13274
+ * If one ever appears, the read declines to describe it rather than
13275
+ * degrading it to `Uninstantiated`: `clauses` is absent,
13276
+ * [`Self::unrepresentable`] names what stopped it, and the signature fields
13277
+ * still answer. A wrong definition presented as a right one is the failure
13278
+ * this route exists to prevent, and a `PUT` of it would destroy the real one.
13279
+ */
13280
+ interface GetFunctionResponse$1 {
13281
+ /**
13282
+ * The number of named arguments it accepts.
13283
+ * @min 0
13284
+ */
13285
+ arity: number;
13286
+ /**
13287
+ * Everything that calls this function, by the same scan `DELETE` refuses
13288
+ * on and `PUT` reports.
13289
+ *
13290
+ * Read before offering an edit: a replacement that changes the arity
13291
+ * keeps every one of these resolvable and makes every one of them wrong.
13292
+ */
13293
+ callers?: FunctionCallerDto[];
13294
+ /**
13295
+ * The pattern-matched clauses, tried in order — in the shape
13296
+ * `register` and `PUT` accept.
13297
+ *
13298
+ * Absent only when the definition holds a construct this shape cannot
13299
+ * express, in which case [`Self::unrepresentable`] says which.
13300
+ */
13301
+ clauses?: FunctionClauseDto$1[] | null;
13302
+ /**
13303
+ * Its stable id, as the registration reported it.
13304
+ * @format uuid
13305
+ */
13306
+ function_id: string;
13307
+ /** Whether it is classical or neural/fuzzy. */
13308
+ kind: FunctionKindDto$1;
13309
+ /** The function's name — the key `POST /functions/evaluate` takes. */
13310
+ name: string;
13311
+ /**
13312
+ * When [`Self::replaceable`] is false, the refusal a `PUT` would produce
13313
+ * — the same `code` and the same prose. Absent otherwise.
13314
+ */
13315
+ not_replaceable?: null | FunctionNotReplaceableDto$1;
13316
+ /**
13317
+ * Whether `PUT`/`DELETE` on this function will act rather than refuse.
13318
+ *
13319
+ * Read through the same admission the mutation routes run, so the read
13320
+ * and the refusal cannot disagree. The engine stays the authority: a
13321
+ * state change between this read and the write can still refuse.
13322
+ */
13323
+ replaceable: boolean;
13324
+ /**
13325
+ * What stopped the definition being expressed in the register shape.
13326
+ *
13327
+ * Absent — not empty — on the ordinary read. Present with `clauses`
13328
+ * absent, never both.
13329
+ */
13330
+ unrepresentable?: string | null;
13331
+ }
13179
13332
  /** Request to read the fuzzy subsumption degree `sub ⊑· sup` */
13180
13333
  interface GetFuzzySubsumptionRequest {
13181
13334
  /**
@@ -30279,6 +30432,8 @@ interface UiAffinityDoc {
30279
30432
  }
30280
30433
  /** Complete hierarchy of UI component sorts */
30281
30434
  type UiSort$1 = "app" | "page" | "dashboard" | "grid" | "flex" | "stack" | "box" | "card" | "divider" | "spacer" | "navbar" | "sidebar" | "tabs" | "tab_panel" | "breadcrumbs" | "menu" | "menu_item" | "link" | "router" | "route" | "data_table" | "column" | "list" | "list_item" | "tree" | "tree_node" | "chart" | "stat" | "badge" | "avatar" | "icon" | "image" | "video" | "text" | "heading" | "paragraph" | "code" | "markdown" | "label" | "form" | "form_field" | "input" | "textarea" | "select" | "option" | "checkbox" | "radio" | "radio_group" | "toggle" | "slider" | "date_picker" | "time_picker" | "date_range_picker" | "file_upload" | "color_picker" | "autocomplete" | "search_input" | "button" | "button_group" | "icon_button" | "fab" | "dropdown_button" | "modal" | "dialog" | "drawer" | "popover" | "tooltip" | "toast" | "alert" | "progress" | "spinner" | "skeleton" | "accordion" | "accordion_item" | "collapsible" | "carousel" | "drag_drop_zone" | "draggable" | "drop_target" | "resizable" | "sortable_list" | "command_palette" | "wizard" | "wizard_step" | "timeline" | "timeline_item" | "kanban_board" | "kanban_column" | "kanban_card" | "calendar" | "rich_text_editor" | "conditional" | "for_each" | "show" | "suspense" | "error_boundary" | "portal" | "data_source" | "computed" | "state" | "effect" | "on_event" | "on_click" | "on_submit" | "on_change" | "sequence" | "navigate" | "api_call" | "set_state" | "show_toast" | "open_modal" | "close_modal" | "animate" | "transition" | "keyframes" | "auth_provider" | "protected_route" | "login_form" | "logout_button" | "user_profile" | "permission_gate" | "session_timeout" | "i18n_provider" | "trans" | "language_switcher" | "locale_date" | "locale_number" | "locale_currency" | "bidi" | "responsive" | "show_on_breakpoint" | "hide_on_breakpoint" | "container_query" | "aspect_ratio" | "theme_provider" | "theme_toggle" | "css_var" | "styled" | "color_scheme" | "screen_reader_only" | "skip_link" | "focus_trap" | "live_region" | "keyboard_nav" | "accessible_label" | "focus_ring" | "virtual_list" | "virtual_grid" | "virtual_table" | "infinite_scroll" | "lazy_load" | "code_split" | "prefetch" | "offline_indicator" | "sync_status" | "cache_control" | "background_sync" | "install_prompt" | "update_available" | "undo_provider" | "undo_button" | "redo_button" | "history_browser" | "snapshot" | "restore_point" | "hotkey" | "shortcut_hint" | "key_combo" | "shortcut_scope" | "global_search" | "search_results" | "search_highlight" | "search_filters" | "recent_searches" | "copy_button" | "paste_handler" | "share_button" | "qr_code" | "export_button" | "print_button" | "print_only" | "screen_only" | "pdf_preview" | "presence_indicator" | "cursor_overlay" | "typing_indicator" | "conflict_resolver" | "realtime_diff" | "notification_center" | "push_notification" | "inbox" | "unread_badge" | "notification_settings" | "debug_panel" | "state_inspector" | "perf_monitor" | "network_inspector" | "error_reporter" | "position" | "layer" | "overlay" | "fixed" | "sticky" | "form_state_provider" | "field_error" | "validation_schema" | "async_validator" | "cross_field_validation" | "pagination" | "cursor_pagination" | "load_more" | "page_size_selector" | "search_params" | "route_params" | "deep_link" | "url_state" | "query_binding" | "scroll_container" | "scroll_snap" | "scroll_lock" | "scroll_restore" | "scroll_to" | "scroll_spy" | "selection_provider" | "selectable" | "selection_actions" | "range_selection" | "gesture_handler" | "swipe_action" | "pinch_zoom" | "long_press" | "pan_gesture" | "multi_touch" | "file_download" | "file_preview" | "file_progress" | "file_browser" | "drop_zone" | "image_cropper" | "animation_controller" | "animation_timeline" | "spring" | "motion_value" | "animate_presence" | "stagger" | "focus_scope" | "focus_manager" | "auto_focus" | "restore_focus" | "merge_conflict" | "conflict_resolution" | "version_indicator" | "tenant_provider" | "tenant_switcher" | "tenant_branding" | "audit_log" | "activity_feed" | "change_history" | "feature_gate" | "feature_provider" | "beta_badge" | "experiment" | "variant" | "experiment_provider" | "analytics" | "page_view" | "click_tracker" | "event_tracker" | "rate_limit_indicator" | "maintenance_mode" | "system_status" | "scheduled_downtime" | "document_head" | "meta_tag" | "document_title" | "open_graph" | "structured_data" | "video_call" | "audio_call" | "screen_share" | "media_stream" | "camera_capture" | "audio_recorder" | "canvas2_d" | "web_g_l" | "drawing_canvas" | "signature_pad" | "geolocation" | "device_orientation" | "camera" | "barcode_scanner" | "local_storage_binding" | "session_storage_binding" | "indexed_db_binding";
30435
+ /** Unary operator for expressions. */
30436
+ type UnaryOperatorDto$1 = "Not" | "Negate";
30282
30437
  interface UncertainEdgeDto$1 {
30283
30438
  /** Possible directions */
30284
30439
  possible_directions: [string, string][];
@@ -56388,6 +56543,16 @@ declare class Functions<SecurityDataType = unknown> {
56388
56543
  * @secure
56389
56544
  */
56390
56545
  evaluateFunction: (data: EvaluateFunctionRequest$1, params?: RequestParams) => Promise<HttpResponse<EvaluateFunctionResponse$1, void>>;
56546
+ /**
56547
+ * @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.
56548
+ *
56549
+ * @tags functions
56550
+ * @name GetFunction
56551
+ * @summary Read one registered function's definition.
56552
+ * @request GET:/api/v1/functions/{name}
56553
+ * @secure
56554
+ */
56555
+ getFunction: (name: string, params?: RequestParams) => Promise<HttpResponse<GetFunctionResponse$1, void>>;
56391
56556
  /**
56392
56557
  * @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.
56393
56558
  *
@@ -56422,8 +56587,33 @@ declare class Functions<SecurityDataType = unknown> {
56422
56587
 
56423
56588
  /**
56424
56589
  * Binary operator for expressions within function bodies.
56590
+ *
56591
+ * @remarks
56592
+ * The whole algebra the engine carries, not the arithmetic corner of it. Four
56593
+ * operators were declared here while the engine had thirteen, and OSFQL
56594
+ * `DERIVE` builds function bodies with every one of them — so a definition
56595
+ * created that way could not be expressed in this shape, and a read that
56596
+ * answered in this shape had to drop it or lie about it (backend #235).
56425
56597
  */
56426
- type BinaryOperatorDto = 'Add' | 'Subtract' | 'Multiply' | 'Divide';
56598
+ type BinaryOperatorDto = 'Add' | 'Subtract' | 'Multiply' | 'Divide' | 'Modulo' | 'LessThan' | 'LessThanOrEqual' | 'GreaterThan' | 'GreaterThanOrEqual' | 'Equal' | 'NotEqual' | 'And' | 'Or';
56599
+ /** Unary operator for expressions within function bodies. */
56600
+ type UnaryOperatorDto = 'Not' | 'Negate';
56601
+ /**
56602
+ * One `WHEN cond THEN value` branch of a {@link ExpressionDto} `Conditional`.
56603
+ *
56604
+ * @remarks
56605
+ * The engine carries these as an unnamed pair; the wire names both halves,
56606
+ * because a two-element array round-trips as well and reads as nothing.
56607
+ */
56608
+ interface ConditionalBranchDto {
56609
+ /** The condition, evaluated in source order against the clause's bindings. */
56610
+ when: ExpressionDto;
56611
+ /**
56612
+ * The value of the whole conditional when this is the first branch whose
56613
+ * condition holds.
56614
+ */
56615
+ then: ExpressionDto;
56616
+ }
56427
56617
  /**
56428
56618
  * Value type for LIFE-style function literals.
56429
56619
  *
@@ -56467,6 +56657,16 @@ type ExpressionDto = {
56467
56657
  type: 'FunctionCall';
56468
56658
  functionName: string;
56469
56659
  arguments: ExpressionDto[];
56660
+ } | {
56661
+ type: 'UnaryOp';
56662
+ op: UnaryOperatorDto;
56663
+ operand: ExpressionDto;
56664
+ } | {
56665
+ type: 'Conditional';
56666
+ /** Branches, tried in order; the first whose `when` holds supplies the value. */
56667
+ branches: ConditionalBranchDto[];
56668
+ /** The value when no branch holds. `null` when the conditional has none. */
56669
+ default?: ExpressionDto | null;
56470
56670
  };
56471
56671
  /**
56472
56672
  * Function body — what a clause computes.
@@ -56817,6 +57017,112 @@ interface FunctionWithdrawalReport {
56817
57017
  */
56818
57018
  callersOrphaned: FunctionCaller[];
56819
57019
  }
57020
+ /**
57021
+ * Why a registered function cannot be replaced, in the terms the mutation
57022
+ * route would answer with.
57023
+ *
57024
+ * @remarks
57025
+ * The read tells a client what the write would say, so a surface can present
57026
+ * the function without offering an edit that is going to be refused.
57027
+ */
57028
+ interface FunctionNotReplaceableDto {
57029
+ /**
57030
+ * The stable machine-readable discriminator `PUT` and `DELETE` carry —
57031
+ * currently `'function_plugin_owned'`.
57032
+ */
57033
+ code: string;
57034
+ /** The refusal in words, naming the lifecycle operation that DOES remove it. */
57035
+ reason: string;
57036
+ }
57037
+ /**
57038
+ * The signature half of a read definition — everything that answers whether or
57039
+ * not the clauses could be expressed.
57040
+ */
57041
+ interface FunctionDefinitionSignature {
57042
+ /** The function's name — the key `POST /functions/evaluate` takes. */
57043
+ name: string;
57044
+ /** Its stable id, as the registration reported it. */
57045
+ functionId: string;
57046
+ /** The number of named arguments it accepts. */
57047
+ arity: number;
57048
+ /** Whether it is classical or neural/fuzzy. */
57049
+ kind: FunctionKindDto;
57050
+ /**
57051
+ * Whether `PUT`/`DELETE` on this function will act rather than refuse.
57052
+ *
57053
+ * Read through the same admission the mutation routes run, so the read and
57054
+ * the refusal cannot disagree. The engine stays the authority: a state
57055
+ * change between this read and the write can still refuse.
57056
+ */
57057
+ replaceable: boolean;
57058
+ /** The refusal a `PUT` would produce. Absent while `replaceable` is true. */
57059
+ notReplaceable?: FunctionNotReplaceableDto;
57060
+ /**
57061
+ * Everything that calls this function, by the same scan `DELETE` refuses on
57062
+ * and `PUT` reports.
57063
+ *
57064
+ * Read before offering an edit: a replacement that changes the arity keeps
57065
+ * every one of these resolvable and makes every one of them wrong. Empty
57066
+ * when nothing calls it.
57067
+ */
57068
+ callers: FunctionCaller[];
57069
+ }
57070
+ /**
57071
+ * One registered function's definition, as `GET /functions/{name}` answers it.
57072
+ *
57073
+ * @remarks
57074
+ * ## The clauses come back in the shape `PUT` takes
57075
+ *
57076
+ * The `clauses` of a readable definition are the exact payload
57077
+ * {@link FunctionsClient.registerFunction} and
57078
+ * {@link FunctionsClient.replaceFunction} accept, so a read-modify-write is an
57079
+ * edit rather than a re-authoring. That is the point of the route: `PUT`
57080
+ * replaces the WHOLE definition, so before it a client fixing one clause of a
57081
+ * three-clause function had to remember the other two or lose them.
57082
+ *
57083
+ * ## Withheld is not empty, and the type says so
57084
+ *
57085
+ * `clauses: []` is a function with no clauses. A definition holding a
57086
+ * construct the register shape cannot express comes back with no `clauses` at
57087
+ * all and an `unrepresentable` reason — the engine declines to describe it
57088
+ * rather than degrading it, because a `PUT` of a degraded read would destroy
57089
+ * the real definition.
57090
+ *
57091
+ * The two are modelled as a union rather than two optional fields, so a client
57092
+ * cannot read `clauses` without first ruling the withheld case out:
57093
+ *
57094
+ * ```typescript
57095
+ * const definition = await client.functions.getFunction('scale');
57096
+ * if (definition.clauses === undefined) {
57097
+ * console.warn(`cannot edit scale: ${definition.unrepresentable}`);
57098
+ * } else {
57099
+ * await client.functions.replaceFunction('scale', {
57100
+ * arity: definition.arity,
57101
+ * clauses: [...definition.clauses, extraClause],
57102
+ * });
57103
+ * }
57104
+ * ```
57105
+ *
57106
+ * ## Reading is not changing
57107
+ *
57108
+ * A plugin-contributed function is refused by `DELETE`/`PUT` and RETURNED
57109
+ * here, with `replaceable: false` and the refusal the mutation would give.
57110
+ */
57111
+ type GetFunctionResponse = FunctionDefinitionSignature & ({
57112
+ /**
57113
+ * The pattern-matched clauses, tried in order — in the shape
57114
+ * `register` and `PUT` accept.
57115
+ */
57116
+ clauses: FunctionClauseDto[];
57117
+ unrepresentable?: undefined;
57118
+ } | {
57119
+ clauses?: undefined;
57120
+ /**
57121
+ * What stopped the definition being expressed in the register shape.
57122
+ * Present only with the clauses absent, never alongside them.
57123
+ */
57124
+ unrepresentable: string;
57125
+ });
56820
57126
  /** Result of replacing a registered function's definition. */
56821
57127
  interface ReplaceFunctionResponse {
56822
57128
  /** The function's name — unchanged by the replacement, by construction. */
@@ -56850,6 +57156,7 @@ interface ReplaceFunctionResponse {
56850
57156
 
56851
57157
  type functions_AuthoringClarificationQuestionDto = AuthoringClarificationQuestionDto;
56852
57158
  type functions_BinaryOperatorDto = BinaryOperatorDto;
57159
+ type functions_ConditionalBranchDto = ConditionalBranchDto;
56853
57160
  type functions_DraftFunctionRequest = DraftFunctionRequest;
56854
57161
  type functions_DraftFunctionResponse = DraftFunctionResponse;
56855
57162
  type functions_EvaluateFunctionRequest = EvaluateFunctionRequest;
@@ -56860,19 +57167,23 @@ type functions_FunctionCaller = FunctionCaller;
56860
57167
  type functions_FunctionCallerKind = FunctionCallerKind;
56861
57168
  type functions_FunctionCallersDisposition = FunctionCallersDisposition;
56862
57169
  type functions_FunctionClauseDto = FunctionClauseDto;
57170
+ type functions_FunctionDefinitionSignature = FunctionDefinitionSignature;
56863
57171
  type functions_FunctionDraftDto = FunctionDraftDto;
56864
57172
  type functions_FunctionGuardDto = FunctionGuardDto;
56865
57173
  type functions_FunctionKindDto = FunctionKindDto;
57174
+ type functions_FunctionNotReplaceableDto = FunctionNotReplaceableDto;
56866
57175
  type functions_FunctionSummaryDto = FunctionSummaryDto;
56867
57176
  type functions_FunctionValueDto = FunctionValueDto;
56868
57177
  type functions_FunctionWithdrawalReport = FunctionWithdrawalReport;
57178
+ type functions_GetFunctionResponse = GetFunctionResponse;
56869
57179
  type functions_ListFunctionsResponse = ListFunctionsResponse;
56870
57180
  type functions_PatternDto = PatternDto;
56871
57181
  type functions_RegisterFunctionRequest = RegisterFunctionRequest;
56872
57182
  type functions_RegisterFunctionResponse = RegisterFunctionResponse;
56873
57183
  type functions_ReplaceFunctionResponse = ReplaceFunctionResponse;
57184
+ type functions_UnaryOperatorDto = UnaryOperatorDto;
56874
57185
  declare namespace functions {
56875
- export type { functions_AuthoringClarificationQuestionDto as AuthoringClarificationQuestionDto, functions_BinaryOperatorDto as BinaryOperatorDto, functions_DraftFunctionRequest as DraftFunctionRequest, functions_DraftFunctionResponse as DraftFunctionResponse, functions_EvaluateFunctionRequest as EvaluateFunctionRequest, functions_EvaluateFunctionResponse as EvaluateFunctionResponse, functions_ExpressionDto as ExpressionDto, functions_FunctionBodyDto as FunctionBodyDto, functions_FunctionCaller as FunctionCaller, functions_FunctionCallerKind as FunctionCallerKind, functions_FunctionCallersDisposition as FunctionCallersDisposition, functions_FunctionClauseDto as FunctionClauseDto, functions_FunctionDraftDto as FunctionDraftDto, functions_FunctionGuardDto as FunctionGuardDto, functions_FunctionKindDto as FunctionKindDto, functions_FunctionSummaryDto as FunctionSummaryDto, functions_FunctionValueDto as FunctionValueDto, functions_FunctionWithdrawalReport as FunctionWithdrawalReport, functions_ListFunctionsResponse as ListFunctionsResponse, functions_PatternDto as PatternDto, functions_RegisterFunctionRequest as RegisterFunctionRequest, functions_RegisterFunctionResponse as RegisterFunctionResponse, functions_ReplaceFunctionResponse as ReplaceFunctionResponse };
57186
+ export type { functions_AuthoringClarificationQuestionDto as AuthoringClarificationQuestionDto, functions_BinaryOperatorDto as BinaryOperatorDto, functions_ConditionalBranchDto as ConditionalBranchDto, functions_DraftFunctionRequest as DraftFunctionRequest, functions_DraftFunctionResponse as DraftFunctionResponse, functions_EvaluateFunctionRequest as EvaluateFunctionRequest, functions_EvaluateFunctionResponse as EvaluateFunctionResponse, functions_ExpressionDto as ExpressionDto, functions_FunctionBodyDto as FunctionBodyDto, functions_FunctionCaller as FunctionCaller, functions_FunctionCallerKind as FunctionCallerKind, functions_FunctionCallersDisposition as FunctionCallersDisposition, functions_FunctionClauseDto as FunctionClauseDto, functions_FunctionDefinitionSignature as FunctionDefinitionSignature, functions_FunctionDraftDto as FunctionDraftDto, functions_FunctionGuardDto as FunctionGuardDto, functions_FunctionKindDto as FunctionKindDto, functions_FunctionNotReplaceableDto as FunctionNotReplaceableDto, functions_FunctionSummaryDto as FunctionSummaryDto, functions_FunctionValueDto as FunctionValueDto, functions_FunctionWithdrawalReport as FunctionWithdrawalReport, functions_GetFunctionResponse as GetFunctionResponse, functions_ListFunctionsResponse as ListFunctionsResponse, functions_PatternDto as PatternDto, functions_RegisterFunctionRequest as RegisterFunctionRequest, functions_RegisterFunctionResponse as RegisterFunctionResponse, functions_ReplaceFunctionResponse as ReplaceFunctionResponse, functions_UnaryOperatorDto as UnaryOperatorDto };
56876
57187
  }
56877
57188
 
56878
57189
  /**
@@ -57019,6 +57330,46 @@ declare class FunctionsClient {
57019
57330
  * ```
57020
57331
  */
57021
57332
  listFunctions(): Promise<ListFunctionsResponse>;
57333
+ /**
57334
+ * Read one registered function's definition.
57335
+ *
57336
+ * @param name - The registered function's name — its identity.
57337
+ * @returns The signature, everything that calls it, whether a `PUT` would
57338
+ * act or refuse, and the clauses in the shape a replacement takes.
57339
+ * @throws {ApiError} 404 if nothing is registered under that name for the
57340
+ * authenticated tenant. Another tenant's function is 404 too — saying
57341
+ * anything else would confirm the name exists somewhere.
57342
+ *
57343
+ * @remarks
57344
+ * This is what makes {@link FunctionsClient.replaceFunction} an edit. `PUT`
57345
+ * replaces the WHOLE definition, so without a read a client fixing one
57346
+ * clause of a three-clause function had to re-author the other two from
57347
+ * memory, and any it forgot were deleted.
57348
+ *
57349
+ * `clauses` and `unrepresentable` are exclusive: a definition holding a
57350
+ * construct the register shape cannot express comes back with no clauses and
57351
+ * a reason, because a degraded read written back would destroy the real
57352
+ * definition. Narrow on `clauses === undefined` before using them.
57353
+ *
57354
+ * A plugin-contributed function is refused by `DELETE`/`PUT` and returned
57355
+ * here, with `replaceable: false` and the refusal the mutation would give.
57356
+ *
57357
+ * @example
57358
+ * ```typescript
57359
+ * const definition = await client.functions.getFunction('scale');
57360
+ * if (definition.clauses === undefined) {
57361
+ * throw new Error(`scale cannot be edited: ${definition.unrepresentable}`);
57362
+ * }
57363
+ * if (!definition.replaceable) {
57364
+ * throw new Error(definition.notReplaceable?.reason);
57365
+ * }
57366
+ * await client.functions.replaceFunction('scale', {
57367
+ * arity: definition.arity,
57368
+ * clauses: definition.clauses.map(tweak),
57369
+ * });
57370
+ * ```
57371
+ */
57372
+ getFunction(name: string): Promise<GetFunctionResponse>;
57022
57373
  /**
57023
57374
  * Withdraw a registered function.
57024
57375
  *
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.25.0";
8
+ var SDK_VERSION = "1.26.0";
9
9
  function resolveConfig(config) {
10
10
  if (!config.baseUrl) {
11
11
  throw new Error("ClientConfig.baseUrl is required");
@@ -8491,6 +8491,22 @@ var Functions = class {
8491
8491
  format: "json",
8492
8492
  ...params
8493
8493
  });
8494
+ /**
8495
+ * @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.
8496
+ *
8497
+ * @tags functions
8498
+ * @name GetFunction
8499
+ * @summary Read one registered function's definition.
8500
+ * @request GET:/api/v1/functions/{name}
8501
+ * @secure
8502
+ */
8503
+ getFunction = (name, params = {}) => this.http.request({
8504
+ path: `/api/v1/functions/${name}`,
8505
+ method: "GET",
8506
+ secure: true,
8507
+ format: "json",
8508
+ ...params
8509
+ });
8494
8510
  /**
8495
8511
  * @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.
8496
8512
  *
@@ -26173,6 +26189,23 @@ function ExpressionDtoFromFrontToApi(model) {
26173
26189
  right: ExpressionDtoFromFrontToApi(model.right)
26174
26190
  };
26175
26191
  }
26192
+ if (model.type === "UnaryOp") {
26193
+ return {
26194
+ type: "UnaryOp",
26195
+ op: model.op,
26196
+ operand: ExpressionDtoFromFrontToApi(model.operand)
26197
+ };
26198
+ }
26199
+ if (model.type === "Conditional") {
26200
+ return {
26201
+ type: "Conditional",
26202
+ branches: model.branches.map((b) => ({
26203
+ when: ExpressionDtoFromFrontToApi(b.when),
26204
+ then: ExpressionDtoFromFrontToApi(b.then)
26205
+ })),
26206
+ default: model.default ? ExpressionDtoFromFrontToApi(model.default) : model.default
26207
+ };
26208
+ }
26176
26209
  return model;
26177
26210
  }
26178
26211
  function ExpressionDtoFromApiToFront(dto) {
@@ -26191,6 +26224,23 @@ function ExpressionDtoFromApiToFront(dto) {
26191
26224
  right: ExpressionDtoFromApiToFront(dto.right)
26192
26225
  };
26193
26226
  }
26227
+ if (dto.type === "UnaryOp") {
26228
+ return {
26229
+ type: "UnaryOp",
26230
+ op: dto.op,
26231
+ operand: ExpressionDtoFromApiToFront(dto.operand)
26232
+ };
26233
+ }
26234
+ if (dto.type === "Conditional") {
26235
+ return {
26236
+ type: "Conditional",
26237
+ branches: dto.branches.map((b) => ({
26238
+ when: ExpressionDtoFromApiToFront(b.when),
26239
+ then: ExpressionDtoFromApiToFront(b.then)
26240
+ })),
26241
+ default: dto.default ? ExpressionDtoFromApiToFront(dto.default) : dto.default
26242
+ };
26243
+ }
26194
26244
  return dto;
26195
26245
  }
26196
26246
  function FunctionBodyDtoFromFrontToApi(model) {
@@ -26407,6 +26457,26 @@ function ReplaceFunctionResponseFromApiToFront(dto) {
26407
26457
  callers: (dto.callers ?? []).map(FunctionCallerFromApiToFront)
26408
26458
  };
26409
26459
  }
26460
+ function GetFunctionResponseFromApiToFront(dto) {
26461
+ const signature = {
26462
+ name: dto.name,
26463
+ functionId: dto.function_id,
26464
+ arity: dto.arity,
26465
+ kind: dto.kind,
26466
+ replaceable: dto.replaceable,
26467
+ notReplaceable: dto.not_replaceable ?? void 0,
26468
+ // The wire omits the field when nothing calls it; the SDK always hands
26469
+ // back an array, as the withdrawal report already does.
26470
+ callers: (dto.callers ?? []).map(FunctionCallerFromApiToFront)
26471
+ };
26472
+ if (dto.clauses == null) {
26473
+ return {
26474
+ ...signature,
26475
+ unrepresentable: dto.unrepresentable ?? "The engine returned no clauses for this function and gave no reason."
26476
+ };
26477
+ }
26478
+ return { ...signature, clauses: dto.clauses.map(FunctionClauseDtoFromApiToFront) };
26479
+ }
26410
26480
 
26411
26481
  // src/resources/functions.ts
26412
26482
  var FunctionsClient = class {
@@ -26470,7 +26540,9 @@ var FunctionsClient = class {
26470
26540
  * ```
26471
26541
  */
26472
26542
  async registerFunction(request) {
26473
- const response = await this.api.registerFunction(RegisterFunctionRequestFromFrontToApi(request));
26543
+ const response = await this.api.registerFunction(
26544
+ RegisterFunctionRequestFromFrontToApi(request)
26545
+ );
26474
26546
  return RegisterFunctionResponseFromApiToFront(response.data);
26475
26547
  }
26476
26548
  /**
@@ -26521,7 +26593,9 @@ var FunctionsClient = class {
26521
26593
  * ```
26522
26594
  */
26523
26595
  async evaluateFunction(request) {
26524
- const response = await this.api.evaluateFunction(EvaluateFunctionRequestFromFrontToApi(request));
26596
+ const response = await this.api.evaluateFunction(
26597
+ EvaluateFunctionRequestFromFrontToApi(request)
26598
+ );
26525
26599
  return EvaluateFunctionResponseFromApiToFront(response.data);
26526
26600
  }
26527
26601
  /**
@@ -26551,6 +26625,49 @@ var FunctionsClient = class {
26551
26625
  const response = await this.api.listFunctions();
26552
26626
  return ListFunctionsResponseFromApiToFront(response.data);
26553
26627
  }
26628
+ /**
26629
+ * Read one registered function's definition.
26630
+ *
26631
+ * @param name - The registered function's name — its identity.
26632
+ * @returns The signature, everything that calls it, whether a `PUT` would
26633
+ * act or refuse, and the clauses in the shape a replacement takes.
26634
+ * @throws {ApiError} 404 if nothing is registered under that name for the
26635
+ * authenticated tenant. Another tenant's function is 404 too — saying
26636
+ * anything else would confirm the name exists somewhere.
26637
+ *
26638
+ * @remarks
26639
+ * This is what makes {@link FunctionsClient.replaceFunction} an edit. `PUT`
26640
+ * replaces the WHOLE definition, so without a read a client fixing one
26641
+ * clause of a three-clause function had to re-author the other two from
26642
+ * memory, and any it forgot were deleted.
26643
+ *
26644
+ * `clauses` and `unrepresentable` are exclusive: a definition holding a
26645
+ * construct the register shape cannot express comes back with no clauses and
26646
+ * a reason, because a degraded read written back would destroy the real
26647
+ * definition. Narrow on `clauses === undefined` before using them.
26648
+ *
26649
+ * A plugin-contributed function is refused by `DELETE`/`PUT` and returned
26650
+ * here, with `replaceable: false` and the refusal the mutation would give.
26651
+ *
26652
+ * @example
26653
+ * ```typescript
26654
+ * const definition = await client.functions.getFunction('scale');
26655
+ * if (definition.clauses === undefined) {
26656
+ * throw new Error(`scale cannot be edited: ${definition.unrepresentable}`);
26657
+ * }
26658
+ * if (!definition.replaceable) {
26659
+ * throw new Error(definition.notReplaceable?.reason);
26660
+ * }
26661
+ * await client.functions.replaceFunction('scale', {
26662
+ * arity: definition.arity,
26663
+ * clauses: definition.clauses.map(tweak),
26664
+ * });
26665
+ * ```
26666
+ */
26667
+ async getFunction(name) {
26668
+ const response = await this.api.getFunction(name);
26669
+ return GetFunctionResponseFromApiToFront(response.data);
26670
+ }
26554
26671
  /**
26555
26672
  * Withdraw a registered function.
26556
26673
  *