Skip to content

Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.

refactor: tool messages

Brad Barbin4c3b2c7879a1
diff --git a/apps/erp/app/components/Chat/RecordButton.tsx b/apps/erp/app/components/Chat/RecordButton.tsx
index df5ad1e139..87ef35e4a4 100644
--- a/apps/erp/app/components/Chat/RecordButton.tsx
+++ b/apps/erp/app/components/Chat/RecordButton.tsx
@@ -216,7 +216,7 @@ export const RecordButton = forwardRef<RecordButtonRef, RecordButtonProps>(
disabled={disabled}
className={cn(
isRecording &&
- "text-emerald-500 hover:text-emerald-500 [&_svg]:text-emerald-500 [&_svg]:hover:text-emerald-500",
+ "text-indigo-600 hover:text-indigo-600 [&_svg]:text-indigo-600 [&_svg]:hover:text-indigo-600",
disabled && "opacity-50",
className
)}
diff --git a/apps/erp/app/components/Chat/hooks/useAudioRecording.tsx b/apps/erp/app/components/Chat/hooks/useAudioRecording.tsx
index d8fa6533f7..f0eab42ce0 100644
--- a/apps/erp/app/components/Chat/hooks/useAudioRecording.tsx
+++ b/apps/erp/app/components/Chat/hooks/useAudioRecording.tsx
@@ -19,7 +19,7 @@ export function useAudioRecording(): UseAudioRecordingReturn {
const recordingTimerRef = useRef<NodeJS.Timeout | null>(null);
// Hard limit: 1 minute (60 seconds)
- const MAX_RECORDING_TIME = 60 * 1000; // 60 seconds in milliseconds
+ const MAX_RECORDING_TIME = 15 * 1000; // 15 seconds in milliseconds
const stopRecording = useCallback(async (): Promise<Blob | null> => {
return new Promise((resolve) => {
@@ -90,18 +90,20 @@ export function useAudioRecording(): UseAudioRecordingReturn {
// Set up auto-stop timer for 1 minute limit
recordingTimerRef.current = setTimeout(() => {
- console.log("Recording automatically stopped after 1 minute");
+ console.log("Recording automatically stopped after 15 seconds");
stopRecording();
}, MAX_RECORDING_TIME);
} catch (error) {
console.error("Error starting audio recording:", error);
throw error;
}
- }, [stopRecording]);
+ }, [MAX_RECORDING_TIME, stopRecording]);
-
const { accessToken } = useCarbon();
- const { id: userId, company: { id: companyId } } = useUser();
+ const {
+ id: userId,
+ company: { id: companyId },
+ } = useUser();
const transcribeAudio = useCallback(
async (audioBlob: Blob): Promise<string> => {
setIsProcessing(true);
@@ -112,28 +114,25 @@ export function useAudioRecording(): UseAudioRecordingReturn {
const base64Audio = btoa(
new Uint8Array(arrayBuffer).reduce(
(data, byte) => data + String.fromCharCode(byte),
- "",
- ),
+ ""
+ )
);
// Get authenticated session
const transcriptionUrl = `${SUPABASE_URL}/functions/v1/transcription`;
- const response = await fetch(
- transcriptionUrl,
- {
- method: "POST",
- headers: {
- "Content-Type": "application/json",
- Authorization: `Bearer ${accessToken}`,
- "x-company-id": companyId,
- "x-user-id": userId,
- },
- body: JSON.stringify({
- audio: base64Audio,
- mimeType: audioBlob.type,
- }),
+ const response = await fetch(transcriptionUrl, {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ Authorization: `Bearer ${accessToken}`,
+ "x-company-id": companyId,
+ "x-user-id": userId,
},
- );
+ body: JSON.stringify({
+ audio: base64Audio,
+ mimeType: audioBlob.type,
+ }),
+ });
if (!response.ok) {
const errorText = await response.text();
@@ -143,7 +142,7 @@ export function useAudioRecording(): UseAudioRecordingReturn {
body: errorText,
});
throw new Error(
- `Failed to transcribe audio: ${response.status} ${response.statusText}`,
+ `Failed to transcribe audio: ${response.status} ${response.statusText}`
);
}
@@ -161,7 +160,7 @@ export function useAudioRecording(): UseAudioRecordingReturn {
setIsProcessing(false);
}
},
- [],
+ [accessToken, companyId, userId]
);
return {
diff --git a/apps/erp/app/components/Chat/lib/agent.tsx b/apps/erp/app/components/Chat/lib/agent.tsx
index c9c3bde101..7a48df689c 100644
--- a/apps/erp/app/components/Chat/lib/agent.tsx
+++ b/apps/erp/app/components/Chat/lib/agent.tsx
@@ -1,4 +1,3 @@
-import { agentConfigs } from "~/routes/api+/ai+/chat+/agents/config";
import type { AgentStatus } from "./types";
// Generate user-friendly status messages
@@ -9,13 +8,17 @@ export const getStatusMessage = (status?: AgentStatus | null) => {
const { agent, status: state } = status;
- if (state === "routing") {
- return "Thinking...";
- }
-
if (state === "executing") {
- const agentConfig = agentConfigs[agent];
- return agentConfig?.executingMessage || "Processing...";
+ const messages: Record<AgentStatus["agent"], string> = {
+ triage: "Thinking...",
+
+ general: "Searching the web...",
+ purchasing: "Calling the purchasing agent...",
+ parts: "Calling the parts agent...",
+ suppliers: "Calling the suppliers agent...",
+ };
+
+ return messages[agent];
}
return null;
diff --git a/apps/erp/app/routes/api+/ai+/chat+/tools/config.ts b/apps/erp/app/routes/api+/ai+/chat+/tools/config.ts
index dbe39b796c..a7f701b3a8 100644
--- a/apps/erp/app/routes/api+/ai+/chat+/tools/config.ts
+++ b/apps/erp/app/routes/api+/ai+/chat+/tools/config.ts
@@ -1,41 +1,25 @@
import type { ToolConfig } from "../agents/shared/tools";
-// Dynamically import all tool configs
-const toolModules = import.meta.glob("./tools/*/index.ts", {
+// Dynamically import all tool configs from sibling files
+// Exclude config.ts itself to avoid circular imports
+const toolModules = import.meta.glob("./*.ts", {
eager: true,
}) as Record<string, { config: ToolConfig }>;
-// Alternative pattern for direct tool files
-const directToolModules = import.meta.glob("./tools/*.ts", {
- eager: true,
-}) as Record<string, { config: ToolConfig }>;
-
-// Combine both patterns and create the config object
+// Create the config object from imported tool modules
export const toolConfigs: Record<
string,
Pick<ToolConfig, "icon" | "displayText" | "message">
-> = {
- ...Object.values(toolModules).reduce((acc, module) => {
- if (module.config) {
- acc[module.config.name] = {
- icon: module.config.icon,
- displayText: module.config.displayText,
- message: module.config.message,
- };
- }
- return acc;
- }, {} as Record<string, Pick<ToolConfig, "icon" | "displayText" | "message">>),
-
- ...Object.values(directToolModules).reduce((acc, module) => {
- if (module.config) {
- acc[module.config.name] = {
- icon: module.config.icon,
- displayText: module.config.displayText,
- message: module.config.message,
- };
- }
- return acc;
- }, {} as Record<string, Pick<ToolConfig, "icon" | "displayText" | "message">>),
-};
+> = Object.entries(toolModules).reduce((acc, [path, module]) => {
+ // Skip config.ts itself to avoid circular imports
+ if (path.includes("config.ts")) return acc;
-console.log(toolConfigs);
+ if (module.config) {
+ acc[module.config.name] = {
+ icon: module.config.icon,
+ displayText: module.config.displayText,
+ message: module.config.message,
+ };
+ }
+ return acc;
+}, {} as Record<string, Pick<ToolConfig, "icon" | "displayText" | "message">>);
diff --git a/package.json b/package.json
index 75f44a2c35..849c64ad4c 100755
--- a/package.json
+++ b/package.json
@@ -78,7 +78,7 @@
"examples/*",
"packages/*"
],
- "packageManager": "[email protected]",
+ "packageManager": "[email protected]",
"dependencies": {
"sst": "3.17.14"
}
diff --git a/packages/remix/src/hooks/useKeyboardWedge.ts b/packages/remix/src/hooks/useKeyboardWedge.ts
index d099a572e1..fba35bd94f 100644
--- a/packages/remix/src/hooks/useKeyboardWedge.ts
+++ b/packages/remix/src/hooks/useKeyboardWedge.ts
@@ -25,7 +25,6 @@ export function useKeyboardWedge(options?: UseKeyboardWedgeOptions) {
const test = options?.test ?? defaultTest;
const callback = options?.callback ?? defaultCallback;
const active = options?.active ?? true;
- console.log(inputBuffer);
useEffect(() => {
if (!active) return;
diff --git a/patches/@ai-sdk-tools+agents+1.0.8.patch b/patches/@ai-sdk-tools+agents+1.0.8.patch
new file mode 100644
index 0000000000..c752f384bf
--- /dev/null
+++ b/patches/@ai-sdk-tools+agents+1.0.8.patch
@@ -0,0 +1,26 @@
+diff --git a/node_modules/@ai-sdk-tools/agents/dist/index.cjs b/node_modules/@ai-sdk-tools/agents/dist/index.cjs
+index 0124c10..994d926 100644
+--- a/node_modules/@ai-sdk-tools/agents/dist/index.cjs
++++ b/node_modules/@ai-sdk-tools/agents/dist/index.cjs
+@@ -81,7 +81,7 @@ __export(index_exports, {
+ module.exports = __toCommonJS(index_exports);
+
+ // ../debug/dist/index.js
+-var isDebugEnabled = process.env.DEBUG_AGENTS === "true";
++var isDebugEnabled = false;
+ var colors = {
+ reset: "\x1B[0m",
+ gray: "\x1B[90m",
+diff --git a/node_modules/@ai-sdk-tools/agents/dist/index.js b/node_modules/@ai-sdk-tools/agents/dist/index.js
+index bdaf7b6..a9a2b9f 100644
+--- a/node_modules/@ai-sdk-tools/agents/dist/index.js
++++ b/node_modules/@ai-sdk-tools/agents/dist/index.js
+@@ -34,7 +34,7 @@ var init_context = __esm({
+ });
+
+ // ../debug/dist/index.js
+-var isDebugEnabled = process.env.DEBUG_AGENTS === "true";
++var isDebugEnabled = false;
+ var colors = {
+ reset: "\x1B[0m",
+ gray: "\x1B[90m",
diff --git a/patches/@ai-sdk-tools+memory+1.0.8.patch b/patches/@ai-sdk-tools+memory+1.0.8.patch
new file mode 100644
index 0000000000..7c5497a9bb
--- /dev/null
+++ b/patches/@ai-sdk-tools+memory+1.0.8.patch
@@ -0,0 +1,48 @@
+diff --git a/node_modules/@ai-sdk-tools/memory/dist/providers/redis.cjs b/node_modules/@ai-sdk-tools/memory/dist/providers/redis.cjs
+index 87f5f9b..c9a1084 100644
+--- a/node_modules/@ai-sdk-tools/memory/dist/providers/redis.cjs
++++ b/node_modules/@ai-sdk-tools/memory/dist/providers/redis.cjs
+@@ -25,7 +25,7 @@ __export(redis_exports, {
+ module.exports = __toCommonJS(redis_exports);
+
+ // ../debug/dist/index.js
+-var isDebugEnabled = process.env.DEBUG_AGENTS === "true";
++var isDebugEnabled = false;
+ var colors = {
+ reset: "\x1B[0m",
+ gray: "\x1B[90m",
+diff --git a/node_modules/@ai-sdk-tools/memory/dist/providers/redis.js b/node_modules/@ai-sdk-tools/memory/dist/providers/redis.js
+index 790365d..241d4fa 100644
+--- a/node_modules/@ai-sdk-tools/memory/dist/providers/redis.js
++++ b/node_modules/@ai-sdk-tools/memory/dist/providers/redis.js
+@@ -1,5 +1,5 @@
+ // ../debug/dist/index.js
+-var isDebugEnabled = process.env.DEBUG_AGENTS === "true";
++var isDebugEnabled = false;
+ var colors = {
+ reset: "\x1B[0m",
+ gray: "\x1B[90m",
+diff --git a/node_modules/@ai-sdk-tools/memory/dist/providers/upstash.cjs b/node_modules/@ai-sdk-tools/memory/dist/providers/upstash.cjs
+index 224b3ba..7cdd3c3 100644
+--- a/node_modules/@ai-sdk-tools/memory/dist/providers/upstash.cjs
++++ b/node_modules/@ai-sdk-tools/memory/dist/providers/upstash.cjs
+@@ -25,7 +25,7 @@ __export(upstash_exports, {
+ module.exports = __toCommonJS(upstash_exports);
+
+ // ../debug/dist/index.js
+-var isDebugEnabled = process.env.DEBUG_AGENTS === "true";
++var isDebugEnabled = false;
+ var colors = {
+ reset: "\x1B[0m",
+ gray: "\x1B[90m",
+diff --git a/node_modules/@ai-sdk-tools/memory/dist/providers/upstash.js b/node_modules/@ai-sdk-tools/memory/dist/providers/upstash.js
+index 6cba92d..1e5fa14 100644
+--- a/node_modules/@ai-sdk-tools/memory/dist/providers/upstash.js
++++ b/node_modules/@ai-sdk-tools/memory/dist/providers/upstash.js
+@@ -1,5 +1,5 @@
+ // ../debug/dist/index.js
+-var isDebugEnabled = process.env.DEBUG_AGENTS === "true";
++var isDebugEnabled = false;
+ var colors = {
+ reset: "\x1B[0m",
+ gray: "\x1B[90m",