@diologue/local-agent 0.1.3 → 0.1.5
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/cli.mjs +35 -34
- package/dist/cli.mjs.map +2 -2
- package/package.json +1 -1
package/dist/cli.mjs
CHANGED
|
@@ -984,6 +984,15 @@ var LlmBroker = class {
|
|
|
984
984
|
if (response.text) {
|
|
985
985
|
entry.observer({ type: "text_delta", text: response.text });
|
|
986
986
|
}
|
|
987
|
+
for (const [index, tc] of (response.toolCalls ?? []).entries()) {
|
|
988
|
+
entry.observer({
|
|
989
|
+
type: "tool_call_delta",
|
|
990
|
+
index,
|
|
991
|
+
id: tc.id,
|
|
992
|
+
name: tc.function.name,
|
|
993
|
+
argumentsDelta: tc.function.arguments
|
|
994
|
+
});
|
|
995
|
+
}
|
|
987
996
|
entry.observer({ type: "complete", payload: response });
|
|
988
997
|
} catch {
|
|
989
998
|
}
|
|
@@ -1747,30 +1756,35 @@ var extractBearer = (req) => {
|
|
|
1747
1756
|
var sendOpenAIError = (res, status, message, type = "invalid_request_error") => {
|
|
1748
1757
|
res.status(status).json({ error: { message, type } });
|
|
1749
1758
|
};
|
|
1759
|
+
var resolveBrokerOr401 = (req, res) => {
|
|
1760
|
+
const token = extractBearer(req);
|
|
1761
|
+
if (!token) {
|
|
1762
|
+
sendOpenAIError(res, 401, "Missing Authorization bearer", "auth_error");
|
|
1763
|
+
return null;
|
|
1764
|
+
}
|
|
1765
|
+
const broker = getActiveBrokerByToken(token) ?? getOnlyActiveBroker();
|
|
1766
|
+
if (!broker) {
|
|
1767
|
+
const tokenPrefix = token.length > 12 ? `${token.slice(0, 12)}\u2026` : token;
|
|
1768
|
+
console.error(
|
|
1769
|
+
`[llm-shim] 401 on ${req.path}: bearer="${tokenPrefix}" active_brokers=${_activeBrokerCount()}`
|
|
1770
|
+
);
|
|
1771
|
+
sendOpenAIError(
|
|
1772
|
+
res,
|
|
1773
|
+
401,
|
|
1774
|
+
"No active coding-agent stream is currently authorised on this helper.",
|
|
1775
|
+
"auth_error"
|
|
1776
|
+
);
|
|
1777
|
+
return null;
|
|
1778
|
+
}
|
|
1779
|
+
return broker;
|
|
1780
|
+
};
|
|
1750
1781
|
var createLlmShimRouter = () => {
|
|
1751
1782
|
const router = createRouter3();
|
|
1752
1783
|
router.post(
|
|
1753
1784
|
"/v1/chat/completions",
|
|
1754
1785
|
async (req, res) => {
|
|
1755
|
-
const
|
|
1756
|
-
if (!
|
|
1757
|
-
sendOpenAIError(res, 401, "Missing Authorization bearer", "auth_error");
|
|
1758
|
-
return;
|
|
1759
|
-
}
|
|
1760
|
-
const broker = getActiveBrokerByToken(token) ?? getOnlyActiveBroker();
|
|
1761
|
-
if (!broker) {
|
|
1762
|
-
const tokenPrefix = token.length > 12 ? `${token.slice(0, 12)}\u2026` : token;
|
|
1763
|
-
console.error(
|
|
1764
|
-
`[llm-shim] 401 on ${req.path}: bearer="${tokenPrefix}" active_brokers=${_activeBrokerCount()}`
|
|
1765
|
-
);
|
|
1766
|
-
sendOpenAIError(
|
|
1767
|
-
res,
|
|
1768
|
-
401,
|
|
1769
|
-
"No active coding-agent stream is currently authorised on this helper.",
|
|
1770
|
-
"auth_error"
|
|
1771
|
-
);
|
|
1772
|
-
return;
|
|
1773
|
-
}
|
|
1786
|
+
const broker = resolveBrokerOr401(req, res);
|
|
1787
|
+
if (!broker) return;
|
|
1774
1788
|
const body = req.body;
|
|
1775
1789
|
if (!body || typeof body !== "object" || !Array.isArray(body.messages) || body.messages.length === 0) {
|
|
1776
1790
|
sendOpenAIError(res, 400, "messages[] is required and must be non-empty");
|
|
@@ -1916,21 +1930,8 @@ var createLlmShimRouter = () => {
|
|
|
1916
1930
|
}
|
|
1917
1931
|
);
|
|
1918
1932
|
router.post("/v1/responses", async (req, res) => {
|
|
1919
|
-
const
|
|
1920
|
-
if (!
|
|
1921
|
-
sendOpenAIError(res, 401, "Missing Authorization bearer", "auth_error");
|
|
1922
|
-
return;
|
|
1923
|
-
}
|
|
1924
|
-
const broker = getActiveBrokerByToken(token);
|
|
1925
|
-
if (!broker) {
|
|
1926
|
-
sendOpenAIError(
|
|
1927
|
-
res,
|
|
1928
|
-
401,
|
|
1929
|
-
"No active coding-agent stream is currently authorised on this helper.",
|
|
1930
|
-
"auth_error"
|
|
1931
|
-
);
|
|
1932
|
-
return;
|
|
1933
|
-
}
|
|
1933
|
+
const broker = resolveBrokerOr401(req, res);
|
|
1934
|
+
if (!broker) return;
|
|
1934
1935
|
const body = req.body;
|
|
1935
1936
|
if (!body || typeof body !== "object" || !Array.isArray(body.input) || body.input.length === 0) {
|
|
1936
1937
|
sendOpenAIError(res, 400, "input[] is required and must be non-empty");
|