(ctx context.Context, raw string)
| 1791 | } |
| 1792 | |
| 1793 | func (h *BaseHandlers) resolveMemoryWorkspaceRef(ctx context.Context, raw string) (string, string, error) { |
| 1794 | trimmed := strings.TrimSpace(raw) |
| 1795 | if trimmed == "" { |
| 1796 | return "", "", NewMemoryValidationError(errors.New("workspace_id is required for workspace scope")) |
| 1797 | } |
| 1798 | if h.Workspaces != nil { |
| 1799 | resolved, err := h.Workspaces.Resolve(ctx, trimmed) |
| 1800 | if err == nil { |
| 1801 | workspaceID := strings.TrimSpace(resolved.WorkspaceID) |
| 1802 | if workspaceID == "" { |
| 1803 | return "", "", errors.New("memory: resolved workspace_id is empty") |
| 1804 | } |
| 1805 | return strings.TrimSpace(resolved.RootDir), workspaceID, nil |
| 1806 | } |
| 1807 | if !filepath.IsAbs(trimmed) { |
| 1808 | return "", "", err |
| 1809 | } |
| 1810 | } |
| 1811 | workspace, err := resolveMemoryWorkspace(trimmed) |
| 1812 | if err != nil { |
| 1813 | return "", "", err |
| 1814 | } |
| 1815 | identity, err := aghworkspace.EnsureIdentity(ctx, workspace) |
| 1816 | if err != nil { |
| 1817 | return "", "", fmt.Errorf("memory: resolve workspace identity: %w", err) |
| 1818 | } |
| 1819 | return workspace, identity.WorkspaceID, nil |
| 1820 | } |
| 1821 | |
| 1822 | func memorySelectorFromQuery(c *gin.Context) memorySelector { |
| 1823 | workspaceID := firstNonEmptyString(c.Query("workspace_id"), c.Query("workspace")) |
no test coverage detected