@parallelworks/tandem-web 0.194.0 → 0.194.2

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.
@@ -0,0 +1,97 @@
1
+ import { api as e, unwrap as t } from "../api/client.js";
2
+ import { myTeamsQuery as n, runnersQuery as r } from "../api/queries.js";
3
+ import { runnersFor as i } from "../lib/agents.js";
4
+ import { useNavigate as a } from "../lib/router.js";
5
+ import { Button as o, Card as s, Select as c, toast as l } from "@parallelworks/ui";
6
+ import { useState as u } from "react";
7
+ import { useErrorMessage as d } from "@parallelworks/problem/react";
8
+ import { useTranslations as f } from "use-intl";
9
+ import { jsx as p, jsxs as m } from "react/jsx-runtime";
10
+ import { useMutation as h, useQuery as g } from "@tanstack/react-query";
11
+ // src/components/AgentActions.tsx
12
+ function _({ workspace: _, agent: v }) {
13
+ let y = f("agent"), b = d(), x = a(), { data: S = [] } = g(r(_)), { data: C = [] } = g(n(_)), w = C.filter((e) => !e.archivedAt), [T, E] = u(), D = T ?? w[0]?.key, O = i(v, S).some((e) => e.online), k = h({
14
+ mutationFn: async ({ action: n, key: r }) => {
15
+ let i = { path: {
16
+ workspace: _,
17
+ key: r
18
+ } }, a = { agent: v.slug };
19
+ return t(n === "knowledge" ? await e.POST("/api/v1/workspaces/{workspace}/teams/{key}/knowledge/agent", {
20
+ params: i,
21
+ body: a
22
+ }) : await e.POST("/api/v1/workspaces/{workspace}/teams/{key}/bugs/agent", {
23
+ params: i,
24
+ body: a
25
+ }));
26
+ },
27
+ onSuccess: (e) => x({
28
+ to: "/$workspace/issues/$identifier",
29
+ params: {
30
+ workspace: _,
31
+ identifier: e.identifier
32
+ }
33
+ }),
34
+ onError: (e) => l.error(b(e))
35
+ }), A = [{
36
+ action: "knowledge",
37
+ title: y("updateKnowledge"),
38
+ hint: y("updateKnowledgeHint")
39
+ }, {
40
+ action: "bugs",
41
+ title: y("scanBugs"),
42
+ hint: y("scanBugsHint")
43
+ }];
44
+ return w.length === 0 ? null : /* @__PURE__ */ m(s, {
45
+ "aria-labelledby": "agent-ask",
46
+ className: "w-full max-w-3xl space-y-4",
47
+ children: [
48
+ /* @__PURE__ */ m("div", {
49
+ className: "flex flex-wrap items-center justify-between gap-3",
50
+ children: [/* @__PURE__ */ p("h2", {
51
+ id: "agent-ask",
52
+ className: "text-base font-semibold",
53
+ children: y("askTitle")
54
+ }), /* @__PURE__ */ p(c, {
55
+ value: D ?? "",
56
+ items: w.map((e) => ({
57
+ value: e.key,
58
+ label: e.name
59
+ })),
60
+ onValueChange: (e) => E(e),
61
+ "aria-label": y("askTeam"),
62
+ width: "content"
63
+ })]
64
+ }),
65
+ /* @__PURE__ */ p("ul", {
66
+ className: "divide-y divide-border",
67
+ children: A.map((e) => /* @__PURE__ */ m("li", {
68
+ className: "flex flex-wrap items-center gap-3 py-3 first:pt-0 last:pb-0",
69
+ children: [/* @__PURE__ */ m("div", {
70
+ className: "min-w-0 flex-1",
71
+ children: [/* @__PURE__ */ p("p", {
72
+ className: "text-sm font-medium",
73
+ children: e.title
74
+ }), /* @__PURE__ */ p("p", {
75
+ className: "text-sm text-pretty text-muted-foreground",
76
+ children: e.hint
77
+ })]
78
+ }), /* @__PURE__ */ p(o, {
79
+ disabled: !O || !D || k.isPending,
80
+ loading: k.isPending && k.variables?.action === e.action,
81
+ onClick: () => D && k.mutate({
82
+ action: e.action,
83
+ key: D
84
+ }),
85
+ "aria-label": `${y("start")}: ${e.title}`,
86
+ children: y("start")
87
+ })]
88
+ }, e.action))
89
+ }),
90
+ !O && /* @__PURE__ */ p("p", {
91
+ className: "text-xs text-muted-foreground",
92
+ children: y("needsRunner")
93
+ })
94
+ ]
95
+ });
96
+ }
97
+ export { _ as AgentActions };
@@ -0,0 +1,228 @@
1
+ import { api as e, unwrap as t } from "../api/client.js";
2
+ import { inboxQuery as n } from "../api/queries.js";
3
+ import { Link as r } from "../lib/router.js";
4
+ import { Button as i, Card as a, Input as o, Modal as s, Select as c, Textarea as l, toast as u } from "@parallelworks/ui";
5
+ import { useState as d } from "react";
6
+ import { useErrorMessage as f } from "@parallelworks/problem/react";
7
+ import { useTranslations as p } from "use-intl";
8
+ import { Fragment as m, jsx as h, jsxs as g } from "react/jsx-runtime";
9
+ import { useMutation as _, useQuery as v, useQueryClient as y } from "@tanstack/react-query";
10
+ // src/components/AgentBugReports.tsx
11
+ var b = [
12
+ "critical",
13
+ "high",
14
+ "medium",
15
+ "low"
16
+ ];
17
+ function x({ workspace: o, agent: s }) {
18
+ let c = p("agent"), l = f(), m = y(), { data: x = [] } = v(n(o)), [C, w] = d(null), T = x.filter((e) => e.bug && !e.answer && !e.canceled && e.agent.kind === "agent" && e.agent.handle === s.slug).sort((e, t) => b.indexOf(e.bug?.severity ?? "low") - b.indexOf(t.bug?.severity ?? "low")), E = () => m.invalidateQueries({ queryKey: [
19
+ "workspace",
20
+ o,
21
+ "decisions"
22
+ ] }), D = async (n, r) => t(await e.POST("/api/v1/workspaces/{workspace}/decisions/{decisionId}/answer", {
23
+ params: { path: {
24
+ workspace: o,
25
+ decisionId: n.id
26
+ } },
27
+ body: { optionId: r }
28
+ })), O = _({
29
+ mutationFn: ({ d: e, optionId: t }) => D(e, t),
30
+ onSuccess: (e) => {
31
+ let t = e.subIssues[0];
32
+ t && u.success(c("bugFiled", { identifier: t.identifier }));
33
+ },
34
+ onError: (e) => u.error(l(e)),
35
+ onSettled: E
36
+ }), k = _({
37
+ mutationFn: async () => {
38
+ for (let e of T) await D(e, "create");
39
+ },
40
+ onSuccess: () => u.success(c("bugsFiled", { count: T.length })),
41
+ onError: (e) => u.error(l(e)),
42
+ onSettled: E
43
+ });
44
+ return T.length === 0 ? null : /* @__PURE__ */ g(a, {
45
+ "aria-labelledby": "agent-bugs",
46
+ className: "w-full max-w-3xl space-y-3",
47
+ children: [
48
+ /* @__PURE__ */ g("div", {
49
+ className: "flex flex-wrap items-center justify-between gap-3",
50
+ children: [/* @__PURE__ */ h("h2", {
51
+ id: "agent-bugs",
52
+ className: "text-base font-semibold",
53
+ children: c("bugsToReview", { count: T.length })
54
+ }), /* @__PURE__ */ h(i, {
55
+ loading: k.isPending,
56
+ onClick: () => k.mutate(),
57
+ children: c("approveAll")
58
+ })]
59
+ }),
60
+ /* @__PURE__ */ h("ul", {
61
+ className: "divide-y divide-border",
62
+ children: T.map((e) => {
63
+ let t = e.bug;
64
+ return /* @__PURE__ */ g("li", {
65
+ className: "space-y-1.5 py-3 first:pt-0 last:pb-0",
66
+ children: [
67
+ /* @__PURE__ */ g("div", {
68
+ className: "flex flex-wrap items-baseline gap-x-2 gap-y-1",
69
+ children: [/* @__PURE__ */ h("span", {
70
+ className: "rounded bg-muted px-1.5 py-0.5 text-xs text-muted-foreground",
71
+ children: c(`severity.${t.severity}`)
72
+ }), /* @__PURE__ */ h("span", {
73
+ className: "min-w-0 flex-1 text-sm font-medium",
74
+ children: t.title
75
+ })]
76
+ }),
77
+ t.file && /* @__PURE__ */ h("code", {
78
+ className: "block truncate font-mono text-xs text-muted-foreground",
79
+ children: t.line ? `${t.file}:${t.line}` : t.file
80
+ }),
81
+ t.body && /* @__PURE__ */ h("p", {
82
+ className: "line-clamp-3 text-sm whitespace-pre-line text-muted-foreground",
83
+ children: t.body
84
+ }),
85
+ /* @__PURE__ */ g("div", {
86
+ className: "flex flex-wrap items-center gap-2 pt-1",
87
+ children: [
88
+ /* @__PURE__ */ h(i, {
89
+ size: "sm",
90
+ variant: "primary",
91
+ disabled: O.isPending || k.isPending,
92
+ onClick: () => O.mutate({
93
+ d: e,
94
+ optionId: "create"
95
+ }),
96
+ children: c("approve")
97
+ }),
98
+ /* @__PURE__ */ h(i, {
99
+ size: "sm",
100
+ variant: "ghost",
101
+ onClick: () => w(e),
102
+ children: c("editReport")
103
+ }),
104
+ /* @__PURE__ */ h(i, {
105
+ size: "sm",
106
+ variant: "ghost",
107
+ disabled: O.isPending || k.isPending,
108
+ onClick: () => O.mutate({
109
+ d: e,
110
+ optionId: "dismiss"
111
+ }),
112
+ children: c("dismissReport")
113
+ }),
114
+ /* @__PURE__ */ h(r, {
115
+ to: "/$workspace/issues/$identifier",
116
+ params: {
117
+ workspace: o,
118
+ identifier: e.identifier
119
+ },
120
+ className: "ml-auto text-xs text-muted-foreground hover:underline",
121
+ children: c("fromScan", { identifier: e.identifier })
122
+ })
123
+ ]
124
+ })
125
+ ]
126
+ }, e.id);
127
+ })
128
+ }),
129
+ C && /* @__PURE__ */ h(S, {
130
+ workspace: o,
131
+ decision: C,
132
+ onClose: () => w(null),
133
+ onDone: () => {
134
+ w(null), E();
135
+ }
136
+ })
137
+ ]
138
+ });
139
+ }
140
+ function S({ workspace: n, decision: r, onClose: a, onDone: v }) {
141
+ let y = p("agent"), x = p("common"), S = f(), [C, w] = d(r.bug), T = _({
142
+ mutationFn: async () => {
143
+ let i = { path: {
144
+ workspace: n,
145
+ decisionId: r.id
146
+ } };
147
+ return t(await e.PUT("/api/v1/workspaces/{workspace}/decisions/{decisionId}/bug", {
148
+ params: i,
149
+ body: C
150
+ })), t(await e.POST("/api/v1/workspaces/{workspace}/decisions/{decisionId}/answer", {
151
+ params: i,
152
+ body: { optionId: "create" }
153
+ }));
154
+ },
155
+ onSuccess: (e) => {
156
+ let t = e.subIssues[0];
157
+ t && u.success(y("bugFiled", { identifier: t.identifier })), v();
158
+ },
159
+ onError: (e) => u.error(S(e))
160
+ });
161
+ return /* @__PURE__ */ h(s, {
162
+ open: !0,
163
+ onClose: a,
164
+ title: y("editReportTitle"),
165
+ onSubmit: (e) => {
166
+ e.preventDefault(), T.mutate();
167
+ },
168
+ footer: /* @__PURE__ */ g(m, { children: [/* @__PURE__ */ h(i, {
169
+ variant: "ghost",
170
+ onClick: a,
171
+ children: x("cancel")
172
+ }), /* @__PURE__ */ h(i, {
173
+ type: "submit",
174
+ variant: "primary",
175
+ loading: T.isPending,
176
+ disabled: !C.title.trim(),
177
+ children: y("approve")
178
+ })] }),
179
+ children: /* @__PURE__ */ g("div", {
180
+ className: "space-y-3",
181
+ children: [
182
+ /* @__PURE__ */ g("label", {
183
+ className: "block text-sm font-medium",
184
+ children: [y("reportTitle"), /* @__PURE__ */ h(o, {
185
+ value: C.title,
186
+ onChange: (e) => w({
187
+ ...C,
188
+ title: e.target.value
189
+ }),
190
+ className: "mt-1"
191
+ })]
192
+ }),
193
+ /* @__PURE__ */ g("label", {
194
+ className: "block text-sm font-medium",
195
+ children: [x("description"), /* @__PURE__ */ h(l, {
196
+ value: C.body ?? "",
197
+ onChange: (e) => w({
198
+ ...C,
199
+ body: e.target.value
200
+ }),
201
+ rows: 6,
202
+ className: "mt-1"
203
+ })]
204
+ }),
205
+ /* @__PURE__ */ g("div", {
206
+ className: "block text-sm font-medium",
207
+ children: [y("severityLabel"), /* @__PURE__ */ h("div", {
208
+ className: "mt-1",
209
+ children: /* @__PURE__ */ h(c, {
210
+ value: C.severity,
211
+ items: b.map((e) => ({
212
+ value: e,
213
+ label: y(`severity.${e}`)
214
+ })),
215
+ onValueChange: (e) => w({
216
+ ...C,
217
+ severity: e
218
+ }),
219
+ "aria-label": y("severityLabel"),
220
+ width: "content"
221
+ })
222
+ })]
223
+ })
224
+ ]
225
+ })
226
+ });
227
+ }
228
+ export { x as AgentBugReports };
@@ -0,0 +1,88 @@
1
+ import { meQuery as e, runnersQuery as t } from "../api/queries.js";
2
+ import { runnerCommand as n, runnersFor as r } from "../lib/agents.js";
3
+ import { appURL as i } from "../lib/base.js";
4
+ import { RunnerBadge as a } from "./RunnerBadge.js";
5
+ import { Card as o, CopyButton as s } from "@parallelworks/ui";
6
+ import { useTranslations as c } from "use-intl";
7
+ import { Fragment as l, jsx as u, jsxs as d } from "react/jsx-runtime";
8
+ import { useQuery as f } from "@tanstack/react-query";
9
+ // src/components/AgentDeploy.tsx
10
+ var p = "go install github.com/parallelworks/tandem/cmd/tandem@latest";
11
+ function m({ workspace: m, agent: h }) {
12
+ let g = c("agent"), { data: _ = [] } = f(t(m)), { data: v } = f(e), y = r(h, _).filter((e) => e.online), b = i(""), x = v?.mode === "platform" ? `tandem login --server ${b} --token -` : `tandem login --server ${b}`, S = [
13
+ {
14
+ title: g("deployInstall"),
15
+ command: p
16
+ },
17
+ {
18
+ title: v?.mode === "platform" ? g("deployLoginToken") : g("deployLogin"),
19
+ command: x
20
+ },
21
+ {
22
+ title: g("deployRun"),
23
+ command: n(h)
24
+ }
25
+ ], C = /* @__PURE__ */ u("ol", {
26
+ className: "space-y-3",
27
+ children: S.map((e, t) => /* @__PURE__ */ d("li", {
28
+ className: "space-y-1",
29
+ children: [/* @__PURE__ */ d("p", {
30
+ className: "text-sm",
31
+ children: [/* @__PURE__ */ d("span", {
32
+ className: "mr-1.5 text-muted-foreground tabular-nums",
33
+ children: [t + 1, "."]
34
+ }), e.title]
35
+ }), /* @__PURE__ */ d("div", {
36
+ className: "flex items-center gap-1 rounded-md border border-border bg-muted px-2 py-1",
37
+ children: [/* @__PURE__ */ u("code", {
38
+ className: "min-w-0 flex-1 overflow-x-auto font-mono text-xs whitespace-nowrap",
39
+ children: e.command
40
+ }), /* @__PURE__ */ u(s, {
41
+ text: e.command,
42
+ label: g("copyCommand"),
43
+ size: "sm",
44
+ variant: "ghost"
45
+ })]
46
+ })]
47
+ }, e.title))
48
+ });
49
+ return /* @__PURE__ */ d(o, {
50
+ "aria-labelledby": "agent-deploy",
51
+ className: "w-full max-w-3xl space-y-3",
52
+ children: [/* @__PURE__ */ u("h2", {
53
+ id: "agent-deploy",
54
+ className: "text-base font-semibold",
55
+ children: y.length > 0 ? g("deployReady") : g("deployTitle")
56
+ }), y.length > 0 ? /* @__PURE__ */ d(l, { children: [
57
+ /* @__PURE__ */ u("p", {
58
+ className: "text-sm text-muted-foreground",
59
+ children: g("deployOnline", { count: y.length })
60
+ }),
61
+ /* @__PURE__ */ u("ul", {
62
+ className: "flex flex-wrap gap-2",
63
+ children: y.map(({ runner: e }) => /* @__PURE__ */ u("li", {
64
+ className: "text-sm",
65
+ children: /* @__PURE__ */ u(a, {
66
+ workspace: m,
67
+ name: e.name,
68
+ kind: e.kind
69
+ })
70
+ }, e.id))
71
+ }),
72
+ /* @__PURE__ */ d("details", {
73
+ className: "text-sm",
74
+ children: [/* @__PURE__ */ u("summary", {
75
+ className: "cursor-pointer text-muted-foreground",
76
+ children: g("deployAnother")
77
+ }), /* @__PURE__ */ u("div", {
78
+ className: "mt-3",
79
+ children: C
80
+ })]
81
+ })
82
+ ] }) : /* @__PURE__ */ d(l, { children: [/* @__PURE__ */ u("p", {
83
+ className: "text-sm text-muted-foreground text-pretty",
84
+ children: g("deployLead")
85
+ }), C] })]
86
+ });
87
+ }
88
+ export { m as AgentDeploy };