Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): release agent-device sessions when device_close runs #21478

Mergedonly21mil(GitHub profile, opens in a new tab)merged 15 commits intomain fromrefs/pull/21478/headmerged by maria-rcks View on GitHub

Showing 13 changed files with 68 additions and 13 deletions (loading 10).

x
0 of 13 viewed, 13 left
36 additions and 0 deletionsapps/server/src/device/AgentDeviceTarget.tsModified
View file
@@ -1,9 +1,12 @@
+import { DeviceOperationError } from "@t3tools/contracts";
import * as Crypto from "effect/Crypto";
+import * as Duration from "effect/Duration";
import * as Effect from "effect/Effect";
import * as Hex from "effect/encoding/Hex";
import * as Schema from "effect/Schema";
import * as FileSystem from "effect/FileSystem";
import * as Path from "effect/Path";
+import { HttpClient, HttpClientRequest, HttpClientResponse } from "effect/http";
​
import type { AgentDaemonEndpoint } from "./DeviceHost.ts";
​
@@ -62,3 +65,36 @@
yield* fs.rename(temporary, file);
}).pipe(Effect.ensuring(fs.remove(temporary, { force: true }).pipe(Effect.ignore)));
});
+​
+const AgentCloseResult = Schema.Union([
+ Schema.Struct({ result: Schema.Struct({ ok: Schema.Literal(true) }) }),
+ Schema.Struct({
+ error: Schema.Struct({
+ data: Schema.Struct({ code: Schema.Literal("SESSION_NOT_FOUND") }),
+ }),
+ }),
+]);
+​
+/** Ends an agent-device session on a running daemon; an already-released session succeeds. */
+export const releaseAgentDeviceSession =
+ (http: HttpClient.HttpClient, endpoint: AgentDaemonEndpoint) => (session: string) =>