@yuriai/web 0.2.6 → 0.2.8-beta.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.
- package/README.md +7 -0
- package/dist/assets/{AssistantView-Ct7V8lpF.js → AssistantView-Df-G2DX8.js} +3 -3
- package/dist/assets/{DiagramView-Ch2D2gUQ.js → DiagramView-BoVqJRQb.js} +1 -1
- package/dist/assets/{GuiPluginSurface-sdtt33qQ.js → GuiPluginSurface-DxLoeTDb.js} +1 -1
- package/dist/assets/MarkdownRenderer-DYi_qpYy.js +2 -0
- package/dist/assets/{MarkdownRendererImpl-CtfnAdo-.js → MarkdownRendererImpl-CMxRMFqp.js} +1 -1
- package/dist/assets/{MarkstreamRendererImpl-CWtvbZSX.js → MarkstreamRendererImpl-DQ4urBZW.js} +1 -1
- package/dist/assets/{MobileDetailNavigation-CUx-H4fe.js → MobileDetailNavigation-C4fJlKdu.js} +1 -1
- package/dist/assets/{MobileShareBridge-DUwPWQNz.js → MobileShareBridge-DLC-TdRy.js} +1 -1
- package/dist/assets/{MobileTabPageHeader-BtLdnDa3.js → MobileTabPageHeader-CMbbtHh7.js} +1 -1
- package/dist/assets/{MultiRunWindow-Gs-5PM3Z.js → MultiRunWindow-Cwp8-_Wh.js} +1 -1
- package/dist/assets/{SettingsView-BJy3bKbz.js → SettingsView-CYDk0wpN.js} +1 -1
- package/dist/assets/{SettingsWindow-w3K1Dbo1.js → SettingsWindow-Vuzphf9b.js} +1 -1
- package/dist/assets/{TerminalView-DnmN2KHj.js → TerminalView-Dhalx6_Z.js} +1 -1
- package/dist/assets/{ToolOutputDialog-Ctr_rqwb.js → ToolOutputDialog-DBxSxWNh.js} +1 -1
- package/dist/assets/{appThemeRegistry-3MgV1x6f.js → appThemeRegistry-JEhMXHGF.js} +1 -1
- package/dist/assets/{capgoAdapter-CpthNQYY.js → capgoAdapter-BgD0wyhC.js} +1 -1
- package/dist/assets/{fileMentionTouchSelection-1havvnZN.js → fileMentionTouchSelection-BQdfRBkk.js} +1 -1
- package/dist/assets/{gitApi-Bw4AQDuA.js → gitApi-DhDVqj9b.js} +1 -1
- package/dist/assets/{insertionBoundaries-_8AmjaTs.js → insertionBoundaries-BMe1F3uB.js} +1 -1
- package/dist/assets/{main-C09TKUe7.js → main-CfOYzhn0.js} +4 -4
- package/dist/assets/{main-C5PgzX4P.js → main-DXlMu2LF.js} +2 -2
- package/dist/assets/{mcpQueries-B-cYFZaO.js → mcpQueries-vxcQAIGB.js} +1 -1
- package/dist/assets/{miniChat-C_az-fSk.js → miniChat-D48iGEEW.js} +2 -2
- package/dist/assets/{mobile-CnXTR6QC.js → mobile-Cy5qSiDY.js} +2 -2
- package/dist/assets/{mobileBackNavigation-DSDlOhh6.js → mobileBackNavigation-QtBK9OSb.js} +1 -1
- package/dist/assets/{multirun-DgLVkagL.js → multirun-BR9a6EBo.js} +1 -1
- package/dist/assets/{native-config-w5ntuSb5.js → native-config-CHySeHif.js} +1 -1
- package/dist/assets/{projectMeta-OMvGIxob.js → projectMeta-Bn2vBNDe.js} +1 -1
- package/dist/assets/{readiness-6XMJtgLY.js → readiness-BAssoNVf.js} +1 -1
- package/dist/assets/{renderElectronMiniChatApp-rvO-rcnc.js → renderElectronMiniChatApp-B9Kci_8q.js} +2 -2
- package/dist/assets/{renderMobileApp-DheZQr5N.js → renderMobileApp-CBivL8Ps.js} +4 -4
- package/dist/assets/{runtimeConfig-cAbdKbv6.js → runtimeConfig-COdEwlK-.js} +1 -1
- package/dist/assets/{runtimeEndpointReset-CPsJLvK2.js → runtimeEndpointReset-D3x76Qpf.js} +3 -3
- package/dist/assets/{sessionChangeSummary-BEB6JZpN.js → sessionChangeSummary-Dtgq0CWg.js} +1 -1
- package/dist/assets/{sessionLookup-BI5wTzCJ.js → sessionLookup--Wlr3e8X.js} +1 -1
- package/dist/assets/{speechSettingsQueries-DZ9a20QR.js → speechSettingsQueries-D3fc_4Iy.js} +1 -1
- package/dist/assets/types-D8_26ZKT.js +2 -0
- package/dist/assets/{useAppFontEffects-CKCYZ3VJ.js → useAppFontEffects-DLT9jVl1.js} +6 -6
- package/dist/assets/{useDesktopWindowControlsLayout-CloJ_VZ3.js → useDesktopWindowControlsLayout-BNAZWH9L.js} +1 -1
- package/dist/assets/{useEffectiveDirectory-CuajC8G4.js → useEffectiveDirectory-D2_-KCB7.js} +1 -1
- package/dist/assets/{useMobileNavigationStore-07uYrwvK.js → useMobileNavigationStore-DJwk64Po.js} +3 -3
- package/dist/assets/{useWorkerHighlightedLines-2Vw7Hzud.js → useWorkerHighlightedLines-k48txabk.js} +1 -1
- package/dist/index.html +5 -5
- package/dist/mini-chat.html +5 -5
- package/dist/mobile.html +5 -5
- package/package.json +9 -4
- package/server/index.js +3 -3
- package/server/lib/assistants/DOCUMENTATION.md +12 -1
- package/server/lib/assistants/contact-tools.js +2 -2
- package/server/lib/assistants/harness.js +21 -17
- package/server/lib/assistants/harness.test.js +19 -23
- package/server/lib/assistants/memory.http.test.js +2 -2
- package/server/lib/assistants/routes.js +1 -3
- package/server/lib/llm/DOCUMENTATION.md +116 -161
- package/server/lib/llm/bridge-client.js +60 -0
- package/server/lib/llm/bridge-client.test.js +35 -0
- package/server/lib/llm/bridge-contract.js +24 -0
- package/server/lib/llm/bridge-plugin.bundle.js +1136 -0
- package/server/lib/llm/bridge-plugin.js +127 -0
- package/server/lib/llm/bridge-plugin.test.js +164 -0
- package/server/lib/llm/completions.js +42 -18
- package/server/lib/llm/completions.test.js +8 -4
- package/server/lib/llm/generate.js +43 -728
- package/server/lib/llm/generate.test.js +62 -1063
- package/server/lib/llm/routes.js +0 -2
- package/server/lib/package-manager.js +1 -1
- package/server/lib/small-model/DOCUMENTATION.md +11 -17
- package/server/lib/small-model/index.js +5 -4
- package/dist/assets/MarkdownRenderer-C1giOHSB.js +0 -2
- package/dist/assets/types-BihDq7ZW.js +0 -2
- package/server/lib/llm/temp-directory.js +0 -58
- package/server/lib/llm/temp-directory.test.js +0 -57
package/server/lib/llm/routes.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { createChatCompletion, LlmError } from './completions.js';
|
|
2
2
|
import { loadConnectedCatalog } from './catalog.js';
|
|
3
3
|
import { OpenCode } from '@opencode/client';
|
|
4
|
-
import { ensureLlmTempDirectory } from './temp-directory.js';
|
|
5
4
|
|
|
6
5
|
const fail = (res, error) => {
|
|
7
6
|
const code = error instanceof LlmError ? error.code : error?.code || 'internal_error';
|
|
@@ -39,7 +38,6 @@ export const registerLlmRoutes = (app, dependencies) => {
|
|
|
39
38
|
buildOpenCodeUrl: dependencies.buildOpenCodeUrl,
|
|
40
39
|
getOpenCodeAuthHeaders: dependencies.getOpenCodeAuthHeaders,
|
|
41
40
|
clientFactory: client,
|
|
42
|
-
ensureTempDirectory: ensureLlmTempDirectory,
|
|
43
41
|
persistSessionMetadata: dependencies.persistSessionMetadata,
|
|
44
42
|
onSystemSessionPersisted: dependencies.onSystemSessionPersisted,
|
|
45
43
|
}))
|
|
@@ -40,7 +40,7 @@ function sanitizeInstallScope(scope) {
|
|
|
40
40
|
return 'web';
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
function getOrCreateInstallId(scope = 'web') {
|
|
43
|
+
export function getOrCreateInstallId(scope = 'web') {
|
|
44
44
|
const configDir = getYuriConfigDir();
|
|
45
45
|
const normalizedScope = sanitizeInstallScope(scope);
|
|
46
46
|
const idPath = path.join(configDir, `install-id-${normalizedScope}`);
|
|
@@ -24,9 +24,7 @@ runtime API.
|
|
|
24
24
|
obtains a single lazy instance from `server/index.js` (`getSmallModelService`)
|
|
25
25
|
and injects it into feature routes, session assist/title/goal, and scheduled
|
|
26
26
|
tasks. Tests may inject `getModelCatalog`, `openCodeClientFactory`, and
|
|
27
|
-
`createChatCompletion`. The
|
|
28
|
-
`onSystemSessionPersisted` so gateway throwaway sessions stay out of the
|
|
29
|
-
sidebar index.
|
|
27
|
+
`createChatCompletion`. The gateway performs no temporary Session creation.
|
|
30
28
|
- `resolve.js` — model selection over the connected catalog only, mirroring
|
|
31
29
|
OpenCode's `getSmallModel` chain:
|
|
32
30
|
0. Yuri's own settings override (Settings → Sessions → Small Model):
|
|
@@ -87,10 +85,11 @@ runtime API.
|
|
|
87
85
|
| Every other purpose | `resolve.js` over the connected catalog → LLM gateway |
|
|
88
86
|
|
|
89
87
|
The LLM gateway checks the model against the connected catalog (`no_provider`
|
|
90
|
-
otherwise)
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
88
|
+
otherwise), then uses the built-in clean-inference plugin over authenticated RPC
|
|
89
|
+
to the external OpenCode service (see `llm/DOCUMENTATION.md`). No Session API,
|
|
90
|
+
agent prompt, Skills, session history or tool loop is involved. Output-token
|
|
91
|
+
limits are forwarded. Unsupported provider/authentication adapters fail explicitly
|
|
92
|
+
instead of falling back to the previous session.generate path.
|
|
94
93
|
`restrictToPreferredProvider` forbids resolution from switching away from the
|
|
95
94
|
session's provider unless the model came from an explicit choice (settings
|
|
96
95
|
override, OpenCode config, or request `model`).
|
|
@@ -101,15 +100,10 @@ instead of silently switching models.
|
|
|
101
100
|
|
|
102
101
|
### Skills / clean context boundary
|
|
103
102
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
the guidance renders as "No skills are currently available." Skill **body**
|
|
109
|
-
content is only injected when the skill tool runs; deny-all also blocks that
|
|
110
|
-
tool. Global `~/.agents/skills` may still be *discovered* by the OpenCode
|
|
111
|
-
instance, but they are not listed or loadable under this agent. Project-level
|
|
112
|
-
skills are absent because the temp directory has none.
|
|
103
|
+
Only the explicit utility system/prompt messages are sent. OpenCode may discover
|
|
104
|
+
its global configuration/plugins to resolve the selected model, but neither skill
|
|
105
|
+
guidance nor bodies, AGENTS.md, agent instructions or Session history are part of
|
|
106
|
+
the inference input. Clean inference does not use the Session context builder.
|
|
113
107
|
|
|
114
108
|
## Registration
|
|
115
109
|
|
|
@@ -117,7 +111,7 @@ skills are absent because the temp directory has none.
|
|
|
117
111
|
`{ buildOpenCodeUrl, getOpenCodeAuthHeaders, persistSessionMetadata,
|
|
118
112
|
onSystemSessionPersisted }` into the factory (and the service into session
|
|
119
113
|
assist/title/goal, scheduled tasks, and `createFeatureRoutesRuntime`). Server
|
|
120
|
-
`stop()` calls `
|
|
114
|
+
`stop()` calls `stopLlmBridgeDirectory()` to remove the isolated plugin directory.
|
|
121
115
|
|
|
122
116
|
## Summary AI settings
|
|
123
117
|
|
|
@@ -144,9 +144,8 @@ export function createSmallModelService(dependencies) {
|
|
|
144
144
|
return { providerID, modelID, source: 'summary-default' };
|
|
145
145
|
};
|
|
146
146
|
|
|
147
|
-
// Every OpenCode-backed call shares the Assistant
|
|
148
|
-
|
|
149
|
-
const generateThroughGateway = async ({ resolved, prompt, system, directory }) => {
|
|
147
|
+
// Every OpenCode-backed call shares the clean Assistant inference gateway.
|
|
148
|
+
const generateThroughGateway = async ({ resolved, prompt, system, directory, maxOutputTokens }) => {
|
|
150
149
|
const catalog = await getModelCatalog(directory);
|
|
151
150
|
const clamped = clampPromptToModelLimit({ prompt, catalog, providerID: resolved.providerID, modelID: resolved.modelID });
|
|
152
151
|
const { completion } = await runChatCompletion({
|
|
@@ -163,6 +162,7 @@ export function createSmallModelService(dependencies) {
|
|
|
163
162
|
clientFactory: openCodeClient,
|
|
164
163
|
persistSessionMetadata,
|
|
165
164
|
onSystemSessionPersisted,
|
|
165
|
+
maxOutputTokens,
|
|
166
166
|
}).catch((error) => {
|
|
167
167
|
const message = summaryErrorMessage(error);
|
|
168
168
|
throw Object.assign(new Error(message), {
|
|
@@ -217,7 +217,7 @@ export function createSmallModelService(dependencies) {
|
|
|
217
217
|
}
|
|
218
218
|
|
|
219
219
|
const resolved = await resolveSummaryProviderModel(summarySettings, directory);
|
|
220
|
-
return generateThroughGateway({ resolved, prompt, system: effectiveSystem, directory });
|
|
220
|
+
return generateThroughGateway({ resolved, prompt, system: effectiveSystem, directory, maxOutputTokens });
|
|
221
221
|
}
|
|
222
222
|
|
|
223
223
|
const resolveCustomApiInput = (body = {}) => {
|
|
@@ -306,6 +306,7 @@ export function createSmallModelService(dependencies) {
|
|
|
306
306
|
prompt: prompt.trim(),
|
|
307
307
|
system: typeof system === 'string' && system.trim() ? system.trim() : undefined,
|
|
308
308
|
directory,
|
|
309
|
+
maxOutputTokens,
|
|
309
310
|
});
|
|
310
311
|
}
|
|
311
312
|
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/MarkstreamRendererImpl-CWtvbZSX.js","assets/rolldown-runtime-hePW80VL.js","assets/vendor-base-ui-CdzJ6My_.js","assets/useUIStore-NMQx_cnG.js","assets/runtime-switch-CAZiOV2G.js","assets/runtime-auth-ef9W7A43.js","assets/vendor-zustand-o69pgTEK.js","assets/brand-storage-bootstrap-D4BW3w-M.js","assets/brand-storage-migration-Bhz6UOBJ.js","assets/vendor-react-BP2cRVqX.js","assets/fileQueries-DbUx7NwP.js","assets/vendor-tanstack-react-query-CdqCAt40.js","assets/vendor-tanstack-query-core-BWz0ose6.js","assets/queryRuntime-BuRnpVtK.js","assets/runtime-fetch-BAN5Gnnp.js","assets/vendor-markstream-react-Bm0cO70Z.js","assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js","assets/vendor-markstream-core-Cm34iPLL.js","assets/vendor-floating-ui-dom-BHhLtF5l.js","assets/vendor-floating-ui-core-Co1I1lFV.js","assets/vendor-reactuses-core-BpfIZ1tg.js","assets/vendor-lodash-es-DfLbG5Af.js","assets/vendor-js-cookie-hSOiFTtX.js","assets/button-BSFWH-Ok.js","assets/desktop-dp2Z0toS.js","assets/runtimeAPIRegistry-C2VogTny.js","assets/store-CgQdmzpX.js","assets/vendor-class-variance-authority-BLUaYARZ.js","assets/vendor-tailwind-merge-BicNWLTg.js","assets/useMobileNavigationStore-07uYrwvK.js","assets/platform-DXeTzJHG.js","assets/vendor-opencode-client-fxfj4IA_.js","assets/vendor-effect-DV9F8PTZ.js","assets/persistence-BfjCXjLZ.js","assets/pathNormalization-ewtPqJWn.js","assets/vendor-pathe-vBmvQE8f.js","assets/runtime-file-resource-D3k0hKDj.js","assets/runtime-file-store-BVRgEtI-.js","assets/path-utils-jGozTg9d.js","assets/vendor-sonner-ZS8XIOVl.js","assets/useAssistantUIStore-D7JZlg_Q.js","assets/vendor-zod-Dzk5kdUU.js","assets/vendor-fuse.js-DB5wDJbI.js","assets/useThemeSystem-8jhE4Zyk.js","assets/tooltip-DygQ-2xe.js","assets/image-loading-FUFYiO1j.js","assets/image-loading-D9Z_BASK.css","assets/url-MRa-FtQa.js","assets/useEffectiveDirectory-CuajC8G4.js","assets/LoadingImage-B7cT_4Oe.js","assets/ImageLoadingPlaceholder-CUKFQTAG.js","assets/markdownHeightCache-DV2j4PlS.js","assets/dualLimitLru-D8Sphgua.js","assets/MarkdownRendererImpl-CtfnAdo-.js","assets/vendor-katex-DNVSTX6g.js","assets/FadeInOnReveal-DkmfVoTO.js","assets/markdownTheme-DHoKvD6O.js","assets/vendor-pierre-diffs-DPBtNDJ5.js","assets/vendor-hast-util-to-html-Bw_SgZ1t.js","assets/vendor-character-entities-legacy-Wut6vMuj.js","assets/vendor-character-entities-html4-DlN_yAFd.js","assets/vendor-ccount-CyGsA0u7.js","assets/vendor-comma-separated-tokens-B9ouxNNS.js","assets/vendor-oniguruma-to-es-CrHzjjSU.js","assets/vendor-oniguruma-parser-D2DIvhSP.js","assets/vendor-diff-Dq7CZNim.js","assets/vendor-lru_map-BMOrLc9L.js","assets/markdown-worker-oBGEB9Eg.js","assets/vendor-morphdom-BbKiNDAu.js","assets/vendor-dompurify-CeJNOzik.js","assets/vendor-pele-C1WTNWUm.js","assets/vendor-marked-WVekxjAN.js","assets/vendor-remend-C3cXc-tf.js","assets/fileReferenceActions-No7p4Kdo.js","assets/toolHelpers-DL452NVK.js","assets/fileReferenceParser-1HHDBUum.js","assets/MarkstreamRendererImpl-EpBnVy9J.css"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{r as e}from"./rolldown-runtime-hePW80VL.js";import{a as t}from"./vendor-zustand-o69pgTEK.js";import{it as n,rt as r}from"./vendor-base-ui-CdzJ6My_.js";import"./brand-storage-bootstrap-D4BW3w-M.js";import{n as i}from"./vendor-react-BP2cRVqX.js";import{o as a}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";import{r as o}from"./button-BSFWH-Ok.js";import{t as s}from"./useEffectiveDirectory-CuajC8G4.js";import{i as c,n as l,t as u}from"./markdownHeightCache-DV2j4PlS.js";var d=i(),f=e(n(),1),p=`yuri:chunk-import-reload`,m=250,h=3e4,g=[/Importing a module script failed/i,/Failed to fetch dynamically imported module/i,/error loading dynamically imported module/i,/Loading chunk \S+ failed/i,/ChunkLoadError/i];function _(e){if(e instanceof Error)return`${e.name}\n${e.message}\n${e.stack??``}`;if(typeof e==`string`)return e;try{return JSON.stringify(e)}catch{return String(e)}}function v(e){let t=_(e);return g.some(e=>e.test(t))}function y(e){return`0.2.6:${_(e).slice(0,500)}`}function b(e){if(typeof window>`u`)return;let t=Date.now(),n=y(e),r=null;try{let e=window.sessionStorage.getItem(p);if(e)try{r=JSON.parse(e)}catch{r=null}}catch{return}let i=typeof r?.timestamp==`number`?r.timestamp:0;if(!(r?.signature===n&&t-i<h)){try{window.sessionStorage.setItem(p,JSON.stringify({signature:n,timestamp:t}))}catch{return}console.error(`[refresh-debug] chunk-import-reload`,{error:_(e).slice(0,1e3)}),window.setTimeout(()=>{window.location.reload()},0)}}async function x(e,t={}){let n=t.retries??1,r;for(let t=0;t<=n;t+=1)try{return await e()}catch(e){if(r=e,!v(e)||t>=n)break;await new Promise(e=>setTimeout(e,m*(t+1)))}throw v(r)&&b(r),r}var S=e=>(0,f.lazy)(()=>x(e)),C=(e,t)=>!!t?.toLowerCase().startsWith(`video/`)||/^data:video\//i.test(e)||/\.(?:mp4|m4v|webm|mov|ogv|ogg)(?:[?#]|$)/i.test(e),w=(e,t)=>{try{let n=t??(typeof localStorage>`u`?null:localStorage);return!n||n.getItem(e)!==`0`}catch{return!0}},T=(e,t)=>{try{typeof localStorage<`u`&&localStorage.setItem(e,t?`1`:`0`)}catch{}},E=`yuri:markstream-react`,D=e=>w(E,e),O=t(e=>({markstreamReactEnabled:D(),setMarkstreamReactEnabled:t=>{T(E,t),e({markstreamReactEnabled:t})}})),k=null,A=()=>(k??=a(()=>import(`./MarkstreamRendererImpl-CWtvbZSX.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76])).catch(e=>{throw k=null,e}),k),j=()=>{A().catch(()=>void 0)},M=null,N=()=>(M??=a(()=>import(`./MarkdownRendererImpl-CtfnAdo-.js`).then(e=>e.n),__vite__mapDeps([53,1,4,5,24,25,2,30,14,6,31,32,7,8,3,33,9,13,12,34,35,36,10,11,37,38,16,54,20,21,22,23,26,27,28,29,39,40,41,42,52,43,45,46,47,48,55,51,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75])).catch(e=>{throw M=null,e}),M),P=()=>{N().catch(()=>void 0),D()&&j()},F=class extends f.Component{state={hasError:!1};static getDerivedStateFromError(){return{hasError:!0}}componentDidCatch(e){console.warn(`[markstream-react] falling back to the current Markdown renderer`,e)}render(){return this.state.hasError?this.props.fallback:this.props.children}},I=f.createContext(!0),L=()=>f.useContext(I),R=r(),z=S(()=>N().then(e=>({default:e.MarkdownRenderer}))),B=S(()=>A().then(e=>({default:e.MarkstreamRenderer}))),V=S(()=>N().then(e=>({default:e.SimpleMarkdownRenderer}))),H=e=>e===`tool`?`markdown-content markdown-tool`:e===`reasoning`?`markdown-content markdown-reasoning`:`markdown-content leading-relaxed`,U=e=>{let t=(0,d.c)(15),n=O(K),r=typeof e.content==`string`?e.content:``,i=typeof e.variant==`string`?e.variant:`assistant`,a;t[0]!==r||t[1]!==n||t[2]!==e.reserveMeasuredHeight||t[3]!==i?(a=e.reserveMeasuredHeight?l(u(r,n?`markstream:${i}`:i)):void 0,t[0]=r,t[1]=n,t[2]=e.reserveMeasuredHeight,t[3]=i,t[4]=a):a=t[4];let s=a,f;t[5]!==e.className||t[6]!==e.variant?(f=o(`relative break-words w-full min-w-0`,H(e.variant),typeof e.className==`string`?e.className:void 0),t[5]=e.className,t[6]=e.variant,t[7]=f):f=t[7];let p;t[8]!==r||t[9]!==e.animated||t[10]!==s?(p=(0,R.jsx)(c,{animated:e.animated,content:r,reservedHeight:s}),t[8]=r,t[9]=e.animated,t[10]=s,t[11]=p):p=t[11];let m;return t[12]!==f||t[13]!==p?(m=(0,R.jsx)(`div`,{className:f,"aria-busy":`true`,"data-markdown-hydration":`deferred`,"data-markdown-ready":`false`,children:p}),t[12]=f,t[13]=p,t[14]=m):m=t[14],m},W=e=>{let t=(0,d.c)(13),n=L(),r=O(q);if(!n&&e.isStreaming!==!0){let n;return t[0]===e?n=t[1]:(n=(0,R.jsx)(U,{...e,animated:!1,reserveMeasuredHeight:!0}),t[0]=e,t[1]=n),n}let i;t[2]===e?i=t[3]:(i=(0,R.jsx)(f.Suspense,{fallback:(0,R.jsx)(U,{...e,reserveMeasuredHeight:!0}),children:(0,R.jsx)(z,{...e})}),t[2]=e,t[3]=i);let a=i,o;t[4]!==a||t[5]!==r||t[6]!==e?(o=r?(0,R.jsx)(F,{fallback:a,children:(0,R.jsx)(f.Suspense,{fallback:(0,R.jsx)(U,{...e,reserveMeasuredHeight:!0}),children:(0,R.jsx)(B,{...e})})}):a,t[4]=a,t[5]=r,t[6]=e,t[7]=o):o=t[7];let c=o,l;t[8]===e?l=t[9]:(l=t=>{if(!e.onShowPopup||t.button!==0||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey)return;let n=t.target instanceof Element?t.target.closest(`a[href]`):null,r=n?.getAttribute(`href`);if(!r||!C(r))return;t.preventDefault(),t.stopPropagation();let i=n?.textContent?.trim()||r.split(/[/?#]/).filter(Boolean).pop()||r;e.onShowPopup({open:!0,title:i,content:``,video:{url:r,filename:i,directory:s()??``}})},t[8]=e,t[9]=l);let u;return t[10]!==c||t[11]!==l?(u=(0,R.jsx)(`div`,{className:`contents`,onClickCapture:l,children:c}),t[10]=c,t[11]=l,t[12]=u):u=t[12],u},G=e=>{let t=(0,d.c)(4);if(!L()){let n;return t[0]===e?n=t[1]:(n=(0,R.jsx)(U,{...e,animated:!1}),t[0]=e,t[1]=n),n}let n;return t[2]===e?n=t[3]:(n=(0,R.jsx)(f.Suspense,{fallback:(0,R.jsx)(U,{...e}),children:(0,R.jsx)(V,{...e})}),t[2]=e,t[3]=n),n};function K(e){return e.markstreamReactEnabled}function q(e){return e.markstreamReactEnabled}export{C as a,P as i,G as n,S as o,I as r,W as t};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/vendor-capacitor-app-B5H_XtmE.js","assets/rolldown-runtime-hePW80VL.js","assets/vendor-aparajita-capacitor-secure-storage-xol_6BsB.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{n as e}from"./platform-DXeTzJHG.js";import{o as t}from"./vendor-aparajita-capacitor-secure-storage-xol_6BsB.js";var n=async()=>{if(!e())return null;let{App:n}=await t(async()=>{let{App:e}=await import(`./vendor-capacitor-app-B5H_XtmE.js`).then(e=>e.t);return{App:e}},__vite__mapDeps([0,1,2])),{id:r}=await n.getInfo();if(typeof r!=`string`||!/^[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)+$/.test(r))throw Error(`Native app identity unavailable`);return r},r=e=>typeof e==`string`&&e.trim().length>0?e.trim():null,i=()=>r(`0.2.6`),a=(e,t)=>r(t)||r(e),o=(e,t)=>{let n=r(e);return n?typeof t!=`number`||!Number.isFinite(t)?n:`${n} (${t})`:null},s=async()=>{let n=i();if(!e())return n;try{let{App:e}=await t(async()=>{let{App:e}=await import(`./vendor-capacitor-app-B5H_XtmE.js`).then(e=>e.t);return{App:e}},__vite__mapDeps([0,1,2]));return a((await e.getInfo()).version,n)}catch{return n}},c=async()=>{if(!e())return null;try{let{App:e}=await t(async()=>{let{App:e}=await import(`./vendor-capacitor-app-B5H_XtmE.js`).then(e=>e.t);return{App:e}},__vite__mapDeps([0,1,2])),n=await e.getInfo(),r=typeof n.build==`string`?n.build.trim():``;if(r.length===0)return null;let i=Number.parseInt(r,10);return Number.isFinite(i)?i:null}catch{return null}},l=class extends Error{code=`mobile_updates_unsupported`;constructor(e=`Mobile OTA updates are only available in the Capacitor native app`){super(e),this.name=`MobileUpdatesUnsupportedError`}};export{s as a,c as i,o as n,n as r,l as t};
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs/promises';
|
|
2
|
-
import os from 'node:os';
|
|
3
|
-
import path from 'node:path';
|
|
4
|
-
|
|
5
|
-
/** @type {string | null} */
|
|
6
|
-
let tempDirectory = null;
|
|
7
|
-
/** @type {Promise<string> | null} */
|
|
8
|
-
let inflight = null;
|
|
9
|
-
/** Serialize markdown refreshes so concurrent ensure cannot interleave one file. */
|
|
10
|
-
let writeChain = Promise.resolve();
|
|
11
|
-
|
|
12
|
-
const writeAgentMarkdown = async (root, agentName, agentMarkdown) => {
|
|
13
|
-
const agentDir = path.join(root, '.opencode', 'agent');
|
|
14
|
-
await fs.mkdir(agentDir, { recursive: true });
|
|
15
|
-
await fs.writeFile(path.join(agentDir, `${agentName}.md`), agentMarkdown, 'utf8');
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
const enqueueWrite = (work) => {
|
|
19
|
-
const run = writeChain.catch(() => {}).then(work);
|
|
20
|
-
writeChain = run.catch(() => {});
|
|
21
|
-
return run;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export async function ensureLlmTempDirectory({ agentName, agentMarkdown }) {
|
|
25
|
-
// Long-lived servers / HMR must refresh the hidden agent markdown so a
|
|
26
|
-
// permission-format fix is not stuck behind a stale temp directory.
|
|
27
|
-
// Concurrent first callers share one mkdtemp; every caller still writes its
|
|
28
|
-
// markdown after settle so a mid-flight ensure cannot skip a newer body.
|
|
29
|
-
// Concurrent warm writes are serialized (last committed body wins).
|
|
30
|
-
if (!tempDirectory) {
|
|
31
|
-
if (!inflight) {
|
|
32
|
-
inflight = (async () => {
|
|
33
|
-
const root = await fs.mkdtemp(path.join(os.tmpdir(), 'yuri-llm-'));
|
|
34
|
-
tempDirectory = root;
|
|
35
|
-
return root;
|
|
36
|
-
})().finally(() => {
|
|
37
|
-
inflight = null;
|
|
38
|
-
});
|
|
39
|
-
}
|
|
40
|
-
await inflight;
|
|
41
|
-
}
|
|
42
|
-
const root = tempDirectory;
|
|
43
|
-
await enqueueWrite(() => writeAgentMarkdown(root, agentName, agentMarkdown));
|
|
44
|
-
return root;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export async function stopLlmTempDirectory() {
|
|
48
|
-
const dir = tempDirectory;
|
|
49
|
-
tempDirectory = null;
|
|
50
|
-
inflight = null;
|
|
51
|
-
writeChain = Promise.resolve();
|
|
52
|
-
if (!dir) return;
|
|
53
|
-
try {
|
|
54
|
-
await fs.rm(dir, { recursive: true, force: true });
|
|
55
|
-
} catch {
|
|
56
|
-
// Best-effort cleanup of the throwaway generator workspace.
|
|
57
|
-
}
|
|
58
|
-
}
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import fs from 'node:fs/promises';
|
|
2
|
-
import path from 'node:path';
|
|
3
|
-
import { afterEach, describe, expect, it } from 'vitest';
|
|
4
|
-
import { ensureLlmTempDirectory, stopLlmTempDirectory } from './temp-directory.js';
|
|
5
|
-
|
|
6
|
-
const readAgent = async (root, agentName) =>
|
|
7
|
-
fs.readFile(path.join(root, '.opencode', 'agent', `${agentName}.md`), 'utf8');
|
|
8
|
-
|
|
9
|
-
afterEach(async () => {
|
|
10
|
-
await stopLlmTempDirectory();
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
describe('ensureLlmTempDirectory', () => {
|
|
14
|
-
it('shares one directory across concurrent first ensures and applies each markdown body', async () => {
|
|
15
|
-
const firstBody = '---\nname: a\n---\nFIRST\n';
|
|
16
|
-
const secondBody = '---\nname: a\n---\nSECOND\n';
|
|
17
|
-
const [first, second] = await Promise.all([
|
|
18
|
-
ensureLlmTempDirectory({ agentName: 'yuri-llm', agentMarkdown: firstBody }),
|
|
19
|
-
ensureLlmTempDirectory({ agentName: 'yuri-llm', agentMarkdown: secondBody }),
|
|
20
|
-
]);
|
|
21
|
-
expect(first).toBe(second);
|
|
22
|
-
const written = await readAgent(first, 'yuri-llm');
|
|
23
|
-
// Last writer wins; both callers must have completed a full write after settle.
|
|
24
|
-
expect(written === firstBody || written === secondBody).toBe(true);
|
|
25
|
-
expect(written).toMatch(/FIRST|SECOND/);
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it('refreshes markdown on a warm directory under concurrent ensure', async () => {
|
|
29
|
-
const root = await ensureLlmTempDirectory({
|
|
30
|
-
agentName: 'yuri-llm',
|
|
31
|
-
agentMarkdown: '---\nname: a\n---\nSEED\n',
|
|
32
|
-
});
|
|
33
|
-
const bodies = Array.from({ length: 8 }, (_, index) => `---\nname: a\n---\nREFRESH-${index}\n`);
|
|
34
|
-
const roots = await Promise.all(
|
|
35
|
-
bodies.map((agentMarkdown) => ensureLlmTempDirectory({ agentName: 'yuri-llm', agentMarkdown })),
|
|
36
|
-
);
|
|
37
|
-
expect(new Set(roots)).toEqual(new Set([root]));
|
|
38
|
-
const written = await readAgent(root, 'yuri-llm');
|
|
39
|
-
expect(bodies).toContain(written);
|
|
40
|
-
expect(written).toMatch(/REFRESH-\d+/);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
it('stop clears the singleton so the next ensure creates a fresh directory', async () => {
|
|
44
|
-
const first = await ensureLlmTempDirectory({
|
|
45
|
-
agentName: 'yuri-llm',
|
|
46
|
-
agentMarkdown: '---\nname: a\n---\nA\n',
|
|
47
|
-
});
|
|
48
|
-
await stopLlmTempDirectory();
|
|
49
|
-
const second = await ensureLlmTempDirectory({
|
|
50
|
-
agentName: 'yuri-llm',
|
|
51
|
-
agentMarkdown: '---\nname: a\n---\nB\n',
|
|
52
|
-
});
|
|
53
|
-
expect(second).not.toBe(first);
|
|
54
|
-
await expect(fs.access(first)).rejects.toThrow();
|
|
55
|
-
expect(await readAgent(second, 'yuri-llm')).toContain('B');
|
|
56
|
-
});
|
|
57
|
-
});
|