@axiom-lattice/core 2.1.102 → 2.1.103
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.mts +125 -2
- package/dist/index.d.ts +125 -2
- package/dist/index.js +280 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +270 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1683,6 +1683,8 @@ __export(index_exports, {
|
|
|
1683
1683
|
QueueMode: () => QueueMode,
|
|
1684
1684
|
RemoteSandboxInstance: () => RemoteSandboxInstance,
|
|
1685
1685
|
RemoteSandboxProvider: () => RemoteSandboxProvider,
|
|
1686
|
+
STTModelLattice: () => STTModelLattice,
|
|
1687
|
+
STTModelLatticeManager: () => STTModelLatticeManager,
|
|
1686
1688
|
SandboxFilesystem: () => SandboxFilesystem,
|
|
1687
1689
|
SandboxLatticeManager: () => SandboxLatticeManager,
|
|
1688
1690
|
SandboxSkillStore: () => SandboxSkillStore,
|
|
@@ -1788,6 +1790,9 @@ __export(index_exports, {
|
|
|
1788
1790
|
getNextCronTime: () => getNextCronTime,
|
|
1789
1791
|
getOrCreateCollectionVectorStore: () => getOrCreateCollectionVectorStore,
|
|
1790
1792
|
getQueueLattice: () => getQueueLattice,
|
|
1793
|
+
getSTTClient: () => getSTTClient,
|
|
1794
|
+
getSTTClientWithTenant: () => getSTTClientWithTenant,
|
|
1795
|
+
getSTTModelLattice: () => getSTTModelLattice,
|
|
1791
1796
|
getSandBoxManager: () => getSandBoxManager,
|
|
1792
1797
|
getScheduleLattice: () => getScheduleLattice,
|
|
1793
1798
|
getStoreLattice: () => getStoreLattice,
|
|
@@ -1831,6 +1836,7 @@ __export(index_exports, {
|
|
|
1831
1836
|
registerLoggerLattice: () => registerLoggerLattice,
|
|
1832
1837
|
registerModelLattice: () => registerModelLattice,
|
|
1833
1838
|
registerQueueLattice: () => registerQueueLattice,
|
|
1839
|
+
registerSTTModelLattice: () => registerSTTModelLattice,
|
|
1834
1840
|
registerSandboxProviderType: () => registerSandboxProviderType,
|
|
1835
1841
|
registerScheduleLattice: () => registerScheduleLattice,
|
|
1836
1842
|
registerStoreLattice: () => registerStoreLattice,
|
|
@@ -1852,6 +1858,7 @@ __export(index_exports, {
|
|
|
1852
1858
|
skillLatticeManager: () => skillLatticeManager,
|
|
1853
1859
|
sqlDatabaseManager: () => sqlDatabaseManager,
|
|
1854
1860
|
storeLatticeManager: () => storeLatticeManager,
|
|
1861
|
+
sttModelLatticeManager: () => sttModelLatticeManager,
|
|
1855
1862
|
toJsonSchema: () => toJsonSchema,
|
|
1856
1863
|
toSafeStateExpr: () => toSafeStateExpr,
|
|
1857
1864
|
toolLatticeManager: () => toolLatticeManager,
|
|
@@ -9656,6 +9663,34 @@ function validateImageSize(sizeBytes) {
|
|
|
9656
9663
|
return null;
|
|
9657
9664
|
}
|
|
9658
9665
|
|
|
9666
|
+
// src/deep_agent_new/backends/audioUtils.ts
|
|
9667
|
+
var AUDIO_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
9668
|
+
".webm",
|
|
9669
|
+
".wav",
|
|
9670
|
+
".mp3",
|
|
9671
|
+
".m4a",
|
|
9672
|
+
".ogg",
|
|
9673
|
+
".flac",
|
|
9674
|
+
".aac",
|
|
9675
|
+
".wma",
|
|
9676
|
+
".opus",
|
|
9677
|
+
".amr"
|
|
9678
|
+
]);
|
|
9679
|
+
function isAudioFile(filePath) {
|
|
9680
|
+
const ext = filePath.toLowerCase().slice(filePath.lastIndexOf("."));
|
|
9681
|
+
return AUDIO_EXTENSIONS.has(ext);
|
|
9682
|
+
}
|
|
9683
|
+
function detectAudioFormat(filePath) {
|
|
9684
|
+
return filePath.toLowerCase().slice(filePath.lastIndexOf(".") + 1);
|
|
9685
|
+
}
|
|
9686
|
+
var MAX_AUDIO_SIZE = 25 * 1024 * 1024;
|
|
9687
|
+
function validateAudioSize(sizeBytes) {
|
|
9688
|
+
if (sizeBytes > MAX_AUDIO_SIZE) {
|
|
9689
|
+
return `Audio file too large (${(sizeBytes / 1024 / 1024).toFixed(1)}MB). Maximum is 25MB.`;
|
|
9690
|
+
}
|
|
9691
|
+
return null;
|
|
9692
|
+
}
|
|
9693
|
+
|
|
9659
9694
|
// src/deep_agent_new/backends/describeImage.ts
|
|
9660
9695
|
var import_messages = require("@langchain/core/messages");
|
|
9661
9696
|
async function describeImage(options) {
|
|
@@ -9681,6 +9716,215 @@ async function describeImage(options) {
|
|
|
9681
9716
|
return result.content || "";
|
|
9682
9717
|
}
|
|
9683
9718
|
|
|
9719
|
+
// src/stt_model_lattice/STTModelLatticeManager.ts
|
|
9720
|
+
init_BaseLatticeManager();
|
|
9721
|
+
|
|
9722
|
+
// src/stt_model_lattice/STTModelLattice.ts
|
|
9723
|
+
var import_openai2 = require("@langchain/openai");
|
|
9724
|
+
var STTModelLattice = class {
|
|
9725
|
+
constructor(key4, config) {
|
|
9726
|
+
this.key = key4;
|
|
9727
|
+
this.config = config;
|
|
9728
|
+
this.client = this;
|
|
9729
|
+
const apiKey = config.apiKey || (config.apiKeyEnvName ? process.env[config.apiKeyEnvName] : void 0) || process.env.OPENAI_API_KEY || "";
|
|
9730
|
+
if (!apiKey) {
|
|
9731
|
+
throw new Error("No API key configured for STT. Set apiKey, apiKeyEnvName, or OPENAI_API_KEY.");
|
|
9732
|
+
}
|
|
9733
|
+
this.openaiClient = new import_openai2.OpenAIClient({
|
|
9734
|
+
apiKey,
|
|
9735
|
+
baseURL: config.baseURL,
|
|
9736
|
+
timeout: config.timeout || 3e4
|
|
9737
|
+
});
|
|
9738
|
+
}
|
|
9739
|
+
/**
|
|
9740
|
+
* Transcribe audio buffer to text.
|
|
9741
|
+
* Routes to whisper or chat API mode based on config.
|
|
9742
|
+
*/
|
|
9743
|
+
async transcribe(audio, format) {
|
|
9744
|
+
const mode = this.config.apiMode || "whisper";
|
|
9745
|
+
if (mode === "chat") {
|
|
9746
|
+
return this.transcribeViaChat(audio, format);
|
|
9747
|
+
}
|
|
9748
|
+
return this.transcribeViaWhisper(audio, format);
|
|
9749
|
+
}
|
|
9750
|
+
/**
|
|
9751
|
+
* Transcribe via OpenAI /v1/audio/transcriptions endpoint (multipart).
|
|
9752
|
+
*/
|
|
9753
|
+
async transcribeViaWhisper(audio, format) {
|
|
9754
|
+
const mimeType = formatToMimeType(format);
|
|
9755
|
+
const file = typeof File !== "undefined" ? new File([audio], `audio.${format}`, { type: mimeType }) : await (0, import_openai2.toFile)(audio, `audio.${format}`, { type: mimeType });
|
|
9756
|
+
const extra = this.config.extra || {};
|
|
9757
|
+
const response = await this.openaiClient.audio.transcriptions.create({
|
|
9758
|
+
file,
|
|
9759
|
+
model: this.config.model || "whisper-1",
|
|
9760
|
+
response_format: "verbose_json",
|
|
9761
|
+
...extra
|
|
9762
|
+
});
|
|
9763
|
+
const result = response;
|
|
9764
|
+
return {
|
|
9765
|
+
text: result.text,
|
|
9766
|
+
segments: result.segments?.map((s) => ({
|
|
9767
|
+
start: s.start,
|
|
9768
|
+
end: s.end,
|
|
9769
|
+
text: s.text
|
|
9770
|
+
})),
|
|
9771
|
+
confidence: result.segments ? result.segments.reduce((sum, s) => sum + Math.exp(s.avg_logprob ?? -Infinity), 0) / result.segments.length : void 0
|
|
9772
|
+
};
|
|
9773
|
+
}
|
|
9774
|
+
/**
|
|
9775
|
+
* Transcribe via OpenAI /v1/chat/completions with input_audio.
|
|
9776
|
+
* Used by Qwen3-ASR-Flash and similar audio-via-chat models.
|
|
9777
|
+
*/
|
|
9778
|
+
async transcribeViaChat(audio, format) {
|
|
9779
|
+
const mimeType = formatToMimeType(format);
|
|
9780
|
+
const dataUri = `data:${mimeType};base64,${audio.toString("base64")}`;
|
|
9781
|
+
const extra = this.config.extra || {};
|
|
9782
|
+
const response = await this.openaiClient.chat.completions.create({
|
|
9783
|
+
model: this.config.model || "qwen3-asr-flash",
|
|
9784
|
+
messages: [
|
|
9785
|
+
{
|
|
9786
|
+
role: "user",
|
|
9787
|
+
content: [
|
|
9788
|
+
{
|
|
9789
|
+
type: "input_audio",
|
|
9790
|
+
input_audio: {
|
|
9791
|
+
data: dataUri,
|
|
9792
|
+
format
|
|
9793
|
+
}
|
|
9794
|
+
}
|
|
9795
|
+
]
|
|
9796
|
+
}
|
|
9797
|
+
],
|
|
9798
|
+
...extra
|
|
9799
|
+
});
|
|
9800
|
+
const result = response;
|
|
9801
|
+
const text = result.choices?.[0]?.message?.content || "";
|
|
9802
|
+
return { text };
|
|
9803
|
+
}
|
|
9804
|
+
};
|
|
9805
|
+
function formatToMimeType(format) {
|
|
9806
|
+
const mimeTypes = {
|
|
9807
|
+
webm: "audio/webm",
|
|
9808
|
+
wav: "audio/wav",
|
|
9809
|
+
mp3: "audio/mpeg",
|
|
9810
|
+
m4a: "audio/mp4",
|
|
9811
|
+
ogg: "audio/ogg",
|
|
9812
|
+
flac: "audio/flac",
|
|
9813
|
+
aac: "audio/aac"
|
|
9814
|
+
};
|
|
9815
|
+
const lower = format.toLowerCase();
|
|
9816
|
+
if (!mimeTypes[lower]) {
|
|
9817
|
+
console.warn(`Unknown STT audio format "${format}", falling back to audio/webm`);
|
|
9818
|
+
}
|
|
9819
|
+
return mimeTypes[lower] || "audio/webm";
|
|
9820
|
+
}
|
|
9821
|
+
|
|
9822
|
+
// src/stt_model_lattice/STTModelLatticeManager.ts
|
|
9823
|
+
var STTModelLatticeManager = class _STTModelLatticeManager extends BaseLatticeManager {
|
|
9824
|
+
static getInstance() {
|
|
9825
|
+
if (!_STTModelLatticeManager._instance) {
|
|
9826
|
+
_STTModelLatticeManager._instance = new _STTModelLatticeManager();
|
|
9827
|
+
}
|
|
9828
|
+
return _STTModelLatticeManager._instance;
|
|
9829
|
+
}
|
|
9830
|
+
getLatticeType() {
|
|
9831
|
+
return "stt";
|
|
9832
|
+
}
|
|
9833
|
+
/**
|
|
9834
|
+
* Register an STT model lattice.
|
|
9835
|
+
* @param key - Lattice key name
|
|
9836
|
+
* @param config - STT provider configuration
|
|
9837
|
+
*/
|
|
9838
|
+
registerLattice(key4, config) {
|
|
9839
|
+
const client = new STTModelLattice(key4, config);
|
|
9840
|
+
const label = config.model || key4;
|
|
9841
|
+
const sttLattice = {
|
|
9842
|
+
key: key4,
|
|
9843
|
+
client,
|
|
9844
|
+
config,
|
|
9845
|
+
label
|
|
9846
|
+
};
|
|
9847
|
+
this.register(key4, sttLattice);
|
|
9848
|
+
}
|
|
9849
|
+
/**
|
|
9850
|
+
* Get an STT model lattice by key.
|
|
9851
|
+
*/
|
|
9852
|
+
getSTTModelLattice(key4) {
|
|
9853
|
+
const lattice = this.get(key4);
|
|
9854
|
+
if (!lattice) {
|
|
9855
|
+
throw new Error(`STTModelLattice "${key4}" not found`);
|
|
9856
|
+
}
|
|
9857
|
+
return lattice;
|
|
9858
|
+
}
|
|
9859
|
+
/**
|
|
9860
|
+
* Get STT client instance by key (default tenant).
|
|
9861
|
+
*/
|
|
9862
|
+
getSTTClient(key4) {
|
|
9863
|
+
return this.getSTTModelLattice(key4).client;
|
|
9864
|
+
}
|
|
9865
|
+
/**
|
|
9866
|
+
* Get STT client instance by key and tenant.
|
|
9867
|
+
* @param tenantId - Tenant ID for isolation
|
|
9868
|
+
* @param key - Lattice key name
|
|
9869
|
+
*/
|
|
9870
|
+
getSTTClientWithTenant(tenantId2, key4) {
|
|
9871
|
+
let lattice = this.getWithTenant(tenantId2, key4);
|
|
9872
|
+
if (!lattice && tenantId2 !== "default") {
|
|
9873
|
+
lattice = this.getWithTenant("default", key4);
|
|
9874
|
+
}
|
|
9875
|
+
if (!lattice) {
|
|
9876
|
+
throw new Error(`STTModelLattice "${key4}" not found for tenant "${tenantId2}"`);
|
|
9877
|
+
}
|
|
9878
|
+
return lattice.client;
|
|
9879
|
+
}
|
|
9880
|
+
/**
|
|
9881
|
+
* Get all registered STT models as info list.
|
|
9882
|
+
*/
|
|
9883
|
+
getAllSTTModelInfo() {
|
|
9884
|
+
return this.getAllLattices().map((l) => ({
|
|
9885
|
+
key: l.key,
|
|
9886
|
+
label: l.label,
|
|
9887
|
+
provider: l.config.provider || "openai-compatible",
|
|
9888
|
+
model: l.config.model || "unknown"
|
|
9889
|
+
}));
|
|
9890
|
+
}
|
|
9891
|
+
getAllLattices() {
|
|
9892
|
+
return this.getAll();
|
|
9893
|
+
}
|
|
9894
|
+
hasLattice(key4) {
|
|
9895
|
+
return this.has(key4);
|
|
9896
|
+
}
|
|
9897
|
+
removeLattice(key4) {
|
|
9898
|
+
return this.remove(key4);
|
|
9899
|
+
}
|
|
9900
|
+
clearLattices() {
|
|
9901
|
+
this.clear();
|
|
9902
|
+
}
|
|
9903
|
+
getLatticeCount() {
|
|
9904
|
+
return this.count();
|
|
9905
|
+
}
|
|
9906
|
+
getLatticeKeys() {
|
|
9907
|
+
return this.keys();
|
|
9908
|
+
}
|
|
9909
|
+
};
|
|
9910
|
+
var sttModelLatticeManager = STTModelLatticeManager.getInstance();
|
|
9911
|
+
var registerSTTModelLattice = (key4, config) => sttModelLatticeManager.registerLattice(key4, config);
|
|
9912
|
+
var getSTTModelLattice = (key4) => sttModelLatticeManager.getSTTModelLattice(key4);
|
|
9913
|
+
var getSTTClient = (key4) => sttModelLatticeManager.getSTTClient(key4);
|
|
9914
|
+
var getSTTClientWithTenant = (tenantId2, key4) => sttModelLatticeManager.getSTTClientWithTenant(tenantId2, key4);
|
|
9915
|
+
|
|
9916
|
+
// src/deep_agent_new/backends/transcribeAudio.ts
|
|
9917
|
+
async function transcribeAudio(options) {
|
|
9918
|
+
const { audioBuffer, format } = options;
|
|
9919
|
+
if (!sttModelLatticeManager.hasLattice("default")) {
|
|
9920
|
+
throw new Error(
|
|
9921
|
+
"No default STT model registered. Use registerSTTModelLattice('default', { ... }) first."
|
|
9922
|
+
);
|
|
9923
|
+
}
|
|
9924
|
+
const client = sttModelLatticeManager.getSTTClient("default");
|
|
9925
|
+
return await client.transcribe(audioBuffer, format);
|
|
9926
|
+
}
|
|
9927
|
+
|
|
9684
9928
|
// src/deep_agent_new/middleware/fs.ts
|
|
9685
9929
|
var FileDataSchema = import_v3.z.object({
|
|
9686
9930
|
content: import_v3.z.array(import_v3.z.string()),
|
|
@@ -9739,7 +9983,7 @@ Path conventions:
|
|
|
9739
9983
|
- glob: find files matching a pattern (e.g., "/project/**/*.py")
|
|
9740
9984
|
- grep: search for text within files`;
|
|
9741
9985
|
var LS_TOOL_DESCRIPTION = "List files and directories in a directory";
|
|
9742
|
-
var READ_FILE_TOOL_DESCRIPTION = "Read the contents of a file. For image files (png, jpg, gif, webp, bmp, svg), returns a visual description when the current model supports vision
|
|
9986
|
+
var READ_FILE_TOOL_DESCRIPTION = "Read the contents of a file. For image files (png, jpg, gif, webp, bmp, svg), returns a visual description when the current model supports vision; otherwise returns an error suggesting a vision-capable model. For audio files (webm, wav, mp3, m4a, ogg, flac, aac, wma, opus, amr), transcribes the content using the default STT model; if none is registered, returns an error with registration instructions.";
|
|
9743
9987
|
var WRITE_FILE_TOOL_DESCRIPTION = "Write content to a new file. Returns an error if the file already exists";
|
|
9744
9988
|
var EDIT_FILE_TOOL_DESCRIPTION = "Edit a file by replacing a specific string with a new string";
|
|
9745
9989
|
var GLOB_TOOL_DESCRIPTION = "Find files matching a glob pattern (e.g., '**/*.py' for all Python files)";
|
|
@@ -9824,6 +10068,34 @@ ${description}`;
|
|
|
9824
10068
|
\u8BFB\u53D6\u56FE\u7247\u5931\u8D25\uFF1A${error instanceof Error ? error.message : "\u672A\u77E5\u9519\u8BEF"}`;
|
|
9825
10069
|
}
|
|
9826
10070
|
}
|
|
10071
|
+
if (isAudioFile(file_path)) {
|
|
10072
|
+
if (!resolvedBackend.readBinary) {
|
|
10073
|
+
return `[Audio] ${file_path}
|
|
10074
|
+
The current backend does not support binary reading, unable to process audio.`;
|
|
10075
|
+
}
|
|
10076
|
+
try {
|
|
10077
|
+
const buffer2 = await resolvedBackend.readBinary(file_path);
|
|
10078
|
+
const sizeWarning = validateAudioSize(buffer2.length);
|
|
10079
|
+
if (sizeWarning) {
|
|
10080
|
+
return `[Audio] ${file_path}
|
|
10081
|
+
${sizeWarning}`;
|
|
10082
|
+
}
|
|
10083
|
+
const format = detectAudioFormat(file_path);
|
|
10084
|
+
const result = await transcribeAudio({ audioBuffer: buffer2, format });
|
|
10085
|
+
let output = `[Audio] ${file_path} (${format}, ${(buffer2.length / 1024).toFixed(1)}KB)`;
|
|
10086
|
+
if (result.confidence !== void 0) {
|
|
10087
|
+
output += `
|
|
10088
|
+
Confidence: ${(result.confidence * 100).toFixed(1)}%`;
|
|
10089
|
+
}
|
|
10090
|
+
output += `
|
|
10091
|
+
|
|
10092
|
+
${result.text}`;
|
|
10093
|
+
return output;
|
|
10094
|
+
} catch (error) {
|
|
10095
|
+
return `[Audio] ${file_path}
|
|
10096
|
+
Audio transcription failed: ${error instanceof Error ? error.message : "Unknown error"}`;
|
|
10097
|
+
}
|
|
10098
|
+
}
|
|
9827
10099
|
return await resolvedBackend.read(file_path, offset, limit);
|
|
9828
10100
|
},
|
|
9829
10101
|
{
|
|
@@ -29430,6 +29702,8 @@ registerBuiltinPlugins();
|
|
|
29430
29702
|
QueueMode,
|
|
29431
29703
|
RemoteSandboxInstance,
|
|
29432
29704
|
RemoteSandboxProvider,
|
|
29705
|
+
STTModelLattice,
|
|
29706
|
+
STTModelLatticeManager,
|
|
29433
29707
|
SandboxFilesystem,
|
|
29434
29708
|
SandboxLatticeManager,
|
|
29435
29709
|
SandboxSkillStore,
|
|
@@ -29535,6 +29809,9 @@ registerBuiltinPlugins();
|
|
|
29535
29809
|
getNextCronTime,
|
|
29536
29810
|
getOrCreateCollectionVectorStore,
|
|
29537
29811
|
getQueueLattice,
|
|
29812
|
+
getSTTClient,
|
|
29813
|
+
getSTTClientWithTenant,
|
|
29814
|
+
getSTTModelLattice,
|
|
29538
29815
|
getSandBoxManager,
|
|
29539
29816
|
getScheduleLattice,
|
|
29540
29817
|
getStoreLattice,
|
|
@@ -29578,6 +29855,7 @@ registerBuiltinPlugins();
|
|
|
29578
29855
|
registerLoggerLattice,
|
|
29579
29856
|
registerModelLattice,
|
|
29580
29857
|
registerQueueLattice,
|
|
29858
|
+
registerSTTModelLattice,
|
|
29581
29859
|
registerSandboxProviderType,
|
|
29582
29860
|
registerScheduleLattice,
|
|
29583
29861
|
registerStoreLattice,
|
|
@@ -29599,6 +29877,7 @@ registerBuiltinPlugins();
|
|
|
29599
29877
|
skillLatticeManager,
|
|
29600
29878
|
sqlDatabaseManager,
|
|
29601
29879
|
storeLatticeManager,
|
|
29880
|
+
sttModelLatticeManager,
|
|
29602
29881
|
toJsonSchema,
|
|
29603
29882
|
toSafeStateExpr,
|
|
29604
29883
|
toolLatticeManager,
|