@tenphi/akno-protocol 0.1.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/LICENSE +83 -0
- package/README.md +26 -0
- package/dist/common.d.ts +1553 -0
- package/dist/common.d.ts.map +1 -0
- package/dist/common.js +309 -0
- package/dist/common.js.map +1 -0
- package/dist/errors.d.ts +24 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +69 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +16 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +16 -0
- package/dist/index.js.map +1 -0
- package/dist/ops/answer.d.ts +207 -0
- package/dist/ops/answer.d.ts.map +1 -0
- package/dist/ops/answer.js +90 -0
- package/dist/ops/answer.js.map +1 -0
- package/dist/ops/context.d.ts +845 -0
- package/dist/ops/context.d.ts.map +1 -0
- package/dist/ops/context.js +82 -0
- package/dist/ops/context.js.map +1 -0
- package/dist/ops/folder.d.ts +85 -0
- package/dist/ops/folder.d.ts.map +1 -0
- package/dist/ops/folder.js +56 -0
- package/dist/ops/folder.js.map +1 -0
- package/dist/ops/graph.d.ts +352 -0
- package/dist/ops/graph.d.ts.map +1 -0
- package/dist/ops/graph.js +63 -0
- package/dist/ops/graph.js.map +1 -0
- package/dist/ops/list.d.ts +136 -0
- package/dist/ops/list.d.ts.map +1 -0
- package/dist/ops/list.js +57 -0
- package/dist/ops/list.js.map +1 -0
- package/dist/ops/mutate.d.ts +432 -0
- package/dist/ops/mutate.d.ts.map +1 -0
- package/dist/ops/mutate.js +234 -0
- package/dist/ops/mutate.js.map +1 -0
- package/dist/ops/read.d.ts +242 -0
- package/dist/ops/read.d.ts.map +1 -0
- package/dist/ops/read.js +65 -0
- package/dist/ops/read.js.map +1 -0
- package/dist/ops/recall.d.ts +531 -0
- package/dist/ops/recall.d.ts.map +1 -0
- package/dist/ops/recall.js +59 -0
- package/dist/ops/recall.js.map +1 -0
- package/dist/ops/timeline.d.ts +264 -0
- package/dist/ops/timeline.d.ts.map +1 -0
- package/dist/ops/timeline.js +68 -0
- package/dist/ops/timeline.js.map +1 -0
- package/dist/ops/write.d.ts +182 -0
- package/dist/ops/write.d.ts.map +1 -0
- package/dist/ops/write.js +114 -0
- package/dist/ops/write.js.map +1 -0
- package/dist/registry.d.ts +2657 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +191 -0
- package/dist/registry.js.map +1 -0
- package/dist/version.d.ts +14 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +14 -0
- package/dist/version.js.map +1 -0
- package/dist/wire.d.ts +112 -0
- package/dist/wire.d.ts.map +1 -0
- package/dist/wire.js +102 -0
- package/dist/wire.js.map +1 -0
- package/package.json +38 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/ops/context.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAYxB,eAAO,MAAM,cAAc;;;EAAqC,CAAC;AACjE,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAE5D,eAAO,MAAM,gBAAgB;;;;;;iBAG3B,CAAC;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAEhE;;;;;GAKG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAsCrB,CAAC;AACL,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC;AAExD,eAAO,MAAM,oBAAoB;;;;;;;;;;;iBAM/B,CAAC;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAExE,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAuBxB,CAAC;AACH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAC"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { Card, PageRole, RecallMode, RecallQualification, RecallResult, ResultEnvelope, SlugFilter, } from "../common.js";
|
|
3
|
+
import { TimelineResult } from "./timeline.js";
|
|
4
|
+
export const ContextProfile = z.enum(['default', 'auto_recall']);
|
|
5
|
+
export const ConversationTurn = z.object({
|
|
6
|
+
role: z.enum(['user', 'assistant']),
|
|
7
|
+
content: z.string().min(1).max(2000),
|
|
8
|
+
});
|
|
9
|
+
/**
|
|
10
|
+
* One budget, one assembly. `context` composes the whole pre-turn bundle —
|
|
11
|
+
* pinned pages, recent timeline, structure tree, and this turn's recall —
|
|
12
|
+
* against a single budget. Separate injections with separate budgets overrun
|
|
13
|
+
* together. Normally called by the host, not by the agent.
|
|
14
|
+
*/
|
|
15
|
+
export const ContextInput = z
|
|
16
|
+
.object({
|
|
17
|
+
query: z.string().min(1).optional(),
|
|
18
|
+
/** `auto_recall` is a conservative evidence-only host injection, not an answer operation. */
|
|
19
|
+
profile: ContextProfile.optional(),
|
|
20
|
+
/** Bounded recent turns used only to resolve a local reference in `query`. */
|
|
21
|
+
conversation_context: z.array(ConversationTurn).max(6).optional(),
|
|
22
|
+
/** Defaults to 20,000 for the broad profile and 1,200 for auto-recall. */
|
|
23
|
+
budget: z.number().int().positive().optional(),
|
|
24
|
+
/** Slugs always included, before anything else competes for room. Ignored by auto-recall. */
|
|
25
|
+
pinned: z.array(z.string()).optional(),
|
|
26
|
+
/** Days of ledger to include. 0 omits the section. Ignored by auto-recall. */
|
|
27
|
+
timeline_days: z.number().int().nonnegative().optional(),
|
|
28
|
+
/** Include a folder outline so the agent knows what exists. Ignored by auto-recall. */
|
|
29
|
+
structure: z.boolean().optional(),
|
|
30
|
+
mode: RecallMode.optional(),
|
|
31
|
+
include: z.array(PageRole).optional(),
|
|
32
|
+
filter: SlugFilter.optional(),
|
|
33
|
+
})
|
|
34
|
+
.superRefine((input, check) => {
|
|
35
|
+
if (input.profile === 'auto_recall' && !input.query) {
|
|
36
|
+
check.addIssue({
|
|
37
|
+
code: 'custom',
|
|
38
|
+
path: ['query'],
|
|
39
|
+
message: 'query is required for the auto_recall context profile',
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
const conversationChars = (input.conversation_context ?? []).reduce((total, turn) => total + turn.content.length, 0);
|
|
43
|
+
if (conversationChars > 6000) {
|
|
44
|
+
check.addIssue({
|
|
45
|
+
code: 'custom',
|
|
46
|
+
path: ['conversation_context'],
|
|
47
|
+
message: 'recent conversation context must not exceed 6000 characters',
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
export const AutoRecallActivation = z.object({
|
|
52
|
+
activated: z.boolean(),
|
|
53
|
+
basis: z.enum(['exact', 'semantic', 'qualified', 'none']),
|
|
54
|
+
candidates: z.number().int().nonnegative(),
|
|
55
|
+
selected: z.number().int().nonnegative(),
|
|
56
|
+
qualification_run: z.boolean(),
|
|
57
|
+
});
|
|
58
|
+
export const ContextOutput = ResultEnvelope.extend({
|
|
59
|
+
profile: ContextProfile.optional(),
|
|
60
|
+
/** Content-free receipt for the precision-first auto-recall activation decision. */
|
|
61
|
+
activation: AutoRecallActivation.optional(),
|
|
62
|
+
pinned: z.array(Card),
|
|
63
|
+
/** Mixed page/document results for this turn's recall. */
|
|
64
|
+
results: z.array(RecallResult),
|
|
65
|
+
/** Recent authored events and typed orphan-document date evidence. */
|
|
66
|
+
timeline: z.array(TimelineResult),
|
|
67
|
+
structure: z.string().optional(),
|
|
68
|
+
searched: z.array(z.string()),
|
|
69
|
+
coverage: z.record(z.string(), z.boolean()).optional(),
|
|
70
|
+
qualification: RecallQualification.optional(),
|
|
71
|
+
budget_used: z.number().int().nonnegative(),
|
|
72
|
+
/** What was dropped to fit, and how much of it. A silent trim reads as
|
|
73
|
+
* "that's everything" when it wasn't — default to visible. */
|
|
74
|
+
dropped: z
|
|
75
|
+
.object({
|
|
76
|
+
pinned: z.number().int().nonnegative(),
|
|
77
|
+
results: z.number().int().nonnegative(),
|
|
78
|
+
timeline: z.number().int().nonnegative(),
|
|
79
|
+
})
|
|
80
|
+
.optional(),
|
|
81
|
+
});
|
|
82
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/ops/context.ts"],"names":[],"m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SACD,QAAQ,EAAE;CACd,CAAC,CAAC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/**
|
|
3
|
+
* **Declare a folder before writing into it.**
|
|
4
|
+
*
|
|
5
|
+
* A folder used to appear the moment a page was written under it, and a new top-level one
|
|
6
|
+
* became a question for the owner. Both halves were wrong. The owner does not want to be
|
|
7
|
+
* asked where an agent's research note goes; and a folder that appears with no statement of
|
|
8
|
+
* what belongs in it is a folder the next caller has to guess about — which is how evidence
|
|
9
|
+
* and claims end up in the same place, and how a rent figure from a transcript gets filed as
|
|
10
|
+
* a defence strategy.
|
|
11
|
+
*
|
|
12
|
+
* So this op is **never gated**: nothing here waits on a human. What it costs instead is a
|
|
13
|
+
* sentence. Saying what the folder is for is the whole point of the step, which is why
|
|
14
|
+
* `description` is required and everything else is optional.
|
|
15
|
+
*/
|
|
16
|
+
export declare const FolderInput: z.ZodObject<{
|
|
17
|
+
path: z.ZodString;
|
|
18
|
+
description: z.ZodString;
|
|
19
|
+
role: z.ZodOptional<z.ZodEnum<{
|
|
20
|
+
knowledge: "knowledge";
|
|
21
|
+
source: "source";
|
|
22
|
+
inference: "inference";
|
|
23
|
+
ignored: "ignored";
|
|
24
|
+
}>>;
|
|
25
|
+
remember: z.ZodOptional<z.ZodEnum<{
|
|
26
|
+
deny: "deny";
|
|
27
|
+
integrate: "integrate";
|
|
28
|
+
}>>;
|
|
29
|
+
about: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
30
|
+
type: z.ZodOptional<z.ZodString>;
|
|
31
|
+
ingest: z.ZodOptional<z.ZodEnum<{
|
|
32
|
+
file: "file";
|
|
33
|
+
page: "page";
|
|
34
|
+
document: "document";
|
|
35
|
+
auto: "auto";
|
|
36
|
+
ignore: "ignore";
|
|
37
|
+
}>>;
|
|
38
|
+
rank: z.ZodOptional<z.ZodNumber>;
|
|
39
|
+
route: z.ZodOptional<z.ZodBoolean>;
|
|
40
|
+
dry_run: z.ZodOptional<z.ZodBoolean>;
|
|
41
|
+
}, z.core.$strip>;
|
|
42
|
+
export type FolderInput = z.infer<typeof FolderInput>;
|
|
43
|
+
export declare const FolderOutput: z.ZodObject<{
|
|
44
|
+
status: z.ZodEnum<{
|
|
45
|
+
ok: "ok";
|
|
46
|
+
empty: "empty";
|
|
47
|
+
degraded: "degraded";
|
|
48
|
+
unavailable: "unavailable";
|
|
49
|
+
}>;
|
|
50
|
+
degraded: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
51
|
+
no_embedding_model: "no_embedding_model";
|
|
52
|
+
no_reranker: "no_reranker";
|
|
53
|
+
no_derive_model: "no_derive_model";
|
|
54
|
+
no_expansion_model: "no_expansion_model";
|
|
55
|
+
embedding_failed: "embedding_failed";
|
|
56
|
+
rerank_failed: "rerank_failed";
|
|
57
|
+
derive_failed: "derive_failed";
|
|
58
|
+
expansion_failed: "expansion_failed";
|
|
59
|
+
no_vector_index: "no_vector_index";
|
|
60
|
+
partial_index: "partial_index";
|
|
61
|
+
no_document_text: "no_document_text";
|
|
62
|
+
document_source_missing: "document_source_missing";
|
|
63
|
+
no_graph_index: "no_graph_index";
|
|
64
|
+
no_entity_index: "no_entity_index";
|
|
65
|
+
entity_resolution_failed: "entity_resolution_failed";
|
|
66
|
+
partial_graph_index: "partial_graph_index";
|
|
67
|
+
graph_traversal_limited: "graph_traversal_limited";
|
|
68
|
+
no_answer_model: "no_answer_model";
|
|
69
|
+
answer_failed: "answer_failed";
|
|
70
|
+
answer_verification_failed: "answer_verification_failed";
|
|
71
|
+
answer_truncated: "answer_truncated";
|
|
72
|
+
}>>>;
|
|
73
|
+
note: z.ZodOptional<z.ZodString>;
|
|
74
|
+
outcome: z.ZodEnum<{
|
|
75
|
+
ok: "ok";
|
|
76
|
+
noop: "noop";
|
|
77
|
+
}>;
|
|
78
|
+
glob: z.ZodOptional<z.ZodString>;
|
|
79
|
+
path: z.ZodOptional<z.ZodString>;
|
|
80
|
+
rule: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
81
|
+
rules_file: z.ZodOptional<z.ZodString>;
|
|
82
|
+
change_id: z.ZodOptional<z.ZodString>;
|
|
83
|
+
}, z.core.$strip>;
|
|
84
|
+
export type FolderOutput = z.infer<typeof FolderOutput>;
|
|
85
|
+
//# sourceMappingURL=folder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"folder.d.ts","sourceRoot":"","sources":["../../src/ops/folder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;iBA0BtB,CAAC;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAEtD,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAWvB,CAAC;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { PageRole, RememberManagement, ResultEnvelope } from "../common.js";
|
|
3
|
+
/**
|
|
4
|
+
* **Declare a folder before writing into it.**
|
|
5
|
+
*
|
|
6
|
+
* A folder used to appear the moment a page was written under it, and a new top-level one
|
|
7
|
+
* became a question for the owner. Both halves were wrong. The owner does not want to be
|
|
8
|
+
* asked where an agent's research note goes; and a folder that appears with no statement of
|
|
9
|
+
* what belongs in it is a folder the next caller has to guess about — which is how evidence
|
|
10
|
+
* and claims end up in the same place, and how a rent figure from a transcript gets filed as
|
|
11
|
+
* a defence strategy.
|
|
12
|
+
*
|
|
13
|
+
* So this op is **never gated**: nothing here waits on a human. What it costs instead is a
|
|
14
|
+
* sentence. Saying what the folder is for is the whole point of the step, which is why
|
|
15
|
+
* `description` is required and everything else is optional.
|
|
16
|
+
*/
|
|
17
|
+
export const FolderInput = z.object({
|
|
18
|
+
/** The folder, as a slug prefix: `research`, `household/appliances`. No globs, no `.md`. */
|
|
19
|
+
path: z.string().min(1),
|
|
20
|
+
/**
|
|
21
|
+
* What belongs here, in a sentence, written for a caller who has never seen this knowledge
|
|
22
|
+
* base. It is returned by `list` and carried in the pre-turn bundle, so it is the thing that
|
|
23
|
+
* makes the folder self-explanatory later.
|
|
24
|
+
*/
|
|
25
|
+
description: z.string().min(1).max(500),
|
|
26
|
+
/** `knowledge` for canonical claims, `source` for quoted evidence, `inference` for
|
|
27
|
+
* model conclusions, and `ignored` for material outside memory. */
|
|
28
|
+
role: PageRole.optional(),
|
|
29
|
+
/** Whether `remember` may place canonical claims in pages in this folder. When omitted,
|
|
30
|
+
* a declared knowledge folder integrates and every non-knowledge role denies. The resolved
|
|
31
|
+
* value is persisted in the rule rather than inherited from a global default. */
|
|
32
|
+
remember: RememberManagement.optional(),
|
|
33
|
+
/** Canonical entities pages in this folder are about. */
|
|
34
|
+
about: z.array(z.string()).optional(),
|
|
35
|
+
/** Default `type` for pages here, when the folder has one. */
|
|
36
|
+
type: z.string().optional(),
|
|
37
|
+
ingest: z.enum(['page', 'document', 'file', 'auto', 'ignore']).optional(),
|
|
38
|
+
/** Multiplied into the recall score. Demotes without hiding. */
|
|
39
|
+
rank: z.number().min(0).max(2).optional(),
|
|
40
|
+
/** Makes this an inbox: arrivals are extracted, named and moved out of it. */
|
|
41
|
+
route: z.boolean().optional(),
|
|
42
|
+
dry_run: z.boolean().optional(),
|
|
43
|
+
});
|
|
44
|
+
export const FolderOutput = ResultEnvelope.extend({
|
|
45
|
+
/** `noop` when the folder was already declared — its existing rule comes back unchanged. */
|
|
46
|
+
outcome: z.enum(['ok', 'noop']),
|
|
47
|
+
/** The glob the rule was filed under, e.g. `research/**`. */
|
|
48
|
+
glob: z.string().optional(),
|
|
49
|
+
path: z.string().optional(),
|
|
50
|
+
/** The rule now in force for this folder. */
|
|
51
|
+
rule: z.record(z.string(), z.unknown()).optional(),
|
|
52
|
+
/** The file the rule was written to, so a caller can say where the taxonomy lives. */
|
|
53
|
+
rules_file: z.string().optional(),
|
|
54
|
+
change_id: z.string().optional(),
|
|
55
|
+
});
|
|
56
|
+
//# sourceMappingURL=folder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"folder.js","sourceRoot":"","sources":["../../src/ops/folder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,QAAQ,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAE5E;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC;IAClC,4FAA4F;IAC5F,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACvB;;;;OAIG;IACH,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC;IACvC;uEACmE;IACnE,IAAI,EAAE,QAAQ,CAAC,QAAQ,EAAE;IACzB;;qFAEiF;IACjF,QAAQ,EAAE,kBAAkB,CAAC,QAAQ,EAAE;IACvC,yDAAyD;IACzD,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE;IACrC,8DAA8D;IAC9D,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC3B,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC,CAAC,QAAQ,EAAE;IACzE,gEAAgE;IAChE,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE;IACzC,8EAA8E;IAC9E,KAAK,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;IAC7B,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE;CAChC,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,YAAY,GAAG,cAAc,CAAC,MAAM,CAAC;IAChD,4FAA4F;IAC5F,OAAO,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IAC/B,6DAA6D;IAC7D,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC3B,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC3B,6CAA6C;IAC7C,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC,QAAQ,EAAE;IAClD,sFAAsF;IACtF,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IACjC,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;CACjC,CAAC,CAAC"}
|
|
@@ -0,0 +1,352 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const GraphDirection: z.ZodEnum<{
|
|
3
|
+
out: "out";
|
|
4
|
+
in: "in";
|
|
5
|
+
both: "both";
|
|
6
|
+
}>;
|
|
7
|
+
export type GraphDirection = z.infer<typeof GraphDirection>;
|
|
8
|
+
/** One exact seed form. Query seeds still resolve only evidence-declared names. */
|
|
9
|
+
export declare const GraphInput: z.ZodObject<{
|
|
10
|
+
slug: z.ZodOptional<z.ZodString>;
|
|
11
|
+
entity: z.ZodOptional<z.ZodString>;
|
|
12
|
+
query: z.ZodOptional<z.ZodString>;
|
|
13
|
+
direction: z.ZodOptional<z.ZodEnum<{
|
|
14
|
+
out: "out";
|
|
15
|
+
in: "in";
|
|
16
|
+
both: "both";
|
|
17
|
+
}>>;
|
|
18
|
+
relations: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
19
|
+
canonical_record: "canonical_record";
|
|
20
|
+
links_to: "links_to";
|
|
21
|
+
mentions: "mentions";
|
|
22
|
+
about: "about";
|
|
23
|
+
has_attribute: "has_attribute";
|
|
24
|
+
related_entity: "related_entity";
|
|
25
|
+
owns_document: "owns_document";
|
|
26
|
+
participates_in: "participates_in";
|
|
27
|
+
}>>>;
|
|
28
|
+
max_hops: z.ZodOptional<z.ZodUnion<readonly [z.ZodLiteral<1>, z.ZodLiteral<2>, z.ZodLiteral<3>]>>;
|
|
29
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
30
|
+
include_history: z.ZodOptional<z.ZodBoolean>;
|
|
31
|
+
}, z.core.$strip>;
|
|
32
|
+
export type GraphInput = z.infer<typeof GraphInput>;
|
|
33
|
+
export declare const GraphEdgeRef: z.ZodObject<{
|
|
34
|
+
id: z.ZodString;
|
|
35
|
+
from: z.ZodString;
|
|
36
|
+
to: z.ZodString;
|
|
37
|
+
relation: z.ZodEnum<{
|
|
38
|
+
canonical_record: "canonical_record";
|
|
39
|
+
links_to: "links_to";
|
|
40
|
+
mentions: "mentions";
|
|
41
|
+
about: "about";
|
|
42
|
+
has_attribute: "has_attribute";
|
|
43
|
+
related_entity: "related_entity";
|
|
44
|
+
owns_document: "owns_document";
|
|
45
|
+
participates_in: "participates_in";
|
|
46
|
+
}>;
|
|
47
|
+
predicate: z.ZodOptional<z.ZodString>;
|
|
48
|
+
confidence: z.ZodNumber;
|
|
49
|
+
derivation: z.ZodEnum<{
|
|
50
|
+
fact: "fact";
|
|
51
|
+
structural: "structural";
|
|
52
|
+
}>;
|
|
53
|
+
resolution: z.ZodEnum<{
|
|
54
|
+
exact: "exact";
|
|
55
|
+
contextual: "contextual";
|
|
56
|
+
}>;
|
|
57
|
+
evidence: z.ZodObject<{
|
|
58
|
+
kind: z.ZodEnum<{
|
|
59
|
+
document: "document";
|
|
60
|
+
page_line: "page_line";
|
|
61
|
+
fact_line: "fact_line";
|
|
62
|
+
frontmatter: "frontmatter";
|
|
63
|
+
}>;
|
|
64
|
+
slug: z.ZodOptional<z.ZodString>;
|
|
65
|
+
document: z.ZodOptional<z.ZodString>;
|
|
66
|
+
event: z.ZodOptional<z.ZodString>;
|
|
67
|
+
fact: z.ZodOptional<z.ZodString>;
|
|
68
|
+
line_start: z.ZodOptional<z.ZodNumber>;
|
|
69
|
+
line_end: z.ZodOptional<z.ZodNumber>;
|
|
70
|
+
field: z.ZodOptional<z.ZodString>;
|
|
71
|
+
}, z.core.$strip>;
|
|
72
|
+
valid_from: z.ZodOptional<z.ZodString>;
|
|
73
|
+
valid_to: z.ZodOptional<z.ZodString>;
|
|
74
|
+
historical: z.ZodBoolean;
|
|
75
|
+
}, z.core.$strip>;
|
|
76
|
+
export type GraphEdgeRef = z.infer<typeof GraphEdgeRef>;
|
|
77
|
+
export declare const GraphSeed: z.ZodObject<{
|
|
78
|
+
form: z.ZodEnum<{
|
|
79
|
+
entity: "entity";
|
|
80
|
+
slug: "slug";
|
|
81
|
+
query: "query";
|
|
82
|
+
}>;
|
|
83
|
+
value: z.ZodString;
|
|
84
|
+
node: z.ZodString;
|
|
85
|
+
}, z.core.$strip>;
|
|
86
|
+
export type GraphSeed = z.infer<typeof GraphSeed>;
|
|
87
|
+
export declare const GraphPath: z.ZodObject<{
|
|
88
|
+
seed: z.ZodString;
|
|
89
|
+
nodes: z.ZodArray<z.ZodString>;
|
|
90
|
+
edges: z.ZodArray<z.ZodString>;
|
|
91
|
+
hops: z.ZodNumber;
|
|
92
|
+
confidence: z.ZodNumber;
|
|
93
|
+
evidence: z.ZodArray<z.ZodObject<{
|
|
94
|
+
kind: z.ZodEnum<{
|
|
95
|
+
document: "document";
|
|
96
|
+
page_line: "page_line";
|
|
97
|
+
fact_line: "fact_line";
|
|
98
|
+
frontmatter: "frontmatter";
|
|
99
|
+
}>;
|
|
100
|
+
slug: z.ZodOptional<z.ZodString>;
|
|
101
|
+
document: z.ZodOptional<z.ZodString>;
|
|
102
|
+
event: z.ZodOptional<z.ZodString>;
|
|
103
|
+
fact: z.ZodOptional<z.ZodString>;
|
|
104
|
+
line_start: z.ZodOptional<z.ZodNumber>;
|
|
105
|
+
line_end: z.ZodOptional<z.ZodNumber>;
|
|
106
|
+
field: z.ZodOptional<z.ZodString>;
|
|
107
|
+
}, z.core.$strip>>;
|
|
108
|
+
}, z.core.$strip>;
|
|
109
|
+
export type GraphPath = z.infer<typeof GraphPath>;
|
|
110
|
+
export declare const GraphAmbiguity: z.ZodObject<{
|
|
111
|
+
mention: z.ZodString;
|
|
112
|
+
normalized: z.ZodString;
|
|
113
|
+
candidates: z.ZodArray<z.ZodObject<{
|
|
114
|
+
id: z.ZodString;
|
|
115
|
+
kind: z.ZodEnum<{
|
|
116
|
+
fact: "fact";
|
|
117
|
+
entity: "entity";
|
|
118
|
+
page: "page";
|
|
119
|
+
document: "document";
|
|
120
|
+
event: "event";
|
|
121
|
+
}>;
|
|
122
|
+
slug: z.ZodOptional<z.ZodString>;
|
|
123
|
+
label: z.ZodOptional<z.ZodString>;
|
|
124
|
+
role: z.ZodOptional<z.ZodEnum<{
|
|
125
|
+
knowledge: "knowledge";
|
|
126
|
+
source: "source";
|
|
127
|
+
inference: "inference";
|
|
128
|
+
ignored: "ignored";
|
|
129
|
+
}>>;
|
|
130
|
+
entity: z.ZodOptional<z.ZodString>;
|
|
131
|
+
entity_type: z.ZodOptional<z.ZodEnum<{
|
|
132
|
+
event: "event";
|
|
133
|
+
person: "person";
|
|
134
|
+
organization: "organization";
|
|
135
|
+
place: "place";
|
|
136
|
+
product: "product";
|
|
137
|
+
concept: "concept";
|
|
138
|
+
other: "other";
|
|
139
|
+
}>>;
|
|
140
|
+
document: z.ZodOptional<z.ZodString>;
|
|
141
|
+
fact: z.ZodOptional<z.ZodString>;
|
|
142
|
+
event: z.ZodOptional<z.ZodString>;
|
|
143
|
+
date: z.ZodOptional<z.ZodString>;
|
|
144
|
+
line_start: z.ZodOptional<z.ZodNumber>;
|
|
145
|
+
line_end: z.ZodOptional<z.ZodNumber>;
|
|
146
|
+
availability: z.ZodOptional<z.ZodEnum<{
|
|
147
|
+
degraded: "degraded";
|
|
148
|
+
unavailable: "unavailable";
|
|
149
|
+
available: "available";
|
|
150
|
+
}>>;
|
|
151
|
+
}, z.core.$strip>>;
|
|
152
|
+
}, z.core.$strip>;
|
|
153
|
+
export type GraphAmbiguity = z.infer<typeof GraphAmbiguity>;
|
|
154
|
+
export declare const GraphOutput: z.ZodObject<{
|
|
155
|
+
status: z.ZodEnum<{
|
|
156
|
+
ok: "ok";
|
|
157
|
+
empty: "empty";
|
|
158
|
+
degraded: "degraded";
|
|
159
|
+
unavailable: "unavailable";
|
|
160
|
+
}>;
|
|
161
|
+
degraded: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
162
|
+
no_embedding_model: "no_embedding_model";
|
|
163
|
+
no_reranker: "no_reranker";
|
|
164
|
+
no_derive_model: "no_derive_model";
|
|
165
|
+
no_expansion_model: "no_expansion_model";
|
|
166
|
+
embedding_failed: "embedding_failed";
|
|
167
|
+
rerank_failed: "rerank_failed";
|
|
168
|
+
derive_failed: "derive_failed";
|
|
169
|
+
expansion_failed: "expansion_failed";
|
|
170
|
+
no_vector_index: "no_vector_index";
|
|
171
|
+
partial_index: "partial_index";
|
|
172
|
+
no_document_text: "no_document_text";
|
|
173
|
+
document_source_missing: "document_source_missing";
|
|
174
|
+
no_graph_index: "no_graph_index";
|
|
175
|
+
no_entity_index: "no_entity_index";
|
|
176
|
+
entity_resolution_failed: "entity_resolution_failed";
|
|
177
|
+
partial_graph_index: "partial_graph_index";
|
|
178
|
+
graph_traversal_limited: "graph_traversal_limited";
|
|
179
|
+
no_answer_model: "no_answer_model";
|
|
180
|
+
answer_failed: "answer_failed";
|
|
181
|
+
answer_verification_failed: "answer_verification_failed";
|
|
182
|
+
answer_truncated: "answer_truncated";
|
|
183
|
+
}>>>;
|
|
184
|
+
note: z.ZodOptional<z.ZodString>;
|
|
185
|
+
seeds: z.ZodArray<z.ZodObject<{
|
|
186
|
+
form: z.ZodEnum<{
|
|
187
|
+
entity: "entity";
|
|
188
|
+
slug: "slug";
|
|
189
|
+
query: "query";
|
|
190
|
+
}>;
|
|
191
|
+
value: z.ZodString;
|
|
192
|
+
node: z.ZodString;
|
|
193
|
+
}, z.core.$strip>>;
|
|
194
|
+
nodes: z.ZodArray<z.ZodObject<{
|
|
195
|
+
id: z.ZodString;
|
|
196
|
+
kind: z.ZodEnum<{
|
|
197
|
+
fact: "fact";
|
|
198
|
+
entity: "entity";
|
|
199
|
+
page: "page";
|
|
200
|
+
document: "document";
|
|
201
|
+
event: "event";
|
|
202
|
+
}>;
|
|
203
|
+
slug: z.ZodOptional<z.ZodString>;
|
|
204
|
+
label: z.ZodOptional<z.ZodString>;
|
|
205
|
+
role: z.ZodOptional<z.ZodEnum<{
|
|
206
|
+
knowledge: "knowledge";
|
|
207
|
+
source: "source";
|
|
208
|
+
inference: "inference";
|
|
209
|
+
ignored: "ignored";
|
|
210
|
+
}>>;
|
|
211
|
+
entity: z.ZodOptional<z.ZodString>;
|
|
212
|
+
entity_type: z.ZodOptional<z.ZodEnum<{
|
|
213
|
+
event: "event";
|
|
214
|
+
person: "person";
|
|
215
|
+
organization: "organization";
|
|
216
|
+
place: "place";
|
|
217
|
+
product: "product";
|
|
218
|
+
concept: "concept";
|
|
219
|
+
other: "other";
|
|
220
|
+
}>>;
|
|
221
|
+
document: z.ZodOptional<z.ZodString>;
|
|
222
|
+
fact: z.ZodOptional<z.ZodString>;
|
|
223
|
+
event: z.ZodOptional<z.ZodString>;
|
|
224
|
+
date: z.ZodOptional<z.ZodString>;
|
|
225
|
+
line_start: z.ZodOptional<z.ZodNumber>;
|
|
226
|
+
line_end: z.ZodOptional<z.ZodNumber>;
|
|
227
|
+
availability: z.ZodOptional<z.ZodEnum<{
|
|
228
|
+
degraded: "degraded";
|
|
229
|
+
unavailable: "unavailable";
|
|
230
|
+
available: "available";
|
|
231
|
+
}>>;
|
|
232
|
+
}, z.core.$strip>>;
|
|
233
|
+
edges: z.ZodArray<z.ZodObject<{
|
|
234
|
+
id: z.ZodString;
|
|
235
|
+
from: z.ZodString;
|
|
236
|
+
to: z.ZodString;
|
|
237
|
+
relation: z.ZodEnum<{
|
|
238
|
+
canonical_record: "canonical_record";
|
|
239
|
+
links_to: "links_to";
|
|
240
|
+
mentions: "mentions";
|
|
241
|
+
about: "about";
|
|
242
|
+
has_attribute: "has_attribute";
|
|
243
|
+
related_entity: "related_entity";
|
|
244
|
+
owns_document: "owns_document";
|
|
245
|
+
participates_in: "participates_in";
|
|
246
|
+
}>;
|
|
247
|
+
predicate: z.ZodOptional<z.ZodString>;
|
|
248
|
+
confidence: z.ZodNumber;
|
|
249
|
+
derivation: z.ZodEnum<{
|
|
250
|
+
fact: "fact";
|
|
251
|
+
structural: "structural";
|
|
252
|
+
}>;
|
|
253
|
+
resolution: z.ZodEnum<{
|
|
254
|
+
exact: "exact";
|
|
255
|
+
contextual: "contextual";
|
|
256
|
+
}>;
|
|
257
|
+
evidence: z.ZodObject<{
|
|
258
|
+
kind: z.ZodEnum<{
|
|
259
|
+
document: "document";
|
|
260
|
+
page_line: "page_line";
|
|
261
|
+
fact_line: "fact_line";
|
|
262
|
+
frontmatter: "frontmatter";
|
|
263
|
+
}>;
|
|
264
|
+
slug: z.ZodOptional<z.ZodString>;
|
|
265
|
+
document: z.ZodOptional<z.ZodString>;
|
|
266
|
+
event: z.ZodOptional<z.ZodString>;
|
|
267
|
+
fact: z.ZodOptional<z.ZodString>;
|
|
268
|
+
line_start: z.ZodOptional<z.ZodNumber>;
|
|
269
|
+
line_end: z.ZodOptional<z.ZodNumber>;
|
|
270
|
+
field: z.ZodOptional<z.ZodString>;
|
|
271
|
+
}, z.core.$strip>;
|
|
272
|
+
valid_from: z.ZodOptional<z.ZodString>;
|
|
273
|
+
valid_to: z.ZodOptional<z.ZodString>;
|
|
274
|
+
historical: z.ZodBoolean;
|
|
275
|
+
}, z.core.$strip>>;
|
|
276
|
+
paths: z.ZodArray<z.ZodObject<{
|
|
277
|
+
seed: z.ZodString;
|
|
278
|
+
nodes: z.ZodArray<z.ZodString>;
|
|
279
|
+
edges: z.ZodArray<z.ZodString>;
|
|
280
|
+
hops: z.ZodNumber;
|
|
281
|
+
confidence: z.ZodNumber;
|
|
282
|
+
evidence: z.ZodArray<z.ZodObject<{
|
|
283
|
+
kind: z.ZodEnum<{
|
|
284
|
+
document: "document";
|
|
285
|
+
page_line: "page_line";
|
|
286
|
+
fact_line: "fact_line";
|
|
287
|
+
frontmatter: "frontmatter";
|
|
288
|
+
}>;
|
|
289
|
+
slug: z.ZodOptional<z.ZodString>;
|
|
290
|
+
document: z.ZodOptional<z.ZodString>;
|
|
291
|
+
event: z.ZodOptional<z.ZodString>;
|
|
292
|
+
fact: z.ZodOptional<z.ZodString>;
|
|
293
|
+
line_start: z.ZodOptional<z.ZodNumber>;
|
|
294
|
+
line_end: z.ZodOptional<z.ZodNumber>;
|
|
295
|
+
field: z.ZodOptional<z.ZodString>;
|
|
296
|
+
}, z.core.$strip>>;
|
|
297
|
+
}, z.core.$strip>>;
|
|
298
|
+
ambiguities: z.ZodArray<z.ZodObject<{
|
|
299
|
+
mention: z.ZodString;
|
|
300
|
+
normalized: z.ZodString;
|
|
301
|
+
candidates: z.ZodArray<z.ZodObject<{
|
|
302
|
+
id: z.ZodString;
|
|
303
|
+
kind: z.ZodEnum<{
|
|
304
|
+
fact: "fact";
|
|
305
|
+
entity: "entity";
|
|
306
|
+
page: "page";
|
|
307
|
+
document: "document";
|
|
308
|
+
event: "event";
|
|
309
|
+
}>;
|
|
310
|
+
slug: z.ZodOptional<z.ZodString>;
|
|
311
|
+
label: z.ZodOptional<z.ZodString>;
|
|
312
|
+
role: z.ZodOptional<z.ZodEnum<{
|
|
313
|
+
knowledge: "knowledge";
|
|
314
|
+
source: "source";
|
|
315
|
+
inference: "inference";
|
|
316
|
+
ignored: "ignored";
|
|
317
|
+
}>>;
|
|
318
|
+
entity: z.ZodOptional<z.ZodString>;
|
|
319
|
+
entity_type: z.ZodOptional<z.ZodEnum<{
|
|
320
|
+
event: "event";
|
|
321
|
+
person: "person";
|
|
322
|
+
organization: "organization";
|
|
323
|
+
place: "place";
|
|
324
|
+
product: "product";
|
|
325
|
+
concept: "concept";
|
|
326
|
+
other: "other";
|
|
327
|
+
}>>;
|
|
328
|
+
document: z.ZodOptional<z.ZodString>;
|
|
329
|
+
fact: z.ZodOptional<z.ZodString>;
|
|
330
|
+
event: z.ZodOptional<z.ZodString>;
|
|
331
|
+
date: z.ZodOptional<z.ZodString>;
|
|
332
|
+
line_start: z.ZodOptional<z.ZodNumber>;
|
|
333
|
+
line_end: z.ZodOptional<z.ZodNumber>;
|
|
334
|
+
availability: z.ZodOptional<z.ZodEnum<{
|
|
335
|
+
degraded: "degraded";
|
|
336
|
+
unavailable: "unavailable";
|
|
337
|
+
available: "available";
|
|
338
|
+
}>>;
|
|
339
|
+
}, z.core.$strip>>;
|
|
340
|
+
}, z.core.$strip>>;
|
|
341
|
+
total: z.ZodNumber;
|
|
342
|
+
truncated: z.ZodBoolean;
|
|
343
|
+
reason: z.ZodOptional<z.ZodEnum<{
|
|
344
|
+
seed_not_found: "seed_not_found";
|
|
345
|
+
no_paths: "no_paths";
|
|
346
|
+
graph_index_unreadable: "graph_index_unreadable";
|
|
347
|
+
}>>;
|
|
348
|
+
}, z.core.$strip>;
|
|
349
|
+
export type GraphOutput = z.infer<typeof GraphOutput>;
|
|
350
|
+
export { GraphEvidenceLocator, GraphNodeRef, GraphRelation } from '../common.ts';
|
|
351
|
+
export type { GraphNodeKind } from '../common.ts';
|
|
352
|
+
//# sourceMappingURL=graph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,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;;;;iBAStB,CAAC;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,WAAW,CAAC,CAAC;AAEtD,OAAO,EAAE,oBAAoB,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACjF,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { GraphEvidenceLocator, GraphNodeRef, GraphRelation, ResultEnvelope } from "../common.js";
|
|
3
|
+
export const GraphDirection = z.enum(['out', 'in', 'both']);
|
|
4
|
+
/** One exact seed form. Query seeds still resolve only evidence-declared names. */
|
|
5
|
+
export const GraphInput = z
|
|
6
|
+
.object({
|
|
7
|
+
slug: z.string().trim().min(1).optional(),
|
|
8
|
+
entity: z.string().trim().min(1).optional(),
|
|
9
|
+
query: z.string().trim().min(1).optional(),
|
|
10
|
+
direction: GraphDirection.optional(),
|
|
11
|
+
relations: z.array(GraphRelation).min(1).max(GraphRelation.options.length).optional(),
|
|
12
|
+
max_hops: z.union([z.literal(1), z.literal(2), z.literal(3)]).optional(),
|
|
13
|
+
/** Maximum returned paths. Nodes, edges, and per-node fan-out have separate hard caps. */
|
|
14
|
+
limit: z.number().int().positive().max(100).optional(),
|
|
15
|
+
include_history: z.boolean().optional(),
|
|
16
|
+
})
|
|
17
|
+
.refine((value) => [value.slug, value.entity, value.query].filter(Boolean).length === 1, {
|
|
18
|
+
message: 'graph requires exactly one of: slug, entity, query',
|
|
19
|
+
});
|
|
20
|
+
export const GraphEdgeRef = z.object({
|
|
21
|
+
id: z.string(),
|
|
22
|
+
from: z.string(),
|
|
23
|
+
to: z.string(),
|
|
24
|
+
relation: GraphRelation,
|
|
25
|
+
predicate: z.string().optional(),
|
|
26
|
+
confidence: z.number().min(0).max(1),
|
|
27
|
+
derivation: z.enum(['structural', 'fact']),
|
|
28
|
+
resolution: z.enum(['exact', 'contextual']),
|
|
29
|
+
evidence: GraphEvidenceLocator,
|
|
30
|
+
valid_from: z.string().optional(),
|
|
31
|
+
valid_to: z.string().optional(),
|
|
32
|
+
historical: z.boolean(),
|
|
33
|
+
});
|
|
34
|
+
export const GraphSeed = z.object({
|
|
35
|
+
form: z.enum(['slug', 'entity', 'query']),
|
|
36
|
+
value: z.string(),
|
|
37
|
+
node: z.string(),
|
|
38
|
+
});
|
|
39
|
+
export const GraphPath = z.object({
|
|
40
|
+
seed: z.string(),
|
|
41
|
+
nodes: z.array(z.string()).min(2).max(4),
|
|
42
|
+
edges: z.array(z.string()).min(1).max(3),
|
|
43
|
+
hops: z.number().int().positive().max(3),
|
|
44
|
+
confidence: z.number().min(0).max(1),
|
|
45
|
+
evidence: z.array(GraphEvidenceLocator).min(1).max(3),
|
|
46
|
+
});
|
|
47
|
+
export const GraphAmbiguity = z.object({
|
|
48
|
+
mention: z.string(),
|
|
49
|
+
normalized: z.string(),
|
|
50
|
+
candidates: z.array(GraphNodeRef),
|
|
51
|
+
});
|
|
52
|
+
export const GraphOutput = ResultEnvelope.extend({
|
|
53
|
+
seeds: z.array(GraphSeed),
|
|
54
|
+
nodes: z.array(GraphNodeRef),
|
|
55
|
+
edges: z.array(GraphEdgeRef),
|
|
56
|
+
paths: z.array(GraphPath),
|
|
57
|
+
ambiguities: z.array(GraphAmbiguity),
|
|
58
|
+
total: z.number().int().nonnegative(),
|
|
59
|
+
truncated: z.boolean(),
|
|
60
|
+
reason: z.enum(['seed_not_found', 'no_paths', 'graph_index_unreadable']).optional(),
|
|
61
|
+
});
|
|
62
|
+
export { GraphEvidenceLocator, GraphNodeRef, GraphRelation } from "../common.js";
|
|
63
|
+
//# sourceMappingURL=graph.js.map
|