stagent 0.6.2 → 0.7.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.
- package/README.md +21 -2
- package/dist/cli.js +272 -1
- package/docs/.coverage-gaps.json +66 -16
- package/docs/.last-generated +1 -1
- package/docs/features/dashboard-kanban.md +13 -7
- package/docs/features/settings.md +15 -3
- package/docs/features/tables.md +122 -0
- package/docs/index.md +3 -2
- package/docs/journeys/developer.md +26 -16
- package/docs/journeys/personal-use.md +23 -9
- package/docs/journeys/power-user.md +40 -14
- package/docs/journeys/work-use.md +43 -15
- package/docs/manifest.json +27 -17
- package/package.json +3 -2
- package/src/app/api/chat/entities/search/route.ts +12 -3
- package/src/app/api/documents/[id]/route.ts +5 -1
- package/src/app/api/documents/[id]/versions/route.ts +53 -0
- package/src/app/api/documents/route.ts +5 -1
- package/src/app/api/projects/[id]/documents/route.ts +124 -0
- package/src/app/api/projects/[id]/route.ts +72 -3
- package/src/app/api/projects/__tests__/delete-project.test.ts +13 -0
- package/src/app/api/schedules/route.ts +19 -1
- package/src/app/api/snapshots/[id]/restore/route.ts +62 -0
- package/src/app/api/snapshots/[id]/route.ts +44 -0
- package/src/app/api/snapshots/route.ts +54 -0
- package/src/app/api/snapshots/settings/route.ts +67 -0
- package/src/app/api/tables/[id]/charts/[chartId]/route.ts +89 -0
- package/src/app/api/tables/[id]/charts/route.ts +72 -0
- package/src/app/api/tables/[id]/columns/route.ts +70 -0
- package/src/app/api/tables/[id]/export/route.ts +94 -0
- package/src/app/api/tables/[id]/history/route.ts +15 -0
- package/src/app/api/tables/[id]/import/route.ts +111 -0
- package/src/app/api/tables/[id]/route.ts +86 -0
- package/src/app/api/tables/[id]/rows/[rowId]/history/route.ts +32 -0
- package/src/app/api/tables/[id]/rows/[rowId]/route.ts +51 -0
- package/src/app/api/tables/[id]/rows/route.ts +101 -0
- package/src/app/api/tables/[id]/triggers/[triggerId]/route.ts +65 -0
- package/src/app/api/tables/[id]/triggers/route.ts +122 -0
- package/src/app/api/tables/route.ts +65 -0
- package/src/app/api/tables/templates/route.ts +92 -0
- package/src/app/api/tasks/[id]/route.ts +37 -2
- package/src/app/api/tasks/[id]/siblings/route.ts +48 -0
- package/src/app/api/tasks/route.ts +8 -9
- package/src/app/api/workflows/[id]/documents/route.ts +209 -0
- package/src/app/api/workflows/[id]/execute/route.ts +6 -2
- package/src/app/api/workflows/[id]/route.ts +16 -3
- package/src/app/api/workflows/[id]/status/route.ts +18 -2
- package/src/app/api/workflows/route.ts +13 -2
- package/src/app/documents/page.tsx +5 -1
- package/src/app/layout.tsx +0 -1
- package/src/app/manifest.ts +3 -3
- package/src/app/projects/[id]/page.tsx +62 -2
- package/src/app/settings/page.tsx +2 -0
- package/src/app/tables/[id]/page.tsx +67 -0
- package/src/app/tables/page.tsx +21 -0
- package/src/app/tables/templates/page.tsx +19 -0
- package/src/components/chat/chat-table-result.tsx +139 -0
- package/src/components/documents/document-browser.tsx +1 -1
- package/src/components/documents/document-chip-bar.tsx +17 -1
- package/src/components/documents/document-detail-view.tsx +51 -0
- package/src/components/documents/document-grid.tsx +5 -0
- package/src/components/documents/document-table.tsx +4 -0
- package/src/components/documents/types.ts +3 -0
- package/src/components/projects/project-form-sheet.tsx +109 -2
- package/src/components/schedules/schedule-form.tsx +91 -1
- package/src/components/settings/data-management-section.tsx +17 -12
- package/src/components/settings/database-snapshots-section.tsx +469 -0
- package/src/components/shared/app-sidebar.tsx +2 -0
- package/src/components/shared/document-picker-sheet.tsx +486 -0
- package/src/components/tables/table-browser.tsx +234 -0
- package/src/components/tables/table-cell-editor.tsx +226 -0
- package/src/components/tables/table-chart-builder.tsx +288 -0
- package/src/components/tables/table-chart-view.tsx +146 -0
- package/src/components/tables/table-column-header.tsx +103 -0
- package/src/components/tables/table-column-sheet.tsx +331 -0
- package/src/components/tables/table-create-sheet.tsx +240 -0
- package/src/components/tables/table-detail-sheet.tsx +144 -0
- package/src/components/tables/table-detail-tabs.tsx +278 -0
- package/src/components/tables/table-grid.tsx +61 -0
- package/src/components/tables/table-history-tab.tsx +148 -0
- package/src/components/tables/table-import-wizard.tsx +542 -0
- package/src/components/tables/table-list-table.tsx +95 -0
- package/src/components/tables/table-relation-combobox.tsx +217 -0
- package/src/components/tables/table-spreadsheet.tsx +499 -0
- package/src/components/tables/table-template-gallery.tsx +162 -0
- package/src/components/tables/table-template-preview.tsx +219 -0
- package/src/components/tables/table-toolbar.tsx +79 -0
- package/src/components/tables/table-triggers-tab.tsx +446 -0
- package/src/components/tables/types.ts +6 -0
- package/src/components/tables/use-spreadsheet-keys.ts +171 -0
- package/src/components/tables/utils.ts +29 -0
- package/src/components/tasks/task-card.tsx +8 -1
- package/src/components/tasks/task-create-panel.tsx +111 -14
- package/src/components/tasks/task-detail-view.tsx +47 -0
- package/src/components/tasks/task-edit-dialog.tsx +103 -2
- package/src/components/workflows/workflow-form-view.tsx +207 -7
- package/src/components/workflows/workflow-kanban-card.tsx +8 -1
- package/src/components/workflows/workflow-list.tsx +90 -45
- package/src/components/workflows/workflow-status-view.tsx +168 -23
- package/src/instrumentation.ts +3 -0
- package/src/lib/__tests__/npx-process-cwd.test.ts +17 -2
- package/src/lib/agents/__tests__/claude-agent.test.ts +5 -1
- package/src/lib/agents/claude-agent.ts +3 -1
- package/src/lib/agents/profiles/registry.ts +6 -3
- package/src/lib/agents/runtime/anthropic-direct.ts +29 -0
- package/src/lib/agents/runtime/openai-direct.ts +29 -0
- package/src/lib/book/__tests__/chapter-slugs.test.ts +80 -0
- package/src/lib/book/chapter-generator.ts +4 -19
- package/src/lib/book/chapter-mapping.ts +17 -0
- package/src/lib/book/content.ts +5 -16
- package/src/lib/book/update-detector.ts +3 -16
- package/src/lib/chat/engine.ts +1 -0
- package/src/lib/chat/stagent-tools.ts +2 -0
- package/src/lib/chat/system-prompt.ts +9 -1
- package/src/lib/chat/tool-catalog.ts +35 -0
- package/src/lib/chat/tools/settings-tools.ts +109 -0
- package/src/lib/chat/tools/table-tools.ts +955 -0
- package/src/lib/chat/tools/workflow-tools.ts +145 -2
- package/src/lib/constants/table-status.ts +68 -0
- package/src/lib/data/__tests__/clear.test.ts +1 -1
- package/src/lib/data/clear.ts +57 -0
- package/src/lib/data/seed-data/__tests__/profiles.test.ts +28 -23
- package/src/lib/data/seed-data/conversations.ts +350 -42
- package/src/lib/data/seed-data/documents.ts +564 -591
- package/src/lib/data/seed-data/learned-context.ts +101 -22
- package/src/lib/data/seed-data/notifications.ts +344 -70
- package/src/lib/data/seed-data/profile-test-results.ts +92 -11
- package/src/lib/data/seed-data/profiles.ts +144 -46
- package/src/lib/data/seed-data/projects.ts +50 -18
- package/src/lib/data/seed-data/repo-imports.ts +28 -13
- package/src/lib/data/seed-data/schedules.ts +208 -41
- package/src/lib/data/seed-data/table-templates.ts +234 -0
- package/src/lib/data/seed-data/tasks.ts +614 -116
- package/src/lib/data/seed-data/usage-ledger.ts +182 -103
- package/src/lib/data/seed-data/user-tables.ts +203 -0
- package/src/lib/data/seed-data/views.ts +52 -7
- package/src/lib/data/seed-data/workflows.ts +231 -84
- package/src/lib/data/seed.ts +55 -14
- package/src/lib/data/tables.ts +417 -0
- package/src/lib/db/bootstrap.ts +275 -0
- package/src/lib/db/index.ts +9 -0
- package/src/lib/db/migrations/0016_add_workflow_document_inputs.sql +13 -0
- package/src/lib/db/migrations/0017_add_document_picker_tables.sql +25 -0
- package/src/lib/db/migrations/0018_add_workflow_run_number.sql +2 -0
- package/src/lib/db/migrations/0019_add_tables_feature.sql +160 -0
- package/src/lib/db/migrations/0020_add_table_triggers.sql +19 -0
- package/src/lib/db/migrations/0021_add_row_history.sql +15 -0
- package/src/lib/db/schema.ts +445 -0
- package/src/lib/docs/reader.ts +2 -3
- package/src/lib/documents/context-builder.ts +75 -2
- package/src/lib/documents/document-resolver.ts +119 -0
- package/src/lib/documents/processors/spreadsheet.ts +2 -1
- package/src/lib/schedules/scheduler.ts +31 -1
- package/src/lib/snapshots/auto-backup.ts +132 -0
- package/src/lib/snapshots/retention.ts +64 -0
- package/src/lib/snapshots/snapshot-manager.ts +429 -0
- package/src/lib/tables/computed.ts +61 -0
- package/src/lib/tables/context-builder.ts +139 -0
- package/src/lib/tables/formula-engine.ts +415 -0
- package/src/lib/tables/history.ts +115 -0
- package/src/lib/tables/import.ts +343 -0
- package/src/lib/tables/query-builder.ts +152 -0
- package/src/lib/tables/trigger-evaluator.ts +146 -0
- package/src/lib/tables/types.ts +141 -0
- package/src/lib/tables/validation.ts +119 -0
- package/src/lib/utils/app-root.ts +20 -0
- package/src/lib/utils/stagent-paths.ts +20 -0
- package/src/lib/validators/__tests__/task.test.ts +43 -10
- package/src/lib/validators/task.ts +7 -1
- package/src/lib/workflows/blueprints/registry.ts +3 -3
- package/src/lib/workflows/engine.ts +24 -8
- package/src/lib/workflows/types.ts +14 -0
- package/tsconfig.json +3 -1
- package/public/icon.svg +0 -13
- package/src/components/tasks/file-upload.tsx +0 -120
- /package/docs/features/{playbook.md → user-guide.md} +0 -0
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { useState, useEffect, useCallback } from "react";
|
|
4
|
+
import { Button } from "@/components/ui/button";
|
|
5
|
+
import { Badge } from "@/components/ui/badge";
|
|
6
|
+
import {
|
|
7
|
+
Popover,
|
|
8
|
+
PopoverContent,
|
|
9
|
+
PopoverTrigger,
|
|
10
|
+
} from "@/components/ui/popover";
|
|
11
|
+
import {
|
|
12
|
+
Command,
|
|
13
|
+
CommandInput,
|
|
14
|
+
CommandList,
|
|
15
|
+
CommandEmpty,
|
|
16
|
+
CommandGroup,
|
|
17
|
+
CommandItem,
|
|
18
|
+
} from "@/components/ui/command";
|
|
19
|
+
import { Check, ChevronsUpDown, X } from "lucide-react";
|
|
20
|
+
import { cn } from "@/lib/utils";
|
|
21
|
+
|
|
22
|
+
interface TargetRow {
|
|
23
|
+
id: string;
|
|
24
|
+
displayValue: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
interface TableRelationComboboxProps {
|
|
28
|
+
targetTableId: string;
|
|
29
|
+
displayColumn: string;
|
|
30
|
+
value: string | string[] | null;
|
|
31
|
+
multiple?: boolean;
|
|
32
|
+
onChange: (value: string | string[]) => void;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function TableRelationCombobox({
|
|
36
|
+
targetTableId,
|
|
37
|
+
displayColumn,
|
|
38
|
+
value,
|
|
39
|
+
multiple = false,
|
|
40
|
+
onChange,
|
|
41
|
+
}: TableRelationComboboxProps) {
|
|
42
|
+
const [open, setOpen] = useState(false);
|
|
43
|
+
const [rows, setRows] = useState<TargetRow[]>([]);
|
|
44
|
+
const [loading, setLoading] = useState(false);
|
|
45
|
+
const [search, setSearch] = useState("");
|
|
46
|
+
|
|
47
|
+
const selectedIds = multiple
|
|
48
|
+
? Array.isArray(value)
|
|
49
|
+
? value
|
|
50
|
+
: value
|
|
51
|
+
? [value]
|
|
52
|
+
: []
|
|
53
|
+
: value
|
|
54
|
+
? [value as string]
|
|
55
|
+
: [];
|
|
56
|
+
|
|
57
|
+
const fetchRows = useCallback(
|
|
58
|
+
async (query?: string) => {
|
|
59
|
+
setLoading(true);
|
|
60
|
+
try {
|
|
61
|
+
const params = new URLSearchParams();
|
|
62
|
+
if (query) params.set("search", query);
|
|
63
|
+
params.set("limit", "50");
|
|
64
|
+
|
|
65
|
+
const res = await fetch(
|
|
66
|
+
`/api/tables/${targetTableId}/rows?${params.toString()}`
|
|
67
|
+
);
|
|
68
|
+
if (res.ok) {
|
|
69
|
+
const data = await res.json();
|
|
70
|
+
const items: TargetRow[] = (data.rows ?? data ?? []).map(
|
|
71
|
+
(row: Record<string, unknown>) => ({
|
|
72
|
+
id: String(row.id ?? row._id ?? ""),
|
|
73
|
+
displayValue: String(row[displayColumn] ?? row.id ?? ""),
|
|
74
|
+
})
|
|
75
|
+
);
|
|
76
|
+
setRows(items);
|
|
77
|
+
}
|
|
78
|
+
} catch {
|
|
79
|
+
// silent
|
|
80
|
+
} finally {
|
|
81
|
+
setLoading(false);
|
|
82
|
+
}
|
|
83
|
+
},
|
|
84
|
+
[targetTableId, displayColumn]
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
useEffect(() => {
|
|
88
|
+
if (open) {
|
|
89
|
+
fetchRows();
|
|
90
|
+
}
|
|
91
|
+
}, [open, fetchRows]);
|
|
92
|
+
|
|
93
|
+
useEffect(() => {
|
|
94
|
+
if (open && search) {
|
|
95
|
+
const timer = setTimeout(() => fetchRows(search), 300);
|
|
96
|
+
return () => clearTimeout(timer);
|
|
97
|
+
}
|
|
98
|
+
}, [search, open, fetchRows]);
|
|
99
|
+
|
|
100
|
+
function handleSelect(rowId: string) {
|
|
101
|
+
if (multiple) {
|
|
102
|
+
const current = [...selectedIds];
|
|
103
|
+
const idx = current.indexOf(rowId);
|
|
104
|
+
if (idx >= 0) {
|
|
105
|
+
current.splice(idx, 1);
|
|
106
|
+
} else {
|
|
107
|
+
current.push(rowId);
|
|
108
|
+
}
|
|
109
|
+
onChange(current);
|
|
110
|
+
} else {
|
|
111
|
+
onChange(rowId);
|
|
112
|
+
setOpen(false);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function handleRemove(rowId: string) {
|
|
117
|
+
if (multiple) {
|
|
118
|
+
onChange(selectedIds.filter((id) => id !== rowId));
|
|
119
|
+
} else {
|
|
120
|
+
onChange(multiple ? [] : "");
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function getDisplayValue(rowId: string): string {
|
|
125
|
+
const row = rows.find((r) => r.id === rowId);
|
|
126
|
+
return row?.displayValue ?? rowId;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Single value display
|
|
130
|
+
const singleDisplay =
|
|
131
|
+
!multiple && selectedIds.length > 0
|
|
132
|
+
? getDisplayValue(selectedIds[0])
|
|
133
|
+
: null;
|
|
134
|
+
|
|
135
|
+
return (
|
|
136
|
+
<div className="space-y-1.5">
|
|
137
|
+
{/* Multi-select: show selected as badges */}
|
|
138
|
+
{multiple && selectedIds.length > 0 && (
|
|
139
|
+
<div className="flex flex-wrap gap-1">
|
|
140
|
+
{selectedIds.map((id) => (
|
|
141
|
+
<Badge key={id} variant="secondary" className="gap-1 pr-1">
|
|
142
|
+
<span className="truncate max-w-[120px]">
|
|
143
|
+
{getDisplayValue(id)}
|
|
144
|
+
</span>
|
|
145
|
+
<button
|
|
146
|
+
type="button"
|
|
147
|
+
onClick={(e) => {
|
|
148
|
+
e.stopPropagation();
|
|
149
|
+
handleRemove(id);
|
|
150
|
+
}}
|
|
151
|
+
className="ml-0.5 rounded-sm hover:bg-muted p-0.5"
|
|
152
|
+
>
|
|
153
|
+
<X className="h-3 w-3" />
|
|
154
|
+
</button>
|
|
155
|
+
</Badge>
|
|
156
|
+
))}
|
|
157
|
+
</div>
|
|
158
|
+
)}
|
|
159
|
+
|
|
160
|
+
<Popover open={open} onOpenChange={setOpen}>
|
|
161
|
+
<PopoverTrigger asChild>
|
|
162
|
+
<Button
|
|
163
|
+
variant="outline"
|
|
164
|
+
role="combobox"
|
|
165
|
+
aria-expanded={open}
|
|
166
|
+
className="w-full justify-between h-9 text-sm font-normal"
|
|
167
|
+
>
|
|
168
|
+
<span className="truncate">
|
|
169
|
+
{singleDisplay ?? (multiple ? "Select rows..." : "Select a row...")}
|
|
170
|
+
</span>
|
|
171
|
+
<ChevronsUpDown className="ml-2 h-4 w-4 shrink-0 opacity-50" />
|
|
172
|
+
</Button>
|
|
173
|
+
</PopoverTrigger>
|
|
174
|
+
<PopoverContent className="w-[280px] p-0" align="start">
|
|
175
|
+
<Command shouldFilter={false}>
|
|
176
|
+
<CommandInput
|
|
177
|
+
placeholder="Search..."
|
|
178
|
+
value={search}
|
|
179
|
+
onValueChange={setSearch}
|
|
180
|
+
/>
|
|
181
|
+
<CommandList>
|
|
182
|
+
{loading ? (
|
|
183
|
+
<div className="py-6 text-center text-sm text-muted-foreground">
|
|
184
|
+
Loading...
|
|
185
|
+
</div>
|
|
186
|
+
) : (
|
|
187
|
+
<>
|
|
188
|
+
<CommandEmpty>No rows found.</CommandEmpty>
|
|
189
|
+
<CommandGroup>
|
|
190
|
+
{rows.map((row) => {
|
|
191
|
+
const isSelected = selectedIds.includes(row.id);
|
|
192
|
+
return (
|
|
193
|
+
<CommandItem
|
|
194
|
+
key={row.id}
|
|
195
|
+
value={row.id}
|
|
196
|
+
onSelect={() => handleSelect(row.id)}
|
|
197
|
+
>
|
|
198
|
+
<Check
|
|
199
|
+
className={cn(
|
|
200
|
+
"mr-2 h-4 w-4",
|
|
201
|
+
isSelected ? "opacity-100" : "opacity-0"
|
|
202
|
+
)}
|
|
203
|
+
/>
|
|
204
|
+
<span className="truncate">{row.displayValue}</span>
|
|
205
|
+
</CommandItem>
|
|
206
|
+
);
|
|
207
|
+
})}
|
|
208
|
+
</CommandGroup>
|
|
209
|
+
</>
|
|
210
|
+
)}
|
|
211
|
+
</CommandList>
|
|
212
|
+
</Command>
|
|
213
|
+
</PopoverContent>
|
|
214
|
+
</Popover>
|
|
215
|
+
</div>
|
|
216
|
+
);
|
|
217
|
+
}
|