@cortexkit/opencode-openai-auth 1.22.0 → 1.23.1

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.
Files changed (43) hide show
  1. package/dist/bin.js +8 -8
  2. package/dist/index-0p8r7cpy.js +60 -0
  3. package/dist/{index-8bt81cys.js → index-3ya2s179.js} +2 -2
  4. package/dist/{index-6afhs2jq.js → index-49ncs7dr.js} +2 -2
  5. package/dist/{index-b3bgqy7r.js → index-4ktepxn1.js} +2 -2
  6. package/dist/index-7hy72nfy.js +79 -0
  7. package/dist/{index-67twdyyz.js → index-bd18sfjj.js} +11 -11
  8. package/dist/{index-0wh22s62.js → index-d0g5g290.js} +1 -1
  9. package/dist/{index-1k8a281v.js → index-drm4dk5y.js} +2 -2
  10. package/dist/{index-mepr345k.js → index-j700j6at.js} +1 -1
  11. package/dist/{index-677jqrrt.js → index-p81hxfe6.js} +1 -1
  12. package/dist/{index-xbhtpa9s.js → index-px1t650b.js} +2 -2
  13. package/dist/{index-9tg5xx9a.js → index-q2czrasr.js} +1 -1
  14. package/dist/{index-vaf4mqd1.js → index-td4g5dc9.js} +2 -2
  15. package/dist/{index-w6kars9d.js → index-wjp3q15r.js} +1 -1
  16. package/dist/index.d.ts +2 -2
  17. package/dist/index.js +1 -1
  18. package/dist/openai-auth.schema.json +274 -27
  19. package/dist/rpc/port-file.js +1 -1
  20. package/dist/rpc/protocol.js +1 -1
  21. package/dist/rpc/rpc-client.js +1 -1
  22. package/dist/rpc/rpc-dir.js +1 -1
  23. package/dist/{runtime-layout-DdxprfY1.d.ts → runtime-layout-B07ApQZL.d.ts} +1 -1
  24. package/dist/sidebar-state.js +1 -1
  25. package/dist/{token-92yc9q7w.js → token-hczqrmmz.js} +1 -1
  26. package/dist/token-util-9t4ma4jz.js +1 -0
  27. package/dist/tui-preferences.js +1 -1
  28. package/dist/v2/server.d.ts +7 -6
  29. package/dist/v2/server.js +4 -4
  30. package/package.json +6 -6
  31. package/src/tui-compiled/raw/shared/58bc35a3cd459085-define.js +10 -1
  32. package/src/tui-compiled/raw/shared/87f6e22d4fc34918-resolve.js +10 -5
  33. package/src/tui-compiled/raw/shared/bfbdd0f9aae56b47-pool-quota.js +10 -0
  34. package/src/tui-compiled/raw/shared/dbc61cd405941828-accounts.js +1 -1
  35. package/src/tui-compiled/raw/shared/fe02abeadc535f77-rows.js +8 -3
  36. package/src/tui-compiled/runtime/shared/58bc35a3cd459085-define.js +10 -1
  37. package/src/tui-compiled/runtime/shared/87f6e22d4fc34918-resolve.js +10 -5
  38. package/src/tui-compiled/runtime/shared/bfbdd0f9aae56b47-pool-quota.js +10 -0
  39. package/src/tui-compiled/runtime/shared/dbc61cd405941828-accounts.js +1 -1
  40. package/src/tui-compiled/runtime/shared/fe02abeadc535f77-rows.js +8 -3
  41. package/dist/index-dw1nh7dk.js +0 -60
  42. package/dist/index-ney54jhs.js +0 -79
  43. package/dist/token-util-g8e70a6j.js +0 -1
@@ -363,47 +363,256 @@
363
363
  }
364
364
  },
365
365
  "cache_keep_enabled": {
366
- "type": "boolean"
366
+ "anyOf": [
367
+ {
368
+ "type": "boolean"
369
+ },
370
+ {
371
+ "type": "object",
372
+ "properties": {
373
+ "default": {
374
+ "type": "boolean"
375
+ },
376
+ "opencode": {
377
+ "type": "boolean"
378
+ },
379
+ "pi": {
380
+ "type": "boolean"
381
+ }
382
+ },
383
+ "additionalProperties": false
384
+ }
385
+ ]
367
386
  },
368
387
  "cache_keep_subagents": {
369
- "type": "boolean"
388
+ "anyOf": [
389
+ {
390
+ "type": "boolean"
391
+ },
392
+ {
393
+ "type": "object",
394
+ "properties": {
395
+ "default": {
396
+ "type": "boolean"
397
+ },
398
+ "opencode": {
399
+ "type": "boolean"
400
+ },
401
+ "pi": {
402
+ "type": "boolean"
403
+ }
404
+ },
405
+ "additionalProperties": false
406
+ }
407
+ ]
370
408
  },
371
409
  "cache_keep_sustain": {
372
- "type": "boolean"
410
+ "anyOf": [
411
+ {
412
+ "type": "boolean"
413
+ },
414
+ {
415
+ "type": "object",
416
+ "properties": {
417
+ "default": {
418
+ "type": "boolean"
419
+ },
420
+ "opencode": {
421
+ "type": "boolean"
422
+ },
423
+ "pi": {
424
+ "type": "boolean"
425
+ }
426
+ },
427
+ "additionalProperties": false
428
+ }
429
+ ]
373
430
  },
374
431
  "cache_keep_window": {
375
- "type": "array",
376
- "items": {
377
- "type": "object",
378
- "properties": {
379
- "start_hour": {
380
- "type": "integer",
381
- "minimum": 0,
382
- "maximum": 23
383
- },
384
- "end_hour": {
385
- "type": "integer",
386
- "minimum": 0,
387
- "maximum": 23
432
+ "anyOf": [
433
+ {
434
+ "type": "array",
435
+ "items": {
436
+ "type": "object",
437
+ "properties": {
438
+ "start_hour": {
439
+ "type": "integer",
440
+ "minimum": 0,
441
+ "maximum": 23
442
+ },
443
+ "end_hour": {
444
+ "type": "integer",
445
+ "minimum": 0,
446
+ "maximum": 23
447
+ }
448
+ },
449
+ "additionalProperties": false,
450
+ "required": ["start_hour", "end_hour"]
388
451
  }
389
452
  },
390
- "additionalProperties": false,
391
- "required": ["start_hour", "end_hour"]
392
- }
453
+ {
454
+ "type": "object",
455
+ "properties": {
456
+ "default": {
457
+ "type": "array",
458
+ "items": {
459
+ "type": "object",
460
+ "properties": {
461
+ "start_hour": {
462
+ "type": "integer",
463
+ "minimum": 0,
464
+ "maximum": 23
465
+ },
466
+ "end_hour": {
467
+ "type": "integer",
468
+ "minimum": 0,
469
+ "maximum": 23
470
+ }
471
+ },
472
+ "additionalProperties": false,
473
+ "required": ["start_hour", "end_hour"]
474
+ }
475
+ },
476
+ "opencode": {
477
+ "type": "array",
478
+ "items": {
479
+ "type": "object",
480
+ "properties": {
481
+ "start_hour": {
482
+ "type": "integer",
483
+ "minimum": 0,
484
+ "maximum": 23
485
+ },
486
+ "end_hour": {
487
+ "type": "integer",
488
+ "minimum": 0,
489
+ "maximum": 23
490
+ }
491
+ },
492
+ "additionalProperties": false,
493
+ "required": ["start_hour", "end_hour"]
494
+ }
495
+ },
496
+ "pi": {
497
+ "type": "array",
498
+ "items": {
499
+ "type": "object",
500
+ "properties": {
501
+ "start_hour": {
502
+ "type": "integer",
503
+ "minimum": 0,
504
+ "maximum": 23
505
+ },
506
+ "end_hour": {
507
+ "type": "integer",
508
+ "minimum": 0,
509
+ "maximum": 23
510
+ }
511
+ },
512
+ "additionalProperties": false,
513
+ "required": ["start_hour", "end_hour"]
514
+ }
515
+ }
516
+ },
517
+ "additionalProperties": false
518
+ }
519
+ ]
393
520
  },
394
521
  "log_level": {
395
- "enum": ["error", "warn", "info", "debug", "trace", "default"]
522
+ "anyOf": [
523
+ {
524
+ "enum": ["error", "warn", "info", "debug", "trace", "default"]
525
+ },
526
+ {
527
+ "type": "object",
528
+ "properties": {
529
+ "default": {
530
+ "enum": ["error", "warn", "info", "debug", "trace", "default"]
531
+ },
532
+ "opencode": {
533
+ "enum": ["error", "warn", "info", "debug", "trace", "default"]
534
+ },
535
+ "pi": {
536
+ "enum": ["error", "warn", "info", "debug", "trace", "default"]
537
+ }
538
+ },
539
+ "additionalProperties": false
540
+ }
541
+ ]
396
542
  },
397
543
  "request_dumps": {
398
- "type": "boolean"
544
+ "anyOf": [
545
+ {
546
+ "type": "boolean"
547
+ },
548
+ {
549
+ "type": "object",
550
+ "properties": {
551
+ "default": {
552
+ "type": "boolean"
553
+ },
554
+ "opencode": {
555
+ "type": "boolean"
556
+ },
557
+ "pi": {
558
+ "type": "boolean"
559
+ }
560
+ },
561
+ "additionalProperties": false
562
+ }
563
+ ]
399
564
  },
400
565
  "dump_dir": {
401
- "type": "string"
566
+ "anyOf": [
567
+ {
568
+ "type": "string"
569
+ },
570
+ {
571
+ "type": "object",
572
+ "properties": {
573
+ "default": {
574
+ "type": "string"
575
+ },
576
+ "opencode": {
577
+ "type": "string"
578
+ },
579
+ "pi": {
580
+ "type": "string"
581
+ }
582
+ },
583
+ "additionalProperties": false
584
+ }
585
+ ]
402
586
  },
403
587
  "dump_max_bytes": {
404
- "type": "integer",
405
- "minimum": 0,
406
- "maximum": 9007199254740991
588
+ "anyOf": [
589
+ {
590
+ "type": "integer",
591
+ "minimum": 0,
592
+ "maximum": 9007199254740991
593
+ },
594
+ {
595
+ "type": "object",
596
+ "properties": {
597
+ "default": {
598
+ "type": "integer",
599
+ "minimum": 0,
600
+ "maximum": 9007199254740991
601
+ },
602
+ "opencode": {
603
+ "type": "integer",
604
+ "minimum": 0,
605
+ "maximum": 9007199254740991
606
+ },
607
+ "pi": {
608
+ "type": "integer",
609
+ "minimum": 0,
610
+ "maximum": 9007199254740991
611
+ }
612
+ },
613
+ "additionalProperties": false
614
+ }
615
+ ]
407
616
  },
408
617
  "web_sockets": {
409
618
  "type": "boolean"
@@ -412,10 +621,48 @@
412
621
  "type": "boolean"
413
622
  },
414
623
  "responses_lite": {
415
- "type": "boolean"
624
+ "anyOf": [
625
+ {
626
+ "type": "boolean"
627
+ },
628
+ {
629
+ "type": "object",
630
+ "properties": {
631
+ "default": {
632
+ "type": "boolean"
633
+ },
634
+ "opencode": {
635
+ "type": "boolean"
636
+ },
637
+ "pi": {
638
+ "type": "boolean"
639
+ }
640
+ },
641
+ "additionalProperties": false
642
+ }
643
+ ]
416
644
  },
417
645
  "codex_api_endpoint": {
418
- "type": "string"
646
+ "anyOf": [
647
+ {
648
+ "type": "string"
649
+ },
650
+ {
651
+ "type": "object",
652
+ "properties": {
653
+ "default": {
654
+ "type": "string"
655
+ },
656
+ "opencode": {
657
+ "type": "string"
658
+ },
659
+ "pi": {
660
+ "type": "string"
661
+ }
662
+ },
663
+ "additionalProperties": false
664
+ }
665
+ ]
419
666
  }
420
667
  },
421
668
  "additionalProperties": false
@@ -1 +1 @@
1
- import{Tg as b,Ug as c}from"../index-8bt81cys.js";import{Zg as a}from"../index-1k8a281v.js";import"../index-b3bgqy7r.js";import"../index-mepr345k.js";import"../index-9tg5xx9a.js";export{b as writePortFile,c as isOpenaiRpcStateDir,a as discoverPortFile};
1
+ import{Xg as b,Yg as c}from"../index-3ya2s179.js";import{bh as a}from"../index-drm4dk5y.js";import"../index-4ktepxn1.js";import"../index-j700j6at.js";import"../index-q2czrasr.js";export{b as writePortFile,c as isOpenaiRpcStateDir,a as discoverPortFile};
@@ -1 +1 @@
1
- import{ih as b}from"../index-w6kars9d.js";import"../index-vaf4mqd1.js";import"../index-b3bgqy7r.js";import"../index-9tg5xx9a.js";export{b as isNotifyPayload};
1
+ import{mh as b}from"../index-wjp3q15r.js";import"../index-td4g5dc9.js";import"../index-4ktepxn1.js";import"../index-q2czrasr.js";export{b as isNotifyPayload};
@@ -1 +1 @@
1
- import{$g as f,_g as F}from"../index-1k8a281v.js";import"../index-b3bgqy7r.js";import"../index-9tg5xx9a.js";function y(r,s,v){return f(r,s,v)}export{y as createRpcClient,F as DEFAULT_RPC_TIMEOUT_MS};
1
+ import{ch as F,dh as f}from"../index-drm4dk5y.js";import"../index-4ktepxn1.js";import"../index-q2czrasr.js";function y(r,s,v){return f(r,s,v)}export{y as createRpcClient,F as DEFAULT_RPC_TIMEOUT_MS};
@@ -1 +1 @@
1
- import{Ch as a,Dh as b,Eh as c,Fh as d}from"../index-mepr345k.js";import"../index-9tg5xx9a.js";export{a as tmpdir,d as resolveRpcDir,c as getRpcDir,b as RPC_DIRECTORY_PREFIX};
1
+ import{Gh as a,Hh as b,Ih as c,Jh as d}from"../index-j700j6at.js";import"../index-q2czrasr.js";export{a as tmpdir,d as resolveRpcDir,c as getRpcDir,b as RPC_DIRECTORY_PREFIX};
@@ -421,7 +421,7 @@ type AccountStorage = {
421
421
  declare function loadAccounts(paths: AccountPaths): Promise<AccountStorage | null>;
422
422
  type TimerHandle = ReturnType<typeof setInterval>;
423
423
  interface BackgroundQuotaRefreshOptions {
424
- setIntervalFn?: (callback: () => void, intervalMs: number) => TimerHandle;
424
+ setIntervalFn?: (callback: () => void | Promise<void>, intervalMs: number) => TimerHandle;
425
425
  clearIntervalFn?: (timer: TimerHandle) => void;
426
426
  random?: () => number;
427
427
  onError?: (error: unknown) => void;
@@ -1 +1 @@
1
- import{$d as S,Ad as r,Bd as s,Cd as t,Dd as u,Ed as v,Fd as w,Gd as x,Hd as y,Id as z,Jd as A,Kd as B,Ld as C,Md as D,Nd as E,Od as F,Pd as G,Qd as H,Rd as I,Sd as J,Td as K,Ud as L,Vd as M,Wd as N,Xd as O,Yd as P,Zd as Q,_d as R,ae as T,jd as a,kd as b,ld as c,md as d,nd as e,od as f,pd as g,qd as h,rd as i,sd as j,td as k,ud as l,vd as m,wd as n,xd as o,yd as p,zd as q}from"./index-xbhtpa9s.js";import"./index-67twdyyz.js";import"./index-6afhs2jq.js";import"./index-w6kars9d.js";import"./index-vaf4mqd1.js";import"./index-b3bgqy7r.js";import"./index-9tg5xx9a.js";export{y as upsertSidebarActiveRouting,p as spendControlExhaustedResetAt,O as sidebarQuotaProjection,I as settleWithinBudget,w as setSidebarState,x as setSidebarMachineState,z as setSidebarLegacyRouting,e as setLegacySidebarStateFileForTest,C as resolveSidebarStickyAssignment,s as resolveSessionStickyAccount,t as resolveSessionSidebarRouting,N as resolveActiveAccount,A as removeSidebarActiveRouting,K as rememberStickyPin,v as pruneStickyAssignments,u as pruneActiveRouting,D as planSidebarStickyAssignmentFromSnapshot,B as planSidebarStickyAssignment,E as persistSidebarStickyAssignment,k as normalizeSidebarState,o as isUsableRoutingEntry,r as isQuotaExhausted,h as hashSidebarSessionId,i as getSidebarStateFile,l as getSidebarState,d as getPresentQuotaWindows,P as getCollapsedQuotaSummary,Q as getCollapsedAccountLines,c as formatWindowLabel,S as fitCollapsedLabel,q as exhaustedQuotaResetAt,G as drainSidebarWrites,R as displayWidth,J as createSidebarStateCache,M as createSidebarBookkeepingQueue,T as computeQuotaPacing,F as clearSidebarStickyAssignment,L as applyStickyPinOverlay,b as accountServesOnCredits,a as accountCreditsText,g as STICKY_ASSIGNMENT_MAX_ENTRIES,f as STICKY_ASSIGNMENT_MAX_AGE_MS,H as HOT_PATH_READ_BUDGET_MS,j as DEFAULT_SIDEBAR_STATE,n as ACTIVE_ROUTING_MAX_ENTRIES,m as ACTIVE_ROUTING_MAX_AGE_MS};
1
+ import{$d as Q,Ad as p,Bd as q,Cd as r,Dd as s,Ed as t,Fd as u,Gd as v,Hd as w,Id as x,Jd as y,Kd as z,Ld as A,Md as B,Nd as C,Od as D,Pd as E,Qd as F,Rd as G,Sd as H,Td as I,Ud as J,Vd as K,Wd as L,Xd as M,Yd as N,Zd as O,_d as P,ae as R,be as S,ce as T,ld as a,md as b,nd as c,od as d,pd as e,qd as f,rd as g,sd as h,td as i,ud as j,vd as k,wd as l,xd as m,yd as n,zd as o}from"./index-px1t650b.js";import"./index-bd18sfjj.js";import"./index-49ncs7dr.js";import"./index-wjp3q15r.js";import"./index-td4g5dc9.js";import"./index-4ktepxn1.js";import"./index-q2czrasr.js";export{y as upsertSidebarActiveRouting,p as spendControlExhaustedResetAt,O as sidebarQuotaProjection,I as settleWithinBudget,w as setSidebarState,x as setSidebarMachineState,z as setSidebarLegacyRouting,e as setLegacySidebarStateFileForTest,C as resolveSidebarStickyAssignment,s as resolveSessionStickyAccount,t as resolveSessionSidebarRouting,N as resolveActiveAccount,A as removeSidebarActiveRouting,K as rememberStickyPin,v as pruneStickyAssignments,u as pruneActiveRouting,D as planSidebarStickyAssignmentFromSnapshot,B as planSidebarStickyAssignment,E as persistSidebarStickyAssignment,k as normalizeSidebarState,o as isUsableRoutingEntry,r as isQuotaExhausted,h as hashSidebarSessionId,i as getSidebarStateFile,l as getSidebarState,d as getPresentQuotaWindows,P as getCollapsedQuotaSummary,Q as getCollapsedAccountLines,c as formatWindowLabel,S as fitCollapsedLabel,q as exhaustedQuotaResetAt,G as drainSidebarWrites,R as displayWidth,J as createSidebarStateCache,M as createSidebarBookkeepingQueue,T as computeQuotaPacing,F as clearSidebarStickyAssignment,L as applyStickyPinOverlay,b as accountServesOnCredits,a as accountCreditsText,g as STICKY_ASSIGNMENT_MAX_ENTRIES,f as STICKY_ASSIGNMENT_MAX_AGE_MS,H as HOT_PATH_READ_BUDGET_MS,j as DEFAULT_SIDEBAR_STATE,n as ACTIVE_ROUTING_MAX_ENTRIES,m as ACTIVE_ROUTING_MAX_AGE_MS};
@@ -1 +1 @@
1
- import{a as U,b as V}from"./index-0wh22s62.js";import{Gh as R}from"./index-9tg5xx9a.js";var E=R((M,Q)=>{var{defineProperty:H,getOwnPropertyDescriptor:W,getOwnPropertyNames:X}=Object,Y=Object.prototype.hasOwnProperty,Z=(z,q)=>{for(var B in q)H(z,B,{get:q[B],enumerable:!0})},$=(z,q,B,F)=>{if(q&&typeof q==="object"||typeof q==="function"){for(let v of X(q))if(!Y.call(z,v)&&v!==B)H(z,v,{get:()=>q[v],enumerable:!(F=W(q,v))||F.enumerable})}return z},A=(z)=>$(H({},"__esModule",{value:!0}),z),L={};Z(L,{refreshToken:()=>D});Q.exports=A(L);var K=U(),G=V();async function D(z){let q=z?.project,B=z?.team;if(!q&&!B){let v=(0,G.findProjectInfo)();q=v.projectId,B=v.teamId}else if(!q||!B){let v=(0,G.findProjectInfo)();q=q??v.projectId,B=B??v.teamId}if(!q)throw new K.VercelOidcTokenError("Failed to refresh OIDC token: No project specified. Try re-linking your project with `vc link`");let F=(0,G.loadToken)(q);if(!F||(0,G.isExpired)((0,G.getTokenPayload)(F.token),z?.expirationBufferMs)){let v=await(0,G.getVercelToken)({expirationBufferMs:z?.expirationBufferMs});if(F=await(0,G.getVercelOidcToken)(v,q,B),!F)throw new K.VercelOidcTokenError("Failed to refresh OIDC token");(0,G.saveToken)(F,q)}process.env.VERCEL_OIDC_TOKEN=F.token;return}});export default E();
1
+ import{a as U,b as V}from"./index-d0g5g290.js";import{Kh as R}from"./index-q2czrasr.js";var E=R((M,Q)=>{var{defineProperty:H,getOwnPropertyDescriptor:W,getOwnPropertyNames:X}=Object,Y=Object.prototype.hasOwnProperty,Z=(z,q)=>{for(var B in q)H(z,B,{get:q[B],enumerable:!0})},$=(z,q,B,F)=>{if(q&&typeof q==="object"||typeof q==="function"){for(let v of X(q))if(!Y.call(z,v)&&v!==B)H(z,v,{get:()=>q[v],enumerable:!(F=W(q,v))||F.enumerable})}return z},A=(z)=>$(H({},"__esModule",{value:!0}),z),L={};Z(L,{refreshToken:()=>D});Q.exports=A(L);var K=U(),G=V();async function D(z){let q=z?.project,B=z?.team;if(!q&&!B){let v=(0,G.findProjectInfo)();q=v.projectId,B=v.teamId}else if(!q||!B){let v=(0,G.findProjectInfo)();q=q??v.projectId,B=B??v.teamId}if(!q)throw new K.VercelOidcTokenError("Failed to refresh OIDC token: No project specified. Try re-linking your project with `vc link`");let F=(0,G.loadToken)(q);if(!F||(0,G.isExpired)((0,G.getTokenPayload)(F.token),z?.expirationBufferMs)){let v=await(0,G.getVercelToken)({expirationBufferMs:z?.expirationBufferMs});if(F=await(0,G.getVercelOidcToken)(v,q,B),!F)throw new K.VercelOidcTokenError("Failed to refresh OIDC token");(0,G.saveToken)(F,q)}process.env.VERCEL_OIDC_TOKEN=F.token;return}});export default E();
@@ -0,0 +1 @@
1
+ import{b as a}from"./index-d0g5g290.js";import"./index-q2czrasr.js";export default a();
@@ -1,4 +1,4 @@
1
- import{Ag as _,Ig as R,Kg as I,Lg as x}from"./index-6afhs2jq.js";import"./index-vaf4mqd1.js";import{qh as N,rh as L,xh as j}from"./index-b3bgqy7r.js";import"./index-9tg5xx9a.js";import{mkdir as T,writeFile as h}from"node:fs/promises";import{homedir as y}from"node:os";import{dirname as f,join as C}from"node:path";import{applyEdits as g,modify as k,parse as b}from"jsonc-parser";function E(z){return z!==null&&typeof z==="object"&&!Array.isArray(z)}async function S(z){try{let q=[],H=b(await j(z,N),q,{allowTrailingComma:!0});return q.length===0&&E(H)?H:{}}catch(q){if(q instanceof L&&q.code!=="ENOENT")throw q;return{}}}var w=`// Shared preferences for TUI plugins.
1
+ import{Eg as _,Mg as R,Og as I,Pg as x}from"./index-49ncs7dr.js";import"./index-td4g5dc9.js";import{Bh as j,uh as N,vh as L}from"./index-4ktepxn1.js";import"./index-q2czrasr.js";import{mkdir as T,writeFile as h}from"node:fs/promises";import{homedir as y}from"node:os";import{dirname as f,join as C}from"node:path";import{applyEdits as g,modify as k,parse as b}from"jsonc-parser";function E(z){return z!==null&&typeof z==="object"&&!Array.isArray(z)}async function S(z){try{let q=[],H=b(await j(z,N),q,{allowTrailingComma:!0});return q.length===0&&E(H)?H:{}}catch(q){if(q instanceof L&&q.code!=="ENOENT")throw q;return{}}}var w=`// Shared preferences for TUI plugins.
2
2
  // Plugins update individual keys in place and preserve comments.
3
3
  {}
4
4
  `;function A(z){let{file:q,pluginKey:H,beforeCommit:Q}=z,X={...I.preferences,timeoutMs:z.timeoutMs??I.preferences.timeoutMs},$=Promise.resolve();async function V(J,D){await R(q,X,async(U)=>{let B;try{B=await j(q,N)}catch(M){if(M.code!=="ENOENT")throw M;B=""}if(B.trim()==="")B=w;let W=g(B,k(B,[H,...J],D,{formattingOptions:{insertSpaces:!0,tabSize:2}}));await _(q,W,{serialize:(M)=>String(M),beforeRename:async()=>{await Q?.(),await U.assertOwned()}})})}return{queueTuiPreferenceUpdate(J,D){let U=[...J],B=structuredClone(D),W=$.then(()=>V(U,B));return $=W.catch(()=>{}),W}}}var p="OPENCODE_TUI_PREFERENCES_FILE",c="tui-preferences.jsonc";function K(){let z=process.env[p];if(z)return z;let q=process.env.OPENCODE_CONFIG_DIR||C(process.env.XDG_CONFIG_HOME||C(y(),".config"),"opencode");return C(q,c)}function Y(z){return typeof z==="object"&&z!==null&&!Array.isArray(z)}function Jq(){return S(K())}var v="openai-auth",d=160,m={forceToTop:!1,order:d,startCollapsed:!1,rememberCollapsed:!0,collapsed:null,pollMs:1500,refreshDebounceMs:200,header:{label:"OPENAI",showVersion:!0},sections:{quota:!0,fallbackAccounts:!0,routing:!0,health:!0,pacing:!0},appearance:{barWidth:10,barFilledChar:"█",barEmptyChar:"░",warnThreshold:50,errorThreshold:80}};function Z(z,q){return typeof z==="boolean"?z:q}function G(z,q,H,Q){if(typeof z!=="number"||!Number.isFinite(z))return q;return Math.min(Math.max(Math.round(z),H),Q)}function u(z,q,H){if(typeof z!=="string"||z.length===0)return q;return z.slice(0,H)}function P(z,q){if(typeof z!=="string")return q;return[...z][0]??q}function Yq(z){let q=z[v];if(!Y(q))return structuredClone(m);let H=m,Q=Y(q.header)?q.header:{},X=Y(q.sections)?q.sections:{},$=Y(q.appearance)?q.appearance:{},V=G($.warnThreshold,H.appearance.warnThreshold,0,99),J=Math.max(G($.errorThreshold,H.appearance.errorThreshold,0,100),Math.min(V+1,100));return{forceToTop:Z(q.forceToTop,H.forceToTop),order:G(q.order,H.order,-1e4,1e4),startCollapsed:Z(q.startCollapsed,H.startCollapsed),rememberCollapsed:Z(q.rememberCollapsed,H.rememberCollapsed),collapsed:typeof q.collapsed==="boolean"?q.collapsed:null,pollMs:G(q.pollMs,H.pollMs,500,30000),refreshDebounceMs:G(q.refreshDebounceMs,H.refreshDebounceMs,50,5000),header:{label:u(Q.label,H.header.label,20),showVersion:Z(Q.showVersion,H.header.showVersion)},sections:{quota:Z(X.quota,H.sections.quota),fallbackAccounts:Z(X.fallbackAccounts,H.sections.fallbackAccounts),routing:Z(X.routing,H.sections.routing),health:Z(X.health,H.sections.health),pacing:Z(X.pacing,H.sections.pacing)},appearance:{barWidth:G($.barWidth,H.appearance.barWidth,4,40),barFilledChar:P($.barFilledChar,H.appearance.barFilledChar),barEmptyChar:P($.barEmptyChar,H.appearance.barEmptyChar),warnThreshold:V,errorThreshold:J}}}var s=-1e5;function Vq(z,q,H){let Q=z[q];if(!Y(Q))return H;if(Q.forceToTop===!0)return s+Object.keys(z).indexOf(q);return G(Q.order,H,-1e4,1e4)}var n=`// Shared preferences for opencode TUI plugins.
@@ -1,4 +1,4 @@
1
- import { C as AccountPaths, a as BeginAccountLoginOptions, g as OpenAiVaultOptions, m as CodexSessionMetadata, n as PoolLifecycleDeps, o as BeginAccountLoginResult, p as CodexRequestRuntime, r as HostSlotAdapter, t as RuntimeLayoutOptions } from "../runtime-layout-DdxprfY1.js";
1
+ import { C as AccountPaths, _ as BackgroundQuotaRefresh, a as BeginAccountLoginOptions, g as OpenAiVaultOptions, m as CodexSessionMetadata, n as PoolLifecycleDeps, o as BeginAccountLoginResult, p as CodexRequestRuntime, r as HostSlotAdapter, t as RuntimeLayoutOptions } from "../runtime-layout-B07ApQZL.js";
2
2
  import { i as OpenDialogPayload, n as ApplyResult } from "../protocol-BZZtDn5h.js";
3
3
  import { Plugin } from "@opencode/plugin";
4
4
  import "@opencode/plugin/promise/integration";
@@ -20,9 +20,8 @@ interface FrameTurnRecord extends FrameTurn {
20
20
  /**
21
21
  * The frame turn of each session.
22
22
  *
23
- * Call `advance` once for every `response.create` frame sent, with the
24
- * host's frame body, and `completed` when that frame's `response.completed`
25
- * arrives. The rule:
23
+ * Call `advance` with the unshaped first send for an attempt (full or
24
+ * chained). Call `completed` when that send or its retry succeeds. The rule:
26
25
  *
27
26
  * - A chained frame (one with `previous_response_id`) starts a new turn
28
27
  * exactly when its `input` holds a user message. The host's deltas carry
@@ -53,8 +52,8 @@ declare class FrameTurnState {
53
52
  * that each bring their own clock.
54
53
  */
55
54
  advance(sessionID: string, frame: Record<string, unknown>, runtime?: CodexRequestRuntime | undefined): FrameTurn;
56
- /** Records that the session's last frame got `response.completed`. */
57
- completed(sessionID: string): void;
55
+ /** Complete a send without marking a newer send, even within the same turn. */
56
+ completed(sessionID: string, expected?: FrameTurnRecord): void;
58
57
  get(sessionID: string): FrameTurnRecord | undefined;
59
58
  /** Drops a deleted host session; its next frame starts a new turn. */
60
59
  forget(sessionID: string): void;
@@ -189,6 +188,8 @@ interface OpenAIAuthV2Options {
189
188
  cacheKeep?: Pick<CacheKeepManagerSetup, 'setIntervalImpl' | 'clearIntervalImpl' | 'joinTimeoutMs'>;
190
189
  /** The account config and state files; read on every use. */
191
190
  paths?: () => AccountPaths;
191
+ /** Test seam for the idle pool refresh timer. */
192
+ backgroundQuota?: ConstructorParameters<typeof BackgroundQuotaRefresh>[0];
192
193
  /** OpenCode 1's login slot the migration reads; its `auth.json` by default. */
193
194
  slot?: HostSlotAdapter;
194
195
  /** This build's version, for the heartbeat and the version fence. */