@agentconnect/ui 0.1.1 → 0.1.3
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/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAI5D;;;GAGG;AACH,wBAAgB,SAAS,IAAI,OAAO,CAAC,kBAAkB,CAAC,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAI5D;;;GAGG;AACH,wBAAgB,SAAS,IAAI,OAAO,CAAC,kBAAkB,CAAC,CAQvD;AAED;;;GAGG;AACH,wBAAgB,WAAW,IAAI,IAAI,CAElC"}
|
package/dist/client.js
CHANGED
|
@@ -9,7 +9,10 @@ let clientPromise = null;
|
|
|
9
9
|
*/
|
|
10
10
|
export function getClient() {
|
|
11
11
|
if (!clientPromise) {
|
|
12
|
-
clientPromise = AgentConnect.connect()
|
|
12
|
+
clientPromise = AgentConnect.connect().catch((err) => {
|
|
13
|
+
clientPromise = null;
|
|
14
|
+
throw err;
|
|
15
|
+
});
|
|
13
16
|
}
|
|
14
17
|
return clientPromise;
|
|
15
18
|
}
|
|
@@ -18,6 +18,9 @@ export declare class AgentConnectConnect extends HTMLElement {
|
|
|
18
18
|
private handleResize;
|
|
19
19
|
private loginPollTimer;
|
|
20
20
|
private readonly loginPollIntervalMs;
|
|
21
|
+
private readonly loginPollTimeoutMs;
|
|
22
|
+
private readonly loginPending;
|
|
23
|
+
private readonly statusCheckInFlight;
|
|
21
24
|
private readonly modelsRefreshIntervalMs;
|
|
22
25
|
constructor();
|
|
23
26
|
connectedCallback(): void;
|
|
@@ -42,6 +45,11 @@ export declare class AgentConnectConnect extends HTMLElement {
|
|
|
42
45
|
private startLoginPolling;
|
|
43
46
|
private stopLoginPolling;
|
|
44
47
|
private pollProviderStatus;
|
|
48
|
+
private shouldPollLogin;
|
|
49
|
+
private updateLoginPolling;
|
|
50
|
+
private updateProviderEntry;
|
|
51
|
+
private checkProviderStatus;
|
|
52
|
+
private waitForProviderLogin;
|
|
45
53
|
private prefetchProviders;
|
|
46
54
|
private prefetchAllProviderModels;
|
|
47
55
|
private refreshModels;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connect.d.ts","sourceRoot":"","sources":["../../src/components/connect.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA+BH,qBAAa,mBAAoB,SAAQ,WAAW;IAClD,OAAO,CAAC,KAAK,CAAwB;IACrC,OAAO,CAAC,WAAW,CAAsB;IACzC,OAAO,CAAC,WAAW,CAAU;IAC7B,OAAO,CAAC,IAAI,CAAU;IACtB,OAAO,CAAC,WAAW,CAAgB;IACnC,OAAO,CAAC,gBAAgB,CAAU;IAClC,OAAO,CAAC,kBAAkB,CAAU;IACpC,OAAO,CAAC,aAAa,CAAU;IAC/B,OAAO,CAAC,eAAe,CAAuC;IAC9D,OAAO,CAAC,cAAc,CAAoB;IAC1C,OAAO,CAAC,eAAe,CAAS;IAChC,OAAO,CAAC,QAAQ,CAAkC;IAClD,OAAO,CAAC,YAAY,CAAa;IACjC,OAAO,CAAC,cAAc,CAAwC;IAC9D,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAQ;IAC5C,OAAO,CAAC,QAAQ,CAAC,uBAAuB,CAAU;;IAyBlD,iBAAiB,IAAI,IAAI;IASzB,oBAAoB,IAAI,IAAI;IAK5B,OAAO,CAAC,kBAAkB;IAc1B,OAAO,KAAK,UAAU,GAErB;IAED,OAAO,KAAK,cAAc,GAEzB;IAED,OAAO,CAAC,MAAM;IAWd,OAAO,CAAC,aAAa;IA4BrB,OAAO,CAAC,U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s = 2000;
|
|
25
|
+
loginPollTimeoutMs = 120_000;
|
|
26
|
+
loginPending = new Set();
|
|
27
|
+
statusCheckInFlight = new Set();
|
|
25
28
|
modelsRefreshIntervalMs = 30_000;
|
|
26
29
|
constructor() {
|
|
27
30
|
super();
|
|
@@ -168,12 +171,7 @@ export class AgentConnectConnect extends HTMLElement {
|
|
|
168
171
|
}
|
|
169
172
|
this.setView(this.state.connected ? 'connected' : 'connect');
|
|
170
173
|
this.refresh();
|
|
171
|
-
|
|
172
|
-
this.startLoginPolling();
|
|
173
|
-
}
|
|
174
|
-
else {
|
|
175
|
-
this.stopLoginPolling();
|
|
176
|
-
}
|
|
174
|
+
this.updateLoginPolling();
|
|
177
175
|
}
|
|
178
176
|
close() {
|
|
179
177
|
this.elements?.overlay?.classList.remove('open');
|
|
@@ -196,12 +194,7 @@ export class AgentConnectConnect extends HTMLElement {
|
|
|
196
194
|
if (view === 'connected') {
|
|
197
195
|
this.popoverLocked = false;
|
|
198
196
|
this.popoverPosition = null;
|
|
199
|
-
|
|
200
|
-
this.startLoginPolling();
|
|
201
|
-
}
|
|
202
|
-
else {
|
|
203
|
-
this.stopLoginPolling();
|
|
204
|
-
}
|
|
197
|
+
this.updateLoginPolling();
|
|
205
198
|
this.renderConnectedModels();
|
|
206
199
|
this.renderReasoningEfforts();
|
|
207
200
|
requestAnimationFrame(() => this.positionPopover());
|
|
@@ -374,6 +367,11 @@ export class AgentConnectConnect extends HTMLElement {
|
|
|
374
367
|
const previous = this.state.providers;
|
|
375
368
|
const providers = await client.providers.list();
|
|
376
369
|
this.state.providers = providers;
|
|
370
|
+
for (const provider of providers) {
|
|
371
|
+
if (provider.loggedIn) {
|
|
372
|
+
this.loginPending.delete(provider.id);
|
|
373
|
+
}
|
|
374
|
+
}
|
|
377
375
|
if (this.state.view === 'connected') {
|
|
378
376
|
this.updatePopoverTitle();
|
|
379
377
|
this.updateButtonLabel();
|
|
@@ -393,10 +391,91 @@ export class AgentConnectConnect extends HTMLElement {
|
|
|
393
391
|
this.renderConnectedModels();
|
|
394
392
|
this.renderReasoningEfforts();
|
|
395
393
|
}
|
|
396
|
-
|
|
394
|
+
this.updateLoginPolling();
|
|
395
|
+
}
|
|
396
|
+
shouldPollLogin() {
|
|
397
|
+
if (!this.elements?.overlay?.classList.contains('open'))
|
|
398
|
+
return false;
|
|
399
|
+
if (this.loginPending.size > 0)
|
|
400
|
+
return true;
|
|
401
|
+
return this.state.providers.some((provider) => provider.installed && !provider.loggedIn);
|
|
402
|
+
}
|
|
403
|
+
updateLoginPolling() {
|
|
404
|
+
if (this.shouldPollLogin()) {
|
|
405
|
+
this.startLoginPolling();
|
|
406
|
+
}
|
|
407
|
+
else {
|
|
397
408
|
this.stopLoginPolling();
|
|
398
409
|
}
|
|
399
410
|
}
|
|
411
|
+
updateProviderEntry(providerId, updates) {
|
|
412
|
+
const index = this.state.providers.findIndex((entry) => entry.id === providerId);
|
|
413
|
+
if (index === -1)
|
|
414
|
+
return;
|
|
415
|
+
this.state.providers[index] = { ...this.state.providers[index], ...updates };
|
|
416
|
+
}
|
|
417
|
+
async checkProviderStatus(providerId, providerName) {
|
|
418
|
+
if (this.statusCheckInFlight.has(providerId))
|
|
419
|
+
return;
|
|
420
|
+
this.statusCheckInFlight.add(providerId);
|
|
421
|
+
const label = providerName || providerId;
|
|
422
|
+
this.setStatus(`Checking ${label} status...`);
|
|
423
|
+
try {
|
|
424
|
+
const client = await getClient();
|
|
425
|
+
const status = await client.providers.status(providerId);
|
|
426
|
+
this.updateProviderEntry(providerId, {
|
|
427
|
+
installed: status.installed,
|
|
428
|
+
loggedIn: status.loggedIn,
|
|
429
|
+
version: status.version,
|
|
430
|
+
});
|
|
431
|
+
if (status.loggedIn) {
|
|
432
|
+
this.loginPending.delete(providerId);
|
|
433
|
+
await this.refreshModels();
|
|
434
|
+
this.renderConnectedModels();
|
|
435
|
+
this.renderReasoningEfforts();
|
|
436
|
+
}
|
|
437
|
+
this.renderProviders();
|
|
438
|
+
this.updatePopoverTitle();
|
|
439
|
+
this.updateButtonLabel();
|
|
440
|
+
this.updateLoginPolling();
|
|
441
|
+
}
|
|
442
|
+
finally {
|
|
443
|
+
this.statusCheckInFlight.delete(providerId);
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
async waitForProviderLogin(providerId, providerName) {
|
|
447
|
+
const client = await getClient();
|
|
448
|
+
const startedAt = Date.now();
|
|
449
|
+
this.loginPending.add(providerId);
|
|
450
|
+
this.updateLoginPolling();
|
|
451
|
+
this.setProviderLoading(providerId, false);
|
|
452
|
+
this.renderProviders();
|
|
453
|
+
this.updatePopoverTitle();
|
|
454
|
+
this.updateButtonLabel();
|
|
455
|
+
while (Date.now() - startedAt < this.loginPollTimeoutMs) {
|
|
456
|
+
const status = await client.providers.status(providerId);
|
|
457
|
+
this.updateProviderEntry(providerId, {
|
|
458
|
+
installed: status.installed,
|
|
459
|
+
loggedIn: status.loggedIn,
|
|
460
|
+
version: status.version,
|
|
461
|
+
});
|
|
462
|
+
if (status.loggedIn) {
|
|
463
|
+
this.loginPending.delete(providerId);
|
|
464
|
+
await this.refreshModels();
|
|
465
|
+
this.renderConnectedModels();
|
|
466
|
+
this.renderReasoningEfforts();
|
|
467
|
+
this.updatePopoverTitle();
|
|
468
|
+
this.updateButtonLabel();
|
|
469
|
+
this.updateLoginPolling();
|
|
470
|
+
return true;
|
|
471
|
+
}
|
|
472
|
+
await new Promise((resolve) => setTimeout(resolve, this.loginPollIntervalMs));
|
|
473
|
+
}
|
|
474
|
+
this.loginPending.delete(providerId);
|
|
475
|
+
this.updateLoginPolling();
|
|
476
|
+
this.setStatus(`Still waiting for ${providerName} login...`);
|
|
477
|
+
return false;
|
|
478
|
+
}
|
|
400
479
|
async prefetchProviders() {
|
|
401
480
|
if (this.prefetching)
|
|
402
481
|
return;
|
|
@@ -533,6 +612,8 @@ export class AgentConnectConnect extends HTMLElement {
|
|
|
533
612
|
}
|
|
534
613
|
if (!provider.installed)
|
|
535
614
|
return 'Not installed';
|
|
615
|
+
if (this.loginPending.has(provider.id))
|
|
616
|
+
return 'Waiting for login';
|
|
536
617
|
if (!provider.loggedIn)
|
|
537
618
|
return 'Login needed';
|
|
538
619
|
if (isConnected)
|
|
@@ -559,6 +640,11 @@ export class AgentConnectConnect extends HTMLElement {
|
|
|
559
640
|
}
|
|
560
641
|
return button;
|
|
561
642
|
}
|
|
643
|
+
if (this.loginPending.has(provider.id)) {
|
|
644
|
+
const button = this.buildActionButton('Waiting for login...', false, () => this.checkProviderStatus(provider.id, provider.name));
|
|
645
|
+
button.title = `Click to check ${provider.name || provider.id} login status`;
|
|
646
|
+
return button;
|
|
647
|
+
}
|
|
562
648
|
if (!provider.loggedIn) {
|
|
563
649
|
const label = terminalLogin ? 'Run /login' : 'Login';
|
|
564
650
|
const button = this.buildActionButton(label, false, () => this.connectProvider(provider));
|
|
@@ -682,13 +768,27 @@ export class AgentConnectConnect extends HTMLElement {
|
|
|
682
768
|
needsLogin = !status.loggedIn;
|
|
683
769
|
}
|
|
684
770
|
if (needsLogin) {
|
|
771
|
+
if (!this.loginPending.has(provider.id)) {
|
|
772
|
+
this.loginPending.add(provider.id);
|
|
773
|
+
this.updateLoginPolling();
|
|
774
|
+
this.renderProviders();
|
|
775
|
+
this.updatePopoverTitle();
|
|
776
|
+
this.updateButtonLabel();
|
|
777
|
+
}
|
|
685
778
|
this.setBusy(true, `Waiting for ${providerName} login...`);
|
|
686
779
|
this.setProviderLoading(provider.id, true, 'Logging in...');
|
|
687
780
|
const loginOptions = provider.id === 'claude' && this.state.loginExperience
|
|
688
781
|
? { loginExperience: this.state.loginExperience }
|
|
689
782
|
: undefined;
|
|
690
783
|
const loggedIn = await client.providers.login(provider.id, loginOptions);
|
|
691
|
-
if (
|
|
784
|
+
if (loggedIn.loggedIn) {
|
|
785
|
+
this.loginPending.delete(provider.id);
|
|
786
|
+
this.updateLoginPolling();
|
|
787
|
+
}
|
|
788
|
+
else {
|
|
789
|
+
const updated = await this.waitForProviderLogin(provider.id, providerName);
|
|
790
|
+
if (updated)
|
|
791
|
+
return true;
|
|
692
792
|
this.setAlert({
|
|
693
793
|
type: 'error',
|
|
694
794
|
...ERROR_MESSAGES.login_incomplete,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agentconnect/ui",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"homepage": "https://github.com/rayzhudev/agent-connect",
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
"dev": "tsc --watch"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@agentconnect/sdk": "
|
|
32
|
+
"@agentconnect/sdk": "workspace:*"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
35
|
"typescript": "^5.6.2"
|