opencode-gitlab-duo-agentic 0.1.19 → 0.1.22
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 +20 -11
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -322,6 +322,18 @@ function toModelsConfig(available) {
|
|
|
322
322
|
async function createPluginHooks(input) {
|
|
323
323
|
return {
|
|
324
324
|
config: async (config) => applyRuntimeConfig(config, input.directory),
|
|
325
|
+
"chat.message": async ({ sessionID }, { parts }) => {
|
|
326
|
+
const text2 = parts.filter((p) => p.type === "text" && !("synthetic" in p && p.synthetic)).map((p) => "text" in p ? p.text : "").join(" ").trim();
|
|
327
|
+
if (!text2) return;
|
|
328
|
+
const title = text2.length > 100 ? text2.slice(0, 97) + "..." : text2;
|
|
329
|
+
const url = new URL(`/session/${encodeURIComponent(sessionID)}`, input.serverUrl);
|
|
330
|
+
await fetch(url, {
|
|
331
|
+
method: "PATCH",
|
|
332
|
+
headers: { "content-type": "application/json" },
|
|
333
|
+
body: JSON.stringify({ title })
|
|
334
|
+
}).catch(() => {
|
|
335
|
+
});
|
|
336
|
+
},
|
|
325
337
|
"chat.params": async (context, output) => {
|
|
326
338
|
if (!isGitLabProvider(context.model)) return;
|
|
327
339
|
output.options = {
|
|
@@ -728,9 +740,11 @@ var DuoWorkflowModel = class {
|
|
|
728
740
|
this.#client = client;
|
|
729
741
|
}
|
|
730
742
|
async doGenerate(options) {
|
|
743
|
+
const sessionID = readSessionID(options);
|
|
744
|
+
if (!sessionID) throw new Error("missing workflow session ID");
|
|
731
745
|
const goal = extractGoal(options.prompt);
|
|
732
746
|
if (!goal) throw new Error("missing user message content");
|
|
733
|
-
const session = this.#resolveSession(
|
|
747
|
+
const session = this.#resolveSession(sessionID);
|
|
734
748
|
const chunks = [];
|
|
735
749
|
for await (const item of session.runTurn(goal, options.abortSignal)) {
|
|
736
750
|
if (item.type === "text-delta") chunks.push(item.value);
|
|
@@ -752,9 +766,11 @@ var DuoWorkflowModel = class {
|
|
|
752
766
|
};
|
|
753
767
|
}
|
|
754
768
|
async doStream(options) {
|
|
769
|
+
const sessionID = readSessionID(options);
|
|
770
|
+
if (!sessionID) throw new Error("missing workflow session ID");
|
|
755
771
|
const goal = extractGoal(options.prompt);
|
|
756
772
|
if (!goal) throw new Error("missing user message content");
|
|
757
|
-
const session = this.#resolveSession(
|
|
773
|
+
const session = this.#resolveSession(sessionID);
|
|
758
774
|
const textId = randomUUID2();
|
|
759
775
|
return {
|
|
760
776
|
stream: new ReadableStream({
|
|
@@ -823,8 +839,7 @@ var DuoWorkflowModel = class {
|
|
|
823
839
|
}
|
|
824
840
|
};
|
|
825
841
|
}
|
|
826
|
-
#resolveSession(
|
|
827
|
-
const sessionID = readSessionID(options);
|
|
842
|
+
#resolveSession(sessionID) {
|
|
828
843
|
const key = `${this.#client.instanceUrl}::${this.modelId}::${sessionID}`;
|
|
829
844
|
const existing = sessions.get(key);
|
|
830
845
|
if (existing) return existing;
|
|
@@ -860,19 +875,13 @@ function readSessionID(options) {
|
|
|
860
875
|
for (const [key, value] of Object.entries(headers)) {
|
|
861
876
|
if (key.toLowerCase() === "x-opencode-session" && value?.trim()) return value.trim();
|
|
862
877
|
}
|
|
863
|
-
return
|
|
878
|
+
return void 0;
|
|
864
879
|
}
|
|
865
880
|
function readProviderBlock(options) {
|
|
866
881
|
const block = options.providerOptions?.[PROVIDER_ID];
|
|
867
882
|
if (block && typeof block === "object" && !Array.isArray(block)) {
|
|
868
883
|
return block;
|
|
869
884
|
}
|
|
870
|
-
if (!options.providerOptions) return void 0;
|
|
871
|
-
for (const value of Object.values(options.providerOptions)) {
|
|
872
|
-
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
873
|
-
return value;
|
|
874
|
-
}
|
|
875
|
-
}
|
|
876
885
|
return void 0;
|
|
877
886
|
}
|
|
878
887
|
|