@ontos-ai/knowhere-claw 0.1.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +163 -0
- package/dist/_virtual/_rolldown/runtime.js +37 -0
- package/dist/client.d.ts +33 -0
- package/dist/client.js +395 -0
- package/dist/config.d.ts +6 -0
- package/dist/config.js +132 -0
- package/dist/error-message.d.ts +1 -0
- package/dist/error-message.js +48 -0
- package/dist/hooks.d.ts +8 -0
- package/dist/hooks.js +415 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +43 -0
- package/dist/node_modules/.pnpm/@knowhere-ai_sdk@0.1.1/node_modules/@knowhere-ai/sdk/dist/index.js +717 -0
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/adapters/adapters.js +83 -0
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/adapters/fetch.js +170 -0
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/adapters/xhr.js +106 -0
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/axios.js +57 -0
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/cancel/CancelToken.js +90 -0
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/cancel/CanceledError.js +20 -0
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/cancel/isCancel.js +6 -0
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/core/Axios.js +174 -0
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/core/AxiosError.js +70 -0
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/core/AxiosHeaders.js +204 -0
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/core/InterceptorManager.js +60 -0
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/core/buildFullPath.js +20 -0
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/core/dispatchRequest.js +52 -0
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/core/mergeConfig.js +81 -0
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/core/settle.js +18 -0
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/core/transformData.js +25 -0
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/defaults/index.js +107 -0
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/defaults/transitional.js +9 -0
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/env/data.js +4 -0
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/helpers/AxiosURLSearchParams.js +50 -0
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/helpers/HttpStatusCode.js +77 -0
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/helpers/bind.js +15 -0
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/helpers/buildURL.js +40 -0
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/helpers/combineURLs.js +14 -0
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/helpers/composeSignals.js +39 -0
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/helpers/cookies.js +31 -0
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/helpers/formDataToJSON.js +67 -0
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/helpers/isAbsoluteURL.js +14 -0
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/helpers/isAxiosError.js +14 -0
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/helpers/isURLSameOrigin.js +8 -0
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/helpers/parseHeaders.js +53 -0
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/helpers/parseProtocol.js +7 -0
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/helpers/progressEventReducer.js +38 -0
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/helpers/resolveConfig.js +36 -0
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/helpers/speedometer.js +36 -0
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/helpers/spread.js +29 -0
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/helpers/throttle.js +38 -0
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/helpers/toFormData.js +151 -0
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/helpers/toURLEncodedForm.js +18 -0
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/helpers/trackStream.js +69 -0
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/helpers/validator.js +76 -0
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/platform/browser/classes/Blob.js +4 -0
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/platform/browser/classes/FormData.js +4 -0
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/platform/browser/classes/URLSearchParams.js +5 -0
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/platform/browser/index.js +22 -0
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/platform/common/utils.js +46 -0
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/platform/index.js +9 -0
- package/dist/node_modules/.pnpm/axios@1.13.6/node_modules/axios/lib/utils.js +698 -0
- package/dist/node_modules/.pnpm/fflate@0.8.2/node_modules/fflate/esm/browser.js +426 -0
- package/dist/node_modules/.pnpm/jszip@3.10.1/node_modules/jszip/dist/jszip.min.js +3110 -0
- package/dist/parser.d.ts +16 -0
- package/dist/parser.js +323 -0
- package/dist/session.d.ts +11 -0
- package/dist/session.js +78 -0
- package/dist/store.d.ts +62 -0
- package/dist/store.js +482 -0
- package/dist/text.d.ts +10 -0
- package/dist/text.js +34 -0
- package/dist/tools.d.ts +9 -0
- package/dist/tools.js +1177 -0
- package/dist/tracker-progress.d.ts +8 -0
- package/dist/tracker-progress.js +197 -0
- package/dist/types.d.ts +247 -0
- package/dist/types.js +9 -0
- package/openclaw.plugin.json +107 -0
- package/package.json +61 -0
- package/skills/knowhere/SKILL.md +243 -0
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { isRecord } from "./types.js";
|
|
2
|
+
import { normalizeWhitespace } from "./text.js";
|
|
3
|
+
import { findConversationSegmentValue, parseConversationSessionKey } from "./session.js";
|
|
4
|
+
//#region src/tracker-progress.ts
|
|
5
|
+
const TRACKER_PROGRESS_SURFACES = new Set([
|
|
6
|
+
"discord",
|
|
7
|
+
"imessage",
|
|
8
|
+
"line",
|
|
9
|
+
"signal",
|
|
10
|
+
"slack",
|
|
11
|
+
"telegram",
|
|
12
|
+
"whatsapp"
|
|
13
|
+
]);
|
|
14
|
+
function readString(value) {
|
|
15
|
+
return normalizeWhitespace(value) || void 0;
|
|
16
|
+
}
|
|
17
|
+
function readInteger(value) {
|
|
18
|
+
const normalized = readString(value);
|
|
19
|
+
if (!normalized || !/^-?\d+$/.test(normalized)) return;
|
|
20
|
+
const parsed = Number(normalized);
|
|
21
|
+
return Number.isSafeInteger(parsed) ? parsed : void 0;
|
|
22
|
+
}
|
|
23
|
+
function normalizeTrackerProgressSurface(value) {
|
|
24
|
+
const normalized = readString(value)?.toLowerCase();
|
|
25
|
+
if (!normalized || !TRACKER_PROGRESS_SURFACES.has(normalized)) return;
|
|
26
|
+
return normalized;
|
|
27
|
+
}
|
|
28
|
+
function extractReplyReferenceFromValue(value, seen = /* @__PURE__ */ new WeakSet()) {
|
|
29
|
+
if (typeof value === "string") return readString(value.match(/"(?:messageId|message_id|replyTo|reply_to|threadTs|thread_ts|ts)"\s*:\s*"([^"]+)"/)?.[1]);
|
|
30
|
+
if (Array.isArray(value)) {
|
|
31
|
+
if (seen.has(value)) return;
|
|
32
|
+
seen.add(value);
|
|
33
|
+
for (let index = value.length - 1; index >= 0; index -= 1) {
|
|
34
|
+
const replyReference = extractReplyReferenceFromValue(value[index], seen);
|
|
35
|
+
if (replyReference) return replyReference;
|
|
36
|
+
}
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
if (!isRecord(value)) return;
|
|
40
|
+
if (seen.has(value)) return;
|
|
41
|
+
seen.add(value);
|
|
42
|
+
for (const key of [
|
|
43
|
+
"messageId",
|
|
44
|
+
"message_id",
|
|
45
|
+
"replyTo",
|
|
46
|
+
"reply_to",
|
|
47
|
+
"threadTs",
|
|
48
|
+
"thread_ts",
|
|
49
|
+
"ts"
|
|
50
|
+
]) {
|
|
51
|
+
const replyReference = readString(value[key]);
|
|
52
|
+
if (replyReference) return replyReference;
|
|
53
|
+
}
|
|
54
|
+
const preferredKeys = [
|
|
55
|
+
"content",
|
|
56
|
+
"text",
|
|
57
|
+
"body",
|
|
58
|
+
"message",
|
|
59
|
+
"messages",
|
|
60
|
+
"items"
|
|
61
|
+
];
|
|
62
|
+
const preferredKeySet = new Set(preferredKeys);
|
|
63
|
+
for (const key of preferredKeys) {
|
|
64
|
+
const replyReference = extractReplyReferenceFromValue(value[key], seen);
|
|
65
|
+
if (replyReference) return replyReference;
|
|
66
|
+
}
|
|
67
|
+
for (const [key, nestedValue] of Object.entries(value).reverse()) {
|
|
68
|
+
if (preferredKeySet.has(key)) continue;
|
|
69
|
+
const replyReference = extractReplyReferenceFromValue(nestedValue, seen);
|
|
70
|
+
if (replyReference) return replyReference;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
function resolveTrackerProgressTarget(params) {
|
|
74
|
+
const context = isRecord(params.context) ? params.context : void 0;
|
|
75
|
+
const session = parseConversationSessionKey(params.sessionKey);
|
|
76
|
+
const surface = normalizeTrackerProgressSurface(context?.channelId) || normalizeTrackerProgressSurface(context?.provider) || normalizeTrackerProgressSurface(context?.surface) || normalizeTrackerProgressSurface(session?.surface);
|
|
77
|
+
if (!surface) return;
|
|
78
|
+
const replyReference = readString(context?.messageId) || readString(context?.replyTo) || readString(context?.threadTs) || (params.messages ? extractReplyReferenceFromValue(params.messages) : void 0);
|
|
79
|
+
switch (surface) {
|
|
80
|
+
case "discord": {
|
|
81
|
+
const threadId = readString(context?.threadId) || findConversationSegmentValue(session, "thread");
|
|
82
|
+
const channelId = findConversationSegmentValue(session, "channel", "guild");
|
|
83
|
+
const directId = findConversationSegmentValue(session, "direct", "user", "member");
|
|
84
|
+
const to = threadId && `channel:${threadId}` || readString(context?.conversationId) || channelId && `channel:${channelId}` || directId && `user:${directId}`;
|
|
85
|
+
if (!to) return;
|
|
86
|
+
return {
|
|
87
|
+
surface,
|
|
88
|
+
to,
|
|
89
|
+
accountId: "tracker",
|
|
90
|
+
replyTo: replyReference
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
case "slack": {
|
|
94
|
+
const directId = findConversationSegmentValue(session, "direct", "user", "member");
|
|
95
|
+
const channelId = findConversationSegmentValue(session, "channel", "group");
|
|
96
|
+
const to = readString(context?.conversationId) || channelId || (directId ? `user:${directId}` : void 0);
|
|
97
|
+
if (!to) return;
|
|
98
|
+
return {
|
|
99
|
+
surface,
|
|
100
|
+
to,
|
|
101
|
+
accountId: readString(context?.accountId),
|
|
102
|
+
threadTs: readString(context?.threadTs) || replyReference
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
case "telegram": {
|
|
106
|
+
const chatId = findConversationSegmentValue(session, "direct", "group", "channel", "chat", "room");
|
|
107
|
+
const to = readString(context?.conversationId) || chatId;
|
|
108
|
+
if (!to) return;
|
|
109
|
+
return {
|
|
110
|
+
surface,
|
|
111
|
+
to,
|
|
112
|
+
accountId: readString(context?.accountId),
|
|
113
|
+
replyToMessageId: readInteger(replyReference),
|
|
114
|
+
messageThreadId: readInteger(context?.threadId)
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
case "line": {
|
|
118
|
+
const directId = findConversationSegmentValue(session, "direct", "user", "member");
|
|
119
|
+
const groupId = findConversationSegmentValue(session, "group");
|
|
120
|
+
const roomId = findConversationSegmentValue(session, "room");
|
|
121
|
+
const chatId = findConversationSegmentValue(session, "channel", "chat", "space");
|
|
122
|
+
const to = readString(context?.conversationId) || (groupId ? `line:group:${groupId}` : void 0) || (roomId ? `line:room:${roomId}` : void 0) || (directId ? `line:${directId}` : void 0) || (chatId ? `line:${chatId}` : void 0);
|
|
123
|
+
if (!to) return;
|
|
124
|
+
return {
|
|
125
|
+
surface,
|
|
126
|
+
to,
|
|
127
|
+
accountId: readString(context?.accountId),
|
|
128
|
+
replyToken: readString(context?.replyToken)
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
case "imessage":
|
|
132
|
+
case "signal":
|
|
133
|
+
case "whatsapp": {
|
|
134
|
+
const conversationId = findConversationSegmentValue(session, "direct", "group", "channel", "chat", "room");
|
|
135
|
+
const to = readString(context?.conversationId) || conversationId;
|
|
136
|
+
if (!to) return;
|
|
137
|
+
return {
|
|
138
|
+
surface,
|
|
139
|
+
to,
|
|
140
|
+
accountId: readString(context?.accountId)
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
async function sendTrackerProgress(params) {
|
|
146
|
+
const target = resolveTrackerProgressTarget({
|
|
147
|
+
context: params.context,
|
|
148
|
+
sessionKey: params.sessionKey,
|
|
149
|
+
messages: params.messages
|
|
150
|
+
});
|
|
151
|
+
if (!target) return;
|
|
152
|
+
try {
|
|
153
|
+
switch (target.surface) {
|
|
154
|
+
case "discord":
|
|
155
|
+
await params.api.runtime.channel.discord.sendMessageDiscord(target.to, params.text, {
|
|
156
|
+
accountId: target.accountId,
|
|
157
|
+
replyTo: target.replyTo
|
|
158
|
+
});
|
|
159
|
+
break;
|
|
160
|
+
case "slack":
|
|
161
|
+
await params.api.runtime.channel.slack.sendMessageSlack(target.to, params.text, {
|
|
162
|
+
accountId: target.accountId,
|
|
163
|
+
threadTs: target.threadTs
|
|
164
|
+
});
|
|
165
|
+
break;
|
|
166
|
+
case "telegram":
|
|
167
|
+
await params.api.runtime.channel.telegram.sendMessageTelegram(target.to, params.text, {
|
|
168
|
+
accountId: target.accountId,
|
|
169
|
+
messageThreadId: target.messageThreadId,
|
|
170
|
+
replyToMessageId: target.replyToMessageId
|
|
171
|
+
});
|
|
172
|
+
break;
|
|
173
|
+
case "line":
|
|
174
|
+
await params.api.runtime.channel.line.sendMessageLine(target.to, params.text, {
|
|
175
|
+
accountId: target.accountId,
|
|
176
|
+
replyToken: target.replyToken
|
|
177
|
+
});
|
|
178
|
+
break;
|
|
179
|
+
case "whatsapp":
|
|
180
|
+
await params.api.runtime.channel.whatsapp.sendMessageWhatsApp(target.to, params.text, {
|
|
181
|
+
accountId: target.accountId,
|
|
182
|
+
verbose: false
|
|
183
|
+
});
|
|
184
|
+
break;
|
|
185
|
+
case "signal":
|
|
186
|
+
await params.api.runtime.channel.signal.sendMessageSignal(target.to, params.text, { accountId: target.accountId });
|
|
187
|
+
break;
|
|
188
|
+
case "imessage":
|
|
189
|
+
await params.api.runtime.channel.imessage.sendMessageIMessage(target.to, params.text, { accountId: target.accountId });
|
|
190
|
+
break;
|
|
191
|
+
}
|
|
192
|
+
} catch (error) {
|
|
193
|
+
params.api.logger.warn(`knowhere: tracker progress send failed. ${error instanceof Error ? error.message : String(error)}`);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
//#endregion
|
|
197
|
+
export { sendTrackerProgress };
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
export type ScopeMode = "session" | "agent" | "global";
|
|
2
|
+
export type StringRecord = Record<string, unknown>;
|
|
3
|
+
export interface PluginLogger {
|
|
4
|
+
debug?: (message: string) => void;
|
|
5
|
+
info: (message: string) => void;
|
|
6
|
+
warn: (message: string) => void;
|
|
7
|
+
error: (message: string) => void;
|
|
8
|
+
}
|
|
9
|
+
export interface ToolRuntimeContext {
|
|
10
|
+
workspaceDir?: string;
|
|
11
|
+
agentId?: string;
|
|
12
|
+
sessionKey?: string;
|
|
13
|
+
sessionId?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface ResolvedKnowhereConfig {
|
|
16
|
+
apiKey: string;
|
|
17
|
+
baseUrl: string;
|
|
18
|
+
storageDir: string;
|
|
19
|
+
scopeMode: ScopeMode;
|
|
20
|
+
autoGrounding: boolean;
|
|
21
|
+
maxContextChars: number;
|
|
22
|
+
pollIntervalMs: number;
|
|
23
|
+
pollTimeoutMs: number;
|
|
24
|
+
requestTimeoutMs: number;
|
|
25
|
+
uploadTimeoutMs: number;
|
|
26
|
+
}
|
|
27
|
+
export interface KnowhereStatistics {
|
|
28
|
+
total_chunks?: number;
|
|
29
|
+
text_chunks?: number;
|
|
30
|
+
image_chunks?: number;
|
|
31
|
+
table_chunks?: number;
|
|
32
|
+
total_pages?: number;
|
|
33
|
+
}
|
|
34
|
+
export interface KnowhereChecksum {
|
|
35
|
+
algorithm?: string;
|
|
36
|
+
value?: string;
|
|
37
|
+
}
|
|
38
|
+
export interface KnowhereManifest {
|
|
39
|
+
version?: string;
|
|
40
|
+
job_id?: string;
|
|
41
|
+
data_id?: string;
|
|
42
|
+
source_file_name?: string;
|
|
43
|
+
processing_date?: string;
|
|
44
|
+
checksum?: KnowhereChecksum;
|
|
45
|
+
statistics?: KnowhereStatistics;
|
|
46
|
+
files?: StringRecord;
|
|
47
|
+
}
|
|
48
|
+
export interface StoredChunk {
|
|
49
|
+
chunkId: string;
|
|
50
|
+
type: "text" | "image" | "table";
|
|
51
|
+
path: string | null;
|
|
52
|
+
summary: string;
|
|
53
|
+
content: string;
|
|
54
|
+
tokens: number | null;
|
|
55
|
+
keywords: string[];
|
|
56
|
+
relationships: unknown[];
|
|
57
|
+
metadata: StringRecord;
|
|
58
|
+
assetFilePath: string | null;
|
|
59
|
+
originalName: string | null;
|
|
60
|
+
tableType: string | null;
|
|
61
|
+
}
|
|
62
|
+
export interface StoredPathRecord {
|
|
63
|
+
path: string;
|
|
64
|
+
parentPath: string | null;
|
|
65
|
+
depth: number;
|
|
66
|
+
childPaths: string[];
|
|
67
|
+
chunkIds: string[];
|
|
68
|
+
directChunkCount: number;
|
|
69
|
+
chunkCount: number;
|
|
70
|
+
textChunkCount: number;
|
|
71
|
+
imageChunkCount: number;
|
|
72
|
+
tableChunkCount: number;
|
|
73
|
+
}
|
|
74
|
+
export type StoredResultFileKind = "manifest" | "chunks" | "fullMarkdown" | "kbCsv" | "hierarchy" | "hierarchyView" | "image" | "table" | "other";
|
|
75
|
+
export interface StoredResultFileRecord {
|
|
76
|
+
relativePath: string;
|
|
77
|
+
kind: StoredResultFileKind;
|
|
78
|
+
chunkId: string | null;
|
|
79
|
+
format: string | null;
|
|
80
|
+
sizeBytes: number | null;
|
|
81
|
+
}
|
|
82
|
+
export interface StoredBrowseIndex {
|
|
83
|
+
version: number;
|
|
84
|
+
paths: StoredPathRecord[];
|
|
85
|
+
chunkOrder: string[];
|
|
86
|
+
resultFiles: StoredResultFileRecord[];
|
|
87
|
+
}
|
|
88
|
+
export interface KnowhereParseResult {
|
|
89
|
+
manifest: KnowhereManifest;
|
|
90
|
+
chunks: StoredChunk[];
|
|
91
|
+
fullMarkdown: string;
|
|
92
|
+
hierarchy: unknown;
|
|
93
|
+
browseIndex: StoredBrowseIndex;
|
|
94
|
+
}
|
|
95
|
+
export interface KnowhereDownloadedResult {
|
|
96
|
+
zipBytes: Buffer;
|
|
97
|
+
rawZipSha1: string;
|
|
98
|
+
}
|
|
99
|
+
export interface KnowhereJob {
|
|
100
|
+
job_id: string;
|
|
101
|
+
status: string;
|
|
102
|
+
source_type: string;
|
|
103
|
+
data_id?: string | null;
|
|
104
|
+
created_at?: string | null;
|
|
105
|
+
upload_url?: string | null;
|
|
106
|
+
upload_headers?: Record<string, string> | null;
|
|
107
|
+
expires_in?: number | null;
|
|
108
|
+
}
|
|
109
|
+
export interface KnowhereJobError {
|
|
110
|
+
code?: string;
|
|
111
|
+
message?: string;
|
|
112
|
+
request_id?: string;
|
|
113
|
+
details?: unknown;
|
|
114
|
+
}
|
|
115
|
+
export interface KnowhereJobResult {
|
|
116
|
+
job_id: string;
|
|
117
|
+
status: string;
|
|
118
|
+
source_type: string;
|
|
119
|
+
data_id?: string | null;
|
|
120
|
+
created_at?: string | null;
|
|
121
|
+
progress?: unknown;
|
|
122
|
+
error?: KnowhereJobError | null;
|
|
123
|
+
result?: StringRecord | null;
|
|
124
|
+
result_url?: string | null;
|
|
125
|
+
result_url_expires_at?: string | null;
|
|
126
|
+
file_name?: string | null;
|
|
127
|
+
file_extension?: string | null;
|
|
128
|
+
model?: string | null;
|
|
129
|
+
ocr_enabled?: boolean | null;
|
|
130
|
+
duration_seconds?: number | null;
|
|
131
|
+
credits_spent?: number | null;
|
|
132
|
+
}
|
|
133
|
+
export interface KnowhereJobList {
|
|
134
|
+
jobs: KnowhereJobResult[];
|
|
135
|
+
total: number;
|
|
136
|
+
page: number;
|
|
137
|
+
pageSize: number;
|
|
138
|
+
totalPages: number;
|
|
139
|
+
}
|
|
140
|
+
export interface KnowhereJobListRequest {
|
|
141
|
+
page?: number;
|
|
142
|
+
pageSize?: number;
|
|
143
|
+
jobStatus?: string;
|
|
144
|
+
jobType?: string;
|
|
145
|
+
recentDays?: 1 | 7 | 30;
|
|
146
|
+
startTime?: string;
|
|
147
|
+
endTime?: string;
|
|
148
|
+
}
|
|
149
|
+
export interface KnowhereParsingParams {
|
|
150
|
+
model?: "base" | "advanced";
|
|
151
|
+
ocr_enabled?: boolean;
|
|
152
|
+
kb_dir?: string;
|
|
153
|
+
doc_type?: string;
|
|
154
|
+
smart_title_parse?: boolean;
|
|
155
|
+
summary_image?: boolean;
|
|
156
|
+
summary_table?: boolean;
|
|
157
|
+
summary_txt?: boolean;
|
|
158
|
+
add_frag_desc?: string;
|
|
159
|
+
}
|
|
160
|
+
export interface KnowhereIngestRequest {
|
|
161
|
+
filePath?: string;
|
|
162
|
+
fileName?: string;
|
|
163
|
+
url?: string;
|
|
164
|
+
dataId?: string;
|
|
165
|
+
parsingParams?: KnowhereParsingParams;
|
|
166
|
+
onJobCreated?: (job: KnowhereJob) => void | Promise<void>;
|
|
167
|
+
onJobUpdated?: (jobResult: KnowhereJobResult) => void | Promise<void>;
|
|
168
|
+
}
|
|
169
|
+
export interface KnowhereIngestResult {
|
|
170
|
+
job: KnowhereJob;
|
|
171
|
+
jobResult: KnowhereJobResult;
|
|
172
|
+
downloadedResult: KnowhereDownloadedResult;
|
|
173
|
+
}
|
|
174
|
+
export interface KnowhereScope {
|
|
175
|
+
mode: ScopeMode | "global";
|
|
176
|
+
key: string;
|
|
177
|
+
label: string;
|
|
178
|
+
rootDir: string;
|
|
179
|
+
documentsDir: string;
|
|
180
|
+
indexPath: string;
|
|
181
|
+
}
|
|
182
|
+
export interface KnowhereAutoGroundingController {
|
|
183
|
+
forgetDocument(scope: KnowhereScope, docId: string): void;
|
|
184
|
+
forgetScope(scope: KnowhereScope): void;
|
|
185
|
+
}
|
|
186
|
+
export interface StoredDocumentRecord {
|
|
187
|
+
id: string;
|
|
188
|
+
title: string;
|
|
189
|
+
sourceType: "file" | "url";
|
|
190
|
+
source: string;
|
|
191
|
+
sourceLabel: string;
|
|
192
|
+
fileName: string | null;
|
|
193
|
+
originalFileName: string | null;
|
|
194
|
+
dataId: string | null;
|
|
195
|
+
jobId: string | null;
|
|
196
|
+
checksum: string | null;
|
|
197
|
+
resultUrl: string | null;
|
|
198
|
+
resultUrlExpiresAt: string | null;
|
|
199
|
+
scopeLabel: string;
|
|
200
|
+
tags: string[];
|
|
201
|
+
ingestedAt: string;
|
|
202
|
+
updatedAt: string;
|
|
203
|
+
chunkCount: number;
|
|
204
|
+
statistics: KnowhereStatistics;
|
|
205
|
+
}
|
|
206
|
+
export interface StoredDocumentPayload {
|
|
207
|
+
version: number;
|
|
208
|
+
document: StoredDocumentRecord;
|
|
209
|
+
manifest: KnowhereManifest;
|
|
210
|
+
jobResult: KnowhereJobResult;
|
|
211
|
+
fullMarkdown: string;
|
|
212
|
+
hierarchy: unknown;
|
|
213
|
+
browseIndex: StoredBrowseIndex;
|
|
214
|
+
rawZipSha1: string;
|
|
215
|
+
chunks: StoredChunk[];
|
|
216
|
+
}
|
|
217
|
+
export interface StoredDocumentMetadata {
|
|
218
|
+
version: number;
|
|
219
|
+
document: StoredDocumentRecord;
|
|
220
|
+
jobResult: KnowhereJobResult;
|
|
221
|
+
rawZipSha1: string;
|
|
222
|
+
}
|
|
223
|
+
export interface KnowhereIndex {
|
|
224
|
+
version: number;
|
|
225
|
+
scopeMode: string;
|
|
226
|
+
scopeKey: string;
|
|
227
|
+
updatedAt: string | null;
|
|
228
|
+
documents: StoredDocumentRecord[];
|
|
229
|
+
}
|
|
230
|
+
export interface SaveStoredDocumentPayload {
|
|
231
|
+
sourceType: "file" | "url";
|
|
232
|
+
source: string;
|
|
233
|
+
sourceLabel?: string;
|
|
234
|
+
fileName: string | null;
|
|
235
|
+
docId?: string;
|
|
236
|
+
title?: string;
|
|
237
|
+
dataId?: string;
|
|
238
|
+
tags: string[];
|
|
239
|
+
job: KnowhereJob;
|
|
240
|
+
jobResult: KnowhereJobResult;
|
|
241
|
+
downloadedResult: KnowhereDownloadedResult;
|
|
242
|
+
}
|
|
243
|
+
export interface JsonSchemaObject {
|
|
244
|
+
[key: string]: unknown;
|
|
245
|
+
}
|
|
246
|
+
export declare function isRecord(value: unknown): value is StringRecord;
|
|
247
|
+
export declare function isNodeError(error: unknown): error is NodeJS.ErrnoException;
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "knowhere",
|
|
3
|
+
"name": "Knowhere",
|
|
4
|
+
"description": "Parse documents with Knowhere and expose the stored result as tool-queryable document state for OpenClaw agents.",
|
|
5
|
+
"skills": ["./skills"],
|
|
6
|
+
"version": "0.1.0-beta.0",
|
|
7
|
+
"uiHints": {
|
|
8
|
+
"apiKey": {
|
|
9
|
+
"label": "Knowhere API Key",
|
|
10
|
+
"help": "Optional when KNOWHERE_API_KEY is already present in the environment.",
|
|
11
|
+
"sensitive": true
|
|
12
|
+
},
|
|
13
|
+
"baseUrl": {
|
|
14
|
+
"label": "Knowhere Base URL",
|
|
15
|
+
"help": "Override the Knowhere API base URL when using a non-default deployment."
|
|
16
|
+
},
|
|
17
|
+
"storageDir": {
|
|
18
|
+
"label": "Storage Directory",
|
|
19
|
+
"help": "Directory for persisted parsed documents and scope indexes."
|
|
20
|
+
},
|
|
21
|
+
"scopeMode": {
|
|
22
|
+
"label": "Document Scope",
|
|
23
|
+
"help": "Choose whether ingested documents are isolated per session, shared per agent, or global."
|
|
24
|
+
},
|
|
25
|
+
"autoGrounding": {
|
|
26
|
+
"label": "Auto Grounding",
|
|
27
|
+
"help": "Automatically ingest attachments and inject compact Knowhere document availability/status guidance before prompt construction."
|
|
28
|
+
},
|
|
29
|
+
"maxContextChars": {
|
|
30
|
+
"label": "Grounding Context Limit",
|
|
31
|
+
"help": "Maximum characters injected into the prompt for Knowhere document handle/status context."
|
|
32
|
+
},
|
|
33
|
+
"pollIntervalMs": {
|
|
34
|
+
"label": "Poll Interval",
|
|
35
|
+
"help": "Polling interval in milliseconds while waiting for Knowhere jobs to finish."
|
|
36
|
+
},
|
|
37
|
+
"pollTimeoutMs": {
|
|
38
|
+
"label": "Poll Timeout",
|
|
39
|
+
"help": "Maximum time to wait for a Knowhere job to finish."
|
|
40
|
+
},
|
|
41
|
+
"requestTimeoutMs": {
|
|
42
|
+
"label": "Request Timeout",
|
|
43
|
+
"help": "Timeout for regular Knowhere API requests."
|
|
44
|
+
},
|
|
45
|
+
"uploadTimeoutMs": {
|
|
46
|
+
"label": "Upload Timeout",
|
|
47
|
+
"help": "Timeout for result downloads and file uploads."
|
|
48
|
+
}
|
|
49
|
+
},
|
|
50
|
+
"configSchema": {
|
|
51
|
+
"type": "object",
|
|
52
|
+
"additionalProperties": false,
|
|
53
|
+
"properties": {
|
|
54
|
+
"apiKey": {
|
|
55
|
+
"type": "string",
|
|
56
|
+
"minLength": 1
|
|
57
|
+
},
|
|
58
|
+
"baseUrl": {
|
|
59
|
+
"type": "string",
|
|
60
|
+
"format": "uri",
|
|
61
|
+
"default": "https://api.knowhereto.ai"
|
|
62
|
+
},
|
|
63
|
+
"storageDir": {
|
|
64
|
+
"type": "string"
|
|
65
|
+
},
|
|
66
|
+
"scopeMode": {
|
|
67
|
+
"type": "string",
|
|
68
|
+
"enum": ["session", "agent", "global"],
|
|
69
|
+
"default": "session"
|
|
70
|
+
},
|
|
71
|
+
"autoGrounding": {
|
|
72
|
+
"type": "boolean",
|
|
73
|
+
"default": true
|
|
74
|
+
},
|
|
75
|
+
"maxContextChars": {
|
|
76
|
+
"type": "integer",
|
|
77
|
+
"minimum": 500,
|
|
78
|
+
"maximum": 12000,
|
|
79
|
+
"default": 4000
|
|
80
|
+
},
|
|
81
|
+
"pollIntervalMs": {
|
|
82
|
+
"type": "integer",
|
|
83
|
+
"minimum": 1000,
|
|
84
|
+
"maximum": 60000,
|
|
85
|
+
"default": 10000
|
|
86
|
+
},
|
|
87
|
+
"pollTimeoutMs": {
|
|
88
|
+
"type": "integer",
|
|
89
|
+
"minimum": 10000,
|
|
90
|
+
"maximum": 7200000,
|
|
91
|
+
"default": 1800000
|
|
92
|
+
},
|
|
93
|
+
"requestTimeoutMs": {
|
|
94
|
+
"type": "integer",
|
|
95
|
+
"minimum": 1000,
|
|
96
|
+
"maximum": 300000,
|
|
97
|
+
"default": 60000
|
|
98
|
+
},
|
|
99
|
+
"uploadTimeoutMs": {
|
|
100
|
+
"type": "integer",
|
|
101
|
+
"minimum": 1000,
|
|
102
|
+
"maximum": 7200000,
|
|
103
|
+
"default": 600000
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ontos-ai/knowhere-claw",
|
|
3
|
+
"version": "0.1.0-beta.0",
|
|
4
|
+
"description": "OpenClaw plugin for Knowhere-powered document ingestion and automatic grounding.",
|
|
5
|
+
"files": [
|
|
6
|
+
"dist/",
|
|
7
|
+
"skills/",
|
|
8
|
+
"openclaw.plugin.json",
|
|
9
|
+
"README.md"
|
|
10
|
+
],
|
|
11
|
+
"type": "module",
|
|
12
|
+
"main": "./dist/index.js",
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"exports": {
|
|
15
|
+
".": {
|
|
16
|
+
"types": "./dist/index.d.ts",
|
|
17
|
+
"default": "./dist/index.js"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "rolldown -c && tsc -p tsconfig.build.json",
|
|
22
|
+
"fmt": "oxfmt",
|
|
23
|
+
"fmt:check": "oxfmt --check",
|
|
24
|
+
"lint": "oxlint --type-aware",
|
|
25
|
+
"lint:fix": "oxlint --type-aware --fix",
|
|
26
|
+
"smoke:tools": "vite-node --mode smoke ./smoketest/run-tool.ts",
|
|
27
|
+
"tsgo": "tsgo --noEmit -p tsconfig.json",
|
|
28
|
+
"typecheck": "pnpm tsgo",
|
|
29
|
+
"clean": "rm -rf dist",
|
|
30
|
+
"check:plugin-version": "node ./scripts/release-guard.mjs plugin-version",
|
|
31
|
+
"check:beta-version": "node ./scripts/release-guard.mjs beta-version",
|
|
32
|
+
"prepack": "pnpm build"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@knowhere-ai/sdk": "^0.1.1",
|
|
36
|
+
"fflate": "^0.8.2"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@tsconfig/node22": "^22.0.5",
|
|
40
|
+
"@types/node": "^25.3.5",
|
|
41
|
+
"@typescript/native-preview": "7.0.0-dev.20260307.1",
|
|
42
|
+
"oxfmt": "0.38.0",
|
|
43
|
+
"oxlint": "^1.51.0",
|
|
44
|
+
"oxlint-tsgolint": "^0.16.0",
|
|
45
|
+
"rolldown": "^1.0.0-rc.8",
|
|
46
|
+
"typescript": "^5.9.3",
|
|
47
|
+
"vite-node": "5.2.0"
|
|
48
|
+
},
|
|
49
|
+
"peerDependencies": {
|
|
50
|
+
"openclaw": ">=2026.3.8"
|
|
51
|
+
},
|
|
52
|
+
"engines": {
|
|
53
|
+
"node": ">=22.12.0"
|
|
54
|
+
},
|
|
55
|
+
"packageManager": "pnpm@10.23.0",
|
|
56
|
+
"openclaw": {
|
|
57
|
+
"extensions": [
|
|
58
|
+
"./dist/index.js"
|
|
59
|
+
]
|
|
60
|
+
}
|
|
61
|
+
}
|