Compare commits

..
7 changed files with 41 additions and 165 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
{
"monorepoCommit": "2f96d311e60b625d14b2815cc789bc3d010332db",
"monorepoCommit": "be30143a326d5d7d7b0cbabea5bc5ac0301ef5b9",
"sourcePath": "quixos-instance/packages/agent-presentation"
}
Generated
+18 -18
View File
@@ -21,19 +21,19 @@
"helpers": {
"flake": false,
"locked": {
"lastModified": 1793277056,
"narHash": "sha256-w7TrYSjU8hbVrqbLdHgxDJAzMdN2NoWe+HkInJLWRlI=",
"ref": "refs/tags/quixos-reachability/c2454054dac36fb7a6ff12004003170a65e4f288",
"rev": "c2454054dac36fb7a6ff12004003170a65e4f288",
"revCount": 85,
"lastModified": 1790852599,
"narHash": "sha256-MdNtZpcsoguLPSCpAy9Naz6fkVPrftbZQbz1Aj7Zm9A=",
"ref": "refs/tags/quixos-reachability/91679e8cc82133093cb0b4f9e519cbb39a5bba4f",
"rev": "91679e8cc82133093cb0b4f9e519cbb39a5bba4f",
"revCount": 54,
"type": "git",
"url": "https://repos.quixos.org/quixos-toolchain/quixos-nix-helpers.git"
"url": "https://gitea-external.egads.tutti.syntaxblitz.net/quixos/quixos-nix-helpers.git"
},
"original": {
"ref": "refs/tags/quixos-reachability/c2454054dac36fb7a6ff12004003170a65e4f288",
"rev": "c2454054dac36fb7a6ff12004003170a65e4f288",
"ref": "refs/tags/quixos-reachability/91679e8cc82133093cb0b4f9e519cbb39a5bba4f",
"rev": "91679e8cc82133093cb0b4f9e519cbb39a5bba4f",
"type": "git",
"url": "https://repos.quixos.org/quixos-toolchain/quixos-nix-helpers.git"
"url": "https://gitea-external.egads.tutti.syntaxblitz.net/quixos/quixos-nix-helpers.git"
}
},
"nixpkgs": {
@@ -58,19 +58,19 @@
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1793458533,
"narHash": "sha256-DnK9ad5YJXxyPqJYt2ysA9Kt6YcUmQV/EGmPzt5rleg=",
"ref": "refs/tags/quixos-reachability/27af7af6c5704c7d9c39fd14d5875ccb1aaca1fd",
"rev": "27af7af6c5704c7d9c39fd14d5875ccb1aaca1fd",
"revCount": 241,
"lastModified": 1791261504,
"narHash": "sha256-QSk9DWR7n5KL6cMHzmSKKXNIyaFA0s8Nu+wXjhhlENI=",
"ref": "refs/tags/quixos-reachability/5b44c8154dc038efd87cf1cbdd2c00b66bfd4f87",
"rev": "5b44c8154dc038efd87cf1cbdd2c00b66bfd4f87",
"revCount": 184,
"type": "git",
"url": "https://repos.quixos.org/quixos-toolchain/quixos-protocol.git"
"url": "https://gitea-external.egads.tutti.syntaxblitz.net/quixos/quixos-protocol.git"
},
"original": {
"ref": "refs/tags/quixos-reachability/27af7af6c5704c7d9c39fd14d5875ccb1aaca1fd",
"rev": "27af7af6c5704c7d9c39fd14d5875ccb1aaca1fd",
"ref": "refs/tags/quixos-reachability/5b44c8154dc038efd87cf1cbdd2c00b66bfd4f87",
"rev": "5b44c8154dc038efd87cf1cbdd2c00b66bfd4f87",
"type": "git",
"url": "https://repos.quixos.org/quixos-toolchain/quixos-protocol.git"
"url": "https://gitea-external.egads.tutti.syntaxblitz.net/quixos/quixos-protocol.git"
}
},
"root": {
+2 -2
View File
@@ -1,9 +1,9 @@
{
inputs.protocol.url = "git+https://repos.quixos.org/quixos-toolchain/quixos-protocol.git?ref=refs/tags/quixos-reachability/27af7af6c5704c7d9c39fd14d5875ccb1aaca1fd&rev=27af7af6c5704c7d9c39fd14d5875ccb1aaca1fd";
inputs.protocol.url = "git+https://gitea-external.egads.tutti.syntaxblitz.net/quixos/quixos-protocol.git?ref=refs/tags/quixos-reachability/5b44c8154dc038efd87cf1cbdd2c00b66bfd4f87&rev=5b44c8154dc038efd87cf1cbdd2c00b66bfd4f87";
inputs.nixpkgs.follows = "protocol/nixpkgs";
inputs.flake-utils.follows = "protocol/flake-utils";
inputs.helpers = {
url = "git+https://repos.quixos.org/quixos-toolchain/quixos-nix-helpers.git?ref=refs/tags/quixos-reachability/c2454054dac36fb7a6ff12004003170a65e4f288&rev=c2454054dac36fb7a6ff12004003170a65e4f288";
url = "git+https://gitea-external.egads.tutti.syntaxblitz.net/quixos/quixos-nix-helpers.git?ref=refs/tags/quixos-reachability/91679e8cc82133093cb0b4f9e519cbb39a5bba4f&rev=91679e8cc82133093cb0b4f9e519cbb39a5bba4f";
flake = false;
};
outputs =
+7 -7
View File
@@ -1,9 +1,9 @@
quixos-lock version 1 {
quixos source { repository "https://gitea.internal.quixos.org/quixos/quixos.git"; commit "2f96d311e60b625d14b2815cc789bc3d010332db"; }
interface StandaloneView source { repository "https://repos.quixos.org/quixos-templates/interface-react-standalone-view.git"; commit "c486be1264a3f2d1f949f918974b191daa2d6f17"; }
interface AgentThread source { repository "https://repos.quixos.org/quixos-templates/interface-agent-thread.git"; commit "7932c1f7094d7c809800b550a52d57a818964e2b"; }
interface Agent source { repository "https://repos.quixos.org/quixos-templates/interface-agent.git"; commit "5abffa1e5e3429cc29f7124fb6716eb2971abadf"; }
interface AgentRequest source { repository "https://repos.quixos.org/quixos-templates/interface-agent-request.git"; commit "594fc97ff6405480eb9976057882172aee6fd1f6"; }
interface AgentItem source { repository "https://repos.quixos.org/quixos-templates/interface-agent-item.git"; commit "e1362479401742ac56f9bc2a6d0c43d6afbc86bd"; }
interface AgentQuestion source { repository "https://repos.quixos.org/quixos-templates/interface-agent-question.git"; commit "43cb66befeb29ca0b7c4293817630ac9782ff7cc"; }
quixos source { repository "https://gitea-external.egads.tutti.syntaxblitz.net/quixos/quixos.git"; commit "be30143a326d5d7d7b0cbabea5bc5ac0301ef5b9"; }
interface StandaloneView source { repository "https://repos.quixos.org/quixos-templates/interface-react-standalone-view.git"; commit "29a974e9db15387c9efc0f0fe64fec348db10344"; }
interface AgentThread source { repository "https://repos.quixos.org/quixos-templates/interface-agent-thread.git"; commit "6ace62f773c230c468efeabe9b5aac35115b7900"; }
interface Agent source { repository "https://repos.quixos.org/quixos-templates/interface-agent.git"; commit "dcd3f271b42649b4ce15a890f9b41e19a7271563"; }
interface AgentRequest source { repository "https://repos.quixos.org/quixos-templates/interface-agent-request.git"; commit "7f1e9d6278366329fd76f2698cd5a53c136f9914"; }
interface AgentItem source { repository "https://repos.quixos.org/quixos-templates/interface-agent-item.git"; commit "6e702e5cab24634d306c8f657f3a0b4873469060"; }
interface AgentQuestion source { repository "https://repos.quixos.org/quixos-templates/interface-agent-question.git"; commit "7d69058c2c12b4ca1800d8ff8218caffa45e5d13"; }
}
+5 -81
View File
@@ -50,64 +50,6 @@ export const control = async (input: Record<string, unknown>) => {
};
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. */
export class HttpThreadController implements ThreadController {
private state: ThreadState = {
@@ -123,8 +65,7 @@ export class HttpThreadController implements ThreadController {
private requests = new Map<string, Request>();
private aliases = new Map<string, Ref>();
private abort = new AbortController();
private timer?: ReturnType<typeof setTimeout>;
private refreshNeeded = false;
private timer?: ReturnType<typeof setInterval>;
private refreshing?: Promise<void>;
private closed = false;
constructor(
@@ -135,6 +76,9 @@ export class HttpThreadController implements ThreadController {
void this.refresh()
.catch((error) => this.patch({ error: String(error), loading: false }))
.finally(() => this.stream());
this.timer = setInterval(() => {
void this.refresh().catch(() => {});
}, 2000);
}
getSnapshot = () => this.state;
subscribe = (callback: () => void) => {
@@ -346,21 +290,6 @@ export class HttpThreadController implements ThreadController {
if (!older) this.refreshing = 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() {
while (!this.closed) {
try {
@@ -371,7 +300,6 @@ export class HttpThreadController implements ThreadController {
);
if (!response.ok || !response.body) throw Error("Live Agent stream unavailable");
this.patch({ connected: true });
this.scheduleRefresh();
const reader = response.body.getReader(),
decoder = new TextDecoder();
let buffer = "";
@@ -387,10 +315,6 @@ export class HttpThreadController implements ThreadController {
buffer = buffer.slice(end + 1);
if (!line) continue;
const event = JSON.parse(line);
if (event.type === "graph") {
this.scheduleRefresh();
continue;
}
if (event.type === "reset") {
await this.refresh();
break;
@@ -501,7 +425,7 @@ export class HttpThreadController implements ThreadController {
close = () => {
this.closed = true;
this.abort.abort();
clearTimeout(this.timer);
clearInterval(this.timer);
this.listeners.clear();
};
}
+8 -55
View File
@@ -144,62 +144,17 @@ function QuestionForm({
</form>
);
}
function activityValue(item: Item) {
try {
return JSON.parse(item.data.activity ?? "null");
} catch {
return null;
}
}
function activityFailed(item: Item) {
const value = activityValue(item);
return (
["failed", "error", "cancelled", "uncertain"].includes(value?.status) ||
(typeof value?.exitCode === "number" && value.exitCode !== 0)
);
}
function Activity({ item }: { item: Item }) {
const value = activityValue(item),
failed = activityFailed(item),
title = value?.command ?? value?.label ?? item.data.text ?? "Activity";
let value: any;
try {
value = JSON.parse(item.data.activity ?? "null");
} catch {}
const title = value?.command ?? value?.label ?? item.data.text ?? "Activity";
return (
<details className="agent-activity-card">
<summary>{failed ? "Tool needs attention" : "Tool details"}</summary>
<pre>{String(title)}</pre>
<summary>{String(title).slice(0, 300)}</summary>
<pre>{value?.aggregatedOutput ?? value?.output ?? value?.detail ?? item.data.text}</pre>
{value?.exitCode !== undefined && value?.exitCode !== null && <p>Exit code: {value.exitCode}</p>}
</details>
);
}
/** Keep chronological message boundaries and failures visible. Only adjacent
* routine tool records fold together; every original item remains inspectable. */
function conversationRows(items: Item[]): (Item | Item[])[] {
const rows: (Item | Item[])[] = [];
for (const item of items) {
const value = activityValue(item);
if (
item.data.kind === "activity" &&
value &&
["completed", "running", "inProgress", "in_progress"].includes(value.status) &&
!activityFailed(item)
) {
const previous = rows.at(-1);
if (Array.isArray(previous)) previous.push(item);
else rows.push([item]);
} else rows.push(item);
}
return rows;
}
function ToolHistory({ items }: { items: Item[] }) {
const working = items.some((item) => activityValue(item)?.status !== "completed");
return (
<details className="agent-tool-history">
<summary>
{items.length} tool {items.length === 1 ? "call" : "calls"} · {working ? "Working" : "Completed"}
</summary>
{items.map((item) => (
<Activity key={itemKey(item)} item={item} />
))}
{value?.exitCode !== undefined && <p>Exit code: {value.exitCode}</p>}
</details>
);
}
@@ -465,9 +420,7 @@ export function ThreadView({
</time>
)}
</div>
{(renderItem ? items : conversationRows(items)).map((row) => {
if (Array.isArray(row)) return <ToolHistory key={itemKey(row[0])} items={row} />;
const item = row;
{items.map((item) => {
const custom = renderItem?.(item, request);
return (
<React.Fragment key={itemKey(item)}>
-1
View File
@@ -78,7 +78,6 @@
overflow-wrap: anywhere;
}
.agent-activity-card,
.agent-tool-history,
.agent-commentary {
border: 1px solid #e0e5ee;
border-radius: 7px;