Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8093cb6e6f | ||
|
|
f2d3613a89 |
@@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"monorepoCommit": "be30143a326d5d7d7b0cbabea5bc5ac0301ef5b9",
|
"monorepoCommit": "5ba3dea6851f6c67712f6cbfb31bacdcaeec9412",
|
||||||
"sourcePath": "quixos-instance/packages/agent-presentation"
|
"sourcePath": "quixos-instance/packages/agent-presentation"
|
||||||
}
|
}
|
||||||
|
|||||||
Generated
+18
-18
@@ -21,19 +21,19 @@
|
|||||||
"helpers": {
|
"helpers": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1790852599,
|
"lastModified": 1791886789,
|
||||||
"narHash": "sha256-MdNtZpcsoguLPSCpAy9Naz6fkVPrftbZQbz1Aj7Zm9A=",
|
"narHash": "sha256-7YF98v0AcxD1qkAdS+nL/aDtmTvcRzld9CB9AxY0qaA=",
|
||||||
"ref": "refs/tags/quixos-reachability/91679e8cc82133093cb0b4f9e519cbb39a5bba4f",
|
"ref": "refs/tags/quixos-reachability/5657043450c46fc84e1a6d38c2f8919ba1e9d10c",
|
||||||
"rev": "91679e8cc82133093cb0b4f9e519cbb39a5bba4f",
|
"rev": "5657043450c46fc84e1a6d38c2f8919ba1e9d10c",
|
||||||
"revCount": 54,
|
"revCount": 78,
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://gitea-external.egads.tutti.syntaxblitz.net/quixos/quixos-nix-helpers.git"
|
"url": "https://repos.quixos.org/quixos-toolchain/quixos-nix-helpers.git"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"ref": "refs/tags/quixos-reachability/91679e8cc82133093cb0b4f9e519cbb39a5bba4f",
|
"ref": "refs/tags/quixos-reachability/5657043450c46fc84e1a6d38c2f8919ba1e9d10c",
|
||||||
"rev": "91679e8cc82133093cb0b4f9e519cbb39a5bba4f",
|
"rev": "5657043450c46fc84e1a6d38c2f8919ba1e9d10c",
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://gitea-external.egads.tutti.syntaxblitz.net/quixos/quixos-nix-helpers.git"
|
"url": "https://repos.quixos.org/quixos-toolchain/quixos-nix-helpers.git"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
@@ -58,19 +58,19 @@
|
|||||||
"nixpkgs": "nixpkgs"
|
"nixpkgs": "nixpkgs"
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1791261504,
|
"lastModified": 1792963716,
|
||||||
"narHash": "sha256-QSk9DWR7n5KL6cMHzmSKKXNIyaFA0s8Nu+wXjhhlENI=",
|
"narHash": "sha256-MESSLO46ZHYtxVhlNpQfpiHi/A6WJEYDnczr+I3Wfb8=",
|
||||||
"ref": "refs/tags/quixos-reachability/5b44c8154dc038efd87cf1cbdd2c00b66bfd4f87",
|
"ref": "refs/tags/quixos-reachability/d829d584af91326aacb8997459014c49def2f66e",
|
||||||
"rev": "5b44c8154dc038efd87cf1cbdd2c00b66bfd4f87",
|
"rev": "d829d584af91326aacb8997459014c49def2f66e",
|
||||||
"revCount": 184,
|
"revCount": 233,
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://gitea-external.egads.tutti.syntaxblitz.net/quixos/quixos-protocol.git"
|
"url": "https://repos.quixos.org/quixos-toolchain/quixos-protocol.git"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"ref": "refs/tags/quixos-reachability/5b44c8154dc038efd87cf1cbdd2c00b66bfd4f87",
|
"ref": "refs/tags/quixos-reachability/d829d584af91326aacb8997459014c49def2f66e",
|
||||||
"rev": "5b44c8154dc038efd87cf1cbdd2c00b66bfd4f87",
|
"rev": "d829d584af91326aacb8997459014c49def2f66e",
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://gitea-external.egads.tutti.syntaxblitz.net/quixos/quixos-protocol.git"
|
"url": "https://repos.quixos.org/quixos-toolchain/quixos-protocol.git"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"root": {
|
"root": {
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
{
|
{
|
||||||
inputs.protocol.url = "git+https://gitea-external.egads.tutti.syntaxblitz.net/quixos/quixos-protocol.git?ref=refs/tags/quixos-reachability/5b44c8154dc038efd87cf1cbdd2c00b66bfd4f87&rev=5b44c8154dc038efd87cf1cbdd2c00b66bfd4f87";
|
inputs.protocol.url = "git+https://repos.quixos.org/quixos-toolchain/quixos-protocol.git?ref=refs/tags/quixos-reachability/d829d584af91326aacb8997459014c49def2f66e&rev=d829d584af91326aacb8997459014c49def2f66e";
|
||||||
inputs.nixpkgs.follows = "protocol/nixpkgs";
|
inputs.nixpkgs.follows = "protocol/nixpkgs";
|
||||||
inputs.flake-utils.follows = "protocol/flake-utils";
|
inputs.flake-utils.follows = "protocol/flake-utils";
|
||||||
inputs.helpers = {
|
inputs.helpers = {
|
||||||
url = "git+https://gitea-external.egads.tutti.syntaxblitz.net/quixos/quixos-nix-helpers.git?ref=refs/tags/quixos-reachability/91679e8cc82133093cb0b4f9e519cbb39a5bba4f&rev=91679e8cc82133093cb0b4f9e519cbb39a5bba4f";
|
url = "git+https://repos.quixos.org/quixos-toolchain/quixos-nix-helpers.git?ref=refs/tags/quixos-reachability/5657043450c46fc84e1a6d38c2f8919ba1e9d10c&rev=5657043450c46fc84e1a6d38c2f8919ba1e9d10c";
|
||||||
flake = false;
|
flake = false;
|
||||||
};
|
};
|
||||||
outputs =
|
outputs =
|
||||||
|
|||||||
+7
-7
@@ -1,9 +1,9 @@
|
|||||||
quixos-lock version 1 {
|
quixos-lock version 1 {
|
||||||
quixos source { repository "https://gitea-external.egads.tutti.syntaxblitz.net/quixos/quixos.git"; commit "be30143a326d5d7d7b0cbabea5bc5ac0301ef5b9"; }
|
quixos source { repository "https://gitea.internal.quixos.org/quixos/quixos.git"; commit "5ba3dea6851f6c67712f6cbfb31bacdcaeec9412"; }
|
||||||
interface StandaloneView source { repository "https://repos.quixos.org/quixos-templates/interface-react-standalone-view.git"; commit "29a974e9db15387c9efc0f0fe64fec348db10344"; }
|
interface StandaloneView source { repository "https://repos.quixos.org/quixos-templates/interface-react-standalone-view.git"; commit "747fa5394f286e7f652e840e9a1db2910e1a265b"; }
|
||||||
interface AgentThread source { repository "https://repos.quixos.org/quixos-templates/interface-agent-thread.git"; commit "6ace62f773c230c468efeabe9b5aac35115b7900"; }
|
interface AgentThread source { repository "https://repos.quixos.org/quixos-templates/interface-agent-thread.git"; commit "8b05fe11b9aabc031a340de7c9c81a25f8ec94f9"; }
|
||||||
interface Agent source { repository "https://repos.quixos.org/quixos-templates/interface-agent.git"; commit "dcd3f271b42649b4ce15a890f9b41e19a7271563"; }
|
interface Agent source { repository "https://repos.quixos.org/quixos-templates/interface-agent.git"; commit "e8a11c82e031dbf9224cfc3bcc61c1b5adae775e"; }
|
||||||
interface AgentRequest source { repository "https://repos.quixos.org/quixos-templates/interface-agent-request.git"; commit "7f1e9d6278366329fd76f2698cd5a53c136f9914"; }
|
interface AgentRequest source { repository "https://repos.quixos.org/quixos-templates/interface-agent-request.git"; commit "bd3b13e42428eef7c7fee0aeeffdb216257fa05e"; }
|
||||||
interface AgentItem source { repository "https://repos.quixos.org/quixos-templates/interface-agent-item.git"; commit "6e702e5cab24634d306c8f657f3a0b4873469060"; }
|
interface AgentItem source { repository "https://repos.quixos.org/quixos-templates/interface-agent-item.git"; commit "44b07538e173d36809a08872489d2177f0b9a45a"; }
|
||||||
interface AgentQuestion source { repository "https://repos.quixos.org/quixos-templates/interface-agent-question.git"; commit "7d69058c2c12b4ca1800d8ff8218caffa45e5d13"; }
|
interface AgentQuestion source { repository "https://repos.quixos.org/quixos-templates/interface-agent-question.git"; commit "95745dba5fcfe0c548e0065e483b937adf634517"; }
|
||||||
}
|
}
|
||||||
|
|||||||
+81
-5
@@ -50,6 +50,64 @@ export const control = async (input: Record<string, unknown>) => {
|
|||||||
};
|
};
|
||||||
export const draftKey = (thread: string) => `quixos.agent.draft:${location.origin}:${thread}`;
|
export const draftKey = (thread: string) => `quixos.agent.draft:${location.origin}:${thread}`;
|
||||||
|
|
||||||
|
/** Status and directory invalidation shared by shells, without a recurring
|
||||||
|
* snapshot timer. Reconnecting rechecks state to cover disconnected changes. */
|
||||||
|
export function subscribeAgentUpdates(listener: () => void, onError: (error: unknown) => void) {
|
||||||
|
const abort = new AbortController();
|
||||||
|
let timer: ReturnType<typeof setTimeout> | undefined;
|
||||||
|
const changed = () => {
|
||||||
|
timer ??= setTimeout(() => {
|
||||||
|
timer = undefined;
|
||||||
|
listener();
|
||||||
|
}, 100);
|
||||||
|
};
|
||||||
|
void (async () => {
|
||||||
|
while (!abort.signal.aborted) {
|
||||||
|
try {
|
||||||
|
const response = await fetch("/api/agent/updates", { credentials: "same-origin", signal: abort.signal });
|
||||||
|
if (!response.ok || !response.body) throw Error("Agent updates unavailable");
|
||||||
|
const reader = response.body.getReader(),
|
||||||
|
decoder = new TextDecoder();
|
||||||
|
let buffer = "";
|
||||||
|
try {
|
||||||
|
while (!abort.signal.aborted) {
|
||||||
|
const chunk = await reader.read();
|
||||||
|
if (chunk.done) break;
|
||||||
|
buffer += decoder.decode(chunk.value, { stream: true });
|
||||||
|
if (buffer.length > 65536) throw Error("Agent update frame exceeds limit");
|
||||||
|
let end: number;
|
||||||
|
while ((end = buffer.indexOf("\n")) !== -1) {
|
||||||
|
const line = buffer.slice(0, end);
|
||||||
|
buffer = buffer.slice(end + 1);
|
||||||
|
if (line && JSON.parse(line).type === "changed") changed();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
await reader.cancel().catch(() => {});
|
||||||
|
reader.releaseLock();
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
if (!abort.signal.aborted) onError(error);
|
||||||
|
}
|
||||||
|
if (!abort.signal.aborted)
|
||||||
|
await new Promise<void>((resolve) => {
|
||||||
|
const finish = () => {
|
||||||
|
clearTimeout(retry);
|
||||||
|
abort.signal.removeEventListener("abort", finish);
|
||||||
|
resolve();
|
||||||
|
};
|
||||||
|
const retry = setTimeout(finish, 1000);
|
||||||
|
abort.signal.addEventListener("abort", finish, { once: true });
|
||||||
|
if (abort.signal.aborted) finish();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})();
|
||||||
|
return () => {
|
||||||
|
abort.abort();
|
||||||
|
clearTimeout(timer);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/** A browser observer owns no executor. Closing it only stops reads. */
|
/** A browser observer owns no executor. Closing it only stops reads. */
|
||||||
export class HttpThreadController implements ThreadController {
|
export class HttpThreadController implements ThreadController {
|
||||||
private state: ThreadState = {
|
private state: ThreadState = {
|
||||||
@@ -65,7 +123,8 @@ export class HttpThreadController implements ThreadController {
|
|||||||
private requests = new Map<string, Request>();
|
private requests = new Map<string, Request>();
|
||||||
private aliases = new Map<string, Ref>();
|
private aliases = new Map<string, Ref>();
|
||||||
private abort = new AbortController();
|
private abort = new AbortController();
|
||||||
private timer?: ReturnType<typeof setInterval>;
|
private timer?: ReturnType<typeof setTimeout>;
|
||||||
|
private refreshNeeded = false;
|
||||||
private refreshing?: Promise<void>;
|
private refreshing?: Promise<void>;
|
||||||
private closed = false;
|
private closed = false;
|
||||||
constructor(
|
constructor(
|
||||||
@@ -76,9 +135,6 @@ export class HttpThreadController implements ThreadController {
|
|||||||
void this.refresh()
|
void this.refresh()
|
||||||
.catch((error) => this.patch({ error: String(error), loading: false }))
|
.catch((error) => this.patch({ error: String(error), loading: false }))
|
||||||
.finally(() => this.stream());
|
.finally(() => this.stream());
|
||||||
this.timer = setInterval(() => {
|
|
||||||
void this.refresh().catch(() => {});
|
|
||||||
}, 2000);
|
|
||||||
}
|
}
|
||||||
getSnapshot = () => this.state;
|
getSnapshot = () => this.state;
|
||||||
subscribe = (callback: () => void) => {
|
subscribe = (callback: () => void) => {
|
||||||
@@ -290,6 +346,21 @@ export class HttpThreadController implements ThreadController {
|
|||||||
if (!older) this.refreshing = task;
|
if (!older) this.refreshing = task;
|
||||||
return task;
|
return task;
|
||||||
};
|
};
|
||||||
|
private scheduleRefresh() {
|
||||||
|
this.refreshNeeded = true;
|
||||||
|
if (this.closed || this.timer) return;
|
||||||
|
this.timer = setTimeout(() => {
|
||||||
|
this.timer = undefined;
|
||||||
|
this.refreshNeeded = false;
|
||||||
|
void (async () => {
|
||||||
|
// A notification arriving during a previous snapshot needs a subsequent
|
||||||
|
// read, not merely the same in-flight promise.
|
||||||
|
await this.refreshing?.catch(() => {});
|
||||||
|
await this.refresh().catch(() => {});
|
||||||
|
if (this.refreshNeeded) this.scheduleRefresh();
|
||||||
|
})();
|
||||||
|
}, 100);
|
||||||
|
}
|
||||||
private async stream() {
|
private async stream() {
|
||||||
while (!this.closed) {
|
while (!this.closed) {
|
||||||
try {
|
try {
|
||||||
@@ -300,6 +371,7 @@ export class HttpThreadController implements ThreadController {
|
|||||||
);
|
);
|
||||||
if (!response.ok || !response.body) throw Error("Live Agent stream unavailable");
|
if (!response.ok || !response.body) throw Error("Live Agent stream unavailable");
|
||||||
this.patch({ connected: true });
|
this.patch({ connected: true });
|
||||||
|
this.scheduleRefresh();
|
||||||
const reader = response.body.getReader(),
|
const reader = response.body.getReader(),
|
||||||
decoder = new TextDecoder();
|
decoder = new TextDecoder();
|
||||||
let buffer = "";
|
let buffer = "";
|
||||||
@@ -315,6 +387,10 @@ export class HttpThreadController implements ThreadController {
|
|||||||
buffer = buffer.slice(end + 1);
|
buffer = buffer.slice(end + 1);
|
||||||
if (!line) continue;
|
if (!line) continue;
|
||||||
const event = JSON.parse(line);
|
const event = JSON.parse(line);
|
||||||
|
if (event.type === "graph") {
|
||||||
|
this.scheduleRefresh();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (event.type === "reset") {
|
if (event.type === "reset") {
|
||||||
await this.refresh();
|
await this.refresh();
|
||||||
break;
|
break;
|
||||||
@@ -425,7 +501,7 @@ export class HttpThreadController implements ThreadController {
|
|||||||
close = () => {
|
close = () => {
|
||||||
this.closed = true;
|
this.closed = true;
|
||||||
this.abort.abort();
|
this.abort.abort();
|
||||||
clearInterval(this.timer);
|
clearTimeout(this.timer);
|
||||||
this.listeners.clear();
|
this.listeners.clear();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user