@cortexkit/opencode-anthropic-auth 2.1.2 → 2.2.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/dist/v2/tui.d.ts CHANGED
@@ -1,11 +1,19 @@
1
1
  import type { Plugin as Tui } from '@opencode/plugin/tui';
2
+ import type { SidebarState } from '../sidebar-state';
3
+ /**
4
+ * Claims the quota sidebar. `entry.mjs` passes the precompiled renderer, so
5
+ * this bundle stays free of JSX and of the OpenCode 1 TUI.
6
+ */
7
+ export type MountSidebar = (ctx: Tui.Context, read: (sessionID: string, signal: AbortSignal) => Promise<SidebarState>) => Promise<() => void>;
2
8
  /**
3
9
  * Shows the `claude` account menu in OpenCode 2 dialogs. The menu's sections,
4
10
  * items and actions come from the plugin server over NATIVE_MENU_RPC, built by
5
11
  * the same Core menu code that OpenCode 1 and Pi render, so every host shows
6
12
  * the same menu.
7
13
  */
8
- export declare function setupAnthropicTui(ctx: Tui.Context): Promise<() => void>;
14
+ export declare function setupAnthropicTui(ctx: Tui.Context, options?: {
15
+ readonly mountSidebar?: MountSidebar;
16
+ }): Promise<() => void>;
9
17
  declare const _default: {
10
18
  id: string;
11
19
  setup: typeof setupAnthropicTui;
package/dist/v2/tui.js CHANGED
@@ -1,2 +1,2 @@
1
- import{t as F}from"../index-jexctf5w.js";import"../index-f2ne65w4.js";async function V(B){let Y=B.client.rpc(F),K=!0,$=!1,L=new AbortController,O=()=>{let w=B.ui.router.current();return w.type==="session"?w.sessionID:void 0};function M(w){return new Promise((J)=>{let j="",G=!1,Q=B.keymap.mode.push("cortexkit-protected-entry"),H=(z,D=!0)=>{if(G)return;G=!0,B.renderer.keyInput.off("keypress",X),B.renderer.keyInput.off("paste",Z),L.signal.removeEventListener("abort",W),Q();let q=z?j:void 0;if(j="",D)B.ui.dialog.clear();J(q)},W=()=>H(!1),X=(z)=>{if(z.preventDefault(),z.stopPropagation(),z.name==="escape"||z.ctrl&&z.name==="c")return H(!1);if(z.name==="return"||z.name==="enter")return H(!0);if(z.name==="backspace"){j=Array.from(j).slice(0,-1).join("");return}if(!z.ctrl&&!z.meta&&!z.option&&Array.from(z.sequence).every((D)=>D.charCodeAt(0)>=32&&D.charCodeAt(0)!==127))j=(j+z.sequence).slice(0,4096)},Z=(z)=>{z.preventDefault(),z.stopPropagation(),j=(j+Array.from(new TextDecoder().decode(z.bytes)).filter((D)=>D.charCodeAt(0)>=32&&D.charCodeAt(0)!==127).join("")).slice(0,4096)};if(B.renderer.keyInput.prependListener("keypress",X),B.renderer.keyInput.prependListener("paste",Z),L.signal.addEventListener("abort",W,{once:!0}),B.ui.dialog.alert({title:w,message:"Type or paste the value. Input is hidden. Enter accepts; Escape cancels."}).then(()=>H(!1,!1),()=>H(!1,!1)),L.signal.aborted)W()})}async function P(w){let J={};for(let j of w.knobs){if(!K)return;if(j.kind==="choice"){let G=await B.ui.dialog.select({title:j.label,options:j.choices.map((Q)=>({title:Q.label,value:Q.value})),current:j.value});if(G===void 0)return;J[j.id]=G}else if(j.kind==="toggle"){let G=await B.ui.dialog.select({title:j.label,options:[{title:"On",value:!0},{title:"Off",value:!1}],current:j.value});if(G===void 0)return;J[j.id]=G}else{let G=j.kind==="text"&&j.masked?await M(j.label):await B.ui.dialog.prompt({title:j.label,value:j.value===void 0?void 0:String(j.value),placeholder:j.kind==="text"?j.placeholder:void 0});if(G===void 0)return;J[j.id]=G===""&&!j.required?null:j.kind==="number"?Number(G):G}}return J}async function C(w,J){if(!K||$||O()!==w)return;$=!0;let j=J;try{while(K&&O()===w){let G=await B.ui.dialog.select({title:j.menu.title,options:j.menu.sections.map((D)=>({title:D.title,description:D.lines.join(`
2
- `),value:D}))});if(!G||!K||O()!==w)return;let Q=[...G.actions.map((D)=>({action:D,itemId:void 0})),...G.items.flatMap((D)=>D.actions.map((q)=>({action:q,itemId:D.id})))],H=await B.ui.dialog.select({title:G.title,options:Q.map((D)=>({title:D.action.label,description:D.action.description,value:D}))});if(!H)continue;let W=await P(H.action);if(!W||!K||O()!==w)return;let X=H.action.confirm?await B.ui.dialog.confirm({title:H.action.label,message:H.action.confirm.message}):void 0;if(H.action.confirm&&X!==!0)continue;if(!K||O()!==w)return;let Z={command:"claude",sectionId:G.id,itemId:H.itemId,actionId:H.action.id,sessionId:w,values:W,confirmed:X},z=await Y.apply(Z,{signal:L.signal,location:B.location});if(!K||O()!==w)return;await B.ui.dialog.alert({title:z.ok?"Claude":"Claude action refused",message:z.text}),j={command:z.command,menu:z.menu}}}finally{$=!1}}let R=Y.events.on("opened",(w)=>C(w.data.sessionId,w.data.payload),{signal:L.signal}),U=Y.events.on("notification",(w)=>{if(K&&O()===w.data.sessionId)B.ui.toast.show({title:"Claude",sessionID:w.data.sessionId,message:w.data.message,variant:w.data.kind})},{signal:L.signal});return B.keymap.layer(()=>({commands:[{id:"cortexkit.claude",title:"Claude",group:"Claude",palette:!0,slash:{name:"claude"},async run(){let w=O();if(!w){await B.ui.dialog.alert({title:"Claude",message:"Open a session before using the Claude menu."});return}let J=await Y.open({sessionId:w},{signal:L.signal,location:B.location});await C(w,J)}}]})),()=>{K=!1,L.abort(),R(),U()}}var T={id:"cortexkit-anthropic-auth",setup:V};export{V as setupAnthropicTui,T as default};
1
+ import{t as P}from"../index-pden7a7y.js";import"../index-czyrqpxc.js";import"../index-f2ne65w4.js";async function T(D,R={}){let Y=D.client.rpc(P),L=!0,q=!1,O=new AbortController,Q=()=>{let z=D.ui.router.current();return z.type==="session"?z.sessionID:void 0};function U(z){return new Promise((K)=>{let j="",H=!1,W=D.keymap.mode.push("cortexkit-protected-entry"),J=(B,G=!0)=>{if(H)return;H=!0,D.renderer.keyInput.off("keypress",Z),D.renderer.keyInput.off("paste",$),O.signal.removeEventListener("abort",X),W();let C=B?j:void 0;if(j="",G)D.ui.dialog.clear();K(C)},X=()=>J(!1),Z=(B)=>{if(B.preventDefault(),B.stopPropagation(),B.name==="escape"||B.ctrl&&B.name==="c")return J(!1);if(B.name==="return"||B.name==="enter")return J(!0);if(B.name==="backspace"){j=Array.from(j).slice(0,-1).join("");return}if(!B.ctrl&&!B.meta&&!B.option&&Array.from(B.sequence).every((G)=>G.charCodeAt(0)>=32&&G.charCodeAt(0)!==127))j=(j+B.sequence).slice(0,4096)},$=(B)=>{B.preventDefault(),B.stopPropagation(),j=(j+Array.from(new TextDecoder().decode(B.bytes)).filter((G)=>G.charCodeAt(0)>=32&&G.charCodeAt(0)!==127).join("")).slice(0,4096)};if(D.renderer.keyInput.prependListener("keypress",Z),D.renderer.keyInput.prependListener("paste",$),O.signal.addEventListener("abort",X,{once:!0}),D.ui.dialog.alert({title:z,message:"Type or paste the value. Input is hidden. Enter accepts; Escape cancels."}).then(()=>J(!1,!1),()=>J(!1,!1)),O.signal.aborted)X()})}async function V(z){let K={};for(let j of z.knobs){if(!L)return;if(j.kind==="choice"){let H=await D.ui.dialog.select({title:j.label,options:j.choices.map((W)=>({title:W.label,value:W.value})),current:j.value});if(H===void 0)return;K[j.id]=H}else if(j.kind==="toggle"){let H=await D.ui.dialog.select({title:j.label,options:[{title:"On",value:!0},{title:"Off",value:!1}],current:j.value});if(H===void 0)return;K[j.id]=H}else{let H=j.kind==="text"&&j.masked?await U(j.label):await D.ui.dialog.prompt({title:j.label,value:j.value===void 0?void 0:String(j.value),placeholder:j.kind==="text"?j.placeholder:void 0});if(H===void 0)return;K[j.id]=H===""&&!j.required?null:j.kind==="number"?Number(H):H}}return K}async function F(z,K){if(!L||q||Q()!==z)return;q=!0;let j=K;try{while(L&&Q()===z){let H=await D.ui.dialog.select({title:j.menu.title,options:j.menu.sections.map((G)=>({title:G.title,description:G.lines.join(`
2
+ `),value:G}))});if(!H||!L||Q()!==z)return;let W=[...H.actions.map((G)=>({action:G,itemId:void 0})),...H.items.flatMap((G)=>G.actions.map((C)=>({action:C,itemId:G.id})))],J=await D.ui.dialog.select({title:H.title,options:W.map((G)=>({title:G.action.label,description:G.action.description,value:G}))});if(!J)continue;let X=await V(J.action);if(!X||!L||Q()!==z)return;let Z=J.action.confirm?await D.ui.dialog.confirm({title:J.action.label,message:J.action.confirm.message}):void 0;if(J.action.confirm&&Z!==!0)continue;if(!L||Q()!==z)return;let $={command:"claude",sectionId:H.id,itemId:J.itemId,actionId:J.action.id,sessionId:z,values:X,confirmed:Z},B=await Y.apply($,{signal:O.signal,location:D.location});if(!L||Q()!==z)return;await D.ui.dialog.alert({title:B.ok?"Claude":"Claude action refused",message:B.text}),j={command:B.command,menu:B.menu}}}finally{q=!1}}let w=Y.events.on("opened",(z)=>F(z.data.sessionId,z.data.payload),{signal:O.signal}),A=Y.events.on("notification",(z)=>{if(L&&Q()===z.data.sessionId)D.ui.toast.show({title:"Claude",sessionID:z.data.sessionId,message:z.data.message,variant:z.data.kind})},{signal:O.signal});D.keymap.layer(()=>({commands:[{id:"cortexkit.claude",title:"Claude",group:"Claude",palette:!0,slash:{name:"claude"},async run(){let z=Q();if(!z){await D.ui.dialog.alert({title:"Claude",message:"Open a session before using the Claude menu."});return}let K=await Y.open({sessionId:z},{signal:O.signal,location:D.location});await F(z,K)}}]}));let M;try{M=await R.mountSidebar?.(D,(z,K)=>Y.sidebar({sessionId:z},{signal:K,location:D.location}))}catch{}return()=>{L=!1,O.abort(),w(),A(),M?.()}}var E={id:"cortexkit-anthropic-auth",setup:T};export{T as setupAnthropicTui,E as default};
package/dist/v2/wire.d.ts CHANGED
@@ -17,6 +17,10 @@ export declare function createNativeWirePolicy(): {
17
17
  fastModeEnabled: boolean;
18
18
  thinkingPrefixMismatchBehavior: "account-default" | "drop_block" | "error" | undefined;
19
19
  midConversationEffortEnabled: boolean;
20
+ turnEndNoteEnabled: boolean;
21
+ turnEndNote: {
22
+ tools: string[];
23
+ } | undefined;
20
24
  serverSideFallbackEnabled: boolean;
21
25
  laneStart: boolean;
22
26
  billingLineage: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cortexkit/opencode-anthropic-auth",
3
- "version": "2.1.2",
3
+ "version": "2.2.0",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",
@@ -77,18 +77,18 @@
77
77
  },
78
78
  "dependencies": {
79
79
  "@clack/prompts": "^1.6.0",
80
- "@cortexkit/anthropic-auth-core": "2.1.2",
80
+ "@cortexkit/anthropic-auth-core": "2.2.0",
81
81
  "@cortexkit/claustrum-client": "0.12.0",
82
82
  "@cortexkit/private-files": "0.2.1",
83
83
  "@cortexkit/subc-client": "^0.22.0",
84
- "@opentui/core": "0.6.5",
85
- "@opentui/solid": "0.6.5",
84
+ "@opentui/core": "0.6.6",
85
+ "@opentui/solid": "0.6.6",
86
86
  "jsonc-parser": "^3.3.1",
87
87
  "solid-js": "1.9.12",
88
88
  "xxhash-wasm": "^1.1.0"
89
89
  },
90
90
  "devDependencies": {
91
91
  "@ai-sdk/anthropic": "4.0.77",
92
- "@opencode/plugin": "2.0.22"
92
+ "@opencode/plugin": "2.0.32"
93
93
  }
94
94
  }
@@ -888,7 +888,10 @@ export function formatPrimeCost(value: number): string {
888
888
  return value.toFixed(Math.min(6, Math.max(0, 4)))
889
889
  }
890
890
 
891
- export function formatPrimeAccountValue(account: PrimeSidebarAccountState): {
891
+ export function formatPrimeAccountValue(
892
+ account: PrimeSidebarAccountState,
893
+ now = Date.now(),
894
+ ): {
892
895
  text: string
893
896
  hasError: boolean
894
897
  } {
@@ -898,7 +901,7 @@ export function formatPrimeAccountValue(account: PrimeSidebarAccountState): {
898
901
  if (account.lastResult === 'skipped') {
899
902
  return { text: 'skip', hasError: false }
900
903
  }
901
- if (account.nextDueAt && account.nextDueAt > Date.now()) {
904
+ if (account.nextDueAt && account.nextDueAt > now) {
902
905
  return { text: formatPrimeTime(account.nextDueAt), hasError: false }
903
906
  }
904
907
  if (account.lastPrimedAt) {
@@ -994,7 +997,9 @@ export function getCollapsedAccounts(
994
997
  state: SidebarState,
995
998
  showFallbacks = true,
996
999
  ) {
997
- const activeId = resolveActiveAccount(state).id
1000
+ // Before any request no account is active; do not mark main as serving.
1001
+ const activeId =
1002
+ state.activeId === undefined ? undefined : resolveActiveAccount(state).id
998
1003
  return [
999
1004
  {
1000
1005
  id: 'main',