opencode-gitlab-duo-agentic 0.2.18 → 0.2.20
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.js +62 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -905,6 +905,25 @@ var WorkflowSession = class {
|
|
|
905
905
|
}
|
|
906
906
|
});
|
|
907
907
|
}
|
|
908
|
+
/**
|
|
909
|
+
* Send an HTTP response back to DWS on the existing connection.
|
|
910
|
+
* Used for gitlab_api_request which requires httpResponse (not plainTextResponse).
|
|
911
|
+
*/
|
|
912
|
+
sendHttpResult(requestId, statusCode, headers, body, error) {
|
|
913
|
+
dlog(`sendHttpResult: reqId=${requestId} status=${statusCode} body=${body.length}b error=${error ?? "none"} socket=${!!this.#socket}`);
|
|
914
|
+
if (!this.#socket) throw new Error("Not connected");
|
|
915
|
+
this.#socket.send({
|
|
916
|
+
actionResponse: {
|
|
917
|
+
requestID: requestId,
|
|
918
|
+
httpResponse: {
|
|
919
|
+
statusCode,
|
|
920
|
+
headers,
|
|
921
|
+
body,
|
|
922
|
+
error: error ?? ""
|
|
923
|
+
}
|
|
924
|
+
}
|
|
925
|
+
});
|
|
926
|
+
}
|
|
908
927
|
/**
|
|
909
928
|
* Wait for the next event from the session.
|
|
910
929
|
* Returns null when the stream is closed (turn complete or connection lost).
|
|
@@ -948,6 +967,12 @@ var WorkflowSession = class {
|
|
|
948
967
|
return;
|
|
949
968
|
}
|
|
950
969
|
const toolAction = action;
|
|
970
|
+
if (toolAction.runHTTPRequest && toolAction.requestID) {
|
|
971
|
+
dlog(`standalone: httpRequest ${toolAction.runHTTPRequest.method} ${toolAction.runHTTPRequest.path} reqId=${toolAction.requestID}`);
|
|
972
|
+
this.#executeHttpRequest(toolAction.requestID, toolAction.runHTTPRequest).catch(() => {
|
|
973
|
+
});
|
|
974
|
+
return;
|
|
975
|
+
}
|
|
951
976
|
const mapped = mapActionToToolRequest(toolAction);
|
|
952
977
|
if (mapped) {
|
|
953
978
|
dlog(`standalone: ${mapped.toolName} reqId=${mapped.requestId} args=${JSON.stringify(mapped.args).slice(0, 200)}`);
|
|
@@ -962,6 +987,42 @@ var WorkflowSession = class {
|
|
|
962
987
|
}
|
|
963
988
|
}
|
|
964
989
|
// ---------------------------------------------------------------------------
|
|
990
|
+
// Private: HTTP request handling (gitlab_api_request)
|
|
991
|
+
// ---------------------------------------------------------------------------
|
|
992
|
+
/**
|
|
993
|
+
* Execute a GitLab API request directly and send the response as httpResponse.
|
|
994
|
+
* DWS is the only action that expects httpResponse instead of plainTextResponse.
|
|
995
|
+
* Runs async in the background (fire-and-forget from #handleAction).
|
|
996
|
+
*/
|
|
997
|
+
async #executeHttpRequest(requestId, request2) {
|
|
998
|
+
try {
|
|
999
|
+
const url = `${this.#client.instanceUrl}/api/v4/${request2.path}`;
|
|
1000
|
+
dlog(`httpRequest: ${request2.method} ${request2.path} reqId=${requestId}`);
|
|
1001
|
+
const init = {
|
|
1002
|
+
method: request2.method,
|
|
1003
|
+
headers: {
|
|
1004
|
+
"authorization": `Bearer ${this.#client.token}`,
|
|
1005
|
+
"content-type": "application/json"
|
|
1006
|
+
}
|
|
1007
|
+
};
|
|
1008
|
+
if (request2.body) {
|
|
1009
|
+
init.body = request2.body;
|
|
1010
|
+
}
|
|
1011
|
+
const response = await fetch(url, init);
|
|
1012
|
+
const body = await response.text();
|
|
1013
|
+
const headers = {};
|
|
1014
|
+
response.headers.forEach((value, key) => {
|
|
1015
|
+
headers[key] = value;
|
|
1016
|
+
});
|
|
1017
|
+
dlog(`httpRequest: ${request2.method} ${request2.path} \u2192 ${response.status} body=${body.length}b`);
|
|
1018
|
+
this.sendHttpResult(requestId, response.status, headers, body);
|
|
1019
|
+
} catch (error) {
|
|
1020
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
1021
|
+
dlog(`httpRequest: ERROR ${request2.method} ${request2.path} \u2192 ${message}`);
|
|
1022
|
+
this.sendHttpResult(requestId, 0, {}, "", message);
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
// ---------------------------------------------------------------------------
|
|
965
1026
|
// Private: connection management
|
|
966
1027
|
// ---------------------------------------------------------------------------
|
|
967
1028
|
/**
|
|
@@ -1193,10 +1254,7 @@ function mapDuoToolRequest(toolName, args) {
|
|
|
1193
1254
|
switch (toolName) {
|
|
1194
1255
|
case "list_dir": {
|
|
1195
1256
|
const directory = asString2(args.directory) ?? ".";
|
|
1196
|
-
return {
|
|
1197
|
-
toolName: "bash",
|
|
1198
|
-
args: { command: `ls -la ${shellQuote(directory)}`, description: "List directory contents", workdir: "." }
|
|
1199
|
-
};
|
|
1257
|
+
return { toolName: "read", args: { filePath: directory } };
|
|
1200
1258
|
}
|
|
1201
1259
|
case "read_file": {
|
|
1202
1260
|
const filePath = asString2(args.file_path) ?? asString2(args.filepath) ?? asString2(args.filePath) ?? asString2(args.path);
|