staklink 0.3.69 → 0.3.71
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/proxy-server.cjs +142 -78
- package/dist/staklink-cli.cjs +1 -1
- package/package.json +2 -2
package/dist/proxy-server.cjs
CHANGED
|
@@ -61229,7 +61229,7 @@ var SSEManager = class {
|
|
|
61229
61229
|
var sseManager = new SSEManager();
|
|
61230
61230
|
|
|
61231
61231
|
// src/proxy/version.ts
|
|
61232
|
-
var VERSION = "0.3.
|
|
61232
|
+
var VERSION = "0.3.71";
|
|
61233
61233
|
|
|
61234
61234
|
// node_modules/uuid/dist/esm/stringify.js
|
|
61235
61235
|
var byteToHex = [];
|
|
@@ -120919,113 +120919,173 @@ function createProcessError(message, exitCode, stderr, metadata) {
|
|
|
120919
120919
|
});
|
|
120920
120920
|
}
|
|
120921
120921
|
function shouldIncludeForAudience(item, audience) {
|
|
120922
|
-
|
|
120922
|
+
try {
|
|
120923
|
+
if (!item?.annotations?.audience || !Array.isArray(item.annotations.audience)) {
|
|
120924
|
+
return true;
|
|
120925
|
+
}
|
|
120926
|
+
return item.annotations.audience.includes(audience);
|
|
120927
|
+
} catch {
|
|
120923
120928
|
return true;
|
|
120924
120929
|
}
|
|
120925
|
-
return item.annotations.audience.includes(audience);
|
|
120926
120930
|
}
|
|
120927
120931
|
function extractToolResultText(content, audience) {
|
|
120928
|
-
|
|
120929
|
-
|
|
120930
|
-
|
|
120931
|
-
|
|
120932
|
-
|
|
120932
|
+
if (!content || !Array.isArray(content)) {
|
|
120933
|
+
return "";
|
|
120934
|
+
}
|
|
120935
|
+
return content.filter((c) => c && typeof c === "object" && shouldIncludeForAudience(c, audience)).map((c) => {
|
|
120936
|
+
try {
|
|
120937
|
+
if (c.type === "text" && c.text) {
|
|
120938
|
+
return c.text;
|
|
120939
|
+
} else if (c.type === "resource" && c.resource?.text) {
|
|
120940
|
+
return c.resource.text;
|
|
120941
|
+
}
|
|
120942
|
+
return JSON.stringify(c);
|
|
120943
|
+
} catch {
|
|
120944
|
+
return "";
|
|
120933
120945
|
}
|
|
120934
|
-
return JSON.stringify(c);
|
|
120935
120946
|
}).join("\n");
|
|
120936
120947
|
}
|
|
120937
120948
|
function convertTextContent(content) {
|
|
120938
120949
|
return {
|
|
120939
120950
|
type: "text",
|
|
120940
|
-
text: content
|
|
120951
|
+
text: content?.text ?? ""
|
|
120941
120952
|
};
|
|
120942
120953
|
}
|
|
120943
120954
|
function convertToolRequest(content) {
|
|
120944
|
-
|
|
120945
|
-
|
|
120946
|
-
|
|
120947
|
-
|
|
120948
|
-
|
|
120949
|
-
|
|
120955
|
+
try {
|
|
120956
|
+
return {
|
|
120957
|
+
type: "tool-call",
|
|
120958
|
+
toolCallId: content?.id || generateId3(),
|
|
120959
|
+
toolName: content?.toolCall?.value?.name ?? "unknown",
|
|
120960
|
+
input: content?.toolCall?.value?.arguments ?? {}
|
|
120961
|
+
};
|
|
120962
|
+
} catch {
|
|
120963
|
+
return null;
|
|
120964
|
+
}
|
|
120950
120965
|
}
|
|
120951
120966
|
function convertToolResponse(content, audience) {
|
|
120952
|
-
|
|
120953
|
-
|
|
120954
|
-
|
|
120955
|
-
|
|
120956
|
-
|
|
120957
|
-
|
|
120958
|
-
|
|
120959
|
-
|
|
120960
|
-
|
|
120961
|
-
|
|
120962
|
-
|
|
120967
|
+
try {
|
|
120968
|
+
const resultText = extractToolResultText(content?.toolResult?.value?.content, audience);
|
|
120969
|
+
return {
|
|
120970
|
+
type: "tool-result",
|
|
120971
|
+
toolCallId: content?.id || generateId3(),
|
|
120972
|
+
toolName: "unknown",
|
|
120973
|
+
// Goose doesn't include tool name in response
|
|
120974
|
+
output: {
|
|
120975
|
+
type: "text",
|
|
120976
|
+
value: resultText
|
|
120977
|
+
}
|
|
120978
|
+
};
|
|
120979
|
+
} catch {
|
|
120980
|
+
return null;
|
|
120981
|
+
}
|
|
120963
120982
|
}
|
|
120964
120983
|
function convertAssistantMessage(message, audience) {
|
|
120965
|
-
|
|
120966
|
-
|
|
120967
|
-
if (!
|
|
120968
|
-
|
|
120984
|
+
try {
|
|
120985
|
+
const content = [];
|
|
120986
|
+
if (!message?.content || !Array.isArray(message.content)) {
|
|
120987
|
+
return null;
|
|
120969
120988
|
}
|
|
120970
|
-
|
|
120971
|
-
|
|
120972
|
-
|
|
120973
|
-
|
|
120989
|
+
for (const item of message.content) {
|
|
120990
|
+
if (!item || typeof item !== "object") {
|
|
120991
|
+
continue;
|
|
120992
|
+
}
|
|
120993
|
+
if (!shouldIncludeForAudience(item, audience)) {
|
|
120994
|
+
continue;
|
|
120995
|
+
}
|
|
120996
|
+
if (item.type === "text" && "text" in item && item.text) {
|
|
120997
|
+
content.push(convertTextContent(item));
|
|
120998
|
+
} else if (item.type === "toolRequest" && "toolCall" in item) {
|
|
120999
|
+
const toolCall = convertToolRequest(item);
|
|
121000
|
+
if (toolCall) {
|
|
121001
|
+
content.push(toolCall);
|
|
121002
|
+
}
|
|
121003
|
+
}
|
|
120974
121004
|
}
|
|
120975
|
-
|
|
120976
|
-
|
|
121005
|
+
if (content.length === 0) {
|
|
121006
|
+
return null;
|
|
121007
|
+
}
|
|
121008
|
+
return {
|
|
121009
|
+
role: "assistant",
|
|
121010
|
+
content
|
|
121011
|
+
};
|
|
121012
|
+
} catch {
|
|
120977
121013
|
return null;
|
|
120978
121014
|
}
|
|
120979
|
-
return {
|
|
120980
|
-
role: "assistant",
|
|
120981
|
-
content
|
|
120982
|
-
};
|
|
120983
121015
|
}
|
|
120984
121016
|
function convertUserMessage(message, audience) {
|
|
120985
|
-
|
|
120986
|
-
|
|
120987
|
-
|
|
120988
|
-
|
|
120989
|
-
if (!
|
|
120990
|
-
|
|
121017
|
+
try {
|
|
121018
|
+
const messages = [];
|
|
121019
|
+
const textParts = [];
|
|
121020
|
+
const toolResults = [];
|
|
121021
|
+
if (!message?.content || !Array.isArray(message.content)) {
|
|
121022
|
+
return [];
|
|
120991
121023
|
}
|
|
120992
|
-
|
|
120993
|
-
|
|
120994
|
-
|
|
120995
|
-
|
|
121024
|
+
for (const item of message.content) {
|
|
121025
|
+
if (!item || typeof item !== "object") {
|
|
121026
|
+
continue;
|
|
121027
|
+
}
|
|
121028
|
+
if (!shouldIncludeForAudience(item, audience)) {
|
|
121029
|
+
continue;
|
|
121030
|
+
}
|
|
121031
|
+
if (item.type === "text" && "text" in item && item.text) {
|
|
121032
|
+
textParts.push(convertTextContent(item));
|
|
121033
|
+
} else if (item.type === "toolResponse" && "toolResult" in item) {
|
|
121034
|
+
const result = convertToolResponse(item, audience);
|
|
121035
|
+
if (result) {
|
|
121036
|
+
toolResults.push(result);
|
|
121037
|
+
}
|
|
121038
|
+
}
|
|
120996
121039
|
}
|
|
121040
|
+
if (textParts.length > 0) {
|
|
121041
|
+
const userMessage = {
|
|
121042
|
+
role: "user",
|
|
121043
|
+
content: textParts
|
|
121044
|
+
};
|
|
121045
|
+
messages.push(userMessage);
|
|
121046
|
+
}
|
|
121047
|
+
if (toolResults.length > 0) {
|
|
121048
|
+
const toolMessage = {
|
|
121049
|
+
role: "tool",
|
|
121050
|
+
content: toolResults
|
|
121051
|
+
};
|
|
121052
|
+
messages.push(toolMessage);
|
|
121053
|
+
}
|
|
121054
|
+
return messages;
|
|
121055
|
+
} catch {
|
|
121056
|
+
return [];
|
|
120997
121057
|
}
|
|
120998
|
-
if (textParts.length > 0) {
|
|
120999
|
-
const userMessage = {
|
|
121000
|
-
role: "user",
|
|
121001
|
-
content: textParts
|
|
121002
|
-
};
|
|
121003
|
-
messages.push(userMessage);
|
|
121004
|
-
}
|
|
121005
|
-
if (toolResults.length > 0) {
|
|
121006
|
-
const toolMessage = {
|
|
121007
|
-
role: "tool",
|
|
121008
|
-
content: toolResults
|
|
121009
|
-
};
|
|
121010
|
-
messages.push(toolMessage);
|
|
121011
|
-
}
|
|
121012
|
-
return messages;
|
|
121013
121058
|
}
|
|
121014
121059
|
function convertGooseMessage(message, audience) {
|
|
121015
|
-
|
|
121016
|
-
|
|
121017
|
-
|
|
121018
|
-
|
|
121019
|
-
|
|
121060
|
+
try {
|
|
121061
|
+
if (!message || typeof message !== "object") {
|
|
121062
|
+
return [];
|
|
121063
|
+
}
|
|
121064
|
+
if (message.role === "assistant") {
|
|
121065
|
+
const converted = convertAssistantMessage(message, audience);
|
|
121066
|
+
return converted ? [converted] : [];
|
|
121067
|
+
} else if (message.role === "user") {
|
|
121068
|
+
return convertUserMessage(message, audience);
|
|
121069
|
+
}
|
|
121070
|
+
return [];
|
|
121071
|
+
} catch {
|
|
121072
|
+
return [];
|
|
121020
121073
|
}
|
|
121021
121074
|
}
|
|
121022
121075
|
function convertGooseMessages(messages, audience) {
|
|
121023
|
-
|
|
121024
|
-
|
|
121025
|
-
|
|
121026
|
-
|
|
121076
|
+
try {
|
|
121077
|
+
if (!messages || !Array.isArray(messages)) {
|
|
121078
|
+
return [];
|
|
121079
|
+
}
|
|
121080
|
+
const result = [];
|
|
121081
|
+
for (const message of messages) {
|
|
121082
|
+
const converted = convertGooseMessage(message, audience);
|
|
121083
|
+
result.push(...converted);
|
|
121084
|
+
}
|
|
121085
|
+
return result;
|
|
121086
|
+
} catch {
|
|
121087
|
+
return [];
|
|
121027
121088
|
}
|
|
121028
|
-
return result;
|
|
121029
121089
|
}
|
|
121030
121090
|
function parseModelId(modelId) {
|
|
121031
121091
|
const slashIndex = modelId.indexOf("/");
|
|
@@ -121493,7 +121553,7 @@ function exportSession(name40, audience = "user") {
|
|
|
121493
121553
|
encoding: "utf-8"
|
|
121494
121554
|
});
|
|
121495
121555
|
const session = JSON.parse(stdout);
|
|
121496
|
-
return convertGooseMessages(session
|
|
121556
|
+
return convertGooseMessages(session?.conversation ?? [], audience);
|
|
121497
121557
|
}
|
|
121498
121558
|
function sanitizeShellArg2(arg) {
|
|
121499
121559
|
return arg.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/`/g, "\\`").replace(/\$/g, "\\$").replace(/\n/g, " ").replace(/\r/g, "").replace(/!/g, "\\!");
|
|
@@ -132817,9 +132877,13 @@ _a153 = symbol153;
|
|
|
132817
132877
|
async function streamGooseToSSE(sessionId, prompt, apiKey, res, options) {
|
|
132818
132878
|
let resume = false;
|
|
132819
132879
|
try {
|
|
132880
|
+
console.log("Exporting session", sessionId);
|
|
132820
132881
|
exportSession(sessionId, "assistant");
|
|
132821
132882
|
resume = true;
|
|
132822
|
-
|
|
132883
|
+
console.log("Session exists, resume");
|
|
132884
|
+
} catch (error87) {
|
|
132885
|
+
console.log("Error exporting session", error87);
|
|
132886
|
+
console.log("Session doesn't exist, don't resume");
|
|
132823
132887
|
}
|
|
132824
132888
|
log("Streaming Goose to SSE", { sessionId, prompt, apiKey, resume });
|
|
132825
132889
|
createGooseConfig();
|
package/dist/staklink-cli.cjs
CHANGED
|
@@ -10967,7 +10967,7 @@ var glob = Object.assign(glob_, {
|
|
|
10967
10967
|
glob.glob = glob;
|
|
10968
10968
|
|
|
10969
10969
|
// src/proxy/version.ts
|
|
10970
|
-
var VERSION = "0.3.
|
|
10970
|
+
var VERSION = "0.3.71";
|
|
10971
10971
|
|
|
10972
10972
|
// src/cli.ts
|
|
10973
10973
|
var STAKLINK_PROXY = "staklink-proxy";
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "staklink",
|
|
3
3
|
"displayName": "staklink",
|
|
4
4
|
"description": "staklink process manager",
|
|
5
|
-
"version": "0.3.
|
|
5
|
+
"version": "0.3.71",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"publisher": "stakwork",
|
|
8
8
|
"engines": {
|
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
"@ai-sdk/google": "^3.0.6",
|
|
119
119
|
"@types/jsonwebtoken": "^9.0.10",
|
|
120
120
|
"ai": "^6.0.26",
|
|
121
|
-
"ai-sdk-provider-goose": "^0.1.
|
|
121
|
+
"ai-sdk-provider-goose": "^0.1.10",
|
|
122
122
|
"aieo": "^0.1.29",
|
|
123
123
|
"async-mutex": "^0.5.0",
|
|
124
124
|
"commander": "^14.0.1",
|