Commit Graph
724 Commits
Author SHA1 Message Date
Sergey KozyrenkoandCursor d97b355ce2 feat(file-manager): expand/collapse all toggle in header
Adds a chevron toggle next to the "Name" header that flips every
directory in the full tree (filter-independent). Uses the existing
overrides map via a new `setExpansion(paths, isExpanded)` bulk helper
on `useFileManagerExpansion`, so a single gesture wins over the
auto-expand-on-search behavior. Skeleton header stays in lock-step.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-09 21:25:42 +07:00
Sergey KozyrenkoandCursor 5fa3d65fe3 refactor(file-manager): replace mutating addAllToSet/removeAllFromSet with pure addAll/removeAll
The old helpers mutated the Set passed in, but the type signature
(`Set<string>`) did not communicate that — only the JSDoc did. Every
existing caller already cloned `prev` before calling, so the migration
to pure `(prev, paths) => new Set` variants is zero-cost and removes a
foot-gun. `toggleSubtreeOnSet` and `computeRowClickSelection` now
compose the pure helpers directly instead of clone-then-mutate.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-09 20:52:15 +07:00
Sergey KozyrenkoandCursor 08fe658925 docs(knowledge): explain skipNextBlockRef cycle in KnowledgeForm
Document the ref-based loop between performSave, onSaveFromDialog, and
useUnsavedChangesGuard so a cold reader can answer "why is the ref
declared after performSave?" without re-tracing the whole component.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-09 20:49:37 +07:00
Sergey KozyrenkoandCursor 4055a981cb test(file-manager): pin compareSizes behavior with directories across folders-first toggle
Lock in the contract that directories collapse to size 0 in compareSizes.
Invisible while folders-first is on, but user-visible (and easy to regress)
once the Resources page lets the user disable that partition.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-09 20:49:05 +07:00
Sergey KozyrenkoandCursor 7125834e7e refactor(frontend): data-router migration, FileManager sorting, shared utilities
App shell:
- Switch from BrowserRouter+Routes to createBrowserRouter so pages can use
  data-router-only APIs (useBlocker). Route definitions live at module scope.

FileManager:
- Sortable headers (name/size/modified) with three-state cycle, optional
  per-column sortability, controlled / uncontrolled+localStorage modes via
  the new useFileManagerSorting hook.
- isFoldersFirst toggle and recursive sortFileManagerTree pure reducer.
- formatModifiedAbsolute alongside the relative formatter; hosts switch via
  the new Resources "Relative dates" toggle.
- Mirror hover highlight while a row's context/dropdown menu is open so the
  user knows which row the menu belongs to.
- Guard row pointerdown so a touch long-press no longer stacks the row menu
  on top of the empty-area menu.

Knowledge edit page:
- Decompose into focused subcomponents (header, intro, meta fields, content,
  desktop/mobile body, leave dialog).
- Targeted useWatch on docType so the markdown editor no longer re-renders
  meta fields on every keystroke.
- New useUnsavedChangesGuard hook encapsulates useBlocker, beforeunload and
  the "Save & Leave" dialog; supports skipNextBlock for post-save navigation.

MarkdownEditor:
- Suppress echo updates from tiptap-markdown's re-serializer so RHF's
  isDirty flag stays accurate.

Shared utilities:
- lib/local-storage.ts (zod-validated getStorageItem/setStorageItem) used by
  both table-storage.ts and the new file-manager-storage.ts.
- lib/table-sort.ts#cycleColumnSort shared between Knowledges and Templates.
- hooks/use-latest-ref.ts replaces five useRef+useEffect pairs in FileManager.

DataTable:
- Filter input upgraded to InputGroup with search icon and clear button.
- Extract DataTableFilter subcomponent to drop the inline IIFE.

Resources page:
- Per-page persisted view options (folders-first, relative dates, optional
  size/modified columns) extracted into a typed ResourcesViewOptions shape
  with a centralized defaultViewOptions and a single loadViewOptions reader.
- Promote upload / new-folder buttons to the page header.

Misc:
- Replace MoreHorizontal / MoreVertical icons with Ellipsis for visual
  consistency.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-09 20:36:54 +07:00
mason5052 5af902872a docs(rfc): address Copilot review feedback on MCP client RFC
- Reword PR #268 references to talk about review feedback rather
  than the PR being rejected.
- Clarify host.docker.internal availability: not universally provided
  by the core compose stack; Docker Desktop typically resolves it,
  while Linux/operator-managed compose stacks may need an explicit
  extra_hosts: host.docker.internal:host-gateway entry or another
  controlled endpoint.
- Make the safe initial Burp example unambiguously read-only: drop
  start_active_scan from the illustrative allowlist and call out
  that active capabilities belong to a later, explicitly gated
  milestone with scope and approval controls.
- Rephrase the awkward 'PentAGI must not be inferred...' sentence
  for clarity.

Signed-off-by: mason5052 <ehehwnwjs5052@gmail.com>
2026-05-08 16:09:01 -04:00
mason5052 ba8a687cb6 docs(rfc): propose MCP client integration design
Signed-off-by: mason5052 <ehehwnwjs5052@gmail.com>
2026-05-08 15:55:23 -04:00
Dmitry Ng ba0cee43c8 fix(router): add new frontend routes for resources and knowledges to preserve route in the browser
- Introduced "/resources" and "/knowledges" routes to the frontendRoutes array in the router configuration, expanding the application's routing capabilities.
2026-05-08 20:46:47 +03:00
Dmitry Ng a9aeb81e4e refactor(resources): update MoveResourceRequest to allow empty destination
- Removed the requirement for the "destination" field in MoveResourceRequest, allowing it to be an empty string, which signifies moving to the root directory.
- Updated related documentation in swagger.json, swagger.yaml, and docs.go to reflect the new behavior.
- Adjusted the MoveResource function to handle cases where the destination is empty, ensuring proper path sanitization and resource movement semantics.
- Enhanced test cases to cover scenarios involving moving resources to the root directory and handling conflicts appropriately.
2026-05-08 20:24:39 +03:00
Dmitry Ng dc2fd43928 feat(assistants): support flowID=0 in REST API to create assistant with new flow
- Allow POST /flows/0/assistants/ to create a new flow together with the assistant, mirroring the existing GraphQL createAssistant(flowID: 0) behavior
- Require both assistants.create and flows.create permissions when flowID=0
- Add explicit flow ownership check for non-zero flowID using flows.admin scope
- Load flow data in the response by fetching it via assistant.FlowID after creation, ensuring AssistantFlow is fully populated in all cases
2026-05-08 18:54:14 +03:00
Sergey KozyrenkoandCursor 95893bf502 feat(knowledge): rich tiptap editor for content with per-panel scrolling
- replace plain textarea with a tiptap-based markdown editor (StarterKit, tiptap-markdown, placeholder) and a basic formatting toolbar so authors can edit knowledge content with rich formatting while keeping markdown as the storage format for embeddings
- introduce a reusable MarkdownEditor shared component and a tiptap Storage type augmentation
- move the save action from the input addon into the page header on the right
- give each desktop resizable panel its own internal scroll so long meta or content no longer makes the whole page scroll

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-08 17:55:38 +07:00
Sergey KozyrenkoandCursor 318acc9f77 feat(knowledge): add knowledge documents UI with list and detail pages
Wire up KnowledgesProvider with Apollo subscriptions and cache policies,
add /knowledges routes and sidebar entry, plus minor formatting cleanups
across file-manager, upload-validation and resources upload helpers.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-08 17:55:38 +07:00
Sergey KozyrenkoandCursor 012cb741ad refactor(file-manager): chevron drill-in, responsive bulk bar and tri-state toggle fix
- File manager core:
  - Chevron click on folder rows now drills in via `onOpenDirectory`
    (when set), matching the existing double-click / Enter semantics.
    Consumers that don't wire the prop keep the legacy expand/collapse
    behaviour, so flow-files / resources trees stay unchanged.
  - Bulk actions bar wraps and collapses to icon-only buttons (Cancel
    included) on small viewports so the bar stays usable on mobile.
  - Fix tri-state subtree toggle requiring two clicks when the
    directory's own path was never in the selection (e.g. user ticked
    children one-by-one). \`toggleSubtreeOnSet\` now accepts an optional
    \`rootPath\` and ignores it for the "all selected?" check, mirroring
    what \`computeDirSelectionState\` shows on the visible checkbox.
    Covered by new regression tests in \`file-manager-utils.test.ts\`.
  - Built-in icons swapped: copy-path uses \`ClipboardCopy\` instead of
    \`Copy\`; bulk \"Save as resources\" uses \`FolderOutput\` instead of
    \`BookmarkPlus\`.

- Pull dialog: flatten the container listing (\`name\` as \`path\`,
  absolute path in \`id\`) so the chevron / double-click drill into
  real subfolders instead of toggling a synthetic \`work/\` wrapper that
  has no meaningful navigation target. Selection is mapped back to
  absolute paths via a name → absolute lookup before pulling.

- Resources page: drop the focus-derived \`currentDir\` plumbing —
  toolbar mkdir / upload always target the library root, row context
  menu loses \"Upload files here\" and renames \"New folder here\" to
  \"New folder\". Page wraps in \`h-[calc(100dvh-3rem)]\` so the bulk
  bar stays inside the viewport. Tooltips simplified accordingly.

- Flow files toolbar: replace the standalone Info icon with rich
  per-button tooltips that explain where each gesture lands
  (/work/uploads, /work/resources, separate Container snapshot area);
  upload button uses the standard \`Upload\` glyph.

- Attach resources dialog: switch the ad-hoc footer to a proper
  \`DialogFooter\` with responsive layout, tighten the dialog title.

- \`Dialog\` / \`Sheet\` footers always apply the inter-button gap,
  not only at the \`sm+\` breakpoint.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-08 17:55:37 +07:00
Sergey KozyrenkoandCursor d743bf5105 refactor(flow-files): share upload validator and rely on subscriptions for cache sync
Two cleanups closing the remaining P2/P3 gaps in the flow-files / resources
upload + delete paths.

A.4 — unify upload-batch validation
- New shared validator at `frontend/src/lib/upload-validation.ts` (with
  tests) exposing `validateUploadBatch(files, limits)`. Mirrors the
  per-file / per-batch / empty-file rules enforced by both backends
  (`pkg/resources/resources.go`, `pkg/flowfiles/files.go`).
- `useResourcesUpload` migrated off its private validator onto the shared
  helper; behaviour and toast strings unchanged.
- `useFlowFilesUpload` now runs the same preflight before constructing
  the FormData. Hitting any of the 300 MB / 1000 files / 2 GB / 0-byte
  rules surfaces a synchronous toast instead of a network round-trip
  followed by a generic 413.
- Added `FLOW_FILES_MAX_FILE_SIZE_MB`, `FLOW_FILES_MAX_UPLOAD_TOTAL_SIZE_MB`
  and `FLOW_FILES_MAX_UPLOAD_FILES_PER_REQUEST` to flow-files-constants
  alongside the existing resources constants — kept as a separate set so
  the two backends can diverge later without touching unrelated call
  sites.

C.2 — drop redundant refetchFiles() after flow-file mutations
- The backend already publishes per-file flowFileAdded / flowFileDeleted
  events (with directory expansion on delete), `lib/apollo.ts` already
  maps them through the universal subscriptionCacheLink, and
  `useFlowFilesRealtime` already wires the three subscriptions. Only the
  imperative `await refetchFiles()` in upload/delete plus the
  `onSuccess={refetchFiles}` props on pull/attach dialogs were left over
  from the pre-subscription era.
- Dropped `refetchFiles` from `useFlowFilesUpload` and `useFlowFilesDelete`
  param types and removed the matching `await` calls. Added optional
  `onAfterDelete` to the delete hook (mirrors `useResourcesDelete`) for
  callers that want a UI hook without driving a refetch.
- Made `onSuccess` optional on `FlowFilesPullDialog` and
  `FlowFilesAttachResourcesDialog`; removed the `onSuccess={refetchFiles}`
  passthroughs in `flow-files.tsx`. The pull dialog's internal
  `refetchListing` over the container listing (a separate hook) is kept.

Verified: vitest 140/140, eslint clean on touched files, tsc shows only
the same pre-existing errors as before this change (`User.ts`/`user.ts`
casing; `single possibly undefined` in unrelated delete branches).

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-08 17:55:37 +07:00
Sergey KozyrenkoandCursor 3540407aa6 feat(frontend): atomic batch resource ops and context-aware uploads
- Send `sources[]` (was single `source`) to /resources/copy,
  /resources/move and /files/to-resources so multi-select operations
  execute in one DB transaction; replace the per-feature 409 aggregation
  state and the now-unused `resources-conflict-dialog` with the shared
  `useOverwriteAction` workflow returning `OverwriteOutcome`.
- Extend `FileManager` with `emptyAreaActions` (right-click context menu
  over the tree's empty area), `appliesToFiles` filter (companion to
  `appliesToDirs`), `onActiveRowChange` focus reporting and row-level
  external-file drop (`onExternalFileDrop`).
- `useFilesDragAndDrop`: capture-phase `onDropCapture` resets the
  internal counter / `isDragging` flag before any descendant claims the
  drop with `stopPropagation`, fixing the page-level upload overlay
  staying stuck after a row-level drop.
- `useResourcesUpload` gains `defaultDir` (read via ref so `uploadFiles`
  stays reference-stable) and `openFilePickerForDir` so toolbar /
  sidebar / CTA pickers upload into the focused folder by default and
  per-row "Upload here" actions can target a specific directory.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-08 17:55:37 +07:00
Sergey KozyrenkoandCursor 76cb4c1283 refactor(frontend): unify overwrite flow and atomic multi-path file APIs
- Extract shared OverwriteConfirmDialog, OverwriteCtaButtons, and
  useOverwriteAction hook; reuse across Pull, Attach, Promote, Move, Copy
  dialogs to drop per-dialog overwrite switches in favour of explicit
  "… with overwrite" CTA + Replace-all confirm.
- Move file-manager into components/shared, add bulkDownloadAction and
  onOpenDirectory navigation override for navigation-style browsers.
- Switch flow files / resources delete and download to atomic multi-path
  endpoints via paths[]= query, drop Promise.allSettled fan-out.
- Add useFlowContainerFiles + container browse in Pull dialog with
  client-side conflict preflight (flow-files-conflicts).
- Extract getApiErrorStatusCode helper to deduplicate 409 detection.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-08 17:55:36 +07:00
Sergey KozyrenkoandCursor 0c65579066 feat(file-manager): extensible bulk actions API and additive shift-click selection
Replace the single `onBulkDelete` prop with a generic `bulkActions` array so the
host owns which gestures appear in the footer bar. Built-in helpers (`bulkDeleteAction`,
`bulkCopyPathsAction`, `bulkMoveAction`, `bulkCopyAction`, `bulkPromoteAction`)
match the row-action pattern; each entry supports inline button or trailing
overflow menu, optional confirm dialog, isDisabled / isHidden predicates, and
receives the deduped FileNode[]. The bar also surfaces a cumulative size
summary alongside the item count.

Fix Shift+click range selection so it matches user expectations and the rest
of the file-manager's folder semantics:

- Range clicks are now ADDITIVE: the visible-order slice is unioned onto the
  previous selection instead of replacing it, so Cmd-clicked picks, earlier
  shift-ranges, and explicitly clicked folder subtrees survive a follow-up
  Shift+click.
- Folders inside the slice expand to their full subtree via `dirSubtreePaths`,
  mirroring the contract of a plain folder click. Without this, a Shift+click
  across collapsed sibling folders left the folder paths in `selectedPaths`
  but rendered their tri-state checkboxes as unchecked because no descendants
  had been added to the selection.
- Anchor preservation across chained Shift+clicks is unchanged; toggle/single
  still move the anchor.

Migrate `flow-files`, `resources`, and the move/copy/promote dialogs to the
new `bulkActions` API.

Tests: 131 passing — covers reverse direction, expanded vs. collapsed folders,
nested folders, mixed file/folder anchors, empty folders in range, omitted
`dirSubtreePaths` (tree-less callers), anchor=null and off-screen anchor
fallbacks, chained shift-clicks accumulating subtrees, toggle + shift-click
combinations, idempotent same-row range clicks, and the additive contract's
explicit divergence from Finder/Explorer (range never shrinks the selection).

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-08 17:55:36 +07:00
Dmitry Ng a348e41a31 feat(settings): add version and isDevelopMode fields to Settings model and GraphQL schema
- Introduced new fields `version` and `isDevelopMode` in the Settings model to provide application versioning and development mode status.
- Updated GraphQL schema and resolvers to support the new fields, ensuring they are accessible via the Settings query.
- Enhanced Swagger documentation to reflect the changes in the Settings API endpoint.
- Added necessary validation and response handling for the new fields in the Settings service.
2026-05-08 13:06:07 +03:00
mason5052 2d407b928e docs(rfc): clarify lifecycle, terminal semantics, and webhook event names
Address Copilot review feedback on PR #306:

- Lifecycle diagram: show running <-> waiting (waiting is a paused state that resumes to running when user input arrives) and document that both running and waiting can reach the terminal statuses finished or failed.

- Replace overloaded 'finished' wording with explicit 'terminal' semantics throughout. finished and failed remain distinct terminal statuses; the queue and webhook layers treat both as terminal.

- Align webhook event names with status terminology: flow.finished for success, flow.failed for failure. Update payload example accordingly and note the failed-flow shape.

Signed-off-by: mason5052 <ehehwnwjs5052@gmail.com>
2026-05-07 13:18:34 -04:00
mason5052 c0e9ed74fd docs(graphiti): use user-facing env vars for OpenAI endpoint
Address Copilot review feedback on PR #305: the 'Current Limitations' bullet for the Graphiti integration mixed PentAGI's user-facing .env variables with the container env vars defined in docker-compose-graphiti.yml.

Reword both README.md and backend/docs/config.md to lead with the user-facing OPEN_AI_KEY and OPEN_AI_SERVER_URL .env variables and explicitly note that docker-compose-graphiti.yml maps them into the bundled vxcontrol/graphiti container as OPENAI_API_KEY and OPENAI_BASE_URL. Operators set the .env variables; the container variables are an implementation detail.

Signed-off-by: mason5052 <ehehwnwjs5052@gmail.com>
2026-05-07 13:16:01 -04:00
mason5052 ad7d2b12ce docs(flows): refine prompt block, snapshot source, and filename limit wording
Address Copilot review feedback on PR #304:

- Clarify the UserFiles template variable produces a <task_files> XML block with <uploads>/<resources> nested sections (matches flowfiles.FileListingForPrompt output).

- Distinguish that uploads/resources mirror to /work/uploads/ and /work/resources/, while container snapshots can originate from arbitrary container paths and are cached only under container/ on the flow side.

- Note that the 255 filename limit is enforced by len(name) <= 255, i.e. byte-length, so it is roughly 255 ASCII characters.

Signed-off-by: mason5052 <ehehwnwjs5052@gmail.com>
2026-05-07 13:11:54 -04:00
mason5052 295e7d3b01 docs(rfc): propose persistent flow queue and completion webhooks
Proposes a design direction for native flow concurrency control and
completion notifications. The RFC follows the maintainer's relocated
proposal pattern at examples/proposals/<topic>.md and explicitly
builds on the lessons from PR #268 (rejected because the in-memory
queue was hidden lifecycle state).

The RFC covers:

- Goals limited to capping concurrent flows, persisting queued flows
  as first-class lifecycle, replacing external polling with at-least-
  once webhooks, and preserving the existing createFlow contract.
- Non-Goals that explicitly forbid hidden in-memory queues, multi-
  tenant scheduling, generic event bus features, and changing the
  meaning of 'finished' for tasks/subtasks/toolcalls.
- Design Principles for persistence, visibility, manageability,
  explicit promotion, clear finished semantics, and at-least-once
  delivery.
- A proposed concurrency model with a new persisted 'queued' status,
  a single MAX_CONCURRENT_FLOWS knob, an explicit promoter, and
  full UI/API visibility plus user cancellation.
- A proposed completion webhook model with per-flow and global URLs,
  HMAC-SHA256 signatures, persisted deliveries, bounded retries,
  and SSRF mitigations.
- Storage and API surface sketches that do not commit to a final
  schema.
- Open Questions covering per-user limits, blocking semantics on
  createFlow, signature alignment with the issue #235 receipt
  direction, and behavior of resources/uploads against queued flows.
- A Suggested First Milestone that lands the queue end-to-end before
  webhooks, to keep PR sizes reviewable.

This is documentation only. No runtime code, schema, GraphQL, REST,
or UI behavior changes here.

Refs #298

Signed-off-by: mason5052 <ehehwnwjs5052@gmail.com>
2026-05-07 12:28:06 -04:00
mason5052 fa53a4e1d2 docs(graphiti): note beta status and OpenAI-only provider limitation
The Graphiti container shipped with docker-compose-graphiti.yml only
takes OPENAI_API_KEY and OPEN_AI_SERVER_URL for entity extraction.
PentAGI configures many other LLM providers (Anthropic, Google AI,
AWS Bedrock, DeepSeek, GLM, Kimi, Qwen) for the main flow, but those
credentials are not consumed by Graphiti today. Until that changes,
operators need to plan around an OpenAI-compatible endpoint just for
the knowledge graph.

This commit makes the limitation visible in two surfaces without
changing runtime behavior:

- README.md: Adds a beta callout at the top of the Knowledge Graph
  Integration section and a new 'Current Limitations' subsection
  covering provider scope, fixed model, independent billing, and the
  lack of an in-app graph explorer.
- backend/docs/config.md: Mirrors the beta callout under Graphiti
  Knowledge Graph Settings and adds a 'Current Limitations (Beta)'
  subsection with the same constraints, so config-focused readers
  see the same message.

Both notes explicitly point at the simple fallback: leave
GRAPHITI_ENABLED=false if the deployment cannot reach an
OpenAI-compatible endpoint.

Refs #187

Signed-off-by: mason5052 <ehehwnwjs5052@gmail.com>
2026-05-07 12:22:38 -04:00
mason5052 e869445430 docs(flows): document flow-scoped Files tab, sources, and current limits
Add a How-to subsection that describes the Files tab on a flow page
without restating implementation details. The new section covers:

- The three file sources surfaced in the UI (uploads, resources,
  container snapshots) with their exact action labels.
- The on-host layout under {dataDir}/flow-{id}-data/ and the
  corresponding container paths /work/uploads and /work/resources.
- Per-file actions (Download, Copy path, Save as resource, Delete)
  and the Pull action's disabled state when the container is not
  running.
- Automatic injection of uploaded files and attached resources into
  agent system prompts via the <UserFiles> block, so users understand
  how the assistant sees their files.
- Current limits (300 MB / 1000 files / 2 GB / 255-char names) and
  current limitations, including that flow deletion does not yet
  archive or remove the flow data directory on disk.

This is a documentation-only change and does not introduce or change
runtime behavior.

Refs #193

Signed-off-by: mason5052 <ehehwnwjs5052@gmail.com>
2026-05-07 12:19:30 -04:00
mason5052 3278c62b96 fix(controller): avoid JSON round-trip and N+1 prompter loads
Address two reviewer concerns on the issue #300 follow-up:

* Replace the `DumpTemplates()` -> `json.Unmarshal` round-trip in
  buildUserPrompter with a new `templates.LoadDefaultPromptsMap()`
  helper that returns the embedded defaults as a `PromptsMap`
  directly. `defaultPrompter.DumpTemplates()` now delegates to the
  same helper, so the JSON output for that API is unchanged.
* Add an optional `prompter` field to `assistantWorkerCtx`. When
  set, `LoadAssistantWorker` reuses it instead of re-querying
  `GetUserPrompts` and re-merging defaults. `LoadFlowWorker`
  populates it once per flow load so multi-assistant flows pay the
  DB+merge cost a single time.

Tests updated to match the new pure-merge `buildUserPrompter`
signature; behavior for users with no overrides is unchanged.

Signed-off-by: mason5052 <ehehwnwjs5052@gmail.com>
2026-05-06 22:30:26 -04:00
mason5052 73d5b8366d fix: drop unverified ollama tags and broaden hint context
Address review on PR #303.

- helpers.go: remove the concrete model examples (llama3.1, qwen2.5, mistral-nemo) from the Ollama tools-unsupported hint. PentAGI does not verify Ollama model capabilities from upstream metadata, so a hard-coded list of supposedly tool-capable tags is risky and ages poorly. The hint now points users to select an Ollama model whose own metadata advertises tool/function calling support.

- helpers.go: rewrite the comment and error wording so it is no longer flow-only. The helper is shared by NewFlowProvider and NewAssistantProvider, so the message now refers to tool execution in flows and assistant sessions, and the doc-comment notes that wording must stay context-neutral.

- helpers_test.go: tighten TestWrapToolCallIDTemplateError to match the new wording, ban the previous concrete model tags, and ban flow-only language ('flow execution', 'flow creation'). The test still verifies that the original underlying error is wrapped via errors.Is.

Signed-off-by: mason5052 <ehehwnwjs5052@gmail.com>
2026-05-06 22:11:12 -04:00
mason5052 552eda8746 fix: clarify Ollama models without tool support
## Summary
Surface an actionable hint when an Ollama model that does not support
tool/function calling is selected for a flow or assistant session, so
users do not have to parse a five-wrap-deep "failed to determine tool
call ID template" stack trace to figure out why flow creation fails.

## Problem
A user on an Ollama deployment of `gemma3:27b-it-q4_K_M` reports that
the Provider/LLM test passes the basic completion checks but flow
creation fails with:

  failed to create flow worker: failed to get flow provider: failed
  to determine tool call ID template: failed to collect tool call ID
  samples: all sample collection attempts failed: failed to call LLM:
  400 Bad Request: registry.ollama.ai/library/gemma3:27b-it-q4_K_M
  does not support tools

The underlying signal "does not support tools" is emitted by the
Ollama API itself; PentAGI buries it five wraps deep, so the user is
left guessing whether the issue is configuration, networking, or
something internal to PentAGI.

## Solution
Add an unexported helper `wrapToolCallIDTemplateError` in
`pkg/providers/helpers.go` that detects the upstream "does not support
tools" substring and prepends a one-sentence guidance message naming
the constraint and a few known-good Ollama tags
(`llama3.1`, `qwen2.5`, `mistral-nemo`). All other errors keep the
existing wording. The original error is preserved via `%w` so log
spans, langfuse traces, and any future `errors.Is/As` callers continue
to work.

Both call sites in `pkg/providers/providers.go`
(`NewFlowProvider`, `NewAssistantProvider`) now route through the
helper.

No schema, API, or DB changes. No new lifecycle state. No background
work. The behavior change is the wording of one error string in one
upstream-defined failure case.

## User Impact
- Users who pick an Ollama model without tool support get a clear,
  actionable error during flow / assistant creation instead of a deep
  stack trace.
- Users on tool-capable models (Anthropic, OpenAI, Bedrock, and
  tool-capable Ollama tags) see no behavioral or message change.
- No restart, migration, or configuration step required.

## Test Plan
- New table-driven test `TestWrapToolCallIDTemplateError` covers:
  - nil error -> nil
  - upstream "does not support tools" chain (matching the real five-
    wrap shape) -> actionable message + `errors.Is` round-trips to the
    original error
  - generic non-tools error -> existing wrap text preserved, no
    new guidance appended
- `go test ./pkg/providers/...` passes locally.
- `go build ./...` and `go vet ./pkg/providers/...` clean.

Closes #280

Signed-off-by: mason5052 <ehehwnwjs5052@gmail.com>
2026-05-06 18:30:32 -04:00
mason5052 08c050ce21 fix: apply custom prompts to new sessions
Custom prompts saved via the Settings -> Prompts UI are persisted to the
database, but every assistant and flow session creation path was using
templates.NewDefaultPrompter() with a leftover TODO, so user overrides
never reached the agents and Langfuse traces always showed the defaults.

Add a controller-side helper that loads the user's saved prompts and
overlays them on the compiled defaults. Prompt types the user has not
customized continue to use the defaults; an empty body row is treated
as no override (the UI uses delete to reset). A database error fails
session creation explicitly instead of silently falling back.

Wire the helper into the four affected call sites in NewAssistantWorker,
LoadAssistantWorker, NewFlowWorker, and LoadFlowWorker.

Closes #300

Signed-off-by: mason5052 <ehehwnwjs5052@gmail.com>
2026-05-06 18:10:17 -04:00
Dmitry Ng 6890584c64 feat(resources): add multi-source move, copy and flow-file promotion
- Add Sources []string to MoveResourceRequest, CopyResourceRequest and AddResourceFromFlowRequest; merged with Source, deduplicated; multi-source uses destination as base dir and runs in a single atomic DB transaction
- Fix MoveResource response to return Added + Updated (not Updated only) so Apollo cache receives new parent directory entries alongside moved items
- Add missing errResourceNotFound case in CopyResource (was 500 instead of 404)
- Cover all new behaviour with table-driven tests (basename conflict, force overwrite, missing source, empty input, dir-into-itself guard, etc.)
2026-05-06 17:03:13 +03:00
Dmitry Ng 3a52079278 feat(knowledge): add pgvector knowledge base management
- GraphQL/REST CRUD + semantic search for knowledge documents
- KnowledgeStore with admin/user-scoped filtering, re-embedding on update
- Real-time subscriptions (created/updated/deleted) per user and admin
- user_id tracking in all agent-stored documents (guide/answer/code/memory)
- sqlc queries, goose migrations, privilege grants, user_id backfill
- Memory cleanup on flow deletion; stale orphan purge via migration
- Unit tests for all KnowledgeStore operations including security cases
- Frontend GraphQL schema and TypeScript types regenerated
2026-05-05 01:09:20 +03:00
Dmitry Ng ca9f4a0211 feat: add multi-path support and ZIP improvements across file APIs
- Added `paths[]` query/body parameter to DeleteFlowFile, DownloadFlowFile,
  GetFlowContainerFiles, PullFlowFiles, ListResources, DeleteResource, and
  DownloadResource; single `path` parameter retained for backward compatibility.
- Introduced `DeduplicatePaths` in flowfiles package with coverage-based
  deduplication (parent covers children), path normalization, and traversal safety.
- Added `ZipRelativePaths` to create ZIP archives from cache-relative paths,
  sharing `zipWriteFile` helper with refactored `ZipDirectory`.
- Switched all ZIP and single-file responses to buffered `DataFromReader` with
  explicit `Content-Length`, fixing Swagger UI download rendering.
- Expanded response payloads: delete and pull operations now enumerate all
  affected nested files; list responses include ancestor directories for tree
  completeness.
- Extended test coverage across flowfiles, flow_files, and resources packages
  with batch, deduplication, atomicity, Docker exec, and security scenarios.
2026-05-04 14:32:39 +03:00
Dmitry Ng f57e988586 feat(cast): add JSON control character sanitization for tool call arguments
- Implemented `SanitizeJSONControlChars` to escape literal control characters in JSON string values, ensuring compliance with the JSON specification.
- Enhanced `SanitizeToolCallArguments` method to apply sanitization across tool call arguments in the chain.
- Added comprehensive tests for both sanitization functions to validate behavior with various input scenarios.
2026-05-03 00:48:47 +03:00
Dmitry Ng 9cd52b102a fix(csum): prevent out-of-range errors in recent section determination
- Updated the logic in `determineRecentSectionsToKeep` to clamp the lower bound of the recent sections to keep, ensuring it does not exceed the available sections. This prevents potential out-of-range errors when `keepQASections` is greater than the total number of sections.
2026-05-03 00:47:47 +03:00
Dmitry Ng 46c7807af9 fix(main): router initialization
- Updated router initialization to include the Docker client
2026-05-03 00:47:04 +03:00
Dmitry Ng e370450dab feat(browser): enhance HTML and MD content handling with warnings for small content and errors for binary URLs
- Updated `getHTML` and `getMD` methods to return warnings for small content instead of errors.
- Implemented checks for binary URLs, returning descriptive errors when such URLs are encountered.
- Added new tests to validate the updated behavior for small and empty content handling.
2026-05-03 00:45:27 +03:00
Dmitry Ng b254ff6f90 refactor(flow_manager): improve error handling for running tasks 2026-05-03 00:43:51 +03:00
Dmitry Ng 75eb8e0f1e fix(aslog): implement TryLock to prevent deadlock in workerMsgUpdater
- Added TryLock mechanism to avoid deadlock situations when reading from the channel while the mutex is held.
- Enhanced timer handling to reset when the mutex is not available, ensuring continuous operation of the stream.
2026-05-03 00:42:17 +03:00
Dmitry Ng c068d86bf0 feat(docker): update Dockerfile and add new vLLM configurations
- Added new provider configurations for vLLM Qwen 3.6 in both thinking and non-thinking modes.
- Updated the Dockerfile to include the new configuration files for vLLM Qwen 3.6 and ensure proper setup for deployment.
2026-05-02 18:57:42 +03:00
Sergey KozyrenkoandCursor 268732f610 feat(file-manager): add subtree selection, open gesture, and parent-dir drop forwarding
- Folder rows now surface a tri-state checkbox derived from descendant selection;
  clicking / shift-clicking / toggling a folder flips the entire subtree in one
  gesture, including descendants of a collapsed folder.
- Files get a new onOpen prop, fired on double-click and Enter; directories keep
  expanding/collapsing. The resources page wires it to the existing download flow.
- Drop on a file row forwards to its parent folder so the whole folder acts as a
  single drop zone (Finder/Explorer semantics), with a shared drag-enter counter
  so highlight stays stable when moving the cursor between sibling rows.
- Extract pure data layer into useFileManagerData and pure selection reducers
  (computeRowClickSelection / computeToggleSelection / computeToggleSelectAll /
  computeDirSelectionState) into file-manager-utils; bundle per-tree row props
  into display / handlers so memoized rows stay reference-stable across parent
  re-renders, keyboard expansion, and selection changes.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-02 17:24:42 +07:00
Dmitry Ng ba14913c0e refactor: standardize resource ID handling and improve flow file management
- Updated resource ID handling to ensure consistent string coercion for numeric IDs across components.
- Enhanced sorting of resources in the FlowForm to use alphabetical order based on path.
- Improved resource attachment logic in the FlowFilesAttachResourcesDialog to avoid deduplication of descendants.
- Introduced utility functions for converting REST resource entries to a consistent format for Apollo cache.
- Adjusted upload handling to ensure proper type consistency between REST and GraphQL responses.
- Refactored promote functionality to align with updated resource ID handling and improve clarity in parameters.
2026-05-01 16:11:45 +03:00
Dmitry Ng 8830ae7010 fix: update resource handling and API documentation
- Adjusted descriptions in API documentation to clarify paths for uploads, resources, and containers.
- Updated data models to use consistent naming conventions (e.g., `isDir` to `is_dir`, `modifiedAt` to `modified_at`).
- Changed resource ID types from string to uint64 for better consistency across the application.
- Enhanced flow file upload functionality to support batch processing of resource files.
- Removed deprecated code related to resource entry responses in tests.
2026-05-01 16:11:09 +03:00
Dmitry Ng 629c018a68 fix: bug with retrieving resources recursive via graphql 2026-05-01 16:09:06 +03:00
Dmitry Ng b6f7fd7ef8 feat: enhance task and subtask handling with interruption management 2026-05-01 16:05:12 +03:00
Sergey Kozyrenko 3da56244dd feat: integrate user resources into flows and polish file manager
- Replace resources feature mocks with real GraphQL + REST integration
  (Apollo subscriptions-backed cache, dedicated hooks for search, upload,
  copy, move, mkdir, delete, plus conflict / mkdir / copy / move dialogs
  and a shared FileDropZone UI component).
- Let flows attach user resources on creation and in chat messages:
  FlowForm exposes resourceIds as a form field with a multi-select
  dropdown (file/folder icons), wired through createFlow, createAssistant,
  putUserInput and callAssistant mutations.
- Add attach-resources and save-as-resource (promote) dialogs to the
  flow files page; unify drag-and-drop via a shared
  hooks/use-files-drag-and-drop.
- Harden file manager: align skeleton layout (grid + column config) with
  real rows, extract use-file-manager-dnd, add group selection state and
  tree-node accessibility fixes.
- Normalize numeric id/userId from REST /resources/ responses to strings
  so GraphQL ID-typed consumers (zod-validated resource picker) work.
  Marked with TODO(backend) for removal once the REST endpoint matches
  the GraphQL ID scalar.
- Ignore *.tsbuildinfo artifacts.

Made-with: Cursor
2026-05-01 04:34:42 +07:00
Sergey Kozyrenko 0c412cedf9 refactor(flow-files): naming 2026-05-01 04:34:42 +07:00
Sergey Kozyrenko ca747b867a chore: remove unused shadcn AI and crud reference components
Drops `components/ai/file-tree.tsx` and `components/blocks/{crud,skeleton}/*`
reference snippets that were never imported anywhere; the real
file manager lives under `components/file-manager/` and is the only
implementation in use.

Made-with: Cursor
2026-05-01 04:34:41 +07:00
Sergey Kozyrenko f35d2cc0ae refactor(file-manager): polish API, accessibility, and naming
- split monolithic FileManager into FileManagerTreeNode, FileManagerBulkActionsBar, and useFileManagerKeyboardNavigation
- group FileManagerProps columns/search into nested configs and rename visibility booleans from show* to is*Visible per project convention
- replace abbreviations (idx, i, Sep, Item) with full names across components, hooks, and tests
- add ARIA tree-pattern attributes (aria-level, aria-posinset, aria-setsize, aria-multiselectable) and fix aria-hidden hiding the Select-all checkbox
- add labels.formatModified to localize the date column
- make walkTree strictly pure by hiding its internal accumulator
- move side effects out of the setState updater in useFileManagerSelection
- drop redundant stopPropagation in favor of the data-fm-skip-row-click marker

Made-with: Cursor
2026-05-01 04:34:41 +07:00
Sergey Kozyrenko 58f3c09cb0 chore: add shadcn AI and crud reference components
- vendor the shadcn ai/file-tree primitive (recursive collapsible tree with shared expand/select context) for future AI chat surfaces
- vendor the shadcn crud-file-manager and skeleton-file-manager demo blocks as design references; not wired into any route yet

Made-with: Cursor
2026-05-01 04:34:41 +07:00
Sergey Kozyrenko 929ee4e8c2 style: reformat flow-form long lines
- collapse multi-line imports and helpers in flow-form back onto single lines per the active prettier config; no behavioral changes

Made-with: Cursor
2026-05-01 04:34:41 +07:00
Sergey Kozyrenko 2b8d4186c6 feat: support async handlers in ConfirmationDialog
- handleConfirm now accepts () => Promise<void> | void; the dialog awaits the promise before closing
- show a Loader2 spinner on the confirm button while the handler is in flight, and disable both confirm and cancel
- block onOpenChange and outside-clicks while processing so the dialog can't be dismissed mid-action
- caller no longer needs to manage its own loading state for confirm-then-async flows

Made-with: Cursor
2026-05-01 04:34:40 +07:00