gitlab-ai-provider 6.12.1 → 6.13.0
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/CHANGELOG.md +10 -0
- package/README.md +1 -0
- package/dist/gitlab-ai-provider-6.13.0.tgz +0 -0
- package/dist/index.d.mts +25 -0
- package/dist/index.d.ts +25 -0
- package/dist/index.js +111 -23
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +111 -23
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/dist/gitlab-ai-provider-6.12.1.tgz +0 -0
package/dist/index.mjs
CHANGED
|
@@ -403,6 +403,10 @@ var WorkflowType = /* @__PURE__ */ ((WorkflowType2) => {
|
|
|
403
403
|
})(WorkflowType || {});
|
|
404
404
|
var WS_KEEPALIVE_PING_INTERVAL_MS = 45e3;
|
|
405
405
|
var WS_HEARTBEAT_INTERVAL_MS = 6e4;
|
|
406
|
+
var WS_CLOSE_WORKFLOW_LOCKED = 1013;
|
|
407
|
+
var WS_CLOSE_WAIT_TIMEOUT_MS = 3e3;
|
|
408
|
+
var WS_WORKFLOW_LOCK_RETRY_DELAY_MS = 1500;
|
|
409
|
+
var WS_WORKFLOW_LOCK_MAX_RETRIES = 8;
|
|
406
410
|
var DEFAULT_WORKFLOW_DEFINITION = "chat" /* CHAT */;
|
|
407
411
|
var DEFAULT_CLIENT_CAPABILITIES = ["shell_command"];
|
|
408
412
|
var CLIENT_VERSION = "8.51.0";
|
|
@@ -1385,6 +1389,7 @@ import OpenAI from "openai";
|
|
|
1385
1389
|
// src/model-mappings.ts
|
|
1386
1390
|
var MODEL_MAPPINGS = {
|
|
1387
1391
|
// Anthropic models
|
|
1392
|
+
"duo-chat-fable-5-1": { provider: "anthropic", model: "claude-fable-5-1" },
|
|
1388
1393
|
"duo-chat-fable-5": { provider: "anthropic", model: "claude-fable-5" },
|
|
1389
1394
|
"duo-chat-opus-5": { provider: "anthropic", model: "claude-opus-5" },
|
|
1390
1395
|
"duo-chat-opus-4-8": { provider: "anthropic", model: "claude-opus-4-8" },
|
|
@@ -2447,7 +2452,7 @@ import { AsyncResource } from "async_hooks";
|
|
|
2447
2452
|
import WebSocket from "isomorphic-ws";
|
|
2448
2453
|
|
|
2449
2454
|
// src/version.ts
|
|
2450
|
-
var VERSION = true ? "6.12.
|
|
2455
|
+
var VERSION = true ? "6.12.2" : "0.0.0-dev";
|
|
2451
2456
|
|
|
2452
2457
|
// src/gitlab-workflow-client.ts
|
|
2453
2458
|
var WS_CONNECT_TIMEOUT_MS = 3e4;
|
|
@@ -2597,6 +2602,48 @@ var GitLabWorkflowClient = class {
|
|
|
2597
2602
|
}
|
|
2598
2603
|
}
|
|
2599
2604
|
}
|
|
2605
|
+
/**
|
|
2606
|
+
* Close the socket and wait for the close handshake to actually land.
|
|
2607
|
+
*
|
|
2608
|
+
* `close()` returns as soon as the close frame is queued. That is too early
|
|
2609
|
+
* when the caller is about to reconnect to the same workflow, because
|
|
2610
|
+
* Workhorse releases the workflow lock only once its own stop handshake with
|
|
2611
|
+
* DWS completes. Awaiting `onclose` (or the timeout) keeps the reconnect from
|
|
2612
|
+
* racing the lock and getting rejected with close code 1013.
|
|
2613
|
+
*
|
|
2614
|
+
* Best effort: never rejects, and resolves after `timeoutMs` if the server
|
|
2615
|
+
* never answers.
|
|
2616
|
+
*
|
|
2617
|
+
* @param timeoutMs - Maximum time to wait for the close event
|
|
2618
|
+
* @default WS_CLOSE_WAIT_TIMEOUT_MS
|
|
2619
|
+
*/
|
|
2620
|
+
closeAndWait(timeoutMs = WS_CLOSE_WAIT_TIMEOUT_MS) {
|
|
2621
|
+
const sock = this.socket;
|
|
2622
|
+
const pending = sock && (sock.readyState === WebSocket.OPEN || sock.readyState === WebSocket.CONNECTING);
|
|
2623
|
+
if (this.closed || !pending) {
|
|
2624
|
+
this.close();
|
|
2625
|
+
return Promise.resolve();
|
|
2626
|
+
}
|
|
2627
|
+
return new Promise((resolve3) => {
|
|
2628
|
+
let settled = false;
|
|
2629
|
+
const finish = () => {
|
|
2630
|
+
if (settled) return;
|
|
2631
|
+
settled = true;
|
|
2632
|
+
clearTimeout(timer);
|
|
2633
|
+
resolve3();
|
|
2634
|
+
};
|
|
2635
|
+
const timer = setTimeout(finish, timeoutMs);
|
|
2636
|
+
const previous = sock.onclose;
|
|
2637
|
+
sock.onclose = (event) => {
|
|
2638
|
+
try {
|
|
2639
|
+
previous?.call(sock, event);
|
|
2640
|
+
} finally {
|
|
2641
|
+
finish();
|
|
2642
|
+
}
|
|
2643
|
+
};
|
|
2644
|
+
this.close();
|
|
2645
|
+
});
|
|
2646
|
+
}
|
|
2600
2647
|
/**
|
|
2601
2648
|
* Check if the WebSocket is currently connected.
|
|
2602
2649
|
*/
|
|
@@ -4556,19 +4603,20 @@ var GitLabWorkflowLanguageModel = class _GitLabWorkflowLanguageModel {
|
|
|
4556
4603
|
}
|
|
4557
4604
|
ss.approvalPending = false;
|
|
4558
4605
|
ss.deferredClose = null;
|
|
4559
|
-
this.cleanupClient(ss, false);
|
|
4560
4606
|
const approval = decision.approved ? { approval: { tool_name: tools[0]?.name, tool_args_json: tools[0]?.args } } : { rejection: { message: decision.message ?? "User rejected" } };
|
|
4561
4607
|
const newStartReq = {
|
|
4562
4608
|
...startReq,
|
|
4563
4609
|
approval,
|
|
4564
4610
|
preapproved_tools: decision.approved ? [...startReq.preapproved_tools ?? [], ...tools.map((t) => t.name)] : startReq.preapproved_tools ?? []
|
|
4565
4611
|
};
|
|
4566
|
-
const
|
|
4567
|
-
|
|
4568
|
-
|
|
4569
|
-
|
|
4570
|
-
|
|
4571
|
-
|
|
4612
|
+
const reconnect = async () => {
|
|
4613
|
+
if (ss.streamClosed) return;
|
|
4614
|
+
await this.closeClientAndWait(ss);
|
|
4615
|
+
const client = new GitLabWorkflowClient();
|
|
4616
|
+
this.activeClients.add(client);
|
|
4617
|
+
ss.activeClient = client;
|
|
4618
|
+
const modelRef = await this.resolveModelRef();
|
|
4619
|
+
await client.connect(
|
|
4572
4620
|
{
|
|
4573
4621
|
instanceUrl: this.config.instanceUrl,
|
|
4574
4622
|
modelRef,
|
|
@@ -4579,23 +4627,63 @@ var GitLabWorkflowLanguageModel = class _GitLabWorkflowLanguageModel {
|
|
|
4579
4627
|
aiCatalogItemVersionId: wsExtras?.aiCatalogItemVersionId,
|
|
4580
4628
|
workflowDefinition: wsExtras?.workflowDefinition
|
|
4581
4629
|
},
|
|
4582
|
-
(event) =>
|
|
4630
|
+
(event) => {
|
|
4631
|
+
if (event.type === "closed" && event.code === WS_CLOSE_WORKFLOW_LOCKED) {
|
|
4632
|
+
void retryWhileLocked();
|
|
4633
|
+
return;
|
|
4634
|
+
}
|
|
4635
|
+
this.handleWorkflowEvent(
|
|
4636
|
+
ss,
|
|
4637
|
+
event,
|
|
4638
|
+
controller,
|
|
4639
|
+
client,
|
|
4640
|
+
toolExecutor,
|
|
4641
|
+
nextTextId,
|
|
4642
|
+
availableToolNames,
|
|
4643
|
+
newStartReq,
|
|
4644
|
+
wsExtras
|
|
4645
|
+
);
|
|
4646
|
+
}
|
|
4647
|
+
);
|
|
4648
|
+
client.sendStartRequest(newStartReq);
|
|
4649
|
+
};
|
|
4650
|
+
let lockRetries = 0;
|
|
4651
|
+
const retryWhileLocked = async () => {
|
|
4652
|
+
if (ss.streamClosed) return;
|
|
4653
|
+
if (++lockRetries > WS_WORKFLOW_LOCK_MAX_RETRIES) {
|
|
4654
|
+
this.failStream(
|
|
4583
4655
|
ss,
|
|
4584
|
-
event,
|
|
4585
4656
|
controller,
|
|
4586
|
-
|
|
4587
|
-
|
|
4588
|
-
|
|
4589
|
-
|
|
4590
|
-
|
|
4591
|
-
|
|
4592
|
-
|
|
4593
|
-
);
|
|
4594
|
-
|
|
4595
|
-
}
|
|
4596
|
-
|
|
4597
|
-
|
|
4598
|
-
|
|
4657
|
+
new GitLabError({
|
|
4658
|
+
message: "Failed to acquire lock on workflow after reconnect retries",
|
|
4659
|
+
statusCode: WS_CLOSE_WORKFLOW_LOCKED
|
|
4660
|
+
})
|
|
4661
|
+
);
|
|
4662
|
+
return;
|
|
4663
|
+
}
|
|
4664
|
+
await new Promise((r) => setTimeout(r, WS_WORKFLOW_LOCK_RETRY_DELAY_MS * lockRetries));
|
|
4665
|
+
await reconnect().catch((err) => this.failStream(ss, controller, err));
|
|
4666
|
+
};
|
|
4667
|
+
await reconnect().catch((err) => this.failStream(ss, controller, err));
|
|
4668
|
+
}
|
|
4669
|
+
/**
|
|
4670
|
+
* Close the active client and wait for its close handshake, so a following
|
|
4671
|
+
* reconnect to the same workflow does not race the Workhorse lock.
|
|
4672
|
+
*/
|
|
4673
|
+
async closeClientAndWait(ss) {
|
|
4674
|
+
const client = ss.activeClient;
|
|
4675
|
+
if (!client) return;
|
|
4676
|
+
this.activeClients.delete(client);
|
|
4677
|
+
ss.activeClient = null;
|
|
4678
|
+
await client.closeAndWait();
|
|
4679
|
+
}
|
|
4680
|
+
/**
|
|
4681
|
+
* Surface a terminal error on the stream and drop the workflow.
|
|
4682
|
+
*/
|
|
4683
|
+
failStream(ss, controller, error) {
|
|
4684
|
+
this.cleanupClient(ss, true);
|
|
4685
|
+
if (ss.streamClosed) return;
|
|
4686
|
+
controller.error(error);
|
|
4599
4687
|
}
|
|
4600
4688
|
// ---------------------------------------------------------------------------
|
|
4601
4689
|
// Workflow metadata
|