@promptev/context-engine 0.0.1 → 0.0.3
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 +80 -0
- package/dist/cli.js +11990 -10954
- package/dist/cli.js.map +1 -1
- package/dist/{config-CdlSkKgV.d.ts → config-BODDdXJ7.d.ts} +33 -11
- package/dist/{config-CNnASw5X.d.cts → config-C5RZ00W6.d.cts} +33 -11
- package/dist/express.cjs.map +1 -1
- package/dist/express.d.cts +3 -3
- package/dist/express.d.ts +3 -3
- package/dist/express.js.map +1 -1
- package/dist/fastify.cjs.map +1 -1
- package/dist/fastify.d.cts +3 -3
- package/dist/fastify.d.ts +3 -3
- package/dist/fastify.js.map +1 -1
- package/dist/{governance-XFVgtEdV.d.ts → governance-BLPK7NMe.d.ts} +1 -1
- package/dist/{governance-D8g6Wyvb.d.cts → governance-P9pRb4Ol.d.cts} +1 -1
- package/dist/graph/index.cjs +57 -23
- package/dist/graph/index.cjs.map +1 -1
- package/dist/graph/index.d.cts +2 -2
- package/dist/graph/index.d.ts +2 -2
- package/dist/graph/index.js +57 -23
- package/dist/graph/index.js.map +1 -1
- package/dist/hono.cjs.map +1 -1
- package/dist/hono.d.cts +3 -3
- package/dist/hono.d.ts +3 -3
- package/dist/hono.js.map +1 -1
- package/dist/index.cjs +7559 -6464
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +154 -32
- package/dist/index.d.ts +154 -32
- package/dist/index.js +7543 -6450
- package/dist/index.js.map +1 -1
- package/dist/mcp-BKSmxayM.d.cts +204 -0
- package/dist/mcp-BKSmxayM.d.ts +204 -0
- package/dist/mcp.cjs +896 -70
- package/dist/mcp.cjs.map +1 -1
- package/dist/mcp.d.cts +2 -31
- package/dist/mcp.d.ts +2 -31
- package/dist/mcp.js +896 -70
- package/dist/mcp.js.map +1 -1
- package/dist/{router-Dsv3fv0R.d.cts → router-CiFwC-EN.d.cts} +1 -1
- package/dist/{router-B_DTkQgU.d.ts → router-D8gBzwLd.d.ts} +1 -1
- package/dist/skills/context-engine/SKILL.md +35 -3
- package/dist/{storage-DU1JRno5.d.cts → storage-CJrKgJeJ.d.ts} +5 -2
- package/dist/{storage-Dvt2ZxsV.d.ts → storage-Dvpq2xAC.d.cts} +5 -2
- package/package.json +1 -1
- package/src/skills/context-engine/SKILL.md +35 -3
package/dist/index.d.cts
CHANGED
|
@@ -1,30 +1,17 @@
|
|
|
1
1
|
import { Pool } from 'pg';
|
|
2
|
-
import { C as ContextEngineConfig, L as LLMConfig, E as ExtractionConfig, R as RerankerConfig } from './config-
|
|
3
|
-
export { a as ContextEngineConfigInit, b as EmbeddingConfig, F as FusionConfig, G as GraphConfig, S as StorageConfig } from './config-
|
|
2
|
+
import { C as ContextEngineConfig, L as LLMConfig, E as ExtractionConfig, R as RerankerConfig } from './config-C5RZ00W6.cjs';
|
|
3
|
+
export { a as ContextEngineConfigInit, b as EmbeddingConfig, F as FusionConfig, G as GraphConfig, S as StorageConfig } from './config-C5RZ00W6.cjs';
|
|
4
4
|
import { H as Hooks, R as RedactionPolicy, U as UsageEvent, P as ProgressEvent, I as IngestReport } from './redaction-BqD_DEUQ.cjs';
|
|
5
5
|
export { D as DocumentReport, a as RedactionRule, b as RedactionRuleInit, c as applyRedaction, e as emitError, d as emitProgress, f as emitToolCall, g as emitUsage, h as graphUnits, u as unitsForFile } from './redaction-BqD_DEUQ.cjs';
|
|
6
|
-
import { E as Embedder, S as StorageBackend, F as FetchImpl } from './storage-
|
|
7
|
-
export { C as ChunkRow, a as EmbedKind, P as PostgresBackend, b as SearchScope, c as buildEmbedder } from './storage-
|
|
8
|
-
import {
|
|
9
|
-
export { c as
|
|
10
|
-
|
|
6
|
+
import { E as Embedder, S as StorageBackend, F as FetchImpl } from './storage-Dvpq2xAC.cjs';
|
|
7
|
+
export { C as ChunkRow, a as EmbedKind, P as PostgresBackend, b as SearchScope, c as buildEmbedder } from './storage-Dvpq2xAC.cjs';
|
|
8
|
+
import { P as Principals, U as Unset, S as ScopeInput, K as KnowledgeComputeFn, T as Trusted } from './mcp-BKSmxayM.cjs';
|
|
9
|
+
export { a as KNOWLEDGE_ACTIONS, b as KNOWLEDGE_TOOL_DESCRIPTION, c as KnowledgeAction, d as Scope, e as TRUSTED, f as UNSCOPED, g as UNSET, h as callKnowledgeTool, i as createMcpApp, k as knowledgeToolDefinition, n as narrowToCeiling, r as resolvePrincipals, j as resolveScope } from './mcp-BKSmxayM.cjs';
|
|
10
|
+
import { T as ToolEngine, C as CanonicalTool, b as ToolHttpClient, a as ToolConfig } from './governance-P9pRb4Ol.cjs';
|
|
11
|
+
export { c as ToolKind, d as configSchema } from './governance-P9pRb4Ol.cjs';
|
|
11
12
|
import 'zod';
|
|
12
13
|
import 'node:http';
|
|
13
14
|
|
|
14
|
-
/**
|
|
15
|
-
* Sentinels distinguishing omitted arguments from real values, including null.
|
|
16
|
-
*
|
|
17
|
-
* UNSET: "argument omitted" vs null (e.g. updateDocument acl=null means unrestricted).
|
|
18
|
-
* TRUSTED: trusted caller, ACL filtering disabled. Truthy on purpose so
|
|
19
|
-
* `if (principals)` does not treat a trusted caller as anonymous.
|
|
20
|
-
*/
|
|
21
|
-
declare const UNSET: unique symbol;
|
|
22
|
-
type Unset = typeof UNSET;
|
|
23
|
-
declare const TRUSTED: unique symbol;
|
|
24
|
-
type Trusted = typeof TRUSTED;
|
|
25
|
-
type Principals = string[] | null | typeof TRUSTED | undefined;
|
|
26
|
-
declare function resolvePrincipals(value: Principals, method: string): string[] | null;
|
|
27
|
-
|
|
28
15
|
type Mode$1 = "hybrid" | "graph";
|
|
29
16
|
interface IngestRequest {
|
|
30
17
|
content?: Buffer | null;
|
|
@@ -79,17 +66,11 @@ declare function getDocumentText(documentId: string, opts: {
|
|
|
79
66
|
secretKey?: string | Buffer | null;
|
|
80
67
|
hooks?: Hooks;
|
|
81
68
|
}): Promise<string>;
|
|
82
|
-
/**
|
|
83
|
-
* Page through documents in scope, newest first.
|
|
84
|
-
*
|
|
85
|
-
* `redaction` masks `documentType` — unconstrained free text an LLM wrote
|
|
86
|
-
* after reading the document body. `name`/`description` remain
|
|
87
|
-
* intentionally unmasked: both are CALLER-set at ingest time, not text the
|
|
88
|
-
* pipeline derived from the document body.
|
|
89
|
-
*/
|
|
90
69
|
declare function listDocuments(opts: {
|
|
91
70
|
pool: Pool;
|
|
92
71
|
sourceId?: string | null;
|
|
72
|
+
/** OR-of-many, ONE keyset-paged query across all of them; with `sourceId`, their union. */
|
|
73
|
+
sourceIds?: string[] | null;
|
|
93
74
|
principals?: string[] | null;
|
|
94
75
|
cursor?: unknown;
|
|
95
76
|
limit?: number;
|
|
@@ -129,6 +110,13 @@ declare function queryStructured(question: string, opts: {
|
|
|
129
110
|
* call, no sandbox run — when the flag is `false`. That flag, not the
|
|
130
111
|
* isolate, is the actual security boundary.
|
|
131
112
|
*
|
|
113
|
+
* Only the document half lives here: fetch the in-scope tabular documents
|
|
114
|
+
* and parse their stored text into `{sheet: rows[]}`. Everything after that
|
|
115
|
+
* — the guards, both redaction surfaces below, the prompt → code → sandbox
|
|
116
|
+
* path and the swept result — is `computeOverFrames`, the seam a host calls
|
|
117
|
+
* when it already holds the frames and has no document to point at; this
|
|
118
|
+
* function builds its frames from documents and delegates.
|
|
119
|
+
*
|
|
132
120
|
* `config.redaction` is applied TWICE:
|
|
133
121
|
* 1. Each document's raw `.text` is masked BEFORE it is parsed into a
|
|
134
122
|
* table, so the data the LLM-authored code runs against is built from
|
|
@@ -146,6 +134,54 @@ declare function compute(instruction: string, opts: {
|
|
|
146
134
|
modelCfg?: LLMConfig | null;
|
|
147
135
|
timeout?: number;
|
|
148
136
|
}): Promise<Record<string, unknown>>;
|
|
137
|
+
/** What `compute()` builds and `computeOverFrames` consumes: sheet name → rows. */
|
|
138
|
+
type ComputeFrames = Record<string, Record<string, unknown>[]>;
|
|
139
|
+
/** A source document behind a frame, as `compute()` reports it in `documentsUsed`. */
|
|
140
|
+
interface ComputeDocument {
|
|
141
|
+
id: string;
|
|
142
|
+
name?: string | null;
|
|
143
|
+
sourceId?: string | null;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Compute an answer to `instruction` over caller-supplied tables.
|
|
147
|
+
*
|
|
148
|
+
* The frame-level seam under `compute()`: everything `compute()` does AFTER
|
|
149
|
+
* it has turned its documents into `{sheet: rows[]}` lives here, so a host
|
|
150
|
+
* that already holds the frames — an uploaded workbook, a connector's
|
|
151
|
+
* sheet, a query result — can run the same prompt → code → sandbox path
|
|
152
|
+
* without first ingesting a document to point at.
|
|
153
|
+
*
|
|
154
|
+
* `frames` keys are the sheet names the caller chose; the LLM sees them and
|
|
155
|
+
* each row's columns exactly as it sees a parsed document's.
|
|
156
|
+
*
|
|
157
|
+
* The guards are `compute()`'s, in the same order and all BEFORE any LLM
|
|
158
|
+
* call: `config.enableCodeExecution` off → `EngineActionError`; no LLM
|
|
159
|
+
* (`modelCfg` or `config.llm`) → `Error`; blank instruction or empty
|
|
160
|
+
* `frames` → `EngineActionError`; `timeout` clamped to 1..300 seconds.
|
|
161
|
+
*
|
|
162
|
+
* `config.redaction` is applied at the same two surfaces as `compute()`:
|
|
163
|
+
*
|
|
164
|
+
* 1. Every string cell and every column name is masked BEFORE the prompt is
|
|
165
|
+
* built (`maskFrames`), so neither the schema summary the LLM reads nor
|
|
166
|
+
* the rows its code runs against carry a raw value. Same intended
|
|
167
|
+
* trade-off as `compute()`'s point 1 — a masked cell can change a
|
|
168
|
+
* computed result, and that is correct.
|
|
169
|
+
* 2. The returned object is swept whole through `redactValueRecursive`,
|
|
170
|
+
* `code` included — `compute()`'s point 2, deliberately blunt.
|
|
171
|
+
*
|
|
172
|
+
* `hooks`, `principals` and `documents` are how `compute()` threads its own
|
|
173
|
+
* context through; a host calling the seam directly normally leaves them at
|
|
174
|
+
* their defaults (no error hook, trusted-internal `unless` evaluation, no
|
|
175
|
+
* source documents — `documentsUsed` comes back empty).
|
|
176
|
+
*/
|
|
177
|
+
declare function computeOverFrames(frames: ComputeFrames, instruction: string, opts: {
|
|
178
|
+
config: ContextEngineConfig;
|
|
179
|
+
modelCfg?: LLMConfig | null;
|
|
180
|
+
timeout?: number;
|
|
181
|
+
hooks?: Hooks | null;
|
|
182
|
+
principals?: string[] | null;
|
|
183
|
+
documents?: ComputeDocument[] | null;
|
|
184
|
+
}): Promise<Record<string, unknown>>;
|
|
149
185
|
|
|
150
186
|
/**
|
|
151
187
|
* AES-256-GCM crypto seam. Wire format is a compatibility promise with the
|
|
@@ -260,7 +296,9 @@ interface RunSearchOpts {
|
|
|
260
296
|
topK?: number;
|
|
261
297
|
mode?: Mode;
|
|
262
298
|
compressToTokens?: number | null;
|
|
263
|
-
|
|
299
|
+
/** A list, or a promise of one: passing a promise lets the graph leg run
|
|
300
|
+
* BESIDE the hybrid legs instead of ahead of them. */
|
|
301
|
+
graphRanked?: string[] | Promise<string[] | null> | null;
|
|
264
302
|
redaction?: RedactionPolicy | null;
|
|
265
303
|
}
|
|
266
304
|
/**
|
|
@@ -411,7 +449,13 @@ declare class ContextEngine implements ToolEngine {
|
|
|
411
449
|
documentIds?: string[] | null;
|
|
412
450
|
principals?: Principals;
|
|
413
451
|
topK?: number;
|
|
414
|
-
|
|
452
|
+
/**
|
|
453
|
+
* Omit it (or pass null) and the mode is worked out from the documents
|
|
454
|
+
* in scope: the graph leg runs when this deployment has a graph AND
|
|
455
|
+
* something in scope was ingested with `mode: "graph"`. Naming one
|
|
456
|
+
* forces it. The graph leg ADDS to the hybrid legs, never replaces them.
|
|
457
|
+
*/
|
|
458
|
+
mode?: "hybrid" | "graph" | null;
|
|
415
459
|
compressToTokens?: number | null;
|
|
416
460
|
redaction?: RedactionPolicy | null;
|
|
417
461
|
}): Promise<SearchResult>;
|
|
@@ -421,8 +465,25 @@ declare class ContextEngine implements ToolEngine {
|
|
|
421
465
|
* caller can never distinguish "doesn't exist" from "exists but you
|
|
422
466
|
* can't see it").
|
|
423
467
|
*/
|
|
468
|
+
/**
|
|
469
|
+
* How long a failed graph probe is remembered. One refused connection must
|
|
470
|
+
* not become one refused connection per request, and must not be permanent
|
|
471
|
+
* either — the database may come back.
|
|
472
|
+
*/
|
|
473
|
+
private static readonly GRAPH_PROBE_BACKOFF_MS;
|
|
474
|
+
private graphUnreachableUntil;
|
|
475
|
+
/**
|
|
476
|
+
* Is the graph database actually up?
|
|
477
|
+
*
|
|
478
|
+
* `graph.enabled` says the deployment is CONFIGURED, not that Neo4j is
|
|
479
|
+
* answering. Choosing the graph leg when it is unreachable buys a connection
|
|
480
|
+
* timeout on every search and no extra results, so a mode-less search checks
|
|
481
|
+
* first and remembers a failure briefly.
|
|
482
|
+
*/
|
|
483
|
+
private graphIsReachable;
|
|
424
484
|
getDocument(documentId: string, opts?: {
|
|
425
485
|
principals?: Principals;
|
|
486
|
+
redaction?: RedactionPolicy | null;
|
|
426
487
|
}): Promise<Record<string, unknown>>;
|
|
427
488
|
deleteDocument(documentId: string, opts?: {
|
|
428
489
|
principals?: Principals;
|
|
@@ -447,17 +508,78 @@ declare class ContextEngine implements ToolEngine {
|
|
|
447
508
|
getDocumentText(documentId: string, opts?: {
|
|
448
509
|
principals?: Principals;
|
|
449
510
|
}): Promise<string>;
|
|
511
|
+
/**
|
|
512
|
+
* The ONE knowledge tool, as a library call. See `knowledge-tool.ts`.
|
|
513
|
+
*
|
|
514
|
+
* The same function the MCP server serves — an application driving its own
|
|
515
|
+
* agent loop hands its model this one door to the corpus without speaking
|
|
516
|
+
* MCP at all, and cannot get a different answer, because there is one
|
|
517
|
+
* implementation behind both surfaces.
|
|
518
|
+
*/
|
|
519
|
+
searchKnowledgeBase(args: {
|
|
520
|
+
action: string;
|
|
521
|
+
principals?: Principals;
|
|
522
|
+
scope: ScopeInput;
|
|
523
|
+
query?: string | null;
|
|
524
|
+
document_id?: string | null;
|
|
525
|
+
source_ids?: string[] | null;
|
|
526
|
+
document_ids?: string[] | null;
|
|
527
|
+
entity?: string | null;
|
|
528
|
+
depth?: number | null;
|
|
529
|
+
category?: string | null;
|
|
530
|
+
label?: string | null;
|
|
531
|
+
entity_type?: string | null;
|
|
532
|
+
top_k?: number | null;
|
|
533
|
+
mode?: string | null;
|
|
534
|
+
limit?: number | null;
|
|
535
|
+
cursor?: unknown;
|
|
536
|
+
redaction?: RedactionPolicy | null;
|
|
537
|
+
compute?: KnowledgeComputeFn | null;
|
|
538
|
+
map_reduce?: ((instruction: string, opts: Record<string, unknown>) => Promise<Record<string, unknown>>) | null;
|
|
539
|
+
start?: number | null;
|
|
540
|
+
end?: number | null;
|
|
541
|
+
max_chars?: number | null;
|
|
542
|
+
}): Promise<Record<string, unknown>>;
|
|
543
|
+
/** Read one document in order, a range of chunks at a time. */
|
|
544
|
+
getChunks(documentId: string, opts?: {
|
|
545
|
+
principals?: Principals;
|
|
546
|
+
start?: number | null;
|
|
547
|
+
end?: number | null;
|
|
548
|
+
redaction?: RedactionPolicy | null;
|
|
549
|
+
}): Promise<Record<string, unknown>>;
|
|
550
|
+
/**
|
|
551
|
+
* Several whole documents at once, each ACL-checked. An id that is absent OR
|
|
552
|
+
* not visible is simply missing from the result, never an error — the same
|
|
553
|
+
* non-disclosure `getDocument` gives, which a batch read is the classic
|
|
554
|
+
* place to lose.
|
|
555
|
+
*/
|
|
556
|
+
getDocuments(documentIds: string[], opts?: {
|
|
557
|
+
principals?: Principals;
|
|
558
|
+
redaction?: RedactionPolicy | null;
|
|
559
|
+
}): Promise<Array<Record<string, unknown>>>;
|
|
560
|
+
/** Ask the same question of every document in scope. */
|
|
561
|
+
mapReduce(instruction: string, opts?: {
|
|
562
|
+
principals?: Principals;
|
|
563
|
+
sourceIds?: string[] | null;
|
|
564
|
+
documentIds?: string[] | null;
|
|
565
|
+
limit?: number | null;
|
|
566
|
+
maxConcurrency?: number | null;
|
|
567
|
+
redaction?: RedactionPolicy | null;
|
|
568
|
+
}): Promise<Record<string, unknown>>;
|
|
450
569
|
listDocuments(opts?: {
|
|
451
570
|
sourceId?: string | null;
|
|
571
|
+
sourceIds?: string[] | null;
|
|
452
572
|
principals?: Principals;
|
|
453
573
|
cursor?: unknown;
|
|
454
574
|
limit?: number;
|
|
575
|
+
redaction?: RedactionPolicy | null;
|
|
455
576
|
}): Promise<Record<string, unknown>>;
|
|
456
577
|
queryStructured(question: string, opts?: {
|
|
457
578
|
sourceIds?: string[] | null;
|
|
458
579
|
principals?: Principals;
|
|
459
580
|
docType?: string | null;
|
|
460
581
|
limit?: number;
|
|
582
|
+
redaction?: RedactionPolicy | null;
|
|
461
583
|
}): Promise<Record<string, unknown>>;
|
|
462
584
|
compute(instruction: string, opts?: {
|
|
463
585
|
sourceIds?: string[] | null;
|
|
@@ -811,4 +933,4 @@ declare function functionTool(fn: (...args: never[]) => unknown): CanonicalTool;
|
|
|
811
933
|
/** Bumped by CI on every main merge; 0.0.0 = pre-first-release. */
|
|
812
934
|
declare const __version__ = "0.0.0";
|
|
813
935
|
|
|
814
|
-
export { ApprovalExpired, ApprovalNotPending, type ApprovalRecord, CeleryRunner, CodeExecutionError, CodeExecutionTimeout, ContextEngine, ContextEngineConfig, DEFAULT_LEG_WEIGHT, DocumentNotFoundError, EXTRACTION_VERSION, Embedder, EngineActionError, ExtraMissingError, Extracted, ExtractionConfig, type ExtractionResult, GraphLegUnavailable, type Hit, Hooks, InProcessRunner, IngestReport, LLMClient, LLMConfig,
|
|
936
|
+
export { ApprovalExpired, ApprovalNotPending, type ApprovalRecord, CeleryRunner, CodeExecutionError, CodeExecutionTimeout, type ComputeDocument, type ComputeFrames, ContextEngine, ContextEngineConfig, DEFAULT_LEG_WEIGHT, DocumentNotFoundError, EXTRACTION_VERSION, Embedder, EngineActionError, ExtraMissingError, Extracted, ExtractionConfig, type ExtractionResult, GraphLegUnavailable, type Hit, Hooks, InProcessRunner, IngestReport, KnowledgeComputeFn, LLMClient, LLMConfig, Principals, ProgressEvent, RedactionPolicy, RerankerConfig, ScopeInput, type SearchResult, StorageBackend, type TaskRunner, type TaskStatus, ToolConfig, Trusted, Unset, UsageEvent, __version__, buildLlmClient, callLlm, compute, computeOverFrames, decryptDict, encryptDict, extract, extractStructuredData, functionTool, getDocumentText, getSecretKey, listDocuments, queryStructured, redactHits, rerank, resolveApproval, resolveFields, rrfFuse, runMigrate, runSearch, shouldRequireApproval, upsertRegistry };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,30 +1,17 @@
|
|
|
1
1
|
import { Pool } from 'pg';
|
|
2
|
-
import { C as ContextEngineConfig, L as LLMConfig, E as ExtractionConfig, R as RerankerConfig } from './config-
|
|
3
|
-
export { a as ContextEngineConfigInit, b as EmbeddingConfig, F as FusionConfig, G as GraphConfig, S as StorageConfig } from './config-
|
|
2
|
+
import { C as ContextEngineConfig, L as LLMConfig, E as ExtractionConfig, R as RerankerConfig } from './config-BODDdXJ7.js';
|
|
3
|
+
export { a as ContextEngineConfigInit, b as EmbeddingConfig, F as FusionConfig, G as GraphConfig, S as StorageConfig } from './config-BODDdXJ7.js';
|
|
4
4
|
import { H as Hooks, R as RedactionPolicy, U as UsageEvent, P as ProgressEvent, I as IngestReport } from './redaction-BqD_DEUQ.js';
|
|
5
5
|
export { D as DocumentReport, a as RedactionRule, b as RedactionRuleInit, c as applyRedaction, e as emitError, d as emitProgress, f as emitToolCall, g as emitUsage, h as graphUnits, u as unitsForFile } from './redaction-BqD_DEUQ.js';
|
|
6
|
-
import { E as Embedder, S as StorageBackend, F as FetchImpl } from './storage-
|
|
7
|
-
export { C as ChunkRow, a as EmbedKind, P as PostgresBackend, b as SearchScope, c as buildEmbedder } from './storage-
|
|
8
|
-
import {
|
|
9
|
-
export { c as
|
|
10
|
-
|
|
6
|
+
import { E as Embedder, S as StorageBackend, F as FetchImpl } from './storage-CJrKgJeJ.js';
|
|
7
|
+
export { C as ChunkRow, a as EmbedKind, P as PostgresBackend, b as SearchScope, c as buildEmbedder } from './storage-CJrKgJeJ.js';
|
|
8
|
+
import { P as Principals, U as Unset, S as ScopeInput, K as KnowledgeComputeFn, T as Trusted } from './mcp-BKSmxayM.js';
|
|
9
|
+
export { a as KNOWLEDGE_ACTIONS, b as KNOWLEDGE_TOOL_DESCRIPTION, c as KnowledgeAction, d as Scope, e as TRUSTED, f as UNSCOPED, g as UNSET, h as callKnowledgeTool, i as createMcpApp, k as knowledgeToolDefinition, n as narrowToCeiling, r as resolvePrincipals, j as resolveScope } from './mcp-BKSmxayM.js';
|
|
10
|
+
import { T as ToolEngine, C as CanonicalTool, b as ToolHttpClient, a as ToolConfig } from './governance-BLPK7NMe.js';
|
|
11
|
+
export { c as ToolKind, d as configSchema } from './governance-BLPK7NMe.js';
|
|
11
12
|
import 'zod';
|
|
12
13
|
import 'node:http';
|
|
13
14
|
|
|
14
|
-
/**
|
|
15
|
-
* Sentinels distinguishing omitted arguments from real values, including null.
|
|
16
|
-
*
|
|
17
|
-
* UNSET: "argument omitted" vs null (e.g. updateDocument acl=null means unrestricted).
|
|
18
|
-
* TRUSTED: trusted caller, ACL filtering disabled. Truthy on purpose so
|
|
19
|
-
* `if (principals)` does not treat a trusted caller as anonymous.
|
|
20
|
-
*/
|
|
21
|
-
declare const UNSET: unique symbol;
|
|
22
|
-
type Unset = typeof UNSET;
|
|
23
|
-
declare const TRUSTED: unique symbol;
|
|
24
|
-
type Trusted = typeof TRUSTED;
|
|
25
|
-
type Principals = string[] | null | typeof TRUSTED | undefined;
|
|
26
|
-
declare function resolvePrincipals(value: Principals, method: string): string[] | null;
|
|
27
|
-
|
|
28
15
|
type Mode$1 = "hybrid" | "graph";
|
|
29
16
|
interface IngestRequest {
|
|
30
17
|
content?: Buffer | null;
|
|
@@ -79,17 +66,11 @@ declare function getDocumentText(documentId: string, opts: {
|
|
|
79
66
|
secretKey?: string | Buffer | null;
|
|
80
67
|
hooks?: Hooks;
|
|
81
68
|
}): Promise<string>;
|
|
82
|
-
/**
|
|
83
|
-
* Page through documents in scope, newest first.
|
|
84
|
-
*
|
|
85
|
-
* `redaction` masks `documentType` — unconstrained free text an LLM wrote
|
|
86
|
-
* after reading the document body. `name`/`description` remain
|
|
87
|
-
* intentionally unmasked: both are CALLER-set at ingest time, not text the
|
|
88
|
-
* pipeline derived from the document body.
|
|
89
|
-
*/
|
|
90
69
|
declare function listDocuments(opts: {
|
|
91
70
|
pool: Pool;
|
|
92
71
|
sourceId?: string | null;
|
|
72
|
+
/** OR-of-many, ONE keyset-paged query across all of them; with `sourceId`, their union. */
|
|
73
|
+
sourceIds?: string[] | null;
|
|
93
74
|
principals?: string[] | null;
|
|
94
75
|
cursor?: unknown;
|
|
95
76
|
limit?: number;
|
|
@@ -129,6 +110,13 @@ declare function queryStructured(question: string, opts: {
|
|
|
129
110
|
* call, no sandbox run — when the flag is `false`. That flag, not the
|
|
130
111
|
* isolate, is the actual security boundary.
|
|
131
112
|
*
|
|
113
|
+
* Only the document half lives here: fetch the in-scope tabular documents
|
|
114
|
+
* and parse their stored text into `{sheet: rows[]}`. Everything after that
|
|
115
|
+
* — the guards, both redaction surfaces below, the prompt → code → sandbox
|
|
116
|
+
* path and the swept result — is `computeOverFrames`, the seam a host calls
|
|
117
|
+
* when it already holds the frames and has no document to point at; this
|
|
118
|
+
* function builds its frames from documents and delegates.
|
|
119
|
+
*
|
|
132
120
|
* `config.redaction` is applied TWICE:
|
|
133
121
|
* 1. Each document's raw `.text` is masked BEFORE it is parsed into a
|
|
134
122
|
* table, so the data the LLM-authored code runs against is built from
|
|
@@ -146,6 +134,54 @@ declare function compute(instruction: string, opts: {
|
|
|
146
134
|
modelCfg?: LLMConfig | null;
|
|
147
135
|
timeout?: number;
|
|
148
136
|
}): Promise<Record<string, unknown>>;
|
|
137
|
+
/** What `compute()` builds and `computeOverFrames` consumes: sheet name → rows. */
|
|
138
|
+
type ComputeFrames = Record<string, Record<string, unknown>[]>;
|
|
139
|
+
/** A source document behind a frame, as `compute()` reports it in `documentsUsed`. */
|
|
140
|
+
interface ComputeDocument {
|
|
141
|
+
id: string;
|
|
142
|
+
name?: string | null;
|
|
143
|
+
sourceId?: string | null;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Compute an answer to `instruction` over caller-supplied tables.
|
|
147
|
+
*
|
|
148
|
+
* The frame-level seam under `compute()`: everything `compute()` does AFTER
|
|
149
|
+
* it has turned its documents into `{sheet: rows[]}` lives here, so a host
|
|
150
|
+
* that already holds the frames — an uploaded workbook, a connector's
|
|
151
|
+
* sheet, a query result — can run the same prompt → code → sandbox path
|
|
152
|
+
* without first ingesting a document to point at.
|
|
153
|
+
*
|
|
154
|
+
* `frames` keys are the sheet names the caller chose; the LLM sees them and
|
|
155
|
+
* each row's columns exactly as it sees a parsed document's.
|
|
156
|
+
*
|
|
157
|
+
* The guards are `compute()`'s, in the same order and all BEFORE any LLM
|
|
158
|
+
* call: `config.enableCodeExecution` off → `EngineActionError`; no LLM
|
|
159
|
+
* (`modelCfg` or `config.llm`) → `Error`; blank instruction or empty
|
|
160
|
+
* `frames` → `EngineActionError`; `timeout` clamped to 1..300 seconds.
|
|
161
|
+
*
|
|
162
|
+
* `config.redaction` is applied at the same two surfaces as `compute()`:
|
|
163
|
+
*
|
|
164
|
+
* 1. Every string cell and every column name is masked BEFORE the prompt is
|
|
165
|
+
* built (`maskFrames`), so neither the schema summary the LLM reads nor
|
|
166
|
+
* the rows its code runs against carry a raw value. Same intended
|
|
167
|
+
* trade-off as `compute()`'s point 1 — a masked cell can change a
|
|
168
|
+
* computed result, and that is correct.
|
|
169
|
+
* 2. The returned object is swept whole through `redactValueRecursive`,
|
|
170
|
+
* `code` included — `compute()`'s point 2, deliberately blunt.
|
|
171
|
+
*
|
|
172
|
+
* `hooks`, `principals` and `documents` are how `compute()` threads its own
|
|
173
|
+
* context through; a host calling the seam directly normally leaves them at
|
|
174
|
+
* their defaults (no error hook, trusted-internal `unless` evaluation, no
|
|
175
|
+
* source documents — `documentsUsed` comes back empty).
|
|
176
|
+
*/
|
|
177
|
+
declare function computeOverFrames(frames: ComputeFrames, instruction: string, opts: {
|
|
178
|
+
config: ContextEngineConfig;
|
|
179
|
+
modelCfg?: LLMConfig | null;
|
|
180
|
+
timeout?: number;
|
|
181
|
+
hooks?: Hooks | null;
|
|
182
|
+
principals?: string[] | null;
|
|
183
|
+
documents?: ComputeDocument[] | null;
|
|
184
|
+
}): Promise<Record<string, unknown>>;
|
|
149
185
|
|
|
150
186
|
/**
|
|
151
187
|
* AES-256-GCM crypto seam. Wire format is a compatibility promise with the
|
|
@@ -260,7 +296,9 @@ interface RunSearchOpts {
|
|
|
260
296
|
topK?: number;
|
|
261
297
|
mode?: Mode;
|
|
262
298
|
compressToTokens?: number | null;
|
|
263
|
-
|
|
299
|
+
/** A list, or a promise of one: passing a promise lets the graph leg run
|
|
300
|
+
* BESIDE the hybrid legs instead of ahead of them. */
|
|
301
|
+
graphRanked?: string[] | Promise<string[] | null> | null;
|
|
264
302
|
redaction?: RedactionPolicy | null;
|
|
265
303
|
}
|
|
266
304
|
/**
|
|
@@ -411,7 +449,13 @@ declare class ContextEngine implements ToolEngine {
|
|
|
411
449
|
documentIds?: string[] | null;
|
|
412
450
|
principals?: Principals;
|
|
413
451
|
topK?: number;
|
|
414
|
-
|
|
452
|
+
/**
|
|
453
|
+
* Omit it (or pass null) and the mode is worked out from the documents
|
|
454
|
+
* in scope: the graph leg runs when this deployment has a graph AND
|
|
455
|
+
* something in scope was ingested with `mode: "graph"`. Naming one
|
|
456
|
+
* forces it. The graph leg ADDS to the hybrid legs, never replaces them.
|
|
457
|
+
*/
|
|
458
|
+
mode?: "hybrid" | "graph" | null;
|
|
415
459
|
compressToTokens?: number | null;
|
|
416
460
|
redaction?: RedactionPolicy | null;
|
|
417
461
|
}): Promise<SearchResult>;
|
|
@@ -421,8 +465,25 @@ declare class ContextEngine implements ToolEngine {
|
|
|
421
465
|
* caller can never distinguish "doesn't exist" from "exists but you
|
|
422
466
|
* can't see it").
|
|
423
467
|
*/
|
|
468
|
+
/**
|
|
469
|
+
* How long a failed graph probe is remembered. One refused connection must
|
|
470
|
+
* not become one refused connection per request, and must not be permanent
|
|
471
|
+
* either — the database may come back.
|
|
472
|
+
*/
|
|
473
|
+
private static readonly GRAPH_PROBE_BACKOFF_MS;
|
|
474
|
+
private graphUnreachableUntil;
|
|
475
|
+
/**
|
|
476
|
+
* Is the graph database actually up?
|
|
477
|
+
*
|
|
478
|
+
* `graph.enabled` says the deployment is CONFIGURED, not that Neo4j is
|
|
479
|
+
* answering. Choosing the graph leg when it is unreachable buys a connection
|
|
480
|
+
* timeout on every search and no extra results, so a mode-less search checks
|
|
481
|
+
* first and remembers a failure briefly.
|
|
482
|
+
*/
|
|
483
|
+
private graphIsReachable;
|
|
424
484
|
getDocument(documentId: string, opts?: {
|
|
425
485
|
principals?: Principals;
|
|
486
|
+
redaction?: RedactionPolicy | null;
|
|
426
487
|
}): Promise<Record<string, unknown>>;
|
|
427
488
|
deleteDocument(documentId: string, opts?: {
|
|
428
489
|
principals?: Principals;
|
|
@@ -447,17 +508,78 @@ declare class ContextEngine implements ToolEngine {
|
|
|
447
508
|
getDocumentText(documentId: string, opts?: {
|
|
448
509
|
principals?: Principals;
|
|
449
510
|
}): Promise<string>;
|
|
511
|
+
/**
|
|
512
|
+
* The ONE knowledge tool, as a library call. See `knowledge-tool.ts`.
|
|
513
|
+
*
|
|
514
|
+
* The same function the MCP server serves — an application driving its own
|
|
515
|
+
* agent loop hands its model this one door to the corpus without speaking
|
|
516
|
+
* MCP at all, and cannot get a different answer, because there is one
|
|
517
|
+
* implementation behind both surfaces.
|
|
518
|
+
*/
|
|
519
|
+
searchKnowledgeBase(args: {
|
|
520
|
+
action: string;
|
|
521
|
+
principals?: Principals;
|
|
522
|
+
scope: ScopeInput;
|
|
523
|
+
query?: string | null;
|
|
524
|
+
document_id?: string | null;
|
|
525
|
+
source_ids?: string[] | null;
|
|
526
|
+
document_ids?: string[] | null;
|
|
527
|
+
entity?: string | null;
|
|
528
|
+
depth?: number | null;
|
|
529
|
+
category?: string | null;
|
|
530
|
+
label?: string | null;
|
|
531
|
+
entity_type?: string | null;
|
|
532
|
+
top_k?: number | null;
|
|
533
|
+
mode?: string | null;
|
|
534
|
+
limit?: number | null;
|
|
535
|
+
cursor?: unknown;
|
|
536
|
+
redaction?: RedactionPolicy | null;
|
|
537
|
+
compute?: KnowledgeComputeFn | null;
|
|
538
|
+
map_reduce?: ((instruction: string, opts: Record<string, unknown>) => Promise<Record<string, unknown>>) | null;
|
|
539
|
+
start?: number | null;
|
|
540
|
+
end?: number | null;
|
|
541
|
+
max_chars?: number | null;
|
|
542
|
+
}): Promise<Record<string, unknown>>;
|
|
543
|
+
/** Read one document in order, a range of chunks at a time. */
|
|
544
|
+
getChunks(documentId: string, opts?: {
|
|
545
|
+
principals?: Principals;
|
|
546
|
+
start?: number | null;
|
|
547
|
+
end?: number | null;
|
|
548
|
+
redaction?: RedactionPolicy | null;
|
|
549
|
+
}): Promise<Record<string, unknown>>;
|
|
550
|
+
/**
|
|
551
|
+
* Several whole documents at once, each ACL-checked. An id that is absent OR
|
|
552
|
+
* not visible is simply missing from the result, never an error — the same
|
|
553
|
+
* non-disclosure `getDocument` gives, which a batch read is the classic
|
|
554
|
+
* place to lose.
|
|
555
|
+
*/
|
|
556
|
+
getDocuments(documentIds: string[], opts?: {
|
|
557
|
+
principals?: Principals;
|
|
558
|
+
redaction?: RedactionPolicy | null;
|
|
559
|
+
}): Promise<Array<Record<string, unknown>>>;
|
|
560
|
+
/** Ask the same question of every document in scope. */
|
|
561
|
+
mapReduce(instruction: string, opts?: {
|
|
562
|
+
principals?: Principals;
|
|
563
|
+
sourceIds?: string[] | null;
|
|
564
|
+
documentIds?: string[] | null;
|
|
565
|
+
limit?: number | null;
|
|
566
|
+
maxConcurrency?: number | null;
|
|
567
|
+
redaction?: RedactionPolicy | null;
|
|
568
|
+
}): Promise<Record<string, unknown>>;
|
|
450
569
|
listDocuments(opts?: {
|
|
451
570
|
sourceId?: string | null;
|
|
571
|
+
sourceIds?: string[] | null;
|
|
452
572
|
principals?: Principals;
|
|
453
573
|
cursor?: unknown;
|
|
454
574
|
limit?: number;
|
|
575
|
+
redaction?: RedactionPolicy | null;
|
|
455
576
|
}): Promise<Record<string, unknown>>;
|
|
456
577
|
queryStructured(question: string, opts?: {
|
|
457
578
|
sourceIds?: string[] | null;
|
|
458
579
|
principals?: Principals;
|
|
459
580
|
docType?: string | null;
|
|
460
581
|
limit?: number;
|
|
582
|
+
redaction?: RedactionPolicy | null;
|
|
461
583
|
}): Promise<Record<string, unknown>>;
|
|
462
584
|
compute(instruction: string, opts?: {
|
|
463
585
|
sourceIds?: string[] | null;
|
|
@@ -811,4 +933,4 @@ declare function functionTool(fn: (...args: never[]) => unknown): CanonicalTool;
|
|
|
811
933
|
/** Bumped by CI on every main merge; 0.0.0 = pre-first-release. */
|
|
812
934
|
declare const __version__ = "0.0.0";
|
|
813
935
|
|
|
814
|
-
export { ApprovalExpired, ApprovalNotPending, type ApprovalRecord, CeleryRunner, CodeExecutionError, CodeExecutionTimeout, ContextEngine, ContextEngineConfig, DEFAULT_LEG_WEIGHT, DocumentNotFoundError, EXTRACTION_VERSION, Embedder, EngineActionError, ExtraMissingError, Extracted, ExtractionConfig, type ExtractionResult, GraphLegUnavailable, type Hit, Hooks, InProcessRunner, IngestReport, LLMClient, LLMConfig,
|
|
936
|
+
export { ApprovalExpired, ApprovalNotPending, type ApprovalRecord, CeleryRunner, CodeExecutionError, CodeExecutionTimeout, type ComputeDocument, type ComputeFrames, ContextEngine, ContextEngineConfig, DEFAULT_LEG_WEIGHT, DocumentNotFoundError, EXTRACTION_VERSION, Embedder, EngineActionError, ExtraMissingError, Extracted, ExtractionConfig, type ExtractionResult, GraphLegUnavailable, type Hit, Hooks, InProcessRunner, IngestReport, KnowledgeComputeFn, LLMClient, LLMConfig, Principals, ProgressEvent, RedactionPolicy, RerankerConfig, ScopeInput, type SearchResult, StorageBackend, type TaskRunner, type TaskStatus, ToolConfig, Trusted, Unset, UsageEvent, __version__, buildLlmClient, callLlm, compute, computeOverFrames, decryptDict, encryptDict, extract, extractStructuredData, functionTool, getDocumentText, getSecretKey, listDocuments, queryStructured, redactHits, rerank, resolveApproval, resolveFields, rrfFuse, runMigrate, runSearch, shouldRequireApproval, upsertRegistry };
|