diff --git a/apps/computer/local-daemon/README.md b/apps/computer/local-daemon/README.md index da2de5d4..63f5e43c 100644 --- a/apps/computer/local-daemon/README.md +++ b/apps/computer/local-daemon/README.md @@ -151,6 +151,14 @@ model. Daemon rereads the status, which carries what the phase reserved or freed (pool use, placement, models unloaded first), and applies the job's line on top; later lines of the phase update that snapshot without another read. +- Error causes. `library status` keeps only a failed row's `code` and + `detail`; the `cause` and `path` of a `GATEWAY_REGISTRATION_FAILED` reach + the Daemon only on the job's error line (`GATEWAY_HOME_NOT_PRIVATE`: the + gateway's private folder at `path` has another owner). The Daemon keeps them + per model and puts them back on that row in every read while it still fails + with that code; the model's next accepted job, or a row that moved on, + drops them. They live in memory, so after a Daemon restart the row shows + only its code. - Pi. When the loaded models change, the Daemon asks the Runtime monitor for a full discovery, so TeamHub sees Pi's new model list. Each model's `pi_model` (`/`, as an Agent's `runtime_model` stores it) is diff --git a/apps/computer/local-daemon/internal/localmodels/library.go b/apps/computer/local-daemon/internal/localmodels/library.go index 58aee26a..f2a1cd05 100644 --- a/apps/computer/local-daemon/internal/localmodels/library.go +++ b/apps/computer/local-daemon/internal/localmodels/library.go @@ -11,6 +11,7 @@ import ( "log/slog" "os" "path/filepath" + "slices" "sort" "strings" "sync" @@ -92,8 +93,12 @@ type Library struct { current *wire.LocalModelsSnapshot // loaded identifies the loaded models of the last status read; nil // before the first one. - loaded *string - jobs map[string]*job + loaded *string + jobs map[string]*job + // causes holds, by model, the cause the last job's error line gave. The + // tool's status keeps only the code, so each read puts the cause back on + // a row that still fails with that code. + causes map[string]*wire.LocalModelError lastProgress time.Time progressTimer *time.Timer // progressTimerID tells a timer callback that already fired whether it @@ -113,7 +118,7 @@ func New(options Options) *Library { tool: options.Tool, environment: options.Environment, jobDirectory: options.JobDirectory, publish: options.Publish, runtimeChanged: options.RuntimeChanged, progressInterval: options.ProgressInterval, statusTimeout: options.StatusTimeout, actionTimeout: options.ActionTimeout, - now: time.Now, ctx: ctx, stop: stop, jobs: make(map[string]*job), + now: time.Now, ctx: ctx, stop: stop, jobs: make(map[string]*job), causes: make(map[string]*wire.LocalModelError), } if library.progressInterval <= 0 { library.progressInterval = defaultProgressInterval @@ -190,9 +195,25 @@ func (l *Library) read(ctx context.Context) wire.LocalModelsSnapshot { slog.Warn("local_models.status_invalid", "error", err) return unavailable(CodeToolFailed, "localmodels reported a library status outside its contract", l.now()) } + l.restoreCauses(&snapshot) return snapshot } +// restoreCauses puts each kept cause back on its failed row, and forgets one +// whose row no longer fails with the code it came with. +func (l *Library) restoreCauses(snapshot *wire.LocalModelsSnapshot) { + l.mu.Lock() + defer l.mu.Unlock() + for id, cause := range l.causes { + index := slices.IndexFunc(snapshot.Models, func(model wire.LocalModel) bool { return model.ID == id }) + if index < 0 || snapshot.Models[index].Error == nil || snapshot.Models[index].Error.Code != cause.Code { + delete(l.causes, id) + continue + } + snapshot.Models[index].Error.Cause, snapshot.Models[index].Error.Path = cause.Cause, cause.Path + } +} + // loadedKey names the loaded models; a change means Pi's model list changed. func loadedKey(snapshot wire.LocalModelsSnapshot) string { var loaded []string @@ -482,6 +503,7 @@ func (l *Library) superviseJob(action Action, events <-chan libraryEvent, ended if accepted { l.mu.Lock() l.jobs[action.Model] = &job{action: action} + delete(l.causes, action.Model) l.mu.Unlock() } } @@ -532,6 +554,11 @@ func (l *Library) superviseJob(action Action, events <-chan libraryEvent, ended } l.mu.Lock() delete(l.jobs, action.Model) + if final != nil && final.Event == "error" { + if cause := final.cause(); cause != nil { + l.causes[action.Model] = cause + } + } l.mu.Unlock() l.Refresh(l.ctx) if action.Name == ActionLoad { diff --git a/apps/computer/local-daemon/internal/localmodels/library_test.go b/apps/computer/local-daemon/internal/localmodels/library_test.go index 8b9ca26e..c2116696 100644 --- a/apps/computer/local-daemon/internal/localmodels/library_test.go +++ b/apps/computer/local-daemon/internal/localmodels/library_test.go @@ -622,3 +622,47 @@ func TestRefreshMapsRichModelCardMetadataAndKeepsItAcrossProgress(t *testing.T) t.Fatalf("progress dropped model card fields: %+v", after) } } + +// localmodels names why a load could not register with its gateway only on +// the job's error line; the snapshot's failed row carries it until another +// job for that model ends. +func TestAFailedLoadKeepsTheGatewayCauseOnItsRow(t *testing.T) { + fake := newFakeTool(t) + fake.write("status.json", status(model(testModel, "idle"))) + failed := model(testModel, "failed") + failed["error"] = map[string]any{"code": "GATEWAY_REGISTRATION_FAILED", "detail": "gateway-home is not private"} + encodedFailed, _ := json.Marshal(status(failed)) + const home = `C:\Users\ana\AppData\Local\localmodels\tools\gateway-home` + causeLine := errorLine(testModel, "GATEWAY_REGISTRATION_FAILED", `,"cause":"GATEWAY_HOME_NOT_PRIVATE","path":"C:\\Users\\ana\\AppData\\Local\\localmodels\\tools\\gateway-home"`) + fake.script("load", fakeScript{ + Lines: []fakeLine{{Line: progressLine(testModel, "load", 0, 2)}, {Line: causeLine, DelayMS: 20}}, + Exit: 1, StatusAfter: encodedFailed, + }) + record := &recorder{} + library := newLibrary(t, fake, record, 10*time.Millisecond) + library.Refresh(context.Background()) + + if refusal, _ := library.Act(context.Background(), Action{Name: ActionLoad, Model: testModel}, soon()); refusal != nil { + t.Fatalf("load refused: %+v", refusal) + } + waitFor(t, "the failed row with its cause", func() bool { + model := modelState(record.last(), testModel) + return model.State == "failed" && model.Error != nil && model.Error.Cause == "GATEWAY_HOME_NOT_PRIVATE" && model.Error.Path == home + }) + if again := modelState(library.Refresh(context.Background()), testModel); again.Error == nil || again.Error.Cause != "GATEWAY_HOME_NOT_PRIVATE" { + t.Fatalf("a later read dropped the cause: %+v", again.Error) + } + + // A retry that fails for another reason carries no stale cause. + fake.script("load", fakeScript{ + Lines: []fakeLine{{Line: progressLine(testModel, "load", 0, 2)}, {Line: errorLine(testModel, "GATEWAY_REGISTRATION_FAILED", ""), DelayMS: 20}}, + Exit: 1, StatusAfter: encodedFailed, + }) + if refusal, _ := library.Act(context.Background(), Action{Name: ActionLoad, Model: testModel}, soon()); refusal != nil { + t.Fatalf("retry refused: %+v", refusal) + } + waitFor(t, "the cause to clear", func() bool { + model := modelState(library.Refresh(context.Background()), testModel) + return model.Error != nil && model.Error.Cause == "" && model.Error.Path == "" + }) +} diff --git a/apps/computer/local-daemon/internal/localmodels/status.go b/apps/computer/local-daemon/internal/localmodels/status.go index be91b0f0..1c55c3f3 100644 --- a/apps/computer/local-daemon/internal/localmodels/status.go +++ b/apps/computer/local-daemon/internal/localmodels/status.go @@ -246,6 +246,8 @@ type libraryEvent struct { NeedBytes *float64 `json:"need_bytes"` FreeBytes *float64 `json:"free_bytes"` HaveBytes *float64 `json:"have_bytes"` + Cause string `json:"cause"` + Path string `json:"path"` } func parseEvent(line []byte) (libraryEvent, bool) { @@ -306,6 +308,19 @@ func bytesValue(value float64) uint64 { return uint64(value) } +// errorCauses is the tool's closed set of error causes; a GATEWAY_REGISTRATION_FAILED +// line carries one with the path it names. +var errorCauses = []string{"GATEWAY_HOME_NOT_PRIVATE"} + +// cause is the error line's cause as the wire carries it on a model's error, +// or nil when the line names none the contract knows. +func (e libraryEvent) cause() *wire.LocalModelError { + if !slices.Contains(errorCodes, e.Code) || !slices.Contains(errorCauses, e.Cause) || e.Path == "" { + return nil + } + return &wire.LocalModelError{Code: e.Code, Cause: e.Cause, Path: clip(e.Path, 4096)} +} + // clip bounds display text to the schema's length in characters. func clip(text string, limit int) string { if utf8.RuneCountInString(text) <= limit { diff --git a/apps/teamhub/internal/app/handlers_local_models.go b/apps/teamhub/internal/app/handlers_local_models.go index 301ce472..fae1e435 100644 --- a/apps/teamhub/internal/app/handlers_local_models.go +++ b/apps/teamhub/internal/app/handlers_local_models.go @@ -147,6 +147,10 @@ func localModelsView(record agentruntimestate.LocalModelsRecord, viewerID string } } } + // A cause's path is a folder on the owner's machine; only they can act on it. + if model.Error != nil && !view.ViewerIsOwner { + model.Error.Path = nil + } view.Models = append(view.Models, httpapi.LocalModelView{Model: model, UsedBy: users}) } return view, nil @@ -324,6 +328,9 @@ func validLocalModelsSnapshot(snapshot teamhubinternal.LocalModelsSnapshot) bool if model.PromptTokensPerSecond != nil && *model.PromptTokensPerSecond < 0 { return false } + if model.Error != nil && model.Error.Cause != nil && !model.Error.Cause.Valid() { + return false + } seen[model.Id] = true } return true diff --git a/apps/teamhub/internal/app/handlers_local_models_test.go b/apps/teamhub/internal/app/handlers_local_models_test.go index 690b750b..65e11da9 100644 --- a/apps/teamhub/internal/app/handlers_local_models_test.go +++ b/apps/teamhub/internal/app/handlers_local_models_test.go @@ -3,6 +3,7 @@ package app import ( "encoding/json" "slices" + "strings" "testing" "time" @@ -97,6 +98,29 @@ func TestLocalModelsViewMatchesAgentsToModelsOnTheComputer(t *testing.T) { } } +// The folder a gateway cause names is a path on the owner's machine: only +// the owner, who can rename it, reads it. +func TestLocalModelsViewShowsTheCausePathOnlyToTheOwner(t *testing.T) { + snapshot := strings.Replace(storedLocalModelsSnapshotJSON, `"state":"idle"`, + `"state":"failed","error":{"code":"GATEWAY_REGISTRATION_FAILED","cause":"GATEWAY_HOME_NOT_PRIVATE","path":"/home/ana/.local/share/localmodels/tools/gateway-home"}`, 1) + record := agentruntimestate.LocalModelsRecord{ + ComputerID: "computer_1", DisplayName: "Studio", Status: "offline", + Owner: agentruntimestate.LocalComputerOwner{TenantID: "tenant_1", OwnerActorID: "actor_owner"}, + Snapshot: json.RawMessage(snapshot), + } + for viewer, wantPath := range map[string]bool{"actor_owner": true, "actor_member": false} { + view, err := localModelsView(record, viewer, time.Now()) + if err != nil { + t.Fatal(err) + } + failed := view.Models[2].Model.Error + if failed == nil || failed.Cause == nil || *failed.Cause != httpapi.LocalModelErrorCauseGatewayHomeNotPrivate || + (failed.Path != nil) != wantPath { + t.Fatalf("%s: error=%+v", viewer, failed) + } + } +} + func TestLocalModelsViewWithoutSnapshotIsNotReported(t *testing.T) { view, err := localModelsView(agentruntimestate.LocalModelsRecord{ComputerID: "computer_1", DisplayName: "Studio", Status: "offline"}, "actor_owner", time.Now()) if err != nil || view.Available || view.Reason == nil || view.Reason.Code != httpapi.LocalModelsViewNotReported || @@ -179,6 +203,11 @@ func TestValidLocalModelsSnapshot(t *testing.T) { u := "http://huggingface.co/Qwen/Qwen3-4B" s.Models[0].SourceUrl = &u }, + "unknown error cause": func(s *teamhubinternal.LocalModelsSnapshot) { + c := teamhubinternal.LocalModelErrorCause("DISK_LOCKED") + s.Models[0].State = teamhubinternal.LocalModelStateFailed + s.Models[0].Error = &teamhubinternal.LocalModelError{Code: "GATEWAY_REGISTRATION_FAILED", Cause: &c} + }, "negative prompt_tokens_per_second": func(s *teamhubinternal.LocalModelsSnapshot) { p := float32(-1) s.Models[0].PromptTokensPerSecond = &p diff --git a/apps/teamhub/internal/app/handlers_message_attachment.go b/apps/teamhub/internal/app/handlers_message_attachment.go index 60c30ce2..41d6744b 100644 --- a/apps/teamhub/internal/app/handlers_message_attachment.go +++ b/apps/teamhub/internal/app/handlers_message_attachment.go @@ -11,6 +11,7 @@ import ( "github.com/simplexai-labs/linger/apps/teamhub/internal/collaboration" "github.com/simplexai-labs/linger/apps/teamhub/internal/idempotency" "github.com/simplexai-labs/linger/apps/teamhub/internal/secretbox" + httpapi "github.com/simplexai-labs/linger/contracts-go/teamhubpublic" ) func (a *App) uploadMessageAttachment(c *gin.Context) { @@ -21,7 +22,9 @@ func (a *App) uploadMessageAttachment(c *gin.Context) { upload, err := a.parseMessageAttachmentUpload(c) if err != nil { if errors.Is(err, artifactstore.ErrTooLarge) || isMaxBytesError(err) { - a.writeError(c, http.StatusRequestEntityTooLarge, "PAYLOAD_TOO_LARGE", "message attachment exceeds the configured limit") + code, limit := "too_large", a.cfg.ArtifactMaxBytes + a.writeErrorWithDetails(c, http.StatusRequestEntityTooLarge, "PAYLOAD_TOO_LARGE", "message attachment exceeds the configured limit", + []httpapi.ErrorDetail{{Field: "content", Code: &code, Reason: "exceeds the attachment size limit", LimitBytes: &limit}}) } else { a.writeError(c, http.StatusBadRequest, "INVALID_REQUEST", "message attachment upload is invalid") } diff --git a/apps/teamhub/internal/app/handlers_upload_too_large_test.go b/apps/teamhub/internal/app/handlers_upload_too_large_test.go index 630ba246..094de7d3 100644 --- a/apps/teamhub/internal/app/handlers_upload_too_large_test.go +++ b/apps/teamhub/internal/app/handlers_upload_too_large_test.go @@ -2,6 +2,7 @@ package app import ( "bytes" + "encoding/json" "mime/multipart" "net/http" "net/http/httptest" @@ -11,6 +12,7 @@ import ( "github.com/gin-gonic/gin" "github.com/simplexai-labs/linger/apps/teamhub/internal/config" + httpapi "github.com/simplexai-labs/linger/contracts-go/teamhubpublic" ) // The multipart parser must surface *http.MaxBytesError so handlers map an @@ -56,3 +58,55 @@ func TestMultipartUploadsMapOversizedBodyToPayloadTooLarge(t *testing.T) { }) } } + +// A refused message attachment names the limit as a structured detail, so a +// client can tell the person how large a file may be. +func TestMessageAttachmentTooLargeNamesTheLimit(t *testing.T) { + t.Parallel() + const maxBytes = 16 + for name, size := range map[string]int{ + "file over the limit": maxBytes + 1, + "body over the limit": maxBytes + (1 << 20) + 1, + } { + t.Run(name, func(t *testing.T) { + var body bytes.Buffer + writer := multipart.NewWriter(&body) + if err := writer.WriteField("filename", "big.zip"); err != nil { + t.Fatal(err) + } + part, err := writer.CreateFormFile("content", "big.zip") + if err != nil { + t.Fatal(err) + } + if _, err := part.Write(bytes.Repeat([]byte("x"), size)); err != nil { + t.Fatal(err) + } + if err := writer.Close(); err != nil { + t.Fatal(err) + } + recorder := httptest.NewRecorder() + context, _ := gin.CreateTestContext(recorder) + context.Set("request_id", "request-attachment-too-large") + context.Request = httptest.NewRequest(http.MethodPost, "/upload", &body) + context.Request.Header.Set("Content-Type", writer.FormDataContentType()) + context.Request.Header.Set("Idempotency-Key", "attachment-too-large-key") + (&App{cfg: config.ForTest(func(c *config.Config) { + c.ArtifactMaxBytes = maxBytes + })}).uploadMessageAttachment(context) + + var response httpapi.ErrorResponse + if err := json.Unmarshal(recorder.Body.Bytes(), &response); err != nil { + t.Fatal(err) + } + if recorder.Code != http.StatusRequestEntityTooLarge || response.Error.Code != "PAYLOAD_TOO_LARGE" || + response.Error.Details == nil || len(*response.Error.Details) != 1 { + t.Fatalf("status=%d body=%s", recorder.Code, recorder.Body.String()) + } + detail := (*response.Error.Details)[0] + if detail.Field != "content" || detail.Code == nil || *detail.Code != "too_large" || + detail.LimitBytes == nil || *detail.LimitBytes != maxBytes { + t.Fatalf("detail = %+v", detail) + } + }) + } +} diff --git a/apps/web/AGENTS.md b/apps/web/AGENTS.md index c59ca0d6..865404fd 100644 --- a/apps/web/AGENTS.md +++ b/apps/web/AGENTS.md @@ -42,8 +42,13 @@ build:assets` to check the initial JS budget. its own Computer. Only the Computer's owner can act; actions return at once and progress arrives as `local-models` invalidation hints. From the click until a snapshot with another status or observation time, or a refusal, the - row shows a requested load or download as started and spins the button of - any other action, with the row's actions off. A Computer's + row shows a requested load or download as started, labels a cancel, unload + or remove under way (Cancelling, Unloading, Removing), and spins that + action's button, with the row's actions off; a download the Computer + accepted can be cancelled before its first progress. Make room lists what + else holds the pool (components, and other apps from `used_bytes` no holder + accounts for) when unloading models cannot free enough, and says a model + cannot fit only when it needs more than the pool's total. A Computer's detail on the Computers page links here and reads no model state itself. - `src/test`: unit-test support, including the in-process TeamHub test server. - `e2e`: Playwright product workflows; every spec runs on the real TeamHub and diff --git a/apps/web/src/features/local-models/local-model-details.tsx b/apps/web/src/features/local-models/local-model-details.tsx index 94ec5160..a35bd5c0 100644 --- a/apps/web/src/features/local-models/local-model-details.tsx +++ b/apps/web/src/features/local-models/local-model-details.tsx @@ -25,6 +25,7 @@ import { isModelOnComputer, modelCapabilities, modelSourceLabel, + otherAppsBytes, parametersLabel, placeName, poolFreeBytes, @@ -118,7 +119,7 @@ export function ModelFacts({ label={stopped ? "Last download" : "Last load"} > - {modelErrorCopy(model.error.code)} + {modelErrorCopy(model.error)} ) : null} @@ -222,13 +223,7 @@ function PoolBar({ view: LocalModelsView; }) { const label = poolLabel(view, pool); - // used_bytes is the device's real use; on a shared card other processes - // hold memory that no holder accounts for. - const otherBytes = Math.max( - 0, - pool.used_bytes - - pool.holders.reduce((sum, holder) => sum + holder.bytes, 0), - ); + const otherBytes = otherAppsBytes(pool); const width = (bytes: number) => `${pool.total_bytes ? Math.min(100, (bytes / pool.total_bytes) * 100) : 0}%`; return ( diff --git a/apps/web/src/features/local-models/local-model-dialogs.tsx b/apps/web/src/features/local-models/local-model-dialogs.tsx index e81bae3f..56690ca7 100644 --- a/apps/web/src/features/local-models/local-model-dialogs.tsx +++ b/apps/web/src/features/local-models/local-model-dialogs.tsx @@ -12,6 +12,7 @@ import { formatGigabytes, makeRoomSelection, makesRoom, + placeName, poolLabel, poolOf, type LoadCheck, @@ -57,13 +58,27 @@ export function MakeRoomDialog({ const [selected, setSelected] = useState(() => makeRoomSelection(check)); const chosen = new Set(selected); const enough = makesRoom(check, chosen); + const pool = poolLabel(view, check.pool); + // Whether unloading every model offered here frees enough; when not, what + // else holds the memory is the thing to show. + const reachable = makesRoom( + check, + new Set(check.loaded.map((item) => item.model.id)), + ); + const tooBig = check.needBytes > check.pool.total_bytes; + const inUse = [ + ...(check.otherAppsBytes + ? [{ bytes: check.otherAppsBytes, id: "", name: "Other apps" }] + : []), + ...check.kept, + ]; const affected = check.loaded.flatMap((item) => chosen.has(item.model.id) ? item.used_by.map((user) => user.name) : [], ); return ( @@ -122,11 +137,38 @@ export function MakeRoomDialog({ ))} - ) : ( + ) : null} + {tooBig ? ( - Nothing else is loaded there. This model doesn't fit even when - the memory is empty. + {entry.model.name} needs more than all{" "} + {formatGigabytes(check.pool.total_bytes)} of {pool}, so it + can't load there. + ) : reachable ? null : ( + <> + {inUse.length ? ( +
    + {inUse.map((holder) => ( +
  • + + {holder.name} + + + {formatGigabytes(holder.bytes)} + +
  • + ))} +
+ ) : null} + + {check.otherAppsBytes + ? `Close other apps that use ${placeName(view, check.pool.id)}, then try again.` + : "Unloading models here doesn't free enough. Choose a smaller model."} + + )} {affected.length ? ( diff --git a/apps/web/src/features/local-models/local-model-row.tsx b/apps/web/src/features/local-models/local-model-row.tsx index c4467cb5..f894c196 100644 --- a/apps/web/src/features/local-models/local-model-row.tsx +++ b/apps/web/src/features/local-models/local-model-row.tsx @@ -141,6 +141,17 @@ const statusTags: Record< unavailable: { label: "Can't download" }, }; +/** + * The label a row shows while an action that ends its current status is + * under way: until a snapshot moves the model on, the status alone would + * read as if nothing had happened. + */ +const endingLabels: Partial> = { + cancel: "Cancelling", + remove: "Removing", + unload: "Unloading", +}; + interface Handlers { onCancel: () => void; onDownload: () => void; @@ -317,19 +328,28 @@ export function ModelRow({ const panelId = useId(); const { model } = entry; // A requested load or download reads as started at once; the snapshot that - // follows says how it went. + // follows says how it went. A cancel can follow a download no snapshot + // shows yet. const status: ModelStatus = requested === "load" ? "loading" - : requested === "download" + : requested === "download" || + (requested === "cancel" && entry.status === "available") ? "downloading" : entry.status; const started = status !== entry.status; const stopped = status === "failed" && downloadStopped(model); const where = placeName(view, model.pool); - const tag = stopped - ? { ...statusTags.failed, label: "Download stopped" } - : statusTags[status]; + const ending = requested && endingLabels[requested]; + const tag = ending + ? { + dot: statusTags[status].dot, + label: stopped && requested === "cancel" ? "Discarding" : ending, + working: true, + } + : stopped + ? { ...statusTags.failed, label: "Download stopped" } + : statusTags[status]; const progress = downloadPercent(model); const download = formatGigabytes(model.download_bytes); const recommended = status === "available" && model.recommended; @@ -415,7 +435,7 @@ export function ModelRow({ {model.name} = { PLATFORM_UNSUPPORTED: "This model doesn't run on this computer.", }; -/** Why the last load or download of a model failed. */ -export function modelErrorCopy(code: Schemas["LocalModelErrorCode"]) { - return modelErrors[code]; +const modelErrorCauses: Record< + NonNullable, + (path: string | undefined) => string +> = { + GATEWAY_HOME_NOT_PRIVATE: (path) => + path + ? `It loaded, but Agents couldn't be given access to it: the folder ${path} belongs to another account. Quit Linger, rename that folder, then open Linger and load the model again.` + : "It loaded, but Agents couldn't be given access to it: a Linger folder on the computer belongs to another account.", +}; + +/** + * Why the last load or download of a model failed. A cause names the fix; + * its path reaches only the Computer's owner. + */ +export function modelErrorCopy(error: Schemas["LocalModelError"]) { + return error.cause + ? modelErrorCauses[error.cause](error.path) + : modelErrors[error.code]; } const notes: Record< diff --git a/apps/web/src/features/local-models/local-models-page.test.tsx b/apps/web/src/features/local-models/local-models-page.test.tsx index d43241ed..af56f92e 100644 --- a/apps/web/src/features/local-models/local-models-page.test.tsx +++ b/apps/web/src/features/local-models/local-models-page.test.tsx @@ -477,6 +477,70 @@ describe("LocalModelsPage", () => { answer(); }); + it("lets an accepted download be cancelled before its first progress", async () => { + const fixture = setup(); + renderPage(fixture); + await findModels(); + + fireEvent.click( + screen.getByRole("button", { name: "Download GPT-OSS 20B" }), + ); + const cancel = await screen.findByRole("button", { + name: "Cancel GPT-OSS 20B", + }); + await waitFor(() => expect(cancel).toBeEnabled()); + expect(statusOf("GPT-OSS 20B")).toBe("Downloading"); + + const answer = holdActions(fixture, () => accepted("cancel")); + fireEvent.click(cancel); + await waitFor(() => expect(statusOf("GPT-OSS 20B")).toBe("Cancelling")); + expect( + screen.queryByRole("button", { name: "Download GPT-OSS 20B" }), + ).toBeNull(); + answer(); + }); + + it("shows a download as cancelling from the click until the Computer stops it", async () => { + const fixture = setup([ + withModel(labView(), "gpt-oss-20b:Q4_K_M", { + download: { done_bytes: 32, step: "download", total_bytes: 100 }, + state: "downloading", + }), + ]); + const answer = holdActions(fixture, () => accepted("cancel")); + renderPage(fixture); + await findModels(); + + fireEvent.click(screen.getByRole("button", { name: "Cancel GPT-OSS 20B" })); + await waitFor(() => expect(statusOf("GPT-OSS 20B")).toBe("Cancelling")); + expect( + card("GPT-OSS 20B").querySelector(".town-shimmer-text"), + ).not.toBeNull(); + + // Progress keeps arriving while the tool stops the download. + publishSnapshot( + fixture, + withModel(labView(), "gpt-oss-20b:Q4_K_M", { + download: { done_bytes: 40, step: "download", total_bytes: 100 }, + state: "downloading", + }), + ); + await waitFor(() => + expect( + screen.getByRole("progressbar", { + name: "GPT-OSS 20B download progress", + }), + ).toHaveAttribute("aria-valuenow", "40"), + ); + expect(statusOf("GPT-OSS 20B")).toBe("Cancelling"); + + publishSnapshot(fixture, labView()); + answer(); + await waitFor(() => + expect(statusOf("GPT-OSS 20B")).toMatch(/^Not downloaded/), + ); + }); + it("discards a stopped download instead of removing it", async () => { const fixture = setup([ withModel(macView(), "llama3.3-70b:Q4_K_M", { @@ -509,6 +573,41 @@ describe("LocalModelsPage", () => { expect(screen.queryByRole("dialog")).not.toBeInTheDocument(); }); + it.each([ + [ + "/home/ana/.local/share/localmodels/tools/gateway-home", + "It loaded, but Agents couldn't be given access to it: the folder /home/ana/.local/share/localmodels/tools/gateway-home belongs to another account. Quit Linger, rename that folder, then open Linger and load the model again.", + ], + [ + undefined, + "It loaded, but Agents couldn't be given access to it: a Linger folder on the computer belongs to another account.", + ], + ])( + "explains a gateway folder another account owns (path %s)", + async (path, copy) => { + renderPage( + setup([ + withModel(macView(), "llama3.3-70b:Q4_K_M", { + error: { + cause: "GATEWAY_HOME_NOT_PRIVATE", + code: "GATEWAY_REGISTRATION_FAILED", + detail: "raw gateway detail", + ...(path ? { path } : {}), + }, + }), + ]), + ); + await findModels(); + + fireEvent.click(screen.getByRole("button", { name: "Llama 3.3 70B" })); + const details = screen.getByRole("region", { + name: "Llama 3.3 70B details", + }); + expect(details).toHaveTextContent(copy); + expect(details).not.toHaveTextContent("raw gateway detail"); + }, + ); + it("retries a model that failed to load with a load and still offers Remove", async () => { const fixture = setup([ withModel(macView(), "llama3.3-70b:Q4_K_M", { @@ -637,9 +736,91 @@ describe("LocalModelsPage", () => { fireEvent.click( screen.getByRole("button", { name: "Retry Llama 3.3 70B" }), ); + const dialog = screen.getByRole("dialog", { name: "Make room to load" }); + expect(dialog).toHaveTextContent( + "Llama 3.3 70B needs more than all 40 GB of Unified memory, so it can't load there.", + ); + expect(within(dialog).getByRole("button", { name: "Load" })).toBeDisabled(); + }); + + it("names the apps holding the memory instead of calling the model too big", async () => { + const lab = labView(); + const qwen = localModel({ + id: "qwen3-14b:Q4_K_M", + memory_bytes: gb(8.9), + name: "Qwen3 14B", + pool: "gpu:0", + state: "idle", + }); + // A 16 GB card where Linger's embedding holds 1 GB and other apps 8 GB: + // the model fits the empty card but not what is free now. + const pool = gpuPool(0, 16, [ + { component: true, gb: 1, id: "embedding", name: "Qwen3 Embedding" }, + ]); + renderPage( + setup([ + { + ...lab, + models: [modelView(qwen)], + pools: [{ ...pool, used_bytes: gb(9) }], + }, + ]), + ); + await findModels(); + + fireEvent.click(screen.getByRole("button", { name: "Load Qwen3 14B" })); + const dialog = screen.getByRole("dialog", { name: "Make room to load" }); + expect(dialog).toHaveTextContent( + "Qwen3 14B needs 8.9 GB on GPU 0 ยท RTX 4090; 7 GB is free.", + ); + expect(dialog).not.toHaveTextContent("empty"); + const inUse = within(dialog).getByRole("list", { + name: "Also using this memory", + }); expect( - screen.getByRole("dialog", { name: "Make room to load" }), - ).toHaveTextContent("Nothing else is loaded there."); + within(inUse) + .getAllByRole("listitem") + .map((item) => item.textContent), + ).toEqual(["Other apps8 GB", "Qwen3 Embedding1 GB"]); + expect(dialog).toHaveTextContent( + "Close other apps that use GPU 0, then try again.", + ); + expect(within(dialog).getByRole("button", { name: "Load" })).toBeDisabled(); + }); + + it("lists other apps when unloading every model still isn't enough", async () => { + const lab = labView(); + const pool = gpuPool(0, 24, [ + { gb: 10, id: "qwen3-coder-30b:Q4_K_M", name: "Qwen3 Coder 30B" }, + ]); + renderPage( + setup([ + withModel( + withModel( + { ...lab, pools: [{ ...pool, used_bytes: gb(22) }, lab.pools[1]!] }, + "qwen3-coder-30b:Q4_K_M", + { memory_bytes: gb(10) }, + ), + "gemma3-27b:Q4_K_M", + { pool: "gpu:0", memory_bytes: gb(13) }, + ), + ]), + ); + await findModels(); + + fireEvent.click(screen.getByRole("button", { name: "Load Gemma 3 27B" })); + const dialog = screen.getByRole("dialog", { name: "Make room to load" }); + expect( + within(dialog).getByRole("checkbox", { name: /Qwen3 Coder 30B/ }), + ).not.toBeChecked(); + expect( + within( + within(dialog).getByRole("list", { name: "Also using this memory" }), + ).getByRole("listitem"), + ).toHaveTextContent("Other apps12 GB"); + expect(dialog).toHaveTextContent( + "Close other apps that use GPU 0, then try again.", + ); }); it("asks before unloading a model an Agent uses, and not otherwise", async () => { @@ -894,6 +1075,7 @@ describe("LocalModelsPage", () => { }); await waitFor(() => expect(unload).toHaveAttribute("aria-busy", "true")); expect(unload).toBeDisabled(); + expect(statusOf("Qwen3 Coder 30B")).toBe("Unloading"); answer(); publishSnapshot( diff --git a/apps/web/src/features/local-models/local-models-page.tsx b/apps/web/src/features/local-models/local-models-page.tsx index d117d542..256546a7 100644 --- a/apps/web/src/features/local-models/local-models-page.tsx +++ b/apps/web/src/features/local-models/local-models-page.tsx @@ -434,6 +434,12 @@ function Library({ for (const input of sending) { if (input) requests.set(input.modelId, input.action); } + // A download the Computer accepted is a job it can cancel before the + // first progress reaches a snapshot; every other request holds the row. + const busy = (modelId: string) => + requests.has(modelId) && + (requests.get(modelId) !== "download" || + sending.some((input) => input?.modelId === modelId)); const offline = view.computer.status === "offline"; const readOnly = !view.viewer_is_owner; // A dialog stays open across snapshots, so its confirm checks the model @@ -527,7 +533,7 @@ function Library({ const modelId = entry.model.id; return ( { expect(check.loaded.map((entry) => entry.model.name)).toEqual([ "GPT-OSS 20B", ]); + // The loaded model is offered, so nothing else holds the pool. + expect(check.kept).toEqual([]); + expect(check.otherAppsBytes).toBe(0); }); it("preselects the fewest models, preferring ones no Agent uses", () => { @@ -125,7 +128,9 @@ describe("local models rules", () => { ...item, status: "loaded" as const, })), + kept: [], needBytes: gb(12), + otherAppsBytes: 0, pool, }; diff --git a/apps/web/src/features/local-models/local-models-rules.ts b/apps/web/src/features/local-models/local-models-rules.ts index d3b6e320..677a529e 100644 --- a/apps/web/src/features/local-models/local-models-rules.ts +++ b/apps/web/src/features/local-models/local-models-rules.ts @@ -133,6 +133,18 @@ export function poolFreeBytes(pool: LocalModelPool) { return Math.max(0, pool.total_bytes - pool.used_bytes); } +/** + * Memory no holder accounts for: used_bytes is the device's real use, so on + * a shared card it includes other apps. + */ +export function otherAppsBytes(pool: LocalModelPool) { + return Math.max( + 0, + pool.used_bytes - + pool.holders.reduce((sum, holder) => sum + holder.bytes, 0), + ); +} + /** What the header adds up: GPU memory when the Computer has GPUs, else its memory. */ export function memorySummary(view: LocalModelsView) { const gpus = view.pools.filter((pool) => pool.kind === "gpu"); @@ -150,6 +162,13 @@ export interface LoadCheck { freeBytes: number; /** Loaded models in the same pool, the ones the user could unload. */ loaded: ModelEntry[]; + /** + * What else holds the pool that Make room cannot unload: components and + * models in another state, by holder. + */ + kept: LocalModelPool["holders"]; + /** Pool memory held outside localmodels, by other apps. */ + otherAppsBytes: number; } /** Why a model cannot load now, or `null` when its pool reports room for it. */ @@ -159,15 +178,20 @@ export function loadCheck( ): LoadCheck | null { const pool = poolOf(view, model.pool); if (!pool || poolFreeBytes(pool) >= model.memory_bytes) return null; + const loaded = modelEntries(view).filter( + (entry) => + entry.status === "loaded" && + entry.model.pool === pool.id && + entry.model.id !== model.id, + ); return { freeBytes: poolFreeBytes(pool), - loaded: modelEntries(view).filter( - (entry) => - entry.status === "loaded" && - entry.model.pool === pool.id && - entry.model.id !== model.id, + kept: pool.holders.filter( + (holder) => !loaded.some((entry) => entry.model.id === holder.id), ), + loaded, needBytes: model.memory_bytes, + otherAppsBytes: otherAppsBytes(pool), pool, }; } diff --git a/apps/web/src/features/rooms/chat/message-composer.test.tsx b/apps/web/src/features/rooms/chat/message-composer.test.tsx index bfc83ee4..804ba850 100644 --- a/apps/web/src/features/rooms/chat/message-composer.test.tsx +++ b/apps/web/src/features/rooms/chat/message-composer.test.tsx @@ -17,6 +17,7 @@ import { formatSkillToken, } from "./message-composer-references"; import { TEAMHUB_MESSAGE_MAX_LENGTH } from "./use-composer-draft"; +import { TeamHubError } from "@/features/teamhub/teamhub-error"; import { createTeamHubMessageContent } from "@/features/teamhub/teamhub-message-content"; describe("MessageComposer", () => { @@ -461,6 +462,40 @@ describe("MessageComposer", () => { }); }); + it("names the file's size and the attachment limit when TeamHub refuses a large file", async () => { + const onStageAttachment = vi.fn().mockRejectedValue( + new TeamHubError({ + code: "PAYLOAD_TOO_LARGE", + details: [ + { + code: "too_large", + field: "content", + limit_bytes: 50 * 1024 * 1024, + reason: "exceeds the attachment size limit", + }, + ], + message: "message attachment exceeds the configured limit", + status: 413, + }), + ); + const file = new File([], "big.zip"); + Object.defineProperty(file, "size", { value: 60 * 1024 * 1024 }); + render( + , + ); + fireEvent.change(screen.getByLabelText("Choose message attachments"), { + target: { files: [file] }, + }); + + expect(await screen.findByRole("alert")).toHaveTextContent( + "big.zip: Attachments can be up to 50 MB, and this file is 60 MB.", + ); + }); + it("keeps the compact attachment remove control visible and cancels its staged upload", async () => { const onCancelAttachment = vi.fn().mockResolvedValue(undefined); const onStageAttachment = vi.fn().mockResolvedValue(undefined); diff --git a/apps/web/src/features/rooms/chat/use-composer-attachments.ts b/apps/web/src/features/rooms/chat/use-composer-attachments.ts index 6083ef8d..bacd8acb 100644 --- a/apps/web/src/features/rooms/chat/use-composer-attachments.ts +++ b/apps/web/src/features/rooms/chat/use-composer-attachments.ts @@ -8,6 +8,8 @@ import { } from "react"; import { createTeamHubIdempotencyKey } from "@/features/teamhub/teamhub-client"; +import { TeamHubError } from "@/features/teamhub/teamhub-error"; +import { formatBytes } from "@/lib/format-bytes"; import { type ComposerAttachment, composerAttachmentStore, @@ -174,8 +176,7 @@ export function useComposerAttachments({ candidate.clientId === attachment.clientId ? { ...candidate, - error: - error instanceof Error ? error.message : "Upload failed.", + error: uploadFailureCopy(error, attachment.file), status: "failed", } : candidate, @@ -260,6 +261,18 @@ export function filesFromClipboard(clipboardData: DataTransfer): File[] { }); } +/** Why one upload failed; TeamHub's limit refusal names both sizes. */ +function uploadFailureCopy(error: unknown, file: File) { + if (error instanceof TeamHubError && error.code === "PAYLOAD_TOO_LARGE") { + const limit = error.details?.find( + (detail) => detail.code === "too_large", + )?.limit_bytes; + if (limit !== undefined) + return `Attachments can be up to ${formatBytes(limit)}, and this file is ${formatBytes(file.size)}.`; + } + return error instanceof Error ? error.message : "Upload failed."; +} + function validateMessageAttachments(files: File[]) { if (files.length > maximumAttachmentCount) { return { diff --git a/contracts/generated/go/nodeservicesinternal/openapi.gen.go b/contracts/generated/go/nodeservicesinternal/openapi.gen.go index 243886b5..d49cea50 100644 --- a/contracts/generated/go/nodeservicesinternal/openapi.gen.go +++ b/contracts/generated/go/nodeservicesinternal/openapi.gen.go @@ -1814,9 +1814,12 @@ type Error struct { // ErrorDetail defines model for ErrorDetail. type ErrorDetail struct { // Code Optional stable classification for this individual validation issue. - Code *string `json:"code,omitempty"` - Field string `json:"field"` - Reason string `json:"reason"` + Code *string `json:"code,omitempty"` + Field string `json:"field"` + + // LimitBytes With code too_large, the largest size the field accepts, in bytes. + LimitBytes *int64 `json:"limit_bytes,omitempty"` + Reason string `json:"reason"` } // ErrorResponse defines model for ErrorResponse. diff --git a/contracts/generated/go/runnergateway/wire.gen.go b/contracts/generated/go/runnergateway/wire.gen.go index ab8144c3..d752713a 100644 --- a/contracts/generated/go/runnergateway/wire.gen.go +++ b/contracts/generated/go/runnergateway/wire.gen.go @@ -1315,6 +1315,8 @@ func (LocalModelEndpoint) RequiredFields() []string { return []string{"base_url" type LocalModelError struct { Code string `json:"code"` Detail string `json:"detail,omitempty"` + Cause string `json:"cause,omitempty"` + Path string `json:"path,omitempty"` } // FixedFields lists the keys whose value the schema fixes for a LocalModelError. diff --git a/contracts/generated/go/teamhubinternal/openapi.gen.go b/contracts/generated/go/teamhubinternal/openapi.gen.go index 297d3ea0..24a05118 100644 --- a/contracts/generated/go/teamhubinternal/openapi.gen.go +++ b/contracts/generated/go/teamhubinternal/openapi.gen.go @@ -836,6 +836,21 @@ func (e LocalModelDownloadProgressStep) Valid() bool { } } +// Defines values for LocalModelErrorCause. +const ( + LocalModelErrorCauseGatewayHomeNotPrivate LocalModelErrorCause = "GATEWAY_HOME_NOT_PRIVATE" +) + +// Valid indicates whether the value is a known member of the LocalModelErrorCause enum. +func (e LocalModelErrorCause) Valid() bool { + switch e { + case LocalModelErrorCauseGatewayHomeNotPrivate: + return true + default: + return false + } +} + // Defines values for LocalModelErrorCode. const ( CANCELLED LocalModelErrorCode = "CANCELLED" @@ -3065,9 +3080,12 @@ type Error struct { // ErrorDetail defines model for ErrorDetail. type ErrorDetail struct { // Code Optional stable classification for this individual validation issue. - Code *string `json:"code,omitempty"` - Field string `json:"field"` - Reason string `json:"reason"` + Code *string `json:"code,omitempty"` + Field string `json:"field"` + + // LimitBytes With code too_large, the largest size the field accepts, in bytes. + LimitBytes *int64 `json:"limit_bytes,omitempty"` + Reason string `json:"reason"` } // ErrorResponse defines model for ErrorResponse. @@ -3225,13 +3243,22 @@ type LocalModelEndpoint struct { // LocalModelError defines model for LocalModelError. type LocalModelError struct { + // Cause Why a GATEWAY_REGISTRATION_FAILED happened, when the Computer supervised the failed job. GATEWAY_HOME_NOT_PRIVATE: the local gateway's private folder at path has another owner; closing Linger and renaming that folder lets the model load. + Cause *LocalModelErrorCause `json:"cause,omitempty"` + // Code Closed localmodels library error set. It is extended only together with the localmodels library contract. Code LocalModelErrorCode `json:"code"` // Detail Diagnostic text for display; never matched on. Detail *string `json:"detail,omitempty"` + + // Path The folder the cause names, on the Computer. The public view carries it only for the Computer's owner. + Path *string `json:"path,omitempty"` } +// LocalModelErrorCause Why a GATEWAY_REGISTRATION_FAILED happened, when the Computer supervised the failed job. GATEWAY_HOME_NOT_PRIVATE: the local gateway's private folder at path has another owner; closing Linger and renaming that folder lets the model load. +type LocalModelErrorCause string + // LocalModelErrorCode Closed localmodels library error set. It is extended only together with the localmodels library contract. type LocalModelErrorCode string diff --git a/contracts/generated/go/teamhubpublic/openapi.gen.go b/contracts/generated/go/teamhubpublic/openapi.gen.go index 89eca03a..57a5dd6a 100644 --- a/contracts/generated/go/teamhubpublic/openapi.gen.go +++ b/contracts/generated/go/teamhubpublic/openapi.gen.go @@ -2120,6 +2120,21 @@ func (e LocalModelDownloadProgressStep) Valid() bool { } } +// Defines values for LocalModelErrorCause. +const ( + LocalModelErrorCauseGatewayHomeNotPrivate LocalModelErrorCause = "GATEWAY_HOME_NOT_PRIVATE" +) + +// Valid indicates whether the value is a known member of the LocalModelErrorCause enum. +func (e LocalModelErrorCause) Valid() bool { + switch e { + case LocalModelErrorCauseGatewayHomeNotPrivate: + return true + default: + return false + } +} + // Defines values for LocalModelErrorCode. const ( CANCELLED LocalModelErrorCode = "CANCELLED" @@ -6042,9 +6057,12 @@ type Error struct { // ErrorDetail defines model for ErrorDetail. type ErrorDetail struct { // Code Optional stable classification for this individual validation issue. - Code *string `json:"code,omitempty"` - Field string `json:"field"` - Reason string `json:"reason"` + Code *string `json:"code,omitempty"` + Field string `json:"field"` + + // LimitBytes With code too_large, the largest size the field accepts, in bytes. + LimitBytes *int64 `json:"limit_bytes,omitempty"` + Reason string `json:"reason"` } // ErrorResponse defines model for ErrorResponse. @@ -6564,13 +6582,22 @@ type LocalModelEndpoint struct { // LocalModelError defines model for LocalModelError. type LocalModelError struct { + // Cause Why a GATEWAY_REGISTRATION_FAILED happened, when the Computer supervised the failed job. GATEWAY_HOME_NOT_PRIVATE: the local gateway's private folder at path has another owner; closing Linger and renaming that folder lets the model load. + Cause *LocalModelErrorCause `json:"cause,omitempty"` + // Code Closed localmodels library error set. It is extended only together with the localmodels library contract. Code LocalModelErrorCode `json:"code"` // Detail Diagnostic text for display; never matched on. Detail *string `json:"detail,omitempty"` + + // Path The folder the cause names, on the Computer. The public view carries it only for the Computer's owner. + Path *string `json:"path,omitempty"` } +// LocalModelErrorCause Why a GATEWAY_REGISTRATION_FAILED happened, when the Computer supervised the failed job. GATEWAY_HOME_NOT_PRIVATE: the local gateway's private folder at path has another owner; closing Linger and renaming that folder lets the model load. +type LocalModelErrorCause string + // LocalModelErrorCode Closed localmodels library error set. It is extended only together with the localmodels library contract. type LocalModelErrorCode string diff --git a/contracts/generated/typescript/src/generated/node-services-internal/types.ts b/contracts/generated/typescript/src/generated/node-services-internal/types.ts index 15046f4d..b963a3db 100644 --- a/contracts/generated/typescript/src/generated/node-services-internal/types.ts +++ b/contracts/generated/typescript/src/generated/node-services-internal/types.ts @@ -1448,6 +1448,11 @@ export interface components { /** @description Optional stable classification for this individual validation issue. */ code?: string; reason: string; + /** + * Format: int64 + * @description With code too_large, the largest size the field accepts, in bytes. + */ + limit_bytes?: number; }; Error: { /** @example ROOM_NOT_FOUND */ diff --git a/contracts/generated/typescript/src/generated/runner-gateway/schema.ts b/contracts/generated/typescript/src/generated/runner-gateway/schema.ts index 9415f080..406b5e23 100644 --- a/contracts/generated/typescript/src/generated/runner-gateway/schema.ts +++ b/contracts/generated/typescript/src/generated/runner-gateway/schema.ts @@ -2403,6 +2403,17 @@ export const runnerGatewayEnvelopeSchema = { type: "string", maxLength: 4000, }, + cause: { + description: + "Why a GATEWAY_REGISTRATION_FAILED happened, from the failed job's error line. GATEWAY_HOME_NOT_PRIVATE: the local gateway's private folder at path has another owner.", + enum: ["GATEWAY_HOME_NOT_PRIVATE"], + }, + path: { + description: "The folder the cause names.", + type: "string", + minLength: 1, + maxLength: 4096, + }, }, }, LocalModelNote: { diff --git a/contracts/generated/typescript/src/generated/runner-gateway/types.ts b/contracts/generated/typescript/src/generated/runner-gateway/types.ts index 13220df0..622ce0b0 100644 --- a/contracts/generated/typescript/src/generated/runner-gateway/types.ts +++ b/contracts/generated/typescript/src/generated/runner-gateway/types.ts @@ -1466,6 +1466,14 @@ export interface LocalModelError { * Diagnostic text for display; never matched on. */ detail?: string; + /** + * Why a GATEWAY_REGISTRATION_FAILED happened, from the failed job's error line. GATEWAY_HOME_NOT_PRIVATE: the local gateway's private folder at path has another owner. + */ + cause?: "GATEWAY_HOME_NOT_PRIVATE"; + /** + * The folder the cause names. + */ + path?: string; } /** * Present only when idle and the automatic load after download was skipped. diff --git a/contracts/generated/typescript/src/generated/teamhub-internal/types.ts b/contracts/generated/typescript/src/generated/teamhub-internal/types.ts index 4d147fc9..341ee591 100644 --- a/contracts/generated/typescript/src/generated/teamhub-internal/types.ts +++ b/contracts/generated/typescript/src/generated/teamhub-internal/types.ts @@ -1604,6 +1604,11 @@ export interface components { /** @description Optional stable classification for this individual validation issue. */ code?: string; reason: string; + /** + * Format: int64 + * @description With code too_large, the largest size the field accepts, in bytes. + */ + limit_bytes?: number; }; Error: { /** @example ROOM_NOT_FOUND */ @@ -2620,6 +2625,13 @@ export interface components { code: components["schemas"]["LocalModelErrorCode"]; /** @description Diagnostic text for display; never matched on. */ detail?: string; + /** + * @description Why a GATEWAY_REGISTRATION_FAILED happened, when the Computer supervised the failed job. GATEWAY_HOME_NOT_PRIVATE: the local gateway's private folder at path has another owner; closing Linger and renaming that folder lets the model load. + * @enum {string} + */ + cause?: "GATEWAY_HOME_NOT_PRIVATE"; + /** @description The folder the cause names, on the Computer. The public view carries it only for the Computer's owner. */ + path?: string; }; LocalModelNote: { /** @enum {string} */ diff --git a/contracts/generated/typescript/src/generated/teamhub-public/types.ts b/contracts/generated/typescript/src/generated/teamhub-public/types.ts index d7e714c2..9e7778f7 100644 --- a/contracts/generated/typescript/src/generated/teamhub-public/types.ts +++ b/contracts/generated/typescript/src/generated/teamhub-public/types.ts @@ -4188,6 +4188,11 @@ export interface components { /** @description Optional stable classification for this individual validation issue. */ code?: string; reason: string; + /** + * Format: int64 + * @description With code too_large, the largest size the field accepts, in bytes. + */ + limit_bytes?: number; }; Error: { /** @example ROOM_NOT_FOUND */ @@ -4679,6 +4684,13 @@ export interface components { code: components["schemas"]["LocalModelErrorCode"]; /** @description Diagnostic text for display; never matched on. */ detail?: string; + /** + * @description Why a GATEWAY_REGISTRATION_FAILED happened, when the Computer supervised the failed job. GATEWAY_HOME_NOT_PRIVATE: the local gateway's private folder at path has another owner; closing Linger and renaming that folder lets the model load. + * @enum {string} + */ + cause?: "GATEWAY_HOME_NOT_PRIVATE"; + /** @description The folder the cause names, on the Computer. The public view carries it only for the Computer's owner. */ + path?: string; }; LocalModelNote: { /** @enum {string} */ diff --git a/contracts/openapi/components/common.yaml b/contracts/openapi/components/common.yaml index 16f74425..f2f0fb4b 100644 --- a/contracts/openapi/components/common.yaml +++ b/contracts/openapi/components/common.yaml @@ -351,6 +351,11 @@ components: reason: type: string minLength: 1 + limit_bytes: + description: With code too_large, the largest size the field accepts, in bytes. + type: integer + format: int64 + minimum: 0 Error: type: object additionalProperties: false diff --git a/contracts/openapi/components/local-models.yaml b/contracts/openapi/components/local-models.yaml index 68dd90f4..c322c40a 100644 --- a/contracts/openapi/components/local-models.yaml +++ b/contracts/openapi/components/local-models.yaml @@ -282,6 +282,22 @@ components: description: Diagnostic text for display; never matched on. type: string maxLength: 4000 + cause: + description: >- + Why a GATEWAY_REGISTRATION_FAILED happened, when the Computer + supervised the failed job. GATEWAY_HOME_NOT_PRIVATE: the local + gateway's private folder at path has another owner; closing Linger + and renaming that folder lets the model load. + type: string + enum: [GATEWAY_HOME_NOT_PRIVATE] + x-enum-varnames: [LocalModelErrorCauseGatewayHomeNotPrivate] + path: + description: >- + The folder the cause names, on the Computer. The public view + carries it only for the Computer's owner. + type: string + minLength: 1 + maxLength: 4096 LocalModelNote: type: object additionalProperties: false diff --git a/contracts/runner-gateway/envelope.schema.json b/contracts/runner-gateway/envelope.schema.json index f67314e2..706b2a0d 100644 --- a/contracts/runner-gateway/envelope.schema.json +++ b/contracts/runner-gateway/envelope.schema.json @@ -2380,6 +2380,16 @@ "description": "Diagnostic text for display; never matched on.", "type": "string", "maxLength": 4000 + }, + "cause": { + "description": "Why a GATEWAY_REGISTRATION_FAILED happened, from the failed job's error line. GATEWAY_HOME_NOT_PRIVATE: the local gateway's private folder at path has another owner.", + "enum": ["GATEWAY_HOME_NOT_PRIVATE"] + }, + "path": { + "description": "The folder the cause names.", + "type": "string", + "minLength": 1, + "maxLength": 4096 } } },