staklink 0.3.67 → 0.3.69
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 +68 -17
- package/dist/staklink-cli.cjs +1 -1
- package/package.json +1 -1
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.69";
|
|
61233
61233
|
|
|
61234
61234
|
// node_modules/uuid/dist/esm/stringify.js
|
|
61235
61235
|
var byteToHex = [];
|
|
@@ -105427,14 +105427,32 @@ async function callModel(opts) {
|
|
|
105427
105427
|
// src/agent/summary.ts
|
|
105428
105428
|
var SYSTEM = `You are a software development expert. Your job is to summarize a software development session.`;
|
|
105429
105429
|
var makeSummaryPrompt = (sessionData) => {
|
|
105430
|
-
return `Please summarize the following software development
|
|
105430
|
+
return `Please summarize the following software development interaction:
|
|
105431
105431
|
|
|
105432
105432
|
${sessionData}
|
|
105433
105433
|
|
|
105434
|
-
Be sure to mention specific file names, or names of new functions, classes, components, data models, endpoints, or other code elements that were created or modified. For file names, use the full file path. In general, just make it easy for the user to understand what was done in
|
|
105434
|
+
Be sure to mention specific file names, or names of new functions, classes, components, data models, endpoints, or other code elements that were created or modified. For file names, use the full file path. In general, just make it easy for the user to understand what was done in this interaction.
|
|
105435
105435
|
`;
|
|
105436
105436
|
};
|
|
105437
|
+
function extractLastInteraction(messages) {
|
|
105438
|
+
if (!messages || messages.length === 0) {
|
|
105439
|
+
return [];
|
|
105440
|
+
}
|
|
105441
|
+
const result = [];
|
|
105442
|
+
let i = messages.length - 1;
|
|
105443
|
+
while (i >= 0 && (messages[i].role === "assistant" || messages[i].role === "tool")) {
|
|
105444
|
+
result.unshift(messages[i]);
|
|
105445
|
+
i--;
|
|
105446
|
+
}
|
|
105447
|
+
while (i >= 0 && messages[i].role === "user") {
|
|
105448
|
+
result.unshift(messages[i]);
|
|
105449
|
+
i--;
|
|
105450
|
+
}
|
|
105451
|
+
return result;
|
|
105452
|
+
}
|
|
105437
105453
|
async function summarizeSession(sessionData, apiKey) {
|
|
105454
|
+
const lastInteraction = extractLastInteraction(sessionData);
|
|
105455
|
+
const dataToSummarize = JSON.stringify(lastInteraction, null, 2);
|
|
105438
105456
|
const systemMessage = {
|
|
105439
105457
|
role: "system",
|
|
105440
105458
|
content: SYSTEM
|
|
@@ -105444,7 +105462,7 @@ async function summarizeSession(sessionData, apiKey) {
|
|
|
105444
105462
|
content: [
|
|
105445
105463
|
{
|
|
105446
105464
|
type: "text",
|
|
105447
|
-
text: makeSummaryPrompt(
|
|
105465
|
+
text: makeSummaryPrompt(dataToSummarize)
|
|
105448
105466
|
}
|
|
105449
105467
|
]
|
|
105450
105468
|
};
|
|
@@ -121495,7 +121513,7 @@ function goose_env(apiKey) {
|
|
|
121495
121513
|
PATH: `${path8.join(os.homedir(), ".local", "bin")}:${process.env.PATH}`
|
|
121496
121514
|
};
|
|
121497
121515
|
}
|
|
121498
|
-
async function runAgent({ prompt, apiKey, cwd, system_prompt, session,
|
|
121516
|
+
async function runAgent({ prompt, apiKey, cwd, system_prompt, session, summarize }) {
|
|
121499
121517
|
createGooseConfig();
|
|
121500
121518
|
const env = goose_env(apiKey);
|
|
121501
121519
|
console.log("RUN goose with env", env);
|
|
@@ -121509,15 +121527,17 @@ async function runAgent({ prompt, apiKey, cwd, system_prompt, session, resume, s
|
|
|
121509
121527
|
session = sanitizeShellArg(session);
|
|
121510
121528
|
session = session.replaceAll(" ", "_");
|
|
121511
121529
|
cmd += ` --name ${session}`;
|
|
121512
|
-
|
|
121513
|
-
|
|
121514
|
-
|
|
121530
|
+
try {
|
|
121531
|
+
exportSession(session, "assistant");
|
|
121532
|
+
cmd += ` --resume`;
|
|
121533
|
+
} catch {
|
|
121534
|
+
}
|
|
121515
121535
|
}
|
|
121516
121536
|
const res = await executeCommand(cmd, cwd, env, (l) => console.log(l));
|
|
121517
121537
|
const output = res.stdout;
|
|
121518
121538
|
if (summarize && session) {
|
|
121519
121539
|
const sessionData = exportSession(session, "assistant");
|
|
121520
|
-
const summary = await summarizeSession(
|
|
121540
|
+
const summary = await summarizeSession(sessionData, apiKey);
|
|
121521
121541
|
return { output, summary };
|
|
121522
121542
|
}
|
|
121523
121543
|
return output;
|
|
@@ -132795,7 +132815,13 @@ _a153 = symbol153;
|
|
|
132795
132815
|
|
|
132796
132816
|
// src/agent/goose-streaming.ts
|
|
132797
132817
|
async function streamGooseToSSE(sessionId, prompt, apiKey, res, options) {
|
|
132798
|
-
|
|
132818
|
+
let resume = false;
|
|
132819
|
+
try {
|
|
132820
|
+
exportSession(sessionId, "assistant");
|
|
132821
|
+
resume = true;
|
|
132822
|
+
} catch {
|
|
132823
|
+
}
|
|
132824
|
+
log("Streaming Goose to SSE", { sessionId, prompt, apiKey, resume });
|
|
132799
132825
|
createGooseConfig();
|
|
132800
132826
|
const textAccumulators = /* @__PURE__ */ new Map();
|
|
132801
132827
|
try {
|
|
@@ -132803,13 +132829,12 @@ async function streamGooseToSSE(sessionId, prompt, apiKey, res, options) {
|
|
|
132803
132829
|
model: goose("anthropic/claude-sonnet-4-5", {
|
|
132804
132830
|
sessionName: sessionId,
|
|
132805
132831
|
apiKey,
|
|
132806
|
-
resume
|
|
132832
|
+
resume
|
|
132807
132833
|
}),
|
|
132808
132834
|
prompt,
|
|
132809
132835
|
system: options?.system
|
|
132810
132836
|
});
|
|
132811
132837
|
for await (const part of result.fullStream) {
|
|
132812
|
-
log("Stream part received:", JSON.stringify(part));
|
|
132813
132838
|
sendSSE(res, "message", part);
|
|
132814
132839
|
if (options?.webhookUrl) {
|
|
132815
132840
|
const p = part;
|
|
@@ -132852,7 +132877,7 @@ async function streamGooseToSSE(sessionId, prompt, apiKey, res, options) {
|
|
|
132852
132877
|
type: "tool-result",
|
|
132853
132878
|
toolCallId: p.toolCallId,
|
|
132854
132879
|
toolName: p.toolName,
|
|
132855
|
-
output: p.output,
|
|
132880
|
+
output: truncateOutput(p.output),
|
|
132856
132881
|
timestamp: Date.now()
|
|
132857
132882
|
}).catch((error87) => error("Error posting to webhook", error87));
|
|
132858
132883
|
break;
|
|
@@ -132875,6 +132900,19 @@ function sendSSE(res, event, data) {
|
|
|
132875
132900
|
`);
|
|
132876
132901
|
}
|
|
132877
132902
|
}
|
|
132903
|
+
function truncateOutput(output) {
|
|
132904
|
+
const str = typeof output === "string" ? output : JSON.stringify(output);
|
|
132905
|
+
const lines = str.split("\n");
|
|
132906
|
+
const maxLines = 10;
|
|
132907
|
+
const maxLineLength = 100;
|
|
132908
|
+
const truncatedLines = lines.slice(0, maxLines).map(
|
|
132909
|
+
(line) => line.length > maxLineLength ? line.slice(0, maxLineLength) + "..." : line
|
|
132910
|
+
);
|
|
132911
|
+
if (lines.length > maxLines) {
|
|
132912
|
+
truncatedLines.push("[truncated]");
|
|
132913
|
+
}
|
|
132914
|
+
return truncatedLines.join("\n");
|
|
132915
|
+
}
|
|
132878
132916
|
async function postToWebhook(url3, payload) {
|
|
132879
132917
|
try {
|
|
132880
132918
|
const response = await fetch(url3, {
|
|
@@ -134823,7 +134861,7 @@ ${diff.trim()}`);
|
|
|
134823
134861
|
res.status(401).json({ error: "Invalid or expired token" });
|
|
134824
134862
|
return;
|
|
134825
134863
|
}
|
|
134826
|
-
const { prompt, system
|
|
134864
|
+
const { prompt, system } = req.body;
|
|
134827
134865
|
if (!prompt) {
|
|
134828
134866
|
res.status(400).json({
|
|
134829
134867
|
error: "Missing required field: prompt"
|
|
@@ -134840,7 +134878,7 @@ ${diff.trim()}`);
|
|
|
134840
134878
|
prompt,
|
|
134841
134879
|
session.apiKey || process.env.ANTHROPIC_API_KEY || "",
|
|
134842
134880
|
res,
|
|
134843
|
-
{ system,
|
|
134881
|
+
{ system, webhookUrl: session.webhookUrl }
|
|
134844
134882
|
);
|
|
134845
134883
|
});
|
|
134846
134884
|
app.use(requireAuth);
|
|
@@ -134864,7 +134902,7 @@ ${diff.trim()}`);
|
|
|
134864
134902
|
return async (req, res) => {
|
|
134865
134903
|
const request_id = startReq();
|
|
134866
134904
|
try {
|
|
134867
|
-
const { repoName, apiKey, agent_name, session,
|
|
134905
|
+
const { repoName, apiKey, agent_name, session, summarize } = req.body;
|
|
134868
134906
|
const params = getParams(req);
|
|
134869
134907
|
const workspaceRoot2 = await workspaceRoot();
|
|
134870
134908
|
let repoPath = workspaceRoot2;
|
|
@@ -134885,7 +134923,6 @@ ${diff.trim()}`);
|
|
|
134885
134923
|
cwd: repoPath,
|
|
134886
134924
|
system_prompt: params.system,
|
|
134887
134925
|
session,
|
|
134888
|
-
resume: resume ? true : false,
|
|
134889
134926
|
summarize: summarize ? true : false
|
|
134890
134927
|
}).then((result) => {
|
|
134891
134928
|
const finalResult = transformResult ? transformResult(result) : result;
|
|
@@ -134903,6 +134940,20 @@ ${diff.trim()}`);
|
|
|
134903
134940
|
}
|
|
134904
134941
|
};
|
|
134905
134942
|
};
|
|
134943
|
+
app.post("/validate_session", async (req, res) => {
|
|
134944
|
+
log("===> POST /validate_session");
|
|
134945
|
+
const { session } = req.body;
|
|
134946
|
+
if (!session) {
|
|
134947
|
+
res.status(400).json({ error: "Missing required field: session" });
|
|
134948
|
+
return;
|
|
134949
|
+
}
|
|
134950
|
+
try {
|
|
134951
|
+
exportSession(session, "assistant");
|
|
134952
|
+
res.json({ exists: true });
|
|
134953
|
+
} catch (error87) {
|
|
134954
|
+
res.json({ exists: false });
|
|
134955
|
+
}
|
|
134956
|
+
});
|
|
134906
134957
|
app.post(
|
|
134907
134958
|
"/agent",
|
|
134908
134959
|
createAsyncAgentHandler((req) => ({
|
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.69";
|
|
10971
10971
|
|
|
10972
10972
|
// src/cli.ts
|
|
10973
10973
|
var STAKLINK_PROXY = "staklink-proxy";
|