@kortexya/reasoninglayer 0.4.1 → 0.5.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 +203 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +418 -14
- package/dist/index.d.ts +418 -14
- package/dist/index.js +202 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/config.ts
|
|
2
|
-
var SDK_VERSION = "0.
|
|
2
|
+
var SDK_VERSION = "0.5.0";
|
|
3
3
|
function resolveConfig(config) {
|
|
4
4
|
if (!config.baseUrl) {
|
|
5
5
|
throw new Error("ClientConfig.baseUrl is required");
|
|
@@ -7389,6 +7389,32 @@ var Rag = class {
|
|
|
7389
7389
|
});
|
|
7390
7390
|
};
|
|
7391
7391
|
|
|
7392
|
+
// src/api-spec/generated/Osfql.ts
|
|
7393
|
+
var Osfql = class {
|
|
7394
|
+
http;
|
|
7395
|
+
constructor(http) {
|
|
7396
|
+
this.http = http;
|
|
7397
|
+
}
|
|
7398
|
+
/**
|
|
7399
|
+
* @description Parses, compiles, and executes an OSFQL program against the caller's tenant-isolated knowledge base. Supports all OSFQL statement types: MATCH, INSERT, RETRACT, DERIVE, UNIFY, AWAIT, COUNTERFACTUAL, CAUSES. # Examples ```json { "query": "INSERT person(name: \"Alice\", age: 30);" } ``` ```json { "query": "MATCH person(name: ?N, age: ?A) WHERE ?A > 18;" } ```
|
|
7400
|
+
*
|
|
7401
|
+
* @tags osfql
|
|
7402
|
+
* @name ExecuteOsfql
|
|
7403
|
+
* @summary Execute an OSFQL program.
|
|
7404
|
+
* @request POST:/api/v1/osfql
|
|
7405
|
+
* @secure
|
|
7406
|
+
*/
|
|
7407
|
+
executeOsfql = (data, params = {}) => this.http.request({
|
|
7408
|
+
path: `/api/v1/osfql`,
|
|
7409
|
+
method: "POST",
|
|
7410
|
+
body: data,
|
|
7411
|
+
secure: true,
|
|
7412
|
+
type: "application/json" /* Json */,
|
|
7413
|
+
format: "json",
|
|
7414
|
+
...params
|
|
7415
|
+
});
|
|
7416
|
+
};
|
|
7417
|
+
|
|
7392
7418
|
// src/resources/sorts.ts
|
|
7393
7419
|
var SortsClient = class {
|
|
7394
7420
|
/** @internal */
|
|
@@ -13560,6 +13586,165 @@ function extractNumericValue(features, featureName) {
|
|
|
13560
13586
|
return null;
|
|
13561
13587
|
}
|
|
13562
13588
|
|
|
13589
|
+
// src/resources/osfql.ts
|
|
13590
|
+
var OsfqlClient = class {
|
|
13591
|
+
/** @internal */
|
|
13592
|
+
api;
|
|
13593
|
+
/** @internal */
|
|
13594
|
+
constructor(api) {
|
|
13595
|
+
this.api = api;
|
|
13596
|
+
}
|
|
13597
|
+
/**
|
|
13598
|
+
* Execute an OSFQL program.
|
|
13599
|
+
*
|
|
13600
|
+
* @param query - The OSFQL program text (one or more statements separated by `;`).
|
|
13601
|
+
* @returns The execution result including variable bindings, produced term IDs,
|
|
13602
|
+
* defined sort IDs, diagnostics, and statement count.
|
|
13603
|
+
* @throws {ApiError} If the request fails.
|
|
13604
|
+
*
|
|
13605
|
+
* @remarks
|
|
13606
|
+
* The query is parsed, compiled, and executed against the caller's tenant-isolated
|
|
13607
|
+
* knowledge base. Results include variable bindings from MATCH queries and IDs of
|
|
13608
|
+
* any terms or sorts created by INSERT, DERIVE, or DEFINE statements.
|
|
13609
|
+
*
|
|
13610
|
+
* @example
|
|
13611
|
+
* ```typescript
|
|
13612
|
+
* // Insert a record and query it back
|
|
13613
|
+
* const result = await client.osfql.execute(
|
|
13614
|
+
* 'INSERT person(name: "Alice", age: 30); MATCH person(name: ?N);'
|
|
13615
|
+
* );
|
|
13616
|
+
* console.log(result.success); // true
|
|
13617
|
+
* console.log(result.bindings); // [{ N: { type: "string", value: "Alice" } }]
|
|
13618
|
+
* console.log(result.producedTermIds); // ["<uuid>"]
|
|
13619
|
+
* console.log(result.statementCount); // 2
|
|
13620
|
+
* ```
|
|
13621
|
+
*/
|
|
13622
|
+
async execute(query) {
|
|
13623
|
+
const response = await this.api.executeOsfql({ query });
|
|
13624
|
+
return response.data;
|
|
13625
|
+
}
|
|
13626
|
+
};
|
|
13627
|
+
|
|
13628
|
+
// src/resources/conversation.ts
|
|
13629
|
+
var ConversationClient = class {
|
|
13630
|
+
/** @internal */
|
|
13631
|
+
http;
|
|
13632
|
+
/** @internal */
|
|
13633
|
+
constructor(http) {
|
|
13634
|
+
this.http = http;
|
|
13635
|
+
}
|
|
13636
|
+
/**
|
|
13637
|
+
* Send a natural language message and receive OSFQL-powered results.
|
|
13638
|
+
*
|
|
13639
|
+
* @param request - The conversation message request.
|
|
13640
|
+
* @returns The assistant's response including generated OSFQL, query results, and suggestions.
|
|
13641
|
+
* @throws {ApiError} If the request fails.
|
|
13642
|
+
*
|
|
13643
|
+
* @remarks
|
|
13644
|
+
* The conversation service:
|
|
13645
|
+
* 1. Classifies the intent (query, insert, define, etc.)
|
|
13646
|
+
* 2. Generates OSFQL from the natural language
|
|
13647
|
+
* 3. Executes the OSFQL against the knowledge base
|
|
13648
|
+
* 4. Self-corrects up to 3 times if execution fails
|
|
13649
|
+
* 5. Returns results + the generated OSFQL + suggestions
|
|
13650
|
+
*
|
|
13651
|
+
* Reuse `conversationId` from a previous response for multi-turn context.
|
|
13652
|
+
*
|
|
13653
|
+
* @example
|
|
13654
|
+
* ```typescript
|
|
13655
|
+
* // First message — starts a new conversation
|
|
13656
|
+
* const first = await client.conversation.sendMessage({
|
|
13657
|
+
* message: 'Who are the prime suspects?',
|
|
13658
|
+
* });
|
|
13659
|
+
* console.log(first.osfqlExecuted); // "PROVE prime_suspect(name: ?N, motive: ?M);"
|
|
13660
|
+
* console.log(first.queryResults); // [{ N: ..., M: ... }, ...]
|
|
13661
|
+
*
|
|
13662
|
+
* // Follow-up — reuses conversation context
|
|
13663
|
+
* const followUp = await client.conversation.sendMessage({
|
|
13664
|
+
* message: 'Which of them had a key?',
|
|
13665
|
+
* conversationId: first.conversationId,
|
|
13666
|
+
* });
|
|
13667
|
+
* ```
|
|
13668
|
+
*/
|
|
13669
|
+
async sendMessage(request) {
|
|
13670
|
+
const response = await this.http.request({
|
|
13671
|
+
path: "/api/v1/conversation/message",
|
|
13672
|
+
method: "POST",
|
|
13673
|
+
body: request,
|
|
13674
|
+
secure: true,
|
|
13675
|
+
type: "application/json" /* Json */,
|
|
13676
|
+
format: "json"
|
|
13677
|
+
});
|
|
13678
|
+
return response.data;
|
|
13679
|
+
}
|
|
13680
|
+
/**
|
|
13681
|
+
* List recent conversations for the authenticated user.
|
|
13682
|
+
*
|
|
13683
|
+
* @returns List of conversation summaries.
|
|
13684
|
+
* @throws {ApiError} If the request fails.
|
|
13685
|
+
*
|
|
13686
|
+
* @example
|
|
13687
|
+
* ```typescript
|
|
13688
|
+
* const { conversations } = await client.conversation.listConversations();
|
|
13689
|
+
* for (const c of conversations) {
|
|
13690
|
+
* console.log(`${c.id}: ${c.turnCount} turns (${c.createdAt})`);
|
|
13691
|
+
* }
|
|
13692
|
+
* ```
|
|
13693
|
+
*/
|
|
13694
|
+
async listConversations() {
|
|
13695
|
+
const response = await this.http.request({
|
|
13696
|
+
path: "/api/v1/conversation/history",
|
|
13697
|
+
method: "GET",
|
|
13698
|
+
secure: true,
|
|
13699
|
+
format: "json"
|
|
13700
|
+
});
|
|
13701
|
+
return response.data;
|
|
13702
|
+
}
|
|
13703
|
+
/**
|
|
13704
|
+
* Get all turns for a conversation.
|
|
13705
|
+
*
|
|
13706
|
+
* @param conversationId - The conversation ID.
|
|
13707
|
+
* @returns All turns in the conversation.
|
|
13708
|
+
* @throws {ApiError} If the request fails.
|
|
13709
|
+
*
|
|
13710
|
+
* @example
|
|
13711
|
+
* ```typescript
|
|
13712
|
+
* const { turns } = await client.conversation.getTurns('conv-uuid');
|
|
13713
|
+
* for (const turn of turns) {
|
|
13714
|
+
* console.log(`[${turn.role}] ${turn.content}`);
|
|
13715
|
+
* if (turn.osfql) console.log(` OSFQL: ${turn.osfql}`);
|
|
13716
|
+
* }
|
|
13717
|
+
* ```
|
|
13718
|
+
*/
|
|
13719
|
+
async getTurns(conversationId) {
|
|
13720
|
+
const response = await this.http.request({
|
|
13721
|
+
path: `/api/v1/conversation/${encodeURIComponent(conversationId)}/turns`,
|
|
13722
|
+
method: "GET",
|
|
13723
|
+
secure: true,
|
|
13724
|
+
format: "json"
|
|
13725
|
+
});
|
|
13726
|
+
return response.data;
|
|
13727
|
+
}
|
|
13728
|
+
/**
|
|
13729
|
+
* Delete a conversation and all its turns.
|
|
13730
|
+
*
|
|
13731
|
+
* @param conversationId - The conversation ID to delete.
|
|
13732
|
+
* @throws {ApiError} If the request fails.
|
|
13733
|
+
*
|
|
13734
|
+
* @example
|
|
13735
|
+
* ```typescript
|
|
13736
|
+
* await client.conversation.deleteConversation('conv-uuid');
|
|
13737
|
+
* ```
|
|
13738
|
+
*/
|
|
13739
|
+
async deleteConversation(conversationId) {
|
|
13740
|
+
await this.http.request({
|
|
13741
|
+
path: `/api/v1/conversation/${encodeURIComponent(conversationId)}`,
|
|
13742
|
+
method: "DELETE",
|
|
13743
|
+
secure: true
|
|
13744
|
+
});
|
|
13745
|
+
}
|
|
13746
|
+
};
|
|
13747
|
+
|
|
13563
13748
|
// src/client.ts
|
|
13564
13749
|
var ReasoningLayerClient = class {
|
|
13565
13750
|
/** Sort (type hierarchy) operations. */
|
|
@@ -13648,6 +13833,10 @@ var ReasoningLayerClient = class {
|
|
|
13648
13833
|
rag;
|
|
13649
13834
|
/** Linear program optimization (CLP(Q) simplex solver via backward chaining). */
|
|
13650
13835
|
optimize;
|
|
13836
|
+
/** OSFQL (OSF Query Language) execution operations. */
|
|
13837
|
+
osfql;
|
|
13838
|
+
/** Conversational AI operations (NL → OSFQL with self-correction). */
|
|
13839
|
+
conversation;
|
|
13651
13840
|
// ─── Group Caches ─────────────────────────────────────────────────
|
|
13652
13841
|
_core;
|
|
13653
13842
|
_ai;
|
|
@@ -13823,6 +14012,7 @@ var ReasoningLayerClient = class {
|
|
|
13823
14012
|
const generatedOntology = new Ontology(generatedHttp);
|
|
13824
14013
|
const generatedGeneration = new Generation(generatedHttp);
|
|
13825
14014
|
const generatedRag = new Rag(generatedHttp);
|
|
14015
|
+
const generatedOsfql = new Osfql(generatedHttp);
|
|
13826
14016
|
this.sorts = new SortsClient(generatedSorts, generatedTypes, resolved.tenantId);
|
|
13827
14017
|
this.terms = new TermsClient(generatedTerms);
|
|
13828
14018
|
this.inference = new InferenceClient(generatedInference, resolved.tenantId);
|
|
@@ -13866,6 +14056,8 @@ var ReasoningLayerClient = class {
|
|
|
13866
14056
|
this.generation = new GenerationClient(generatedGeneration);
|
|
13867
14057
|
this.rag = new RagClient(generatedRag);
|
|
13868
14058
|
this.optimize = new OptimizeClient(generatedInference, generatedSorts, generatedQuery, generatedTerms, resolved.tenantId);
|
|
14059
|
+
this.osfql = new OsfqlClient(generatedOsfql);
|
|
14060
|
+
this.conversation = new ConversationClient(generatedHttp);
|
|
13869
14061
|
}
|
|
13870
14062
|
};
|
|
13871
14063
|
|
|
@@ -14007,6 +14199,12 @@ var ilp_exports = {};
|
|
|
14007
14199
|
// src/types/plain-values.ts
|
|
14008
14200
|
var plain_values_exports = {};
|
|
14009
14201
|
|
|
14202
|
+
// src/types/osfql.ts
|
|
14203
|
+
var osfql_exports = {};
|
|
14204
|
+
|
|
14205
|
+
// src/types/conversation.ts
|
|
14206
|
+
var conversation_exports = {};
|
|
14207
|
+
|
|
14010
14208
|
// src/builders/value.ts
|
|
14011
14209
|
var Value = {
|
|
14012
14210
|
/**
|
|
@@ -14286,9 +14484,9 @@ var SortBuilder = class _SortBuilder {
|
|
|
14286
14484
|
* @example
|
|
14287
14485
|
* ```typescript
|
|
14288
14486
|
* builder.boundConstraint({
|
|
14289
|
-
*
|
|
14487
|
+
* constraintType: "upper",
|
|
14290
14488
|
* target: "end_date",
|
|
14291
|
-
*
|
|
14489
|
+
* sourcePath: "company.dissolutionDate",
|
|
14292
14490
|
* })
|
|
14293
14491
|
* ```
|
|
14294
14492
|
*/
|
|
@@ -14400,6 +14598,6 @@ function discriminateFeatureValue(value) {
|
|
|
14400
14598
|
);
|
|
14401
14599
|
}
|
|
14402
14600
|
|
|
14403
|
-
export { action_reviews_exports as ActionReviews, admin_exports as Admin, analysis_exports as Analysis, ApiError, AuthenticationError, BadRequestError, cdl_exports as CDL, causal_exports as Causal, cognitive_exports as Cognitive, collections_exports as Collections, communities_exports as Communities, ConstraintViolationError, constraints_exports as Constraints, control_exports as Control, discovery_exports as Discovery, execution_exports as Execution, extract_exports as Extract, ForbiddenError, functions_exports as Functions, fuzzy_exports as Fuzzy, FuzzyShape, generation_exports as Generation, health_exports as Health, homoiconic_exports as Homoiconic, ilp_exports as ILP, image_extraction_exports as ImageExtraction, inference_exports as Inference, ingestion_exports as Ingestion, InternalServerError, LP, namespaces_exports as Namespaces, NetworkError, neuro_symbolic_exports as NeuroSymbolic, NotFoundError, ontology_exports as Ontology, optimize_exports as Optimize, oversight_exports as Oversight, plain_values_exports as PlainValues, preferences_exports as Preferences, proof_engine_exports as ProofEngine, query_exports as Query, rag_exports as RAG, RateLimitError, reasoning_exports as Reasoning, ReasoningLayerClient, ReasoningLayerError, reviews_exports as Reviews, row_exports as Row, SDK_VERSION, scenarios_exports as Scenarios, SortBuilder, sorts_exports as Sorts, sources_exports as Sources, spaces_exports as Spaces, statistical_exports as Statistical, synthetic_exports as Synthetic, terms_exports as Terms, TimeoutError, utilities_exports as Utilities, ValidationError, Value, values_exports as Values, visualization_exports as Visualization, WebSocketClient, WebSocketConnection, webhook_actions_exports as WebhookActions, allen, constrained, discriminateFeatureValue, guard, isConstrainedPlainVar, isPsiTermInput, isTaggedValueDto, isUuid, psi, toTaggedFeatures, toTaggedValue, toTermInputDto, toUntaggedFeatures, toUntaggedValue };
|
|
14601
|
+
export { action_reviews_exports as ActionReviews, admin_exports as Admin, analysis_exports as Analysis, ApiError, AuthenticationError, BadRequestError, cdl_exports as CDL, causal_exports as Causal, cognitive_exports as Cognitive, collections_exports as Collections, communities_exports as Communities, ConstraintViolationError, constraints_exports as Constraints, control_exports as Control, conversation_exports as Conversation, discovery_exports as Discovery, execution_exports as Execution, extract_exports as Extract, ForbiddenError, functions_exports as Functions, fuzzy_exports as Fuzzy, FuzzyShape, generation_exports as Generation, health_exports as Health, homoiconic_exports as Homoiconic, ilp_exports as ILP, image_extraction_exports as ImageExtraction, inference_exports as Inference, ingestion_exports as Ingestion, InternalServerError, LP, namespaces_exports as Namespaces, NetworkError, neuro_symbolic_exports as NeuroSymbolic, NotFoundError, ontology_exports as Ontology, optimize_exports as Optimize, osfql_exports as Osfql, oversight_exports as Oversight, plain_values_exports as PlainValues, preferences_exports as Preferences, proof_engine_exports as ProofEngine, query_exports as Query, rag_exports as RAG, RateLimitError, reasoning_exports as Reasoning, ReasoningLayerClient, ReasoningLayerError, reviews_exports as Reviews, row_exports as Row, SDK_VERSION, scenarios_exports as Scenarios, SortBuilder, sorts_exports as Sorts, sources_exports as Sources, spaces_exports as Spaces, statistical_exports as Statistical, synthetic_exports as Synthetic, terms_exports as Terms, TimeoutError, utilities_exports as Utilities, ValidationError, Value, values_exports as Values, visualization_exports as Visualization, WebSocketClient, WebSocketConnection, webhook_actions_exports as WebhookActions, allen, constrained, discriminateFeatureValue, guard, isConstrainedPlainVar, isPsiTermInput, isTaggedValueDto, isUuid, psi, toTaggedFeatures, toTaggedValue, toTermInputDto, toUntaggedFeatures, toUntaggedValue };
|
|
14404
14602
|
//# sourceMappingURL=index.js.map
|
|
14405
14603
|
//# sourceMappingURL=index.js.map
|