dsh-opencode-go 0.1.12 → 0.1.13

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/lib/client.js CHANGED
@@ -90,9 +90,27 @@ function parseGoModelCatalog(value) {
90
90
  return {
91
91
  models: parseGoModels(catalog.models),
92
92
  stale: catalog.stale,
93
- ...catalog.error === void 0 ? {} : { error: catalog.error }
93
+ ...catalog.error === void 0 ? {} : { error: catalog.error },
94
+ ...catalog.sources === void 0 ? {} : { sources: parseSources(catalog.sources) }
94
95
  };
95
96
  }
97
+ function parseSources(value) {
98
+ if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error("Invalid OpenCode Go catalog sources");
99
+ const sources = value;
100
+ const parse = (value2) => {
101
+ if (!value2 || typeof value2 !== "object" || Array.isArray(value2)) throw new Error("Invalid OpenCode Go catalog source status");
102
+ const source = value2;
103
+ if (source.updatedAt !== void 0 && (typeof source.updatedAt !== "number" || !Number.isSafeInteger(source.updatedAt) || source.updatedAt < 0 || source.updatedAt > 864e13)) {
104
+ throw new Error("Invalid OpenCode Go catalog source timestamp");
105
+ }
106
+ if (source.error !== void 0 && typeof source.error !== "string") throw new Error("Invalid OpenCode Go catalog source error");
107
+ return {
108
+ ...source.updatedAt === void 0 ? {} : { updatedAt: source.updatedAt },
109
+ ...source.error === void 0 ? {} : { error: source.error }
110
+ };
111
+ };
112
+ return { listing: parse(sources.listing), metadata: parse(sources.metadata) };
113
+ }
96
114
  var codec = {
97
115
  mode: "strict",
98
116
  typeSymbol: "dsh-opencode-go#GoModelCatalog",
@@ -112,16 +130,16 @@ var modelsRemote = {
112
130
  }]
113
131
  };
114
132
 
115
- // plugin-css:/Users/tanglei/Desktop/dsh-opencode-go/src/client/Section.module.css
133
+ // plugin-css:/private/var/folders/4z/q9yrksqd0y12spqrxkv0p_dm0000gn/T/dsh-release-0.1.13-Tf3MEL/source/src/client/Section.module.css
116
134
  var id = "dsh-opencode-go/Section.module.css";
117
135
  if (!document.querySelector("style[data-plugin-css=" + JSON.stringify(id) + "]")) {
118
136
  const style = document.createElement("style");
119
137
  style.dataset.plugin = "dsh-opencode-go";
120
138
  style.dataset.pluginCss = id;
121
- style.textContent = '.BtKYva_page{flex-direction:column;min-width:0;height:100%;min-height:0;display:flex;container-type:size}.BtKYva_pageBody{scrollbar-gutter:stable;flex:1;min-height:0;padding-right:4px;overflow-y:auto}.BtKYva_field{flex-direction:column;gap:6px;padding:12px 0;display:flex}.BtKYva_field+.BtKYva_field{border-top:.5px solid var(--dsw-alias-border-l2)}.BtKYva_head{align-items:center;gap:8px;display:flex}.BtKYva_label{min-width:0;color:var(--dsw-alias-label-primary);flex:1;font-size:13px;font-weight:500;line-height:1.5}.BtKYva_badges{align-items:center;gap:8px;display:inline-flex}.BtKYva_reset{font:inherit;color:var(--dsw-alias-label-secondary);cursor:pointer;background:0 0;border:none;padding:0;font-size:12px;line-height:1.5}.BtKYva_reset:hover:not(:disabled){color:var(--dsw-alias-label-primary)}.BtKYva_reset:disabled{cursor:default}.BtKYva_reset:focus-visible,.BtKYva_disclosure:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:3px}.BtKYva_input{border:.5px solid var(--dsw-alias-border-l4);background:var(--dsw-alias-bg-layer-3);height:34px;font:inherit;color:var(--dsw-alias-label-primary);border-radius:8px;padding:0 12px;font-size:13px;line-height:1.5}.BtKYva_input:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:1px;border-color:var(--dsw-alias-brand-primary)}.BtKYva_input:disabled{color:var(--dsw-alias-label-tertiary);cursor:default}.BtKYva_inputInvalid{border-color:var(--dsw-alias-label-error);}.BtKYva_invalid{color:var(--dsw-alias-label-error);margin:0;font-size:12px;line-height:1.5}.BtKYva_hint{color:var(--dsw-alias-label-tertiary);margin:0;font-size:12px;line-height:1.5}.BtKYva_intro{color:var(--dsw-alias-label-secondary);margin:0 0 8px;font-size:13px;line-height:1.5}.BtKYva_disclosure{font:inherit;text-align:left;cursor:pointer;background:0 0;border:none;align-items:center;gap:8px;margin:0;padding:0;display:flex}.BtKYva_disclosure:hover .BtKYva_label{color:var(--dsw-alias-brand-primary)}.BtKYva_chevron,.BtKYva_chevronOpen{width:14px;height:14px;color:var(--dsw-alias-label-tertiary);flex:none}.BtKYva_chevron{transform:rotate(-90deg)}.BtKYva_advanced{flex-direction:column;gap:4px;padding:4px 0 0 22px;display:flex}.BtKYva_advanced .BtKYva_field+.BtKYva_field{border-top:none}.BtKYva_chips{flex-wrap:wrap;gap:6px;display:flex}.BtKYva_limitsEditor{flex-direction:column;gap:10px;padding-top:4px;display:flex}.BtKYva_limitsToolbar{grid-template-columns:minmax(0,1fr) auto;align-items:end;gap:6px 10px;display:grid}.BtKYva_limitsFilterLabel{color:var(--dsw-alias-label-secondary);grid-column:1/-1;font-size:12px;font-weight:500;line-height:1.5}.BtKYva_limitsSummary{color:var(--dsw-alias-label-tertiary);white-space:nowrap;padding-bottom:8px;font-size:12px;line-height:1.5}.BtKYva_limitsId,.BtKYva_limitsModelId{text-overflow:ellipsis;white-space:nowrap;display:block;overflow:hidden}.BtKYva_limitsId{color:var(--dsw-alias-label-primary);font-size:13px;line-height:1.4}.BtKYva_limitsModelId{color:var(--dsw-alias-label-tertiary);margin-top:2px;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:11px;line-height:1.4}.BtKYva_visuallyHidden{clip:rect(0, 0, 0, 0);white-space:nowrap;border:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}@media (width<=560px){.BtKYva_limitsToolbar{grid-template-columns:1fr}.BtKYva_limitsSummary{padding-bottom:0}}.BtKYva_actions{border-top:.5px solid var(--dsw-alias-border-l2);flex-wrap:wrap;flex:none;align-items:center;gap:8px;padding:12px 0;display:flex}.BtKYva_failedNote{color:var(--dsw-alias-label-error);margin:0;font-size:12px;line-height:1.5}.BtKYva_pageTop{align-items:flex-start;gap:16px;display:flex}.BtKYva_pageTop .BtKYva_intro{flex:1}.BtKYva_advancedTrigger{flex-shrink:0;margin-left:auto;}.BtKYva_advancedTrigger .BtKYva_label{color:var(--dsw-alias-label-tertiary);font-size:12px}.BtKYva_filters{flex-wrap:wrap;gap:6px;display:flex}.BtKYva_filter{font:inherit;color:var(--dsw-alias-label-secondary);cursor:pointer;background:0 0;border:0;border-radius:6px;padding:6px 9px;font-size:12px}.BtKYva_filter[aria-pressed=true]{color:var(--dsw-alias-label-primary);background:var(--dsw-alias-bg-layer-3)}.BtKYva_filter span{color:var(--dsw-alias-label-tertiary);margin-left:4px}.BtKYva_modelLayout{border:.5px solid var(--dsw-alias-border-l4);border-radius:10px;grid-template-columns:minmax(0,43fr) minmax(0,57fr);height:clamp(240px,100cqh - 460px,480px);display:grid;overflow:hidden}.BtKYva_modelList{border-right:.5px solid var(--dsw-alias-border-l2);min-height:0;padding:6px;overflow-y:auto}.BtKYva_modelRow{align-items:center;gap:8px;padding-right:6px;display:flex}.BtKYva_modelRow>[role=switch]{flex-shrink:0}.BtKYva_modelChoice{text-align:left;min-width:0;color:var(--dsw-alias-label-primary);cursor:pointer;background:0 0;border:0;border-radius:6px;flex:1;padding:12px 9px;display:block}.BtKYva_modelChoice[aria-pressed=true],.BtKYva_modelChoice:hover{background:var(--dsw-alias-bg-layer-3)}.BtKYva_modelName{overflow-wrap:anywhere;flex-wrap:wrap;align-items:center;gap:5px;font-size:13px;display:flex}.BtKYva_modelDetails{flex-direction:column;align-items:stretch;gap:10px;min-width:0;padding:18px;display:flex;overflow-y:auto}.BtKYva_modelDetails h3{overflow-wrap:anywhere;margin:0;font-size:16px}.BtKYva_modelHeading{flex-wrap:wrap;align-items:center;gap:6px;display:flex}.BtKYva_modelDetails .BtKYva_field{border:0;padding:8px 0}.BtKYva_modelDetails .BtKYva_input{box-sizing:border-box;width:100%;min-width:0}.BtKYva_modelDetails .BtKYva_reset{align-self:flex-start}.BtKYva_newBadge{color:var(--dsw-alias-label-primary);background:var(--dsw-alias-bg-layer-3);border:.5px solid var(--dsw-alias-border-l4);border-radius:4px;padding:2px 4px;font-size:9px}.BtKYva_releaseDate{color:var(--dsw-alias-label-tertiary);margin-top:4px;font-size:10px;display:block}.BtKYva_modelChoice:focus-visible,.BtKYva_filter:focus-visible,.BtKYva_advancedTrigger:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:-2px}@container (width<=440px){.BtKYva_pageTop{flex-wrap:wrap}.BtKYva_modelLayout{grid-template-columns:minmax(0,1fr);height:auto}.BtKYva_modelList{border-right:0;border-bottom:.5px solid var(--dsw-alias-border-l2);max-height:240px}.BtKYva_modelDetails{max-height:460px}}.BtKYva_keySection{border-top:.5px solid var(--dsw-alias-border-l2);padding:12px 0}.BtKYva_keySection summary{cursor:pointer;list-style:none}.BtKYva_keySection summary:after{content:"\u2304";color:var(--dsw-alias-label-tertiary)}.BtKYva_keySection summary::-webkit-details-marker{display:none}.BtKYva_keySection>.BtKYva_input{box-sizing:border-box;width:100%;margin:10px 0 6px}.BtKYva_keySection summary:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:2px}';
139
+ style.textContent = '.Juo2ua_page{flex-direction:column;min-width:0;height:100%;min-height:0;display:flex;container-type:size}.Juo2ua_pageBody{scrollbar-gutter:stable;flex:1;min-height:0;padding-right:4px;overflow-y:auto}.Juo2ua_field{flex-direction:column;gap:6px;padding:12px 0;display:flex}.Juo2ua_field+.Juo2ua_field{border-top:.5px solid var(--dsw-alias-border-l2)}.Juo2ua_head{align-items:center;gap:8px;display:flex}.Juo2ua_label{min-width:0;color:var(--dsw-alias-label-primary);flex:1;font-size:13px;font-weight:500;line-height:1.5}.Juo2ua_badges{align-items:center;gap:8px;display:inline-flex}.Juo2ua_reset{font:inherit;color:var(--dsw-alias-label-secondary);cursor:pointer;background:0 0;border:none;padding:0;font-size:12px;line-height:1.5}.Juo2ua_reset:hover:not(:disabled){color:var(--dsw-alias-label-primary)}.Juo2ua_reset:disabled{cursor:default}.Juo2ua_reset:focus-visible,.Juo2ua_disclosure:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:3px}.Juo2ua_input{border:.5px solid var(--dsw-alias-border-l4);background:var(--dsw-alias-bg-layer-3);height:34px;font:inherit;color:var(--dsw-alias-label-primary);border-radius:8px;padding:0 12px;font-size:13px;line-height:1.5}.Juo2ua_input:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:1px;border-color:var(--dsw-alias-brand-primary)}.Juo2ua_input:disabled{color:var(--dsw-alias-label-tertiary);cursor:default}.Juo2ua_inputInvalid{border-color:var(--dsw-alias-label-error);}.Juo2ua_invalid{color:var(--dsw-alias-label-error);margin:0;font-size:12px;line-height:1.5}.Juo2ua_hint{color:var(--dsw-alias-label-tertiary);margin:0;font-size:12px;line-height:1.5}.Juo2ua_intro{color:var(--dsw-alias-label-secondary);margin:0 0 8px;font-size:13px;line-height:1.5}.Juo2ua_disclosure{font:inherit;text-align:left;cursor:pointer;background:0 0;border:none;align-items:center;gap:8px;margin:0;padding:0;display:flex}.Juo2ua_disclosure:hover .Juo2ua_label{color:var(--dsw-alias-brand-primary)}.Juo2ua_chevron,.Juo2ua_chevronOpen{width:14px;height:14px;color:var(--dsw-alias-label-tertiary);flex:none}.Juo2ua_chevron{transform:rotate(-90deg)}.Juo2ua_advanced{flex-direction:column;gap:4px;padding:4px 0 0 22px;display:flex}.Juo2ua_advanced .Juo2ua_field+.Juo2ua_field{border-top:none}.Juo2ua_chips{flex-wrap:wrap;gap:6px;display:flex}.Juo2ua_limitsEditor{flex-direction:column;gap:10px;padding-top:4px;display:flex}.Juo2ua_limitsToolbar{grid-template-columns:minmax(0,1fr) auto;align-items:end;gap:6px 10px;display:grid}.Juo2ua_limitsFilterLabel{color:var(--dsw-alias-label-secondary);grid-column:1/-1;font-size:12px;font-weight:500;line-height:1.5}.Juo2ua_limitsSummary{color:var(--dsw-alias-label-tertiary);white-space:nowrap;padding-bottom:8px;font-size:12px;line-height:1.5}.Juo2ua_limitsId,.Juo2ua_limitsModelId{text-overflow:ellipsis;white-space:nowrap;display:block;overflow:hidden}.Juo2ua_limitsId{color:var(--dsw-alias-label-primary);font-size:13px;line-height:1.4}.Juo2ua_limitsModelId{color:var(--dsw-alias-label-tertiary);margin-top:2px;font-family:ui-monospace,SFMono-Regular,Menlo,monospace;font-size:11px;line-height:1.4}.Juo2ua_visuallyHidden{clip:rect(0, 0, 0, 0);white-space:nowrap;border:0;width:1px;height:1px;margin:-1px;padding:0;position:absolute;overflow:hidden}@media (width<=560px){.Juo2ua_limitsToolbar{grid-template-columns:1fr}.Juo2ua_limitsSummary{padding-bottom:0}}.Juo2ua_actions{border-top:.5px solid var(--dsw-alias-border-l2);flex-wrap:wrap;flex:none;align-items:center;gap:8px;padding:12px 0;display:flex}.Juo2ua_starLink{max-width:100%;color:var(--dsw-alias-label-secondary);border-radius:4px;align-items:center;gap:7px;margin-left:auto;padding:6px 0;font-size:12px;line-height:1.5;text-decoration:none;display:inline-flex}.Juo2ua_starLink svg{flex:none}.Juo2ua_starLink:hover{color:var(--dsw-alias-brand-primary)}.Juo2ua_starLink:hover span{text-underline-offset:3px;text-decoration:underline}.Juo2ua_starLink:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:3px}.Juo2ua_failedNote{color:var(--dsw-alias-label-error);margin:0;font-size:12px;line-height:1.5}.Juo2ua_pageTop{align-items:flex-start;gap:16px;display:flex}.Juo2ua_pageTop .Juo2ua_intro{flex:1}.Juo2ua_advancedTrigger{flex-shrink:0;margin-left:auto;}.Juo2ua_advancedTrigger .Juo2ua_label{color:var(--dsw-alias-label-tertiary);font-size:12px}.Juo2ua_filters{flex-wrap:wrap;gap:6px;display:flex}.Juo2ua_filter{font:inherit;color:var(--dsw-alias-label-secondary);cursor:pointer;background:0 0;border:0;border-radius:6px;padding:6px 9px;font-size:12px}.Juo2ua_filter[aria-pressed=true]{color:var(--dsw-alias-label-primary);background:var(--dsw-alias-bg-layer-3)}.Juo2ua_filter span{color:var(--dsw-alias-label-tertiary);margin-left:4px}.Juo2ua_modelLayout{border:.5px solid var(--dsw-alias-border-l4);border-radius:10px;grid-template-columns:minmax(0,43fr) minmax(0,57fr);height:clamp(240px,100cqh - 460px,480px);display:grid;overflow:hidden}.Juo2ua_modelList{border-right:.5px solid var(--dsw-alias-border-l2);min-height:0;padding:6px;overflow-y:auto}.Juo2ua_modelRow{align-items:center;gap:8px;padding-right:6px;display:flex}.Juo2ua_modelRow>[role=switch]{flex-shrink:0}.Juo2ua_modelChoice{text-align:left;min-width:0;color:var(--dsw-alias-label-primary);cursor:pointer;background:0 0;border:0;border-radius:6px;flex:1;padding:12px 9px;display:block}.Juo2ua_modelChoice[aria-pressed=true],.Juo2ua_modelChoice:hover{background:var(--dsw-alias-bg-layer-3)}.Juo2ua_modelName{overflow-wrap:anywhere;flex-wrap:wrap;align-items:center;gap:5px;font-size:13px;display:flex}.Juo2ua_modelDetails{flex-direction:column;align-items:stretch;gap:10px;min-width:0;padding:18px;display:flex;overflow-y:auto}.Juo2ua_modelDetails h3{overflow-wrap:anywhere;margin:0;font-size:16px}.Juo2ua_modelHeading{flex-wrap:wrap;align-items:center;gap:6px;display:flex}.Juo2ua_modelDetails .Juo2ua_field{border:0;padding:8px 0}.Juo2ua_modelDetails .Juo2ua_input{box-sizing:border-box;width:100%;min-width:0}.Juo2ua_modelDetails .Juo2ua_reset{align-self:flex-start}.Juo2ua_newBadge{color:var(--dsw-alias-label-primary);background:var(--dsw-alias-bg-layer-3);border:.5px solid var(--dsw-alias-border-l4);border-radius:4px;padding:2px 4px;font-size:9px}.Juo2ua_releaseDate{color:var(--dsw-alias-label-tertiary);margin-top:4px;font-size:10px;display:block}.Juo2ua_modelChoice:focus-visible,.Juo2ua_filter:focus-visible,.Juo2ua_advancedTrigger:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:-2px}@container (width<=440px){.Juo2ua_pageTop{flex-wrap:wrap}.Juo2ua_modelLayout{grid-template-columns:minmax(0,1fr);height:auto}.Juo2ua_modelList{border-right:0;border-bottom:.5px solid var(--dsw-alias-border-l2);max-height:240px}.Juo2ua_modelDetails{max-height:460px}}.Juo2ua_keySection{border-top:.5px solid var(--dsw-alias-border-l2);padding:12px 0}.Juo2ua_keySection summary{cursor:pointer;list-style:none}.Juo2ua_keySection summary:after{content:"\u2304";color:var(--dsw-alias-label-tertiary)}.Juo2ua_keySection summary::-webkit-details-marker{display:none}.Juo2ua_keySection>.Juo2ua_input{box-sizing:border-box;width:100%;margin:10px 0 6px}.Juo2ua_keySection summary:focus-visible{outline:2px solid var(--dsw-alias-brand-primary);outline-offset:2px}';
122
140
  document.head.appendChild(style);
123
141
  }
124
- var Section_default = { "failedNote": "BtKYva_failedNote", "advancedTrigger": "BtKYva_advancedTrigger BtKYva_disclosure", "chevron": "BtKYva_chevron", "modelName": "BtKYva_modelName", "filter": "BtKYva_filter", "modelHeading": "BtKYva_modelHeading", "filters": "BtKYva_filters", "label": "BtKYva_label", "hint": "BtKYva_hint", "page": "BtKYva_page", "keySection": "BtKYva_keySection", "limitsToolbar": "BtKYva_limitsToolbar", "intro": "BtKYva_intro", "modelRow": "BtKYva_modelRow", "limitsId": "BtKYva_limitsId", "limitsEditor": "BtKYva_limitsEditor", "input": "BtKYva_input", "reset": "BtKYva_reset", "limitsFilterLabel": "BtKYva_limitsFilterLabel", "limitsSummary": "BtKYva_limitsSummary", "visuallyHidden": "BtKYva_visuallyHidden", "pageTop": "BtKYva_pageTop", "badges": "BtKYva_badges", "advanced": "BtKYva_advanced", "limitsModelId": "BtKYva_limitsModelId", "invalid": "BtKYva_invalid", "actions": "BtKYva_actions", "modelLayout": "BtKYva_modelLayout", "pageBody": "BtKYva_pageBody", "inputInvalid": "BtKYva_inputInvalid BtKYva_input", "modelList": "BtKYva_modelList", "newBadge": "BtKYva_newBadge", "releaseDate": "BtKYva_releaseDate", "modelDetails": "BtKYva_modelDetails", "chips": "BtKYva_chips", "field": "BtKYva_field", "disclosure": "BtKYva_disclosure", "modelChoice": "BtKYva_modelChoice", "chevronOpen": "BtKYva_chevronOpen", "head": "BtKYva_head" };
142
+ var Section_default = { "modelRow": "Juo2ua_modelRow", "chevronOpen": "Juo2ua_chevronOpen", "head": "Juo2ua_head", "badges": "Juo2ua_badges", "starLink": "Juo2ua_starLink", "limitsModelId": "Juo2ua_limitsModelId", "intro": "Juo2ua_intro", "limitsSummary": "Juo2ua_limitsSummary", "limitsFilterLabel": "Juo2ua_limitsFilterLabel", "modelName": "Juo2ua_modelName", "failedNote": "Juo2ua_failedNote", "hint": "Juo2ua_hint", "limitsId": "Juo2ua_limitsId", "inputInvalid": "Juo2ua_inputInvalid Juo2ua_input", "releaseDate": "Juo2ua_releaseDate", "pageBody": "Juo2ua_pageBody", "pageTop": "Juo2ua_pageTop", "label": "Juo2ua_label", "limitsEditor": "Juo2ua_limitsEditor", "actions": "Juo2ua_actions", "filter": "Juo2ua_filter", "filters": "Juo2ua_filters", "modelLayout": "Juo2ua_modelLayout", "field": "Juo2ua_field", "modelList": "Juo2ua_modelList", "modelHeading": "Juo2ua_modelHeading", "newBadge": "Juo2ua_newBadge", "keySection": "Juo2ua_keySection", "disclosure": "Juo2ua_disclosure", "visuallyHidden": "Juo2ua_visuallyHidden", "advancedTrigger": "Juo2ua_advancedTrigger Juo2ua_disclosure", "reset": "Juo2ua_reset", "limitsToolbar": "Juo2ua_limitsToolbar", "advanced": "Juo2ua_advanced", "chevron": "Juo2ua_chevron", "input": "Juo2ua_input", "chips": "Juo2ua_chips", "page": "Juo2ua_page", "modelChoice": "Juo2ua_modelChoice", "invalid": "Juo2ua_invalid", "modelDetails": "Juo2ua_modelDetails" };
125
143
 
126
144
  // src/client/ModelEditor.tsx
127
145
  var import_jsx_runtime = require("react/jsx-runtime");
@@ -146,6 +164,7 @@ function ModelEditor({ models, draft, modelVisibility, t, locale, disabled, visi
146
164
  const entries = all.filter((model2) => `${model2.name ?? ""} ${model2.id}`.toLocaleLowerCase().includes(normalized) && (filter === "all" || filter === "new" && isNewModel(model2, now) || filter === "custom" && hasCapacityOverride(draft[model2.id]) || filter === "deprecated" && model2.deprecated));
147
165
  const model = entries.find((entry) => entry.id === selected) ?? entries[0];
148
166
  const visibilityDisabled = disabled || visibilitySaving;
167
+ const metadataUnavailable = models.status === "ready" && models.sources?.metadata.error !== void 0;
149
168
  const customized = all.filter((entry) => hasCapacityOverride(draft[entry.id])).length;
150
169
  const filters = [
151
170
  ["all", "filterAll", all.length],
@@ -158,7 +177,7 @@ function ModelEditor({ models, draft, modelVisibility, t, locale, disabled, visi
158
177
  onEdit({ ...draft, [id3]: { ...current, [field]: value ?? null } });
159
178
  };
160
179
  const badges = (entry) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
161
- entry.configurationMissing ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Tag, { tone: "warning", children: t("configurationMissing") }) : null,
180
+ entry.configurationMissing ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Tag, { tone: "warning", children: t(metadataUnavailable ? "configurationUnavailable" : "configurationMissing") }) : null,
162
181
  isNewModel(entry, now) ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: Section_default.newBadge, title: t("newHint"), children: t("newBadge") }) : null,
163
182
  entry.deprecated ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dsh_client_ui_primitives.Tag, { tone: "warning", children: t("deprecatedBadge") }) : null
164
183
  ] });
@@ -236,7 +255,7 @@ function ModelEditor({ models, draft, modelVisibility, t, locale, disabled, visi
236
255
  badges(model)
237
256
  ] }),
238
257
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)("code", { className: Section_default.limitsModelId, translate: "no", children: model.id }),
239
- model.configurationMissing ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: Section_default.hint, children: t("configurationMissingHint") }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
258
+ model.configurationMissing ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: Section_default.hint, children: t(metadataUnavailable ? "configurationUnavailableHint" : "configurationMissingHint") }) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
240
259
  model.deprecated ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", { className: Section_default.hint, children: t("deprecatedHint") }) : null,
241
260
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Capacity, { model, field: "contextWindow", limit: draft[model.id], t, locale, disabled, onChange: write }),
242
261
  /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Capacity, { model, field: "maxTokens", limit: draft[model.id], t, locale, disabled, onChange: write }),
@@ -351,19 +370,37 @@ function ValueField(props) {
351
370
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { id: hintId, className: props.field.invalid ? Section_default.invalid : Section_default.hint, children: props.field.invalid ? props.invalidLabel : props.hint })
352
371
  ] });
353
372
  }
354
- function ModelsBody({ models, t }) {
373
+ function ModelsBody({ models, t, locale }) {
374
+ const sources = models.status === "ready" || models.status === "failed" ? models.sources : void 0;
375
+ const metadataOnlyFailure = sources?.metadata.error !== void 0 && sources.listing.error === void 0;
376
+ const sourceStatus = sources ? ["listing", "metadata"].map((source) => {
377
+ const status = sources[source];
378
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("p", { className: Section_default.hint, children: [
379
+ t(source === "listing" ? "modelsListingSource" : "modelsMetadataSource"),
380
+ ": ",
381
+ " ",
382
+ status.error ? t("modelsSourceFailed") : t("modelsSourceCurrent"),
383
+ ". ",
384
+ " ",
385
+ status.updatedAt === void 0 ? t("modelsSourceNeverFetched") : t("modelsSourceUpdated", { time: new Date(status.updatedAt).toLocaleString(locale) })
386
+ ] }, source);
387
+ }) : null;
355
388
  if (models.status === "failed") {
356
389
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
357
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: Section_default.failedNote, role: "alert", children: t("modelsFailed") }),
358
- models.message ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: Section_default.hint, children: models.message }) : null
390
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: Section_default.failedNote, role: "alert", children: t(metadataOnlyFailure ? "modelsMetadataFailed" : "modelsFailed") }),
391
+ models.message ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: Section_default.hint, children: models.message }) : null,
392
+ sourceStatus
359
393
  ] });
360
394
  }
361
395
  if (models.status !== "ready") return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: Section_default.hint, role: "status", "aria-live": "polite", children: t("modelsLoading") });
362
- if (models.refreshing) return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: Section_default.hint, role: "status", children: t("modelsRefreshing") });
396
+ const progress = models.refreshing ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: Section_default.hint, role: "status", children: t("modelsRefreshing") }) : null;
363
397
  if (models.stale) return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
364
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: Section_default.failedNote, role: "alert", children: t("modelsStale") }),
365
- models.message ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: Section_default.hint, children: models.message }) : null
398
+ progress,
399
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: Section_default.failedNote, role: "alert", children: t(metadataOnlyFailure ? "modelsMetadataFailed" : "modelsStale") }),
400
+ models.message ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: Section_default.hint, children: models.message }) : null,
401
+ sourceStatus
366
402
  ] });
403
+ if (models.refreshing) return progress;
367
404
  if (models.count === 0) return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: Section_default.hint, children: t("modelsEmpty") });
368
405
  return null;
369
406
  }
@@ -601,7 +638,7 @@ function Loaded(props) {
601
638
  )
602
639
  ] })
603
640
  ] }),
604
- /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ModelsBody, { models: state.models, t })
641
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(ModelsBody, { models: state.models, t, locale: props.locale })
605
642
  ] }),
606
643
  /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: Section_default.field, children: [
607
644
  state.pickerFailed ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: Section_default.failedNote, role: "alert", children: t("pickerFailed") }) : null,
@@ -627,6 +664,20 @@ function Loaded(props) {
627
664
  /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)("div", { className: Section_default.actions, children: [
628
665
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives2.Button, { variant: "primary", size: "md", disabled: disabled || !state.dirty || state.invalid || state.saving || state.pickerSaving, onClick: props.save, children: state.saving ? t("saving") : t("save") }),
629
666
  /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_dsh_client_ui_primitives2.Button, { variant: "outline", size: "md", disabled: disabled || !state.dirty || state.saving, onClick: props.discard, children: t("discard") }),
667
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
668
+ "a",
669
+ {
670
+ className: Section_default.starLink,
671
+ href: "https://github.com/Duskriver/dsh-opencode-go",
672
+ target: "_blank",
673
+ rel: "noopener noreferrer",
674
+ title: t("starProjectTitle"),
675
+ children: [
676
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("svg", { viewBox: "0 0 24 24", width: "18", height: "18", fill: "currentColor", "aria-hidden": "true", focusable: "false", children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12" }) }),
677
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("span", { children: t("starProject") })
678
+ ]
679
+ }
680
+ ),
630
681
  state.failed ? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("p", { className: Section_default.failedNote, children: t("savedFailed") }) : null
631
682
  ] })
632
683
  ] });
@@ -1047,13 +1098,17 @@ var OpencodeGoSectionController = class {
1047
1098
  this.models = previous ? { ...previous, refreshing: true } : { status: "loading" };
1048
1099
  this.store.set(this.projection());
1049
1100
  const failed = (message) => {
1050
- this.models = previous ? { ...previous, refreshing: false, stale: true, message } : { status: "failed", message };
1101
+ this.models = previous ? { ...previous, refreshing: false, stale: true, message, sources: void 0 } : { status: "failed", message };
1051
1102
  };
1052
1103
  void this.readModels().then((response) => {
1053
1104
  if (request !== this.modelsRequest) return;
1054
1105
  if (!response.ok) failed(response.error.message);
1055
1106
  else if (response.value.stale && response.value.models.length === 0) {
1056
- this.models = { status: "failed", ...response.value.error ? { message: response.value.error } : {} };
1107
+ this.models = {
1108
+ status: "failed",
1109
+ ...response.value.error ? { message: response.value.error } : {},
1110
+ ...response.value.sources ? { sources: response.value.sources } : {}
1111
+ };
1057
1112
  } else {
1058
1113
  this.models = {
1059
1114
  status: "ready",
@@ -1061,6 +1116,7 @@ var OpencodeGoSectionController = class {
1061
1116
  preview: response.value.models.map((model) => model.name ?? model.id),
1062
1117
  entries: response.value.models,
1063
1118
  stale: response.value.stale,
1119
+ ...response.value.sources ? { sources: response.value.sources } : {},
1064
1120
  ...response.value.error ? { message: response.value.error } : {}
1065
1121
  };
1066
1122
  }
@@ -1173,6 +1229,17 @@ function refOf(snapshot) {
1173
1229
 
1174
1230
  // src/client/locales.ts
1175
1231
  var en = {
1232
+ cacheTitle: "Session cache reads",
1233
+ cacheReadRatio: "Cached input share",
1234
+ cacheReadTokens: "Cache read tokens",
1235
+ cacheInputTokens: "Total input tokens",
1236
+ cacheWriteTokens: "Cache write tokens",
1237
+ cacheResponses: "Measured responses",
1238
+ cacheEmpty: "No usable Go response usage in the loaded history yet.",
1239
+ cacheExcluded: "Responses excluded for missing route or usage:",
1240
+ cacheScope: "Settled Go responses in loaded history. Inherited fork responses and unsettled attempts are excluded.",
1241
+ cacheMore: "Older history is not fully loaded.",
1242
+ cacheRoutingHint: "A stable session header supports routing affinity. Cache reads are reported separately by the gateway and may remain zero.",
1176
1243
  usageTitle: "OpenCode Go usage",
1177
1244
  usageRollingShort: "5h",
1178
1245
  usageHint: "Account usage \xB7 used percentage \xB7 refreshes every minute",
@@ -1193,6 +1260,8 @@ var en = {
1193
1260
  nav: "OpenCode Go",
1194
1261
  title: "OpenCode Go",
1195
1262
  intro: "Choose the OpenCode Go models shown in conversations and adjust their capacities.",
1263
+ starProject: "Enjoying the plugin? Star it on GitHub",
1264
+ starProjectTitle: "Open the GitHub project in a new tab",
1196
1265
  enabledLabel: "Enable OpenCode Go",
1197
1266
  enabledHint: "While this is on, OpenCode Go appears in every model picker and can serve requests. Turning it off withdraws the provider and its models immediately; this page stays reachable so you can turn it back on.",
1198
1267
  enabledOff: "OpenCode Go is off. Its models are withdrawn from every picker and no request reaches the gateway. Turn the switch back on to use it again.",
@@ -1206,7 +1275,14 @@ var en = {
1206
1275
  modelsRefresh: "Refresh",
1207
1276
  modelsLoading: "Reading the gateway model list\u2026",
1208
1277
  modelsFailed: "Could not read the gateway model list.",
1209
- modelsStale: "Refresh failed. Showing the last fetched models, also used by conversation pickers. Their current availability could not be confirmed.",
1278
+ modelsStale: "Some model data could not be refreshed. Available cached or built-in data is still in use, including in conversation pickers.",
1279
+ modelsMetadataFailed: "Could not load model configuration from models.dev. Models with usable cached or built-in configuration remain available. See the error details below, check network access from the machine running DSH, then refresh.",
1280
+ modelsListingSource: "Model availability",
1281
+ modelsMetadataSource: "Model configuration",
1282
+ modelsSourceFailed: "Refresh failed",
1283
+ modelsSourceCurrent: "Up to date",
1284
+ modelsSourceNeverFetched: "No successful fetch yet",
1285
+ modelsSourceUpdated: "Last successful check: {time}",
1210
1286
  modelsRefreshing: "Refreshing\u2026 Keeping the last fetched models visible.",
1211
1287
  modelsEmpty: "The gateway currently serves no model this adapter can route.",
1212
1288
  modelsCount: "{count} models",
@@ -1223,7 +1299,9 @@ var en = {
1223
1299
  visibilityHint: "Only enabled models appear in conversation pickers. Changes apply immediately. Deprecated models are off by default and can be enabled individually.",
1224
1300
  modelVisibleLabel: "Show {name} in conversations",
1225
1301
  configurationMissing: "Configuration missing",
1226
- configurationMissingHint: "The gateway lists this model, but its OpenCode Go configuration is missing. It cannot be enabled.",
1302
+ configurationMissingHint: "The gateway lists this model, but no usable OpenCode Go configuration is available. Once the upstream configuration is supplied or corrected, refresh the list to enable it.",
1303
+ configurationUnavailable: "Configuration unavailable",
1304
+ configurationUnavailableHint: "The model configuration could not be loaded, and no usable cached or built-in configuration is available for this model. Check network access to models.dev from the machine running DSH and the error details above, then refresh.",
1227
1305
  pickerFailed: "Could not update model visibility. Please retry.",
1228
1306
  deprecatedBadge: "Deprecated",
1229
1307
  deprecatedHint: "Marked deprecated by models.dev, but still provided by this gateway.",
@@ -1270,6 +1348,17 @@ var en = {
1270
1348
  unavailable: "The OpenCode Go settings are not served in this deployment."
1271
1349
  };
1272
1350
  var zh = {
1351
+ cacheTitle: "\u4F1A\u8BDD\u7F13\u5B58\u8BFB\u53D6",
1352
+ cacheReadRatio: "\u7F13\u5B58\u8BFB\u53D6\u5360\u8F93\u5165\u6BD4\u4F8B",
1353
+ cacheReadTokens: "\u7F13\u5B58\u8BFB\u53D6 tokens",
1354
+ cacheInputTokens: "\u603B\u8F93\u5165 tokens",
1355
+ cacheWriteTokens: "\u7F13\u5B58\u5199\u5165 tokens",
1356
+ cacheResponses: "\u5DF2\u7EDF\u8BA1\u54CD\u5E94\u6570",
1357
+ cacheEmpty: "\u5DF2\u52A0\u8F7D\u5386\u53F2\u4E2D\u6682\u65E0\u53EF\u7528\u7684 Go \u54CD\u5E94\u7528\u91CF\u3002",
1358
+ cacheExcluded: "\u56E0\u7F3A\u5C11\u8DEF\u7531\u6216\u7528\u91CF\u800C\u672A\u7EDF\u8BA1\u7684\u54CD\u5E94\uFF1A",
1359
+ cacheScope: "\u7EDF\u8BA1\u5DF2\u52A0\u8F7D\u5386\u53F2\u4E2D\u7684 Go \u5DF2\u7ED3\u7B97\u54CD\u5E94\uFF0C\u6392\u9664\u5206\u53C9\u7EE7\u627F\u7684\u54CD\u5E94\u53CA\u672A\u7ED3\u7B97\u7684\u8BF7\u6C42\u3002",
1360
+ cacheMore: "\u66F4\u65E9\u7684\u5386\u53F2\u5C1A\u672A\u5168\u90E8\u52A0\u8F7D\u3002",
1361
+ cacheRoutingHint: "\u7A33\u5B9A\u7684\u4F1A\u8BDD\u6807\u8BC6\u6709\u52A9\u4E8E\u8DEF\u7531\u4FDD\u6301\u4E00\u81F4\uFF1B\u5B9E\u9645\u7F13\u5B58\u8BFB\u53D6\u91CF\u7531\u7F51\u5173\u53E6\u884C\u62A5\u544A\uFF0C\u4ECD\u53EF\u80FD\u4E3A\u96F6\u3002",
1273
1362
  usageTitle: "OpenCode Go \u7528\u91CF",
1274
1363
  usageRollingShort: "5\u5C0F\u65F6",
1275
1364
  usageHint: "\u8D26\u53F7\u989D\u5EA6 \xB7 \u5DF2\u7528\u767E\u5206\u6BD4 \xB7 \u6BCF\u5206\u949F\u5237\u65B0",
@@ -1290,6 +1379,8 @@ var zh = {
1290
1379
  nav: "OpenCode Go",
1291
1380
  title: "OpenCode Go",
1292
1381
  intro: "\u9009\u62E9\u4F1A\u8BDD\u4E2D\u663E\u793A\u7684 OpenCode Go \u6A21\u578B\uFF0C\u5E76\u8C03\u6574\u5176\u5BB9\u91CF\u3002",
1382
+ starProject: "\u559C\u6B22\u8FD9\u4E2A\u63D2\u4EF6\uFF1F\u53BB GitHub \u70B9\u4E2A Star",
1383
+ starProjectTitle: "\u5728\u65B0\u6807\u7B7E\u9875\u6253\u5F00 GitHub \u9879\u76EE",
1293
1384
  enabledLabel: "\u542F\u7528 OpenCode Go",
1294
1385
  enabledHint: "\u5F00\u542F\u65F6\uFF0COpenCode Go \u4F1A\u51FA\u73B0\u5728\u6240\u6709\u6A21\u578B\u9009\u62E9\u5668\u4E2D\u5E76\u53EF\u5904\u7406\u8BF7\u6C42\u3002\u5173\u95ED\u540E\u5C06\u7ACB\u5373\u64A4\u4E0B\u8BE5\u63D0\u4F9B\u65B9\u53CA\u5176\u6A21\u578B\uFF1B\u672C\u9875\u4ECD\u53EF\u8BBF\u95EE\uFF0C\u65B9\u4FBF\u4F60\u968F\u65F6\u91CD\u65B0\u5F00\u542F\u3002",
1295
1386
  enabledOff: "OpenCode Go \u5DF2\u5173\u95ED\u3002\u5176\u6A21\u578B\u5DF2\u4ECE\u6240\u6709\u9009\u62E9\u5668\u4E2D\u64A4\u4E0B\uFF0C\u4E5F\u4E0D\u4F1A\u6709\u8BF7\u6C42\u53D1\u5F80\u7F51\u5173\u3002\u9700\u8981\u65F6\u628A\u5F00\u5173\u91CD\u65B0\u6253\u5F00\u5373\u53EF\u3002",
@@ -1303,7 +1394,14 @@ var zh = {
1303
1394
  modelsRefresh: "\u5237\u65B0",
1304
1395
  modelsLoading: "\u6B63\u5728\u8BFB\u53D6\u7F51\u5173\u6A21\u578B\u5217\u8868\u2026",
1305
1396
  modelsFailed: "\u672A\u80FD\u8BFB\u53D6\u7F51\u5173\u6A21\u578B\u5217\u8868\u3002",
1306
- modelsStale: "\u5237\u65B0\u5931\u8D25\uFF0C\u6B63\u5728\u663E\u793A\u4E0A\u6B21\u83B7\u53D6\u7684\u6A21\u578B\uFF1B\u4F1A\u8BDD\u9009\u62E9\u5668\u4E5F\u4F7F\u7528\u8FD9\u4EFD\u7F13\u5B58\uFF0C\u5F53\u524D\u53EF\u7528\u6027\u5C1A\u672A\u786E\u8BA4\u3002",
1397
+ modelsStale: "\u90E8\u5206\u6A21\u578B\u6570\u636E\u5237\u65B0\u5931\u8D25\uFF0C\u6B63\u5728\u7EE7\u7EED\u4F7F\u7528\u53EF\u7528\u7684\u7F13\u5B58\u6216\u5185\u7F6E\u914D\u7F6E\uFF1B\u4F1A\u8BDD\u9009\u62E9\u5668\u4E5F\u4F7F\u7528\u8FD9\u4EFD\u6570\u636E\u3002",
1398
+ modelsMetadataFailed: "\u672A\u80FD\u4ECE models.dev \u83B7\u53D6\u6709\u6548\u7684\u6A21\u578B\u914D\u7F6E\u3002\u5DF2\u6709\u53EF\u7528\u7F13\u5B58\u6216\u5185\u7F6E\u914D\u7F6E\u7684\u6A21\u578B\u4ECD\u53EF\u4F7F\u7528\u3002\u8BF7\u67E5\u770B\u4E0B\u65B9\u9519\u8BEF\u8BE6\u60C5\uFF0C\u68C0\u67E5\u8FD0\u884C DSH \u7684\u8BBE\u5907\u7684\u7F51\u7EDC\u8FDE\u63A5\uFF0C\u7136\u540E\u5237\u65B0\u91CD\u8BD5\u3002",
1399
+ modelsListingSource: "\u6A21\u578B\u540D\u5355",
1400
+ modelsMetadataSource: "\u6A21\u578B\u914D\u7F6E",
1401
+ modelsSourceFailed: "\u5237\u65B0\u5931\u8D25",
1402
+ modelsSourceCurrent: "\u5DF2\u66F4\u65B0",
1403
+ modelsSourceNeverFetched: "\u5C1A\u672A\u6210\u529F\u83B7\u53D6",
1404
+ modelsSourceUpdated: "\u4E0A\u6B21\u6210\u529F\u68C0\u67E5\uFF1A{time}",
1307
1405
  modelsRefreshing: "\u6B63\u5728\u5237\u65B0\uFF0C\u6682\u65F6\u4FDD\u7559\u4E0A\u6B21\u83B7\u53D6\u7684\u6A21\u578B\u3002",
1308
1406
  modelsEmpty: "\u7F51\u5173\u5F53\u524D\u6CA1\u6709\u672C\u9002\u914D\u5668\u53EF\u8DEF\u7531\u7684\u6A21\u578B\u3002",
1309
1407
  modelsCount: "{count} \u4E2A\u6A21\u578B",
@@ -1320,7 +1418,9 @@ var zh = {
1320
1418
  visibilityHint: "\u5F00\u542F\u7684\u6A21\u578B\u624D\u4F1A\u663E\u793A\u5728\u4F1A\u8BDD\u9009\u62E9\u5668\u4E2D\uFF0C\u4FEE\u6539\u7ACB\u5373\u751F\u6548\u3002\u8FC7\u65F6\u6A21\u578B\u9ED8\u8BA4\u5173\u95ED\uFF0C\u53EF\u5355\u72EC\u5F00\u542F\u3002",
1321
1419
  modelVisibleLabel: "\u5728\u4F1A\u8BDD\u4E2D\u663E\u793A {name}",
1322
1420
  configurationMissing: "\u914D\u7F6E\u7F3A\u5931",
1323
- configurationMissingHint: "\u7F51\u5173\u5DF2\u5217\u51FA\u6B64\u6A21\u578B\uFF0C\u4F46\u7F3A\u5C11\u5BF9\u5E94\u7684 OpenCode Go \u914D\u7F6E\uFF0C\u6682\u4E0D\u53EF\u5F00\u542F\u3002",
1421
+ configurationMissingHint: "\u7F51\u5173\u5DF2\u5217\u51FA\u6B64\u6A21\u578B\uFF0C\u4F46\u6682\u672A\u83B7\u5F97\u53EF\u7528\u7684 OpenCode Go \u914D\u7F6E\u3002\u4E0A\u6E38\u8865\u9F50\u6216\u4FEE\u6B63\u914D\u7F6E\u540E\uFF0C\u5237\u65B0\u5217\u8868\u5373\u53EF\u5F00\u542F\u3002",
1422
+ configurationUnavailable: "\u914D\u7F6E\u6682\u4E0D\u53EF\u7528",
1423
+ configurationUnavailableHint: "\u6682\u672A\u80FD\u83B7\u53D6\u6709\u6548\u7684\u6A21\u578B\u914D\u7F6E\uFF0C\u4E14\u6CA1\u6709\u6B64\u6A21\u578B\u7684\u53EF\u7528\u7F13\u5B58\u6216\u5185\u7F6E\u914D\u7F6E\u3002\u8BF7\u67E5\u770B\u4E0A\u65B9\u9519\u8BEF\u8BE6\u60C5\uFF0C\u68C0\u67E5\u8FD0\u884C DSH \u7684\u8BBE\u5907\u80FD\u5426\u8BBF\u95EE models.dev\uFF0C\u7136\u540E\u5237\u65B0\u91CD\u8BD5\u3002",
1324
1424
  pickerFailed: "\u6A21\u578B\u663E\u793A\u8BBE\u7F6E\u672A\u66F4\u65B0\uFF0C\u8BF7\u91CD\u8BD5\u3002",
1325
1425
  deprecatedBadge: "\u5DF2\u5F03\u7528",
1326
1426
  deprecatedHint: "models.dev \u6807\u8BB0\u4E3A\u5DF2\u5F03\u7528\uFF0C\u5F53\u524D\u7F51\u5173\u4ECD\u63D0\u4F9B\u6B64\u6A21\u578B\u3002",
@@ -1413,21 +1513,152 @@ var goRemote = {
1413
1513
  };
1414
1514
 
1415
1515
  // src/client/UsagePill.tsx
1516
+ var import_react4 = require("react");
1517
+
1518
+ // src/client/SessionCache.tsx
1416
1519
  var import_react3 = require("react");
1417
1520
 
1418
- // plugin-css:/Users/tanglei/Desktop/dsh-opencode-go/src/client/UsagePill.module.css
1521
+ // src/client/session-cache.ts
1522
+ function record(value) {
1523
+ return value !== null && typeof value === "object" && !Array.isArray(value) ? value : void 0;
1524
+ }
1525
+ function tokens(value) {
1526
+ return typeof value === "number" && Number.isSafeInteger(value) && value >= 0;
1527
+ }
1528
+ function sessionEventSource(sessions, sessionId) {
1529
+ const service = record(sessions);
1530
+ if (typeof service?.binding !== "function") return void 0;
1531
+ const source = record(record(service.binding(sessionId))?.eventSource);
1532
+ if (typeof source?.getSnapshot !== "function" || typeof source.subscribe !== "function") return void 0;
1533
+ const getSnapshot = source.getSnapshot.bind(source);
1534
+ const subscribe = source.subscribe.bind(source);
1535
+ return {
1536
+ getSnapshot: () => getSnapshot(),
1537
+ subscribe: (listener) => subscribe(listener)
1538
+ };
1539
+ }
1540
+ function summarizeSessionCache(window) {
1541
+ const snapshot = record(window);
1542
+ let stats = {
1543
+ responses: 0,
1544
+ missingUsage: 0,
1545
+ unattributed: 0,
1546
+ inputTokens: 0,
1547
+ cacheReadTokens: 0,
1548
+ cacheWriteTokens: 0,
1549
+ hasMore: snapshot?.hasMore === true
1550
+ };
1551
+ let provider;
1552
+ const seen = /* @__PURE__ */ new Set();
1553
+ for (const entry of Array.isArray(snapshot?.entries) ? snapshot.entries : []) {
1554
+ const row = record(entry);
1555
+ const event = record(row?.event);
1556
+ if (row?.type !== "event" || !event || !tokens(event.seq) || seen.has(event.seq)) continue;
1557
+ seen.add(event.seq);
1558
+ const data = record(event.data);
1559
+ if (event.type === "request/header") provider = record(record(data?.header)?.config)?.provider;
1560
+ if (event.type === "session/end-seed" && data?.inherited === true) {
1561
+ stats = {
1562
+ ...stats,
1563
+ responses: 0,
1564
+ missingUsage: 0,
1565
+ unattributed: 0,
1566
+ inputTokens: 0,
1567
+ cacheReadTokens: 0,
1568
+ cacheWriteTokens: 0
1569
+ };
1570
+ }
1571
+ if (event.type !== "assistant/message") continue;
1572
+ if (provider === void 0) {
1573
+ stats.unattributed++;
1574
+ continue;
1575
+ }
1576
+ if (provider !== "opencode-go") continue;
1577
+ const usage = record(data?.usage);
1578
+ const input = usage?.inputTokens;
1579
+ const read = usage?.cacheReadTokens === void 0 ? 0 : usage.cacheReadTokens;
1580
+ const write = usage?.cacheWriteTokens === void 0 ? 0 : usage.cacheWriteTokens;
1581
+ if (!tokens(input) || !tokens(read) || !tokens(write) || !Number.isSafeInteger(stats.inputTokens + input + read + write)) {
1582
+ stats.missingUsage++;
1583
+ continue;
1584
+ }
1585
+ stats.responses++;
1586
+ stats.inputTokens += input + read + write;
1587
+ stats.cacheReadTokens += read;
1588
+ stats.cacheWriteTokens += write;
1589
+ }
1590
+ return stats;
1591
+ }
1592
+ function sessionCacheSource(events) {
1593
+ let window;
1594
+ let value;
1595
+ return {
1596
+ subscribe: (listener) => events.subscribe(listener),
1597
+ getSnapshot: () => {
1598
+ const next = events.getSnapshot();
1599
+ if (value !== void 0 && next === window) return value;
1600
+ const previous = record(window);
1601
+ window = next;
1602
+ const current = record(next);
1603
+ const change = record(current?.change);
1604
+ if (value !== void 0 && typeof previous?.revision === "number" && current?.revision === previous.revision + 1 && change?.kind === "append" && Array.isArray(change.entries) && change.entries.every((entry) => record(entry)?.type === "transient")) return value;
1605
+ const stats = summarizeSessionCache(next);
1606
+ if (value === void 0 || Object.keys(stats).some((key) => stats[key] !== value[key])) value = stats;
1607
+ return value;
1608
+ }
1609
+ };
1610
+ }
1611
+
1612
+ // plugin-css:/private/var/folders/4z/q9yrksqd0y12spqrxkv0p_dm0000gn/T/dsh-release-0.1.13-Tf3MEL/source/src/client/UsagePill.module.css
1419
1613
  var id2 = "dsh-opencode-go/UsagePill.module.css";
1420
1614
  if (!document.querySelector("style[data-plugin-css=" + JSON.stringify(id2) + "]")) {
1421
1615
  const style = document.createElement("style");
1422
1616
  style.dataset.plugin = "dsh-opencode-go";
1423
1617
  style.dataset.pluginCss = id2;
1424
- style.textContent = ".dmPm3q_root{min-width:0;display:inline-flex;position:relative}.dmPm3q_trigger{color:inherit;opacity:.75;font:inherit;cursor:pointer;white-space:nowrap;background:0 0;border:0;border-radius:6px;padding:4px 6px;font-size:12px}.dmPm3q_trigger:hover,.dmPm3q_trigger:focus-visible{opacity:1;background:color-mix(in srgb, currentColor 8%, transparent)}.dmPm3q_panel{z-index:100;box-sizing:border-box;border:1px solid color-mix(in srgb, currentColor 18%, transparent);width:280px;max-width:calc(100vw - 32px);max-height:70vh;color:var(--dsw-alias-label-primary,CanvasText);background:var(--dsw-specific-menu,Canvas);border-radius:12px;padding:16px;font-size:12px;position:absolute;bottom:calc(100% + 12px);right:0;overflow-y:auto;box-shadow:0 8px 30px #0002}.dmPm3q_hint{opacity:.65;font-size:11px;line-height:1.6}.dmPm3q_warning{background:color-mix(in srgb, currentColor 6%, transparent);overflow-wrap:anywhere;border-radius:6px;margin:10px 0;padding:10px;line-height:1.5}.dmPm3q_warning p{margin:5px 0 0}.dmPm3q_retry{border:1px solid color-mix(in srgb, currentColor 25%, transparent);color:inherit;font:inherit;cursor:pointer;background:0 0;border-radius:6px;padding:5px 9px}.dmPm3q_retry:disabled{opacity:.6;cursor:default}.dmPm3q_retry:focus-visible{outline-offset:2px;outline:2px solid}.dmPm3q_window{margin-top:14px}.dmPm3q_row{justify-content:space-between;margin-bottom:5px;display:flex}.dmPm3q_window progress{appearance:none;background:color-mix(in srgb, currentColor 15%, transparent);border:0;border-radius:4px;width:100%;height:5px;margin-bottom:5px;display:block}.dmPm3q_window progress::-webkit-progress-bar{background:0 0;border-radius:4px}.dmPm3q_window progress::-webkit-progress-value{background:#39a878;border-radius:4px}.dmPm3q_window progress::-moz-progress-bar{background:#39a878;border-radius:4px}";
1618
+ style.textContent = ".xXzfkq_root{min-width:0;display:inline-flex;position:relative}.xXzfkq_trigger{color:inherit;opacity:.75;font:inherit;cursor:pointer;white-space:nowrap;background:0 0;border:0;border-radius:6px;padding:4px 6px;font-size:12px}.xXzfkq_trigger:hover,.xXzfkq_trigger:focus-visible{opacity:1;background:color-mix(in srgb, currentColor 8%, transparent)}.xXzfkq_panel{z-index:100;box-sizing:border-box;border:1px solid color-mix(in srgb, currentColor 18%, transparent);width:280px;max-width:calc(100vw - 32px);max-height:70vh;color:var(--dsw-alias-label-primary,CanvasText);background:var(--dsw-specific-menu,Canvas);border-radius:12px;padding:16px;font-size:12px;position:absolute;bottom:calc(100% + 12px);right:0;overflow-y:auto;box-shadow:0 8px 30px #0002}.xXzfkq_hint{opacity:.65;font-size:11px;line-height:1.6}.xXzfkq_warning{background:color-mix(in srgb, currentColor 6%, transparent);overflow-wrap:anywhere;border-radius:6px;margin:10px 0;padding:10px;line-height:1.5}.xXzfkq_warning p{margin:5px 0 0}.xXzfkq_retry{border:1px solid color-mix(in srgb, currentColor 25%, transparent);color:inherit;font:inherit;cursor:pointer;background:0 0;border-radius:6px;padding:5px 9px}.xXzfkq_retry:disabled{opacity:.6;cursor:default}.xXzfkq_retry:focus-visible{outline-offset:2px;outline:2px solid}.xXzfkq_window{margin-top:14px}.xXzfkq_row{justify-content:space-between;margin-bottom:5px;display:flex}.xXzfkq_cache{border-top:1px solid color-mix(in srgb, currentColor 18%, transparent);margin-top:16px;padding-top:12px}.xXzfkq_cache>strong{margin-bottom:10px;display:block}.xXzfkq_stats{grid-template-columns:1fr auto;gap:5px 10px;display:grid}.xXzfkq_stats dd{text-align:right;font-variant-numeric:tabular-nums;margin:0}.xXzfkq_window progress{appearance:none;background:color-mix(in srgb, currentColor 15%, transparent);border:0;border-radius:4px;width:100%;height:5px;margin-bottom:5px;display:block}.xXzfkq_window progress::-webkit-progress-bar{background:0 0;border-radius:4px}.xXzfkq_window progress::-webkit-progress-value{background:#39a878;border-radius:4px}.xXzfkq_window progress::-moz-progress-bar{background:#39a878;border-radius:4px}";
1425
1619
  document.head.appendChild(style);
1426
1620
  }
1427
- var UsagePill_default = { "trigger": "dmPm3q_trigger", "panel": "dmPm3q_panel", "hint": "dmPm3q_hint", "root": "dmPm3q_root", "retry": "dmPm3q_retry", "row": "dmPm3q_row", "warning": "dmPm3q_warning", "window": "dmPm3q_window" };
1621
+ var UsagePill_default = { "warning": "xXzfkq_warning", "stats": "xXzfkq_stats", "trigger": "xXzfkq_trigger", "hint": "xXzfkq_hint", "panel": "xXzfkq_panel", "row": "xXzfkq_row", "window": "xXzfkq_window", "root": "xXzfkq_root", "retry": "xXzfkq_retry", "cache": "xXzfkq_cache" };
1428
1622
 
1429
- // src/client/UsagePill.tsx
1623
+ // src/client/SessionCache.tsx
1430
1624
  var import_jsx_runtime3 = require("react/jsx-runtime");
1625
+ function SessionCache({ events, t, getLocale }) {
1626
+ const source = (0, import_react3.useMemo)(() => sessionCacheSource(events), [events]);
1627
+ const stats = (0, import_react3.useSyncExternalStore)(source.subscribe, source.getSnapshot, source.getSnapshot);
1628
+ const format = new Intl.NumberFormat(getLocale?.());
1629
+ const ratio = stats.inputTokens > 0 ? new Intl.NumberFormat(getLocale?.(), { style: "percent", maximumFractionDigits: 1 }).format(stats.cacheReadTokens / stats.inputTokens) : "\u2014";
1630
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("section", { className: UsagePill_default.cache, "aria-label": t("cacheTitle"), children: [
1631
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("strong", { children: t("cacheTitle") }),
1632
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: UsagePill_default.row, children: [
1633
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: t("cacheReadRatio") }),
1634
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("strong", { children: ratio })
1635
+ ] }),
1636
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("dl", { className: UsagePill_default.stats, children: [
1637
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("dt", { children: t("cacheReadTokens") }),
1638
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("dd", { children: format.format(stats.cacheReadTokens) }),
1639
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("dt", { children: t("cacheInputTokens") }),
1640
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("dd", { children: format.format(stats.inputTokens) }),
1641
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("dt", { children: t("cacheWriteTokens") }),
1642
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("dd", { children: format.format(stats.cacheWriteTokens) }),
1643
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("dt", { children: t("cacheResponses") }),
1644
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("dd", { children: format.format(stats.responses) })
1645
+ ] }),
1646
+ stats.responses === 0 && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: UsagePill_default.hint, children: t("cacheEmpty") }),
1647
+ stats.missingUsage + stats.unattributed > 0 && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("p", { className: UsagePill_default.hint, children: [
1648
+ t("cacheExcluded"),
1649
+ " ",
1650
+ format.format(stats.missingUsage + stats.unattributed)
1651
+ ] }),
1652
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("p", { className: UsagePill_default.hint, children: [
1653
+ t("cacheScope"),
1654
+ stats.hasMore ? ` ${t("cacheMore")}` : ""
1655
+ ] }),
1656
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: UsagePill_default.hint, children: t("cacheRoutingHint") })
1657
+ ] });
1658
+ }
1659
+
1660
+ // src/client/UsagePill.tsx
1661
+ var import_jsx_runtime4 = require("react/jsx-runtime");
1431
1662
  function usageFailure(error) {
1432
1663
  if (error && typeof error === "object" && "code" in error && error.code === "opencode-go/usage-unavailable" && "details" in error && error.details && typeof error.details === "object") {
1433
1664
  const details = error.details;
@@ -1440,18 +1671,18 @@ function usageFailure(error) {
1440
1671
  return { retainPrevious: false };
1441
1672
  }
1442
1673
  function UsagePill({ directory, ...props }) {
1443
- const state = (0, import_react3.useSyncExternalStore)(directory.subscribe, directory.getSnapshot, directory.getSnapshot);
1444
- return state.current?.provider === "opencode-go" ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ActiveUsage, { ...props }) : null;
1674
+ const state = (0, import_react4.useSyncExternalStore)(directory.subscribe, directory.getSnapshot, directory.getSnapshot);
1675
+ return state.current?.provider === "opencode-go" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ActiveUsage, { ...props }) : null;
1445
1676
  }
1446
- function ActiveUsage({ readUsage, t, getLocale }) {
1447
- const [snapshot, setSnapshot] = (0, import_react3.useState)(null);
1448
- const [failed, setFailed] = (0, import_react3.useState)(null);
1449
- const [refreshing, setRefreshing] = (0, import_react3.useState)(false);
1450
- const [open, setOpen] = (0, import_react3.useState)(false);
1451
- const root = (0, import_react3.useRef)(null);
1452
- const retry = (0, import_react3.useRef)(() => {
1677
+ function ActiveUsage({ readUsage, t, getLocale, sessionEvents }) {
1678
+ const [snapshot, setSnapshot] = (0, import_react4.useState)(null);
1679
+ const [failed, setFailed] = (0, import_react4.useState)(null);
1680
+ const [refreshing, setRefreshing] = (0, import_react4.useState)(false);
1681
+ const [open, setOpen] = (0, import_react4.useState)(false);
1682
+ const root = (0, import_react4.useRef)(null);
1683
+ const retry = (0, import_react4.useRef)(() => {
1453
1684
  });
1454
- (0, import_react3.useEffect)(() => {
1685
+ (0, import_react4.useEffect)(() => {
1455
1686
  let alive = true;
1456
1687
  let busy = false;
1457
1688
  setSnapshot(null);
@@ -1497,7 +1728,7 @@ function ActiveUsage({ readUsage, t, getLocale }) {
1497
1728
  document.removeEventListener("visibilitychange", visible);
1498
1729
  };
1499
1730
  }, [readUsage]);
1500
- (0, import_react3.useEffect)(() => {
1731
+ (0, import_react4.useEffect)(() => {
1501
1732
  if (!open) return;
1502
1733
  const click = (event) => {
1503
1734
  if (!root.current?.contains(event.target)) setOpen(false);
@@ -1516,8 +1747,8 @@ function ActiveUsage({ readUsage, t, getLocale }) {
1516
1747
  const usage = current?.usage;
1517
1748
  const failure = failed?.reader === readUsage ? failed.failure : null;
1518
1749
  const label = usage ? `Go \xB7 ${t("usageRollingShort")} ${usage.rolling.percent}% \xB7 ${t("usageWeekShort")} ${usage.weekly.percent}%${failure ? ` \xB7 ${t("usageStaleShort")}` : ""}` : `Go \xB7 ${failure ? t("usageUnavailable") : "\u2026"}`;
1519
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { className: UsagePill_default.root, ref: root, children: [
1520
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1750
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { className: UsagePill_default.root, ref: root, children: [
1751
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1521
1752
  "button",
1522
1753
  {
1523
1754
  type: "button",
@@ -1531,15 +1762,15 @@ function ActiveUsage({ readUsage, t, getLocale }) {
1531
1762
  children: label
1532
1763
  }
1533
1764
  ),
1534
- open && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: UsagePill_default.panel, role: "dialog", "aria-label": t("usageTitle"), "aria-busy": refreshing, children: [
1535
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("strong", { children: t("usageTitle") }),
1536
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { className: UsagePill_default.hint, children: t("usageHint") }),
1537
- failure ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: UsagePill_default.warning, role: "alert", children: [
1538
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("strong", { children: t("usageRefreshFailed") }),
1539
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { children: failure.message ?? t("usageUnavailable") }),
1540
- usage ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { children: t("usageStaleHint") }) : null
1765
+ open && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: UsagePill_default.panel, role: "dialog", "aria-label": t("usageTitle"), "aria-busy": refreshing, children: [
1766
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("strong", { children: t("usageTitle") }),
1767
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { className: UsagePill_default.hint, children: t("usageHint") }),
1768
+ failure ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: UsagePill_default.warning, role: "alert", children: [
1769
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("strong", { children: t("usageRefreshFailed") }),
1770
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { children: failure.message ?? t("usageUnavailable") }),
1771
+ usage ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { children: t("usageStaleHint") }) : null
1541
1772
  ] }) : null,
1542
- failure ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1773
+ failure ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1543
1774
  "button",
1544
1775
  {
1545
1776
  type: "button",
@@ -1551,27 +1782,28 @@ function ActiveUsage({ readUsage, t, getLocale }) {
1551
1782
  children: t(refreshing ? "usageRefreshing" : "usageRetry")
1552
1783
  }
1553
1784
  ) : null,
1554
- current ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("p", { className: UsagePill_default.hint, children: [
1785
+ current ? /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("p", { className: UsagePill_default.hint, children: [
1555
1786
  t("usageLastUpdated"),
1556
1787
  " ",
1557
1788
  new Date(current.updatedAt).toLocaleString(getLocale?.())
1558
1789
  ] }) : null,
1559
- usage ? ["rolling", "weekly", "monthly"].map((key) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: UsagePill_default.window, children: [
1560
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: UsagePill_default.row, children: [
1561
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: t(`usage_${key}`) }),
1562
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("strong", { children: [
1790
+ usage ? ["rolling", "weekly", "monthly"].map((key) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: UsagePill_default.window, children: [
1791
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: UsagePill_default.row, children: [
1792
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: t(`usage_${key}`) }),
1793
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("strong", { children: [
1563
1794
  usage[key].percent,
1564
1795
  "%"
1565
1796
  ] })
1566
1797
  ] }),
1567
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("progress", { "aria-label": t(`usage_${key}`), max: 100, value: Math.min(100, usage[key].percent) }),
1568
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { className: UsagePill_default.hint, children: [
1798
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("progress", { "aria-label": t(`usage_${key}`), max: 100, value: Math.min(100, usage[key].percent) }),
1799
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className: UsagePill_default.hint, children: [
1569
1800
  t("usageResets"),
1570
1801
  " ",
1571
1802
  new Date(usage[key].resetsAt).toLocaleString(getLocale?.())
1572
1803
  ] }),
1573
- usage[key].status === "rate-limited" && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { children: t("usageLimited") })
1574
- ] }, key)) : failure ? null : /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { children: t("usageLoading") })
1804
+ usage[key].status === "rate-limited" && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { children: t("usageLimited") })
1805
+ ] }, key)) : failure ? null : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { children: t("usageLoading") }),
1806
+ sessionEvents && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(SessionCache, { events: sessionEvents, t, getLocale })
1575
1807
  ] })
1576
1808
  ] });
1577
1809
  }
@@ -1592,6 +1824,7 @@ function registerUsagePill(ctx) {
1592
1824
  order: 1e3,
1593
1825
  inject: (sessionId) => ({
1594
1826
  directory: ready.modelDirectories.directoryFor(sessionId).store,
1827
+ sessionEvents: sessionEventSource(ready.get("sessions"), sessionId),
1595
1828
  readUsage,
1596
1829
  getLocale: () => ready.locale.getLocale().active,
1597
1830
  t: (key) => translate(key)