@parallelworks/tandem-web 0.176.0 → 0.177.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,139 +1,185 @@
1
1
  import { api as e, unwrap as t } from "../../../api/client.js";
2
- import { agentsQuery as n, meQuery as r } from "../../../api/queries.js";
3
- import { AgentIcon as i } from "../../../components/icons.js";
4
- import { harnessNames as a } from "../../../lib/agents.js";
5
- import { useConfirm as o } from "../../../lib/confirm.js";
6
- import { copyItem as s, useLinkItems as c } from "../../../lib/menus.js";
7
- import { usePageTitle as l } from "../../../lib/pageTitle.js";
8
- import { may as u } from "../../../lib/roles.js";
9
- import { Link as d, useNavigate as f } from "../../../lib/router.js";
10
- import { Route as p } from "./index.js";
11
- import { Avatar as m, Card as h, EmptyState as g, buttonClasses as _, menuDivider as v, useOpenMenu as y } from "@parallelworks/ui";
12
- import { useTranslations as b } from "use-intl";
13
- import { jsx as x, jsxs as S } from "react/jsx-runtime";
14
- import { useMutation as C, useQueryClient as w, useSuspenseQuery as T } from "@tanstack/react-query";
2
+ import { agentsQuery as n, meQuery as r, runnersQuery as i, workspaceRunsQuery as a } from "../../../api/queries.js";
3
+ import { AgentIcon as o, AlertIcon as s } from "../../../components/icons.js";
4
+ import { RunnerBadge as c } from "../../../components/RunnerBadge.js";
5
+ import { harnessNames as l, runnersFor as u } from "../../../lib/agents.js";
6
+ import { useConfirm as d } from "../../../lib/confirm.js";
7
+ import { copyItem as f, useLinkItems as p } from "../../../lib/menus.js";
8
+ import { usePageTitle as m } from "../../../lib/pageTitle.js";
9
+ import { may as h } from "../../../lib/roles.js";
10
+ import { Link as g, useNavigate as _ } from "../../../lib/router.js";
11
+ import { Route as v } from "./index.js";
12
+ import { Avatar as y, Card as b, EmptyState as x, buttonClasses as S, menuDivider as C, useOpenMenu as w } from "@parallelworks/ui";
13
+ import { useTranslations as T } from "use-intl";
14
+ import { jsx as E, jsxs as D } from "react/jsx-runtime";
15
+ import { useMutation as O, useQuery as k, useQueryClient as A, useSuspenseQuery as j } from "@tanstack/react-query";
15
16
  // src/routes/$workspace/agents/index.tsx?tsr-split=component
16
- function E() {
17
- let { workspace: E } = p.useParams(), D = b("agents"), O = b("common"), k = c(), { data: A } = T(n(E));
18
- l(D("title"));
19
- let { data: j } = T(r), M = u(j, E, "manage_agents"), N = y(), P = f(), F = w(), I = C({
17
+ function M() {
18
+ let { workspace: s } = v.useParams(), c = T("agents"), u = T("common"), M = p(), { data: P } = j(n(s)), { data: F = [] } = k(i(s)), { data: I = [] } = k(a(s, {
19
+ live: !0,
20
+ limit: 200
21
+ }));
22
+ m(c("title"));
23
+ let { data: L } = j(r), R = h(L, s, "manage_agents"), z = w(), B = _(), V = A(), H = O({
20
24
  mutationFn: async (n) => t(await e.DELETE("/api/v1/workspaces/{workspace}/agents/{slug}", { params: { path: {
21
- workspace: E,
25
+ workspace: s,
22
26
  slug: n
23
27
  } } })),
24
- onSettled: () => F.invalidateQueries({ queryKey: n(E).queryKey })
25
- }), { confirm: L, dialog: R } = o(), z = (e) => [
28
+ onSettled: () => V.invalidateQueries({ queryKey: n(s).queryKey })
29
+ }), { confirm: U, dialog: W } = d(), G = (e) => [
26
30
  {
27
- label: O("open"),
28
- onClick: () => P({
31
+ label: u("open"),
32
+ onClick: () => B({
29
33
  to: "/$workspace/agents/$slug",
30
34
  params: {
31
- workspace: E,
35
+ workspace: s,
32
36
  slug: e.slug
33
37
  }
34
38
  })
35
39
  },
36
- ...k(`/${E}/agents/${e.slug}`),
37
- s(D("copySlug"), e.slug),
38
- ...M && !e.archivedAt ? [v, {
39
- label: D("archive"),
40
+ ...M(`/${s}/agents/${e.slug}`),
41
+ f(c("copySlug"), e.slug),
42
+ ...R && !e.archivedAt ? [C, {
43
+ label: c("archive"),
40
44
  destructive: !0,
41
- onClick: () => L({
42
- title: D("archiveTitle", { name: e.name }),
43
- description: D("archiveDescription"),
44
- confirmLabel: D("archive"),
45
- onConfirm: () => I.mutateAsync(e.slug)
45
+ onClick: () => U({
46
+ title: c("archiveTitle", { name: e.name }),
47
+ description: c("archiveDescription"),
48
+ confirmLabel: c("archive"),
49
+ onConfirm: () => H.mutateAsync(e.slug)
46
50
  })
47
51
  }] : []
48
52
  ];
49
- return /* @__PURE__ */ S("div", {
53
+ return /* @__PURE__ */ D("div", {
50
54
  className: "w-full px-4 py-6 md:px-8 md:py-8",
51
55
  children: [
52
- /* @__PURE__ */ S("div", {
56
+ /* @__PURE__ */ D("div", {
53
57
  className: "flex items-center justify-between",
54
58
  children: [
55
- /* @__PURE__ */ x("div", { children: /* @__PURE__ */ x("h1", {
59
+ /* @__PURE__ */ E("div", { children: /* @__PURE__ */ E("h1", {
56
60
  className: "text-xl font-semibold tracking-tight",
57
- children: D("title")
61
+ children: c("title")
58
62
  }) }),
59
- A.length > 0 && /* @__PURE__ */ x(d, {
63
+ P.length > 0 && /* @__PURE__ */ E(g, {
60
64
  to: "/$workspace/measures",
61
- params: { workspace: E },
62
- className: `${_()} ml-auto mr-2`,
63
- children: D("measures")
65
+ params: { workspace: s },
66
+ className: `${S()} ml-auto mr-2`,
67
+ children: c("measures")
64
68
  }),
65
- M && A.length > 0 && /* @__PURE__ */ x(d, {
69
+ R && P.length > 0 && /* @__PURE__ */ E(g, {
66
70
  to: "/$workspace/agents/$slug",
67
71
  params: {
68
- workspace: E,
72
+ workspace: s,
69
73
  slug: "new"
70
74
  },
71
- className: _({ variant: "primary" }),
72
- children: D("new")
75
+ className: S({ variant: "primary" }),
76
+ children: c("new")
73
77
  })
74
78
  ]
75
79
  }),
76
- A.length === 0 ? /* @__PURE__ */ x(g, {
77
- icon: /* @__PURE__ */ x(i, {}),
78
- title: D("empty"),
79
- description: D("emptyDescription"),
80
- ...M && { action: /* @__PURE__ */ x(d, {
80
+ P.length === 0 ? /* @__PURE__ */ E(x, {
81
+ icon: /* @__PURE__ */ E(o, {}),
82
+ title: c("empty"),
83
+ description: c("emptyDescription"),
84
+ ...R && { action: /* @__PURE__ */ E(g, {
81
85
  to: "/$workspace/agents/$slug",
82
86
  params: {
83
- workspace: E,
87
+ workspace: s,
84
88
  slug: "new"
85
89
  },
86
- className: _({ variant: "primary" }),
87
- children: D("new")
90
+ className: S({ variant: "primary" }),
91
+ children: c("new")
88
92
  }) },
89
93
  className: "mt-8"
90
- }) : /* @__PURE__ */ x(h, {
94
+ }) : /* @__PURE__ */ E(b, {
91
95
  size: "fill",
92
96
  padding: "none",
93
97
  divided: !0,
94
98
  interactive: !1,
95
- render: /* @__PURE__ */ x("ul", {}),
99
+ render: /* @__PURE__ */ E("ul", {}),
96
100
  className: "mt-8 overflow-hidden",
97
- children: A.map((e) => /* @__PURE__ */ x("li", { children: /* @__PURE__ */ S(d, {
101
+ children: P.map((e) => /* @__PURE__ */ E("li", { children: /* @__PURE__ */ D(g, {
98
102
  to: "/$workspace/agents/$slug",
99
103
  params: {
100
- workspace: E,
104
+ workspace: s,
101
105
  slug: e.slug
102
106
  },
103
- onContextMenu: (t) => N(t, z(e)),
107
+ onContextMenu: (t) => z(t, G(e)),
104
108
  className: "flex items-center gap-3 px-3 py-2.5 hover:bg-muted",
105
109
  children: [
106
- /* @__PURE__ */ x(m, {
110
+ /* @__PURE__ */ E(y, {
107
111
  kind: "agent",
108
112
  name: e.name,
109
113
  size: "md",
110
114
  decorative: !0
111
115
  }),
112
- /* @__PURE__ */ S("span", {
116
+ /* @__PURE__ */ D("span", {
113
117
  className: "min-w-0 flex-1",
114
- children: [/* @__PURE__ */ S("span", {
115
- className: "block text-sm font-medium",
116
- children: [e.name, e.archivedAt && /* @__PURE__ */ S("span", {
117
- className: "font-normal text-muted-foreground",
118
- children: [" ", D("archived")]
119
- })]
120
- }), /* @__PURE__ */ x("span", {
121
- className: "block truncate text-xs text-muted-foreground",
122
- children: e.description || D("noDescription")
123
- })]
118
+ children: [
119
+ /* @__PURE__ */ D("span", {
120
+ className: "block text-sm font-medium",
121
+ children: [e.name, e.archivedAt && /* @__PURE__ */ D("span", {
122
+ className: "font-normal text-muted-foreground",
123
+ children: [" ", c("archived")]
124
+ })]
125
+ }),
126
+ /* @__PURE__ */ E("span", {
127
+ className: "block truncate text-xs text-muted-foreground",
128
+ children: e.description || c("noDescription")
129
+ }),
130
+ !e.archivedAt && /* @__PURE__ */ E(N, {
131
+ workspace: s,
132
+ agent: e,
133
+ runners: F,
134
+ working: I.filter((t) => t.agentId === e.id && t.state === "working")
135
+ })
136
+ ]
124
137
  }),
125
- /* @__PURE__ */ x("span", {
138
+ /* @__PURE__ */ E("span", {
126
139
  className: "text-xs text-muted-foreground",
127
- children: e.model ? D("harnessWithModel", {
128
- harness: a[e.harness] ?? e.harness,
140
+ children: e.model ? c("harnessWithModel", {
141
+ harness: l[e.harness] ?? e.harness,
129
142
  model: e.model
130
- }) : a[e.harness]
143
+ }) : l[e.harness]
131
144
  })
132
145
  ]
133
146
  }) }, e.id))
134
147
  }),
135
- R
148
+ W
136
149
  ]
137
150
  });
138
151
  }
139
- export { E as component };
152
+ function N({ workspace: e, agent: t, runners: n, working: r }) {
153
+ let i = T("agents"), a = u(t, n).filter((e) => e.online), o = [...new Map(r.filter((e) => e.runnerName).map((e) => [e.runnerName, e])).values()];
154
+ return /* @__PURE__ */ D("span", {
155
+ className: "mt-1 flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-muted-foreground",
156
+ children: [o.length > 0 ? /* @__PURE__ */ D("span", {
157
+ className: "inline-flex min-w-0 flex-wrap items-center gap-x-1.5 gap-y-0.5",
158
+ children: [/* @__PURE__ */ E("span", {
159
+ className: "whitespace-nowrap",
160
+ children: i("workingOn")
161
+ }), o.map((t) => /* @__PURE__ */ E(c, {
162
+ workspace: e,
163
+ name: t.runnerName ?? "",
164
+ kind: t.runnerKind,
165
+ link: !1,
166
+ className: "font-medium text-foreground"
167
+ }, t.runnerName))]
168
+ }) : /* @__PURE__ */ E("span", { children: i("idle") }), a.length > 0 ? /* @__PURE__ */ D("span", {
169
+ className: "inline-flex min-w-0 flex-wrap items-center gap-x-1.5 gap-y-0.5",
170
+ children: [/* @__PURE__ */ E("span", {
171
+ className: "whitespace-nowrap",
172
+ children: i("canRunOn")
173
+ }), a.map((t) => /* @__PURE__ */ E(c, {
174
+ workspace: e,
175
+ name: t.runner.name,
176
+ kind: t.runner.kind,
177
+ link: !1
178
+ }, t.runner.id))]
179
+ }) : /* @__PURE__ */ D("span", {
180
+ className: "inline-flex items-center gap-1 text-warning",
181
+ children: [/* @__PURE__ */ E(s, { className: "size-3.5" }), i("noRunnerOnline")]
182
+ })]
183
+ });
184
+ }
185
+ export { M as component };