@nextclaw/ncp-agent-runtime 0.3.23 → 0.3.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +14 -14
- package/dist/index.js +21 -21
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { NcpAgentConversationStateManager, NcpAgentRunInput, NcpAgentRunOptions, NcpAgentRuntime, NcpAssistantReasoningNormalizationMode, NcpContextBuilder, NcpContextPrepareOptions, NcpEncodeContext, NcpEndpointEvent, NcpInvalidToolArgumentsResult, NcpLLMApi, NcpLLMApiInput, NcpLLMApiOptions, NcpMessagePart, NcpRoundBuffer, NcpStreamEncoder, NcpTool, NcpToolCallResult, NcpToolDefinition, NcpToolRegistry, OpenAIChatChunk, OpenAIChatMessage, OpenAIContentPart, OpenAITool } from "@nextclaw/ncp";
|
|
2
2
|
|
|
3
|
-
//#region src/assets/asset
|
|
3
|
+
//#region src/assets/stores/local-asset.store.d.ts
|
|
4
4
|
type StoredAssetRecord = {
|
|
5
5
|
id: string;
|
|
6
6
|
uri: string;
|
|
@@ -44,25 +44,25 @@ declare class LocalAssetStore {
|
|
|
44
44
|
constructor(options: {
|
|
45
45
|
rootDir: string;
|
|
46
46
|
});
|
|
47
|
-
put(input: AssetPutInput)
|
|
48
|
-
putBytes(params: {
|
|
47
|
+
put: (input: AssetPutInput) => Promise<AssetRef>;
|
|
48
|
+
putBytes: (params: {
|
|
49
49
|
fileName: string;
|
|
50
50
|
mimeType?: string | null;
|
|
51
51
|
bytes: Uint8Array;
|
|
52
52
|
createdAt?: Date;
|
|
53
|
-
})
|
|
54
|
-
putPath(params: {
|
|
53
|
+
}) => Promise<StoredAssetRecord>;
|
|
54
|
+
putPath: (params: {
|
|
55
55
|
path: string;
|
|
56
56
|
fileName?: string;
|
|
57
57
|
mimeType?: string | null;
|
|
58
58
|
createdAt?: Date;
|
|
59
|
-
})
|
|
60
|
-
export(ref: AssetRef, targetPath: string)
|
|
61
|
-
stat(ref: AssetRef)
|
|
62
|
-
getByUri(uri: string)
|
|
63
|
-
statRecord(uri: string)
|
|
64
|
-
readAssetBytes(uri: string)
|
|
65
|
-
resolveContentPath(uri: string)
|
|
59
|
+
}) => Promise<StoredAssetRecord>;
|
|
60
|
+
export: (ref: AssetRef, targetPath: string) => Promise<string>;
|
|
61
|
+
stat: (ref: AssetRef) => Promise<AssetMeta | null>;
|
|
62
|
+
getByUri: (uri: string) => StoredAssetRecord | null;
|
|
63
|
+
statRecord: (uri: string) => Promise<StoredAssetRecord | null>;
|
|
64
|
+
readAssetBytes: (uri: string) => Promise<Buffer | null>;
|
|
65
|
+
resolveContentPath: (uri: string) => string | null;
|
|
66
66
|
private putFromPath;
|
|
67
67
|
private putFromBytes;
|
|
68
68
|
private buildRecord;
|
|
@@ -75,7 +75,7 @@ declare function buildAssetContentPath(params: {
|
|
|
75
75
|
assetUri: string;
|
|
76
76
|
}): string;
|
|
77
77
|
//#endregion
|
|
78
|
-
//#region src/runtime/context-builder.d.ts
|
|
78
|
+
//#region src/runtime/context-builder.service.d.ts
|
|
79
79
|
type DefaultNcpContextBuilderOptions = {
|
|
80
80
|
toolRegistry?: NcpToolRegistry;
|
|
81
81
|
assetStore?: LocalAssetStore | null;
|
|
@@ -88,7 +88,7 @@ declare class DefaultNcpContextBuilder implements NcpContextBuilder {
|
|
|
88
88
|
prepare: (input: NcpAgentRunInput, options?: NcpContextPrepareOptions) => NcpLLMApiInput;
|
|
89
89
|
}
|
|
90
90
|
//#endregion
|
|
91
|
-
//#region src/runtime/user-content.d.ts
|
|
91
|
+
//#region src/runtime/user-content.utils.d.ts
|
|
92
92
|
declare function buildNcpUserContent(parts: NcpMessagePart[], options?: {
|
|
93
93
|
assetStore?: LocalAssetStore | null;
|
|
94
94
|
}): string | OpenAIContentPart[];
|
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { createHash, randomUUID } from "node:crypto";
|
|
|
4
4
|
import { copyFile, mkdir, readFile, stat, writeFile } from "node:fs/promises";
|
|
5
5
|
import { basename, dirname, join, resolve } from "node:path";
|
|
6
6
|
import { NcpAssistantTextStreamNormalizer, NcpEventType, isHiddenNcpMessage, normalizeAssistantText } from "@nextclaw/ncp";
|
|
7
|
-
//#region src/runtime/user-content.ts
|
|
7
|
+
//#region src/runtime/user-content.utils.ts
|
|
8
8
|
function readOptionalString$1(value) {
|
|
9
9
|
if (typeof value !== "string") return null;
|
|
10
10
|
const trimmed = value.trim();
|
|
@@ -741,7 +741,7 @@ function appendToolRoundToInput(input, reasoning, text, toolResults, toolResultC
|
|
|
741
741
|
});
|
|
742
742
|
}
|
|
743
743
|
//#endregion
|
|
744
|
-
//#region src/runtime/context-builder.ts
|
|
744
|
+
//#region src/runtime/context-builder.service.ts
|
|
745
745
|
function isRecord(value) {
|
|
746
746
|
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
747
747
|
}
|
|
@@ -875,7 +875,7 @@ var DefaultNcpContextBuilder = class {
|
|
|
875
875
|
};
|
|
876
876
|
};
|
|
877
877
|
//#endregion
|
|
878
|
-
//#region src/assets/asset
|
|
878
|
+
//#region src/assets/stores/local-asset.store.ts
|
|
879
879
|
const ASSET_URI_SCHEME = "asset://store/";
|
|
880
880
|
function normalizeSegment(value) {
|
|
881
881
|
return value.replace(/[^\w.-]+/g, "_").replace(/^_+|_+$/g, "") || "asset.bin";
|
|
@@ -1002,44 +1002,44 @@ var LocalAssetStore = class {
|
|
|
1002
1002
|
constructor(options) {
|
|
1003
1003
|
this.rootDir = ensureAssetRoot(options.rootDir);
|
|
1004
1004
|
}
|
|
1005
|
-
async
|
|
1005
|
+
put = async (input) => {
|
|
1006
1006
|
return { uri: (input.kind === "path" ? await this.putFromPath(input) : await this.putFromBytes({
|
|
1007
1007
|
fileName: input.fileName,
|
|
1008
1008
|
mimeType: input.mimeType,
|
|
1009
1009
|
bytes: input.bytes,
|
|
1010
1010
|
createdAt: input.createdAt
|
|
1011
1011
|
})).uri };
|
|
1012
|
-
}
|
|
1013
|
-
async
|
|
1012
|
+
};
|
|
1013
|
+
putBytes = async (params) => {
|
|
1014
1014
|
return this.putFromBytes(params);
|
|
1015
|
-
}
|
|
1016
|
-
async
|
|
1015
|
+
};
|
|
1016
|
+
putPath = async (params) => {
|
|
1017
1017
|
return this.putFromPath({
|
|
1018
1018
|
kind: "path",
|
|
1019
1019
|
...params
|
|
1020
1020
|
});
|
|
1021
|
-
}
|
|
1022
|
-
async
|
|
1021
|
+
};
|
|
1022
|
+
export = async (ref, targetPath) => {
|
|
1023
1023
|
const record = await this.statRecord(ref.uri);
|
|
1024
1024
|
if (!record) throw new Error(`Asset not found: ${ref.uri}`);
|
|
1025
1025
|
const outputPath = resolve(targetPath);
|
|
1026
1026
|
await ensureParentDirectory(outputPath);
|
|
1027
1027
|
await copyFile(this.resolveContentPathOrThrow(record), outputPath);
|
|
1028
1028
|
return outputPath;
|
|
1029
|
-
}
|
|
1030
|
-
async
|
|
1029
|
+
};
|
|
1030
|
+
stat = async (ref) => {
|
|
1031
1031
|
const record = await this.statRecord(ref.uri);
|
|
1032
1032
|
return record ? toAssetMeta(record) : null;
|
|
1033
|
-
}
|
|
1034
|
-
getByUri(uri) {
|
|
1033
|
+
};
|
|
1034
|
+
getByUri = (uri) => {
|
|
1035
1035
|
const storageKey = parseAssetUri(uri);
|
|
1036
1036
|
if (!storageKey) return null;
|
|
1037
1037
|
const metaPath = join(this.resolveStorageKeyDirectory(storageKey), "meta.json");
|
|
1038
1038
|
if (!existsSync(metaPath)) return null;
|
|
1039
1039
|
const text = readFileSync(metaPath, "utf8");
|
|
1040
1040
|
return hydrateStoredAssetRecord(JSON.parse(text));
|
|
1041
|
-
}
|
|
1042
|
-
async
|
|
1041
|
+
};
|
|
1042
|
+
statRecord = async (uri) => {
|
|
1043
1043
|
const record = this.getByUri(uri);
|
|
1044
1044
|
if (!record) return null;
|
|
1045
1045
|
try {
|
|
@@ -1048,8 +1048,8 @@ var LocalAssetStore = class {
|
|
|
1048
1048
|
} catch {
|
|
1049
1049
|
return null;
|
|
1050
1050
|
}
|
|
1051
|
-
}
|
|
1052
|
-
async
|
|
1051
|
+
};
|
|
1052
|
+
readAssetBytes = async (uri) => {
|
|
1053
1053
|
const record = await this.statRecord(uri);
|
|
1054
1054
|
if (!record) return null;
|
|
1055
1055
|
try {
|
|
@@ -1057,11 +1057,11 @@ var LocalAssetStore = class {
|
|
|
1057
1057
|
} catch {
|
|
1058
1058
|
return null;
|
|
1059
1059
|
}
|
|
1060
|
-
}
|
|
1061
|
-
resolveContentPath(uri) {
|
|
1060
|
+
};
|
|
1061
|
+
resolveContentPath = (uri) => {
|
|
1062
1062
|
const record = this.getByUri(uri);
|
|
1063
1063
|
return record ? this.resolveContentPathOrThrow(record) : null;
|
|
1064
|
-
}
|
|
1064
|
+
};
|
|
1065
1065
|
async putFromPath(input) {
|
|
1066
1066
|
const sourcePath = resolve(input.path);
|
|
1067
1067
|
if (!(await stat(sourcePath)).isFile()) throw new Error(`Asset source path is not a file: ${sourcePath}`);
|