Skip to content

Linger is An Open-Source Personal Agent That Runs Fully on Your PC. We aim to break Big Tech’s grip on AI by bringing powerful local AI to everyday computers through efficient model–harness co-design, so everyone can run their own.

fix(computer): send local models frames only to a service that accepts them

Dongdong Chene951c7e8c93f
diff --git a/apps/computer/AGENTS.md b/apps/computer/AGENTS.md
index ca05a99c..49e5120c 100644
--- a/apps/computer/AGENTS.md
+++ b/apps/computer/AGENTS.md
@@ -76,9 +76,15 @@
`app-sha256` differs from the Agent's `target_release`. A Daemon
change therefore needs no version bump to reach Computers.
- Bump `apps/computer/package.json` only when raising the version
- floor. The package version is the source for the bundled CLI and Go Daemon
- `ReleaseVersion`; it is used for display and the floor, never to trigger or
- order upgrades.
+ floor or when the Agent Service must tell a release that decodes a new
+ optional `runner.welcome` field from one that rejects it (the Daemon decodes
+ frames strictly). The package version is the source for the bundled CLI and
+ Go Daemon `ReleaseVersion`; it is used for display, the floor, and those
+ welcome fields, never to trigger or order upgrades.
+- A Daemon can outlive its Agent Service release: a desktop upgrade replaces
+ the Daemon while the installed services keep running until the owner
+ updates them. A Daemon-to-Agent frame family added within protocol 2 is
+ sent only when `runner.welcome`'s `service_features` names it.
- Before reporting a Daemon update as delivered, distinguish an image that
carries the new build from an existing Computer that has actually upgraded
(its active bundle's `app-sha256`).
diff --git a/apps/computer/local-daemon/internal/daemon/connection.go b/apps/computer/local-daemon/internal/daemon/connection.go
index 080190ac..b3cf9245 100644
--- a/apps/computer/local-daemon/internal/daemon/connection.go
+++ b/apps/computer/local-daemon/internal/daemon/connection.go
@@ -9,6 +9,7 @@ import (
"fmt"
"log/slog"
mathrand "math/rand/v2"
+ "slices"
"sort"
"time"
@@ -316,11 +317,14 @@ func (d *Daemon) acceptRunnerWelcome(ctx, connectionCtx context.Context, stream
d.prewarmOnce.Do(func() { go p.Prewarm(ctx) })
}
d.setGatewayState("connected")
- if err := d.activateStreamAndReplay(ctx, stream, command.ReconcileOperationIDs); err != nil {
+ localModels := slices.Contains(command.ServiceFeatures, serviceFeatureLocalModels)
+ if err := d.activateStreamAndReplay(ctx, stream, command.ReconcileOperationIDs, localModels); err != nil {
return err
}
go d.heartbeatLoop(connectionCtx, stream, command.HeartbeatIntervalMs)
- d.refreshLocalModels(connectionCtx)
+ if localModels {
+ d.refreshLocalModels(connectionCtx)
+ }
return nil
}
@@ -395,6 +399,9 @@ func (d *Daemon) clearDiagnosticsStream(stream transport.Stream) {
if d.diagnosticsStream == stream {
d.diagnosticsStream = nil
}
+ if d.localModelsStream == stream {
+ d.localModelsStream = nil
+ }
d.connectionMu.Unlock()
}
@@ -504,11 +511,17 @@ func (d *Daemon) replayRetainedEvents(ctx context.Context, stream transport.Stre
return nil
}
-func (d *Daemon) activateStreamAndReplay(ctx context.Context, stream transport.Stream, operationIDs []string) error {
+// activateStreamAndReplay makes stream the live connection; localModels says
+// whether its Agent Service accepts runner.local_models.
+func (d *Daemon) activateStreamAndReplay(ctx context.Context, stream transport.Stream, operationIDs []string, localModels bool) error {
d.connectionMu.Lock()
defer d.connectionMu.Unlock()
d.diagnosticsStream = stream
d.operationStream = stream
+ d.localModelsStream = nil
+ if localModels {
+ d.localModelsStream = stream
+ }
return d.replayRetainedEvents(ctx, stream, operationIDs)
}
diff --git a/apps/computer/local-daemon/internal/daemon/daemon.go b/apps/computer/local-daemon/internal/daemon/daemon.go
index 55fb3057..94992aa2 100644
--- a/apps/computer/local-daemon/internal/daemon/daemon.go
+++ b/apps/computer/local-daemon/internal/daemon/daemon.go
@@ -160,7 +160,10 @@ type Daemon struct {
diagnosticsRevision uint64
connectionMu sync.Mutex
diagnosticsStream transport.Stream
- operationStream transport.Stream
+ // localModelsStream is the live connection when its Agent Service
+ // accepts runner.local_models; nil otherwise.
+ localModelsStream transport.Stream
+ operationStream transport.Stream
// dispatcher is the live connection's command dispatcher. It is atomic so
// DrainIfIdle can read it under admissionMu without taking connectionMu.
dispatcher atomic.Pointer[commandDispatcher]
diff --git a/apps/computer/local-daemon/internal/daemon/local_models.go b/apps/computer/local-daemon/internal/daemon/local_models.go
index 1fe78f11..fc9a206c 100644
--- a/apps/computer/local-daemon/internal/daemon/local_models.go
+++ b/apps/computer/local-daemon/internal/daemon/local_models.go
@@ -13,6 +13,11 @@ import (
wire "github.com/simplexai-labs/linger/contracts-go/runnergateway"
)
+// serviceFeatureLocalModels in runner.welcome's service_features says the
+// Agent Service accepts runner.local_models and sends local_models commands.
+// An Agent Service that predates them closes the connection on the frame.
+const serviceFeatureLocalModels = "local_models"
+
// LocalModelLibrary runs the actions a Computer owner chooses on this
// Computer's localmodels library. The Daemon never picks a model itself.
type LocalModelLibrary interface {
@@ -33,13 +38,13 @@ func (d *Daemon) refreshLocalModels(ctx context.Context) {
}
// PublishLocalModels sends one runner.local_models snapshot on the live
-// connection. Without one it does nothing: every connection starts with a
-// fresh read.
+// connection when its Agent Service accepts them. Otherwise it does nothing:
+// every connection starts with a fresh read.
func (d *Daemon) PublishLocalModels(snapshot wire.LocalModelsSnapshot) {
d.localModelsMu.Lock()
defer d.localModelsMu.Unlock()
d.connectionMu.Lock()
- stream := d.diagnosticsStream
+ stream := d.localModelsStream
d.connectionMu.Unlock()
if stream == nil {
return
@@ -87,6 +92,11 @@ func (d *Daemon) handleLocalModelsCommand(ctx context.Context, stream transport.
case !validLocalModelAction(action):
slog.Warn("local_models.command_rejected", "reason", "shape", "action", request.Action)
refusal = &wire.LocalModelActionRefusal{Code: "MODEL_UNKNOWN", Detail: "the command names no valid model action"}
+ case !d.acceptsLocalModels(stream):
+ // The welcome did not name local_models, so no snapshot follows the
+ // action on this connection.
+ slog.Warn("local_models.command_rejected", "reason", "service_features", "action", request.Action)
+ refusal = &wire.LocalModelActionRefusal{Code: localmodels.CodeToolFailed, Detail: "the Agent Service did not announce local models on this connection"}
case d.localModels == nil:
refusal = &wire.LocalModelActionRefusal{Code: localmodels.CodeToolNotInstalled}
default:
@@ -150,3 +160,11 @@ func validLocalModelAction(action localmodels.Action) bool {
}
return false
}
+
+// acceptsLocalModels reports whether stream is the live connection and its
+// welcome named local_models.
+func (d *Daemon) acceptsLocalModels(stream transport.Stream) bool {
+ d.connectionMu.Lock()
+ defer d.connectionMu.Unlock()
+ return d.localModelsStream != nil && d.localModelsStream == stream
+}
diff --git a/apps/computer/local-daemon/internal/daemon/local_models_test.go b/apps/computer/local-daemon/internal/daemon/local_models_test.go
index 23eb4ad4..47266514 100644
--- a/apps/computer/local-daemon/internal/daemon/local_models_test.go
+++ b/apps/computer/local-daemon/internal/daemon/local_models_test.go
@@ -3,11 +3,14 @@ package daemon
import (
"context"
"encoding/json"
+ "errors"
+ "io"
"path/filepath"
"sync"
"testing"
"time"
+ "github.com/simplexai-labs/linger/apps/computer/local-daemon/internal/linger/transport"
"github.com/simplexai-labs/linger/apps/computer/local-daemon/internal/localmodels"
"github.com/simplexai-labs/linger/apps/computer/local-daemon/internal/protocol"
wire "github.com/simplexai-labs/linger/contracts-go/runnergateway"
@@ -46,6 +49,7 @@ func TestLocalModelsCommandAnswersAcceptedOrRefused(t *testing.T) {
}
payload, _ := json.Marshal(request)
stream := &browserEventStream{}
+ d.localModelsStream = stream
command := protocol.Command{Type: protocol.CommandCapabilityLocalModels, ProtocolVersion: "2", CommandID: "command-1", RunnerID: "computer", ConnectionEpoch: 7, Payload: payload}
if err := d.handleLocalModelsCommand(t.Context(), stream, command); err != nil {
t.Fatal(err)
@@ -115,6 +119,7 @@ func TestLocalModelsCommandTheToolDidNotDecideInTimeGetsNoAnswer(t *testing.T) {
"expires_at": time.Now().Add(time.Minute).UTC().Format(time.RFC3339Nano),
})
stream := &browserEventStream{}
+ d.localModelsStream = stream
if err := d.handleLocalModelsCommand(t.Context(), stream, protocol.Command{Type: protocol.CommandCapabilityLocalModels, Payload: payload}); err != nil {
t.Fatal(err)
}
@@ -132,6 +137,7 @@ func TestExpiredLocalModelsCommandIsNotStarted(t *testing.T) {
"expires_at": time.Now().Add(-time.Second).UTC().Format(time.RFC3339Nano),
})
stream := &browserEventStream{}
+ d.localModelsStream = stream
if err := d.handleLocalModelsCommand(t.Context(), stream, protocol.Command{Type: protocol.CommandCapabilityLocalModels, Payload: payload}); err != nil {
t.Fatal(err)
}
@@ -144,7 +150,7 @@ func TestExpiredLocalModelsCommandIsNotStarted(t *testing.T) {
// real library.
func TestConnectedComputerWithoutTheToolReportsToolNotInstalled(t *testing.T) {
stream := &browserEventStream{}
- d := &Daemon{computerID: "computer", protocolVersion: protocol.Version, diagnosticsStream: stream}
+ d := &Daemon{computerID: "computer", protocolVersion: protocol.Version, diagnosticsStream: stream, localModelsStream: stream}
library := localmodels.New(localmodels.Options{JobDirectory: filepath.Join(t.TempDir(), "jobs"), Publish: d.PublishLocalModels})
defer library.Close()
d.localModels = library
@@ -165,9 +171,127 @@ func TestConnectedComputerWithoutTheToolReportsToolNotInstalled(t *testing.T) {
}
}
- d.diagnosticsStream = nil
+ d.diagnosticsStream, d.localModelsStream = nil, nil
library.Refresh(t.Context())
if len(stream.events) != 2 {
t.Fatal("a snapshot was sent without a connection")
}
}
+
+// publishingLocalModels publishes one snapshot per Refresh, like the real
+// library, and counts the reads.
+type publishingLocalModels struct {
+ fakeLocalModels
+ publish func(wire.LocalModelsSnapshot)
+ refreshes chan struct{}
+}
+
+func (f *publishingLocalModels) Refresh(context.Context) wire.LocalModelsSnapshot {
+ snapshot := wire.LocalModelsSnapshot{Available: true}
+ f.publish(snapshot)
+ f.refreshes <- struct{}{}
+ return snapshot
+}
+
+// A newer Computer connected to an Agent Service that predates local models
+// (a desktop upgrade leaves the old service running) must not send
+// runner.local_models: that service closes the connection on the frame.
+// Only a welcome whose service_features names local_models opens the family.
+func TestLocalModelsFramesFollowTheWelcomeServiceFeatures(t *testing.T) {
+ for _, test := range []struct {
+ name string
+ features []string
+ want bool
+ }{
+ {name: "older service", features: nil, want: false},
+ {name: "current service", features: []string{"local_models"}, want: true},
+ } {
+ t.Run(test.name, func(t *testing.T) {
+ device, err := transport.GenerateIdentity()
+ if err != nil {
+ t.Fatal(err)
+ }
+ release := make(chan struct{})
+ stream := &fakeStream{
+ commands: []protocol.Command{
+ {Type: protocol.CommandRunnerWelcome, ConnectionEpoch: 1, ServiceFeatures: test.features},
+ {Type: protocol.CommandRunnerReconciled, RunnerID: "computer-1", ConnectionEpoch: 1},
+ },
+ wait: release,
+ }
+ library := &publishingLocalModels{refreshes: make(chan struct{}, 4)}
+ d, err := newTestDaemon(t, Options{
+ ComputerID: "computer-1", ControlPlane: fakeControlPlane{stream: stream}, IdentityStore: fakeStore{value: device},
+ OperationResolver: fakeOperationResolver{}, LocalModels: library,
+ Owners: []ComputerOwner{{TenantID: "tenant", OwnerActorID: "owner"}},
+ })
+ if err != nil {
+ t.Fatal(err)
+ }
+ library.publish = d.PublishLocalModels
+ done := make(chan error, 1)
+ go func() { done <- d.runConnection(t.Context(), device) }()
+ // Commands apply in order, so the receipt marks the welcome applied.
+ deadline := time.Now().Add(5 * time.Second)
+ for !d.Reconciled() && time.Now().Before(deadline) {
+ time.Sleep(time.Millisecond)
+ }
+ if !d.Reconciled() {
+ t.Fatal("the connection was not welcomed")
+ }
+ if test.want {
+ select {
+ case <-library.refreshes:
+ case <-time.After(5 * time.Second):
+ t.Fatal("the welcomed connection did not read the library")
+ }
+ }
+ // A library change while connected publishes through the same gate.
+ d.PublishLocalModels(wire.LocalModelsSnapshot{Available: true})
+
+ payload, _ := json.Marshal(map[string]any{
+ "type": "execute", "kind": "local_models", "protocol_version": "2", "command_id": "command-1",
+ "runner_id": "computer-1", "tenant_id": "tenant", "owner_actor_id": "owner", "connection_epoch": 1,
+ "expires_at": time.Now().Add(time.Minute).UTC().Format(time.RFC3339Nano), "action": "refresh",
+ })
+ if err := d.handleLocalModelsCommand(t.Context(), stream, protocol.Command{
+ Type: protocol.CommandCapabilityLocalModels, ProtocolVersion: "2", CommandID: "command-1",
+ RunnerID: "computer-1", ConnectionEpoch: 1, Payload: payload,
+ }); err != nil {
+ t.Fatal(err)
+ }
+ close(release)
+ if err := <-done; !errors.Is(err, io.EOF) {
+ t.Fatalf("connection ended with %v", err)
+ }
+
+ var snapshots int
+ var outcome protocol.Event
+ for _, event := range stream.snapshotEvents() {
+ switch event.Type {
+ case protocol.EventLocalModels:
+ snapshots++
+ case protocol.EventCapabilityLocalModelsAccepted, protocol.EventCapabilityLocalModelsRefused:
+ outcome = event
+ }
+ }
+ if test.want {
+ if snapshots != 2 || outcome.Type != protocol.EventCapabilityLocalModelsAccepted {
+ t.Fatalf("snapshots = %d, outcome = %s", snapshots, outcome.Type)
+ }
+ return
+ }
+ select {
+ case <-library.refreshes:
+ t.Fatal("the library was read for a service that does not accept snapshots")
+ default:
+ }
+ if snapshots != 0 || outcome.Type != protocol.EventCapabilityLocalModelsRefused {
+ t.Fatalf("snapshots = %d, outcome = %s", snapshots, outcome.Type)
+ }
+ if actions := library.actions; len(actions) != 0 {
+ t.Fatalf("the library ran %+v", actions)
+ }
+ })
+ }
+}
diff --git a/apps/computer/local-daemon/internal/daemon/operation_input_lifecycle_test.go b/apps/computer/local-daemon/internal/daemon/operation_input_lifecycle_test.go
index 1260d9dc..ece1f046 100644
--- a/apps/computer/local-daemon/internal/daemon/operation_input_lifecycle_test.go
+++ b/apps/computer/local-daemon/internal/daemon/operation_input_lifecycle_test.go
@@ -116,7 +116,7 @@ func TestOperationInputRecordFailureStopsTheDaemonWithoutATerminal(t *testing.T)
backend.complete = make(chan struct{})
d.ledger = inputOutcomeFailureLedger{d.ledger}
stream := &fakeStream{}
- if err := d.activateStreamAndReplay(t.Context(), stream, nil); err != nil {
+ if err := d.activateStreamAndReplay(t.Context(), stream, nil, false); err != nil {
t.Fatal(err)
}
if err := d.handleOperationStart(t.Context(), stream, start); err != nil {
@@ -185,7 +185,7 @@ func TestOperationInputOutcomePrecedesImmediateTerminal(t *testing.T) {
d, _, start, input, backend := delayedInputFixture(t)
backend.complete = make(chan struct{})
stream := &fakeStream{}
- if err := d.activateStreamAndReplay(t.Context(), stream, nil); err != nil {
+ if err := d.activateStreamAndReplay(t.Context(), stream, nil, false); err != nil {
t.Fatal(err)
}
if err := d.handleOperationStart(t.Context(), stream, start); err != nil {
@@ -400,7 +400,7 @@ func TestOperationInputBusyReceiptPrecedesConcurrentOutput(t *testing.T) {
close(stream.release)
}
})
- if err := d.activateStreamAndReplay(t.Context(), stream, nil); err != nil {
+ if err := d.activateStreamAndReplay(t.Context(), stream, nil, false); err != nil {
t.Fatal(err)
}
if err := d.handleOperationStart(t.Context(), stream, start); err != nil {
@@ -443,7 +443,7 @@ func TestOperationInputRuntimeResponseIsNotBusyBehindASteer(t *testing.T) {
d, _, start, input, backend := delayedInputFixture(t)
backend.complete = make(chan struct{})
stream := &fakeStream{}
- if err := d.activateStreamAndReplay(t.Context(), stream, nil); err != nil {
+ if err := d.activateStreamAndReplay(t.Context(), stream, nil, false); err != nil {
t.Fatal(err)
}
if err := d.handleOperationStart(t.Context(), stream, start); err != nil {
diff --git a/apps/computer/local-daemon/internal/protocol/types.go b/apps/computer/local-daemon/internal/protocol/types.go
index b77bf1ee..3dbbf564 100644
--- a/apps/computer/local-daemon/internal/protocol/types.go
+++ b/apps/computer/local-daemon/internal/protocol/types.go
@@ -40,6 +40,7 @@ type Command struct {
ReconcileOperationIDs []string `json:"reconcile_operation_ids,omitempty"`
ContextContentURL string `json:"context_content_url,omitempty"`
TargetRelease *TargetRelease `json:"target_release,omitempty"`
+ ServiceFeatures []string `json:"service_features,omitempty"`
Payload json.RawMessage `json:"payload,omitempty"`
}
diff --git a/apps/computer/package.json b/apps/computer/package.json
index 268ed3c0..55d4271c 100644
--- a/apps/computer/package.json
+++ b/apps/computer/package.json
@@ -1,6 +1,6 @@
{
"name": "@linger/computer",
- "version": "0.51.0",
+ "version": "0.52.0",
"description": "Local Computer: resident Daemon, control CLI, and Runner Gateway transport.",
"private": true,
"type": "module",
diff --git a/apps/node-services/src/agent/runner-gateway/local-computer-management.ts b/apps/node-services/src/agent/runner-gateway/local-computer-management.ts
index 7c48c6b5..f0e10434 100644
--- a/apps/node-services/src/agent/runner-gateway/local-computer-management.ts
+++ b/apps/node-services/src/agent/runner-gateway/local-computer-management.ts
@@ -25,6 +25,10 @@ export const MINIMUM_CURRENT_COMPUTER_VERSION = "0.44.0";
// below the current release updates itself from the welcome's
// `target_release`; an older protocol 2 build is refused.
export const FIRST_PROTOCOL_2_COMPUTER_VERSION = "0.43.0";
+// The first release that decodes runner.welcome's `service_features`. An
+// older Computer rejects the unknown key and would never reach its
+// `target_release`, so it is welcomed without the field.
+export const FIRST_SERVICE_FEATURES_COMPUTER_VERSION = "0.52.0";
const COMPUTER_RELEASE_VERSION = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)$/;
diff --git a/apps/node-services/src/agent/runner-gateway/runner-connections.ts b/apps/node-services/src/agent/runner-gateway/runner-connections.ts
index 1118e19e..ea951344 100644
--- a/apps/node-services/src/agent/runner-gateway/runner-connections.ts
+++ b/apps/node-services/src/agent/runner-gateway/runner-connections.ts
@@ -24,6 +24,7 @@ import {
LocalComputerPlacementError,
LocalRuntimeAdmissionUnavailableError,
MINIMUM_CURRENT_COMPUTER_VERSION,
+ FIRST_SERVICE_FEATURES_COMPUTER_VERSION,
type LocalPlacementRequirement,
type LocalReasoningEffort,
type LocalRuntimeModelDefinition,
@@ -449,6 +450,12 @@ export class RunnerConnections {
),
}
: {}),
+ ...(isComputerVersionAtLeast(
+ connection.hello.daemon_version,
+ FIRST_SERVICE_FEATURES_COMPUTER_VERSION,
+ )
+ ? { service_features: ["local_models"] }
+ : {}),
};
}
diff --git a/apps/node-services/tests/agent/runner-gateway/runner-gateway-local-models.test.ts b/apps/node-services/tests/agent/runner-gateway/runner-gateway-local-models.test.ts
index 0a8bc856..342f1747 100644
--- a/apps/node-services/tests/agent/runner-gateway/runner-gateway-local-models.test.ts
+++ b/apps/node-services/tests/agent/runner-gateway/runner-gateway-local-models.test.ts
@@ -89,7 +89,10 @@ const snapshot = (toolVersion: string): LocalModelsSnapshot => ({
],
});
-const connect = async (registry?: TestLocalComputerRegistry) => {
+const connect = async (
+ registry?: TestLocalComputerRegistry,
+ daemonVersion = "dev",
+) => {
const computerRegistry = registry ?? createTestLocalComputerRegistry();
computerRegistry.enroll({ ...target });
const gateway = createTestRunnerGateway({
@@ -110,7 +113,7 @@ const connect = async (registry?: TestLocalComputerRegistry) => {
type: "runner.hello",
platform: "linux",
protocol_version: "2",
- daemon_version: "dev",
+ daemon_version: daemonVersion,
...currentRunnerIdentity(),
capabilities: [...CURRENT_RUNNER_CAPABILITIES],
runner_id: target.computerId,
@@ -147,7 +150,15 @@ const connect = async (registry?: TestLocalComputerRegistry) => {
sent.splice(sent.indexOf(value), 1);
return value;
};
- return { gateway, connection, computerRegistry, report, command, close };
+ return {
+ gateway,
+ connection,
+ computerRegistry,
+ report,
+ command,
+ close,
+ sent,
+ };
};
const isLocalModelsCommand = (
@@ -174,6 +185,27 @@ const versions = (registry: TestLocalComputerRegistry) =>
.map((recorded) => recorded.tool_version);
describe("Runner Gateway local models", () => {
+ // A Computer sends runner.local_models only when the welcome names the
+ // family; a release before 0.52.0 rejects the unknown welcome key, so it
+ // is welcomed without it and keeps receiving its target_release.
+ it.each([
+ ["dev", ["local_models"]],
+ ["0.52.0", ["local_models"]],
+ ["0.51.0", undefined],
+ ])(
+ "welcomes a %s Computer with service_features %j",
+ async (daemonVersion, expected) => {
+ const { sent } = await connect(undefined, daemonVersion);
+ const welcome = sent.find((frame) => frame.type === "runner.welcome");
+ expect(welcome).toBeDefined();
+ expect(
+ welcome && "service_features" in welcome
+ ? welcome.service_features
+ : undefined,
+ ).toEqual(expected);
+ },
+ );
+
it("records each snapshot in TeamHub and drops a stale revision", async () => {
const { computerRegistry, report } = await connect();
await report(1);
diff --git a/contracts/generated/go/runnergateway/wire.gen.go b/contracts/generated/go/runnergateway/wire.gen.go
index 19ef9012..85952282 100644
--- a/contracts/generated/go/runnergateway/wire.gen.go
+++ b/contracts/generated/go/runnergateway/wire.gen.go
@@ -1531,6 +1531,7 @@ type RunnerWelcome struct {
ReconcileOperationIDs []string `json:"reconcile_operation_ids"`
TargetRelease *ComputerTargetRelease `json:"target_release,omitempty"`
ContextContentURL string `json:"context_content_url,omitempty"`
+ ServiceFeatures []string `json:"service_features,omitempty"`
}
// FixedFields lists the keys whose value the schema fixes for a RunnerWelcome.
diff --git a/contracts/generated/typescript/src/generated/runner-gateway/schema.ts b/contracts/generated/typescript/src/generated/runner-gateway/schema.ts
index 3721d334..f817b4cf 100644
--- a/contracts/generated/typescript/src/generated/runner-gateway/schema.ts
+++ b/contracts/generated/typescript/src/generated/runner-gateway/schema.ts
@@ -189,6 +189,11 @@ export const runnerGatewayEnvelopeSchema = {
"A host feature the Computer has. Every other v2 behavior is part of protocol 2 itself.",
enum: ["browser_connection", "computer_permissions"],
},
+ ServiceFeature: {
+ description:
+ "An optional Runner behavior the Agent Service accepts. An older service rejects its frames as a protocol violation.",
+ enum: ["local_models"],
+ },
Timestamp: {
type: "string",
format: "date-time",
@@ -2581,7 +2586,7 @@ export const runnerGatewayEnvelopeSchema = {
},
RunnerLocalModels: {
description:
- "The Computer's model library. Sent after runner.hello, after every library change, and at most every 2 seconds while a download or load runs. revision grows within one connection.",
+ "The Computer's model library. Sent after a runner.welcome whose service_features names local_models, after every library change, and at most every 2 seconds while a download or load runs. revision grows within one connection.",
type: "object",
additionalProperties: false,
required: [
@@ -2949,6 +2954,15 @@ export const runnerGatewayEnvelopeSchema = {
maxLength: 2048,
pattern: "^https?://",
},
+ service_features: {
+ description:
+ "Runner behaviors this Agent Service accepts beyond the protocol 2 base. A Computer sends runner.local_models and runs execute with kind local_models only when the list names local_models. The service sends the field only to a Computer release that decodes it.",
+ type: "array",
+ uniqueItems: true,
+ items: {
+ $ref: "#/$defs/ServiceFeature",
+ },
+ },
},
},
ComputerReleaseArchive: {
diff --git a/contracts/generated/typescript/src/generated/runner-gateway/types.ts b/contracts/generated/typescript/src/generated/runner-gateway/types.ts
index 4328769e..37997f34 100644
--- a/contracts/generated/typescript/src/generated/runner-gateway/types.ts
+++ b/contracts/generated/typescript/src/generated/runner-gateway/types.ts
@@ -27,6 +27,10 @@ export type AgentToDaemonEnvelope =
export type ProtocolVersion = "2";
export type Id = string;
export type PositiveInteger = number;
+/**
+ * An optional Runner behavior the Agent Service accepts. An older service rejects its frames as a protocol violation.
+ */
+export type ServiceFeature = "local_models";
export type JsonValue =
| null
| boolean
@@ -780,6 +784,10 @@ export interface RunnerWelcome {
* Base URL the Computer fetches Context View manifests (views/<view_digest>) and files (files/<sha256>) from while this connection is current.
*/
context_content_url?: string;
+ /**
+ * Runner behaviors this Agent Service accepts beyond the protocol 2 base. A Computer sends runner.local_models and runs execute with kind local_models only when the list names local_models. The service sends the field only to a Computer release that decodes it.
+ */
+ service_features?: ServiceFeature[];
}
export interface ComputerTargetRelease {
targets: {
@@ -1202,7 +1210,7 @@ export interface RunnerRuntimeDiagnostics {
runtime_diagnostics: RuntimeDiagnostics;
}
/**
- * The Computer's model library. Sent after runner.hello, after every library change, and at most every 2 seconds while a download or load runs. revision grows within one connection.
+ * The Computer's model library. Sent after a runner.welcome whose service_features names local_models, after every library change, and at most every 2 seconds while a download or load runs. revision grows within one connection.
*/
export interface RunnerLocalModels {
type: "runner.local_models";
diff --git a/contracts/runner-gateway/asyncapi.yaml b/contracts/runner-gateway/asyncapi.yaml
index 28ef3d24..c42ef72e 100644
--- a/contracts/runner-gateway/asyncapi.yaml
+++ b/contracts/runner-gateway/asyncapi.yaml
@@ -5,10 +5,14 @@ info:
description: >-
Authenticated bidirectional Agent Runner desired state and Runtime operation
protocol between Agent Service and a Local Computer Daemon. Every frame
- carries protocol_version 2; the Computer and the Agent Service are built
- from one commit, so the protocol has no feature negotiation. The only
- capabilities a Computer declares are host features (browser_connection
- and computer_permissions).
+ carries protocol_version 2. The only capabilities a Computer declares are
+ host features (browser_connection and computer_permissions). A desktop
+ upgrade can leave a newer Computer connected to an older Agent Service,
+ so a frame family added within protocol 2 is gated: runner.welcome's
+ service_features names each one the service accepts, and the Computer
+ sends nothing from a family the list leaves out. The service sends the
+ field only to a Computer release that decodes it, because an older
+ Computer rejects unknown welcome keys.
The Daemon initiates the WebSocket connection; the service-issued
connection epoch fences commands and responses after reconnect. The
Daemon receives runner.reconciled only after the service has completed
@@ -54,8 +58,9 @@ info:
refresh). The Computer answers executed with outcome accepted or refused
at once and supervises the long-running localmodels job itself; progress
and outcomes reach the service only as runner.local_models snapshots,
- which the Computer sends after runner.hello, after every library change,
- and at most every 2 seconds while a download or load runs.
+ which the Computer sends after a runner.welcome whose service_features
+ names local_models, after every library change, and at most every 2
+ seconds while a download or load runs.
x-frame-limits:
maxBytes: 4194304
maxDepth: 32
diff --git a/contracts/runner-gateway/envelope.schema.json b/contracts/runner-gateway/envelope.schema.json
index 449bb9e5..df0363bb 100644
--- a/contracts/runner-gateway/envelope.schema.json
+++ b/contracts/runner-gateway/envelope.schema.json
@@ -187,6 +187,10 @@
"description": "A host feature the Computer has. Every other v2 behavior is part of protocol 2 itself.",
"enum": ["browser_connection", "computer_permissions"]
},
+ "ServiceFeature": {
+ "description": "An optional Runner behavior the Agent Service accepts. An older service rejects its frames as a protocol violation.",
+ "enum": ["local_models"]
+ },
"Timestamp": {
"type": "string",
"format": "date-time",
@@ -2544,7 +2548,7 @@
]
},
"RunnerLocalModels": {
- "description": "The Computer's model library. Sent after runner.hello, after every library change, and at most every 2 seconds while a download or load runs. revision grows within one connection.",
+ "description": "The Computer's model library. Sent after a runner.welcome whose service_features names local_models, after every library change, and at most every 2 seconds while a download or load runs. revision grows within one connection.",
"type": "object",
"additionalProperties": false,
"required": [
@@ -2909,6 +2913,14 @@
"minLength": 1,
"maxLength": 2048,
"pattern": "^https?://"
+ },
+ "service_features": {
+ "description": "Runner behaviors this Agent Service accepts beyond the protocol 2 base. A Computer sends runner.local_models and runs execute with kind local_models only when the list names local_models. The service sends the field only to a Computer release that decodes it.",
+ "type": "array",
+ "uniqueItems": true,
+ "items": {
+ "$ref": "#/$defs/ServiceFeature"
+ }
}
}
},